[PATCH] Fix MIPS tri-arch build

2012-04-28 Thread Aurelien Jarno
Hi all,

Since patch [1] has been applied, that is in GCC 4.7, it's not possible
to build a tri-arch GCC (o32, n32, 64), using mips-linux-gnu as the host
triplet (that is defaulting to o32). In that case mips/t-tpbit is not 
included anymore, and while the build succeeds, the resulting 
libgcc_s.so.1 has the following  functions as undefined:

  1697: 0004d940 0 FUNCGLOBAL DEFAULT  UND __trunctfsf2
  1698: 0004d930 0 FUNCGLOBAL DEFAULT  UND __subtf3
  1699: 0004d920 0 FUNCGLOBAL DEFAULT  UND __floatsitf
  1704: 0004d900 0 FUNCGLOBAL DEFAULT  UND __fixunstfsi
  1716: 0004d8f0 0 FUNCGLOBAL DEFAULT  UND __lttf2
  1722: 0004d8d0 0 FUNCGLOBAL DEFAULT  UND __trunctfdf2
  1728: 0004d880 0 FUNCGLOBAL DEFAULT  UND __divtf3
  1731: 0004d860 0 FUNCGLOBAL DEFAULT  UND __addtf3
  1737: 0004d830 0 FUNCGLOBAL DEFAULT  UND __netf2
  1746: 0004d800 0 FUNCGLOBAL DEFAULT  UND __floatunsitf
  1747: 0004d7f0 0 FUNCGLOBAL DEFAULT  UND __eqtf2
  1751: 0004d7d0 0 FUNCGLOBAL DEFAULT  UND __multf3


The patch below fixes that by including mips/t-tpbit when long double is
16 bytes long, instead of detecting that using the host triplet.

Aurelien


[1] http://gcc.gnu.org/ml/gcc-patches/2011-07/msg00927.html


2012-04-28  Aurelien Jarno  

* config.host (mips64*-*-linux*, mipsisa64*-*-linux*): Remove. 
(mips*-*-linux*): Include mips/t-tpbit when long double is 
16 bytes long. 

Index: libgcc/config.host
===
--- libgcc/config.host  (révision 186921)
+++ libgcc/config.host  (copie de travail)
@@ -728,15 +728,13 @@
;;
 mips*-*-netbsd*)   # NetBSD/mips, either endian.
;;
-mips64*-*-linux* | mipsisa64*-*-linux*)
-   extra_parts="$extra_parts crtfastmath.o"
-   tmake_file="${tmake_file} t-crtfm mips/t-mips16 mips/t-tpbit"
-   md_unwind_header=mips/linux-unwind.h
-   ;;
 mips*-*-linux*)# Linux MIPS, either endian.
extra_parts="$extra_parts crtfastmath.o"
tmake_file="${tmake_file} t-crtfm mips/t-mips16"
md_unwind_header=mips/linux-unwind.h
+   if test "${ac_cv_sizeof_long_double}" = 16; then
+   tmake_file="${tmake_file} mips/t-tpbit"
+   fi
;;
 mips*-sde-elf*)
tmake_file="$tmake_file mips/t-crtstuff mips/t-mips16"

-- 
Aurelien Jarno  GPG: 1024D/F1BCDB73
aurel...@aurel32.net http://www.aurel32.net


Re: [PATCH] Fix MIPS tri-arch build

2012-04-28 Thread Richard Sandiford
Aurelien Jarno  writes:
> 2012-04-28  Aurelien Jarno  
>
>   * config.host (mips64*-*-linux*, mipsisa64*-*-linux*): Remove. 
>   (mips*-*-linux*): Include mips/t-tpbit when long double is 
>   16 bytes long. 

Thanks, applied to trunk and 4.7 branch.

Richard


[PATCH] pr51020 Fix invalid options validation for ARM target

2012-04-28 Thread Alexey Kravets
Hi guys,
Please, take a look at this patch. It fixes the invalid star symbol
processing in validate_switches function reported in GCC bugzilla:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51020

With this patch invalid options are no  longer accepted by the 
compiler (see new testcase for more details).
It showed no regressions on GCC-4.6.3 on ARM.

ChangeLog:
  * gcc/gcc.c(validate_switches): Reset starred flag.
  * gcc/testsuite/gcc.target/arm/pr51020.c: New test.
-- 
Alexey Kravets
a.krav...@samsung.com
local ext. 3964 
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 75f522e..e3c8609 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -7023,11 +7023,12 @@ validate_switches (const char *start)
   size_t len;
   int i;
   bool suffix = false;
-  bool starred = false;
+  bool starred;
 
 #define SKIP_WHITE() do { while (*p == ' ' || *p == '\t') p++; } while (0)
 
 next_member:
+  starred = false;
   SKIP_WHITE ();
 
   if (*p == '!')
diff --git a/gcc/testsuite/gcc.target/arm/pr51020.c b/gcc/testsuite/gcc.target/arm/pr51020.c
new file mode 100644
index 000..ac77dc1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/pr51020.c
@@ -0,0 +1,5 @@
+/* PR 51020 */
+/* { dg-do compile { target arm*-*-* } } */
+/* { dg-options "---" { target arm*-*-* } } */
+int main() {return 0;}
+/* { dg-error "unrecognized option '---'" ""  { target *-*-* } 0 } */
-- 
1.7.5.4



signature.asc
Description: Digital signature


Re: [RFH / Patch] PR 51222

2012-04-28 Thread Paolo Carlini

Hi,

On 04/28/2012 05:24 AM, Jason Merrill wrote:

On 04/27/2012 09:42 PM, Paolo Carlini wrote:

