[Ada] Do not invoke gnatls unconditionally

2012-12-11 Thread Eric Botcazou
Even if the Ada language isn't enabled, the Make-lang.in fragment of the Ada 
compiler is processed and invokes gnatls unconditionally, which can result in 
error messages if the command isn't present.

Tested on x86_64-suse-linux, applied on the mainline.


2012-12-11  Eric Botcazou  

* gcc-interface/Make-lang.in (RTS_DIR): Define only if Ada is enabled.


-- 
Eric BotcazouIndex: gcc-interface/Make-lang.in
===
--- gcc-interface/Make-lang.in	(revision 194382)
+++ gcc-interface/Make-lang.in	(working copy)
@@ -122,7 +122,9 @@ ifeq ($(build), $(host))
 
 # put the host RTS dir first in the PATH to hide the default runtime
 # files that are among the sources
-RTS_DIR:=$(strip $(subst \,/,$(shell gnatls -v | grep adalib )))
+ifneq ($(findstring ada,$(LANGUAGES)),)
+  RTS_DIR:=$(strip $(subst \,/,$(shell gnatls -v | grep adalib )))
+endif
 
 ADA_TOOLS_FLAGS_TO_PASS=\
 CC="$(CC)" \
@@ -157,7 +159,9 @@ else
   else
 # This is a canadian cross. We should use a toolchain running on the
 # build platform and targeting the host platform.
-RTS_DIR:=$(strip $(subst \,/,$(shell $(GNATLS_FOR_HOST) -v | grep adalib )))
+ifneq ($(findstring ada,$(LANGUAGES)),)
+  RTS_DIR:=$(strip $(subst \,/,$(shell $(GNATLS_FOR_HOST) -v | grep adalib )))
+endif
 ADA_TOOLS_FLAGS_TO_PASS=\
 CC="$(CC)" \
 $(COMMON_FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS)  \


[C++ PATCH] Avoid decay_conversion on inline asm "m" inputs (PR c++/55619)

2012-12-11 Thread Jakub Jelinek
Hi!

As the testcase shows, for "m" or similar constraints that don't accept
registers, but do accept memory, we want to call *mark_addressable on the
operand, but the call to decay_conversion can change something that was
originally addressable into something non-addressable (be it replacement
of a const var with its initializer, or e.g. when the argument is an array).