In particular about the exact meaning of the FIXME? More generally, is
the issue here matter of compile-time optimization? Like we want to save
work when we actually *know* the type even in template context? (then
looks like type_dependent_expression_p isn't really what we want...)
It's more of a mangling issue.  If the type is 
instantiation-dependent, we should mangle it as written; if not, we 
mangle the real type. Currently we don't test for 
instantiation-dependence, so we get this wrong; your change would go 
too far in the other direction.
Thanks for the clarification, essentially I was completely missing the 
concept of "instantiation-dependent", so far isn't used much, besides a 
block in pt.c (which I noticed just now).


In the specific case here at issue we have problems with DELETE_EXPR 
(either naked or wrapped in COMPOUND_EXPR) with NEW_EXPR as op0: the 
whole expression isn't type_dependent because DELETE_EXPR immediately 
isn't, but clearly can be instantiation dependent. Then, I guess the way 
I'm proposing to handle this is by starting some sort of embryonic 
instantiation_dependent_expression_p and using it only here, for now, 
like the attached (which passes on x86_64-linux). What do you think?


Thanks,
Paolo.



Index: testsuite/g++.dg/cpp0x/decltype37.C
===
--- testsuite/g++.dg/cpp0x/decltype37.C (revision 0)
+++ testsuite/g++.dg/cpp0x/decltype37.C (revision 0)
@@ -0,0 +1,101 @@
+// PR c++/51222
+// { dg-options -std=c++11 }
+
+template
+struct add_rref {
+  typedef T&& type;
+};
+
+template<>
+struct add_rref {
+  typedef void type;
+};
+
+template
+typename add_rref::type declval();
+
+template()))
+>
+auto f(int) -> char;
+
+template
+auto f(...) -> char(&)[2];
+
+template
+auto g(int) -> char;
+
+template
+auto g(...) -> char(&)[2];
+
+template
+auto f2(int) -> decltype(::delete ::new T(declval()), char());
+
+template
+auto f2(...) -> char(&)[2];
+
+template
+auto g2(int) -> decltype(::delete ::new T(), char());
+
+template
+auto g2(...) -> char(&)[2];
+
+struct C { };
+
+struct A {
+  virtual ~A() = 0;
+};
+
+struct D1 {
+  D1() = delete;
+};
+
+struct D2 {
+  ~D2() = delete;
+};
+
+static_assert(sizeof(g(0)) == 2, "Ouch");
+static_assert(sizeof(g(0)) == 2, "Ouch");
+static_assert(sizeof(g(0)) == 2, "Ouch");
+static_assert(sizeof(g(0)) == 2, "Ouch");
+static_assert(sizeof(g(0)) == 2, "Ouch");
+static_assert(sizeof(g(0)) == 2, "Ouch");
+static_assert(sizeof(g(0)) == 2, "Ouch");
+static_assert(sizeof(g(0)) == 2, "Ouch");
+static_assert(sizeof(g(0)) == 2, "Ouch");
+static_assert(sizeof(g(0)) == 2, "Ouch");
+static_assert(sizeof(f(0)) == 2, "Ouch");
+static_assert(sizeof(f(0)) == 2, "Ouch");
+static_assert(sizeof(f(0)) == 2, "Ouch");
+static_assert(sizeof(f(0)) == 2, "Ouch");
+static_assert(sizeof(f(0)) == 2, "Ouch");
+static_assert(sizeof(f(0)) == 2, "Ouch");
+static_assert(sizeof(f(0)) == 2, "Ouch");
+static_assert(sizeof(f(0)) == 2, "Ouch");
+static_assert(sizeof(f(0)) == 2, "Ouch");
+static_assert(sizeof(f(0)) == 2, "Ouch");
+static_assert(sizeof(f(0)) == 2, "Ouch");
+
+static_assert(sizeof(g2(0)) == 2, "Ouch");
+static_assert(sizeof(g2(0)) == 2, "Ouch");
+static_assert(sizeof(g2(0)) == 2, "Ouch");
+static_assert(sizeof(g2(0)) == 2, "Ouch");
+static_assert(sizeof(g2(0)) == 2, "Ouch");
+static_assert(sizeof(g2(0)) == 2, "Ouch");
+static_assert(sizeof(g2(0)) == 2, "Ouch");
+static_assert(sizeof(g2(0)) == 2, "Ouch");
+static_assert(sizeof(g2(0)) == 2, "Ouch");
+static_assert(sizeof(g2(0)) == 2, "Ouch");
+static_assert(sizeof(f2(0)) == 2, "Ouch");
+static_assert(sizeof(f2(0)) == 2, "Ouch");
+static_assert(sizeof(f2(0)) == 2, "Ouch");
+static_assert(sizeof(f2(0)) == 2, "Ouch");
+static_assert(sizeof(f2(0)) == 2, "Ouch");
+static_assert(sizeof(f2(0)) == 2, "Ouch");
+static_assert(sizeof(f2(0)) == 2, "Ouch");
+static_assert(sizeof(f2(0)) == 2, "Ouch");
+static_assert(sizeof(f2(0)) == 2, "Ouch");
+static_assert(sizeof(f2(0)) == 2, "Ouch");
+static_assert(sizeof(f2(0)) == 2, "Ouch");
Index: cp/semantics.c
===
--- cp/semantics.c  (revision 186932)
+++ cp/semantics.c  (working copy)
@@ -5141,6 +5141,26 @@ finish_static_assert (tree condition, tree message
   input_location = saved_loc;
 }
 }
+
+static bool
+instantiation_dependent_expression_p (tree expr)
+{
+  if (!processing_template_decl)
+return false;
+
+  if (type_dependent_expression_p (expr))
+return true;
+
+  if (TREE_CODE (expr) == DELETE_EXPR)
+return instantiation_dependent_expression_p (TREE_OPERAND (expr, 0));
+
+  if (TREE_CODE (expr) == COMPOUND_EXPR)
+return (instantiation_dependent_expression_p (TREE_OPERAND (expr, 0))
+   || instantiation_dependent_expression_p (TREE_OPERAND (expr, 1)));
+
+  return false;
+}
+
 
 /* Implements the C++0x de

[PATCH RFC] Warn when optimization flag is given without -O

2012-04-28 Thread Alexander Monakov

Looks like people who want to play with optimization options are still tripped
by the fact that optimizations are not enabled unless -O is given (even though
it's documented in the manual now).  Can we add a warning for that like below?

Untested beside bubblestrap.  I suppose this will produce noise for -O0
torture testsuite — what is the recommended way to fix that?

diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index 354bce0..a18a89d 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -1056,6 +1056,11 @@ read_cmdline_option (struct gcc_options *opts,
   if (!handle_option (opts, opts_set, decoded, lang_mask, DK_UNSPECIFIED,
  loc, handlers, false, dc))
 error_at (loc, "unrecognized command line option %qs", opt);
+
+  if ((option->flags & CL_OPTIMIZATION)
+  && !opts->x_optimize)
+warning_at (loc, 0, "optimization option %qs has no effect "
+   "at zero -O level", opt);
 }
 
 /* Set any field in OPTS, and OPTS_SET if not NULL, for option


Re: Fix find_moveable_pseudos, PR52997

2012-04-28 Thread Bernd Schmidt

On 04/27/2012 06:25 PM, Ulrich Weigand wrote:

Bernd Schmidt wrote:


We're creating new pseudos, and while we're resizing some data
structures, we aren't doing it for everything.



@@ -3983,7 +3983,8 @@ find_moveable_pseudos (void)

last_moveable_pseudo = max_reg_num ();

-  fix_reg_equiv_init();
+  fix_reg_equiv_init ();
+  resize_reg_info ();
regstat_free_n_sets_and_refs ();
regstat_free_ri ();
regstat_init_n_sets_and_refs ();


This causes a bootstrap failure on s390 when enabling
-fsched-pressure -fsched-pressure-algorithm=model by default
(not sure why this doesn't show up without that change).

The problem is that resize_reg_info only resizes the data
structure, but leaves it uninitialized.


Argh. Something like this maybe (currently testing on i686-linux, ok if 
it passes?)



Bernd
	* ira.c (allocated_reg_info_size): New static variable.
	(expand_reg_info): Manage it. Call
	setup_preferred_alternate_classes_for_new_pseudos.
	(ira): Don't do it here.  Remove local allocated_reg_info_size,
	set the global before calling find_moveable_pseudos.
	(find_moveable_pseudos): Call expand_reg_info rather than
	resize_reg_info.

Index: gcc/ira.c
===
--- gcc/ira.c	(revision 186932)
+++ gcc/ira.c	(working copy)
@@ -2238,18 +2238,22 @@ setup_preferred_alternate_classes_for_ne
 }
 
 
+/* The number of entries allocated in teg_info.  */
+static int allocated_reg_info_size;
 
 /* Regional allocation can create new pseudo-registers.  This function
expands some arrays for pseudo-registers.  */
 static void