The following patch fixes that, bootstrapped/regtested on x86_64-linux and
i686-linux, ok for trunk?  The C FE might need some change too (const vars
aren't an issue, but array conversions are).

2012-12-11  Jakub Jelinek  

PR c++/55619
* semantics.c (finish_asm_stmt): Don't call decay_conversion
on input operands that can be only in memory.

* g++.dg/ext/asm12.C: New test.

--- gcc/cp/semantics.c.jj   2012-12-10 08:42:39.0 +0100
+++ gcc/cp/semantics.c  2012-12-10 15:24:20.666231490 +0100
@@ -1369,7 +1369,15 @@ finish_asm_stmt (int volatile_p, tree st
   for (i = 0, t = input_operands; t; ++i, t = TREE_CHAIN (t))
{
  constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (t)));
- operand = decay_conversion (TREE_VALUE (t), tf_warning_or_error);
+ bool constraint_parsed
+   = parse_input_constraint (&constraint, i, ninputs, noutputs, 0,   
+ oconstraints, &allows_mem, &allows_reg);
+ /* If the operand is going to end up in memory, don't call
+decay_conversion.  */
+ if (constraint_parsed && !allows_reg && allows_mem)
+   operand = mark_rvalue_use (TREE_VALUE (t));
+ else
+   operand = decay_conversion (TREE_VALUE (t), tf_warning_or_error);
 
  /* If the type of the operand hasn't been determined (e.g.,
 because it involves an overloaded function), then issue
@@ -1382,8 +1390,7 @@ finish_asm_stmt (int volatile_p, tree st
  operand = error_mark_node;
}
 
- if (parse_input_constraint (&constraint, i, ninputs, noutputs, 0,
- oconstraints, &allows_mem, &allows_reg))
+ if (constraint_parsed)
{
  /* If the operand is going to end up in memory,
 mark it addressable.  */
--- gcc/testsuite/g++.dg/ext/asm12.C.jj 2012-12-10 15:28:26.313827902 +0100
+++ gcc/testsuite/g++.dg/ext/asm12.C2012-12-10 15:28:03.0 +0100
@@ -0,0 +1,14 @@
+// PR c++/55619
+// { dg-do compile }
+
+typedef int V __attribute__ ((vector_size (4 * sizeof (int;
+
+static const V C = { 0x201, 0, 0, 0 };
+static const int D = 0x201;
+
+void
+f ()
+{
+  __asm volatile ("" : : "m" (C));
+  __asm volatile ("" : : "m" (D));
+}

Jakub


[PATCH] Fix DEBUG_INSN handling in lra-constraints (PR rtl-optimization/55193)

2012-12-11 Thread Jakub Jelinek
Hi!

As the testcase in the PR (unfortunately only reproduceable after reverting
some inlining patch, so not including that testcase in the patch) shows,
loc_equivalence_change_p isn't good enough for debug_insns, when a REG is
substituted for VOIDmode constant.  In that case, the surrounding SUBREG
(handled in loc_equivalence_change_p), but also other operations like
ZERO_EXTEND/SIGN_EXTEND, ZERO_EXTRACT etc. need to be simplified while we
still know the original mode, and perhaps several times, as SIGN_EXTEND
might be in another ZERO_EXTEND etc.  The best way to deal with that
is simplify_replace_fn_rtx which is used in various other places in the
compiler.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2012-12-11  Jakub Jelinek  

PR rtl-optimization/55193
* lra-constraints.c (loc_equivalence_callback): New function.
(lra_constraints): Call simplify_replace_fn_rtx instead of
loc_equivalence_change_p on DEBUG_INSNs.

--- gcc/lra-constraints.c.jj2012-12-10 08:42:40.0 +0100
+++ gcc/lra-constraints.c   2012-12-10 18:43:04.977277475 +0100
@@ -3186,6 +3186,21 @@ loc_equivalence_change_p (rtx *loc)
   return result;
 }
 
+/* Similar to loc_equivalence_change_p, but for use as
+   simplify_replace_fn_rtx callback.  */
+static rtx
+loc_equivalence_callback (rtx loc, const_rtx, void *)
+{
+  if (!REG_P (loc))
+return NULL_RTX;
+
+  rtx subst = get_equiv_substitution (loc);
+  if (subst != loc)
+return subst;
+
+  return NULL_RTX;
+}
+
 /* Maximum allowed number of constraint pass iterations after the last
spill pass. It is for preventing LRA cycling in a bug case.  */
 #define MAX_CONSTRAINT_ITERATION_NUMBER 30
@@ -3422,11 +3437,17 @@ lra_constraints (bool first_p)
  /* We need to check equivalence in debug insn and change
 pseudo to the equivalent value if necessary.  */
  curr_id = lra_get_insn_recog_data (curr_insn);
- if (bitmap_bit_p (&equiv_insn_bitmap, INSN_UID (curr_insn))
- && loc_equivalence_change_p (curr_id->operand_loc[0]))
+ if (bitmap_bit_p (&equiv_insn_bitmap, INSN_UID (curr_insn)))
{
- lra_update_insn_regno_info (curr_insn);
- changed_p = true;
+ rtx old = *curr_id->operand_loc[0];
+ *curr_id->operand_loc[0]
+   = simplify_replace_fn_rtx (old, NULL_RTX,
+  loc_equivalence_callback, NULL);
+ if (old != *curr_id->operand_loc[0])
+   {
+ lra_update_insn_regno_info (curr_insn);
+ changed_p = true;
+   }
}
}
   else if (INSN_P (curr_insn))

Jakub


Re: [asan] Handle noreturn calls with __asan_handle_no_return ()

2012-12-11 Thread Dodji Seketeli
Jakub Jelinek  writes:

> On Mon, Dec 10, 2012 at 10:44:49PM +0100, Dodji Seketeli wrote:
>> Jakub Jelinek  writes:
>> 
>> > +++ gcc/asan.c 2012-12-05 15:30:56.069890542 +0100
>> > @@ -1031,7 +1031,7 @@ instrument_builtin_call (gimple_stmt_ite
>> >  {
>> >gimple call = gsi_stmt (*iter);
>> >  
>> > -  gcc_assert (is_gimple_builtin_call (call));
>> > +  gcc_checking_assert (is_gimple_builtin_call (call));
>> 
>> Why is this change necessary?
>
> It is not necessary, just it isn't as low cost as it would be good for
> an assertion, it does:
>   if (is_gimple_call (stmt)
>   && (callee = gimple_call_fndecl (stmt))
>   && is_builtin_fn (callee)
>   && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL)
> return true;
> and the caller calls that exact routine already:
>   if (is_gimple_builtin_call (gsi_stmt (*iter)))
> return instrument_builtin_call (iter);
> and this is the second statement in instrument_builtin_call.

Ah, okay.  Thanks.

-- 
Dodji


[Committed] S/390: Check execute target patterns for validity

2012-12-11 Thread Andreas Krebbel
Hi,

on S/390 we have the execute instruction which modifies and executes
an instruction in memory specified by an address operand.  On RTL
level (after reload) we embed the target instruction into the execute
pattern.  So far we never checked the embedded pattern for validity
what unfortunately caused a failure now.  The late scheduling pass
moved such a pattern across an address register increment and modified
the displacement making the address operand in the embedded pattern
invalid.

The attached patch implements a new predicate which extracts the
embedded pattern, constructs an insn from it and checks the insn for
validity.

Bootstrapped and regtested on s390 and s390x.
Comitted to mainline.

Bye,

-Andreas-

2012-12-11  Andreas Krebbel  

* config/s390/predicates.md ("execute_operation"): New predicate.
* config/s390/s390.md ("*execute_rl", "*execute"): Use the new
predicate.

---
 gcc/config/s390/predicates.md |   46 ++
 gcc/config/s390/s390.md   |4 !!!
 2 files changed, 46 insertions(+), 4 modifications(!)

Index: gcc/config/s390/predicates.md
===
*** gcc/config/s390/predicates.md.orig
--- gcc/config/s390/predicates.md
***
*** 348,353 
--- 348,399 
return true;
  })
  
+ ;; For an execute pattern the target instruction is embedded into the
+ ;; RTX but will not get checked for validity by recog automatically.
+ ;; The execute_operation predicate extracts the target RTX and invokes
+ ;; recog.
+ (define_special_predicate "execute_operation"
+   (match_code "parallel")
+ {
+   rtx pattern = op;
+   rtx insn;
+   int icode;
+ 
+   /* This is redundant but since this predicate is evaluated
+  first when recognizing the insn we can prevent the more
+  expensive code below from being executed for many cases.  */
+   if (GET_CODE (XVECEXP (pattern, 0, 0)) != UNSPEC
+   || XINT (XVECEXP (pattern, 0, 0), 1) != UNSPEC_EXECUTE)
+ return false;
+ 
+   /* Keep in sync with s390_execute_target.  */
+   if (XVECLEN (pattern, 0) == 2)
+ {
+   pattern = copy_rtx (XVECEXP (pattern, 0, 1));
+ }
+   else
+ {
+   rtvec vec = rtvec_alloc (XVECLEN (pattern, 0) - 1);
+   int i;
+ 
+   for (i = 0; i < XVECLEN (pattern, 0) - 1; i++)
+   RTVEC_ELT (vec, i) = copy_rtx (XVECEXP (pattern, 0, i + 1));
+ 
+   pattern = gen_rtx_PARALLEL (VOIDmode, vec);
+ }
+ 
+   /* Since we do not have the wrapping insn here we have to build one.  */
+   insn = make_insn_raw (pattern);
+   icode = recog_memoized (insn);
+   if (icode < 0)
+ return false;
+ 
+   extract_insn (insn);
+   constrain_operands (1);
+ 
+   return which_alternative >= 0;
+ })
+ 
  ;; Return true if OP is a store multiple operation.  It is known to be a
  ;; PARALLEL and the first section will be tested.
  
Index: gcc/config/s390/s390.md
===
*** gcc/config/s390/s390.md.orig
--- gcc/config/s390/s390.md
***
*** 2493,2499 
  ;;
  
  (define_insn "*execute_rl"
!   [(match_parallel 0 ""
  [(unspec [(match_operand 1"register_operand" "a")
  (match_operand 2"" "")
(match_operand:SI 3 "larl_operand" "X")] UNSPEC_EXECUTE)])]
--- 2493,2499 
  ;;
  
  (define_insn "*execute_rl"
!   [(match_parallel 0 "execute_operation"
  [(unspec [(match_operand 1"register_operand" "a")
  (match_operand 2"" "")
(match_operand:SI 3 "larl_operand" "X")] UNSPEC_EXECUTE)])]
***
*** 2504,2510 
 (set_attr "type""cs")])
  
  (define_insn "*execute"
!   [(match_parallel 0 ""
  [(unspec [(match_operand 1 "register_operand" "a")
(match_operand:BLK 2 "memory_operand" "R")
(match_operand 3 "" "")] UNSPEC_EXECUTE)])]
--- 2504,2510 
 (set_attr "type""cs")])
  
  (define_insn "*execute"
!   [(match_parallel 0 "execute_operation"
  [(unspec [(match_operand 1 "register_operand" "a")
(match_operand:BLK 2 "memory_operand" "R")
(match_operand 3 "" "")] UNSPEC_EXECUTE)])]



Re: [PATCH] Bugfix: Additional parameter for canonicalize comparison

2012-12-11 Thread Andreas Krebbel
On 11/12/12 00:12, Kaz Kojima wrote:
> Andreas Krebbel  wrote:
>> Index: gcc/config/sh/sh.c
>> ===
>> *** gcc/config/sh/sh.c.orig
>> --- gcc/config/sh/sh.c
> [snop]
>> ! static void
>>   sh_canonicalize_comparison (enum rtx_code& cmp, rtx& op0, rtx& op1,
>> !enum machine_mode mode,
>> !bool op0_preserve_value ATTRIBUTE_UNUSED)
>>   {
>> +   HOST_WIDE_INT val;
>> + 
> 
> Please remove the last two lines which cause the warning:
> 
> gcc/config/sh/sh.c:1927:17: warning: unused variable 'val' [-Wunused-variable]

urgs - I'll fix this. Is the patch ok with that change for sh?

-Andreas-



Re: [PATCH] Bugfix: Additional parameter for canonicalize comparison

2012-12-11 Thread Kaz Kojima
Andreas Krebbel  wrote:
> urgs - I'll fix this. Is the patch ok with that change for sh?

Yes, the sh portion is OK with that change, though it would be better
to fix the users of sh_canonicalize_comparison instead of its wrapper
as pointed out by rth and oleg.

Regards,
kaz


Re: Fix ICE on loop over constant vector at -O

2012-12-11 Thread Eric Botcazou
> ... so if would really be a pessimization doing that.  Of course handling
> CONST_DECL in for_each_index is indeed obvious - I just was curios if
> it was a missed-optimization opportunity as well.

It turns out that, for the same testcase, &CONST_DECL is generated on the MIPS 
and prepare_decl_rtl is trying to put an RTX on the CONST_DECL, hence ICE.

Tested on x86_64-suse-linux, applied on the mainline as obvious.  I agree that 
this is on the fringes of what we have to support, but we won't revisit it 
until the 4.9 development cycle.


2012-12-11  Eric Botcazou  

* tree-ssa-loop-ivopts.c (prepare_decl_rtl) : Generate RTL
only for a DECL which HAS_RTL_P.


-- 
Eric BotcazouIndex: tree-ssa-loop-ivopts.c
===
--- tree-ssa-loop-ivopts.c	(revision 194382)
+++ tree-ssa-loop-ivopts.c	(working copy)
@@ -2806,7 +2806,7 @@ prepare_decl_rtl (tree *expr_p, int *ws,
 	   expr_p = &TREE_OPERAND (*expr_p, 0))
 	continue;
   obj = *expr_p;
-  if (DECL_P (obj) && !DECL_RTL_SET_P (obj))
+  if (DECL_P (obj) && HAS_RTL_P (obj) && !DECL_RTL_SET_P (obj))
 x = produce_memory_decl_rtl (obj, regno);
   break;
 

Re: [PATCH i386]: Enable push/pop in pro/epilogue for modern CPUs

2012-12-11 Thread Richard Biener
On Mon, Dec 10, 2012 at 10:07 PM, Mike Stump  wrote:
> On Dec 10, 2012, at 12:42 PM, Xinliang David Li  wrote:
>> I have not measured the CFI size impact -- but conceivably it should
>> be larger -- which is unfortunate.
>
> Code speed and size are preferable to optimizing dwarf size…  :-)  I'd let 
> dwarf 5 fix it!

Well, different to debug info, CFI data has to be in memory to make
unwinding work.
These days most Linux distributions enable asyncronous unwind tables so any
size savings due to shorter push/pop epilogue/prologue sequences has to be
offsetted by the increase in CFI data.  I'm not sure there is really a
speed difference
between both variants (well, maybe due to better icache footprint of
the push/pop
variant).

That said - I'd prefer to have more data on this before making the switch for
the generic model.  What was your original motivation?  Just "theory" or was
it a real case?

Thanks,
Richard.


Re: application/xml mime-type in recent libstdc++ doc changes

2012-12-11 Thread Florian Weimer

On 12/10/2012 06:52 PM, Benjamin De Kosnik wrote:



libstdc++-v3/doc/xsl/customization.xsl.in is marked as

   svn:mime-type = application/xml

at least on the 4.7 branch, having some unexpected outcome for svn
diff. If this was unintended, could you change the svn:mime-type
back to text?


This is unintentional, and frankly I don't know how the inital mime
type was created or how to fix it.


The Subversion client in Fedora 17 automatically sets application/xml 
for .xml files.  It seems that "svn add" runs the equivalent of "file 
-i" on the new file, and that prints "application/xml" even for text 
files.  I fell into this trap as well, and have now filed a bug:


https://bugzilla.redhat.com/show_bug.cgi?id=886005

--
Florian Weimer / Red Hat Product Security Team


Re: Fix ICE on loop over constant vector at -O

2012-12-11 Thread Richard Biener
On Tue, Dec 11, 2012 at 10:12 AM, Eric Botcazou  wrote:
>> ... so if would really be a pessimization doing that.  Of course handling
>> CONST_DECL in for_each_index is indeed obvious - I just was curios if
>> it was a missed-optimization opportunity as well.
>
> It turns out that, for the same testcase, &CONST_DECL is generated on the MIPS
> and prepare_decl_rtl is trying to put an RTX on the CONST_DECL, hence ICE.
>
> Tested on x86_64-suse-linux, applied on the mainline as obvious.  I agree that
> this is on the fringes of what we have to support, but we won't revisit it
> until the 4.9 development cycle.

Yeah - I plan to make CONST_DECLs much more present with getting rid of
&STRING_CST (making that &CONST_DECL of a string).  That solves one
weird special case we allow in the IL and also fixes wrong-code issues with LTO.

Richard.

>
> 2012-12-11  Eric Botcazou  
>
> * tree-ssa-loop-ivopts.c (prepare_decl_rtl) : Generate RTL
> only for a DECL which HAS_RTL_P.
>
>
> --
> Eric Botcazou


Re: [PATCH] Bugfix: Additional parameter for canonicalize comparison

2012-12-11 Thread Andreas Krebbel
On 11/12/12 10:16, Kaz Kojima wrote:
> Andreas Krebbel  wrote:
>> urgs - I'll fix this. Is the patch ok with that change for sh?
> 
> Yes, the sh portion is OK with that change, though it would be better
> to fix the users of sh_canonicalize_comparison instead of its wrapper
> as pointed out by rth and oleg.

For the backend internal uses sh_canonicalize_comparison has an additional 
'mode' parameter. It is
not clear to me why this is actually needed. But "fixing" the users would 
involve getting rid of
this parameter. I didn't want to change that with this patch since it might 
change the original
behaviour. The patch hopefully is a NOP for the change back-ends.

-Andreas-




[PATCH] Adjust build requirement docs for GCC 4.8

2012-12-11 Thread Richard Biener

This brings the build-requirements up-to-date with us now requiring
a C++ host compiler.  I optimistically increased the minimum required
GCC version listed from 2.95 to 3.4 as that is the earliest version
that could reasonably be called a C++98 compatible compiler (yeah,
lawrence will now argue that we want to require C++04 or how it was
called).

Installed.  Suggestions for incremental improvements (including
actually verifying the requirements) welcome.

At least this fixes this P1 bug for me.

Thanks,
Richard.

2012-12-11  Richard Biener  

PR other/54324
* doc/install.texi (Tools/packages necessary for building GCC):
State ISO C++98 host compiler requirement.  Increment minimum
GCC version required for building all languages for a cross-compiler
to 3.4 or later.

Index: gcc/doc/install.texi
===
--- gcc/doc/install.texi(revision 194388)
+++ gcc/doc/install.texi(working copy)
@@ -243,13 +243,15 @@ described below.
 
 @heading Tools/packages necessary for building GCC
 @table @asis
-@item ISO C90 compiler
+@item ISO C++98 compiler
 Necessary to bootstrap GCC, although versions of GCC prior
-to 3.4 also allow bootstrapping with a traditional (K&R) C compiler.
+to 4.8 also allow bootstrapping with a ISO C89 compiler and versions
+of GCC prior to 3.4 also allow bootstrapping with a traditional
+(K&R) C compiler.
 
 To build all languages in a cross-compiler or other configuration where
 3-stage bootstrap is not performed, you need to start with an existing
-GCC binary (version 2.95 or later) because source code for language
+GCC binary (version 3.4 or later) because source code for language
 frontends other than C might use GCC extensions.
 
 @item GNAT


Re: [PATCH] Bugfix: Additional parameter for canonicalize comparison

2012-12-11 Thread Oleg Endo
On Tue, 2012-12-11 at 11:15 +0100, Andreas Krebbel wrote:
> On 11/12/12 10:16, Kaz Kojima wrote:
> > Andreas Krebbel  wrote:
> >> urgs - I'll fix this. Is the patch ok with that change for sh?
> > 
> > Yes, the sh portion is OK with that change, though it would be better
> > to fix the users of sh_canonicalize_comparison instead of its wrapper
> > as pointed out by rth and oleg.
> 
> For the backend internal uses sh_canonicalize_comparison has an additional 
> 'mode' parameter. It is
> not clear to me why this is actually needed. But "fixing" the users would 
> involve getting rid of
> this parameter. I didn't want to change that with this patch since it might 
> change the original
> behaviour. The patch hopefully is a NOP for the change back-ends.
> 

The mode is used to do e.g.

  /* unsigned x > 0x7FFF   --> signed x < 0
 unsigned x <= 0x7FFF  --> signed x >= 0  */

which only works for SImode.  The mode parameter is passed to
sh_canonicalize_comparison by prepare_cbranch_operands which is invoked
by the cbranchdi4 expander, by expand_cbranchsi4 and by
expand_cbranchdi4.  When sh_canonicalize_comparison is invoked by
combine the mode is set to VOIDmode and the function will try to use the
mode of the operands instead.  Probably that would also be sufficient
when it is being used during cbranch expansion, as the operands will
have a mode.  I've not tried out doing that though when I refactored
those pieces a while ago.
I think fixing the users of sh_canonicalize_comparison should be done
after the int* vs. rtx_code thing has been figured out.  Otherwise, we'd
have to add casts in a couple of places (int* vs rtx_code*) and remove
them again afterwards.

Cheers,
Oleg



Re: [Fortran, (RFC) patch] PR49110/51055 Assignment to alloc. deferred-length character vars

2012-12-11 Thread Janus Weil
Ok, so here is a new patch, updated according to the suggestions of
David and Jakub. This now only touches the dotted variables, which are
responsible for the AIX trouble. Whether the same prefixing should
also be applied in other cases, we can still decide later.

> The remaining question is if this
> concept should be applied to all of the mangling with the new macro in
> gfortran.h.

The trouble is that changing the mangling will break ABI
compatibility. But, anyway, since we need to change it in some places,
it might be worth to clean up other places, too?

Cheers,
Janus


mangling_v4a.diff
Description: Binary data


Re: [Ada] Do not invoke gnatls unconditionally

2012-12-11 Thread Mike Stump
On Dec 11, 2012, at 12:01 AM, Eric Botcazou  wrote:
> Even if the Ada language isn't enabled, the Make-lang.in fragment of the Ada 
> compiler is processed and invokes gnatls unconditionally, which can result in 
> error messages if the command isn't present.

Thank you.


Re: [asan] Instrument non-public common vars

2012-12-11 Thread Dodji Seketeli
Jakub Jelinek  writes:

>   * varasm.c (get_variable_section): Don't return lcomm_section
>   for asan_protect_global decls.
>   * asan.c (asan_protect_global): Only avoid public common variables.
>   Don't call get_variable_section here.

This is OK, thanks.

-- 
Dodji


Re: [Fortran, (RFC) patch] PR49110/51055 Assignment to alloc. deferred-length character vars

2012-12-11 Thread Jakub Jelinek
On Tue, Dec 11, 2012 at 12:16:33PM +0100, Janus Weil wrote:
> Ok, so here is a new patch, updated according to the suggestions of
> David and Jakub. This now only touches the dotted variables, which are
> responsible for the AIX trouble. Whether the same prefixing should
> also be applied in other cases, we can still decide later.

Why are you changing anything in create_function_arglist (PARM_DECLs
can't ever be TREE_STATIC, and it is compiler internal (plus debug info)
thing how they are named, no need for any kind of mangling) or
saved_dovar (again, doesn't seem to be TREE_STATIC)?

Even in gfc_create_string_length you don't need to increase the length
of the names and obfuscate them if it isn't going to be TREE_STATIC.

Jakub


[PATCH][ARM][testsuite] Add testsuite options for AArch32 NEON

2012-12-11 Thread Kyrylo Tkachov
Hi all,

Since the new AArch32 NEON instructions in arm_neon.h are predicated on
__ARM_ARCH 8 the testsuite add_options procedure should also include
-march=armv8-a to make these instructions available.

This makes the new vrnd* tests in gcc.target/arm/neon PASS in situations
where armv8-a is not the default target.
No regressions otherwise on arm-none-eabi.

Ok for trunk?

Thanks,
Kyrill

gcc/testsuite/ChangeLog

2012-12-11  Kyrylo Tkachov  

* lib/target-supports.exp (add_options_for_arm_v8_neon):
Add -march=armv8-a.diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index ef93ad1..493a38a 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -2186,7 +2186,7 @@ proc add_options_for_arm_v8_neon { flags } {
 if { ! [check_effective_target_arm_v8_neon_ok] } {
 return "$flags"
 }
-return "$flags -mfpu=neon-fp-armv8 -mfloat-abi=softfp"
+return "$flags -march=armv8-a -mfpu=neon-fp-armv8 -mfloat-abi=softfp"
 }
 
 # Add the options needed for NEON.  We need either -mfloat-abi=softfp


[PATCH] Fix up undefined signed overflows in FIXED_SSNEG (PR libgcc/55451)

2012-12-11 Thread Jakub Jelinek
Hi!

This routine, besides aspiring to win obfuscated C contest (not trying to
address that) contains two undefined signed overflows, which presumably
show up in arm testing.  One overflow is on z = x - y; line,
where the x looks just like obfuscation (it is always 0), for input equal to
INT_MIN bits (from what I understand, the routine wants to return normal
negation of all values but INT_MIN, which is instead replaced with INT_MAX).
Fixed by doing the subtraction (== negation) in UINT_C_TYPE instead.
Another issue is that ((INT_C_TYPE) 1) << I_F_BITS, if it is equal to
INT_MIN, overflows on z-- (x >= 0 is always true, another obfuscation).

Untested, Greta, can you please test this on arm?  Ok for trunk?

2012-12-11  Jakub Jelinek  

PR libgcc/55451
* fixed-bit.c (FIXED_SSNEG): Avoid undefined signed overflows.

--- gcc/fixed-bit.c.jj  2011-11-04 07:49:37.0 +0100
+++ gcc/fixed-bit.c 2012-12-11 13:16:53.701767571 +0100
@@ -1,5 +1,5 @@
 /* This is a software fixed-point library.
-   Copyright (C) 2007, 2009, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009, 2011, 2012 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -569,16 +569,11 @@ FIXED_SSNEG (FIXED_C_TYPE a)
   INT_C_TYPE x, y, z;
   memcpy (&y, &a, FIXED_SIZE);
   x = 0;
-  z = x - y;
+  z = x - (UINT_C_TYPE) y;
   if (((x ^ y) >> I_F_BITS) & 1)
 {
   if (((z ^ x) >> I_F_BITS) & 1)
-{
-  z = 1;
-  z = z << I_F_BITS;
-  if (x >= 0)
-z--;
-}
+   z = (((UINT_C_TYPE) 1) << I_F_BITS) - 1;
 }
 #if HAVE_PADDING_BITS
   z = z << PADDING_BITS;

Jakub


Re: [Fortran, (RFC) patch] PR49110/51055 Assignment to alloc. deferred-length character vars

2012-12-11 Thread Janus Weil
2012/12/11 Jakub Jelinek :
> On Tue, Dec 11, 2012 at 12:16:33PM +0100, Janus Weil wrote:
>> Ok, so here is a new patch, updated according to the suggestions of
>> David and Jakub. This now only touches the dotted variables, which are
>> responsible for the AIX trouble. Whether the same prefixing should
>> also be applied in other cases, we can still decide later.
>
> Why are you changing anything in create_function_arglist (PARM_DECLs
> can't ever be TREE_STATIC, and it is compiler internal (plus debug info)
> thing how they are named, no need for any kind of mangling) or
> saved_dovar (again, doesn't seem to be TREE_STATIC)?
>
> Even in gfc_create_string_length you don't need to increase the length
> of the names and obfuscate them if it isn't going to be TREE_STATIC.

Yes, you're probably right.

Anyway, I'm out. I don't have the capacities to deal with this right
now (and, frankly, it's not my duty anyway) ...

Cheers,
Janus


PING^2: [PATCH] PR sanitizer/55533: Can't bootstrap libsanitizer

2012-12-11 Thread H.J. Lu
On Thu, Dec 6, 2012 at 7:07 AM, H.J. Lu  wrote:
> On Thu, Nov 29, 2012 at 10:30 AM, H.J. Lu  wrote:
>> Hi,
>>
>> Since libsanitizer is used for bootstrap and compiled with raw_cxx,
>> we need to use explicit -I for libstdc++-v3 header files in
>> libsanitizer.  Otherwise, we will get
>>
>> libtool: compile: unrecognized option `-D_GNU_SOURCE'
>> libtool: compile: Try `libtool --help' for more information.
>>
>> This patch fixes it.  OK to install?
>>
>> Thanks.
>>
>>
>> H.J.
>> ---
>>  libsanitizer/Makefile.am  |  2 --
>>  libsanitizer/Makefile.in  |  6 +++---
>>  libsanitizer/aclocal.m4   |  1 +
>>  libsanitizer/asan/Makefile.am |  6 --
>>  libsanitizer/asan/Makefile.in | 14 ++
>>  libsanitizer/configure| 22 --
>>  libsanitizer/configure.ac |  1 +
>>  libsanitizer/interception/Makefile.am |  6 --
>>  libsanitizer/interception/Makefile.in | 14 ++
>>  libsanitizer/sanitizer_common/Makefile.am |  6 --
>>  libsanitizer/sanitizer_common/Makefile.in | 14 ++
>>  libsanitizer/tsan/Makefile.am |  6 --
>>  libsanitizer/tsan/Makefile.in | 13 +
>>  14 files changed, 97 insertions(+), 31 deletions(-)
>>  create mode 100644 libsanitizer/ChangeLog.asan
>>
>> 2012-11-22  H.J. Lu  
>>
>> * Makefile.am (AM_MAKEFLAGS): Remove CC and CXX.
>> * configure.ac (ACX_NONCANONICAL_TARGET): New.
>> * asan/Makefile.am (AM_CXXFLAGS): Add -I for libstdc++-v3 header
>> files.
>> (AM_MAKEFLAGS): Remove CC and CXX.
>> * interception/Makefile.am: Likewise.
>> * sanitizer_common/Makefile.am: Likewise.
>> * tsan/Makefile.am: Likewise.
>> * Makefile.in: Regenerated.
>> * aclocal.m4: Likewise.
>> * configure: Likewise.
>> * asan/Makefile.in: Likewise.
>> * interception/Makefile.in: Likewise.
>> * sanitizer_common/Makefile.in: Likewise.
>> * tsan/Makefile.in: Likewise.
>>
>> diff --git a/libsanitizer/Makefile.am b/libsanitizer/Makefile.am
>> index 64d3d2e..cd4e92d 100644
>> --- a/libsanitizer/Makefile.am
>> +++ b/libsanitizer/Makefile.am
>> @@ -37,8 +37,6 @@ AM_MAKEFLAGS = \
>> "includedir=$(includedir)" \
>> "AR=$(AR)" \
>> "AS=$(AS)" \
>> -   "CC=$(CC)" \
>> -   "CXX=$(CXX)" \
>> "LD=$(LD)" \
>> "LIBCFLAGS=$(LIBCFLAGS)" \
>> "NM=$(NM)" \
>> diff --git a/libsanitizer/Makefile.in b/libsanitizer/Makefile.in
>> index 21c2711..53e0be9 100644
>> --- a/libsanitizer/Makefile.in
>> +++ b/libsanitizer/Makefile.in
>> @@ -41,7 +41,8 @@ DIST_COMMON = $(am__configure_deps) 
>> $(srcdir)/../config.guess \
>> $(srcdir)/../mkinstalldirs $(srcdir)/Makefile.am \
>> $(srcdir)/Makefile.in $(top_srcdir)/configure ChangeLog
>>  ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
>> -am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
>> +am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
>> +   $(top_srcdir)/../config/depstand.m4 \
>> $(top_srcdir)/../config/lead-dot.m4 \
>> $(top_srcdir)/../config/multi.m4 \
>> $(top_srcdir)/../config/override.m4 \
>> @@ -236,6 +237,7 @@ sysconfdir = @sysconfdir@
>>  target = @target@
>>  target_alias = @target_alias@
>>  target_cpu = @target_cpu@
>> +target_noncanonical = @target_noncanonical@
>>  target_os = @target_os@
>>  target_vendor = @target_vendor@
>>  toolexecdir = @toolexecdir@
>> @@ -278,8 +280,6 @@ AM_MAKEFLAGS = \
>> "includedir=$(includedir)" \
>> "AR=$(AR)" \
>> "AS=$(AS)" \
>> -   "CC=$(CC)" \
>> -   "CXX=$(CXX)" \
>> "LD=$(LD)" \
>> "LIBCFLAGS=$(LIBCFLAGS)" \
>> "NM=$(NM)" \
>> diff --git a/libsanitizer/aclocal.m4 b/libsanitizer/aclocal.m4
>> index a52bc30..d6782f8 100644
>> --- a/libsanitizer/aclocal.m4
>> +++ b/libsanitizer/aclocal.m4
>> @@ -990,6 +990,7 @@ AC_SUBST([am__tar])
>>  AC_SUBST([am__untar])
>>  ]) # _AM_PROG_TAR
>>
>> +m4_include([../config/acx.m4])
>>  m4_include([../config/depstand.m4])
>>  m4_include([../config/lead-dot.m4])
>>  m4_include([../config/multi.m4])
>> diff --git a/libsanitizer/asan/Makefile.am b/libsanitizer/asan/Makefile.am
>> index 3da1db3..45fb3b3 100644
>> --- a/libsanitizer/asan/Makefile.am
>> +++ b/libsanitizer/asan/Makefile.am
>> @@ -5,6 +5,10 @@ gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
>>
>>  DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS 
>> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DASAN_HAS_EXCEPTIONS=1 
>> -DASAN_FLEXIBLE_MAPPING_AND_OFFSET=0 -DASAN_NEEDS_SEGV=1
>>  AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic 
>> -Wno-long-long  -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer 
>> -funwind-tables -fvisibility=hidden -Wno-variadic-macros -Wno-c99-extensions
>> +## We require libstdc++-v3 to be in the same build tree.
>> +A

Re: [PATCH] Adjust build requirement docs for GCC 4.8

2012-12-11 Thread Gabriel Dos Reis
On Tue, Dec 11, 2012 at 4:14 AM, Richard Biener  wrote:
>
> This brings the build-requirements up-to-date with us now requiring
> a C++ host compiler.  I optimistically increased the minimum required
> GCC version listed from 2.95 to 3.4 as that is the earliest version
> that could reasonably be called a C++98 compatible compiler (yeah,
> lawrence will now argue that we want to require C++04 or how it was
> called).

For a long period of time, we (in the GCC/g++ front-end land) did not
make much distinction between C++98 and C++03 because the latter
is just a bug fix of the former.  I am not sure we are using any
construct for which the distinction would matter in practice or
whether there is any real C++ compiler used to bootstrap GCC for
which the fine distinctions matter.

-- Gaby


[patch] remove vcg CFG dumper

2012-12-11 Thread Steven Bosscher
Hello,

With the new GraphViz CFG dumper, the VCG dumper is now redundant. It
could only dump the CFG just after constructing it, and it doesn't
work as well as the DOT dumper (especially for multiple functions).

Bootstrapped&tested on powerpc64-unknown-linux-gnu. OK for trunk?

Ciao!
Steven


remove_vcg_dump.diff
Description: Binary data


Re: [patch] remove vcg CFG dumper

2012-12-11 Thread Richard Biener
On Tue, Dec 11, 2012 at 2:58 PM, Steven Bosscher  wrote:
> Hello,
>
> With the new GraphViz CFG dumper, the VCG dumper is now redundant. It
> could only dump the CFG just after constructing it, and it doesn't
> work as well as the DOT dumper (especially for multiple functions).
>
> Bootstrapped&tested on powerpc64-unknown-linux-gnu. OK for trunk?

Ok with me - please give others two seconds to object.

Thanks,
Richard.

> Ciao!
> Steven


[PATCH][ARM] ce_count attribute for thumb2 abssi2 patterns

2012-12-11 Thread Kyrylo Tkachov
Hi all,

This patch fixes http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55642
It sets the ce_count attribute for the abssi2 patterns in thumb2.md. If we
don't set it, gcc assumes that the pattern generates only one conditional
instruction and produces
the wrong enclosing IT instruction. The two affected patterns each produce
two conditional instructions.

A new testcase is added.
No regressions on arm-none-eabi with qemu.

Ok for trunk?

Thanks,
Kyrill

gcc/ChangeLog

2012-12-11  Kyrylo Tkachov  

PR target/55642
* config/arm/thumb2.md (*thumb2_abssi2):
Set ce_count attribute to 2.
(*thumb2_neg_abssi2): Likewise.


gcc/testsuite/ChangeLog

2012-12-11  Kyrylo Tkachov  

* gcc.target/arm/pr55642.c: New testcase.diff --git a/gcc/config/arm/thumb2.md b/gcc/config/arm/thumb2.md
index de573ca..f22666c 100644
--- a/gcc/config/arm/thumb2.md
+++ b/gcc/config/arm/thumb2.md
@@ -142,6 +142,7 @@
   [(set_attr "conds" "clob,*")
(set_attr "shift" "1")
(set_attr "predicable" "no, yes")
+   (set_attr "ce_count" "2")
(set_attr "length" "10,8")]
 )
 
@@ -156,6 +157,7 @@
   [(set_attr "conds" "clob,*")
(set_attr "shift" "1")
(set_attr "predicable" "no, yes")
+   (set_attr "ce_count" "2")
(set_attr "length" "10,8")]
 )
 
diff --git a/gcc/testsuite/gcc.target/arm/pr55642.c 
b/gcc/testsuite/gcc.target/arm/pr55642.c
new file mode 100644
index 000..10f2daa
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/pr55642.c
@@ -0,0 +1,15 @@
+/* { dg-options "-mthumb -O2" }  */
+/* { dg-do compile } */
+/* { dg-require-effective-target arm_thumb2_ok } */
+
+int
+foo (int v)
+{
+  register int i asm ("r0");
+  register int j asm ("r1");
+  if (v > 1)
+i = abs (j);
+
+  return i;
+}
+


Re: [PATCH][ARM] ce_count attribute for thumb2 abssi2 patterns

2012-12-11 Thread Ramana Radhakrishnan




gcc/testsuite/ChangeLog

2012-12-11  Kyrylo Tkachov  


Missing reference to PR in the testsuite changelog entry.



* gcc.target/arm/pr55642.c: New testcase.




Ok with that change.



Ramana





[PATCH] Xfail builtin-object-size-8.c test (PR tree-optimization/54570)

2012-12-11 Thread Jakub Jelinek
Hi!

As discussed on IRC, fixing this issue is probably 4.9 material, we have
some plans, but not for 4.8.  What GCC generates is actually not incorrect,
given __builtin_object_size (x, 1) being a high bound, it is just larger than
strictly required, but I hope it won't trigger very much on real-world code,
where it could mean less strict -D_FORTIFY_SOURCE=2 protection.
The following patch xfails the problematic testcase and instead adds a new
testcase which tests the same things, but doesn't test interaction of
different __builtin_object_size calls (for different fields) from the same
pointer.  Tested on x86_64-linux, ok for trunk?

2012-12-11  Jakub Jelinek  

PR tree-optimization/54570
* gcc.dg/builtin-object-size-8.c: Xfail.
* gcc.dg/builtin-object-size-13.c: New test.

--- gcc/testsuite/gcc.dg/builtin-object-size-8.c.jj 2009-07-20 
20:41:51.0 +0200
+++ gcc/testsuite/gcc.dg/builtin-object-size-8.c2012-12-11 
15:13:59.646748335 +0100
@@ -1,4 +1,4 @@
-/* { dg-do run } */
+/* { dg-do run { xfail *-*-* } } */
 /* { dg-options "-O2" } */
 
 typedef __SIZE_TYPE__ size_t;
--- gcc/testsuite/gcc.dg/builtin-object-size-13.c.jj2012-12-11 
15:10:48.046891600 +0100
+++ gcc/testsuite/gcc.dg/builtin-object-size-13.c   2012-12-11 
15:10:24.0 +0100
@@ -0,0 +1,351 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+typedef __SIZE_TYPE__ size_t;
+extern void *malloc (size_t);
+extern void free (void *);
+extern void abort (void);
+
+union A
+{
+  int a1;
+  char a2[3];
+};
+
+union B
+{
+  long long b1;
+  union A b2;
+};
+
+struct C
+{
+  int c1;
+  union A c2;
+};
+
+struct D
+{
+  int d1;
+  union B d2;
+};
+
+union E
+{
+  struct C e1;
+  char e2[3];
+};
+
+union F
+{
+  int f1;
+  struct D f2;
+};
+
+struct G
+{
+  union A g1;
+  char g2;
+};
+
+struct H
+{
+  int h1;
+  union E h2;
+};
+
+#define T(X, S0, S1) \
+  if (__builtin_object_size (X, 0) != (S0))\
+abort ();  \
+  if (__builtin_object_size (X, 1) != (S1))\
+abort ();  \
+  if (__builtin_object_size (X, 2) != (S0))\
+abort ();  \
+  if (__builtin_object_size (X, 3) != (S1))\
+abort ()
+#define TS(X, S0) T(&X, S0, sizeof (X))
+#define TA(X, S0, S1) \
+  T(X, S0, S1); T(&X[0], S0, S1); T(&X[1], (S0) - 1, (S1) - 1)
+#define TF(X, S0) TA(X, S0, S0)
+
+int
+main (void)
+{
+  size_t s, o, o2;
+
+  s = sizeof (union A);
+  o = 0;
+  union A *a1 = malloc (s);
+  union A *a2 = malloc (o + 212);
+  TS (a1->a1, s);
+  s = o + 212;
+  TS (a2->a1, s);
+  free (a2);
+  free (a1);
+  s = sizeof (union A);
+  o = 0;
+  a1 = malloc (s);
+  a2 = malloc (o + 212);
+  TF (a1->a2, s);
+  s = o + 212;
+  TF (a2->a2, s);
+  free (a2);
+  free (a1);
+
+  s = sizeof (union B);
+  o = 0;
+  union B *b1 = malloc (s);
+  union B *b2 = malloc (o + 212);
+  TS (b1->b1, s);
+  s = o + 212;
+  TS (b2->b1, s);
+  free (b2);
+  free (b1);
+  s = sizeof (union B);
+  o = 0;
+  b1 = malloc (s);
+  b2 = malloc (o + 212);
+  TS (b1->b2.a1, s);
+  s = o + 212;
+  TS (b2->b2.a1, s);
+  free (b2);
+  free (b1);
+  s = sizeof (union B);
+  o = 0;
+  b1 = malloc (s);
+  b2 = malloc (o + 212);
+  TF (b1->b2.a2, s);
+  s = o + 212;
+  TF (b2->b2.a2, s);
+  free (b2);
+  free (b1);
+
+  s = sizeof (struct C);
+  o = __builtin_offsetof (struct C, c2);
+  struct C *c1 = malloc (s);
+  struct C *c2 = malloc (o + 212);
+  TS (c1->c1, s);
+  s = o + 212;
+  TS (c2->c1, s);
+  free (c2);
+  free (c1);
+  s = sizeof (struct C);
+  o = __builtin_offsetof (struct C, c2);
+  c1 = malloc (s);
+  c2 = malloc (o + 212);
+  TS (c1->c2.a1, s - o);
+  s = o + 212;
+  TS (c2->c2.a1, s - o);
+  free (c2);
+  free (c1);
+  s = sizeof (struct C);
+  o = __builtin_offsetof (struct C, c2);
+  c1 = malloc (s);
+  c2 = malloc (o + 212);
+  TF (c1->c2.a2, s - o);
+  s = o + 212;
+  TF (c2->c2.a2, s - o);
+  free (c2);
+  free (c1);
+
+  s = sizeof (struct D);
+  o = __builtin_offsetof (struct D, d2);
+  struct D *d1 = malloc (s);
+  struct D *d2 = malloc (o + 212);
+  TS (d1->d1, s);
+  s = o + 212;
+  TS (d2->d1, s);
+  free (d2);
+  free (d1);
+  s = sizeof (struct D);
+  o = __builtin_offsetof (struct D, d2);
+  d1 = malloc (s);
+  d2 = malloc (o + 212);
+  TS (d1->d2.b1, s - o);
+  s = o + 212;
+  TS (d2->d2.b1, s - o);
+  free (d2);
+  free (d1);
+  s = sizeof (struct D);
+  o = __builtin_offsetof (struct D, d2);
+  d1 = malloc (s);
+  d2 = malloc (o + 212);
+  TS (d1->d2.b2.a1, s - o);
+  s = o + 212;
+  TS (d2->d2.b2.a1, s - o);
+  free (d2);
+  free (d1);
+  s = sizeof (struct D);
+  o = __builtin_offsetof (struct D, d2);
+  d1 = malloc (s);
+  d2 = malloc (o + 212);
+  TF (d1->d2.b2.a2, s - o);
+  s = o + 212;
+  TF (d2->d2.b2.a2, s - o);
+  free (d2);
+  free (d1);
+
+  s = sizeof (union E);
+  o = __builtin_offsetof (union E, e1.c2);
+  union E *e1 = malloc (s);
+  union E *e2 = malloc (o + 212);
+  TS (e1->e1.c1, s);
+  s = o +

Re: [PATCH] Xfail builtin-object-size-8.c test (PR tree-optimization/54570)

2012-12-11 Thread Richard Biener
On Tue, 11 Dec 2012, Jakub Jelinek wrote:

> Hi!
> 
> As discussed on IRC, fixing this issue is probably 4.9 material, we have
> some plans, but not for 4.8.  What GCC generates is actually not incorrect,
> given __builtin_object_size (x, 1) being a high bound, it is just larger than
> strictly required, but I hope it won't trigger very much on real-world code,
> where it could mean less strict -D_FORTIFY_SOURCE=2 protection.
> The following patch xfails the problematic testcase and instead adds a new
> testcase which tests the same things, but doesn't test interaction of
> different __builtin_object_size calls (for different fields) from the same
> pointer.  Tested on x86_64-linux, ok for trunk?

Ok.

Thanks,
Richard.

> 2012-12-11  Jakub Jelinek  
> 
>   PR tree-optimization/54570
>   * gcc.dg/builtin-object-size-8.c: Xfail.
>   * gcc.dg/builtin-object-size-13.c: New test.
> 
> --- gcc/testsuite/gcc.dg/builtin-object-size-8.c.jj   2009-07-20 
> 20:41:51.0 +0200
> +++ gcc/testsuite/gcc.dg/builtin-object-size-8.c  2012-12-11 
> 15:13:59.646748335 +0100
> @@ -1,4 +1,4 @@
> -/* { dg-do run } */
> +/* { dg-do run { xfail *-*-* } } */
>  /* { dg-options "-O2" } */
>  
>  typedef __SIZE_TYPE__ size_t;
> --- gcc/testsuite/gcc.dg/builtin-object-size-13.c.jj  2012-12-11 
> 15:10:48.046891600 +0100
> +++ gcc/testsuite/gcc.dg/builtin-object-size-13.c 2012-12-11 
> 15:10:24.0 +0100
> @@ -0,0 +1,351 @@
> +/* { dg-do run } */
> +/* { dg-options "-O2" } */
> +
> +typedef __SIZE_TYPE__ size_t;
> +extern void *malloc (size_t);
> +extern void free (void *);
> +extern void abort (void);
> +
> +union A
> +{
> +  int a1;
> +  char a2[3];
> +};
> +
> +union B
> +{
> +  long long b1;
> +  union A b2;
> +};
> +
> +struct C
> +{
> +  int c1;
> +  union A c2;
> +};
> +
> +struct D
> +{
> +  int d1;
> +  union B d2;
> +};
> +
> +union E
> +{
> +  struct C e1;
> +  char e2[3];
> +};
> +
> +union F
> +{
> +  int f1;
> +  struct D f2;
> +};
> +
> +struct G
> +{
> +  union A g1;
> +  char g2;
> +};
> +
> +struct H
> +{
> +  int h1;
> +  union E h2;
> +};
> +
> +#define T(X, S0, S1) \
> +  if (__builtin_object_size (X, 0) != (S0))  \
> +abort ();\
> +  if (__builtin_object_size (X, 1) != (S1))  \
> +abort ();\
> +  if (__builtin_object_size (X, 2) != (S0))  \
> +abort ();\
> +  if (__builtin_object_size (X, 3) != (S1))  \
> +abort ()
> +#define TS(X, S0) T(&X, S0, sizeof (X))
> +#define TA(X, S0, S1) \
> +  T(X, S0, S1); T(&X[0], S0, S1); T(&X[1], (S0) - 1, (S1) - 1)
> +#define TF(X, S0) TA(X, S0, S0)
> +
> +int
> +main (void)
> +{
> +  size_t s, o, o2;
> +
> +  s = sizeof (union A);
> +  o = 0;
> +  union A *a1 = malloc (s);
> +  union A *a2 = malloc (o + 212);
> +  TS (a1->a1, s);
> +  s = o + 212;
> +  TS (a2->a1, s);
> +  free (a2);
> +  free (a1);
> +  s = sizeof (union A);
> +  o = 0;
> +  a1 = malloc (s);
> +  a2 = malloc (o + 212);
> +  TF (a1->a2, s);
> +  s = o + 212;
> +  TF (a2->a2, s);
> +  free (a2);
> +  free (a1);
> +
> +  s = sizeof (union B);
> +  o = 0;
> +  union B *b1 = malloc (s);
> +  union B *b2 = malloc (o + 212);
> +  TS (b1->b1, s);
> +  s = o + 212;
> +  TS (b2->b1, s);
> +  free (b2);
> +  free (b1);
> +  s = sizeof (union B);
> +  o = 0;
> +  b1 = malloc (s);
> +  b2 = malloc (o + 212);
> +  TS (b1->b2.a1, s);
> +  s = o + 212;
> +  TS (b2->b2.a1, s);
> +  free (b2);
> +  free (b1);
> +  s = sizeof (union B);
> +  o = 0;
> +  b1 = malloc (s);
> +  b2 = malloc (o + 212);
> +  TF (b1->b2.a2, s);
> +  s = o + 212;
> +  TF (b2->b2.a2, s);
> +  free (b2);
> +  free (b1);
> +
> +  s = sizeof (struct C);
> +  o = __builtin_offsetof (struct C, c2);
> +  struct C *c1 = malloc (s);
> +  struct C *c2 = malloc (o + 212);
> +  TS (c1->c1, s);
> +  s = o + 212;
> +  TS (c2->c1, s);
> +  free (c2);
> +  free (c1);
> +  s = sizeof (struct C);
> +  o = __builtin_offsetof (struct C, c2);
> +  c1 = malloc (s);
> +  c2 = malloc (o + 212);
> +  TS (c1->c2.a1, s - o);
> +  s = o + 212;
> +  TS (c2->c2.a1, s - o);
> +  free (c2);
> +  free (c1);
> +  s = sizeof (struct C);
> +  o = __builtin_offsetof (struct C, c2);
> +  c1 = malloc (s);
> +  c2 = malloc (o + 212);
> +  TF (c1->c2.a2, s - o);
> +  s = o + 212;
> +  TF (c2->c2.a2, s - o);
> +  free (c2);
> +  free (c1);
> +
> +  s = sizeof (struct D);
> +  o = __builtin_offsetof (struct D, d2);
> +  struct D *d1 = malloc (s);
> +  struct D *d2 = malloc (o + 212);
> +  TS (d1->d1, s);
> +  s = o + 212;
> +  TS (d2->d1, s);
> +  free (d2);
> +  free (d1);
> +  s = sizeof (struct D);
> +  o = __builtin_offsetof (struct D, d2);
> +  d1 = malloc (s);
> +  d2 = malloc (o + 212);
> +  TS (d1->d2.b1, s - o);
> +  s = o + 212;
> +  TS (d2->d2.b1, s - o);
> +  free (d2);
> +  free (d1);
> +  s = sizeof (struct D);
> +  o = __builtin_offsetof (struct D, d2);
> +  d1 = malloc (s);
> +  d2 = malloc (o + 212);
> +  TS (d1->d2

Re: PING^2: [PATCH] PR sanitizer/55533: Can't bootstrap libsanitizer

2012-12-11 Thread Paolo Bonzini
Il 11/12/2012 14:47, H.J. Lu ha scritto:
> On Thu, Dec 6, 2012 at 7:07 AM, H.J. Lu  wrote:
>> On Thu, Nov 29, 2012 at 10:30 AM, H.J. Lu  wrote:
>>> Hi,
>>>
>>> Since libsanitizer is used for bootstrap and compiled with raw_cxx,
>>> we need to use explicit -I for libstdc++-v3 header files in
>>> libsanitizer.  Otherwise, we will get
>>>
>>> libtool: compile: unrecognized option `-D_GNU_SOURCE'
>>> libtool: compile: Try `libtool --help' for more information.
>>>
>>> This patch fixes it.  OK to install?
>>>
>>> Thanks.
>>>
>>>
>>> H.J.
>>> ---
>>>  libsanitizer/Makefile.am  |  2 --
>>>  libsanitizer/Makefile.in  |  6 +++---
>>>  libsanitizer/aclocal.m4   |  1 +
>>>  libsanitizer/asan/Makefile.am |  6 --
>>>  libsanitizer/asan/Makefile.in | 14 ++
>>>  libsanitizer/configure| 22 --
>>>  libsanitizer/configure.ac |  1 +
>>>  libsanitizer/interception/Makefile.am |  6 --
>>>  libsanitizer/interception/Makefile.in | 14 ++
>>>  libsanitizer/sanitizer_common/Makefile.am |  6 --
>>>  libsanitizer/sanitizer_common/Makefile.in | 14 ++
>>>  libsanitizer/tsan/Makefile.am |  6 --
>>>  libsanitizer/tsan/Makefile.in | 13 +
>>>  14 files changed, 97 insertions(+), 31 deletions(-)
>>>  create mode 100644 libsanitizer/ChangeLog.asan
>>>
>>> 2012-11-22  H.J. Lu  
>>>
>>> * Makefile.am (AM_MAKEFLAGS): Remove CC and CXX.
>>> * configure.ac (ACX_NONCANONICAL_TARGET): New.
>>> * asan/Makefile.am (AM_CXXFLAGS): Add -I for libstdc++-v3 header
>>> files.
>>> (AM_MAKEFLAGS): Remove CC and CXX.
>>> * interception/Makefile.am: Likewise.
>>> * sanitizer_common/Makefile.am: Likewise.
>>> * tsan/Makefile.am: Likewise.
>>> * Makefile.in: Regenerated.
>>> * aclocal.m4: Likewise.
>>> * configure: Likewise.
>>> * asan/Makefile.in: Likewise.
>>> * interception/Makefile.in: Likewise.
>>> * sanitizer_common/Makefile.in: Likewise.
>>> * tsan/Makefile.in: Likewise.
>>>
>>> diff --git a/libsanitizer/Makefile.am b/libsanitizer/Makefile.am
>>> index 64d3d2e..cd4e92d 100644
>>> --- a/libsanitizer/Makefile.am
>>> +++ b/libsanitizer/Makefile.am
>>> @@ -37,8 +37,6 @@ AM_MAKEFLAGS = \
>>> "includedir=$(includedir)" \
>>> "AR=$(AR)" \
>>> "AS=$(AS)" \
>>> -   "CC=$(CC)" \
>>> -   "CXX=$(CXX)" \
>>> "LD=$(LD)" \
>>> "LIBCFLAGS=$(LIBCFLAGS)" \
>>> "NM=$(NM)" \

As a followup please check if AM_MAKEFLAGS is needed at all.

>>> diff --git a/libsanitizer/Makefile.in b/libsanitizer/Makefile.in
>>> index 21c2711..53e0be9 100644
>>> --- a/libsanitizer/Makefile.in
>>> +++ b/libsanitizer/Makefile.in

Please do not include regenerated files in the patch.

>>> diff --git a/libsanitizer/asan/Makefile.am b/libsanitizer/asan/Makefile.am
>>> index 3da1db3..45fb3b3 100644
>>> --- a/libsanitizer/asan/Makefile.am
>>> +++ b/libsanitizer/asan/Makefile.am
>>> @@ -5,6 +5,10 @@ gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
>>>
>>>  DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS 
>>> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DASAN_HAS_EXCEPTIONS=1 
>>> -DASAN_FLEXIBLE_MAPPING_AND_OFFSET=0 -DASAN_NEEDS_SEGV=1
>>>  AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic 
>>> -Wno-long-long  -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer 
>>> -funwind-tables -fvisibility=hidden -Wno-variadic-macros -Wno-c99-extensions
>>> +## We require libstdc++-v3 to be in the same build tree.
>>> +AM_CXXFLAGS += -I../../libstdc++-v3/include \
>>> +  -I../../libstdc++-v3/include/$(target_noncanonical) \
>>> +  -I$(srcdir)/../../libstdc++-v3/libsupc++

As a followup, please bring back the possibility to build libsanitizer
standalone, also wrapping the chooice of flags to link to libstdc++-v3
in a new config/libstdc++-raw-cxx.m4 file.

Bonus points for using this macro elsewhere in the tree.

>>>  ACLOCAL_AMFLAGS = -I $(top_srcdir) -I $(top_srcdir)/config
>>>
>>>  toolexeclib_LTLIBRARIES = libasan.la
>>> @@ -64,8 +68,6 @@ AM_MAKEFLAGS = \
>>> "includedir=$(includedir)" \
>>> "AR=$(AR)" \
>>> "AS=$(AS)" \
>>> -   "CC=$(CC)" \
>>> -   "CXX=$(CXX)" \
>>> "LD=$(LD)" \
>>> "LIBCFLAGS=$(LIBCFLAGS)" \
>>> "NM=$(NM)" \

Same as above, and same for other .am files.


>>> diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac
>>> index 2d62ec4..9c73904 100644
>>> --- a/libsanitizer/configure.ac
>>> +++ b/libsanitizer/configure.ac
>>> @@ -19,6 +19,7 @@ AC_MSG_RESULT($version_specific_libs)
>>>  # Do not delete or change the following two lines.  For why, see
>>>  # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
>>>  AC_CANONICAL_SYSTEM
>>> +ACX_NONCANONICAL_TARGET

Note that i

Re: [PATCH] Fix up undefined signed overflows in FIXED_SSNEG (PR libgcc/55451)

2012-12-11 Thread Ian Lance Taylor
On Tue, Dec 11, 2012 at 4:55 AM, Jakub Jelinek  wrote:
>
> This routine, besides aspiring to win obfuscated C contest (not trying to
> address that) contains two undefined signed overflows, which presumably
> show up in arm testing.  One overflow is on z = x - y; line,
> where the x looks just like obfuscation (it is always 0), for input equal to
> INT_MIN bits (from what I understand, the routine wants to return normal
> negation of all values but INT_MIN, which is instead replaced with INT_MAX).
> Fixed by doing the subtraction (== negation) in UINT_C_TYPE instead.
> Another issue is that ((INT_C_TYPE) 1) << I_F_BITS, if it is equal to
> INT_MIN, overflows on z-- (x >= 0 is always true, another obfuscation).
>
> Untested, Greta, can you please test this on arm?  Ok for trunk?
>
> 2012-12-11  Jakub Jelinek  
>
> PR libgcc/55451
> * fixed-bit.c (FIXED_SSNEG): Avoid undefined signed overflows.
>
> --- gcc/fixed-bit.c.jj  2011-11-04 07:49:37.0 +0100
> +++ gcc/fixed-bit.c 2012-12-11 13:16:53.701767571 +0100
> @@ -1,5 +1,5 @@
>  /* This is a software fixed-point library.
> -   Copyright (C) 2007, 2009, 2011 Free Software Foundation, Inc.
> +   Copyright (C) 2007, 2009, 2011, 2012 Free Software Foundation, Inc.
>
>  This file is part of GCC.
>
> @@ -569,16 +569,11 @@ FIXED_SSNEG (FIXED_C_TYPE a)
>INT_C_TYPE x, y, z;
>memcpy (&y, &a, FIXED_SIZE);
>x = 0;
> -  z = x - y;
> +  z = x - (UINT_C_TYPE) y;
>if (((x ^ y) >> I_F_BITS) & 1)
>  {
>if (((z ^ x) >> I_F_BITS) & 1)
> -{
> -  z = 1;
> -  z = z << I_F_BITS;
> -  if (x >= 0)
> -z--;
> -}
> +   z = (((UINT_C_TYPE) 1) << I_F_BITS) - 1;
>  }
>  #if HAVE_PADDING_BITS
>z = z << PADDING_BITS;


I presume that the intent of the obfuscation is to make SSNEG look
exactly like SSSUB.  And SSSUB appears to have the exact problems that
you are fixing here.  So I think you ought to fix both the same way.

Ian


Re: PING^2: [PATCH] PR sanitizer/55533: Can't bootstrap libsanitizer

2012-12-11 Thread H.J. Lu
On Tue, Dec 11, 2012 at 6:36 AM, Paolo Bonzini  wrote:

> As a followup please check if AM_MAKEFLAGS is needed at all.

I think it is just copied from elsewhere.  I will take a look after this.

 diff --git a/libsanitizer/Makefile.in b/libsanitizer/Makefile.in
 index 21c2711..53e0be9 100644
 --- a/libsanitizer/Makefile.in
 +++ b/libsanitizer/Makefile.in
>
> Please do not include regenerated files in the patch.

Sure.

 diff --git a/libsanitizer/asan/Makefile.am b/libsanitizer/asan/Makefile.am
 index 3da1db3..45fb3b3 100644
 --- a/libsanitizer/asan/Makefile.am
 +++ b/libsanitizer/asan/Makefile.am
 @@ -5,6 +5,10 @@ gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)

  DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS 
 -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DASAN_HAS_EXCEPTIONS=1 
 -DASAN_FLEXIBLE_MAPPING_AND_OFFSET=0 -DASAN_NEEDS_SEGV=1
  AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic 
 -Wno-long-long  -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer 
 -funwind-tables -fvisibility=hidden -Wno-variadic-macros 
 -Wno-c99-extensions
 +## We require libstdc++-v3 to be in the same build tree.
 +AM_CXXFLAGS += -I../../libstdc++-v3/include \
 +  -I../../libstdc++-v3/include/$(target_noncanonical) \
 +  -I$(srcdir)/../../libstdc++-v3/libsupc++
>
> As a followup, please bring back the possibility to build libsanitizer
> standalone, also wrapping the chooice of flags to link to libstdc++-v3
> in a new config/libstdc++-raw-cxx.m4 file.

I don't believe it is possible with libsanitizer in GCC since it
uses GCC toplevel files.  Where do you get those toplevel files
when you compile it standalone?

> Bonus points for using this macro elsewhere in the tree.
>
  ACLOCAL_AMFLAGS = -I $(top_srcdir) -I $(top_srcdir)/config

  toolexeclib_LTLIBRARIES = libasan.la
 @@ -64,8 +68,6 @@ AM_MAKEFLAGS = \
 "includedir=$(includedir)" \
 "AR=$(AR)" \
 "AS=$(AS)" \
 -   "CC=$(CC)" \
 -   "CXX=$(CXX)" \
 "LD=$(LD)" \
 "LIBCFLAGS=$(LIBCFLAGS)" \
 "NM=$(NM)" \
>
> Same as above, and same for other .am files.

I prefer to leave them where they are so that

# cd asan
# make

can compile.  If they are passed from the parent directory,
this won't work.

>
 diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac
 index 2d62ec4..9c73904 100644
 --- a/libsanitizer/configure.ac
 +++ b/libsanitizer/configure.ac
 @@ -19,6 +19,7 @@ AC_MSG_RESULT($version_specific_libs)
  # Do not delete or change the following two lines.  For why, see
  # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
  AC_CANONICAL_SYSTEM
 +ACX_NONCANONICAL_TARGET
>
> Note that if you create a new macro, ACX_NONCANONICAL_TARGET should be
> AC_REQUIREd there.
>
> Paolo
>

How do I AC_REQUIRE it? I just copied it from other places:

[hjl@gnu-6 gcc]$ grep ACX_NONCANONICAL_TARGET */configure.*
boehm-gc/configure.ac:ACX_NONCANONICAL_TARGET
fixincludes/configure.ac:ACX_NONCANONICAL_TARGET
gcc/configure.ac:ACX_NONCANONICAL_TARGET
gnattools/configure.ac:ACX_NONCANONICAL_TARGET
libada/configure.ac:ACX_NONCANONICAL_TARGET
libgcc/configure.ac:ACX_NONCANONICAL_TARGET
libgfortran/configure.ac:ACX_NONCANONICAL_TARGET
libmudflap/configure.ac:ACX_NONCANONICAL_TARGET
libobjc/configure.ac:ACX_NONCANONICAL_TARGET
libquadmath/configure.ac:ACX_NONCANONICAL_TARGET
libssp/configure.ac:ACX_NONCANONICAL_TARGET

Thanks.

-- 
H.J.


Re: [PATCH] Fix up undefined signed overflows in FIXED_SSNEG (PR libgcc/55451)

2012-12-11 Thread Jakub Jelinek
On Tue, Dec 11, 2012 at 06:52:38AM -0800, Ian Lance Taylor wrote:
> I presume that the intent of the obfuscation is to make SSNEG look
> exactly like SSSUB.  And SSSUB appears to have the exact problems that
> you are fixing here.  So I think you ought to fix both the same way.

Ugh, I was hoping for a small patch.
Here is updated patch for the 5 routines I could quickly find by looking
around.

2012-12-11  Jakub Jelinek  

PR libgcc/55451
* fixed-bit.c (FIXED_SSADD, FIXED_USADD, FIXED_SSSUB, FIXED_USSUB,
FIXED_SSNEG): Avoid undefined signed overflows.

--- libgcc/fixed-bit.c.jj   2011-11-04 07:49:37.0 +0100
+++ libgcc/fixed-bit.c  2012-12-11 16:01:30.178653065 +0100
@@ -1,5 +1,5 @@
 /* This is a software fixed-point library.
-   Copyright (C) 2007, 2009, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2007, 2009, 2011, 2012 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -80,15 +80,14 @@ FIXED_SSADD (FIXED_C_TYPE a, FIXED_C_TYP
   INT_C_TYPE x, y, z;
   memcpy (&x, &a, FIXED_SIZE);
   memcpy (&y, &b, FIXED_SIZE);
-  z = x + y;
+  z = x + (UINT_C_TYPE) y;
   if x ^ y) >> I_F_BITS) & 1) == 0)
 {
   if (((z ^ x) >> I_F_BITS) & 1)
 {
-  z = 1;
-  z = z << I_F_BITS;
-  if (x >= 0)
-z--;
+ z = ((UINT_C_TYPE) 1) << I_F_BITS;
+ if (x >= 0)
+   z -= (UINT_C_TYPE) 1;
 }
 }
 #if HAVE_PADDING_BITS
@@ -108,7 +107,7 @@ FIXED_USADD (FIXED_C_TYPE a, FIXED_C_TYP
   INT_C_TYPE x, y, z;
   memcpy (&x, &a, FIXED_SIZE);
   memcpy (&y, &b, FIXED_SIZE);
-  z = x + y;
+  z = x + (UINT_C_TYPE) y;
 #if HAVE_PADDING_BITS
   z = z << PADDING_BITS;
   z = z >> PADDING_BITS;
@@ -152,15 +151,14 @@ FIXED_SSSUB (FIXED_C_TYPE a, FIXED_C_TYP
   INT_C_TYPE x, y, z;
   memcpy (&x, &a, FIXED_SIZE);
   memcpy (&y, &b, FIXED_SIZE);
-  z = x - y;
+  z = x - (UINT_C_TYPE) y;
   if (((x ^ y) >> I_F_BITS) & 1)
 {
   if (((z ^ x) >> I_F_BITS) & 1)
 {
-  z = 1;
-  z = z << I_F_BITS;
-  if (x >= 0)
-z--;
+ z = ((UINT_C_TYPE) 1) << I_F_BITS;
+ if (x >= 0)
+   z -= (UINT_C_TYPE) 1;
 }
 }
 #if HAVE_PADDING_BITS
@@ -180,7 +178,7 @@ FIXED_USSUB (FIXED_C_TYPE a, FIXED_C_TYP
   INT_C_TYPE x, y, z;
   memcpy (&x, &a, FIXED_SIZE);
   memcpy (&y, &b, FIXED_SIZE);
-  z = x - y;
+  z = x - (UINT_C_TYPE) y;
   if (x < y)
 z = 0;
 #if HAVE_PADDING_BITS
@@ -569,16 +567,11 @@ FIXED_SSNEG (FIXED_C_TYPE a)
   INT_C_TYPE x, y, z;
   memcpy (&y, &a, FIXED_SIZE);
   x = 0;
-  z = x - y;
+  z = x - (UINT_C_TYPE) y;
   if (((x ^ y) >> I_F_BITS) & 1)
 {
   if (((z ^ x) >> I_F_BITS) & 1)
-{
-  z = 1;
-  z = z << I_F_BITS;
-  if (x >= 0)
-z--;
-}
+   z = (((UINT_C_TYPE) 1) << I_F_BITS) - 1;
 }
 #if HAVE_PADDING_BITS
   z = z << PADDING_BITS;


Jakub


Re: [PATCH] PR c++/53609 - Wrong argument deduction for pack expansion in argument pack

2012-12-11 Thread Dodji Seketeli
Jason Merrill  writes:

> On 12/08/2012 05:12 PM, Dodji Seketeli wrote:
> >>> +  else if (arg_from_pack_level_to_prune || has_empty_arg)
> >>> +{
> >>> +  /* ... we just return a pack expansion which pattern is PATTERN
> >>> +  into which ARGS has been substituted.  */
> >>> +  *instantiation_yields_no_list_p = true;
> >>> +}
> >>
> > Though I think it would still be appropriate to keep this 'if' just to
> > avoid going into the 'else' block for cases where we know that looping
> > over the parameter packs (and do the ARGUMENT_PACK_SELECT dance) is
> > unnecessary; all we want is to go straight to the point where we
> > substitute args into the pattern, build a pack expansion and return
> > it.  Or isn't what you meant?
> 
> I suppose we should keep this for has_empty_arg, but I'd like to do
> away with special handling of the arg_from_parm_pack case if possible,
> as it's a lot of extra complexity.

OK, done.

> 
> > My understanding is that in practise, we never hit this point in the
> > previous code.  The reason why len would still be negative at this
> > point would be if we didn't find any (good) argument pack.  But in
> > that case, we would have considered that we have unsubstituted packs
> > and would have returned an unsubstituted pack expansion before we
> > reach this point.
> 
> I don't see that; in the old code, if there are unsubstituted packs we
> tsubst the args into the pattern.

Yes, and we build and return a pack expansion with that pattern.
That's what I meant clumsily by "unsubstituted pack expansion".  I
should have probably said "uninstantiated".

So, all this to say that we never return error_mark_node for the case
where len < 0 in practise.  Do you agree?

> 
> > +  /* We got some full packs, but we can't substitute them in until we
> > +have values for all the packs.  So remember these until then.  */
> 
> How can having this in gen_elem_of_pack_expansion_instantiation could
> work?  We don't want an expansion for each element of the packs that
> we have.

Oops, it seems I was too hasty in trying to do away with the
instantiation_yields_no_list_p parameter to
gen_elem_of_pack_expansion_instantiation.  That is, whenever we are in
this case we must return just one expansion, as you noted.  So I am
putting back a way for gen_elem_of_pack_expansion_instantiation to
notify its caller that it needs to return the uninstantiated pack
expansion right away.

Tested on x86_64-unknown-linux-gnu against trunk.

gcc/cp/

* pt.c (argument_pack_element_is_expansion_p)
(make_argument_pack_select, scan_parm_packs)
(gen_elem_of_pack_expansion_instantiation): New static functions.
(has_bare_parameter_packs): Factorized out of ...
(check_for_bare_parameter_packs): ... here.
(tsubst): When looking through an ARGUMENT_PACK_SELECT tree node,
look through the possibly resulting pack expansion as well.
(tsubst_pack_expansion): Now this function is clearly organized in
two parts: a part that maps each parameter pack with its matching
argument pack, and a part that walks that map to build the result
of substituting each element of the argument packs into the
parameter packs.  Use gen_elem_of_pack_expansion_instantiation for
the latter part.

gcc/testsuite/

* g++.dg/cpp0x/variadic139.C: New test.
* g++.dg/cpp0x/variadic140.C: Likewise.
* g++.dg/cpp0x/variadic141.C: Likewise.
---
 gcc/cp/pt.c  | 473 +--
 gcc/testsuite/g++.dg/cpp0x/variadic139.C |  14 +
 gcc/testsuite/g++.dg/cpp0x/variadic140.C |  22 ++
 gcc/testsuite/g++.dg/cpp0x/variadic141.C |  22 ++
 4 files changed, 387 insertions(+), 144 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic139.C
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic140.C
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic141.C

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index ecb013e..663d46a 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -3308,6 +3308,29 @@ make_pack_expansion (tree arg)
   return result;
 }
 
+/* Return NULL_TREE iff T contains *NO* unexpanded parameter packs.
+   Return the TREE_LIST of unexpanded parameter packs otherwise.  */
+
+static tree
+has_bare_parameter_packs (tree t)
+{
+  tree parameter_packs = NULL_TREE;
+  struct find_parameter_pack_data ppd;
+
+  if (!processing_template_decl || !t || t == error_mark_node)
+return NULL_TREE;
+
+  if (TREE_CODE (t) == TYPE_DECL)
+t = TREE_TYPE (t);
+
+  ppd.parameter_packs = ¶meter_packs;
+  ppd.visited = pointer_set_create ();
+  cp_walk_tree (&t, &find_parameter_packs_r, &ppd, ppd.visited);
+  pointer_set_destroy (ppd.visited);
+
+  return parameter_packs;
+}
+
 /* Checks T for any "bare" parameter packs, which have not yet been
expanded, and issues an error if any are found. This operation can
only be done on full expressions or types (e.g., an expression
@@ -3325,19

Re: PING^2: [PATCH] PR sanitizer/55533: Can't bootstrap libsanitizer

2012-12-11 Thread Paolo Bonzini
Il 11/12/2012 16:03, H.J. Lu ha scritto:
> diff --git a/libsanitizer/asan/Makefile.am b/libsanitizer/asan/Makefile.am
> index 3da1db3..45fb3b3 100644
> --- a/libsanitizer/asan/Makefile.am
> +++ b/libsanitizer/asan/Makefile.am
> @@ -5,6 +5,10 @@ gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
>
>  DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS 
> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DASAN_HAS_EXCEPTIONS=1 
> -DASAN_FLEXIBLE_MAPPING_AND_OFFSET=0 -DASAN_NEEDS_SEGV=1
>  AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic 
> -Wno-long-long  -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer 
> -funwind-tables -fvisibility=hidden -Wno-variadic-macros 
> -Wno-c99-extensions
> +## We require libstdc++-v3 to be in the same build tree.
> +AM_CXXFLAGS += -I../../libstdc++-v3/include \
> +  -I../../libstdc++-v3/include/$(target_noncanonical) \
> +  -I$(srcdir)/../../libstdc++-v3/libsupc++
>>
>> As a followup, please bring back the possibility to build libsanitizer
>> standalone, also wrapping the chooice of flags to link to libstdc++-v3
>> in a new config/libstdc++-raw-cxx.m4 file.
> 
> I don't believe it is possible with libsanitizer in GCC since it
> uses GCC toplevel files.  Where do you get those toplevel files
> when you compile it standalone?

Does it use any GCC toplevel files except when regenerating the
configury?  But I think it's a useful refactoring anyway.

>> Bonus points for using this macro elsewhere in the tree.
>>
>  ACLOCAL_AMFLAGS = -I $(top_srcdir) -I $(top_srcdir)/config
>
>  toolexeclib_LTLIBRARIES = libasan.la
> @@ -64,8 +68,6 @@ AM_MAKEFLAGS = \
> "includedir=$(includedir)" \
> "AR=$(AR)" \
> "AS=$(AS)" \
> -   "CC=$(CC)" \
> -   "CXX=$(CXX)" \
> "LD=$(LD)" \
> "LIBCFLAGS=$(LIBCFLAGS)" \
> "NM=$(NM)" \
>>
>> Same as above, and same for other .am files.
> 
> I prefer to leave them where they are so that
> 
> # cd asan
> # make
> 
> can compile.  If they are passed from the parent directory,
> this won't work.

What do you mean?

> diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac
> index 2d62ec4..9c73904 100644
> --- a/libsanitizer/configure.ac
> +++ b/libsanitizer/configure.ac
> @@ -19,6 +19,7 @@ AC_MSG_RESULT($version_specific_libs)
>  # Do not delete or change the following two lines.  For why, see
>  # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
>  AC_CANONICAL_SYSTEM
> +ACX_NONCANONICAL_TARGET
>>
>> Note that if you create a new macro, ACX_NONCANONICAL_TARGET should be
>> AC_REQUIREd there.
> 
> How do I AC_REQUIRE it? I just copied it from other places:
> 
> [hjl@gnu-6 gcc]$ grep ACX_NONCANONICAL_TARGET */configure.*
> boehm-gc/configure.ac:ACX_NONCANONICAL_TARGET
> fixincludes/configure.ac:ACX_NONCANONICAL_TARGET
> gcc/configure.ac:ACX_NONCANONICAL_TARGET
> gnattools/configure.ac:ACX_NONCANONICAL_TARGET
> libada/configure.ac:ACX_NONCANONICAL_TARGET
> libgcc/configure.ac:ACX_NONCANONICAL_TARGET
> libgfortran/configure.ac:ACX_NONCANONICAL_TARGET
> libmudflap/configure.ac:ACX_NONCANONICAL_TARGET
> libobjc/configure.ac:ACX_NONCANONICAL_TARGET
> libquadmath/configure.ac:ACX_NONCANONICAL_TARGET
> libssp/configure.ac:ACX_NONCANONICAL_TARGET

This is connected to the change proposed above, of getting the -I
options to a separate macro in config/*.m4.

Paolo



Re: [C++ PATCH] Avoid decay_conversion on inline asm "m" inputs (PR c++/55619)

2012-12-11 Thread Jason Merrill

On 12/11/2012 03:16 AM, Jakub Jelinek wrote:

+ if (constraint_parsed && !allows_reg && allows_mem)
+   operand = mark_rvalue_use (TREE_VALUE (t));


This should be mark_lvalue_use, since we're using its address rather 
than its value.  OK with that change.


Jason



Re: [asan] Handle noreturn calls with __asan_handle_no_return ()

2012-12-11 Thread Dodji Seketeli
Jakub Jelinek  writes:

> Actually, the problem was that libasan was linked in after libpthread. 
> Perhaps we need some driver hacks to make sure -lasan comes before -lpthread
> when added automatically for -fsanitize=address (and similarly for -ltsan).
> For now just tweaking dg-options.


> Ok for trunk? (of course, depends on all the earlier patches from today and
> Wei's patch).

This is OK, thanks.

-- 
Dodji


Re: [C++ PATCH] Avoid decay_conversion on inline asm "m" inputs (PR c++/55619)

2012-12-11 Thread Jakub Jelinek
On Tue, Dec 11, 2012 at 11:19:48AM -0500, Jason Merrill wrote:
> On 12/11/2012 03:16 AM, Jakub Jelinek wrote:
> >+  if (constraint_parsed && !allows_reg && allows_mem)
> >+operand = mark_rvalue_use (TREE_VALUE (t));
> 
> This should be mark_lvalue_use, since we're using its address rather
> than its value.  OK with that change.

I guess it depends on how would make_lvalue_use differ from make_rvalue_use
in the future.  To some extent it is lvalue-ish use, but not completely,
while it is taking its address, it is fine if the operand is e.g. const,
which is wrong for lvalues.  I'll change it, it can be adjusted when
some difference between the two is actually added.

Jakub


Re: [PATCH] PR c++/53609 - Wrong argument deduction for pack expansion in argument pack

2012-12-11 Thread Jason Merrill

On 12/11/2012 10:55 AM, Dodji Seketeli wrote:

Oops, it seems I was too hasty in trying to do away with the
instantiation_yields_no_list_p parameter to
gen_elem_of_pack_expansion_instantiation.


I still think that the elem function should just deal with the single 
element case; the cases where we can't do a piecewise substitution 
should be handled outside the elem function.



I suppose we should keep this for has_empty_arg, but I'd like to do
away with special handling of the arg_from_parm_pack case if possible,
as it's a lot of extra complexity.


OK, done.


Looks like you only removed the check from that one if; I'd like to do 
away with the arg_from_parm_pack function entirely if we can.


Jason



Re: [C++ PATCH] Avoid decay_conversion on inline asm "m" inputs (PR c++/55619)

2012-12-11 Thread Jason Merrill

On 12/11/2012 11:33 AM, Jakub Jelinek wrote:

I guess it depends on how would make_lvalue_use differ from make_rvalue_use
in the future.  To some extent it is lvalue-ish use, but not completely,
while it is taking its address, it is fine if the operand is e.g. const,
which is wrong for lvalues.


In C++ lvalues can be const.

Jason



Re: PING^2: [PATCH] PR sanitizer/55533: Can't bootstrap libsanitizer

2012-12-11 Thread H.J. Lu
On Tue, Dec 11, 2012 at 8:19 AM, Paolo Bonzini  wrote:
> Il 11/12/2012 16:03, H.J. Lu ha scritto:
>> diff --git a/libsanitizer/asan/Makefile.am 
>> b/libsanitizer/asan/Makefile.am
>> index 3da1db3..45fb3b3 100644
>> --- a/libsanitizer/asan/Makefile.am
>> +++ b/libsanitizer/asan/Makefile.am
>> @@ -5,6 +5,10 @@ gcc_version := $(shell cat 
>> $(top_srcdir)/../gcc/BASE-VER)
>>
>>  DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS 
>> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DASAN_HAS_EXCEPTIONS=1 
>> -DASAN_FLEXIBLE_MAPPING_AND_OFFSET=0 -DASAN_NEEDS_SEGV=1
>>  AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic 
>> -Wno-long-long  -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer 
>> -funwind-tables -fvisibility=hidden -Wno-variadic-macros 
>> -Wno-c99-extensions
>> +## We require libstdc++-v3 to be in the same build tree.
>> +AM_CXXFLAGS += -I../../libstdc++-v3/include \
>> +  -I../../libstdc++-v3/include/$(target_noncanonical) \
>> +  -I$(srcdir)/../../libstdc++-v3/libsupc++
>>>
>>> As a followup, please bring back the possibility to build libsanitizer
>>> standalone, also wrapping the chooice of flags to link to libstdc++-v3
>>> in a new config/libstdc++-raw-cxx.m4 file.
>>
>> I don't believe it is possible with libsanitizer in GCC since it
>> uses GCC toplevel files.  Where do you get those toplevel files
>> when you compile it standalone?
>
> Does it use any GCC toplevel files except when regenerating the
> configury?  But I think it's a useful refactoring anyway.

libsanitizer started as standalone and it didn't work with GCC build.
We removed all those extra files to get it compile as the part of
GCC build:

2012-11-13  H.J. Lu  

PR other/55304
* acinclude.m4: New file.
* Makefile.am (ACLOCAL_AMFLAGS): New.
* configure.ac (AC_PREREQ): Set to 2.64.
(AC_CONFIG_AUX_DIR): Set to "..".
* Makefile.in: Regenerated.
* aclocal.m4: Likewise.
* configure: Likewise.
* asan/Makefile.in: Likewise.
* interception/Makefile.in: Likewise.
* sanitizer_common/Makefile.in: Likewise.

* config.guess: Removed.
* config.sub: Likewise.
* depcomp: Likewise.
* install-sh: Likewise.
* ltmain.sh: Likewise.
* missing: Likewise.

Are we going back now?

>>> Bonus points for using this macro elsewhere in the tree.
>>>
>>  ACLOCAL_AMFLAGS = -I $(top_srcdir) -I $(top_srcdir)/config
>>
>>  toolexeclib_LTLIBRARIES = libasan.la
>> @@ -64,8 +68,6 @@ AM_MAKEFLAGS = \
>> "includedir=$(includedir)" \
>> "AR=$(AR)" \
>> "AS=$(AS)" \
>> -   "CC=$(CC)" \
>> -   "CXX=$(CXX)" \
>> "LD=$(LD)" \
>> "LIBCFLAGS=$(LIBCFLAGS)" \
>> "NM=$(NM)" \
>>>
>>> Same as above, and same for other .am files.
>>
>> I prefer to leave them where they are so that
>>
>> # cd asan
>> # make
>>
>> can compile.  If they are passed from the parent directory,
>> this won't work.
>
> What do you mean?
>
>> diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac
>> index 2d62ec4..9c73904 100644
>> --- a/libsanitizer/configure.ac
>> +++ b/libsanitizer/configure.ac
>> @@ -19,6 +19,7 @@ AC_MSG_RESULT($version_specific_libs)
>>  # Do not delete or change the following two lines.  For why, see
>>  # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
>>  AC_CANONICAL_SYSTEM
>> +ACX_NONCANONICAL_TARGET
>>>
>>> Note that if you create a new macro, ACX_NONCANONICAL_TARGET should be
>>> AC_REQUIREd there.
>>
>> How do I AC_REQUIRE it? I just copied it from other places:
>>
>> [hjl@gnu-6 gcc]$ grep ACX_NONCANONICAL_TARGET */configure.*
>> boehm-gc/configure.ac:ACX_NONCANONICAL_TARGET
>> fixincludes/configure.ac:ACX_NONCANONICAL_TARGET
>> gcc/configure.ac:ACX_NONCANONICAL_TARGET
>> gnattools/configure.ac:ACX_NONCANONICAL_TARGET
>> libada/configure.ac:ACX_NONCANONICAL_TARGET
>> libgcc/configure.ac:ACX_NONCANONICAL_TARGET
>> libgfortran/configure.ac:ACX_NONCANONICAL_TARGET
>> libmudflap/configure.ac:ACX_NONCANONICAL_TARGET
>> libobjc/configure.ac:ACX_NONCANONICAL_TARGET
>> libquadmath/configure.ac:ACX_NONCANONICAL_TARGET
>> libssp/configure.ac:ACX_NONCANONICAL_TARGET
>
> This is connected to the change proposed above, of getting the -I
> options to a separate macro in config/*.m4.

I will take a look.

-- 
H.J.


Re: PING^2: [PATCH] PR sanitizer/55533: Can't bootstrap libsanitizer

2012-12-11 Thread Paolo Bonzini
Il 11/12/2012 17:55, H.J. Lu ha scritto:
>> > Does it use any GCC toplevel files except when regenerating the
>> > configury?  But I think it's a useful refactoring anyway.
> libsanitizer started as standalone and it didn't work with GCC build.
> We removed all those extra files to get it compile as the part of
> GCC build:
> 
> 2012-11-13  H.J. Lu  
> 
>   PR other/55304
>   * acinclude.m4: New file.
>   * Makefile.am (ACLOCAL_AMFLAGS): New.
>   * configure.ac (AC_PREREQ): Set to 2.64.
>   (AC_CONFIG_AUX_DIR): Set to "..".
>   * Makefile.in: Regenerated.
>   * aclocal.m4: Likewise.
>   * configure: Likewise.
>   * asan/Makefile.in: Likewise.
>   * interception/Makefile.in: Likewise.
>   * sanitizer_common/Makefile.in: Likewise.
> 
>   * config.guess: Removed.
>   * config.sub: Likewise.
>   * depcomp: Likewise.
>   * install-sh: Likewise.
>   * ltmain.sh: Likewise.
>   * missing: Likewise.
> 
> Are we going back now?
> 

No, thanks for reminding me of the whole story. :)

Paolo


Re: [PATCH i386]: Enable push/pop in pro/epilogue for modern CPUs

2012-12-11 Thread Xinliang David Li
On Tue, Dec 11, 2012 at 1:49 AM, Richard Biener
 wrote:
> On Mon, Dec 10, 2012 at 10:07 PM, Mike Stump  wrote:
>> On Dec 10, 2012, at 12:42 PM, Xinliang David Li  wrote:
>>> I have not measured the CFI size impact -- but conceivably it should
>>> be larger -- which is unfortunate.
>>
>> Code speed and size are preferable to optimizing dwarf size…  :-)  I'd let 
>> dwarf 5 fix it!
>
> Well, different to debug info, CFI data has to be in memory to make
> unwinding work.
> These days most Linux distributions enable asyncronous unwind tables so any
> size savings due to shorter push/pop epilogue/prologue sequences has to be
> offsetted by the increase in CFI data.  I'm not sure there is really a
> speed difference
> between both variants (well, maybe due to better icache footprint of
> the push/pop
> variant).

Yes, for large applications, this can be crucial to performance.

>
> That said - I'd prefer to have more data on this before making the switch for
> the generic model.  What was your original motivation?  Just "theory" or was
> it a real case?

1) some of the very large internal apps I measured benefit from this
change (in terms of performance)
2) both ICC and LLVM do the same.

I have already committed the patch. I will find some time to collect
more size data and post it later.

thanks,

David


>
> Thanks,
> Richard.


Re: [PATCH] Fix up undefined signed overflows in FIXED_SSNEG (PR libgcc/55451)

2012-12-11 Thread Ian Lance Taylor
On Tue, Dec 11, 2012 at 7:07 AM, Jakub Jelinek  wrote:
>
> 2012-12-11  Jakub Jelinek  
>
> PR libgcc/55451
> * fixed-bit.c (FIXED_SSADD, FIXED_USADD, FIXED_SSSUB, FIXED_USSUB,
> FIXED_SSNEG): Avoid undefined signed overflows.

This is OK.

Thanks.

Ian


Re: [PATCH] Fix DEBUG_INSN handling in lra-constraints (PR rtl-optimization/55193)

2012-12-11 Thread Vladimir Makarov

On 12/11/2012 03:21 AM, Jakub Jelinek wrote:

Hi!

As the testcase in the PR (unfortunately only reproduceable after reverting
some inlining patch, so not including that testcase in the patch) shows,
loc_equivalence_change_p isn't good enough for debug_insns, when a REG is
substituted for VOIDmode constant.  In that case, the surrounding SUBREG
(handled in loc_equivalence_change_p), but also other operations like
ZERO_EXTEND/SIGN_EXTEND, ZERO_EXTRACT etc. need to be simplified while we
still know the original mode, and perhaps several times, as SIGN_EXTEND
might be in another ZERO_EXTEND etc.  The best way to deal with that
is simplify_replace_fn_rtx which is used in various other places in the
compiler.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

Yes.  Thanks for working on it, Jakub.

2012-12-11  Jakub Jelinek  

PR rtl-optimization/55193
* lra-constraints.c (loc_equivalence_callback): New function.
(lra_constraints): Call simplify_replace_fn_rtx instead of
loc_equivalence_change_p on DEBUG_INSNs.






Re: patch to fix pr55141

2012-12-11 Thread Vladimir Makarov

On 12/08/2012 05:30 AM, Richard Sandiford wrote:

Vladimir Makarov  writes:

Index: lra-constraints.c
===
--- lra-constraints.c   (revision 194307)
+++ lra-constraints.c   (working copy)
@@ -3329,8 +3329,9 @@ lra_constraints (bool first_p)
reg = regno_reg_rtx[i];
if ((hard_regno = lra_get_regno_hard_regno (i)) >= 0)
  {
-   int j, nregs = hard_regno_nregs[hard_regno][PSEUDO_REGNO_MODE (i)];
+   int j, nregs;
  
+	nregs = hard_regno_nregs[hard_regno][lra_reg_info[i].biggest_mode];

for (j = 0; j < nregs; j++)
  df_set_regs_ever_live (hard_regno + j, true);

It looks like this loop now iterates over a different mode from the
pseudo register's, but starts at the hard register allocated to the
pseudo.  That doesn't work on big-endian targets, where the "extra"
registers come before hard_regno.  I think you need to use
simplify_subreg_regno (...subreg_lowpart_offset (...)).
I realise we only support little-endian for 4.8, but still.
Yes, Richard, I am aware about it.  There are a few places in LRA where 
similar code should be fixed for big-endian targets.  I'd like to 
address this problem on lra-branch when I am less busy.

Maybe it'd be worth having a helper function that provides the range.





[PING] RE: [Ping]FW: [PATCH] Cilk Plus merging to trunk (2 of n)

2012-12-11 Thread Iyer, Balaji V
Hello,
Did you get a chance to look at this patch? I submitted this ~1 month 
ago, so thought I would inquire its status.

Thanks,

Balaji V. Iyer.

> -Original Message-
> From: Iyer, Balaji V
> Sent: Monday, November 05, 2012 4:43 PM
> To: Joseph Myers
> Cc: gcc-patches@gcc.gnu.org
> Subject: RE: [Ping]FW: [PATCH] Cilk Plus merging to trunk (2 of n)
> 
> Hello Joseph,
>   Here is the fixed patch with all your changes and the ChangeLog entries
> below.
> 
> gcc/ChangeLog
> 2012-11-05  Balaji V. Iyer  
> 
> * Makefile.in (C_COMMON_OBJS): Added c-family/array-notation-
> common.o.
> * doc/passes.texi (Cilk Plus Transformation): Documented array
> notation and overall transformations for Cilk Plus.
> * doc/invoke.texi (C Dialect Options): Documented -fcilkplus flag.
> * doc/generic.texi (Storage References): Documented
> ARRAY_NOTATION_REF
> tree addition.
> 
> gcc/c-family/ChangeLog
> 2012-11-05  Balaji V. Iyer  
> 
> * c-common.h (build_array_notation_expr): New function declaration.
> (ARRAY_NOTATION_ARRAY): Added new #define.
> (ARRAY_NOTATION_CHECK): Likewise.
> (ARRAY_NOTATION_START): Likewise.
> (ARRAY_NOTATION_LENGTH): Likewise.
> (ARRAY_NOTATION_STRIDE): Likewise.
> (ARRAY_NOTATION_TYPE): Likewise.
> (enum array_notation_reduce_type): Added new enumerator.
> * c-common.def: Added new tree ARRAY_NOTATION_REF.
> * c-common.c (c_define_builtins): Added a call to initialize array
> notation builtin functions.
> (c_common_init_ts): Set ARRAY_NOTATION_REF as typed.
> * c-pretty-print.c (pp_c_postfix_expression): Added ARRAY_NOTATION_REF
> case.
> * c.opt (-fcilkplus): Define new command line switch.
> * array-notation-common.c: New file.
> 
> gcc/c/ChangeLog
> 2012-11-05  Balaji V. Iyer  
> 
> * c-typeck.c (build_array_ref): Added a check to see if array's index
> is greater than one.  If true, then emit an error.
> (build_function_call_vec): Exclude error reporting & checking for
> builtin array-notation functions.
> (convert_arguments): Likewise.
> (c_finish_return): Added a check for array notations as a return
> expression.  If true, then emit an error.
> (c_finish_loop): Added a check for array notations in a loop 
> condition.
> If true then emit an error.
> (lvalue_p): Added a ARRAY_NOTATION_REF case.
> * Make-lang.in (C_AND_OBJC_OBJS): Added c-array-notation.o.
> * c-parser.c (c_parser_compound_statement): Check if array notation 
> code
> is used in tree, if so, then transform them into appropriate C code.
> (c_parser_expr_no_commas): Check if array notation is used in LHS or
> RHS, if so, then build array notation expression instead of regular
> modify.
> (c_parser_postfix_expression_after_primary): Added a check for 
> colon(s)
> after square braces, if so then handle it like an array notation.  
> Also,
> break up array notations in unary op if found.
> (c_parser_direct_declarator_inner): Added a check for array notation.
> (c_parser_compound_statement): Added a check for array notation in a
> stmt.  If one is present, then expand array notation expr.
> (c_parser_if_statement): Likewise.
> (c_parser_switch_statement): Added a check for array notations in a
> switch statement's condition.  If true, then output an error.
> (c_parser_while_statement): Same as switch statement, but for a while.
> (c_parser_do_statement): Same as switch statement, but for a do-while.
> (c_parser_for_statement): Same as switch statement, but for a 
> for-loop.
> (c_parser_unary_expression): Check if array notation is used in a
> pre-increment or pre-decrement expression.  If true, then expand them.
> (c_parser_array_notation): New function.
> * c-array-notation.c: New file.
> 
> gcc/testsuite/ChangeLog
> 2012-11-05  Balaji V. Iyer  
> 
> * gcc.dg/cilk-plus/array_notation/execute/execute.exp: New script.
> * gcc.dg/cilk-plus/array_notation/compile/compile.exp: Likewise.
> * gcc.dg/cilk-plus/array_notation/errors/errors.exp: Likewise.
> * gcc.dg/cilk-plus/array_notation/execute/sec_implicit_ex.c: New test.
> * gcc.dg/cilk-plus/array_notation/execute/comma_exp.c: Likewise.
> * gcc.dg/cilk-plus/array_notation/execute/conditional.c: Likewise.
> * gcc.dg/cilk-plus/array_notation/execute/exec-once.c: Likewise.
> * gcc.dg/cilk-plus/array_notation/execute/if_test.c: Likewise.
> * gcc.dg/cilk-plus/array_notation/execute/n-ptr_test.c: Likewise.
> * gcc.dg/cilk-plus/array_notation/execute/gather_scatter.c: Likewise.
> * gcc.dg/cilk-plus/array_notation/execute/builtin_func_double2.c:
> Likewi

Re: [PATCH] New fdo summary-based icache sensitive unrolling (issue6351086)

2012-12-11 Thread Markus Trippelsdorf
On 2012.12.11 at 09:13 -0800, Teresa Johnson wrote:
> Ping.
> Teresa
> 
> On Mon, Nov 19, 2012 at 4:58 PM, Teresa Johnson  wrote:
> > This patch was proposed awhile back, and the new working set program
> > summary was split out and committed separately. I would like to
> > see if the loop unroller part of the patch can now go in. For the
> > previous versions of the patch and related discussion, see:
> >
> > http://gcc.gnu.org/ml/gcc-patches/2012-06/msg00437.html
> > and
> > http://gcc.gnu.org/ml/gcc-patches/2012-07/msg01373.html
> >
> > Use the new working set information in the FDO program summary for
> > codesize based unroll and peel decisions, to prevent those
> > optimizations from increasing code size too much when the
> > program may be sensitive to icache effects.
> >
> > As part of this, cache additional loop analysis results in the niter_desc
> > auxiliary information hanging off the loop structure to reduce
> > redundant analyses during unrolling.
> >
> > Bootstrapped and tested on x86_64-unknown-linux-gnu. Ok for trunk?

I guess this is the missing piece that would fix the Firefox lto/pgo
code-size issue:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45375#c144

-- 
Markus


Re: [PATCH] New fdo summary-based icache sensitive unrolling (issue6351086)

2012-12-11 Thread Jan Hubicka
> On 2012.12.11 at 09:13 -0800, Teresa Johnson wrote:
> > Ping.
> > Teresa
> > 
> > On Mon, Nov 19, 2012 at 4:58 PM, Teresa Johnson  
> > wrote:
> > > This patch was proposed awhile back, and the new working set program
> > > summary was split out and committed separately. I would like to
> > > see if the loop unroller part of the patch can now go in. For the
> > > previous versions of the patch and related discussion, see:
> > >
> > > http://gcc.gnu.org/ml/gcc-patches/2012-06/msg00437.html
> > > and
> > > http://gcc.gnu.org/ml/gcc-patches/2012-07/msg01373.html
> > >
> > > Use the new working set information in the FDO program summary for
> > > codesize based unroll and peel decisions, to prevent those
> > > optimizations from increasing code size too much when the
> > > program may be sensitive to icache effects.
> > >
> > > As part of this, cache additional loop analysis results in the niter_desc
> > > auxiliary information hanging off the loop structure to reduce
> > > redundant analyses during unrolling.
> > >
> > > Bootstrapped and tested on x86_64-unknown-linux-gnu. Ok for trunk?
> 
> I guess this is the missing piece that would fix the Firefox lto/pgo
> code-size issue:
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45375#c144

It won't help in this case - the problem is that too much of code is identified 
as hot,
similar as for spec2k GCC benchmark.  Teresa - do you have any ideas what to do 
here
short of re-adding the BB ratio parameter and combining both heuristics for 4.8?

Honza
> 
> -- 
> Markus


C++ PATCH for c++/54416 (ICE after error on bogus specialization)

2012-12-11 Thread Jason Merrill
In this testcase we get confused by a specialization nested inside a 
class template; the members of the specialization end up having 
dependent template arguments, and then we get confused when we try to 
define one of them in a context that has no template headers.


Fixed by rejecting the definition of the specialization, and therefore 
the definition of the member of the specialization.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 9bcbafc418c3f7aff48c8e98f362e7f44849051e
Author: Jason Merrill 
Date:   Tue Dec 11 10:59:36 2012 -0500

	* pt.c (maybe_process_partial_specialization): Handle aliases first.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 1bc9e1b..f30a1e1 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -812,13 +812,17 @@ maybe_process_partial_specialization (tree type)
 
   context = TYPE_CONTEXT (type);
 
-  if ((CLASS_TYPE_P (type) && CLASSTYPE_USE_TEMPLATE (type))
-  /* Consider non-class instantiations of alias templates as
-	 well.  */
-  || (TYPE_P (type)
-	  && TYPE_TEMPLATE_INFO (type)
-	  && DECL_LANG_SPECIFIC (TYPE_NAME (type))
-	  && DECL_USE_TEMPLATE (TYPE_NAME (type
+  if (TYPE_ALIAS_P (type))
+{
+  if (TYPE_TEMPLATE_INFO (type)
+	  && DECL_ALIAS_TEMPLATE_P (TYPE_TI_TEMPLATE (type)))
+	error ("specialization of alias template %qD",
+	   TYPE_TI_TEMPLATE (type));
+  else
+	error ("explicit specialization of non-template %qT", type);
+  return error_mark_node;
+}
+  else if (CLASS_TYPE_P (type) && CLASSTYPE_USE_TEMPLATE (type))
 {
   /* This is for ordinary explicit specialization and partial
 	 specialization of a template class such as:
@@ -831,8 +835,7 @@ maybe_process_partial_specialization (tree type)
 
 	 Make sure that `C' and `C' are implicit instantiations.  */
 
-  if (CLASS_TYPE_P (type)
-	  && CLASSTYPE_IMPLICIT_INSTANTIATION (type)
+  if (CLASSTYPE_IMPLICIT_INSTANTIATION (type)
 	  && !COMPLETE_TYPE_P (type))
 	{
 	  check_specialization_namespace (CLASSTYPE_TI_TEMPLATE (type));
@@ -845,16 +848,9 @@ maybe_process_partial_specialization (tree type)
 		return error_mark_node;
 	}
 	}
-  else if (CLASS_TYPE_P (type)
-	   && CLASSTYPE_TEMPLATE_INSTANTIATION (type))
+  else if (CLASSTYPE_TEMPLATE_INSTANTIATION (type))
 	error ("specialization of %qT after instantiation", type);
 
-  if (DECL_ALIAS_TEMPLATE_P (TYPE_TI_TEMPLATE (type)))
-	{
-	  error ("partial specialization of alias template %qD",
-		 TYPE_TI_TEMPLATE (type));
-	  return error_mark_node;
-	}
 }
   else if (CLASS_TYPE_P (type)
 	   && !CLASSTYPE_USE_TEMPLATE (type)
diff --git a/gcc/testsuite/g++.dg/cpp0x/alias-decl-1.C b/gcc/testsuite/g++.dg/cpp0x/alias-decl-1.C
index d0eda5f..cbba90f 100644
--- a/gcc/testsuite/g++.dg/cpp0x/alias-decl-1.C
+++ b/gcc/testsuite/g++.dg/cpp0x/alias-decl-1.C
@@ -5,10 +5,10 @@
 
 template struct A0 {};
 template using AA0 = A0;
-template struct AA0 {}; // { dg-error "partial specialization" }
+template struct AA0 {}; // { dg-error "specialization" }
 
 template  using Ptr = U*;
-template struct Ptr {}; // { dg-error "partial specialization" }
+template struct Ptr {}; // { dg-error "specialization" }
 
 struct A {
 using A = int;//{ dg-error "nested|has|same name as|class|in which|declared" }

commit e575667938e576ceeede4bdb00361d2b52540a48
Author: Jason Merrill 
Date:   Sat Dec 8 20:16:30 2012 -0500

	PR c++/54416
	* pt.c (maybe_process_partial_specialization): Don't accept
	definition of a specialization without the appropriate header.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index f30a1e1..91450d8 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -850,7 +850,13 @@ maybe_process_partial_specialization (tree type)
 	}
   else if (CLASSTYPE_TEMPLATE_INSTANTIATION (type))
 	error ("specialization of %qT after instantiation", type);
-
+  else if (errorcount && !processing_specialization
+	&& CLASSTYPE_TEMPLATE_SPECIALIZATION (type)
+	   && !uses_template_parms (CLASSTYPE_TI_ARGS (type)))
+	/* Trying to define a specialization either without a template<> header
+	   or in an inappropriate place.  We've already given an error, so just
+	   bail now so we don't actually define the specialization.  */
+	return error_mark_node;
 }
   else if (CLASS_TYPE_P (type)
 	   && !CLASSTYPE_USE_TEMPLATE (type)
diff --git a/gcc/testsuite/g++.dg/template/crash105.C b/gcc/testsuite/g++.dg/template/crash105.C
index 649bf8b..8cfff6a 100644
--- a/gcc/testsuite/g++.dg/template/crash105.C
+++ b/gcc/testsuite/g++.dg/template/crash105.C
@@ -10,5 +10,8 @@ template < typename > struct S < int >
 void
 f ()
 {
-  S < int >::f (); // { dg-error "cannot call" }
+  S < int >::f ();
 }
+
+// Don't be picky about error-recovery.
+// { dg-prune-output "." }
diff --git a/gcc/testsuite/g++.dg/template/error48.C b/gcc/testsuite/g++.dg/template/error48.C
new file mode 100644
index 000..483f7b5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/error48.C
@@ -0,0 +1,15 @@
+// PR c++/54416
+
+template <

[C++ PATCH] Fix -Wunused-but-set-variable false positives with cast to floating (PR c++/55643)

2012-12-11 Thread Jakub Jelinek
Hi!

When casting ints to other ints, CASE_CONVERT in mark_exp_read handles that
case, but for FLOAT_EXPR it doesn't.  I've tried other static casts, but
haven't found anything else that would fail similarly.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk/4.7?

2012-12-11  Jakub Jelinek  

PR c++/55643
* expr.c (mark_exp_read): Handle FLOAT_EXPR similarly to NOP_EXPR.

* g++.dg/warn/Wunused-var-19.C: New test.

--- gcc/cp/expr.c.jj2010-12-02 11:51:22.0 +0100
+++ gcc/cp/expr.c   2012-12-11 08:51:53.008992474 +0100
@@ -131,6 +131,7 @@ mark_exp_read (tree exp)
 CASE_CONVERT:
 case ADDR_EXPR:
 case INDIRECT_REF:
+case FLOAT_EXPR:
   mark_exp_read (TREE_OPERAND (exp, 0));
   break;
 case COMPOUND_EXPR:
--- gcc/testsuite/g++.dg/warn/Wunused-var-19.C.jj   2012-12-11 
08:54:47.600958580 +0100
+++ gcc/testsuite/g++.dg/warn/Wunused-var-19.C  2012-12-11 08:53:20.0 
+0100
@@ -0,0 +1,26 @@
+// PR c++/55643
+// { dg-do compile }
+// { dg-options "-std=c++11 -Wunused" }
+
+enum class E { e = 123 };
+
+int
+foo ()
+{
+  E x = E::e;
+  return (double) x;
+}
+
+int
+bar ()
+{
+  E x = E::e;
+  return (long double) x;
+}
+
+int
+baz ()
+{
+  E x = E::e;
+  return (float) x;
+}

Jakub


[PATCH] Fix discover_iteration_bound_by_body_walk bounds computation overflows (PR fortran/55633)

2012-12-11 Thread Jakub Jelinek
Hi!

The following testcase on x86_64 (or the f90-intrinsic-bitsize.f on 32-bit
HWI) with -Os shows a bug in discover_iteration_bound_by_body_walk.  If some
bound is a -1, -1 HWI, then adding double_int_one to it overflows into 0, 0
HWI and we can return that as maximum number of iterations.  We need to
ignore such bounds instead.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2012-12-11  Jakub Jelinek  

PR fortran/55633
* tree-ssa-loop-niter.c (discover_iteration_bound_by_body_walk):
Ignore bounds on which bound += double_int_one overflowed.

* gcc.dg/torture/pr55633.c: New test.

--- gcc/tree-ssa-loop-niter.c.jj2012-11-21 16:00:09.0 +0100
+++ gcc/tree-ssa-loop-niter.c   2012-12-11 10:56:49.890396498 +0100
@@ -3011,7 +3011,12 @@ discover_iteration_bound_by_body_walk (s
   /* Exit terminates loop at given iteration, while non-exits produce 
undefined
 effect on the next iteration.  */
   if (!elt->is_exit)
-   bound += double_int_one;
+   {
+ bound += double_int_one;
+ /* If an overflow occurred, ignore the result.  */
+ if (bound.is_zero ())
+   continue;
+   }
 
   if (!loop->any_upper_bound
  || bound.ult (loop->nb_iterations_upper_bound))
@@ -3037,7 +3042,12 @@ discover_iteration_bound_by_body_walk (s
 {
   double_int bound = elt->bound;
   if (!elt->is_exit)
-   bound += double_int_one;
+   {
+ bound += double_int_one;
+ /* If an overflow occurred, ignore the result.  */
+ if (bound.is_zero ())
+   continue;
+   }
 
   if (!loop->any_upper_bound
  || bound.ult (loop->nb_iterations_upper_bound))
--- gcc/testsuite/gcc.dg/torture/pr55633.c.jj   2012-12-11 11:12:19.567069030 
+0100
+++ gcc/testsuite/gcc.dg/torture/pr55633.c  2012-12-11 11:12:04.0 
+0100
@@ -0,0 +1,39 @@
+/* PR fortran/55633 */
+/* { dg-do run { target int128 } } */
+
+extern void abort (void);
+
+__attribute__((noinline, noclone)) void
+bar (__int128_t *x)
+{
+  int c = sizeof (__int128_t) * __CHAR_BIT__;
+  if (c > 127)
+c = 127;
+  if (*x != c)
+abort ();
+}
+
+__attribute__((noinline)) void
+foo (void)
+{
+  __int128_t m, ma;
+  ma = 0;
+  m = 0;
+  m = ~m;
+  do
+{
+  if (m == 0 || ma > 126)
+   break;
+  ma = ma + 1;
+  m = ((__uint128_t) m) >> 1;
+}
+  while (1);
+  bar (&ma);
+}
+
+int
+main ()
+{
+  foo ();
+  return 0;
+}

Jakub


[PATCH] Don't use -frandom-seed=$@ to build libbacktrace unconditionally (PR bootstrap/54926)

2012-12-11 Thread Jakub Jelinek
Hi!

Richard noticed that bootstrap with very old GCC as system compiler failed
(as one of the reasons) because -frandom-seed=dwarf.lo etc. was used to
compile the host libbacktrace in stage1.  Non-GCC compilers presumably don't
support that option either.

The following patch fixes it by adding it unconditionally only for target
libbacktrace and otherwise testing, if the option is supported.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2012-12-11  Jakub Jelinek  

PR bootstrap/54926
* Makefile.am (AM_CFLAGS): Remove -frandom-seed=$@.
* configure.ac: If --with-target-subdir, add -frandom-seed=$@
to EXTRA_FLAGS unconditionally, otherwise check whether the compiler
accepts it.
* Makefile.in: Regenerated.
* configure: Regenerated.

--- libbacktrace/Makefile.am.jj 2012-12-07 15:13:56.0 +0100
+++ libbacktrace/Makefile.am2012-12-11 12:30:48.498852727 +0100
@@ -34,7 +34,7 @@ ACLOCAL_AMFLAGS = -I .. -I ../config
 AM_CPPFLAGS = -I $(top_srcdir)/../include -I $(top_srcdir)/../libgcc \
-I ../libgcc -I ../gcc/include -I $(MULTIBUILDTOP)../../gcc/include
 
-AM_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) $(PIC_FLAG) -frandom-seed=$@
+AM_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) $(PIC_FLAG)
 
 noinst_LTLIBRARIES = libbacktrace.la
 
--- libbacktrace/configure.ac.jj2012-11-14 08:13:38.0 +0100
+++ libbacktrace/configure.ac   2012-12-11 12:30:29.466962449 +0100
@@ -98,7 +98,7 @@ AC_SUBST(BACKTRACE_FILE)
 
 EXTRA_FLAGS=
 if test -n "${with_target_subdir}"; then
-  EXTRA_FLAGS=-funwind-tables
+  EXTRA_FLAGS="-funwind-tables -frandom-seed=\$@"
 else
   AC_CACHE_CHECK([for -funwind-tables option],
 [libbacktrace_cv_c_unwind_tables],
@@ -109,9 +109,21 @@ else
[libbacktrace_cv_c_unwind_tables=yes],
[libbacktrace_cv_c_unwind_tables=no])
  CFLAGS="$CFLAGS_hold"])
-   if test "$libbacktrace_cv_c_unwind_tables" = "yes"; then
- EXTRA_FLAGS=-funwind-tables
-   fi
+  if test "$libbacktrace_cv_c_unwind_tables" = "yes"; then
+EXTRA_FLAGS=-funwind-tables
+  fi
+  AC_CACHE_CHECK([for -frandom-seed=string option],
+[libbacktrace_cv_c_random_seed_string],
+[CFLAGS_hold="$CFLAGS"
+ CFLAGS="$CFLAGS -frandom-seed=conftest.lo"
+ AC_COMPILE_IFELSE(
+   [AC_LANG_PROGRAM([], [return 0;])],
+   [libbacktrace_cv_c_random_seed_string=yes],
+   [libbacktrace_cv_c_random_seed_string=no])
+ CFLAGS="$CFLAGS_hold"])
+  if test "$libbacktrace_cv_c_random_seed_string" = "yes"; then
+EXTRA_FLAGS="$EXTRA_FLAGS -frandom-seed=\$@"
+  fi
 fi
 AC_SUBST(EXTRA_FLAGS)
 
--- libbacktrace/Makefile.in.jj 2012-12-07 15:13:56.0 +0100
+++ libbacktrace/Makefile.in2012-12-11 12:31:05.951752225 +0100
@@ -254,7 +254,7 @@ ACLOCAL_AMFLAGS = -I .. -I ../config
 AM_CPPFLAGS = -I $(top_srcdir)/../include -I $(top_srcdir)/../libgcc \
-I ../libgcc -I ../gcc/include -I $(MULTIBUILDTOP)../../gcc/include
 
-AM_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) $(PIC_FLAG) -frandom-seed=$@
+AM_CFLAGS = $(EXTRA_FLAGS) $(WARN_FLAGS) $(PIC_FLAG)
 noinst_LTLIBRARIES = libbacktrace.la
 libbacktrace_la_SOURCES = \
backtrace.h \
--- libbacktrace/configure.jj   2012-11-14 08:13:38.0 +0100
+++ libbacktrace/configure  2012-12-11 12:31:19.217675175 +0100
@@ -11491,7 +11491,7 @@ fi
 
 EXTRA_FLAGS=
 if test -n "${with_target_subdir}"; then
-  EXTRA_FLAGS=-funwind-tables
+  EXTRA_FLAGS="-funwind-tables -frandom-seed=\$@"
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -funwind-tables 
option" >&5
 $as_echo_n "checking for -funwind-tables option... " >&6; }
@@ -11521,9 +11521,40 @@ rm -f core conftest.err conftest.$ac_obj
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: 
$libbacktrace_cv_c_unwind_tables" >&5
 $as_echo "$libbacktrace_cv_c_unwind_tables" >&6; }
-   if test "$libbacktrace_cv_c_unwind_tables" = "yes"; then
- EXTRA_FLAGS=-funwind-tables
-   fi
+  if test "$libbacktrace_cv_c_unwind_tables" = "yes"; then
+EXTRA_FLAGS=-funwind-tables
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -frandom-seed=string 
option" >&5
+$as_echo_n "checking for -frandom-seed=string option... " >&6; }
+if test "${libbacktrace_cv_c_random_seed_string+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  CFLAGS_hold="$CFLAGS"
+ CFLAGS="$CFLAGS -frandom-seed=conftest.lo"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  libbacktrace_cv_c_random_seed_string=yes
+else
+  libbacktrace_cv_c_random_seed_string=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ CFLAGS="$CFLAGS_hold"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: 
$libbacktrace_cv_c_random_seed_string" >&5
+$as_echo "$libbacktrace_cv_c_random_seed_string" >&6; }
+  if test "$libbacktrace_cv_c_random_seed_string" = "yes"; then
+EXTRA_FLAGS="$EXTRA_FLAG

Re: [Fortran, (RFC) patch] PR49110/51055 Assignment to alloc. deferred-length character vars

2012-12-11 Thread Jakub Jelinek
On Tue, Dec 11, 2012 at 02:29:18PM +0100, Janus Weil wrote:
> 2012/12/11 Jakub Jelinek :
> > On Tue, Dec 11, 2012 at 12:16:33PM +0100, Janus Weil wrote:
> >> Ok, so here is a new patch, updated according to the suggestions of
> >> David and Jakub. This now only touches the dotted variables, which are
> >> responsible for the AIX trouble. Whether the same prefixing should
> >> also be applied in other cases, we can still decide later.
> >
> > Why are you changing anything in create_function_arglist (PARM_DECLs
> > can't ever be TREE_STATIC, and it is compiler internal (plus debug info)
> > thing how they are named, no need for any kind of mangling) or
> > saved_dovar (again, doesn't seem to be TREE_STATIC)?
> >
> > Even in gfc_create_string_length you don't need to increase the length
> > of the names and obfuscate them if it isn't going to be TREE_STATIC.
> 
> Yes, you're probably right.
> 
> Anyway, I'm out. I don't have the capacities to deal with this right
> now (and, frankly, it's not my duty anyway) ...

So, what about this version instead?

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2012-12-11  Jakub Jelinek  
Janus Weil  

PR fortran/55636
* gfortran.h (GFC_PREFIX): Define.
* trans-decl.c (gfc_create_string_length): For VAR_DECLs that
will be TREE_STATIC, use GFC_PREFIX to mangle the names.

--- gcc/fortran/gfortran.h.jj   2012-12-04 14:17:30.574177056 +0100
+++ gcc/fortran/gfortran.h  2012-12-11 15:48:37.96747 +0100
@@ -63,6 +63,15 @@ along with GCC; see the file COPYING3.
 #define PREFIX(x) "_gfortran_" x
 #define PREFIX_LEN 10
 
+/* A prefix for internal variables, which are not user-visible.  */
+#if !defined (NO_DOT_IN_LABEL)
+# define GFC_PREFIX(x) "_F." x
+#elif !defined (NO_DOLLAR_IN_LABEL)
+# define GFC_PREFIX(x) "_F$" x
+#else
+# define GFC_PREFIX(x) "_F_" x
+#endif
+
 #define BLANK_COMMON_NAME "__BLNK__"
 
 /* Macro to initialize an mstring structure.  */
--- gcc/fortran/trans-decl.c.jj 2012-12-11 09:25:18.757189184 +0100
+++ gcc/fortran/trans-decl.c2012-12-11 15:50:13.487857146 +0100
@@ -1090,7 +1090,15 @@ gfc_create_string_length (gfc_symbol * s
   const char *name;
 
   /* Also prefix the mangled name.  */
-  if (sym->module)
+  if (sym->attr.save || sym->ns->proc_name->attr.flavor == FL_MODULE)
+   {
+ if (sym->module)
+   name = gfc_get_string (GFC_PREFIX ("%s_MOD_%s"), sym->module,
+  sym->name);
+ else
+   name = gfc_get_string (GFC_PREFIX ("%s"), sym->name);
+   }
+  else if (sym->module)
name = gfc_get_string (".__%s_MOD_%s", sym->module, sym->name);
   else
name = gfc_get_string (".%s", sym->name);

Jakub


[PATCH] Speed up gfortran.dg/vect/fast-math-pr38968.f90 testcase

2012-12-11 Thread Jakub Jelinek
Hi!

Lately this testcase often timesout for me on a busy box,
I don't see a point iterating 2000^3 times, with 400^3 it is much faster
and I still could reproduce the problem before the corresponding fix
and the vectorizer r145171 fix fixed it.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2012-12-11  Jakub Jelinek  

* gfortran.dg/vect/fast-math-pr38968.f90: Decrease n
from 2000 to 400.

--- gcc/testsuite/gfortran.dg/vect/fast-math-pr38968.f90.jj 2011-01-25 
18:39:53.0 +0100
+++ gcc/testsuite/gfortran.dg/vect/fast-math-pr38968.f902012-12-11 
16:19:45.222105217 +0100
@@ -7,7 +7,7 @@
 program mymatmul
   implicit none
   integer, parameter :: kp = 4
-  integer, parameter :: n = 2000
+  integer, parameter :: n = 400
   real(kp), dimension(n,n) :: rr, ri
   complex(kp), dimension(n,n) :: a,b,c
   real :: t1, t2

Jakub


Re: [PATCH] Don't use -frandom-seed=$@ to build libbacktrace unconditionally (PR bootstrap/54926)

2012-12-11 Thread Ian Lance Taylor
On Tue, Dec 11, 2012 at 10:36 AM, Jakub Jelinek  wrote:
>
> 2012-12-11  Jakub Jelinek  
>
> PR bootstrap/54926
> * Makefile.am (AM_CFLAGS): Remove -frandom-seed=$@.
> * configure.ac: If --with-target-subdir, add -frandom-seed=$@
> to EXTRA_FLAGS unconditionally, otherwise check whether the compiler
> accepts it.
> * Makefile.in: Regenerated.
> * configure: Regenerated.

This is OK.

Thanks.

Ian


[SPARC] Fix PR target/54121

2012-12-11 Thread Eric Botcazou
This is a regression present on mainline and 4.7 branch for the SPARC.  Reload 
is trying to change the value of a symbol(!) because it is mightily confused 
by an output constraint on a source operand (old pasto in some TLS patterns).

Fixed thusly, tested on SPARC64/Linux, applied on all branches.


2012-12-11  Eric Botcazou  

PR target/54121
* config/sparc/sparc.md (tldo_stb_sp32): Fix pasto.
(tldo_stb_sp64): Likewise.
(tldo_sth_sp32): Likewise.
(tldo_sth_sp64): Likewise.
(tldo_stw_sp32): Likewise.
(tldo_stw_sp64): Likewise.
(tldo_stx_sp64): Likewise.


2012-12-11  Eric Botcazou  

* gcc.dg/pr54121.c: New test.


-- 
Eric BotcazouIndex: config/sparc/sparc.md
===
--- config/sparc/sparc.md	(revision 194382)
+++ config/sparc/sparc.md	(working copy)
@@ -7757,7 +7757,7 @@ (define_insn "*tldo_stb_sp32"
  (match_operand 3 "tld_symbolic_operand" "")]
 UNSPEC_TLSLDO)
 			 (match_operand:SI 1 "register_operand" "r")))
-	(match_operand:QI 0 "register_operand" "=r"))]
+	(match_operand:QI 0 "register_operand" "r"))]
   "TARGET_TLS && TARGET_ARCH32"
   "stb\t%0, [%1 + %2], %%tldo_add(%3)"
   [(set_attr "type" "store")])