-expand_reg_info (int old_size)
+expand_reg_info (void)
 {
   int i;
   int size = max_reg_num ();
 
   resize_reg_info ();
-  for (i = old_size; i < size; i++)
+  for (i = allocated_reg_info_size; i < size; i++)
 setup_reg_classes (i, GENERAL_REGS, ALL_REGS, GENERAL_REGS);
+  setup_preferred_alternate_classes_for_new_pseudos (allocated_reg_info_size);
+  allocated_reg_info_size = size;
 }
 
 /* Return TRUE if there is too high register pressure in the function.
@@ -3984,7 +3988,7 @@ find_moveable_pseudos (void)
   last_moveable_pseudo = max_reg_num ();
 
   fix_reg_equiv_init ();
-  resize_reg_info ();
+  expand_reg_info ();
   regstat_free_n_sets_and_refs ();
   regstat_free_ri ();
   regstat_init_n_sets_and_refs ();
@@ -4044,7 +4048,6 @@ static int saved_flag_ira_share_spill_sl
 static void
 ira (FILE *f)
 {
-  int allocated_reg_info_size;
   bool loops_p;
   int max_regno_before_ira, ira_max_point_before_emit;
   int rebuild_p;
@@ -4121,9 +4124,10 @@ ira (FILE *f)
 	}
 }
 
+  allocated_reg_info_size = max_reg_num ();
   find_moveable_pseudos ();
 
-  max_regno_before_ira = allocated_reg_info_size = max_reg_num ();
+  max_regno_before_ira = max_reg_num ();
   ira_setup_eliminable_regset ();
 
   ira_overall_cost = ira_reg_cost = ira_mem_cost = 0;
@@ -4169,10 +4173,7 @@ ira (FILE *f)
 	ira_initiate_assign ();
   else
 	{
-	  expand_reg_info (allocated_reg_info_size);
-	  setup_preferred_alternate_classes_for_new_pseudos
-	(allocated_reg_info_size);
-	  allocated_reg_info_size = max_regno;
+	  expand_reg_info ();
 
 	  if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL)
 	fprintf (ira_dump_file, "Flattening IR\n");


PATCH: Properly handle arg_pointer and frame_pointer in DWARF output

2012-04-28 Thread H.J. Lu
Hi,

arg_pointer and frame_pointer are handled as special cases in
based_loc_descr.

(plus:DI (reg/f:DI 16 argp)
(const_int -20 [0xffec]))

is perfectly valid when Pmode == DImode and DWARF2_ADDR_SIZE is 32bit
with ptr_mode == SImode.  This patch fixes ICE on the 2 testcases here.
OK for trunk?

Thanks. 


H.J.

gcc/

2012-04-06  H.J. Lu  

PR debug/52857
* dwarf2out.c (mem_loc_descriptor): Allow arg_pointer_rtx and
frame_pointer_rtx for based_loc_descr.

gcc/testsuite/

2012-04-06  H.J. Lu  

PR debug/52857
* gcc.target/i386/pr52857-1.c: New.
* gcc.target/i386/pr52857-2.c: Likewise.

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index ca88fc5..515a824 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -11655,6 +11657,8 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode,
 case REG:
   if (GET_MODE_CLASS (mode) != MODE_INT
  || (GET_MODE_SIZE (mode) > DWARF2_ADDR_SIZE
+ && rtl != arg_pointer_rtx
+ && rtl != frame_pointer_rtx
 #ifdef POINTERS_EXTEND_UNSIGNED
  && (mode != Pmode || mem_mode == VOIDmode)
 #endif
@@ -11927,7 +11931,9 @@ mem_loc_descriptor (rtx rtl, enum machine_mode mode,
 case PLUS:
 plus:
   if (is_based_loc (rtl)
- && GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE
+ && (GET_MODE_SIZE (mode) <= DWARF2_ADDR_SIZE
+ || XEXP (rtl, 0) == arg_pointer_rtx
+ || XEXP (rtl, 0) == frame_pointer_rtx)
  && GET_MODE_CLASS (mode) == MODE_INT)
mem_loc_result = based_loc_descr (XEXP (rtl, 0),
  INTVAL (XEXP (rtl, 1)),
diff --git a/gcc/testsuite/gcc.target/i386/pr52857-1.c 
b/gcc/testsuite/gcc.target/i386/pr52857-1.c
new file mode 100644
index 000..16fd78f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr52857-1.c
@@ -0,0 +1,10 @@
+/* { dg-do compile { target { ! { ia32 } } } } */
+/* { dg-options "-g -O -mx32 -maddress-mode=long" } */
+
+extern void get_BID128 (int *);
+void 
+__bid128_div (void)
+{
+  int res;
+  get_BID128 (&res);
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr52857-2.c 
b/gcc/testsuite/gcc.target/i386/pr52857-2.c
new file mode 100644
index 000..879240a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr52857-2.c
@@ -0,0 +1,8 @@
+/* { dg-do compile { target { ! { ia32 } } } } */
+/* { dg-options "-g -O -mx32 -maddress-mode=long" } */
+
+void uw_init_context_1 (void *);
+void _Unwind_ForcedUnwind (void)
+{
+  uw_init_context_1 (__builtin_dwarf_cfa ());
+}


Re: [patch] Move add_case_node logic from stmt.c to gimplify.c

2012-04-28 Thread H.J. Lu
On Tue, Apr 17, 2012 at 3:11 PM, Steven Bosscher  wrote:
> On Wed, Apr 18, 2012 at 12:04 AM, Steven Bosscher  
> wrote:
>> Hello,
>>
>> This is another step towards moving GIMPLE_SWITCH expansion to an
>> earlier point in the pipeline.
>>
>> With the attached patch, some of the logic from stmt.c:add_case_node()
>> is moved to gimplify.c:gimplify_switch_expr(). This includes:
>>
>> * Code to drop case labels that are out of range for the switch index
>> expression. (Actually, I suspect this code hasn't worked properly
>> since gimplification was introduced, because the switch index
>> expression can be promoted by language specific gimplification, so
>> expand_case never actually sees the proper type with the current
>> implementation in stmt.c.)
>>
>> * Code to fold_convert case label values to the right type. I've opted
>> to go for folding to the original type of the SWITCH_EXPR, rather than
>> to the post-gimplification switch index type.
>>
>> * Code to canonicalize CASE_LABEL's subnodes, CASE_LOW and CASE_HIGH.
>> I've chosen to impose strict requirements that CASE_HIGH > CASE_LOW if
>> CASE_HIGH is non-zero. This is different from what add_case_node does,
>> but I think it makes sense to go for the minimal representation here:
>> The case labels in stmt.c never lived very long (only during expand)
>> but GIMPLE_SWITCH statements stay around for much of the compilation
>> process and can also be streamed out, etc.
>>
>> Bootstrapped and tested on powerpc-unknown-linux-gnu. OK for trunk?
>>
>> Ciao!
>> Steven
>
> And this time with the right subject and the right patch attached.
> Sorry for the inconvenience!

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53153


-- 
H.J.


Optimize calls to functions that return one of their arguments

2012-04-28 Thread Bernd Schmidt
This patch allows us to recognize that even if the argument to memcpy 
lives across the call, we can allocate it to a call-used register by 
reusing the return value of the function.


First, the patch sets the existing "fn spec" attribute for 
memcpy/memmove. This is translated to a new form of 
CALL_INSN_FUNCTION_USAGE, a (set (returnreg) (argreg)). This is 
recognized by IRA to adjust costs, and for communicating to caller-save 
that the register can be restored cheaply.


The optimization only triggers if the argument is passed in a register, 
which should be the case in the majority of sane ABIs. The effect on the 
new testcase:


pushq   %rbx  | subq$8, %rsp
movslq  %edx, %rdx  movslq  %edx, %rdx
movq%rdi, %rbx<
callmemcpy  callmemcpy
movq%rbx, %rax| addq$8, %rsp
popq%rbx  <
ret ret

Bootstrapped with all languages on i686-linux, and bootstrapped and 
tested minus Ada on x86_64-linux. There's one Go test which seems to 
fail randomly both with and without the patch:

FAIL: go.test/test/stack.go execution,  -O2 -g

Ok?


Bernd
	* attribs.c (decl_attributes): Avoid emitting a warning if
	ATTR_FLAG_BUILT_IN.
	* doc/rtl.texi (CALL_INSN_FUNCTION_USAGE): Use lowercase for rtx
	codes.  Document meaning of sets inside CALL_INSN_FUNCTION_USAGE.
	* c-family/c-common.c (DEF_ATTR_STRING): Define and undefine as
	necessary.
	* builtin-attrs.def (DEF_ATTR_FOR_STRING): Define.  Use it to
	define a string "1".
	(ATTR_RET1_NOTHROW_NONNULL_LEAF): New attr definition.
	* builtins.def (BUILT_IN_MEMCPY, BUILT_IN_MEMMOVE): Use it for
	these functions.
	* postreload.c (reload_combine): Deal with SETs inside
	CALL_INSN_FUNCTION_USAGE.
	* caller-save.c (setup_save_areas, save_call_clobbered_regs):
	Look for REG_RETURNED notes and use a cheap restore if possible.
	* ira-int.h (struct ira_allocno): New member cheap_calls_crossed_num.
	(ALLOCNO_CHEAP_CALLS_CROSSED_NUM): New macro.
	* ira-lives.c (pseudo_regno_single_word_and_live_p): New static
	function.
	(process_bb_node_lives): Look for SETs in CALL_INSN_FUNCTION_USAGE,
	and set ALLOCNO_CHEAP_CALLS_CROSSED_NUM if possible.  Also make
	a REG_RETURNED note in that case.
	* ira.c (setup_reg_renumber): Change assert to allow cases where
	allocnos only cross calls for which they are cheap to restore.
	* ira-costs.c (ira_tune_allocno_costs): Compare
	ALLOCNO_CALLS_CROSSED_NUM to ALLOCNO_CHEAP_CALLS_CROSSED_NUM rather
	than 0.
	* reg-notes.def (REG_RETURNED): New note.
	* cse.c (cse_insn): Likewise.
	* sched-deps.c (sched_analyze_insn): Likewise.
	* expr.c (init_block_move_fn): Set a "fn spec" attribute.
	* calls.c (decl_return_flags): New static function.
	(expand_call): Generate a SET in CALL_INSN_FUNCTION_USAGE for
	functions that return one of their arguments.
	* lto/lto-lang.c (handle_fnspec_attribute): New static function.
	(lto_attribute_table): Add "fn spec".
	(DEF_ATTR_STRING): Define and undefine along with the other macros.
	* regcprop.c (struct kill_set_value_data): New.
	(kill_set_value): Interpret data as a pointer to such a struct.
	Do nothing if the caller wants the register to be ignored.
	(copyprop_hardreg_forward_1): Handle SETs in CALL_INSN_FUNCTION_USAGE.

testsuite/
	* gcc.target/i386/retarg.c: New test.

Index: gcc/attribs.c
===
--- gcc/attribs.c	(revision 186712)
+++ gcc/attribs.c	(working copy)
@@ -312,8 +312,9 @@ decl_attributes (tree *node, tree attrib
 
   if (spec == NULL)
 	{
-	  warning (OPT_Wattributes, "%qE attribute directive ignored",
-		   name);
+	  if (!(flags & (int) ATTR_FLAG_BUILT_IN))
+	warning (OPT_Wattributes, "%qE attribute directive ignored",
+		 name);
 	  continue;
 	}
   else if (list_length (args) < spec->min_length
Index: gcc/doc/rtl.texi
===
--- gcc/doc/rtl.texi	(revision 186712)
+++ gcc/doc/rtl.texi	(working copy)
@@ -3455,20 +3455,26 @@ unpredictably.
 @code{call_insn} insns have the same extra fields as @code{insn} insns,
 accessed in the same way and in addition contain a field
 @code{CALL_INSN_FUNCTION_USAGE}, which contains a list (chain of
-@code{expr_list} expressions) containing @code{use} and @code{clobber}
-expressions that denote hard registers and @code{MEM}s used or
-clobbered by the called function.
+@code{expr_list} expressions) containing @code{use}, @code{clobber} and
+sometimes @code{set} expressions that denote hard registers and
+@code{mem}s used or clobbered by the called function.
 
-A @code{MEM} generally points to a stack slots in which arguments passed
+A @code{mem} generally points to a stack slots in which arguments passed
 to the libcall by reference (@pxref{Register Arguments,
 TARGET_PASS_BY_REFERENCE}) are stored.  If the argument is
 caller-copied (@pxref{Register 

Re: [PATCH] teach phi-opt to produce -(a COND b)

2012-04-28 Thread Paolo Bonzini
Il 27/04/2012 18:43, H.J. Lu ha scritto:
> On Fri, Apr 27, 2012 at 3:01 AM, Paolo Bonzini  wrote:
>> This patch teaches phiopt to look at phis whose arguments are -1 and 0,
>> and produce negated setcc statements.
>>
>> Bootstrapped/regtested x86_64-pc-linux-gnu, together with the patch
>> for pr53138.  Ok for mainline?
>>
>> Paolo
>>
>> 2012-04-27  Paolo Bonzini  
>>
>>* tree-ssa-phiopt.c (conditional_replacement): Replace PHIs
>>whose arguments are -1 and 0, by negating the result of the
>>conditional.
>>
> 
> This caused:
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53144

The bug exists even in 4.7.0, so in some sense it's a good thing that
the testsuite reminds about it. :)

Paolo


Re: [patch] Fix cygwin ada install [was Re: Yet another issue with gcc current trunk with ada on cygwin]

2012-04-28 Thread Arnaud Charlet
> Le 06/04/2012 17:27, Pascal Obry a écrit :
> > 
> > Back on this! It turn out that this breaks the shared Ada runtime.
> > Indeed, exported variables on Ada packages in a DLLs are only accessible
> > when linking against DLL (thanks to runtime pseudo reloc).
> > 
> > With the patch applied it is not possible to build any Ada application
> > using the shared runtime. This is a very serious problem, the patch
> > should be reverted.
> > 
> > Sorry for not having remembered before about this and why linking
> > against DLL was so important!
> > 
> 
> PING?

Pascal, I'd suggest you go ahead and revert this patch.


Re: [PATCH] Fix PR38884

2012-04-28 Thread H.J. Lu
On Thu, Oct 6, 2011 at 1:36 AM, Richard Guenther  wrote:
>
> This handles the case of CSEing part of an SSA name that is stored
> to memory and defined with a composition like COMPLEX_EXPR or
> CONSTRUCTOR.  This fixes the remaining pieces of PR38884 and
> PR38885.
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk.
>
> Richard.
>
> 2011-10-06  Richard Guenther  
>
>        PR tree-optimization/38884
>        * tree-ssa-sccvn.c (vn_reference_lookup_3): Handle partial
>        reads from aggregate SSA names.
>

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53144

-- 
H.J.


[patch] backport powerpc64-freebsd support to 4.7 branch

2012-04-28 Thread Andreas Tobler

Hello all,

I did a backport of the powerpc64-freebsd support to the 4.7 branch, 
here the results:


http://gcc.gnu.org/ml/gcc-testresults/2012-04/msg02768.html
http://gcc.gnu.org/ml/gcc-testresults/2012-04/msg02767.html

Is the attached/below ok to commit to 4.7 branch?

TIA,
Andreas

libstdc++:
2012-04-28  Andreas Tobler  

Backport from mainline
2012-03-21  Andreas Tobler  

* testsuite/23_containers/vector/bool/modifiers/insert/31370.cc:
Skip this test on powerpc64-*-freebsd*.

libgcc:
2012-04-28  Andreas Tobler  

Backport from mainline
2012-03-21  Andreas Tobler  

* config.host: Add bits to support powerpc64-*-freebsd*.
* config/rs6000/freebsd-unwind.h: New file.
* config/rs6000/t-freebsd64: New file.

gcc:
2012-04-28  Andreas Tobler  

Backport from mainline
2012-03-21  Andreas Tobler  

* configure.ac (HAVE_LD_NO_DOT_SYMBOLS): Add powerpc64-*-freebsd*.
Introduce emul_name to select the right linker emulation for
powerpc64-*-freebsd*.
* configure: Regenerate.
* config.gcc: Add bits to support powerpc64-*-freebsd*.
* config/rs6000/freebsd.h (POWERPC_FREEBSD): Define.
* config/rs6000/freebsd64.h: New file.
* config/rs6000/rs6000.c (rs6000_option_override_internal): Use
POWERPC_FREEBSD.
(rs6000_savres_strategy): Likewise.
(rs6000_savres_routine_name): Likewise.
(rs6000_elf_file_end): Likewise.
* config/rs6000/t-freebsd64: New file.
* config/rs6000/sysv4.h (SUBTARGET_OVERRIDE_OPTIONS): Set the
rs6000_current_abi for 64-bit FreeBSD to ABI_AIX.
Index: 
libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/31370.cc
===
--- libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/31370.cc  
(revision 186918)
+++ libstdc++-v3/testsuite/23_containers/vector/bool/modifiers/insert/31370.cc  
(working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2009, 2010 Free Software Foundation, Inc.
+// Copyright (C) 2007, 2009, 2010, 2012 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -17,6 +17,7 @@
 
 // 23.2.5 class vector [lib.vector.bool]
 
+// { dg-skip-if "" { powerpc64-*-freebsd* } { "*" } { "" } }
 // { dg-do run { xfail *-*-darwin8.[0-4].* } }
 
 #include 
Index: libgcc/config.host
===
--- libgcc/config.host  (revision 186918)
+++ libgcc/config.host  (working copy)
@@ -848,9 +848,15 @@
tmake_file="$tmake_file rs6000/t-darwin64 rs6000/t-ibm-ldouble"
extra_parts="$extra_parts crt2.o"
;;
-powerpc-*-freebsd*)
-   tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-savresfgpr 
rs6000/t-crtstuff rs6000/t-freebsd t-softfp-sfdf t-softfp-excl t-softfp 
t-slibgcc-libgcc"
+powerpc*-*-freebsd*)
+   tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-savresfgpr 
rs6000/t-crtstuff rs6000/t-freebsd t-softfp-sfdf t-softfp-excl t-softfp"
extra_parts="$extra_parts crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o"
+   case ${host} in
+   powerpc64*)
+ tmake_file="${tmake_file} rs6000/t-freebsd64"
+ md_unwind_header=rs6000/freebsd-unwind.h
+ ;;
+   esac
;;
 powerpc-*-netbsd*)
tmake_file="$tmake_file rs6000/t-netbsd rs6000/t-crtstuff"
Index: libgcc/config/rs6000/t-freebsd64
===
--- libgcc/config/rs6000/t-freebsd64(revision 0)
+++ libgcc/config/rs6000/t-freebsd64(revision 0)
@@ -0,0 +1,5 @@
+HOST_LIBGCC2_CFLAGS += -mno-minimal-toc
+SHLIB_MAPFILES = libgcc-std.ver
+
+softfp_wrap_start := '\#ifndef __powerpc64__'
+softfp_wrap_end := '\#endif'
Index: libgcc/config/rs6000/freebsd-unwind.h
===
--- libgcc/config/rs6000/freebsd-unwind.h   (revision 0)
+++ libgcc/config/rs6000/freebsd-unwind.h   (revision 0)
@@ -0,0 +1,69 @@
+/* DWARF2 EH unwinding support for PowerPC64 FreeBSD.
+   Copyright (C) 2012 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published
+   by the Free Software Foundation; either version 3, or (at your
+   option) any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should 

[v3] is_modulo

2012-04-28 Thread Marc Glisse

Hello,

the attached follows the precisions on the definition of is_modulo in 
DR 612. I believe this is what the values always should have been, so I 
didn't make the change conditional to C++11.


PR 22200 can remain open if people want to discuss the interaction with 
-fwrapv, but false is the safe value.


I ran the testsuite, to make sure there wasn't a huge typo that would 
prevent the file from compiling, and the only failure was the usual 
22_locale/time_get/get_date/wchar_t/4.cc.


2012-04-29  Marc Glisse  

PR libstdc++/22200
* include/std/limits (numeric_limits<>::is_modulo): false for
signed types.

--
Marc GlisseIndex: include/std/limits
===
--- include/std/limits  (revision 186932)
+++ include/std/limits  (working copy)
@@ -268,14 +268,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 /** True if the set of values representable by the type is
finite.  All built-in types are bounded, this member would be
false for arbitrary precision types. [18.2.1.2]/54  */
 static _GLIBCXX_USE_CONSTEXPR bool is_bounded = false;
 