@@ -7767,7 +7767,7 @@ (define_insn "*tldo_stb_sp64"
  (match_operand 3 "tld_symbolic_operand" "")]
 UNSPEC_TLSLDO)
 			 (match_operand:DI 1 "register_operand" "r")))
-	(match_operand:QI 0 "register_operand" "=r"))]
+	(match_operand:QI 0 "register_operand" "r"))]
   "TARGET_TLS && TARGET_ARCH64"
   "stb\t%0, [%1 + %2], %%tldo_add(%3)"
   [(set_attr "type" "store")])
@@ -,7 +,7 @@ (define_insn "*tldo_sth_sp32"
  (match_operand 3 "tld_symbolic_operand" "")]
 UNSPEC_TLSLDO)
 			 (match_operand:SI 1 "register_operand" "r")))
-	(match_operand:HI 0 "register_operand" "=r"))]
+	(match_operand:HI 0 "register_operand" "r"))]
   "TARGET_TLS && TARGET_ARCH32"
   "sth\t%0, [%1 + %2], %%tldo_add(%3)"
   [(set_attr "type" "store")])
@@ -7787,7 +7787,7 @@ (define_insn "*tldo_sth_sp64"
  (match_operand 3 "tld_symbolic_operand" "")]
 UNSPEC_TLSLDO)
 			 (match_operand:DI 1 "register_operand" "r")))
-	(match_operand:HI 0 "register_operand" "=r"))]
+	(match_operand:HI 0 "register_operand" "r"))]
   "TARGET_TLS && TARGET_ARCH64"
   "sth\t%0, [%1 + %2], %%tldo_add(%3)"
   [(set_attr "type" "store")])
@@ -7797,7 +7797,7 @@ (define_insn "*tldo_stw_sp32"
  (match_operand 3 "tld_symbolic_operand" "")]
 UNSPEC_TLSLDO)
 			 (match_operand:SI 1 "register_operand" "r")))
-	(match_operand:SI 0 "register_operand" "=r"))]
+	(match_operand:SI 0 "register_operand" "r"))]
   "TARGET_TLS && TARGET_ARCH32"
   "st\t%0, [%1 + %2], %%tldo_add(%3)"
   [(set_attr "type" "store")])
@@ -7807,7 +7807,7 @@ (define_insn "*tldo_stw_sp64"
  (match_operand 3 "tld_symbolic_operand" "")]
 UNSPEC_TLSLDO)
 			 (match_operand:DI 1 "register_operand" "r")))
-	(match_operand:SI 0 "register_operand" "=r"))]
+	(match_operand:SI 0 "register_operand" "r"))]
   "TARGET_TLS && TARGET_ARCH64"
   "stw\t%0, [%1 + %2], %%tldo_add(%3)"
   [(set_attr "type" "store")])