-/** True if the type is @e modulo, that is, if it is possible to add two
-   positive numbers and have a result that wraps around to a third number
-   that is less.  Typically false for floating types, true for unsigned
-   integers, and true for signed integers.  */
+/** True if the type is @e modulo. A type is modulo if, for any
+   operation involving +, -, or * on values of that type whose
+   result would fall outside the range [min(),max()], the value
+   returned differs from the true value by an integer multiple of
+   max() - min() + 1. On most machines, this is false for floating
+   types, true for unsigned integers, and true for signed integers.
+   See PR22200 about signed integers.  */
 static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
 
 /** True if trapping is implemented for this type.  */
 static _GLIBCXX_USE_CONSTEXPR bool traps = false;
 
@@ -492,11 +495,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   static _GLIBCXX_CONSTEXPR char 
   denorm_min() _GLIBCXX_USE_NOEXCEPT { return static_cast(0); }
 
   static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
   static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
-  static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true;
+  static _GLIBCXX_USE_CONSTEXPR bool is_modulo = !is_signed;
 
   static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
   static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
   static _GLIBCXX_USE_CONSTEXPR float_round_style round_style 
= round_toward_zero;
@@ -562,11 +565,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   denorm_min() _GLIBCXX_USE_NOEXCEPT
   { return static_cast(0); }
 
   static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
   static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