@@ -7817,7 +7817,7 @@ (define_insn "*tldo_stx_sp64"
  (match_operand 3 "tld_symbolic_operand" "")]
 UNSPEC_TLSLDO)
 			 (match_operand:DI 1 "register_operand" "r")))
-	(match_operand:DI 0 "register_operand" "=r"))]
+	(match_operand:DI 0 "register_operand" "r"))]
   "TARGET_TLS && TARGET_ARCH64"
   "stx\t%0, [%1 + %2], %%tldo_add(%3)"
   [(set_attr "type" "store")])
/* PR target/54121 */
/* Reported by Jan Engelhardt  */

/* { dg-do compile { target fpic } } */
/* { dg-options "-std=gnu99 -O -fPIC -fprofile-generate" } */

typedef __SIZE_TYPE__ size_t;
typedef unsigned char uint8_t;

extern void *memcpy (void *__restrict __dest,
   __const void *__restrict __src, size_t __n)
 __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2)));

typedef enum {
 LZMA_OK = 0,
 LZMA_STREAM_END = 1,
 LZMA_NO_CHECK = 2,
 LZMA_UNSUPPORTED_CHECK = 3,
 LZMA_GET_CHECK = 4,
 LZMA_MEM_ERROR = 5,
 LZMA_MEMLIMIT_ERROR = 6,
 LZMA_FORMAT_ERROR = 7,
 LZMA_OPTIONS_ERROR = 8,
 LZMA_DATA_ERROR = 9,
 LZMA_BUF_ERROR = 10,
 LZMA_PROG_ERROR = 11,
} lzma_ret;

typedef enum {
 LZMA_RUN = 0,
 LZMA_SYNC_FLUSH = 1,
 LZMA_FULL_FLUSH = 2,
 LZMA_FINISH = 3
} lzma_action;

typedef struct {
 void *( *alloc)(void *opaque, size_t nmemb, size_t size);
 void ( *free)(void *opaque, void *ptr);
 void *opaque;
} lzma_allocator;

typedef struct lzma_coder_s lzma_coder;

typedef struct lzma_next_coder_s lzma_next_coder;

typedef struct lzma_filter_info_s lzma_filter_info;

typedef lzma_ret (*lzma_init_function)(
  lzma_next_coder *next, lzma_allocator *allocator,
  const lzma_filter_info *filters);

typedef lzma_ret (*lzma_code_function)(
  lzma_coder *coder, lzma_allocator *allocator,
  const uint8_t *restrict in, size_t *restrict in_pos,
  size_t in_size, uint8_t *restrict out,
  size_t *

Re: [SPARC] Fix PR target/54121

2012-12-11 Thread David Miller
From: Eric Botcazou 
Date: Tue, 11 Dec 2012 19:37:36 +0100

> This is a regression present on mainline and 4.7 branch for the SPARC.  
> Reload 
> is trying to change the value of a symbol(!) because it is mightily confused 
> by an output constraint on a source operand (old pasto in some TLS patterns).
> 
> Fixed thusly, tested on SPARC64/Linux, applied on all branches.

Thanks for fixing this Eric.


Re: [C++ PATCH] Fix -Wunused-but-set-variable false positives with cast to floating (PR c++/55643)

2012-12-11 Thread Jason Merrill

OK.

Jason


Re: More vector constexpr fixes

2012-12-11 Thread Jason Merrill

OK.

Jason


Re: PING^2: [PATCH] PR sanitizer/55533: Can't bootstrap libsanitizer

2012-12-11 Thread H.J. Lu
On Tue, Dec 11, 2012 at 6:36 AM, Paolo Bonzini  wrote:

>
> As a followup please check if AM_MAKEFLAGS is needed at all.
>
 diff --git a/libsanitizer/Makefile.in b/libsanitizer/Makefile.in
 index 21c2711..53e0be9 100644
 --- a/libsanitizer/Makefile.in
 +++ b/libsanitizer/Makefile.in
>
> Please do not include regenerated files in the patch.
>
 diff --git a/libsanitizer/asan/Makefile.am b/libsanitizer/asan/Makefile.am
 index 3da1db3..45fb3b3 100644
 --- a/libsanitizer/asan/Makefile.am
 +++ b/libsanitizer/asan/Makefile.am
 @@ -5,6 +5,10 @@ gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)

  DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS 
 -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DASAN_HAS_EXCEPTIONS=1 
 -DASAN_FLEXIBLE_MAPPING_AND_OFFSET=0 -DASAN_NEEDS_SEGV=1
  AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic 
 -Wno-long-long  -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer 
 -funwind-tables -fvisibility=hidden -Wno-variadic-macros 
 -Wno-c99-extensions
 +## We require libstdc++-v3 to be in the same build tree.
 +AM_CXXFLAGS += -I../../libstdc++-v3/include \
 +  -I../../libstdc++-v3/include/$(target_noncanonical) \
 +  -I$(srcdir)/../../libstdc++-v3/libsupc++
>
> As a followup, please bring back the possibility to build libsanitizer
> standalone, also wrapping the chooice of flags to link to libstdc++-v3
> in a new config/libstdc++-raw-cxx.m4 file.

Done.

> Bonus points for using this macro elsewhere in the tree.

That will be a separate patch.

  ACLOCAL_AMFLAGS = -I $(top_srcdir) -I $(top_srcdir)/config

  toolexeclib_LTLIBRARIES = libasan.la
 @@ -64,8 +68,6 @@ AM_MAKEFLAGS = \
 "includedir=$(includedir)" \
 "AR=$(AR)" \
 "AS=$(AS)" \
 -   "CC=$(CC)" \
 -   "CXX=$(CXX)" \
 "LD=$(LD)" \
 "LIBCFLAGS=$(LIBCFLAGS)" \
 "NM=$(NM)" \
>
> Same as above, and same for other .am files.
>
>
 diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac
 index 2d62ec4..9c73904 100644
 --- a/libsanitizer/configure.ac
 +++ b/libsanitizer/configure.ac
 @@ -19,6 +19,7 @@ AC_MSG_RESULT($version_specific_libs)
  # Do not delete or change the following two lines.  For why, see
  # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
  AC_CANONICAL_SYSTEM
 +ACX_NONCANONICAL_TARGET
>
> Note that if you create a new macro, ACX_NONCANONICAL_TARGET should be
> AC_REQUIREd there.
>

Here is the updated patch.  OK to install?

Thanks.


-- 
H.J.
---
config/

2012-12-11  H.J. Lu  

PR sanitizer/55533
* libstdc++-raw-cxx.m4: New file.

libsanitizer/

2012-12-11  H.J. Lu  

PR sanitizer/55533
* Makefile.am (AM_MAKEFLAGS): Remove CC and CXX.
* configure.ac (GCC_LIBSTDCXX_RAW_CXX_CXXFLAGS): New.
* asan/Makefile.am (AM_CXXFLAGS): Add $(LIBSTDCXX_RAW_CXX_CXXFLAGS).
(AM_MAKEFLAGS): Remove CC and CXX.
* interception/Makefile.am: Likewise.
* sanitizer_common/Makefile.am: Likewise.
* tsan/Makefile.am: Likewise.
* Makefile.in: Regenerated.
* aclocal.m4: Likewise.
* configure: Likewise.
* asan/Makefile.in: Likewise.
* interception/Makefile.in: Likewise.
* sanitizer_common/Makefile.in: Likewise.
* tsan/Makefile.in: Likewise.

diff --git a/config/libstdc++-raw-cxx.m4 b/config/libstdc++-raw-cxx.m4
new file mode 100644
index 000..453153c
--- /dev/null
+++ b/config/libstdc++-raw-cxx.m4
@@ -0,0 +1,26 @@
+# 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# .
+
+# Define compiler flags, LIBSTDCXX_RAW_CXX_CXXFLAGS, for libstdc++-v3
+# header files to compile libraries in C++ with raw_cxx=true.
+AC_DEFUN([GCC_LIBSTDCXX_RAW_CXX_CXXFLAGS], [
+  AC_REQUIRE([ACX_NONCANONICAL_TARGET])
+  LIBSTDCXX_RAW_CXX_CXXFLAGS="\
+-I\$(top_builddir)/../libstdc++-v3/include \
+-I\$(top_builddir)/../libstdc++-v3/include/\$(target_noncanonical) \
+-I\$(top_srcdir)/../libstdc++-v3/libsupc++"
+  AC_SUBST(LIBSTDCXX_RAW_CXX_CXXFLAGS)
+])
diff --git a/libsanitizer/Makefile.am b/libsanitizer/Makefile.am
index 9a06839..308d438 100644
--- a/libsanitizer/Makefile.am
+++ b/libsanitizer/Makefile.am
@@ -41,8 +41,6 @@ AM_MAKEFLAGS = \
"i

Re: [PATCH] New fdo summary-based icache sensitive unrolling (issue6351086)

2012-12-11 Thread Teresa Johnson
On Tue, Dec 11, 2012 at 10:12 AM, Jan Hubicka  wrote:
>> On 2012.12.11 at 09:13 -0800, Teresa Johnson wrote:
>> > Ping.
>> > Teresa
>> >
>> > On Mon, Nov 19, 2012 at 4:58 PM, Teresa Johnson  
>> > wrote:
>> > > This patch was proposed awhile back, and the new working set program
>> > > summary was split out and committed separately. I would like to
>> > > see if the loop unroller part of the patch can now go in. For the
>> > > previous versions of the patch and related discussion, see:
>> > >
>> > > http://gcc.gnu.org/ml/gcc-patches/2012-06/msg00437.html
>> > > and
>> > > http://gcc.gnu.org/ml/gcc-patches/2012-07/msg01373.html
>> > >
>> > > Use the new working set information in the FDO program summary for
>> > > codesize based unroll and peel decisions, to prevent those
>> > > optimizations from increasing code size too much when the
>> > > program may be sensitive to icache effects.
>> > >
>> > > As part of this, cache additional loop analysis results in the niter_desc
>> > > auxiliary information hanging off the loop structure to reduce
>> > > redundant analyses during unrolling.
>> > >
>> > > Bootstrapped and tested on x86_64-unknown-linux-gnu. Ok for trunk?
>>
>> I guess this is the missing piece that would fix the Firefox lto/pgo
>> code-size issue:
>>
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45375#c144
>
> It won't help in this case - the problem is that too much of code is 
> identified as hot,
> similar as for spec2k GCC benchmark.  Teresa - do you have any ideas what to 
> do here
> short of re-adding the BB ratio parameter and combining both heuristics for 
> 4.8?

Right, I doubt this patch would help. I looked through the bugzilla
log and it is most likely inlining increases. What was the size of the
gcc lto/pgo binary before the change to use the histogram? Was it
close to the gcc 4.7 lto/pgo size? In that case that is a very large
increase, ~25%.

Markus, could you attach to the bug one of the gcda files so that I
can see the program summary and figure out how far off the old hot bb
threshold is from the new histogram-based one? Also, it would be good
to see the -fdump-ipa-inline dumps before and after the regression (if
necessary, the before one could be from 4_7).

I'll update the bug with the same, so that we can track the discussion there.

Thanks,
Teresa

>
> Honza
>>
>> --
>> Markus



--
Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413


[patch] cluster loop bodies in CFG graph dumping

2012-12-11 Thread Steven Bosscher
Hello,

This patch clusters loop bodies in the CFG graph dumper. Makes for
easier-to-interpret plots and helps debugging.

Bootstrapped&tested on powerpc64-unknown-linux-gnu. OK for trunk?

Ciao!
Steven


graph_dump_loops.diff
Description: Binary data


Re: patch to fix pr55141

2012-12-11 Thread Richard Sandiford
Vladimir Makarov  writes:
> On 12/08/2012 05:30 AM, Richard Sandiford wrote:
>> Vladimir Makarov  writes:
>>> Index: lra-constraints.c
>>> ===
>>> --- lra-constraints.c   (revision 194307)
>>> +++ lra-constraints.c   (working copy)
>>> @@ -3329,8 +3329,9 @@ lra_constraints (bool first_p)
>>> reg = regno_reg_rtx[i];
>>> if ((hard_regno = lra_get_regno_hard_regno (i)) >= 0)
>>>   {
>>> -   int j, nregs = hard_regno_nregs[hard_regno][PSEUDO_REGNO_MODE (i)];
>>> +   int j, nregs;
>>>   
>>> +   nregs = hard_regno_nregs[hard_regno][lra_reg_info[i].biggest_mode];
>>> for (j = 0; j < nregs; j++)
>>>   df_set_regs_ever_live (hard_regno + j, true);
>> It looks like this loop now iterates over a different mode from the
>> pseudo register's, but starts at the hard register allocated to the
>> pseudo.  That doesn't work on big-endian targets, where the "extra"
>> registers come before hard_regno.  I think you need to use
>> simplify_subreg_regno (...subreg_lowpart_offset (...)).
>> I realise we only support little-endian for 4.8, but still.
> Yes, Richard, I am aware about it.  There are a few places in LRA where 
> similar code should be fixed for big-endian targets.  I'd like to 
> address this problem on lra-branch when I am less busy.

Well, OK, but in the meantime how about putting asserts like:

  gcc_assert (!BYTES_BIG_ENDIAN)

in the affected places?  I'm just worried that this kind of thing leads
to subtle wrong-code bugs in hard-to-reduce cases, so an assert would
make it easier to track which places need updating.

Richard


Re: [google/4.7]mark expected failures for ppc64 (issue 6932046)

2012-12-11 Thread jingyu

As suggested by Doug, this patch is aimed to google/integration,
google/main, and google/gcc-4_7.

https://codereview.appspot.com/6932046/


Re: [google/4.7]mark expected failures for ppc64 (issue 6932046)

2012-12-11 Thread Diego Novillo
On Tue, Dec 11, 2012 at 3:33 PM,   wrote:
> As suggested by Doug, this patch is aimed to google/integration,
> google/main, and google/gcc-4_7.

OK for google branches.  No need to add ChangeLog entries, however.


Diego.


[patch, mips] Follow up to pr54061 patch, fix another abort.

2012-12-11 Thread Steve Ellcey
While building libgcc in mips16 mode I found another instance of
dbx_reg_number aborting that the patch to pr54061 did not fix.
This code:

extern void __chk_fail (void) __attribute__ ((__noreturn__));
__strncpy_chk (s1, s2, n, s1len)
{
  char c;
  char *s = s1;
  if (__builtin_expect (s1len < n, 0))
__chk_fail ();
  while (c != '\0');
  return s;
}

aborts when compiled with -O2 -g -fpic -mips16.  The following patch
fixes it.  OK to checkin?

Steve Ellcey
sell...@mips.com


2012-12-11  Steve Ellcey  

* config/mips/mips.c (mips_option_override): Set
mips_dbx_regno[CPRESTORE_SLOT_REGNUM] to IGNORED_DWARF_REGNUM.


diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 820b228..8113e5d 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -16760,6 +16760,8 @@ mips_option_override (void)
   for (i = ALL_COP_REG_FIRST; i <= ALL_COP_REG_LAST; i++)
 mips_dbx_regno[i] = IGNORED_DWARF_REGNUM;
 
+  mips_dbx_regno[CPRESTORE_SLOT_REGNUM] = IGNORED_DWARF_REGNUM;
+
   /* Accumulator debug registers use big-endian ordering.  */
   mips_dbx_regno[HI_REGNUM] = MD_DBX_FIRST + 0;
   mips_dbx_regno[LO_REGNUM] = MD_DBX_FIRST + 1;


Re: [PATCH] PR c++/53609 - Wrong argument deduction for pack expansion in argument pack

2012-12-11 Thread Dodji Seketeli
Jason Merrill  writes:

> On 12/11/2012 10:55 AM, Dodji Seketeli wrote:
>> Oops, it seems I was too hasty in trying to do away with the
>> instantiation_yields_no_list_p parameter to
>> gen_elem_of_pack_expansion_instantiation.
>
> I still think that the elem function should just deal with the single
> element case; the cases where we can't do a piecewise substitution
> should be handled outside the elem function.

Like in the patch below?

>
>>> I suppose we should keep this for has_empty_arg, but I'd like to do
>>> away with special handling of the arg_from_parm_pack case if possible,
>>> as it's a lot of extra complexity.
>>
>> OK, done.
>
> Looks like you only removed the check from that one if; I'd like to do
> away with the arg_from_parm_pack function entirely if we can.

OK.  The below should hopefully approach what you have in mind.


Tested on x86_64-unknown-linux-gnu against trunk.

gcc/cp/

* pt.c (argument_pack_element_is_expansion_p)
(make_argument_pack_select, scan_parm_packs_and_args)
(gen_elem_of_pack_expansion_instantiation): New static functions.
(has_bare_parameter_packs): Factorized out of ...
(check_for_bare_parameter_packs): ... here.
(tsubst): When looking through an ARGUMENT_PACK_SELECT tree node,
look through the possibly resulting pack expansion as well.
(tsubst_pack_expansion): Now this function is clearly organized in
two parts: a part that maps each parameter pack with its matching
argument pack, and a part that walks that map to build the result
of substituting each element of the argument packs into the
parameter packs.  Use gen_elem_of_pack_expansion_instantiation for
the latter part.
(arg_from_parm_pack_p): Remove this for it's not used by
tsubst_pack_expansion anymore.

gcc/testsuite/

* g++.dg/cpp0x/variadic139.C: New test.
* g++.dg/cpp0x/variadic140.C: Likewise.
* g++.dg/cpp0x/variadic141.C: Likewise.
---
 gcc/cp/pt.c  | 487 ---
 gcc/testsuite/g++.dg/cpp0x/variadic139.C |  14 +
 gcc/testsuite/g++.dg/cpp0x/variadic140.C |  22 ++
 gcc/testsuite/g++.dg/cpp0x/variadic141.C |  22 ++
 4 files changed, 370 insertions(+), 175 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic139.C
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic140.C
 create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic141.C

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index ecb013e..14914d5 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -201,7 +201,6 @@ static void append_type_to_template_for_access_check_1 
(tree, tree, tree,
 static tree listify (tree);
 static tree listify_autos (tree, tree);
 static tree template_parm_to_arg (tree t);
-static bool arg_from_parm_pack_p (tree, tree);
 static tree current_template_args (void);
 static tree tsubst_template_parm (tree, tree, tsubst_flags_t);
 static tree instantiate_alias_template (tree, tree, tsubst_flags_t);
@@ -3308,6 +3307,29 @@ make_pack_expansion (tree arg)
   return result;
 }
 
+/* Return NULL_TREE iff T contains *NO* unexpanded parameter packs.
+   Return the TREE_LIST of unexpanded parameter packs otherwise.  */
+
+static tree
+has_bare_parameter_packs (tree t)
+{
+  tree parameter_packs = NULL_TREE;
+  struct find_parameter_pack_data ppd;
+
+  if (!processing_template_decl || !t || t == error_mark_node)
+return NULL_TREE;
+
+  if (TREE_CODE (t) == TYPE_DECL)
+t = TREE_TYPE (t);
+
+  ppd.parameter_packs = ¶meter_packs;
+  ppd.visited = pointer_set_create ();
+  cp_walk_tree (&t, &find_parameter_packs_r, &ppd, ppd.visited);
+  pointer_set_destroy (ppd.visited);
+
+  return parameter_packs;
+}
+
 /* Checks T for any "bare" parameter packs, which have not yet been
expanded, and issues an error if any are found. This operation can
only be done on full expressions or types (e.g., an expression
@@ -3325,19 +3347,7 @@ make_pack_expansion (tree arg)
 bool 
 check_for_bare_parameter_packs (tree t)
 {
-  tree parameter_packs = NULL_TREE;
-  struct find_parameter_pack_data ppd;
-
-  if (!processing_template_decl || !t || t == error_mark_node)
-return false;
-
-  if (TREE_CODE (t) == TYPE_DECL)
-t = TREE_TYPE (t);
-
-  ppd.parameter_packs = ¶meter_packs;
-  ppd.visited = pointer_set_create ();
-  cp_walk_tree (&t, &find_parameter_packs_r, &ppd, ppd.visited);
-  pointer_set_destroy (ppd.visited);
+  tree parameter_packs = has_bare_parameter_packs (t);
 
   if (parameter_packs) 
 {
@@ -3812,42 +3822,6 @@ template_parm_to_arg (tree t)
   return t;
 }
 
-/* This function returns TRUE if PARM_PACK is a template parameter
-   pack and if ARG_PACK is what template_parm_to_arg returned when
-   passed PARM_PACK.  */
-
-static bool
-arg_from_parm_pack_p (tree arg_pack, tree parm_pack)
-{
-  /* For clarity in the comments below let's use the representation
- argument_pack' to denote an argument pack and its
- elements.
-

Re: [patch] cfglayout fixes

2012-12-11 Thread Steven Bosscher
Ping?

On Thu, Dec 6, 2012 at 1:48 PM, Steven Bosscher wrote:
> Hello,
>
> This patch has 3 parts:
>
> 1. Benign comment fixes.
>
> 2. Using DF_REF_REG_MEM_P idiom. Also benign.
>
> 3. Real bug fixes for cfglayout mode.
>
> For (3) the fixes are:
> - Pointers to the unlinked parts of the insns chain are not cleared,
> which results in complete RTL bodies being left not
> garbage-collectable until the next function goes into cfglayout mode.
> When compiling an artificial test case with two very large functions,
> this patch reduces memory footprint by ~33%.
> - Looking for BARRIERs as, well, barriers between basic blocks doesn't
> work in cfglayout mode: the barriers are not there (they're in
> BB_FOOTER, not in the insns chain).
>
> Bootstrapped&tested on powerpc64-unknown-linux-gnu. OK for trunk?
>
> Ciao!
> Steven
>
>
>
> * bitmap.h: Fix "set_difference" references in comment.
> * dse.c (dse_bitmap_obstack): Fix comment.
>
> * loop-invariant.c (record_use): Use DF_REF_REG_MEM_P instead of
> looking at specific flags.
>
> * cfgrtl.c (rtl_verify_flow_info): Fix code style (indentation).
> (fixup_reorder_chain): Set cfg_layout_function_header to NULL to
> avoid dangling pointers into GC-allocated insns.  Clear BB_HEADER,
> BB_FOOTER, and cfg_layout_function_footer for the same reason.
> Do not link new barriers for cfgrtl mode to cfglayout's BB_FOOTER.
> * combine.c (combine_instructions): Fix end-of-block check to not
> expect BARRIERs, which may not exist in cfglayout mode.
>
> Index: bitmap.h
> ===
> --- bitmap.h(revision 194247)
> +++ bitmap.h(working copy)
> @@ -81,7 +81,7 @@ along with GCC; see the file COPYING3.  If not see
>   EXECUTE_IF_AND_IN_BITMAP
>   * set_union   : bitmap_ior / bitmap_ior_into
>   * set_difference  : bitmap_intersect_compl_p /
> - bitmap_and_comp / bitmap_and_comp_into /
> + bitmap_and_compl / bitmap_and_compl_into /
>   EXECUTE_IF_AND_COMPL_IN_BITMAP
>   * set_disjuction  : bitmap_xor_comp / bitmap_xor_comp_into
>   * set_compare : bitmap_equal_p
> Index: dse.c
> ===
> --- dse.c   (revision 194247)
> +++ dse.c   (working copy)
> @@ -204,7 +204,7 @@ along with GCC; see the file COPYING3.  If not see
> on the default obstack because these bitmaps can grow quite large
> (~2GB for the small (!) test case of PR54146) and we'll hold on to
> all that memory until the end of the compiler run.
> -   As a bonus, delete_tree_live_info can destroy all the bitmaps by just
> +   As a bonus, dse_step7 can destroy all the bitmaps by just
> releasing the whole obstack.  */
>  static bitmap_obstack dse_bitmap_obstack;
>
> Index: loop-invariant.c
> ===
> --- loop-invariant.c(revision 194247)
> +++ loop-invariant.c(working copy)
> @@ -756,8 +756,7 @@ record_use (struct def *def, df_ref use)
>
>u->pos = DF_REF_REAL_LOC (use);
>u->insn = DF_REF_INSN (use);
> -  u->addr_use_p = (DF_REF_TYPE (use) == DF_REF_REG_MEM_LOAD
> -  || DF_REF_TYPE (use) == DF_REF_REG_MEM_STORE);
> +  u->addr_use_p = DF_REF_REG_MEM_P (use);
>u->next = def->uses;
>def->uses = u;
>def->n_uses++;
> Index: cfgrtl.c
> ===
> --- cfgrtl.c(revision 194247)
> +++ cfgrtl.c(working copy)
> @@ -2361,13 +2361,13 @@ rtl_verify_flow_info (void)
> break;
>
>   /* And that the code outside of basic blocks has NULL bb field.  */
> -   if (!BARRIER_P (x)
> -   && BLOCK_FOR_INSN (x) != NULL)
> - {
> -   error ("insn %d outside of basic blocks has non-NULL bb field",
> -  INSN_UID (x));
> -   err = 1;
> - }
> + if (!BARRIER_P (x)
> + && BLOCK_FOR_INSN (x) != NULL)
> +   {
> + error ("insn %d outside of basic blocks has non-NULL bb field",
> +INSN_UID (x));
> + err = 1;
> +   }
> }
>
>if (!x)
> @@ -3159,6 +3159,7 @@ fixup_reorder_chain (void)
>insn = cfg_layout_function_header;
>while (NEXT_INSN (insn))
> insn = NEXT_INSN (insn);
> +  cfg_layout_function_header = NULL_RTX;
>  }
>
>/* First do the bulk reordering -- rechain the blocks without regard to
> @@ -3190,15 +3191,18 @@ fixup_reorder_chain (void)
>   while (NEXT_INSN (insn))
> insn = NEXT_INSN (insn);
> }
> +  BB_HEADER (bb) = BB_FOOTER (bb) = NULL_RTX;
>  }
>
>NEXT_INSN (insn) = cfg_layout_function_footer;
>if (cfg_layout_function_footer

Re: PING^2: [PATCH] PR sanitizer/55533: Can't bootstrap libsanitizer

2012-12-11 Thread Paolo Bonzini
Il 11/12/2012 20:27, H.J. Lu ha scritto:
> On Tue, Dec 11, 2012 at 6:36 AM, Paolo Bonzini  wrote:
> 
>>
>> As a followup please check if AM_MAKEFLAGS is needed at all.
>>
> diff --git a/libsanitizer/Makefile.in b/libsanitizer/Makefile.in
> index 21c2711..53e0be9 100644
> --- a/libsanitizer/Makefile.in
> +++ b/libsanitizer/Makefile.in
>>
>> Please do not include regenerated files in the patch.
>>
> diff --git a/libsanitizer/asan/Makefile.am b/libsanitizer/asan/Makefile.am
> index 3da1db3..45fb3b3 100644
> --- a/libsanitizer/asan/Makefile.am
> +++ b/libsanitizer/asan/Makefile.am
> @@ -5,6 +5,10 @@ gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER)
>
>  DEFS = -D_GNU_SOURCE -D_DEBUG -D__STDC_CONSTANT_MACROS 
> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -DASAN_HAS_EXCEPTIONS=1 
> -DASAN_FLEXIBLE_MAPPING_AND_OFFSET=0 -DASAN_NEEDS_SEGV=1
>  AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic 
> -Wno-long-long  -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer 
> -funwind-tables -fvisibility=hidden -Wno-variadic-macros 
> -Wno-c99-extensions
> +## We require libstdc++-v3 to be in the same build tree.
> +AM_CXXFLAGS += -I../../libstdc++-v3/include \
> +  -I../../libstdc++-v3/include/$(target_noncanonical) \
> +  -I$(srcdir)/../../libstdc++-v3/libsupc++
>>
>> As a followup, please bring back the possibility to build libsanitizer
>> standalone, also wrapping the chooice of flags to link to libstdc++-v3
>> in a new config/libstdc++-raw-cxx.m4 file.
> 
> Done.
> 
>> Bonus points for using this macro elsewhere in the tree.
> 
> That will be a separate patch.
> 
>  ACLOCAL_AMFLAGS = -I $(top_srcdir) -I $(top_srcdir)/config
>
>  toolexeclib_LTLIBRARIES = libasan.la
> @@ -64,8 +68,6 @@ AM_MAKEFLAGS = \
> "includedir=$(includedir)" \
> "AR=$(AR)" \
> "AS=$(AS)" \
> -   "CC=$(CC)" \
> -   "CXX=$(CXX)" \
> "LD=$(LD)" \
> "LIBCFLAGS=$(LIBCFLAGS)" \
> "NM=$(NM)" \
>>
>> Same as above, and same for other .am files.
>>
>>
> diff --git a/libsanitizer/configure.ac b/libsanitizer/configure.ac
> index 2d62ec4..9c73904 100644
> --- a/libsanitizer/configure.ac
> +++ b/libsanitizer/configure.ac
> @@ -19,6 +19,7 @@ AC_MSG_RESULT($version_specific_libs)
>  # Do not delete or change the following two lines.  For why, see
>  # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
>  AC_CANONICAL_SYSTEM
> +ACX_NONCANONICAL_TARGET
>>
>> Note that if you create a new macro, ACX_NONCANONICAL_TARGET should be
>> AC_REQUIREd there.
>>
> 
> Here is the updated patch.  OK to install?
> 
> Thanks.

Ok.



Re: [PATCH] PR c++/53609 - Wrong argument deduction for pack expansion in argument pack

2012-12-11 Thread Jason Merrill

On 12/11/2012 04:09 PM, Dodji Seketeli wrote:

OK.  The below should hopefully approach what you have in mind.


Thanks, that's closer to what I was thinking.  I'd also like to move the 
scan and PACK_EXPANSION_EXTRA_ARGS code back out of the loop.


Jason



[PATCH] Forward port Steven's PR middle-end/52640 patch

2012-12-11 Thread Jakub Jelinek
Hi!

As discussed in the PR, this patch forward ports Steven's patch from 4.7
branch to trunk.  No need to include pointer-set.h (already included),
I've moved the var definition into the #ifdef so that it isn't an unused
static var and tweaked the comment a little bit.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2012-12-11  Steven Bosscher  
Jakub Jelinek  

PR middle-end/52640
* varasm.c (pending_assemble_externals_set): New pointer set.
(process_pending_assemble_externals): Destroy the pointer set.
(assemble_external): See if decl is in pending_assemble_externals_set,
and add it to pending_assemble_externals if necessary.
(init_varasm_once): Allocate pending_assemble_externals_set.

* gcc.c-torture/compile/limits-externdecl.c: New test.

--- gcc/varasm.c.jj 2012-12-11 13:05:36.099732106 +0100
+++ gcc/varasm.c2012-12-11 18:01:52.454620513 +0100
@@ -2089,6 +2089,10 @@ contains_pointers_p (tree type)
 static GTY(()) tree pending_assemble_externals;
 
 #ifdef ASM_OUTPUT_EXTERNAL
+/* Avoid O(external_decls**2) lookups in the pending_assemble_externals
+   TREE_LIST in assemble_external.  */
+static struct pointer_set_t *pending_assemble_externals_set;
+
 /* True if DECL is a function decl for which no out-of-line copy exists.
It is assumed that DECL's assembler name has been set.  */
 
@@ -2140,6 +2144,7 @@ process_pending_assemble_externals (void
 assemble_external_real (TREE_VALUE (list));
 
   pending_assemble_externals = 0;
+  pointer_set_destroy (pending_assemble_externals_set);
 #endif
 }
 
@@ -2191,7 +2196,7 @@ assemble_external (tree decl ATTRIBUTE_U
 weak_decls = tree_cons (NULL, decl, weak_decls);
 
 #ifdef ASM_OUTPUT_EXTERNAL
-  if (value_member (decl, pending_assemble_externals) == NULL_TREE)
+  if (! pointer_set_insert (pending_assemble_externals_set, decl))
 pending_assemble_externals = tree_cons (NULL, decl,
pending_assemble_externals);
 #endif
@@ -5904,6 +5909,10 @@ init_varasm_once (void)
 
   if (readonly_data_section == NULL)
 readonly_data_section = text_section;
+
+#ifdef ASM_OUTPUT_EXTERNAL
+  pending_assemble_externals_set = pointer_set_create ();
+#endif
 }
 
 enum tls_model