-  static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true;
+  static _GLIBCXX_USE_CONSTEXPR bool is_modulo = false;
 
   static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
   static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
   static _GLIBCXX_USE_CONSTEXPR float_round_style round_style 
= round_toward_zero;
@@ -703,11 +706,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   static _GLIBCXX_CONSTEXPR wchar_t 
   denorm_min() _GLIBCXX_USE_NOEXCEPT { return wchar_t(); }
 
   static _GLIBCXX_USE_CONSTEXPR bool is_iec559 = false;
   static _GLIBCXX_USE_CONSTEXPR bool is_bounded = true;
-  static _GLIBCXX_USE_CONSTEXPR bool is_modulo = true;
+  static _GLIBCXX_USE_CONSTEXPR bool is_modulo = !is_signed;
 
   static _GLIBCXX_USE_CONSTEXPR bool traps = __glibcxx_integral_traps;
   static _GLIBCXX_USE_CONSTEXPR bool tinyness_before = false;
   static _GLIBCXX_USE_CONSTEXPR float_round_style round_style 
= round_toward_zero;
@@ -766,11 +769,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   static constexpr char16_t 
   denorm_min() noexcept { return char16_t(); }
 
   static constexpr bool is_iec559 = false;
   static constexpr bool is_bounded = true;
-  static constexpr bool is_modulo = true;
+  static constexpr bool is_modulo = !is_signed;
 
   static constexpr bool traps = __glibcxx_integral_traps;
   static constexpr bool tinyness_before = false;
   static constexpr float_round_style round_style = round_toward_zero;
 };
@@ -827,11 +830,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   static constexpr char32_t 
   denorm_min() noexcept { return char32_t(); }
 
   static constexpr bool is_iec559 = false;
   static constexpr bool is_bounded = true;
-  static constexpr bool is_modulo = true;
+  static constexpr bool is_modulo = !is_signed;
 
   static constexpr bool traps = __glibcxx_integral_traps;
   static constexpr bool tinyness_before = f

Re: [v3] is_modulo

2012-04-28 Thread Gabriel Dos Reis
On Sat, Apr 28, 2012 at 5:41 PM, Marc Glisse  wrote:
> Hello,
>
> the attached follows the precisions on the definition of is_modulo in DR
> 612. I believe this is what the values always should have been, so I didn't
> make the change conditional to C++11.