--- gcc/testsuite/gcc.c-torture/compile/limits-externdecl.c.jj  2012-12-11 
17:59:03.130578361 +0100
+++ gcc/testsuite/gcc.c-torture/compile/limits-externdecl.c 2012-12-11 
17:59:03.130578361 +0100
@@ -0,0 +1,55 @@
+/* Inspired by the test case for PR middle-end/52640.  */
+
+typedef struct
+{
+char *value;
+} REFERENCE;
+
+/* Add a few "extern int Xx ();" declarations.  */
+#undef DEF
+#undef LIM1
+#undef LIM2
+#undef LIM3
+#undef LIM4
+#undef LIM5
+#undef LIM6
+#define DEF(x) extern int x ()
+#define LIM1(x) DEF(x##0); DEF(x##1); DEF(x##2); DEF(x##3); DEF(x##4); \
+   DEF(x##5); DEF(x##6); DEF(x##7); DEF(x##8); DEF(x##9);
+#define LIM2(x) LIM1(x##0) LIM1(x##1) LIM1(x##2) LIM1(x##3) LIM1(x##4) \
+   LIM1(x##5) LIM1(x##6) LIM1(x##7) LIM1(x##8) LIM1(x##9)
+#define LIM3(x) LIM2(x##0) LIM2(x##1) LIM2(x##2) LIM2(x##3) LIM2(x##4) \
+   LIM2(x##5) LIM2(x##6) LIM2(x##7) LIM2(x##8) LIM2(x##9)
+#define LIM4(x) LIM3(x##0) LIM3(x##1) LIM3(x##2) LIM3(x##3) LIM3(x##4) \
+   LIM3(x##5) LIM3(x##6) LIM3(x##7) LIM3(x##8) LIM3(x##9)
+#define LIM5(x) LIM4(x##0) LIM4(x##1) LIM4(x##2) LIM4(x##3) LIM4(x##4) \
+   LIM4(x##5) LIM4(x##6) LIM4(x##7) LIM4(x##8) LIM4(x##9)
+#define LIM6(x) LIM5(x##0) LIM5(x##1) LIM5(x##2) LIM5(x##3) LIM5(x##4) \
+   LIM5(x##5) LIM5(x##6) LIM5(x##7) LIM5(x##8) LIM5(x##9)
+LIM5 (X);
+
+/* Add references to them, or GCC will simply ignore the extern decls.  */
+#undef DEF
+#undef LIM1
+#undef LIM2
+#undef LIM3
+#undef LIM4
+#undef LIM5
+#undef LIM6
+#define DEF(x) (char *) x
+#define LIM1(x) DEF(x##0), DEF(x##1), DEF(x##2), DEF(x##3), DEF(x##4), \
+   DEF(x##5), DEF(x##6), DEF(x##7), DEF(x##8), DEF(x##9),
+#define LIM2(x) LIM1(x##0) LIM1(x##1) LIM1(x##2) LIM1(x##3) LIM1(x##4) \
+   LIM1(x##5) LIM1(x##6) LIM1(x##7) LIM1(x##8) LIM1(x##9)
+#define LIM3(x) LIM2(x##0) LIM2(x##1) LIM2(x##2) LIM2(x##3) LIM2(x##4) \
+   LIM2(x##5) LIM2(x##6) LIM2(x##7) LIM2(x##8) LIM2(x##9)
+#define LIM4(x) LIM3(x##0) LIM3(x##1) LIM3(x##2) LIM3(x##3) LIM3(x##4) \
+   LIM3(x##5) LIM3(x##6) LIM3(x##7) LIM3(x##8) LIM3(x##9)
+#define LIM5(x) LIM4(x##0) LIM4(x##1) LIM4(x##2) LIM4(x##3) LIM4(x##4) \
+   LIM4(x##5) LIM4(x##6) LIM4(x##7) LIM4(x##8) LIM4(x##9)
+#define LIM6(x) LIM5(x##0) LIM5(x##1) LIM5(x##2) LIM5(x##3) LIM5(x##4) \
+   LIM5(x##5) LIM5(x##6) LIM5(x##7) LIM5(x##8) LIM5(x##9)
+REFERENCE references[] = {
+  LIM5 (X)
+  0
+};

Jakub


PATCH: Remove AM_MAKEFLAGS from libsanitizer

2012-12-11 Thread H.J. Lu
On Tue, Dec 11, 2012 at 6:36 AM, Paolo Bonzini  wrote:
> Il 11/12/2012 14:47, H.J. Lu ha scritto:
>> On Thu, Dec 6, 2012 at 7:07 AM, H.J. Lu  wrote:
>>> On Thu, Nov 29, 2012 at 10:30 AM, H.J. Lu  wrote:
 Hi,

 Since libsanitizer is used for bootstrap and compiled with raw_cxx,
 we need to use explicit -I for libstdc++-v3 header files in
 libsanitizer.  Otherwise, we will get

 libtool: compile: unrecognized option `-D_GNU_SOURCE'
 libtool: compile: Try `libtool --help' for more information.

 This patch fixes it.  OK to install?

 Thanks.


 H.J.
 ---
  libsanitizer/Makefile.am  |  2 --
  libsanitizer/Makefile.in  |  6 +++---
  libsanitizer/aclocal.m4   |  1 +
  libsanitizer/asan/Makefile.am |  6 --
  libsanitizer/asan/Makefile.in | 14 ++
  libsanitizer/configure| 22 --
  libsanitizer/configure.ac |  1 +
  libsanitizer/interception/Makefile.am |  6 --
  libsanitizer/interception/Makefile.in | 14 ++
  libsanitizer/sanitizer_common/Makefile.am |  6 --
  libsanitizer/sanitizer_common/Makefile.in | 14 ++
  libsanitizer/tsan/Makefile.am |  6 --
  libsanitizer/tsan/Makefile.in | 13 +
  14 files changed, 97 insertions(+), 31 deletions(-)
  create mode 100644 libsanitizer/ChangeLog.asan

 2012-11-22  H.J. Lu  

 * Makefile.am (AM_MAKEFLAGS): Remove CC and CXX.
 * configure.ac (ACX_NONCANONICAL_TARGET): New.
 * asan/Makefile.am (AM_CXXFLAGS): Add -I for libstdc++-v3 header
 files.
 (AM_MAKEFLAGS): Remove CC and CXX.
 * interception/Makefile.am: Likewise.
 * sanitizer_common/Makefile.am: Likewise.
 * tsan/Makefile.am: Likewise.
 * Makefile.in: Regenerated.
 * aclocal.m4: Likewise.
 * configure: Likewise.
 * asan/Makefile.in: Likewise.
 * interception/Makefile.in: Likewise.
 * sanitizer_common/Makefile.in: Likewise.
 * tsan/Makefile.in: Likewise.

 diff --git a/libsanitizer/Makefile.am b/libsanitizer/Makefile.am
 index 64d3d2e..cd4e92d 100644
 --- a/libsanitizer/Makefile.am
 +++ b/libsanitizer/Makefile.am
 @@ -37,8 +37,6 @@ AM_MAKEFLAGS = \
 "includedir=$(includedir)" \
 "AR=$(AR)" \
 "AS=$(AS)" \
 -   "CC=$(CC)" \
 -   "CXX=$(CXX)" \
 "LD=$(LD)" \
 "LIBCFLAGS=$(LIBCFLAGS)" \
 "NM=$(NM)" \
>
> As a followup please check if AM_MAKEFLAGS is needed at all.
>
 diff --git a/libsanitizer/Makefile.in b/libsanitizer/Makefile.in
 index 21c2711..53e0be9 100644
 --- a/libsanitizer/Makefile.in
 +++ b/libsanitizer/Makefile.in
>
> Please do not include regenerated files in the patch.
>

Here is a patch to remove AM_MAKEFLAGS from
libsanitizer.  Tested on Linux/x86-64.  OK to install?

Thanks.


H.J.
---
2012-12-11  H.J. Lu  

* Makefile.am (AM_MAKEFLAGS): Removed.
* interception/Makefile.am: Likewise.
* sanitizer_common/Makefile.am: Likewise.
* tsan/Makefile.am: Likewise.
* Makefile.in: Regenerated.
* asan/Makefile.in: Likewise.
* interception/Makefile.in: Likewise.
* sanitizer_common/Makefile.in: Likewise.
* tsan/Makefile.in: Likewise.

diff --git a/libsanitizer/Makefile.am b/libsanitizer/Makefile.am
index 308d438..272a218 100644
--- a/libsanitizer/Makefile.am
+++ b/libsanitizer/Makefile.am
@@ -10,44 +10,6 @@ if USING_MAC_INTERPOSE
 SUBDIRS = sanitizer_common asan
 endif

-# Work around what appears to be a GNU make bug handling MAKEFLAGS
-# values defined in terms of make variables, as is the case for CC and
-# friends when we are called from the top level Makefile.
-AM_MAKEFLAGS = \
-   "AR_FLAGS=$(AR_FLAGS)" \
-   "CC_FOR_BUILD=$(CC_FOR_BUILD)" \
-   "CFLAGS=$(CFLAGS)" \
-   "CXXFLAGS=$(CXXFLAGS)" \
-   "CFLAGS_FOR_BUILD=$(CFLAGS_FOR_BUILD)" \
-   "CFLAGS_FOR_TARGET=$(CFLAGS_FOR_TARGET)" \
-   "INSTALL=$(INSTALL)" \
-   "INSTALL_DATA=$(INSTALL_DATA)" \
-   "INSTALL_PROGRAM=$(INSTALL_PROGRAM)" \
-   "INSTALL_SCRIPT=$(INSTALL_SCRIPT)" \
-   "JC1FLAGS=$(JC1FLAGS)" \
-   "LDFLAGS=$(LDFLAGS)" \
-   "LIBCFLAGS=$(LIBCFLAGS)" \
-   "LIBCFLAGS_FOR_TARGET=$(LIBCFLAGS_FOR_TARGET)" \
-   "MAKE=$(MAKE)" \
-   "MAKEINFO=$(MAKEINFO) $(MAKEINFOFLAGS)" \
-   "PICFLAG=$(PICFLAG)" \
-   "PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
-   "SHELL=$(SHELL)" \
-   "RUNTESTFLAGS=$(RUNTESTFLAGS)" \
-   "exec_prefix=$(exec_prefix)" \
-   "infodir=$(infodir)" \
-   "libdir=$(libdir)" \
-   "prefix=$(prefix)" \
-   "includedir=$(incl

extern "C" fixes for sunCC

2012-12-11 Thread Marc Glisse

Hello,

this patch should help if we ever want to use sunCC to initiate a 
bootstrap, though I didn't test with sunCC. Note that using gmp_fprintf 
means we have to include stdio.h before gmp.h. I didn't investigate how, 
but this seems to already be the case :-) The reallocator cast is just a 
hack, but the point here is only to help sunCC, making gcc extern 
"C"-clean is a larger task...


Passes bootstrap+testsuite on x86_64-linux using the system's gcc 
(graphite is enabled, don't know if this particular code is exercised).


2012-12-12  Marc Glisse  

PR bootstrap/50167
PR bootstrap/50177
libcpp/
* line-map.c (get_combined_adhoc_loc): Cast to extern "C" type.
gcc/
* graphite-interchange.c (pdr_stride_in_loop): Use gmp_fprintf.
* graphite-poly.c (debug_gmp_value): Likewise.


--
Marc GlisseIndex: gcc/graphite-poly.c
===
--- gcc/graphite-poly.c (revision 194404)
+++ gcc/graphite-poly.c (working copy)
@@ -48,26 +48,21 @@ along with GCC; see the file COPYING3.
 #include "graphite-poly.h"
 
 #define OPENSCOP_MAX_STRING 256
 
 
 /* Print to STDERR the GMP value VAL.  */
 
 DEBUG_FUNCTION void
 debug_gmp_value (mpz_t val)
 {
-  char *str = mpz_get_str (0, 10, val);
-  void (*gmp_free) (void *, size_t);
-
-  fprintf (stderr, "%s", str);
-  mp_get_memory_functions (NULL, NULL, &gmp_free);
-  (*gmp_free) (str, strlen (str) + 1);
+  gmp_fprintf (stderr, "%Zd", val);
 }
 
 /* Return the maximal loop depth in SCOP.  */
 
 int
 scop_max_loop_depth (scop_p scop)
 {
   int i;
   poly_bb_p pbb;
   int max_nb_loops = 0;
Index: gcc/graphite-interchange.c
===
--- gcc/graphite-interchange.c  (revision 194404)
+++ gcc/graphite-interchange.c  (working copy)
@@ -233,29 +233,22 @@ pdr_stride_in_loop (mpz_t stride, graphi
   aff = isl_aff_set_coefficient_si (aff, isl_dim_in, offset + offset - 1, 1);
   isl_int_init (islstride);
   isl_set_max (set, aff, &islstride);
   isl_int_get_gmp (islstride, stride);
   isl_int_clear (islstride);
   isl_aff_free (aff);
   isl_set_free (set);
 
   if (dump_file && (dump_flags & TDF_DETAILS))
 {
-  char *str;
-  void (*gmp_free) (void *, size_t);
-
-  fprintf (dump_file, "\nStride in BB_%d, DR_%d, depth %d:",
-  pbb_index (pbb), PDR_ID (pdr), (int) depth);
-  str = mpz_get_str (0, 10, stride);
-  fprintf (dump_file, "  %s ", str);
-  mp_get_memory_functions (NULL, NULL, &gmp_free);
-  (*gmp_free) (str, strlen (str) + 1);
+  gmp_fprintf (dump_file, "\nStride in BB_%d, DR_%d, depth %d:  %Zd ",
+  pbb_index (pbb), PDR_ID (pdr), (int) depth, stride);
 }
 }
 
 /* Sets STRIDES to the sum of all the strides of the data references
accessed in LOOP at DEPTH.  */
 
 static void
 memory_strides_in_loop_1 (lst_p loop, graphite_dim_t depth, mpz_t strides)
 {
   int i, j;
Index: libcpp/line-map.c
===
--- libcpp/line-map.c   (revision 194404)
+++ libcpp/line-map.c   (working copy)
@@ -116,21 +116,22 @@ get_combined_adhoc_loc (struct line_maps
   slot = (struct location_adhoc_data **)
   htab_find_slot (set->location_adhoc_data_map.htab, &lb, INSERT);
   if (*slot == NULL)
 {
   if (set->location_adhoc_data_map.curr_loc >=
  set->location_adhoc_data_map.allocated)
{
  char *orig_data = (char *) set->location_adhoc_data_map.data;
  long long offset;
  line_map_realloc reallocator
- = set->reallocator ? set->reallocator : xrealloc;
+ = set->reallocator ? set->reallocator
+: (line_map_realloc) xrealloc;
 
  if (set->location_adhoc_data_map.allocated == 0)
set->location_adhoc_data_map.allocated = 128;
  else
set->location_adhoc_data_map.allocated *= 2;
  set->location_adhoc_data_map.data = (struct location_adhoc_data *)
  reallocator (set->location_adhoc_data_map.data,
   set->location_adhoc_data_map.allocated
   * sizeof (struct location_adhoc_data));
  offset = (char *) (set->location_adhoc_data_map.data) - orig_data;


Re: [patch] cfglayout fixes

2012-12-11 Thread Marek Polacek
On Thu, Dec 06, 2012 at 01:48:31PM +0100, Steven Bosscher wrote:
> Hello,
> 
> This patch has 3 parts:
> 
> 1. Benign comment fixes.
> 
> 2. Using DF_REF_REG_MEM_P idiom. Also benign.
> 
> 3. Real bug fixes for cfglayout mode.
> 
> For (3) the fixes are:
> - Pointers to the unlinked parts of the insns chain are not cleared,
> which results in complete RTL bodies being left not
> garbage-collectable until the next function goes into cfglayout mode.
> When compiling an artificial test case with two very large functions,
> this patch reduces memory footprint by ~33%.
> - Looking for BARRIERs as, well, barriers between basic blocks doesn't
> work in cfglayout mode: the barriers are not there (they're in
> BB_FOOTER, not in the insns chain).
> 
> Bootstrapped&tested on powerpc64-unknown-linux-gnu. OK for trunk?
> 
> Ciao!
> Steven
> 
> 
> 
> * bitmap.h: Fix "set_difference" references in comment.
> * dse.c (dse_bitmap_obstack): Fix comment.
> 
> * loop-invariant.c (record_use): Use DF_REF_REG_MEM_P instead of
> looking at specific flags.

Dunno about the rest, but these parts look ok.

Marek


Re: [patch, mips] Follow up to pr54061 patch, fix another abort.

2012-12-11 Thread Richard Sandiford
"Steve Ellcey "  writes:
> While building libgcc in mips16 mode I found another instance of
> dbx_reg_number aborting that the patch to pr54061 did not fix.
> This code:
>
> extern void __chk_fail (void) __attribute__ ((__noreturn__));
> __strncpy_chk (s1, s2, n, s1len)
> {
>   char c;
>   char *s = s1;
>   if (__builtin_expect (s1len < n, 0))
> __chk_fail ();
>   while (c != '\0');
>   return s;
> }
>
> aborts when compiled with -O2 -g -fpic -mips16.  The following patch
> fixes it.  OK to checkin?
>
> Steve Ellcey
> sell...@mips.com
>
>
> 2012-12-11  Steve Ellcey  
>
>   * config/mips/mips.c (mips_option_override): Set
>   mips_dbx_regno[CPRESTORE_SLOT_REGNUM] to IGNORED_DWARF_REGNUM.
>
>
> diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
> index 820b228..8113e5d 100644
> --- a/gcc/config/mips/mips.c
> +++ b/gcc/config/mips/mips.c
> @@ -16760,6 +16760,8 @@ mips_option_override (void)
>for (i = ALL_COP_REG_FIRST; i <= ALL_COP_REG_LAST; i++)
>  mips_dbx_regno[i] = IGNORED_DWARF_REGNUM;
>  
> +  mips_dbx_regno[CPRESTORE_SLOT_REGNUM] = IGNORED_DWARF_REGNUM;
> +
>/* Accumulator debug registers use big-endian ordering.  */
>mips_dbx_regno[HI_REGNUM] = MD_DBX_FIRST + 0;
>mips_dbx_regno[LO_REGNUM] = MD_DBX_FIRST + 1;

If even fake registers like these are going to be used, then I think
we should initialise to IGNORED_DWARF_REGNUM rather than INVALID_REGNUM in:

  for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
{
  mips_dbx_regno[i] = INVALID_REGNUM;
  ...
}

and remove the ALL_COP_REG loop that was in the earlier patch.

Richard


Use libstdc++-raw-cxx.m4 in libjava

2012-12-11 Thread H.J. Lu
On Tue, Dec 11, 2012 at 6:36 AM, Paolo Bonzini  wrote:

  AM_CXXFLAGS = -Wall -W -Wno-unused-parameter -Wwrite-strings -pedantic 
 -Wno-long-long  -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer 
 -funwind-tables -fvisibility=hidden -Wno-variadic-macros 
 -Wno-c99-extensions
 +## We require libstdc++-v3 to be in the same build tree.
 +AM_CXXFLAGS += -I../../libstdc++-v3/include \
 +  -I../../libstdc++-v3/include/$(target_noncanonical) \
 +  -I$(srcdir)/../../libstdc++-v3/libsupc++
>
> As a followup, please bring back the possibility to build libsanitizer
> standalone, also wrapping the chooice of flags to link to libstdc++-v3
> in a new config/libstdc++-raw-cxx.m4 file.
>
> Bonus points for using this macro elsewhere in the tree.
>

This patch adds LIBSTDCXX_RAW_CXX_LDFLAGS and use
it in libjava and libsanitizer which set raw_cxx=true.  I am testing
it on Linux/x86-64.  OK to install if it works?

Thanks.


H.J.
---
cat /tmp/gcc-raw-cxx.patch
config/

2012-12-11  H.J. Lu  

* libstdc++-raw-cxx.m4 (GCC_LIBSTDCXX_RAW_CXX_FLAGS): Also
AC_SUBST LIBSTDCXX_RAW_CXX_LDFLAGS.

libjava/

2012-12-11  H.J. Lu  

* Makefile.am (lib_gnu_awt_xlib_la_CPPFLAGS): Use
$(LIBSTDCXX_RAW_CXX_CXXLAGS).
(lib_gnu_awt_xlib_la_LDFLAGS): Use $(LIBSTDCXX_RAW_CXX_LDLAGS).
* configure.ac (GCC_LIBSTDCXX_RAW_CXX_FLAGS): New.
* aclocal.m4: Regenerated.
* Makefile.in:Likewise.
* configure: Likewise.

libsanitizer/

2012-12-11  H.J. Lu  

* asan/Makefile.am (libasan_la_LIBADD): Use $(LIBSTDCXX_RAW_CXX_LDLAGS).
* tsan/Makefile.am (libtsan_la_LIBADD): Likewise.
* Makefile.in: Regenerated.
* configure: Likewise.
* asan/Makefile.in: Likewise.
* interception/Makefile.in: Likewise.
* sanitizer_common/Makefile.in: Likewise.
* tsan/Makefile.in: Likewise.

diff --git a/config/libstdc++-raw-cxx.m4 b/config/libstdc++-raw-cxx.m4
index 20124e3..8052c2f 100644
--- a/config/libstdc++-raw-cxx.m4
+++ b/config/libstdc++-raw-cxx.m4
@@ -14,13 +14,17 @@
 # along with GCC; see the file COPYING3.  If not see
 # .

-# Define compiler flags, LIBSTDCXX_RAW_CXX_CXXFLAGS, for libstdc++-v3
-# header files to compile libraries in C++ with raw_cxx=true.
+# Define flags, LIBSTDCXX_RAW_CXX_CXXFLAGS and # LIBSTDCXX_RAW_CXX_LDFLAGS,
+# for libstdc++-v3 header files to compile and link libraries in C++ with
+# raw_cxx=true.
 AC_DEFUN([GCC_LIBSTDCXX_RAW_CXX_FLAGS], [
   AC_REQUIRE([ACX_NONCANONICAL_TARGET])
   LIBSTDCXX_RAW_CXX_CXXFLAGS="\
 -I\$(top_builddir)/../libstdc++-v3/include \
 -I\$(top_builddir)/../libstdc++-v3/include/\$(target_noncanonical) \
 -I\$(top_srcdir)/../libstdc++-v3/libsupc++"
+  LIBSTDCXX_RAW_CXX_LDFLAGS="\
+-I\$(top_builddir)/../libstdc++-v3/src/libstdc++.la"
   AC_SUBST(LIBSTDCXX_RAW_CXX_CXXFLAGS)
+  AC_SUBST(LIBSTDCXX_RAW_CXX_LDFLAGS)
 ])
diff --git a/libjava/Makefile.am b/libjava/Makefile.am
index 1b71962..c6c84e4 100644
--- a/libjava/Makefile.am
+++ b/libjava/Makefile.am
@@ -590,14 +590,11 @@ lib_gnu_awt_xlib_la_DEPENDENCIES =
libgcj-$(gcc_version).jar \
 if BUILD_SUBLIBS
 lib_gnu_awt_xlib_la_DEPENDENCIES += libgcj-noncore.la
 endif
-## We require libstdc++-v3 to be in the same build tree.
 lib_gnu_awt_xlib_la_CPPFLAGS = \
$(AM_CPPFLAGS) \
-   -I../libstdc++-v3/include \
-   -I../libstdc++-v3/include/$(target_noncanonical) \
-   -I$(srcdir)/../libstdc++-v3/libsupc++
+   $(LIBSTDCXX_RAW_CXX_CXXFLAGS)
 ## The mysterious backslash in the grep pattern is consumed by make.
-lib_gnu_awt_xlib_la_LDFLAGS = ../libstdc++-v3/src/libstdc++.la \
+lib_gnu_awt_xlib_la_LDFLAGS = $(LIBSTDCXX_RAW_CXX_LDLAGS) \
@X_PRE_LIBS@ @X_LIBS@ -lX11 @X_EXTRA_LIBS@ \
 -rpath $(toolexeclibdir) $(LIBJAVA_LDFLAGS_NOUNDEF) \
 -version-info `grep -v '^\#' $(srcdir)/libtool-version`
$(LIBGCJ_LD_SYMBOLIC)
diff --git a/libjava/configure.ac b/libjava/configure.ac
index 5fa75c6..ba6b363 100644
--- a/libjava/configure.ac
+++ b/libjava/configure.ac
@@ -24,6 +24,8 @@ _GCC_TOPLEV_NONCANONICAL_TARGET

 AC_SUBST(target_noncanonical)

+GCC_LIBSTDCXX_RAW_CXX_FLAGS
+
 # This works around the fact that libtool configuration may change LD
 # for this particular configuration, but some shells, instead of
 # keeping the changes in LD private, export them just because LD is
diff --git a/libsanitizer/asan/Makefile.am b/libsanitizer/asan/Makefile.am
index 5852c35..95fd75e 100644
--- a/libsanitizer/asan/Makefile.am
+++ b/libsanitizer/asan/Makefile.am
@@ -36,10 +36,11 @@ asan_files = \
 libasan_la_SOURCES = $(asan_files)
 if USING_MAC_INTERPOSE
 libasan_la_SOURCES += dynamic/asan_interceptors_dynamic.cc
-libasan_la_LIBADD =
$(top_builddir)/sanitizer_common/libsanitizer_common.la
$(top_builddir)/../libstdc++-v3/src/libstdc++.la
+libasan_la_LIBADD = $(top_builddir)/sanitizer_common/libsanitizer_common.la
 else
-libasan_la_L

[patch c/c++]: Fix for PR c/52991 issue about ignored packed-attribute for ms-structure-layout

2012-12-11 Thread Kai Tietz
Hello,

This fixes an old regression about ms-structure-layout in combination
with packed-attribute.

ChangeLog

2012-12-11  Kai Tietz

PR c/52991
* stor-layout.c (start_record_layout): Handle
packed-attribute for ms-structure-layout.
(update_alignment_for_field): Likewise.
(place_field): Likewise.


Tested for i686-w64-mingw32, x86_64-w64-mingw32, and for
x86_64-unknown-linux-gnu.  Ok for apply?

Regards,
Kai

Index: stor-layout.c
===
--- stor-layout.c   (Revision 194386)
+++ stor-layout.c   (Arbeitskopie)
@@ -756,7 +756,10 @@ start_record_layout (tree t)
   /* If the type has a minimum specified alignment (via an attribute
  declaration, for example) use it -- otherwise, start with a
  one-byte alignment.  */
-  rli->record_align = MAX (BITS_PER_UNIT, TYPE_ALIGN (t));
+  if (TYPE_PACKED (t))
+rli->record_align = BITS_PER_UNIT;
+  else
+rli->record_align = MAX (BITS_PER_UNIT, TYPE_ALIGN (t));
   rli->unpacked_align = rli->record_align;
   rli->offset_align = MAX (rli->record_align, BIGGEST_ALIGNMENT);

@@ -952,15 +955,20 @@ update_alignment_for_field (record_layout_info rli
  meaningless.  */
   if (targetm.ms_bitfield_layout_p (rli->t))
 {
+  if (rli->t && TYPE_PACKED (rli->t)
+  && (is_bitfield || !DECL_PACKED (field)
+  || DECL_SIZE (field) == NULL_TREE
+  || !integer_zerop (DECL_SIZE (field
+desired_align = BITS_PER_UNIT;
   /* Here, the alignment of the underlying type of a bitfield can
 affect the alignment of a record; even a zero-sized field
 can do this.  The alignment should be to the alignment of
 the type, except that for zero-size bitfields this only
 applies if there was an immediately prior, nonzero-size
 bitfield.  (That's the way it is, experimentally.) */
-  if ((!is_bitfield && !DECL_PACKED (field))
- || ((DECL_SIZE (field) == NULL_TREE
-  || !integer_zerop (DECL_SIZE (field)))
+  else if ((!is_bitfield && !DECL_PACKED (field))
+  || ((DECL_SIZE (field) == NULL_TREE
+  || !integer_zerop (DECL_SIZE (field)))
  ? !DECL_PACKED (field)
  : (rli->prev_field
 && DECL_BIT_FIELD_TYPE (rli->prev_field)
@@ -1414,7 +1422,13 @@ place_field (record_layout_info rli, tree field)
}

  /* Now align (conventionally) for the new type.  */
- type_align = TYPE_ALIGN (TREE_TYPE (field));
+ if (!TYPE_PACKED (rli->t))
+   {
+ type_align = TYPE_ALIGN (TREE_TYPE (field));
+ if (DECL_PACKED (field))
+   type_align = MIN (type_align, BITS_PER_UNIT);
+   
+   }

  if (maximum_field_alignment != 0)
type_align = MIN (type_align, maximum_field_alignment);


Re: [PATCH, libgcc, ARM] __gnu_f2h_internal inaccuracy

2012-12-11 Thread John Tytgat
Ping ? Paul, seen that you've contributed fp16.c together with Sandra
Loosemore, perhaps you can review this patch please ?

John.

In message 
  John Tytgat  wrote:

> __gnu_f2h_internal in libgcc converts single-precision floating-point value
> to half-precision value for ARM.  I noticed there is a slight inaccuracy
> for floating-point values 2^-25 + epsilon (with epsilon > 0 and < 2^-26).
> Those should all be converted to 2^-24 in half-precision.
> 
> And this because the mask used to implement the even-odd rounding for
> aexp = -25 is wrong.  Currently we have:
> 
>   /* Decimal point between bits 22 and 23.  */
>   mantissa |= 0x0080;
>   if (aexp < -14)
> {
>   mask = 0x007f;
>   if (aexp < -25)
> aexp = -26;
>   else if (aexp != -25)
> mask >>= 24 + aexp;
> }
>   else
> mask = 0x1fff;
> 
> But when aexp is 25 the mask should be 0xff instead of 0x7f as the
> decimal dot in half-precision will be between bit 24 and 23 of the
> above mentioned mantissa.  Cfr. the even-odd rounding done:
> 
>   /* Round.  */
>   if (mantissa & mask)
> {
>   increment = (mask + 1) >> 1;
>   if ((mantissa & mask) == increment)
> increment = mantissa & (increment << 1);
>   mantissa += increment;
>   if (mantissa >= 0x0100)
> {
>   mantissa >>= 1;
>   aexp++;
> }
> }
> 
> Attached patch solves this problem.  I've left out the clamping of
> aexp to -26 for values less than -25 as this it not necessary.  After
> the even-odd rounding all aexp values less than -24 will result in +0. or
> -0. anyway.
> 
> John Tytgat  
> 
>   * config/arm/fp16.c (__gnu_f2h_internal): Fix inaccuracy.
> 
> I've got a copyright assignment but no write access.
> 
> John Tytgat.

-- 
John Tytgat BASS
j...@bass-software.comIndex: libgcc/config/arm/fp16.c
===
--- libgcc/config/arm/fp16.c(revision 193830)
+++ libgcc/config/arm/fp16.c(working copy)
@@ -47,11 +47,9 @@
   mantissa |= 0x0080;
   if (aexp < -14)
 {
-  mask = 0x007f;
-  if (aexp < -25)
-   aexp = -26;
-  else if (aexp != -25)
-   mask >>= 24 + aexp;
+  mask = 0x00ff;
+  if (aexp >= -25)
+mask >>= 25 + aexp;
 }
   else
 mask = 0x1fff;



[patch] fix libstdc++/55631

2012-12-11 Thread Jonathan Wakely
PR libstdc++/55631
* include/ext/alloc_traits.h: Include missing header.
* include/ext/pointer.h: Likewise.
* include/ext/string_conversions.h: Require C++11.
* libsupc++/initializer_list: Reindent.

Tested x86_64-linux, committed to trunk.
commit 4e4d3c624f02150044702ff9bff695c2c168308f
Author: Jonathan Wakely 
Date:   Tue Dec 11 19:29:27 2012 +

PR libstdc++/55631
* include/ext/alloc_traits.h: Include missing header.
* include/ext/pointer.h: Likewise.
* include/ext/string_conversions.h: Require C++11.
* libsupc++/initializer_list: Reindent.

diff --git a/libstdc++-v3/include/ext/alloc_traits.h 
b/libstdc++-v3/include/ext/alloc_traits.h
index a0834c3..b46b0fc 100644
--- a/libstdc++-v3/include/ext/alloc_traits.h
+++ b/libstdc++-v3/include/ext/alloc_traits.h
@@ -32,6 +32,7 @@
 #pragma GCC system_header
 
 #if __cplusplus >= 201103L
+# include 
 # include 
 #else
 # include   // for __alloc_swap
diff --git a/libstdc++-v3/include/ext/pointer.h 
b/libstdc++-v3/include/ext/pointer.h
index 5592a77..b3c8687 100644
--- a/libstdc++-v3/include/ext/pointer.h
+++ b/libstdc++-v3/include/ext/pointer.h
@@ -43,6 +43,7 @@
 #include 
 #include 
 #if __cplusplus >= 201103L
+# include 
 # include 
 #endif
 
diff --git a/libstdc++-v3/include/ext/string_conversions.h 
b/libstdc++-v3/include/ext/string_conversions.h
index f85ab99..7df905f 100644
--- a/libstdc++-v3/include/ext/string_conversions.h
+++ b/libstdc++-v3/include/ext/string_conversions.h
@@ -31,6 +31,10 @@
 
 #pragma GCC system_header
 
+#if __cplusplus < 201103L
+# include 
+#else
+
 #include 
 #include 
 #include 
@@ -98,4 +102,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
+#endif // C++11
+
 #endif // _STRING_CONVERSIONS_H
diff --git a/libstdc++-v3/libsupc++/initializer_list 
b/libstdc++-v3/libsupc++/initializer_list
index 5e2a78b..89add48 100644
--- a/libstdc++-v3/libsupc++/initializer_list
+++ b/libstdc++-v3/libsupc++/initializer_list
@@ -77,7 +77,7 @@ namespace std
   // One past the last element.
   constexpr const_iterator
   end() const noexcept { return begin() + size(); }
-  };
+};
 
   /**
*  @brief  Return an iterator pointing to the first element of


C++ PATCH for c++/54883 (link conflict with enum in anon namespace)

2012-12-11 Thread Jason Merrill

Enums in anonymous namespace should get anon visibility just like classes.

Tested x86_64-pc-linux-gnu, applying to 4.6, 4.7 and trunk.
commit ebb0d2ecbf7717afcb45f52ab7d7a0d68ae2157b
Author: Jason Merrill 
Date:   Tue Dec 11 16:34:24 2012 -0500

	PR c++/54883
	* decl2.c (min_vis_r): Handle anon visibility for enums.

diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index fd54cac..c5de37e 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1926,16 +1926,15 @@ min_vis_r (tree *tp, int *walk_subtrees, void *data)
 {
   *walk_subtrees = 0;
 }
-  else if (CLASS_TYPE_P (*tp))
+  else if (TAGGED_TYPE_P (*tp)
+	   && !TREE_PUBLIC (TYPE_MAIN_DECL (*tp)))
 {
-  if (!TREE_PUBLIC (TYPE_MAIN_DECL (*tp)))
-	{
-	  *vis_p = VISIBILITY_ANON;
-	  return *tp;
-	}
-  else if (CLASSTYPE_VISIBILITY (*tp) > *vis_p)
-	*vis_p = CLASSTYPE_VISIBILITY (*tp);
+  *vis_p = VISIBILITY_ANON;
+  return *tp;
 }
+  else if (CLASS_TYPE_P (*tp)
+	   && CLASSTYPE_VISIBILITY (*tp) > *vis_p)
+*vis_p = CLASSTYPE_VISIBILITY (*tp);
   return NULL;
 }
 
diff --git a/gcc/testsuite/g++.dg/abi/anon1.C b/gcc/testsuite/g++.dg/abi/anon1.C
new file mode 100644
index 000..c45917a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/anon1.C
@@ -0,0 +1,5 @@
+// PR c++/54883
+
+namespace { enum E { E1 }; } void f(E e) { }
+
+// { dg-final { scan-assembler-not "globl" } }


[cxx-conversion] Convert tree-sra.c'candidates to hash_table

2012-12-11 Thread Lawrence Crowl
Convert tree-sra.c'candidates from htab_t to hash_table.

Fold uid_decl_map_hash and uid_decl_map_eq into new struct
uid_decl_hasher.  This change moves the definitions from tree-ssa.c
into tree-sra.c and removes the declarations from tree-flow.h

Update dependent calls and types to hash_table.

Tested on x86_64.

Okay for branch?


Index: gcc/tree-sra.c
===
--- gcc/tree-sra.c  (revision 194381)
+++ gcc/tree-sra.c  (working copy)
@@ -74,6 +74,7 @@ along with GCC; see the file COPYING3.
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
+#include "hash-table.h"
 #include "alloc-pool.h"
 #include "tm.h"
 #include "tree.h"
@@ -269,18 +270,44 @@ static alloc_pool link_pool;
 /* Base (tree) -> Vector (vec *) map.  */
 static struct pointer_map_t *base_access_vec;

+/* Candidate ashtable helpers.  */
+
+struct uid_decl_hasher : typed_noop_remove 
+{
+  typedef tree_node value_type;
+  typedef tree_node compare_type;
+  static inline hashval_t hash (const value_type *);
+  static inline bool equal (const value_type *, const compare_type *);
+};
+
+/* Hash a tree in a uid_decl_map.  */
+
+inline hashval_t
+uid_decl_hasher::hash (const value_type *item)
+{
+  return item->decl_minimal.uid;
+}
+
+/* Return true if the DECL_UID in both trees are equal.  */
+
+inline bool
+uid_decl_hasher::equal (const value_type *a, const compare_type *b)
+{
+  return (a->decl_minimal.uid == b->decl_minimal.uid);
+}
+
 /* Set of candidates.  */
 static bitmap candidate_bitmap;
-static htab_t candidates;
+static hash_table  candidates;

 /* For a candidate UID return the candidates decl.  */

 static inline tree
 candidate (unsigned uid)
 {
- struct tree_decl_minimal t;
- t.uid = uid;
- return (tree) htab_find_with_hash (candidates, &t, uid);
+ tree_node t;
+ t.decl_minimal.uid = uid;
+ return candidates.find_with_hash (&t, static_cast  (uid));
 }

 /* Bitmap of candidates which we should try to entirely scalarize away and
@@ -611,8 +638,7 @@ static void
 sra_initialize (void)
 {
   candidate_bitmap = BITMAP_ALLOC (NULL);
-  candidates = htab_create (vec_safe_length (cfun->local_decls) / 2,
-   uid_decl_map_hash, uid_decl_map_eq, NULL);
+  candidates.create (vec_safe_length (cfun->local_decls) / 2);
   should_scalarize_away_bitmap = BITMAP_ALLOC (NULL);
   cannot_scalarize_away_bitmap = BITMAP_ALLOC (NULL);
   gcc_obstack_init (&name_obstack);
@@ -642,7 +668,7 @@ static void
 sra_deinitialize (void)
 {
   BITMAP_FREE (candidate_bitmap);
-  htab_delete (candidates);
+  candidates.dispose ();
   BITMAP_FREE (should_scalarize_away_bitmap);
   BITMAP_FREE (cannot_scalarize_away_bitmap);
   free_alloc_pool (access_pool);
@@ -659,9 +685,9 @@ static void
 disqualify_candidate (tree decl, const char *reason)
 {
   if (bitmap_clear_bit (candidate_bitmap, DECL_UID (decl)))
-htab_clear_slot (candidates,
-htab_find_slot_with_hash (candidates, decl,
-  DECL_UID (decl), NO_INSERT));
+candidates.clear_slot (candidates.find_slot_with_hash (decl,
+  DECL_UID (decl),
+  NO_INSERT));

   if (dump_file && (dump_flags & TDF_DETAILS))
 {
@@ -1687,7 +1713,7 @@ maybe_add_sra_candidate (tree var)
 {
   tree type = TREE_TYPE (var);
   const char *msg;
-  void **slot;
+  tree_node **slot;

   if (!AGGREGATE_TYPE_P (type))
 {
@@ -1735,8 +1761,8 @@ maybe_add_sra_candidate (tree var)
 }

   bitmap_set_bit (candidate_bitmap, DECL_UID (var));
-  slot = htab_find_slot_with_hash (candidates, var, DECL_UID (var), INSERT);
-  *slot = (void *) var;
+  slot = candidates.find_slot_with_hash (var, DECL_UID (var), INSERT);
+  *slot = var;

   if (dump_file && (dump_flags & TDF_DETAILS))
 {
@@ -3589,7 +3615,7 @@ find_param_candidates (void)
parm = DECL_CHAIN (parm))
 {
   tree type = TREE_TYPE (parm);
-  void **slot;
+  tree_node **slot;

   count++;

@@ -3628,9 +3654,8 @@ find_param_candidates (void)
continue;

   bitmap_set_bit (candidate_bitmap, DECL_UID (parm));
-  slot = htab_find_slot_with_hash (candidates, parm,
-  DECL_UID (parm), INSERT);
-  *slot = (void *) parm;
+  slot = candidates.find_slot_with_hash (parm, DECL_UID (parm), INSERT);
+  *slot = parm;

   ret = true;
   if (dump_file && (dump_flags & TDF_DETAILS))
Index: gcc/tree-ssa.c
===
--- gcc/tree-ssa.c  (revision 194381)
+++ gcc/tree-ssa.c  (working copy)
@@ -1052,24 +1052,6 @@ err:

 /* Return true if the DECL_UID in both trees are equal.  */

-int
-uid_decl_map_eq (const void *va, const void *vb)
-{
-  const_tree a = (const_tree) va;
-  const_tree b = (const_tree) vb;
-  return (a->decl_minimal.uid == b->decl_minimal.uid);
-}
-
-/* H

Re: [Patch, ARM] Fix the check on arg reg number in function thumb_find_work_register

2012-12-11 Thread Ramana Radhakrishnan
On Wed, Nov 28, 2012 at 5:53 AM, Terry Guo  wrote:
> Hello,
>
> Attached patch intends to fix a bug on how to check argument register number
> which should consider the PCS. A test case is also included. Without this
> fix, one of the function argument will be overridden in the case. Tested on
> QEMU for cortex-m3, no regression found. Is it OK to trunk?


OK and for release branches after a suitable amount of time on trunk
and if no RM objects.

Ramana
>
> BR,
> Terry
>
> gcc/ChangeLog:
>
> 2012-11-28  Terry Guo  
>
> * config/arm/arm.c (thumb_find_work_register): Check
> argument register number based on current PCS.
>
> gcc/testsuite/ChangeLog:
>
> 2012-11-28  Terry Guo  
>
> * gcc.target/arm/thumb-find-work-register.c: New.


[cxx-conversion] Convert various htab_t tables to hash_table

2012-12-11 Thread Lawrence Crowl
Update various htab_t tables to hash_table.  Each file is independent.
Update dependent calls and types.

* tree-ssa-strlen.c'decl_to_stridxlist_htab

Fold decl_to_stridxlist_hash into new struct stridxlist_hasher.

* tree-ssa-loop-ivopts.c'ivopts_data::inv_expr_tab

Fold htab_inv_expr_hash and htab_inv_expr_eq into new struct
iv_inv_expr_hasher.

* tree-ssa-uncprop.c'equiv

Equiv renamed to val_ssa_equiv because of name ambiguity with local variables.

Fold equiv_hash, equiv_eq and equiv_free into new struct val_ssa_equiv_hasher.

Renamed variables equiv_hash_elt to an_equiv_elt because of name ambiguity
with struct type.  Changed equiv_hash_elt_p to an_equiv_elt_p to match.

* tree-ssa-phiopt.c'seen_ssa_names

Fold name_to_bb_hash and name_to_bb_eq into new struct ssa_names_hasher.

* tree-ssa-structalias.c'pointer_equiv_class_table
* tree-ssa-structalias.c'location_equiv_class_table

Fold equiv_class_label_hash and equiv_class_label_eq into new
struct equiv_class_hasher.

* tree-ssa-structalias.c'shared_bitmap_table

Fold shared_bitmap_hash and shared_bitmap_eq into new struct
shared_bitmap_hasher.

* tree-ssa-live.c'var_map_base_init::tree_to_index

New struct tree_int_map_hasher.

* tree-ssa-reassoc.c'undistribute_ops_list::ctable

Fold oecount_hash and oecount_eq into new struct oecount_hasher.

* tree-ssa-loop-im.c'memory_accesses.refs

Fold memref_hash and memref_eq into new struct mem_ref_hasher.

Tested on x86_64.

Okay for branch?


Index: gcc/tree-ssa-phiopt.c
===
--- gcc/tree-ssa-phiopt.c   (revision 194381)
+++ gcc/tree-ssa-phiopt.c   (working copy)
@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
+#include "hash-table.h"
 #include "tm.h"
 #include "ggc.h"
 #include "tree.h"
@@ -1239,34 +1240,42 @@ struct name_to_bb
   basic_block bb;
 };

-/* The hash table for remembering what we've seen.  */
-static htab_t seen_ssa_names;
+/* Hashtable helpers.  */

-/* The set of MEM_REFs which can't trap.  */
-static struct pointer_set_t *nontrap_set;
+struct ssa_names_hasher : typed_free_remove 
+{
+  typedef name_to_bb value_type;
+  typedef name_to_bb compare_type;
+  static inline hashval_t hash (const value_type *);
+  static inline bool equal (const value_type *, const compare_type *);
+};

 /* The hash function.  */
-static hashval_t
-name_to_bb_hash (const void *p)
+
+inline hashval_t
+ssa_names_hasher::hash (const value_type *n)
 {
-  const struct name_to_bb *n = (const struct name_to_bb *) p;
   return n->ssa_name_ver ^ (((hashval_t) n->store) << 31)
  ^ (n->offset << 6) ^ (n->size << 3);
 }

 /* The equality function of *P1 and *P2.  */
-static int
-name_to_bb_eq (const void *p1, const void *p2)
-{
-  const struct name_to_bb *n1 = (const struct name_to_bb *)p1;
-  const struct name_to_bb *n2 = (const struct name_to_bb *)p2;

+inline bool
+ssa_names_hasher::equal (const value_type *n1, const compare_type *n2)
+{
   return n1->ssa_name_ver == n2->ssa_name_ver
  && n1->store == n2->store
  && n1->offset == n2->offset
  && n1->size == n2->size;
 }

+/* The hash table for remembering what we've seen.  */
+static hash_table  seen_ssa_names;
+
+/* The set of MEM_REFs which can't trap.  */
+static struct pointer_set_t *nontrap_set;
+
 /* We see the expression EXP in basic block BB.  If it's an interesting
expression (an MEM_REF through an SSA_NAME) possibly insert the
expression into the set NONTRAP or the hash table of seen expressions.
@@ -1285,7 +1294,7 @@ add_or_mark_expr (basic_block bb, tree e
 {
   tree name = TREE_OPERAND (exp, 0);
   struct name_to_bb map;
-  void **slot;
+  name_to_bb **slot;
   struct name_to_bb *n2bb;
   basic_block found_bb = 0;

@@ -1297,8 +1306,8 @@ add_or_mark_expr (basic_block bb, tree e
   map.offset = tree_low_cst (TREE_OPERAND (exp, 1), 0);
   map.size = size;

-  slot = htab_find_slot (seen_ssa_names, &map, INSERT);
-  n2bb = (struct name_to_bb *) *slot;
+  slot = seen_ssa_names.find_slot (&map, INSERT);
+  n2bb = *slot;
   if (n2bb)
 found_bb = n2bb->bb;

@@ -1370,8 +1379,7 @@ get_non_trapping (void)
   struct dom_walk_data walk_data;

   nontrap = pointer_set_create ();
-  seen_ssa_names = htab_create (128, name_to_bb_hash, name_to_bb_eq,
-   free);
+  seen_ssa_names.create (128);
   /* We're going to do a dominator walk, so ensure that we have
  dominance information.  */
   calculate_dominance_info (CDI_DOMINATORS);
@@ -1388,7 +1396,7 @@ get_non_trapping (void)
   init_walk_dominator_tree (&walk_data);
   walk_dominator_tree (&walk_data, ENTRY_BLOCK_PTR);
   fini_walk_dominator_tree (&walk_data);
-  htab_delete (seen_ssa_names);
+  seen_ssa_names.dispose ();

   return nontrap;
 }
Index: gcc/tree-ssa-reassoc.c
===
--- gc

[cxx-conversion] Convert tree-vectorizer.h'_loop_vec_info::peeling_htab to hash_table

2012-12-11 Thread Lawrence Crowl
Convert tree-vectorizer.h'_loop_vec_info::peeling_htab from htab_t
to hash_table.

* tree-vectorizer.h

New struct peel_info_hasher.

* tree-vect-loop.c

Update dependent calls and types to match.

* tree-vect-data-refs.c

Fold vect_peeling_hash and vect_peeling_hash_eq into struct peel_info_hasher.

Update dependent calls and types to match.

Tested on x86_64.

Okay for branch?


Index: gcc/tree-vectorizer.h
===
--- gcc/tree-vectorizer.h   (revision 194381)
+++ gcc/tree-vectorizer.h   (working copy)
@@ -192,6 +192,30 @@ typedef struct _vect_peel_extended_info
   stmt_vector_for_cost body_cost_vec;
 } *vect_peel_extended_info;

+
+/* Peeling hashtable helpers.  */
+
+struct peel_info_hasher : typed_free_remove <_vect_peel_info>
+{
+  typedef _vect_peel_info value_type;
+  typedef _vect_peel_info compare_type;
+  static inline hashval_t hash (const value_type *);
+  static inline bool equal (const value_type *, const compare_type *);
+};
+
+inline hashval_t
+peel_info_hasher::hash (const value_type *peel_info)
+{
+  return (hashval_t) peel_info->npeel;
+}
+
+inline bool
+peel_info_hasher::equal (const value_type *a, const compare_type *b)
+{
+  return (a->npeel == b->npeel);
+}
+
+
 /*-*/
 /* Info on vectorized loops.   */
 /*-*/
@@ -276,7 +300,7 @@ typedef struct _loop_vec_info {
   vec reduction_chains;

   /* Hash table used to choose the best peeling option.  */
-  htab_t peeling_htab;
+  hash_table  peeling_htab;

   /* Cost data used by the target cost model.  */
   void *target_cost_data;
Index: gcc/tree-vect-loop.c
===
--- gcc/tree-vect-loop.c(revision 194381)
+++ gcc/tree-vect-loop.c(working copy)
@@ -874,7 +874,6 @@ new_loop_vec_info (struct loop *loop)
   LOOP_VINFO_REDUCTION_CHAINS (res).create (10);
   LOOP_VINFO_SLP_INSTANCES (res).create (10);
   LOOP_VINFO_SLP_UNROLLING_FACTOR (res) = 1;
-  LOOP_VINFO_PEELING_HTAB (res) = NULL;
   LOOP_VINFO_TARGET_COST_DATA (res) = init_cost (loop);
   LOOP_VINFO_PEELING_FOR_GAPS (res) = false;
   LOOP_VINFO_OPERANDS_SWAPPED (res) = false;
@@ -969,8 +968,8 @@ destroy_loop_vec_info (loop_vec_info loo
   LOOP_VINFO_REDUCTIONS (loop_vinfo).release ();
   LOOP_VINFO_REDUCTION_CHAINS (loop_vinfo).release ();

-  if (LOOP_VINFO_PEELING_HTAB (loop_vinfo))
-htab_delete (LOOP_VINFO_PEELING_HTAB (loop_vinfo));
+  if (LOOP_VINFO_PEELING_HTAB (loop_vinfo).is_created ())
+LOOP_VINFO_PEELING_HTAB (loop_vinfo).dispose ();

   destroy_cost_data (LOOP_VINFO_TARGET_COST_DATA (loop_vinfo));

Index: gcc/Makefile.in
===
--- gcc/Makefile.in (revision 194381)
+++ gcc/Makefile.in (working copy)
@@ -967,7 +967,8 @@ GIMPLE_STREAMER_H = gimple-streamer.h $(
 TREE_STREAMER_H = tree-streamer.h $(TREE_H) $(LTO_STREAMER_H) \
  $(STREAMER_HOOKS_H)
 STREAMER_HOOKS_H = streamer-hooks.h $(TREE_H)
-TREE_VECTORIZER_H = tree-vectorizer.h $(TREE_DATA_REF_H) $(TARGET_H)
+TREE_VECTORIZER_H = tree-vectorizer.h $(TREE_DATA_REF_H) $(TARGET_H) \
+   $(HASH_TABLE_H)
 IPA_PROP_H = ipa-prop.h $(TREE_H) $(VEC_H) $(CGRAPH_H) $(GIMPLE_H) alloc-pool.h
 IPA_INLINE_H = ipa-inline.h $(IPA_PROP_H)
 GSTAB_H = gstab.h stab.def
Index: gcc/tree-vect-data-refs.c
===
--- gcc/tree-vect-data-refs.c   (revision 194381)
+++ gcc/tree-vect-data-refs.c   (working copy)
@@ -1275,27 +1275,6 @@ vect_get_data_access_cost (struct data_r
 }


-static hashval_t
-vect_peeling_hash (const void *elem)
-{
-  const struct _vect_peel_info *peel_info;
-
-  peel_info = (const struct _vect_peel_info *) elem;
-  return (hashval_t) peel_info->npeel;
-}
-
-
-static int
-vect_peeling_hash_eq (const void *elem1, const void *elem2)
-{
-  const struct _vect_peel_info *a, *b;
-
-  a = (const struct _vect_peel_info *) elem1;
-  b = (const struct _vect_peel_info *) elem2;
-  return (a->npeel == b->npeel);
-}
-
-
 /* Insert DR into peeling hash table with NPEEL as key.  */

 static void
@@ -1303,12 +1282,11 @@ vect_peeling_hash_insert (loop_vec_info
   int npeel)
 {
   struct _vect_peel_info elem, *slot;
-  void **new_slot;
+  _vect_peel_info **new_slot;
   bool supportable_dr_alignment = vect_supportable_dr_alignment (dr, true);

   elem.npeel = npeel;
-  slot = (vect_peel_info) htab_find (LOOP_VINFO_PEELING_HTAB (loop_vinfo),
- &elem);
+  slot = LOOP_VINFO_PEELING_HTAB (loop_vinfo).find (&elem);
   if (slot)
 slot->count++;
   else
@@ -1317,8 +1295,7 @@ vect_peeling_hash_insert (loop_vec_info
   slot->npeel = npeel;
   slot->dr = dr;
   slot->count = 1;
-  new_slot = htab_find_slot (LOOP_VINFO_PEELIN

Re: [PATCH i386]: Enable push/pop in pro/epilogue for modern CPUs

2012-12-11 Thread Xinliang David Li
The following the O2 size data from SPEC2k.  Note that with push/pop,
it is a always a net win (negative delta) in terms of total binary or
total loadable section size.

thanks,

David

   .text.eh_frame  Total_binary
vortex-move 440252 40796 584066
vortex-push 415436 57452 575906
delta-5.6% 40.8%  -1.397%

twolf-move 169324 10748 223521
twolf-push 168876 11124 223449
delta   -0.3% 3.5% -0.032%

gzip-move 30668 3652 374399
gzip-push 30524 3740 374343
delta -0.5% 2.4% -0.015%

bzip2-move 22748 3196 111616
bzip2-push 22636 3284 111592
delta  -0.5% 2.8% -0.022%

vpr-move 104684 9380 147378
vpr-push 104236 9788 147338
delta -0.4% 4.3% -0.027%

mcf-move 8444 1244 26760
mcf-push 8444 1244 26760
delta0.0% 0.0% 0.000%

cc1-move 1093964 90772 1576994
cc1-push 1078988 104068 1575314
delta  -1.4% 14.6% -0.107%

crafty-move 130556 5508 1256037
crafty-push 130236 5772 1255981
delta-0.2% 4.8% -0.004%

eon-move 333660 33220 516491
eon-push 330140 35812 51
delta -1.1% 7.8% -0.181%

gap-move 404092 46732 1457735
gap-push 396012 53180 1456103
delta -2.0% 13.8% -0.112%

perlbmk-move 456572 45324 618585
perlbmk-push 449516 52340 618545
delta -1.5% 15.5% -0.006%

parser-move 81244 15788 334003
parser-push 80684 16332 333987
delta   -0.7% 3.4% -0.005%


On Tue, Dec 11, 2012 at 9:14 AM, Xinliang David Li  wrote:
> On Tue, Dec 11, 2012 at 1:49 AM, Richard Biener
>  wrote:
>> On Mon, Dec 10, 2012 at 10:07 PM, Mike Stump  wrote:
>>> On Dec 10, 2012, at 12:42 PM, Xinliang David Li  wrote:
 I have not measured the CFI size impact -- but conceivably it should
 be larger -- which is unfortunate.
>>>
>>> Code speed and size are preferable to optimizing dwarf size…  :-)  I'd let 
>>> dwarf 5 fix it!
>>
>> Well, different to debug info, CFI data has to be in memory to make
>> unwinding work.
>> These days most Linux distributions enable asyncronous unwind tables so any
>> size savings due to shorter push/pop epilogue/prologue sequences has to be
>> offsetted by the increase in CFI data.  I'm not sure there is really a
>> speed difference
>> between both variants (well, maybe due to better icache footprint of
>> the push/pop
>> variant).
>
> Yes, for large applications, this can be crucial to performance.
>
>>
>> That said - I'd prefer to have more data on this before making the switch for
>> the generic model.  What was your original motivation?  Just "theory" or was
>> it a real case?
>
> 1) some of the very large internal apps I measured benefit from this
> change (in terms of performance)
> 2) both ICC and LLVM do the same.
>
> I have already committed the patch. I will find some time to collect
> more size data and post it later.
>
> thanks,
>
> David
>
>
>>
>> Thanks,
>> Richard.


Re: [PATCH i386]: Enable push/pop in pro/epilogue for modern CPUs

2012-12-11 Thread Xinliang David Li
Some SPEC2k performance number (with 3 runs on core2):

Push wins over move on 3 benchmarks. Others are noises.

perlbmk : ~+1.9%
gap:   ~+1.4%
vortex:~ +0.7%

David

On Tue, Dec 11, 2012 at 2:53 PM, Xinliang David Li  wrote:
> The following the O2 size data from SPEC2k.  Note that with push/pop,
> it is a always a net win (negative delta) in terms of total binary or
> total loadable section size.
>
> thanks,
>
> David
>
>.text.eh_frame  Total_binary
> vortex-move 440252 40796 584066
> vortex-push 415436 57452 575906
> delta-5.6% 40.8%  -1.397%
>
> twolf-move 169324 10748 223521
> twolf-push 168876 11124 223449
> delta   -0.3% 3.5% -0.032%
>
> gzip-move 30668 3652 374399
> gzip-push 30524 3740 374343
> delta -0.5% 2.4% -0.015%
>
> bzip2-move 22748 3196 111616
> bzip2-push 22636 3284 111592
> delta  -0.5% 2.8% -0.022%
>
> vpr-move 104684 9380 147378
> vpr-push 104236 9788 147338
> delta -0.4% 4.3% -0.027%
>
> mcf-move 8444 1244 26760
> mcf-push 8444 1244 26760
> delta0.0% 0.0% 0.000%
>
> cc1-move 1093964 90772 1576994
> cc1-push 1078988 104068 1575314
> delta  -1.4% 14.6% -0.107%
>
> crafty-move 130556 5508 1256037
> crafty-push 130236 5772 1255981
> delta-0.2% 4.8% -0.004%
>
> eon-move 333660 33220 516491
> eon-push 330140 35812 51
> delta -1.1% 7.8% -0.181%
>
> gap-move 404092 46732 1457735
> gap-push 396012 53180 1456103
> delta -2.0% 13.8% -0.112%
>
> perlbmk-move 456572 45324 618585
> perlbmk-push 449516 52340 618545
> delta -1.5% 15.5% -0.006%
>
> parser-move 81244 15788 334003
> parser-push 80684 16332 333987
> delta   -0.7% 3.4% -0.005%
>
>
> On Tue, Dec 11, 2012 at 9:14 AM, Xinliang David Li  wrote:
>> On Tue, Dec 11, 2012 at 1:49 AM, Richard Biener
>>  wrote:
>>> On Mon, Dec 10, 2012 at 10:07 PM, Mike Stump  wrote:
 On Dec 10, 2012, at 12:42 PM, Xinliang David Li  wrote:
> I have not measured the CFI size impact -- but conceivably it should
> be larger -- which is unfortunate.

 Code speed and size are preferable to optimizing dwarf size…  :-)  I'd let 
 dwarf 5 fix it!
>>>
>>> Well, different to debug info, CFI data has to be in memory to make
>>> unwinding work.
>>> These days most Linux distributions enable asyncronous unwind tables so any
>>> size savings due to shorter push/pop epilogue/prologue sequences has to be
>>> offsetted by the increase in CFI data.  I'm not sure there is really a
>>> speed difference
>>> between both variants (well, maybe due to better icache footprint of
>>> the push/pop
>>> variant).
>>
>> Yes, for large applications, this can be crucial to performance.
>>
>>>
>>> That said - I'd prefer to have more data on this before making the switch 
>>> for
>>> the generic model.  What was your original motivation?  Just "theory" or was
>>> it a real case?
>>
>> 1) some of the very large internal apps I measured benefit from this
>> change (in terms of performance)
>> 2) both ICC and LLVM do the same.
>>
>> I have already committed the patch. I will find some time to collect
>> more size data and post it later.
>>
>> thanks,
>>
>> David
>>
>>
>>>
>>> Thanks,
>>> Richard.


Re: [patch, mips] Follow up to pr54061 patch, fix another abort.

2012-12-11 Thread Steve Ellcey
On Tue, 2012-12-11 at 21:52 +, Richard Sandiford wrote:

> > +  mips_dbx_regno[CPRESTORE_SLOT_REGNUM] = IGNORED_DWARF_REGNUM;


> If even fake registers like these are going to be used, then I think
> we should initialise to IGNORED_DWARF_REGNUM rather than INVALID_REGNUM in:
> 
>   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
> {
>   mips_dbx_regno[i] = INVALID_REGNUM;
>   ...
> }
> 
> and remove the ALL_COP_REG loop that was in the earlier patch.
> 
> Richard

So far, this is the only fake register that I have seen show up while
building GCC, glibc, newlib, binutils, etc.  I am not sure if we want to
set all fake registers to IGNORED because of this one case.  If more
popped up then I could see us making that change.

Steve Ellcey
sell...@mips.com



Re: PATCH: pass sysroot to cc1plus

2012-12-11 Thread Etienne Le Sueur

Hi Richard,

Thanks for your reply.

The sysroot of /dev/null is basically to force the user or build system to pass a valid --sysroot argument. This helps us to ensure that we only 
link against known libraries (that are in a specific location) and there isn't any leakage from the host system.


I'm not sure if we're using sysroot the way it was intended, but it is 
certainly helping us to maintain some sanity in our build.

It seems to me like the sysroot that the user passes in as an argument to gcc 
should definitely be forwarded to cc1plus.

Etienne


On 4/12/12 1:21 AM, Richard Biener wrote:

On Mon, Dec 3, 2012 at 9:03 PM, Etienne Le Sueur  wrote:

First ping... anyone?

A sysroot of /dev/null does not sound like something that we should support.
If we do the semantics of this setting should be documented somewhere.

Richard.


On 28/11/12 1:21 PM, Etienne Le Sueur wrote:

Hi,

With a sysroot of /dev/null, passing a .i file to cc1plus causes it to
attempt to open /dev/null/usr/include, which fails. This causes problems for
ccache and distcc. There is an open bugzilla ticket at [1].

The patch below applies on to 4.6.3, but it appears the bug is still
present in 4.7.2.

If this is not the correct way to solve this problem, please suggest a
better approach.

Regards,
Etienne Le Sueur

[1] http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54560


diff --git a/gcc-4.6.3/gcc/cp/lang-specs.h b/gcc-4.6.3/gcc/cp/lang-specs.h
index a73aba3..873609a 100644
--- a/gcc-4.6.3/gcc/cp/lang-specs.h
+++ b/gcc-4.6.3/gcc/cp/lang-specs.h
@@ -64,5 +64,5 @@ along with GCC; see the file COPYING3.  If not see
{".ii", "@c++-cpp-output", 0, 0, 0},
{"@c++-cpp-output",
 "%{!M:%{!MM:%{!E:\
-cc1plus -fpreprocessed %i %(cc1_options) %2\
+cc1plus -fpreprocessed %i %I %(cc1_options) %2\
  %{!fsyntax-only:%(invoke_as)", 0, 0, 0},
diff --git a/gcc-4.6.3/gcc/gcc.c b/gcc-4.6.3/gcc/gcc.c
index 75f522e..214ef29 100644
--- a/gcc-4.6.3/gcc/gcc.c
+++ b/gcc-4.6.3/gcc/gcc.c
@@ -950,7 +950,7 @@ static const struct compiler default_compilers[] =
  %W{o*:--output-pch=%*}}%V}}", 0, 0, 0},
{".i", "@cpp-output", 0, 0, 0},
{"@cpp-output",
-   "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options)
%{!fsyntax-only:%(invoke_as)", 0, 0, 0},
+   "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %I %(cc1_options)
%{!fsyntax-only:%(invoke_as)", 0, 0, 0},
{".s", "@assembler", 0, 0, 0},
{"@assembler",
 "%{!M:%{!MM:%{!E:%{!S:as %(asm_debug) %(asm_options) %i %A ", 0,
0, 0},





Re: [PATCH, libbacktrace] Find executable on ia64 and 64-bit hppa hpux

2012-12-11 Thread Ian Lance Taylor
On Sun, Dec 9, 2012 at 11:57 AM, John David Anglin
 wrote:
>
>  #ifndef HAVE_GETEXECNAME
> +#if defined(__hpux) && (defined(__ia64) || defined(_LP64))
> +#include 
> +#define getexecname getexecname_hpux
> +
> +static char *
> +getexecname_hpux (void)
> +{
> +  struct load_module_desc desc;
> +
> +  dlget(-2, &desc, sizeof(desc));
> +  return dlgetname(&desc, sizeof(desc), NULL, 0, 0);
> +}
> +

This is the kind of thing that is normally done via configure tests
rather than #ifdef tests.  And once the configure tests are written, I
would prefer to see this as another pass in fileline.c, rather than
this rather complex reuse of getexecname.

Ian


Re: [PATCH, libbacktrace] Fix build on hpux10

2012-12-11 Thread Ian Lance Taylor
On Sun, Dec 9, 2012 at 10:49 AM, John David Anglin
 wrote:
>
> 2012-12-09  John David Anglin  
>
> * mmapio.c: Define MAP_FAILED if not defined.

This is OK.

Thanks.

Ian


Re: [Fortran, (RFC) patch] PR49110/51055 Assignment to alloc. deferred-length character vars

2012-12-11 Thread David Edelsohn
On Tue, Dec 11, 2012 at 1:37 PM, Jakub Jelinek  wrote:

> So, what about this version instead?
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
>
> 2012-12-11  Jakub Jelinek  
> Janus Weil  
>
> PR fortran/55636
> * gfortran.h (GFC_PREFIX): Define.
> * trans-decl.c (gfc_create_string_length): For VAR_DECLs that
> will be TREE_STATIC, use GFC_PREFIX to mangle the names.
>
> --- gcc/fortran/gfortran.h.jj   2012-12-04 14:17:30.574177056 +0100
> +++ gcc/fortran/gfortran.h  2012-12-11 15:48:37.96747 +0100
> @@ -63,6 +63,15 @@ along with GCC; see the file COPYING3.
>  #define PREFIX(x) "_gfortran_" x
>  #define PREFIX_LEN 10
>
> +/* A prefix for internal variables, which are not user-visible.  */
> +#if !defined (NO_DOT_IN_LABEL)
> +# define GFC_PREFIX(x) "_F." x
> +#elif !defined (NO_DOLLAR_IN_LABEL)
> +# define GFC_PREFIX(x) "_F$" x
> +#else
> +# define GFC_PREFIX(x) "_F_" x
> +#endif
> +
>  #define BLANK_COMMON_NAME "__BLNK__"
>
>  /* Macro to initialize an mstring structure.  */
> --- gcc/fortran/trans-decl.c.jj 2012-12-11 09:25:18.757189184 +0100
> +++ gcc/fortran/trans-decl.c2012-12-11 15:50:13.487857146 +0100
> @@ -1090,7 +1090,15 @@ gfc_create_string_length (gfc_symbol * s
>const char *name;
>
>/* Also prefix the mangled name.  */
> -  if (sym->module)
> +  if (sym->attr.save || sym->ns->proc_name->attr.flavor == FL_MODULE)
> +   {
> + if (sym->module)
> +   name = gfc_get_string (GFC_PREFIX ("%s_MOD_%s"), sym->module,
> +  sym->name);
> + else
> +   name = gfc_get_string (GFC_PREFIX ("%s"), sym->name);
> +   }
> +  else if (sym->module)
> name = gfc_get_string (".__%s_MOD_%s", sym->module, sym->name);
>else
> name = gfc_get_string (".%s", sym->name);

Why are you only correcting the prefix for attr.save or FL_MODULE?
Why leave the dot name in the other cases?

Thanks, David


[Patch] Ignore Invalid Memory operands in constraint 'X'

2012-12-11 Thread Hurugalawadi, Naveen
Hi,

The definition of constraint 'X' allows all operands.
`X' - Any operand whatsoever is allowed.
However, invalid memory operands should not be valid input for 'X'.

Please find attached the patch "X_constraint.patch" which ignores 
invalid memory operands in constraint 'X'.

Fixes the ICE gcc.dg/torture/asm-subreg-1.c on aarch64.

Regression Tested on aarch64-elf. No new Regressions.

2012-12-12  Naveen H.S  

*recog.c (asm_operand_ok): Ignore invalid memory operands in
constraint 'X'

Regards,
Naveen
--- gcc/recog.c	2012-12-11 16:12:21.896002274 +0530
+++ gcc/recog.c	2012-12-11 16:38:34.004002088 +0530
@@ -1794,7 +1794,12 @@ asm_operand_ok (rtx op, const char *cons
 	  break;
 
 	case 'X':
-	  result = 1;
+	  /* Match any operands except for invalid memory operands.  */
+	  if (! (MEM_P (op)
+		 && ! memory_address_addr_space_p (GET_MODE (op), 
+		   XEXP (op, 0),
+		   MEM_ADDR_SPACE (op
+	result = 1;
 	  break;
 
 	case 'g':


PR other/54324: allow bootstrapping with older compilers

2012-12-11 Thread Aldy Hernandez

Hi Richard.

Your last patch for this PR suggested we verify our assumptions wrt a 
least common C++ compiler to build trunk with.  Since I already had the 
offended system at hand (Red Hat Linux 8.0), I decided to investigate a 
bit further.


g++ 3.4 builds trunk just fine, but anything prior to this chokes on a 
variety of inputs.  The patch below fixes them all, and gets 4.8 to 
bootstrap with a GCC 3.2 system.


I don't know how much of this is a fool's errand, and if we want to 
commit to supporting < GCC 3.4, but your patch suggested c++98, and GCC 
3.2 claims such.


The fixed issues are as follows:

1. Older G++ cannot understand attributes among arguments:

int foo(int bar __attribute__ ((__unused__)))

   It looks like we already have ARG_UNUSED for this precise problem,
   and it is already predicated on !__cplusplus || GCC_VERSION >= 3004.
   However, we've deviated from using ARG_UNUSED
   throughout the compiler, and I spent hours changing
   ATTRIBUTE_UNUSED into ARG_UNUSED until I gave up.  It's EVERYWHERE
   in the compiler-- all the way into our gen*.c files.  It seemed a lot
   simpler just changing the definition of ATTRIBUTE_UNUSED.

   Perhaps we could even deprecate ARG_UNUSED?

2. gcov-io.c uses __builtin_popcountll and __builtin_clzll.  Older
   GCC's do not have this.  For that matter, how does this even work on
   non-GCC systems?

   I have abstracted the non built-in versions we have for these in
   hwint.c, which seem written for older GCC's and non GCC's.

   I am not a huge fan of the new include file, but I really didn't
   want to duplicate code.  I'm open to suggestions.

3. Derived classes that include a union template die miserably on g++
   3.2.  Thankfully, this works:

-struct ssa_name_var_hash : typed_noop_remove 
+struct ssa_name_var_hash : typed_noop_remove 

4. Type checking as part of a `for' initializer segfaults on g++ 3.2:

for (type = TYPE_MAIN_VARIANT (blah); )

   The only reasonable thing I could think of, was disabling the tree
   checking code for older compilers.

I really don't want to spend much more time on this, but at the same 
time, I don't want to throw away a day's work, especially if it could 
conceivably help us with (older) non-GCC bootstrap compilers.


The attached patch bootstraps trunk on GCC 3.2 on a Red Hat Linux 8.0 
system (i686) configured with:


blah/configure --enable-languages=c,c++ --disable-libsanitizer

libsanitizer seems to be a moving target and it currently has issues 
with the RHL8.0 header files (earlier today it had other problems :)).


What are your thoughts on this?
PR other/54324
* Makefile.in (GCOV_IO_C): New.
(hwint.o): Depend on hwint-helper.c
(coverage.o): Depend on $(GCOV_IO_C).
(gcov.o): Same.
(gcov-dump.o): Same.
* basic-block.h (gt_ggc_mx): Fix prototype to work on older
compilers.
(gt_pch_nx): Same.
* gcov-io.c: Include hwint-helper.c.
(gcov_read_summary): Rename __builtin_popcountll to my_popcount.
(gcov_histo_index): Rename __builtin_clzll to my_clz_hwi.
* hwint.c: Move floor_log2, ceil_log2, exact_log2, ctz_hwi,
clz_hwi, ffs_hwi, and popcount_hwi into...
* hwint-helper.c: New file.
* tree-ssa-coalesce.c (struct ssa_name_var_hash): Remove union
specifier.
* tree.h: Disable checking code for GCC < 3.4.
* cp/cp-tree.h: Disable checking code for GCC < 3.4.
* include/ansidecl.h: Do not set __attribute__ for GCC < 3.4.

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 9efc2d3..e04e365 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -879,6 +879,7 @@ GIMPLE_H = gimple.h gimple.def gsstruct.def pointer-set.h 
$(VEC_H) \
tree-ssa-alias.h $(INTERNAL_FN_H)
 TRANS_MEM_H = trans-mem.h
 GCOV_IO_H = gcov-io.h gcov-iov.h auto-host.h
+GCOV_IO_C = gcov-io.c hwint-helper.c
 COVERAGE_H = coverage.h $(GCOV_IO_H)
 DEMANGLE_H = $(srcdir)/../include/demangle.h
 RECOG_H = recog.h
@@ -2700,7 +2701,7 @@ toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) coretypes.h 
$(TM_H) $(TREE_H) \
$(TREE_PRETTY_PRINT_H) opts-diagnostic.h $(COMMON_TARGET_H) \
tsan.h
 
-hwint.o : hwint.c $(CONFIG_H) $(SYSTEM_H) $(DIAGNOSTIC_CORE_H)
+hwint.o : hwint.c $(CONFIG_H) $(SYSTEM_H) $(DIAGNOSTIC_CORE_H) hwint-helper.c
 
 passes.o : passes.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
$(RTL_H) $(FUNCTION_H) $(FLAGS_H) $(INPUT_H) $(INSN_ATTR_H) output.h \
@@ -2945,7 +2946,7 @@ ipa-pure-const.o : ipa-pure-const.c $(CONFIG_H) 
$(SYSTEM_H) \
 coverage.o : coverage.c $(GCOV_IO_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h 
dumpfile.h \
$(TM_H) $(RTL_H) $(TREE_H) $(FLAGS_H) output.h $(REGS_H) $(EXPR_H) \
$(FUNCTION_H) $(BASIC_BLOCK_H) toplev.h $(DIAGNOSTIC_CORE_H) $(GGC_H) 
langhooks.h $(COVERAGE_H) \
-   tree-iterator.h $(CGRAPH_H) gcov-io.c $(TM_P_H) \
+   tree-iterator.h $(CGRAPH_H) $(GCOV_IO_C) $(TM_P_H) \
$(DIAGNOS