Thanks for the patch.
I think  'char' shouldn't be considered modulo  even if
-funsigned-char -- I will bring this to LWG attention.

>
> PR 22200 can remain open if people want to discuss the interaction with
> -fwrapv, but false is the safe value.

I believe the interaction with -fwrapv is an interesting one.

>
> I ran the testsuite, to make sure there wasn't a huge typo that would
> prevent the file from compiling, and the only failure was the usual
> 22_locale/time_get/get_date/wchar_t/4.cc.

OK.
>
> 2012-04-29  Marc Glisse  
>
>        PR libstdc++/22200
>        * include/std/limits (numeric_limits<>::is_modulo): false for
>        signed types.
>
> --
> Marc Glisse


Re: [PATCH, diagnostics] Add -Wvarargs option

2012-04-28 Thread Gabriel Dos Reis
On Fri, Apr 27, 2012 at 4:46 PM, Dodji Seketeli  wrote:
> Dodji Seketeli  writes:
>
>
>> Tested on x86_64-unknown-linux-gnu against trunk.  Bootstrap for all
>> languages is still underway.
>>
>> gcc/c-family/
>>
>>       * c.opt (Wvarargs):  Define new option.
>>
>> gcc/
>>       builtins.c (fold_builtin_next_arg):  Use OPT_Wvarargs as an
>>       argument for the various warning_at calls.
>>
>> gcc/doc/
>>
>>       * invoke.texi: Update the documentation.
>>
>> gcc/testsuite/
>>
>>       * c-c++-common/Wvarargs.c: New test case.
>>       * c-c++-common/Wvarargs-2.c: Likewise.
>
> FWIW, this completed bootstrap and testing fine.

OK.  thanks,

-- Gaby


Re: [PATCH 11/13] Fix va_start related location

2012-04-28 Thread Gabriel Dos Reis
On Fri, Apr 27, 2012 at 4:45 PM, Dodji Seketeli  wrote:
> Dodji Seketeli  writes:
>
>
>> Tested on x86_64-unknown-linux-gnu against trunk.  Bootstrap is still
>> running ...
>>
>>       * builtins.c (fold_builtin_next_arg): Unwinds to the first
>>       location in real source code.
>> ---
>>  gcc/builtins.c |   23 +++
>>  1 files changed, 19 insertions(+), 4 deletions(-)
>
> FWIW, this completed bootstrap and testing fine.

OK.


Re: [v3] is_modulo

2012-04-28 Thread Marc Glisse

On Sat, 28 Apr 2012, Gabriel Dos Reis wrote:


On Sat, Apr 28, 2012 at 5:41 PM, Marc Glisse  wrote:

Hello,

the attached follows the precisions on the definition of is_modulo in DR
612. I believe this is what the values always should have been, so I didn't
make the change conditional to C++11.


Thanks for the patch.
I think  'char' shouldn't be considered modulo  even if
-funsigned-char -- I will bring this to LWG attention.


Why not? If an implementation decides to guarantee that the arithmetic on 
a type is modular, it should advertise it through this trait, I don't see 
anything wrong about that. Well, doing arithmetic on char may not be the 
best idea, but still... Actually, if you are going to bring this up in 
LWG, let's not discuss that here.



OK.


Note that I can't commit, you'll have to do it, sorry...

--
Marc Glisse


Re: [RFH / Patch] PR 51222

2012-04-28 Thread Jason Merrill

On 04/28/2012 07:12 AM, Paolo Carlini wrote:

isn't, but clearly can be instantiation dependent. Then, I guess the way
I'm proposing to handle this is by starting some sort of embryonic
instantiation_dependent_expression_p and using it only here, for now,
like the attached (which passes on x86_64-linux). What do you think?


I think that implementing it properly shouldn't be that much harder; the 
definition from the ABI is


An expression is instantiation-dependent if it is type-dependent or 
value-dependent, or it has a subexpression that is type-dependent or 
value-dependent.


This might just be a matter of calling for_each_template_parm and 
returning 1 if we see any template parameter.


Jason


Re: [PATCH 04/11] Fix expansion point loc for macro-like tokens

2012-04-28 Thread Jason Merrill

On 04/25/2012 05:07 AM, Dodji Seketeli wrote:

+ /* If the first token we got was a padding token, let's put
+it back into the stream so that cpp_get_token will get it
+first; and if we are currently expanding a macro, don't
+forget that information.  */
+ cpp_hashnode *macro =
+   (pfile->context->tokens_kind == TOKENS_KIND_EXTENDED)
+   ? pfile->context->c.mc->macro_node
+   : pfile->context->c.macro;
+ _cpp_push_token_context (pfile, macro, padding, 1);


What about the other places that call _cpp_push_token_context with a 
NULL macro argument?  Don't we want to continue the current macro 
context in that case, too?  Perhaps we should move this new code inside 
_cpp_push_token_context for the case when the macro parameter is NULL.


Jason


Re: [PATCH 05/11] Make expand_location resolve to locus in main source file

2012-04-28 Thread Jason Merrill

On 04/25/2012 11:31 AM, Dodji Seketeli wrote:

+#define EXPANSION_POINT_LOCATION_FILE(LOC) \
+  ((expand_location_to_expansion_point (LOC)).file)
+#define EXPANSION_POINT_LOCATION_LINE(LOC) \
+  ((expand_location_to_expansion_point (LOC)).line)
+#define EXPANSION_POINT_LOCATION_COLUMN(LOC)   \
+  ((expand_location_to_expansion_point (LOC)).column)


These macros don't seem to be used anywhere.  The rest of the patch is OK.

Jason