Re: [PATCH] Fix up vectorizer DDR_REVERSED_P handling (PR tree-optimization/59594, take 2)

2014-01-29 Thread Richard Biener
On January 28, 2014 11:32:40 PM GMT+01:00, Jakub Jelinek  
wrote:
>On Tue, Jan 28, 2014 at 01:14:32PM +0100, Richard Biener wrote:
>> > I admit I fully don't understand why exactly, but my
>experimentation so far
>> > showed that for read/write and write/read ddrs it is ok and
>desirable to
>> > ignore the dist > 0 && DDR_REVERSED_P (ddr) cases, but for
>write/write
>> > ddrs it is undesirable.  See the PR for further tests, perhaps I
>could
>> > turn them into further testcases.
>> 
>> Please.
>
>New testcase in the patch.
>
>> > -  if (dist > 0 && DDR_REVERSED_P (ddr))
>> > +  if (dist > 0 && DDR_REVERSED_P (ddr)
>> > +&& (DR_IS_READ (dra) || DR_IS_READ (drb)))
>> 
>> I think that'snot sufficient.  It depends
>> on the order of the stmts whether the dependence distance is really
>> negative - we are trying to catch write-after-read negative distance
>> here I think.  We can't rely on the DDRs being formed in stmt order
>> (anymore, at least since 4.9 where we start to arbitrary re-order
>> the vector of DRs).
>
>As discussed on IRC, the actual bug was that
>vect_analyze_data_ref_accesses
>reordered the data references before DDRs were constructed, thus DDR_A
>wasn't necessarily before DDR_B lexically in the loop and thus using
>DDR_REVERSED_P bit didn't really reflect whether it is negative or
>positive
>distance.
>
>Fixed by making sure the data refs aren't reordered (well, they are
>reordered on a copy of the vector only for the purposes of
>vect_analyze_data_ref_accesses).  Bootstrapped/regtested on
>x86_64-linux
>and i686-linux, ok for trunk?

Ok.

Thanks,
Richard.

>2014-01-28  Jakub Jelinek  
>
>   PR tree-optimization/59594
>   * tree-vect-data-refs.c (vect_analyze_data_ref_accesses): Sort
>   a copy of the datarefs vector rather than the vector itself.
>
>   * gcc.dg/vect/no-vfa-vect-depend-2.c: New test.
>   * gcc.dg/vect/no-vfa-vect-depend-3.c: New test.
>   * gcc.dg/vect/pr59594.c: New test.
>
>--- gcc/tree-vect-data-refs.c.jj   2014-01-23 10:52:26.766346677 +0100
>+++ gcc/tree-vect-data-refs.c  2014-01-28 16:11:34.371698307 +0100
>@@ -2484,19 +2484,21 @@ vect_analyze_data_ref_accesses (loop_vec
> return true;
> 
> /* Sort the array of datarefs to make building the interleaving chains
>- linear.  */
>-  qsort (datarefs.address (), datarefs.length (),
>+ linear.  Don't modify the original vector's order, it is needed
>for
>+ determining what dependencies are reversed.  */
>+  vec datarefs_copy = datarefs.copy ();
>+  qsort (datarefs_copy.address (), datarefs_copy.length (),
>sizeof (data_reference_p), dr_group_sort_cmp);
> 
>   /* Build the interleaving chains.  */
>-  for (i = 0; i < datarefs.length () - 1;)
>+  for (i = 0; i < datarefs_copy.length () - 1;)
> {
>-  data_reference_p dra = datarefs[i];
>+  data_reference_p dra = datarefs_copy[i];
>   stmt_vec_info stmtinfo_a = vinfo_for_stmt (DR_STMT (dra));
>   stmt_vec_info lastinfo = NULL;
>-  for (i = i + 1; i < datarefs.length (); ++i)
>+  for (i = i + 1; i < datarefs_copy.length (); ++i)
>   {
>-data_reference_p drb = datarefs[i];
>+data_reference_p drb = datarefs_copy[i];
> stmt_vec_info stmtinfo_b = vinfo_for_stmt (DR_STMT (drb));
> 
> /* ???  Imperfect sorting (non-compatible types, non-modulo
>@@ -2573,7 +2575,7 @@ vect_analyze_data_ref_accesses (loop_vec
>   }
> }
> 
>-  FOR_EACH_VEC_ELT (datarefs, i, dr)
>+  FOR_EACH_VEC_ELT (datarefs_copy, i, dr)
> if (STMT_VINFO_VECTORIZABLE (vinfo_for_stmt (DR_STMT (dr))) 
> && !vect_analyze_data_ref_access (dr))
>   {
>@@ -2588,9 +2590,13 @@ vect_analyze_data_ref_accesses (loop_vec
> continue;
>   }
> else
>-  return false;
>+{
>+  datarefs_copy.release ();
>+  return false;
>+}
>   }
> 
>+  datarefs_copy.release ();
>   return true;
> }
> 
>--- gcc/testsuite/gcc.dg/vect/no-vfa-vect-depend-2.c.jj2014-01-28
>14:06:10.818303424 +0100
>+++ gcc/testsuite/gcc.dg/vect/no-vfa-vect-depend-2.c   2014-01-28
>14:06:10.818303424 +0100
>@@ -0,0 +1,55 @@
>+/* { dg-require-effective-target vect_int } */
>+
>+#include 
>+#include "tree-vect.h"
>+
>+#define N 17
>+
>+int ia[N] = {48,45,42,39,36,33,30,27,24,21,18,15,12,9,6,3,0};
>+int ib[N] = {48,45,42,39,36,33,30,27,24,21,18,15,12,9,6,3,0};
>+int res[N] =
>{48,192,180,168,156,144,132,120,108,96,84,72,60,48,36,24,12};
>+
>+__attribute__ ((noinline))
>+int main1 ()
>+{
>+  int i;
>+
>+  /* Not vectorizable due to data dependence: dependence distance 1. 
>*/ 
>+  for (i = N - 1; i >= 0; i--)
>+{
>+  ia[i] = ia[i+1] * 4;
>+}
>+
>+  /* check results:  */
>+  for (i = 0; i < N; i++)
>+{
>+  if (ia[i] != 0)
>+  abort ();
>+} 
>+
>+  /* Vectorizable. Dependence distance -1.  */
>+  for (i = N - 1; i >= 0; i--)
>+{
>+  ib[i+1] = ib[i] * 4;
>+}
>+
>+  /* check results:  */
>+  for (i = 0; i < N; i++)
>+   

Re: Ping Re: Fix IBM long double spurious overflows

2014-01-29 Thread Mike Stump
On Jan 28, 2014, at 6:38 PM, David Edelsohn  wrote:
> It is not appropriate for a GCC or GLIBC maintainer to impose behavior

So, let's ask the direct question, do you oppose making -mieee conforming to 
ieee?  If not, they the fixes in question seem like they should be turned on 
with -mieee, and conformance tests that care about conformance can merely use 
that flag on such a target.

Re: VEC_WIDEN_MULT_(LO|HI)_EXPR vs. VEC_WIDEN_MULT_(EVEN|ODD)_EXPR in vectorization.

2014-01-29 Thread Richard Biener
On Tue, Jan 28, 2014 at 4:17 PM, Bingfeng Mei  wrote:
> I checked vectorization code, it seems that only relevant place 
> vec_widen_mult_even/odd & vec_widen_mult_lo/hi are generated is in 
> supportable_widening_operation. One of these pairs is selected, with priority 
> given to vec_widen_mult_even/odd if it is a reduction loop. However, lo/hi 
> pair seems to have wider usage than even/odd pair (non-loop? Non-reduction?). 
> Maybe that's why AltiVec and x86 still implement both pairs. Is following 
> patch OK?

Ok.

Thanks,
Richard.

> Index: gcc/ChangeLog
> ===
> --- gcc/ChangeLog   (revision 207183)
> +++ gcc/ChangeLog   (working copy)
> @@ -1,3 +1,9 @@
> +2014-01-28  Bingfeng Mei  
> +
> +   * doc/md.texi: Mention that a target shouldn't implement
> +   vec_widen_(s|u)mul_even/odd pair if it is less efficient
> +   than hi/lo pair.
> +
>  2014-01-28  Richard Biener  
>
> Revert
> Index: gcc/doc/md.texi
> ===
> --- gcc/doc/md.texi (revision 207183)
> +++ gcc/doc/md.texi (working copy)
> @@ -4918,7 +4918,8 @@ the output vector (operand 0).
>  Signed/Unsigned widening multiplication.  The two inputs (operands 1 and 2)
>  are vectors with N signed/unsigned elements of size S@.  Multiply the 
> high/low
>  or even/odd elements of the two vectors, and put the N/2 products of size 2*S
> -in the output vector (operand 0).
> +in the output vector (operand 0). A target shouldn't implement even/odd 
> pattern
> +pair if it is less efficient than lo/hi one.
>
>  @cindex @code{vec_widen_ushiftl_hi_@var{m}} instruction pattern
>  @cindex @code{vec_widen_ushiftl_lo_@var{m}} instruction pattern
>
>
> -Original Message-
> From: Richard Biener [mailto:richard.guent...@gmail.com]
> Sent: 28 January 2014 12:56
> To: Bingfeng Mei
> Cc: g...@gcc.gnu.org
> Subject: Re: VEC_WIDEN_MULT_(LO|HI)_EXPR vs. VEC_WIDEN_MULT_(EVEN|ODD)_EXPR 
> in vectorization.
>
> On Tue, Jan 28, 2014 at 12:08 PM, Bingfeng Mei  wrote:
>> Thanks, Richard. It is not very clear from documents.
>>
>> "Signed/Unsigned widening multiplication. The two inputs (operands 1 and 2)
>> are vectors with N signed/unsigned elements of size S. Multiply the high/low
>> or even/odd elements of the two vectors, and put the N/2 products of size 2*S
>> in the output vector (operand 0)."
>>
>> So I thought that implementing both can help vectorizer to optimize more 
>> loops.
>> Maybe we should improve documents.
>
> Maybe.  But my answer was from the top of my head - so better double-check
> in the vectorizer sources.
>
> Richard.
>
>> Bingfeng
>>
>>
>>
>> -Original Message-
>> From: Richard Biener [mailto:richard.guent...@gmail.com]
>> Sent: 28 January 2014 11:02
>> To: Bingfeng Mei
>> Cc: g...@gcc.gnu.org
>> Subject: Re: VEC_WIDEN_MULT_(LO|HI)_EXPR vs. VEC_WIDEN_MULT_(EVEN|ODD)_EXPR 
>> in vectorization.
>>
>> On Wed, Jan 22, 2014 at 1:20 PM, Bingfeng Mei  wrote:
>>> Hi,
>>> I noticed there is a regression of 4.8 against ancient 4.5 in vectorization 
>>> on our port. After a bit investigation, I found following code that prefer 
>>> even|odd version instead of lo|hi one. This is obviously the case for 
>>> AltiVec and maybe some other targets. But even|odd (expanding to a series 
>>> of instructions) versions are less efficient on our target than lo|hi ones. 
>>> Shouldn't there be a target-specific hook to do the choice instead of 
>>> hard-coded one here, or utilizing some cost-estimating technique to compare 
>>> two alternatives?
>>
>> Hmm, what's the reason for a target to support both?  I think the idea
>> was that a target only supports either (the more efficient case).
>>
>> Richard.
>>
>>>  /* The result of a vectorized widening operation usually requires
>>>  two vectors (because the widened results do not fit into one 
>>> vector).
>>>  The generated vector results would normally be expected to be
>>>  generated in the same order as in the original scalar computation,
>>>  i.e. if 8 results are generated in each vector iteration, they are
>>>  to be organized as follows:
>>> vect1: [res1,res2,res3,res4],
>>> vect2: [res5,res6,res7,res8].
>>>
>>>  However, in the special case that the result of the widening
>>>  operation is used in a reduction computation only, the order 
>>> doesn't
>>>  matter (because when vectorizing a reduction we change the order of
>>>  the computation).  Some targets can take advantage of this and
>>>  generate more efficient code.  For example, targets like Altivec,
>>>  that support widen_mult using a sequence of {mult_even,mult_odd}
>>>  generate the following vectors:
>>> vect1: [res1,res3,res5,res7],
>>> vect2: [res2,res4,res6,res8].
>>>
>>>  When vectorizing outer-loops, we execu

Re: -Og bug?

2014-01-29 Thread Richard Biener
On Tue, Jan 28, 2014 at 10:24 PM, Ian Lance Taylor  wrote:
> `On Tue, Jan 28, 2014 at 1:10 PM, Thomas Schwinge
>  wrote:
>>
>> OK, I agree to all of that, but I'd assume that if the compiler doesn't
>> do such value tracking to see whether all cases have been covered, it
>> also souldn't emit such possibly unitialized warning, to not cause false
>> positive warnings.
>
> The -Wuninitialized warning is full of false positives.
>
> It is the canonical example of why warnings that are driven by
> optimizations are difficult for users in practice.

Indeed.  In this case it's of course the "optimistic" data-flow done by
the -Wuninit pass - if it were to assume that a value is initialized if
it cannot prove it isn't then we'd get no false positives but also a lot
of false negatives.  Currently if it cannot prove it is initialized on a path
the pass assumes it is uninitialized on it.

As always you could do both dataflow kinds and add an extra "maybe"
before cases where both analyses do not agree.

Note that the current "maybe" is supposed to mean that there exists
a path to the use where the value seems to be(!) uninitialized.  In contrast
to there exists a path to the use where the value _is_ uninitialized or
even "all paths to the use have the value uninitialized" (the cases where
no maybe is emitted).

Richard.

> Ian


Re: [PATCH] Improve EDGE_ABNORMAL construction (PR middle-end/59917, tree-optimization/59920)

2014-01-29 Thread Richard Biener
On Tue, 28 Jan 2014, Jakub Jelinek wrote:

> Hi!
> 
> As discussed in the PR and similarly to what has been done previously
> for __builtin_setjmp only, this patch attempts to decrease number of
> EDGE_ABNORMAL edges in functions with non-local gotos and/or setjmp or
> other functions that return twice.
> Because, if we have many non-local labels or calls returning twice and
> many calls that could potentially longjmp or goto a non-local label,
> and especially if we have many SSA_NAMEs live across those abnormal edges,
> the number of needed PHI arguments is number of non-local
> labels/returns_twice calls times number of (most of) calls times number of
> such SSA_NAMEs, which even on real-world testcases means gigabytes of memory
> and hours of compilation time.
> The patch changes it, so that abnormal edges from calls that might longjmp
> or do non-local goto point to a special basic block containing
> an artificial ABNORMAL_DISPATCHER internal call and from that basic block
> there are abnormal edges to each non-local
> label/__builtin_setjmp_receiver/returns_twice call.
> 
> The patch also fixes the OpenMP PR, the abnormal edges since their
> introduction for setjmp for 4.9 (and for non-local gotos and computed gotos
> since forever) prevent discovery of OpenMP regions, because dominance can't
> be used for that.  As OpenMP SESE regions must not be entered abnormally or
> left abnormally (exit allowed as an exception and we allow abort too) in a
> valid program, we don't need to deal with longjmp jumping out of or into
> an OpenMP region (explicitly disallowed in the standard) and similarly for
> non-local gotos or computed gotos, the patch constructs the abnormal
> dispatchers or computed goto factored blocks one per OpenMP SESE region
> that needs it, which means fewer abnormal edges and more importantly that
> the regions can be easily discovered and outlined into separate functions.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

I wonder if you can't simply prune the edges for the OpenMP regions
(similar as to how we could prune some of the edges from setjmp
to calls before that setjmp call)?  Eventually this asks for delaying
of abnormal edge creation (but that's what you do anyway) to be able
to compute dominators between "regular" CFG creation and abnormal
edge creation.

More comments below

> 2014-01-27  Jakub Jelinek  
> 
>   PR middle-end/59917
>   PR tree-optimization/59920
>   * tree.c (build_common_builtin_nodes): Remove
>   __builtin_setjmp_dispatcher initialization.
>   * omp-low.h (make_gimple_omp_edges): Add a new int * argument.
>   * profile.c (branch_prob): Use gsi_start_nondebug_after_labels_bb
>   instead of gsi_after_labels + manually skipping debug stmts.
>   Don't ignore bbs with BUILT_IN_SETJMP_DISPATCHER, instead
>   ignore bbs with IFN_ABNORMAL_DISPATCHER.
>   * tree-inline.c (copy_edges_for_bb): Remove
>   can_make_abnormal_goto argument, instead add abnormal_goto_dest
>   argument.  Ignore computed_goto_p stmts.  Don't call
>   make_abnormal_goto_edges.  If a call might need abnormal edges
>   for non-local gotos, see if it already has an edge to
>   IFN_ABNORMAL_DISPATCHER or if it is IFN_ABNORMAL_DISPATCHER
>   with true argument, don't do anything then, otherwise add
>   EDGE_ABNORMAL from the call's bb to abnormal_goto_dest.
>   (copy_cfg_body): Compute abnormal_goto_dest, adjust copy_edges_for_bb
>   caller.
>   * gimple-low.c (struct lower_data): Remove calls_builtin_setjmp.
>   (lower_function_body): Don't emit __builtin_setjmp_dispatcher.
>   (lower_stmt): Don't set data->calls_builtin_setjmp.
>   (lower_builtin_setjmp): Adjust comment.
>   * builtins.def (BUILT_IN_SETJMP_DISPATCHER): Remove.
>   * tree-cfg.c (found_computed_goto): Remove.
>   (factor_computed_gotos): Remove.
>   (make_goto_expr_edges): Return bool, true for computed gotos.
>   Don't call make_abnormal_goto_edges.
>   (build_gimple_cfg): Don't set found_computed_goto, don't call
>   factor_computed_gotos.
>   (computed_goto_p): No longer static.
>   (make_blocks): Don't set found_computed_goto.
>   (handle_abnormal_edges): New function.
>   (make_edges): If make_goto_expr_edges returns true, push bb
>   into ab_edge_goto vector, for stmt_can_make_abnormal_goto calls
>   instead of calling make_abnormal_goto_edges push bb into ab_edge_call
>   vector.  Record mapping between bbs and OpenMP regions if there
>   are any, adjust make_gimple_omp_edges caller.  Call
>   handle_abnormal_edges.
>   (make_abnormal_goto_edges): Remove.
>   * tree-cfg.h (make_abnormal_goto_edges): Remove.
>   (computed_goto_p): New prototype.
>   * internal-fn.c (expand_ABNORMAL_DISPATCHER): New function.
>   * builtins.c (expand_builtin): Don't handle
>   BUILT_IN_SETJMP_DISPATCHER.
>   * internal-fn.def (ABNORMAL_

Re: [PATCH] FIx a valgrind reported issue in build tools (PR other/58712)

2014-01-29 Thread Richard Biener
On Tue, Jan 28, 2014 at 11:48 PM, Jakub Jelinek  wrote:
> Hi!
>
> I've started an --enable-checking=valgrind bootstrap during the weekend,
> but only on Sunday afternoon and thus killed it on Monday morning, so it
> didn't get very far, but still reported a problem where the build tools
> had uninitialized memory use in copy_rtx:
> case CLOBBER:
>   /* Share clobbers of hard registers (like cc0), but do not share
>* pseudo reg
>  clobbers or clobbers of hard registers that originated as pseudos.
>  This is needed to allow safe register renaming.  */
>   if (REG_P (XEXP (orig, 0)) && REGNO (XEXP (orig, 0)) < 
> FIRST_PSEUDO_REGISTER
>   && ORIGINAL_REGNO (XEXP (orig, 0)) == REGNO (XEXP (orig, 0)))
> return orig;
> - ORIGINAL_REGNO was uninitialized.  The problem is that read_rtx_code uses
> rtx_alloc, which clears only the first int in the structure (header), and
> then ignores the fields with 0 format character.  For ORIGINAL_REGNO, we
> want to set it to REGNO, for others IMHO it is best to just clear those
> fields.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?

Ok.

Thanks,
Richard.

> 2014-01-28  Jakub Jelinek  
>
> PR other/58712
> * read-rtl.c (read_rtx_code): Clear all of RTX_CODE_SIZE (code).
> For REGs set ORIGINAL_REGNO.
>
> --- gcc/read-rtl.c.jj   2014-01-03 11:40:57.0 +0100
> +++ gcc/read-rtl.c  2014-01-27 10:01:44.154527266 +0100
> @@ -1131,6 +1131,7 @@ read_rtx_code (const char *code_name)
>/* If we end up with an insn expression then we free this space below.  */
>return_rtx = rtx_alloc (code);
>format_ptr = GET_RTX_FORMAT (code);
> +  memset (return_rtx, 0, RTX_CODE_SIZE (code));
>PUT_CODE (return_rtx, code);
>
>if (iterator)
> @@ -1154,6 +1155,8 @@ read_rtx_code (const char *code_name)
> /* 0 means a field for internal use only.
>Don't expect it to be present in the input.  */
>case '0':
> +   if (code == REG)
> + ORIGINAL_REGNO (return_rtx) = REGNO (return_rtx);
> break;
>
>case 'e':
>
> Jakub


Re: PATCH: PR target/59672: Add -m16 support for x86

2014-01-29 Thread Richard Biener
On Tue, 28 Jan 2014, Uros Bizjak wrote:

> On Mon, Jan 27, 2014 at 8:44 PM, H.J. Lu  wrote:
> 
> > The .code16gcc directive was added to binutils back in 1999:
> >
> > ---
> >'.code16gcc' provides experimental support for generating 16-bit code
> > from gcc, and differs from '.code16' in that 'call', 'ret', 'enter',
> > 'leave', 'push', 'pop', 'pusha', 'popa', 'pushf', and 'popf'
> > instructions default to 32-bit size.  This is so that the stack pointer
> > is manipulated in the same way over function calls, allowing access to
> > function parameters at the same stack offsets as in 32-bit mode.
> > '.code16gcc' also automatically adds address size prefixes where
> > necessary to use the 32-bit addressing modes that gcc generates.
> > ---
> >
> > It encodes 32-bit assembly instructions generated by GCC in 16-bit format
> >  so that GCC can be used to generate 16-bit instructions.  To do that, the
> >  .code16gcc directive may be placed at the very beginning of the assembly
> >  code.  This patch adds -m16 to x86 backend by:
> >
> > 1. Add -m16 and make it mutually exclusive with -m32, -m64 and -mx32.
> > 2. Treat -m16 like -m32 so that --32 is passed to assembler.
> > 3. Output .code16gcc at the very beginning of the assembly code.
> > 4. Turn off 64-bit ISA when -m16 is used.
> >
> > Tested on Linux/x86 and Linux/x86-64.  OK for trunk?
> >
> > Thanks.
> >
> > H.J.
> > ---
> > PR target/59672
> > * config/i386/gnu-user64.h (SPEC_32): Add "m16|" to "m32".
> > (SPEC_X32): Likewise.
> > (SPEC_64): Likewise.
> > * config/i386/i386.c (ix86_option_override_internal): Turn off
> > OPTION_MASK_ISA_64BIT, OPTION_MASK_ABI_X32 and OPTION_MASK_ABI_64
> > for TARGET_16BIT.
> > (x86_file_start): Output .code16gcc for TARGET_16BIT.
> > * config/i386/i386.h (TARGET_16BIT): New macro.
> > (TARGET_16BIT_P): Likewise.
> > * config/i386/i386.opt: Add m16.
> > * doc/invoke.texi: Document -m16.
> 
> OK for mainline, needs OK from RMs for a backport.

I don't think this is suitable for the branch.  Unless there is
tremendous need for it somewhere ...?  I like the suggested
addition of a --code16gcc assembler flag.  Please make sure to
document the minimum required binutils to make this work.

Richard.


Re: Disable accumulate-outgoing-args for Generic and Buldozers

2014-01-29 Thread Jakub Jelinek
On Tue, Jan 28, 2014 at 07:26:47AM +0100, Jakub Jelinek wrote:
> > I wonder if this is just some of --enable-checking tests in dwarf2out going 
> > wild
> > or if it is just expensive sanity checking code?
> > I used to have chroot environment for 32bit builds, I will need to 
> > re-install it now.
> 
>  variable tracking   :2914.85 (83%) usr   1.88 ( 7%) sys2931.22 (82%) 
> wall   80844 kB ( 3%) ggc
>  var-tracking dataflow   :  18.19 ( 1%) usr   0.19 ( 1%) sys  18.49 ( 1%) 
> wall   10899 kB ( 0%) ggc
>  var-tracking emit   :  29.41 ( 1%) usr   0.11 ( 0%) sys  29.65 ( 1%) 
> wall  148128 kB ( 6%) ggc
>  TOTAL :3525.9725.73  3570.33
> 2321043 kB
> 
> So, strangely both vt_find_locations and vt_emit_notes, typically the most 
> expensive ones,
> are quite unexpensive and most of the time is spent elsewhere, in 
> vt_initialize?

So, most of the time seems to be spent in cselib.c remove_useless_values
(both from Ctrl-C in gdb profiling, and callgrind).  For callgrind I've
actually built 64-bit cc1plus with --enable-checking=release, and still compiled
the same --enable-checking=yes,rtl -m32 -O2 -g insn-recog.c, the build then
took just 14 minutes instead of 60 minutes, and in that case only about 30%
of compile time has been spent in var-tracking and 20% of compile time
in remove_useless_values in particular.

The problem with remove_useless_values is that we have quickly very big
cselib hash table (over 20 entries) and very large number of very small
basic blocks (over 34000) and at the end of every basic block we call
cselib_preserve_only_values which walks the whole hash table, and e.g.
references_value_p is called 845114869x from discard_useless_locs.

A micro-optimization could be e.g. to turn references_value_p into a
template where only_useless would be a template parameter rather than actual
parameter (due to recursion inlining doesn't help here) or just two
functions.

Also, for RTL checking, I wonder if the functions like reference_values_p
and similar ones that use GET_RTX_FORMAT/GET_RTX_LENGTH to walk the elements
couldn't use special non-checking macros in doing so if the compiler can't
figure out checking is redundant there because it is being performed by hand
by the function (haven't verified).  And, perhaps also an approach similar
to http://gcc.gnu.org/ml/gcc-patches/2014-01/msg00140.html for
GET_RTX_FORMAT and/or GET_RTX_LENGTH (so that at least for the cases where
the compiler knows which rtx code it is (if some code is guarded with
specific GET_CODE () == test), it could avoid loading from the const
arrays).

Anyway, I guess more important is whether all the values in the
cselib_hash_table will be ever useful for some lookup, or if there are
e.g. values that only reference preserved values where none of those
referenced values have any locations other than preserved values.

Or if we can somehow quickly find out what VALUEs have changed during
processing of the last bb and only process that subset instead of all the
hash table entries all the time.

Alex?  Your thoughts?

Jakub


[PATCH] longlong.h: Add prototype for udiv_w_sdiv

2014-01-29 Thread Andreas Krebbel
Hi,

the attached patch adds a prototype for __udiv_w_sdiv to longlong.h if
needed.  This fixes tons of build warnings on s390 32 bit in glibc.

Ok?

Bye,

-Andreas-


2014-01-29  Andreas Krebbel  

* longlong.h: Add __udiv_w_sdiv prototype.

diff --git a/include/longlong.h b/include/longlong.h
index 5f00e54..053a81d 100644
--- a/include/longlong.h
+++ b/include/longlong.h
@@ -1671,7 +1671,8 @@ extern UHItype __stormy16_count_leading_zeros (UHItype);
 #if !defined (udiv_qrnnd) && defined (sdiv_qrnnd)
 #define udiv_qrnnd(q, r, nh, nl, d) \
   do { \
-USItype __r;   \
+extern UWtype __udiv_w_sdiv (UWtype *, UWtype, UWtype, UWtype);\
+UWtype __r;
\
 (q) = __udiv_w_sdiv (&__r, nh, nl, d); \
 (r) = __r; \
   } while (0)



Re: C++ PATCH for c++/53756 (-g and C++1y auto)

2014-01-29 Thread Andreas Schwab
Jason Merrill  writes:

> +// { dg-final { scan-assembler "a1.*(0x\[0-9a-f\]+)\[ \t\]*# 
> DW_AT_type.*\\1. 
> DW_TAG_unspecified_type.*DW_AT_specification\[\n\r\]{1,2}\[^\n\r\]*(0x\[0-9a-f\]+)\[
>  \t\]*# DW_AT_type.*\\2. DW_TAG_base_type" } }

This regexp is completely broken.

Here's what I get on m68k:

.uleb128 0x3| (DIE (0x2b) DW_TAG_subprogram)
| DW_AT_external
.ascii "a1\0"   | DW_AT_name
.byte   0x1 | DW_AT_decl_file 
(/daten/aranym/gcc/gcc-20140129/gcc/testsuite/g++.dg/debug/dwarf2/auto1.C)
.byte   0x17| DW_AT_decl_line
.long   .LASF2  | DW_AT_linkage_name: "_ZN1A2a1Ev"
.long   0x44| DW_AT_type
| DW_AT_declaration
.long   0x3d| DW_AT_object_pointer
.uleb128 0x4| (DIE (0x3d) DW_TAG_formal_parameter)
.long   0x49| DW_AT_type
| DW_AT_artificial
.byte   0   | end of children of DIE 0x2b
.byte   0   | end of children of DIE 0x21
.uleb128 0x5| (DIE (0x44) DW_TAG_unspecified_type)
.long   .LASF3  | DW_AT_name: "auto"
.uleb128 0x6| (DIE (0x49) DW_TAG_pointer_type)
.byte   0x4 | DW_AT_byte_size
.long   0x21| DW_AT_type
.uleb128 0x7| (DIE (0x4f) DW_TAG_subprogram)
.long   0x2b| DW_AT_specification
.long   0x77| DW_AT_type
.long   .LFB0   | DW_AT_low_pc
.long   .LFE0-.LFB0 | DW_AT_high_pc
.uleb128 0x1| DW_AT_frame_base
.byte   0x9c| DW_OP_call_frame_cfa
.long   0x6a| DW_AT_object_pointer
| DW_AT_GNU_all_call_sites
.long   0x77| DW_AT_sibling
.uleb128 0x8| (DIE (0x6a) DW_TAG_formal_parameter)
.long   .LASF4  | DW_AT_name: "this"
.long   0x7e| DW_AT_type
| DW_AT_artificial
.uleb128 0x2| DW_AT_location
.byte   0x91| DW_OP_fbreg
.sleb128 0
.byte   0   | end of children of DIE 0x4f
.uleb128 0x9| (DIE (0x77) DW_TAG_base_type)
.byte   0x4 | DW_AT_byte_size
.byte   0x5 | DW_AT_encoding
.ascii "int\0"  | DW_AT_name

And this is what I get on ia64:

.uleb128 0x3// (DIE (0x2f) DW_TAG_subprogram)
// DW_AT_external
.ascii "a1\0"   // DW_AT_name
data1   0x1 // DW_AT_decl_file 
(/usr/local/gcc/gcc-20140129/gcc/testsuite/g++.dg/debug/dwarf2/auto1.C)
data1   0x17// DW_AT_decl_line
data4.ua@secrel(.LASF2) // DW_AT_linkage_name: "_ZN1A2a1Ev"
data4.ua0x48// DW_AT_type
// DW_AT_declaration
data4.ua0x41// DW_AT_object_pointer
.uleb128 0x4// (DIE (0x41) DW_TAG_formal_parameter)
data4.ua0x4d// DW_AT_type
// DW_AT_artificial
data1   0   // end of children of DIE 0x2f
data1   0   // end of children of DIE 0x25
.uleb128 0x5// (DIE (0x48) DW_TAG_unspecified_type)
data4.ua@secrel(.LASF3) // DW_AT_name: "auto"
.uleb128 0x6// (DIE (0x4d) DW_TAG_pointer_type)
data1   0x8 // DW_AT_byte_size
data4.ua0x25// DW_AT_type
.uleb128 0x7// (DIE (0x53) DW_TAG_subprogram)
data4.ua0x2f// DW_AT_specification
data4.ua0x85// DW_AT_type
data8.ua.LFB0   // DW_AT_low_pc
data8.ua.LFE0-.LFB0 // DW_AT_high_pc
data4.ua@secrel(.LLST0) // DW_AT_frame_base
data4.ua0x78// DW_AT_object_pointer
// DW_AT_GNU_all_call_sites
data4.ua0x85// DW_AT_sibling
.uleb128 0x8// (DIE (0x78) DW_TAG_formal_parameter)
data4.ua@secrel(.LASF4) // DW_AT_name: "this"
data4.ua0x8c// DW_AT_type
// DW_AT_artificial
.uleb128 0x2// DW_AT_location
data1   0x91// DW_OP_fbreg
.sleb128 0
data1   0   // end of children of DIE 0x53
.uleb128 0x9// (DIE (0x85) DW_TAG_base_type)
data1   0x4 // DW_AT_byte_size
data1   0x5 // DW_AT_encoding
.ascii "int\0"  // DW_AT_name

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


RFA: RL78: Fix UMUL and $FP size

2014-01-29 Thread Nick Clifton
Hi DJ,

  I noticed a couple of RL78 patches in our local tree that ought to be
  upstream, so here they are.  The first is for the size of the frame
  pointer register and the second is for the UMUL instruction when both
  input operands are in the same register.

  OK to apply ?

Cheers
  Nick

gcc/ChangeLog
2014-01-29  Nick Clifton  
DJ Delorie  

* config/rl78/rl78.c (register_sizes): Make the "upper half" of
%fp 2 to keep registers after it properly word-aligned.
(rl78_alloc_physical_registers_umul): Handle the case where both
input operands are the same.

Index: gcc/config/rl78/rl78.c
===
--- gcc/config/rl78/rl78.c  (revision 207224)
+++ gcc/config/rl78/rl78.c  (working copy)
@@ -327,13 +327,15 @@
 }
 
 /* Most registers are 8 bits.  Some are 16 bits because, for example,
-   gcc doesn't like dealing with $FP as a register pair.  This table
-   maps register numbers to size in bytes.  */
+   gcc doesn't like dealing with $FP as a register pair (the second
+   half of $fp is also 2 to keep reload happy wrt register pairs, but
+   no register class includes it).  This table maps register numbers
+   to size in bytes.  */
 static const int register_sizes[] =
 {
   1, 1, 1, 1, 1, 1, 1, 1,
   1, 1, 1, 1, 1, 1, 1, 1,
-  1, 1, 1, 1, 1, 1, 2, 1,
+  1, 1, 1, 1, 1, 1, 2, 2,
   1, 1, 1, 1, 1, 1, 1, 1,
   2, 2, 1, 1, 1
 };
@@ -2996,9 +2998,19 @@
 
   tmp_id = get_max_insn_count ();
   saved_op1 = OP (1);
-  
-  OP (1) = move_to_acc (1, insn);
 
+  if (rtx_equal_p (OP (1), OP (2)))
+{
+  gcc_assert (GET_MODE (OP (2)) == QImode);
+  /* The MULU instruction does not support duplicate arguments
+but we know that if we copy OP (2) to X it will do so via
+A and thus OP (1) will already be loaded into A.  */
+  OP (2) = move_to_x (2, insn);
+  OP (1) = A;
+}
+  else
+OP (1) = move_to_acc (1, insn);
+
   MAYBE_OK (insn);
 
   /* If we omitted the move of OP1 into the accumulator (because


RFA: MN10300: Fix typo store_movm pattern

2014-01-29 Thread Nick Clifton
Hi Alex, Hi Jeff,

  There is a typo in the MN10300 store_movm pattern.  It calls
  mn10300_store_multiple_operation to generate a bit mask of registers
  to be pushed, which it then passes to mn10300_print_reg_list.  But
  mn10300_store_multiple_operation is actually a predicate function
  (defined in predicates.md).  The function that should have been called
  is mn10300_store_multiple_operation_p.

  The patch below is the obvious fix for the typo, but I am wondering
  whether it would be better to rename the two functions.  Eg:

mn10300_store_multiple_operation   -> mn10300_store_multiple_operation_p
mn10300_store_multiple_operation_p -> mn10300_store_multiple_regs

Cheers
  Nick

gcc/ChangeLog
2014-01-29  Nick Clifton  

* config/mn10300/mn10300.md (store_movm): Fix typo.

Index: gcc/config/mn10300/mn10300.md
===
--- gcc/config/mn10300/mn10300.md   (revision 207224)
+++ gcc/config/mn10300/mn10300.md   (working copy)
@@ -2059,8 +2059,7 @@
 {
   fputs ("\tmovm ", asm_out_file);
   mn10300_print_reg_list (asm_out_file,
-  mn10300_store_multiple_operation (operands[0],
-   VOIDmode));
+  mn10300_store_multiple_operation_p (operands[0]));
   fprintf (asm_out_file, ",(sp)\n");
   return "";
 }


[PATCH] Fix PR58742

2014-01-29 Thread Richard Biener

This adds GIMPLE combining for /[ex] X * X as it appears for
pointer subtraction / addition combo.

Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2014-01-29  Richard Biener  

PR tree-optimization/58742
* tree-ssa-forwprop.c (associate_plusminus): Return true
if we changed sth, defer EH cleanup to ...
(ssa_forward_propagate_and_combine): ... here.  Call simplify_mult.
(simplify_mult): New function.

Index: gcc/tree-ssa-forwprop.c
===
--- gcc/tree-ssa-forwprop.c (revision 207194)
+++ gcc/tree-ssa-forwprop.c (working copy)
@@ -2792,9 +2792,7 @@ out:
 {
   fold_stmt_inplace (gsi);
   update_stmt (stmt);
-  if (maybe_clean_or_replace_eh_stmt (stmt, stmt)
- && gimple_purge_dead_eh_edges (gimple_bb (stmt)))
-   return true;
+  return true;
 }
 
   return false;
@@ -3425,6 +3423,53 @@ simplify_vector_constructor (gimple_stmt
   return true;
 }
 
+/* Simplify multiplications.
+   Return true if a transformation applied, otherwise return false.  */
+
+static bool
+simplify_mult (gimple_stmt_iterator *gsi)
+{
+  gimple stmt = gsi_stmt (*gsi);
+  tree arg1 = gimple_assign_rhs1 (stmt);
+  tree arg2 = gimple_assign_rhs2 (stmt);
+
+  if (TREE_CODE (arg1) != SSA_NAME)
+return false;
+
+  gimple def_stmt = SSA_NAME_DEF_STMT (arg1);
+  if (!is_gimple_assign (def_stmt))
+return false;
+
+  /* Look through a sign-changing conversion.  */
+  if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt)))
+{
+  if (TYPE_PRECISION (TREE_TYPE (gimple_assign_lhs (def_stmt)))
+ != TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs1 (def_stmt)))
+ || TREE_CODE (gimple_assign_rhs1 (def_stmt)) != SSA_NAME)
+   return false;
+  def_stmt = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (def_stmt));
+  if (!is_gimple_assign (def_stmt))
+   return false;
+}
+
+  if (gimple_assign_rhs_code (def_stmt) == EXACT_DIV_EXPR)
+{
+  if (operand_equal_p (gimple_assign_rhs2 (def_stmt), arg2, 0))
+   {
+ tree res = gimple_assign_rhs1 (def_stmt);
+ if (useless_type_conversion_p (TREE_TYPE (arg1), TREE_TYPE (res)))
+   gimple_assign_set_rhs_with_ops (gsi, TREE_CODE (res), res,
+   NULL_TREE);
+ else
+   gimple_assign_set_rhs_with_ops (gsi, NOP_EXPR, res, NULL_TREE);
+ gcc_assert (gsi_stmt (*gsi) == stmt);
+ update_stmt (stmt);
+ return true;
+   }
+}
+
+  return false;
+}
 /* Main entry point for the forward propagation and statement combine
optimizer.  */
 
@@ -3576,9 +3621,23 @@ ssa_forward_propagate_and_combine (void)
 || code == BIT_IOR_EXPR
 || code == BIT_XOR_EXPR)
  changed = simplify_bitwise_binary (&gsi);
+   else if (code == MULT_EXPR)
+ {
+   changed = simplify_mult (&gsi);
+   if (changed
+   && maybe_clean_or_replace_eh_stmt (stmt, stmt)
+   && gimple_purge_dead_eh_edges (bb))
+ cfg_changed = true;
+ }
else if (code == PLUS_EXPR
 || code == MINUS_EXPR)
- changed = associate_plusminus (&gsi);
+ {
+   changed = associate_plusminus (&gsi);
+   if (changed
+   && maybe_clean_or_replace_eh_stmt (stmt, stmt)
+   && gimple_purge_dead_eh_edges (bb))
+ cfg_changed = true;
+ }
else if (code == POINTER_PLUS_EXPR)
  changed = associate_pointerplus (&gsi);
else if (CONVERT_EXPR_CODE_P (code)


[PATCH][C] Fix PR59905, remove code replacing calls with abort

2014-01-29 Thread Richard Biener

This removes the code that tries to avoid ICEs in the middle-end when
facing calls through an incompatible type.  The middle-end can now
happily deal with those mismatches (and we rely on that).  Also the
code only detects the most primitive cases like

  ((bar_get_x_func*) foo_get_x) (x)

but does not touch

  bar_get_x_func* fn = foo_get_x;
  fn (x);

I preserved the warning (so I didn't have to remove the cast-function-1.c
testcase) and fixed the testcase to be not optimized to nothing by the
very first DCE pass and thus get non-empty assembler output with
some calls and some inlines (yes, we _can_ inline some mismatches,
esp. those refered to in the PR which is about void * vs some
struct * type).

Bootstrap / regtest running on x86_64-unknown-linux-gnu - ok for trunk?

Thanks,
Richard.

2014-01-29  Richard Biener  

PR c/59905
* c-typeck.c (build_function_call_vec): Do not replace calls
to a function via an incompatible type with a runtime abort.

* gcc.dg/cast-function-1.c: Adjust to survive DCE.

Index: gcc/c/c-typeck.c
===
*** gcc/c/c-typeck.c(revision 207194)
--- gcc/c/c-typeck.c(working copy)
*** build_function_call_vec (location_t loc,
*** 2907,2962 
  return error_mark_node;
  
/* Check that the function is called through a compatible prototype.
!  If it is not, replace the call by a trap, wrapped up in a compound
!  expression if necessary.  This has the nice side-effect to prevent
!  the tree-inliner from generating invalid assignment trees which may
!  blow up in the RTL expander later.  */
if (CONVERT_EXPR_P (function)
&& TREE_CODE (tem = TREE_OPERAND (function, 0)) == ADDR_EXPR
&& TREE_CODE (tem = TREE_OPERAND (tem, 0)) == FUNCTION_DECL
&& !comptypes (fntype, TREE_TYPE (tem)))
  {
tree return_type = TREE_TYPE (fntype);
-   tree trap = build_function_call (loc,
-  builtin_decl_explicit (BUILT_IN_TRAP),
-  NULL_TREE);
-   int i;
  
/* This situation leads to run-time undefined behavior.  We can't,
 therefore, simply error unless we can prove that all possible
 executions of the program must execute the code.  */
!   if (warning_at (loc, 0, "function called through a non-compatible 
type"))
!   /* We can, however, treat "undefined" any way we please.
!  Call abort to encourage the user to fix the program.  */
!   inform (loc, "if this code is reached, the program will abort");
!   /* Before the abort, allow the function arguments to exit or
!call longjmp.  */
!   for (i = 0; i < nargs; i++)
!   trap = build2 (COMPOUND_EXPR, void_type_node, (*params)[i], trap);
  
!   if (VOID_TYPE_P (return_type))
!   {
! if (TYPE_QUALS (return_type) != TYPE_UNQUALIFIED)
!   pedwarn (loc, 0,
!"function with qualified void return type called");
! return trap;
!   }
!   else
!   {
! tree rhs;
! 
! if (AGGREGATE_TYPE_P (return_type))
!   rhs = build_compound_literal (loc, return_type,
! build_constructor (return_type,
!   NULL),
! false);
! else
!   rhs = build_zero_cst (return_type);
! 
! return require_complete_type (build2 (COMPOUND_EXPR, return_type,
!   trap, rhs));
!   }
! }
  
argarray = vec_safe_address (params);
  
--- 2907,2930 
  return error_mark_node;
  
/* Check that the function is called through a compatible prototype.
!  If it is not, warn.  */
if (CONVERT_EXPR_P (function)
&& TREE_CODE (tem = TREE_OPERAND (function, 0)) == ADDR_EXPR
&& TREE_CODE (tem = TREE_OPERAND (tem, 0)) == FUNCTION_DECL
&& !comptypes (fntype, TREE_TYPE (tem)))
  {
tree return_type = TREE_TYPE (fntype);
  
/* This situation leads to run-time undefined behavior.  We can't,
 therefore, simply error unless we can prove that all possible
 executions of the program must execute the code.  */
!   warning_at (loc, 0, "function called through a non-compatible type");
  
!   if (VOID_TYPE_P (return_type)
! && TYPE_QUALS (return_type) != TYPE_UNQUALIFIED)
!   pedwarn (loc, 0,
!"function with qualified void return type called");
!  }
  
argarray = vec_safe_address (params);
  
Index: gcc/testsuite/gcc.dg/cast-function-1.c
===
*** gcc/testsuite/gcc.dg/cast-function-1.c  (revision 207194)
--- gcc/testsuite/gcc.dg/cast-function-1.c  (working copy)
*** typedef struct {
*** 16,27 
int a;
  } str_t;
  
! void bar(void)
  {

Re: [PATCH] preprocessor/58580 - preprocessor goes OOM with warning for zero literals

2014-01-29 Thread Dodji Seketeli
"H.J. Lu"  writes:

> The new tests failed on Linux/x86:

Woops.

I have committed the patch below under the obvious rule for this.  Sorry
for the inconvenience.


gcc/testsuite/ChangeLog:

* c-c++-common/cpp/warning-zero-location-2.c: Fix error message
specifier.

diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a468447..2da 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-01-29  Dodji Seketeli  
+
+   * c-c++-common/cpp/warning-zero-location-2.c: Fix error message
+   selector.
+
 2014-01-29  Jakub Jelinek  
 
PR middle-end/59917
diff --git a/gcc/testsuite/c-c++-common/cpp/warning-zero-location-2.c 
b/gcc/testsuite/c-c++-common/cpp/warning-zero-location-2.c
index c0e0bf7..e919bca 100644
--- a/gcc/testsuite/c-c++-common/cpp/warning-zero-location-2.c
+++ b/gcc/testsuite/c-c++-common/cpp/warning-zero-location-2.c
@@ -7,4 +7,4 @@
 #include 
 int main() { return 0; }
 
-/* { dg-error "No such file or directory" { target *-*-* } 4636 } */
+/* { dg-message "" "#include" {target *-*-* } 0 }
-- 
Dodji


Re: [PING] [PATCH] _Cilk_for for C and C++

2014-01-29 Thread Jakub Jelinek
On Tue, Jan 28, 2014 at 04:55:38PM +, Iyer, Balaji V wrote:
>   I thought about it a bit more, and the main issue here is that we
> need access to the _Cilk_for loop's components both inside the child
> function and the parent function.

I guess for the C++ iterators, if in the _Cilk_for model you need to provide
number of iterations before parallelization, it really depends on what the
standard allows and what you want to do exactly.
If you need to provide the iteration count before spawning the threads and
the standard allows you that, then just lower it in the C++ FE already
so that you do:
  vector::iterator temp = array.begin ();
  sizetype tempcount = (array.end () - temp);
before the parallel, and then
  #pragma omp parallel firstprivate(temp, tempcount)
_Cilk_for (sizetype temp2 = 0; temp2 < tempcount; temp2++)
  {
vector::iterator ii = temp + temp2;

  }
or similar.  The C++ FE needs to lower the C++ iterators anyway, the
middle-end can really only work with integral or pointer iterators, and it
depends on how exactly the Cilk+ standard defines _Cilk_for with iterators
(what methods must be implemented on the iterators and what methods and in
what order should be called).

Jakub


Re: Disable accumulate-outgoing-args for Generic and Buldozers

2014-01-29 Thread Jakub Jelinek
On Wed, Jan 29, 2014 at 11:02:05AM +0100, Jakub Jelinek wrote:
> So, most of the time seems to be spent in cselib.c remove_useless_values
> (both from Ctrl-C in gdb profiling, and callgrind).  For callgrind I've
> actually built 64-bit cc1plus with --enable-checking=release, and still 
> compiled
> the same --enable-checking=yes,rtl -m32 -O2 -g insn-recog.c, the build then
> took just 14 minutes instead of 60 minutes, and in that case only about 30%
> of compile time has been spent in var-tracking and 20% of compile time
> in remove_useless_values in particular.

Ugh, actually it seems I've screwed up my testing, the
--enable-checking=release numbers above and also the callgrind were
mistakenly from -m64 -O2 -g insn-recog.c compilation.
If I use 64-bit --enable-checking=release compiler to compile the
32-bit insn-recog.c with yes,rtl checking in the preprocessed source
(-m32 -O2 -g), then it takes:
real62m43.754s
user62m11.885s
sys 0m11.894s
to compile it, so this isn't really about the RTL checking being actually
slow in the prev-gcc compiler, but just by RTL checking resulting in too
many basic blocks and too many values in insn-recog.c sources, which
increases the severity.  Not going to start callgrind now on something that
takes one hour without emulation though, that would be more than 24 hours.

Jakub


[C++ Patch] PR 58072

2014-01-29 Thread Paolo Carlini

Hi,

a very simple ICE on invalid regression present only in mainline. Tested 
x86_64-linux.


Thanks,
Paolo.

///
/cp
2014-01-29  Paolo Carlini  

PR c++/58072
* semantics.c (finish_omp_reduction_clause): Check type for
error_mark_node.

/testsuite
2014-01-29  Paolo Carlini  

PR c++/58072
* g++.dg/gomp/pr58702.C: New.
Index: cp/semantics.c
===
--- cp/semantics.c  (revision 207234)
+++ cp/semantics.c  (working copy)
@@ -5021,7 +5021,9 @@ finish_omp_reduction_clause (tree c, bool *need_de
   tree type = TREE_TYPE (t);
   if (TREE_CODE (type) == REFERENCE_TYPE)
 type = TREE_TYPE (type);
-  if (ARITHMETIC_TYPE_P (type))
+  if (type == error_mark_node)
+return true;
+  else if (ARITHMETIC_TYPE_P (type))
 switch (OMP_CLAUSE_REDUCTION_CODE (c))
   {
   case PLUS_EXPR:
Index: testsuite/g++.dg/gomp/pr58702.C
===
--- testsuite/g++.dg/gomp/pr58702.C (revision 0)
+++ testsuite/g++.dg/gomp/pr58702.C (working copy)
@@ -0,0 +1,10 @@
+// PR c++/58702
+// { dg-do compile }
+// { dg-options "-fopenmp" }
+
+void foo()
+{
+  x;   // { dg-error "was not declared" }
+#pragma omp parallel for reduction(+:x)
+  for (int i = 0; i < 10; ++i) ;
+}


Re: [C++ Patch] PR 58072

2014-01-29 Thread Jakub Jelinek
On Wed, Jan 29, 2014 at 01:29:53PM +0100, Paolo Carlini wrote:
> a very simple ICE on invalid regression present only in mainline.
> Tested x86_64-linux.
> 
> Thanks,
> Paolo.
> 
> ///

> /cp
> 2014-01-29  Paolo Carlini  
> 
>   PR c++/58072
>   * semantics.c (finish_omp_reduction_clause): Check type for
>   error_mark_node.
> 
> /testsuite
> 2014-01-29  Paolo Carlini  
> 
>   PR c++/58072
>   * g++.dg/gomp/pr58702.C: New.

This is ok, thanks.

Jakub


Re: [PATCH] Fix handling of context diff patches in mklog

2014-01-29 Thread Diego Novillo
On Wed, Jan 22, 2014 at 9:36 AM, Yury Gribov  wrote:

> Ok to commit?

OK. Thanks.


Diego.


Re: [ARM] add armv7ve support

2014-01-29 Thread Kyrill Tkachov

Okay for trunk?
This is Ok since this was submitted quite sometime back.


Hi all,

I've committed this as r207237 with slightly fixed ChangeLog entries:

2014-01-29  Renlin Li  

* config/arm/arm-arches.def (ARM_ARCH): Add armv7ve arch.
* config/arm/arm.c (FL_FOR_ARCH7VE): New.
(arm_file_start): Generate correct asm header for armv7ve.
* config/arm/bpabi.h: Add multilib support for armv7ve.
* config/arm/driver-arm.c: Change the architectures of cortex-a7
and cortex-a15 to armv7ve.
* config/arm/t-aprofile: Add multilib support for armv7ve.
* doc/invoke.texi: Document -march=armv7ve.

2014-01-29  Renlin Li  

* gcc.target/arm/ftest-armv7ve-arm.c: New.
* gcc.target/arm/ftest-armv7ve-thumb.c: New.
* lib/target-supports.exp: New armfunc, armflag and armdef for armv7ve.


Kyrill



Re: PATCH: PR target/59672: Add -m16 support for x86

2014-01-29 Thread H.J. Lu
On Wed, Jan 29, 2014 at 1:52 AM, Richard Biener  wrote:
> On Tue, 28 Jan 2014, Uros Bizjak wrote:
>
>> On Mon, Jan 27, 2014 at 8:44 PM, H.J. Lu  wrote:
>>
>> > The .code16gcc directive was added to binutils back in 1999:
>> >
>> > ---
>> >'.code16gcc' provides experimental support for generating 16-bit code
>> > from gcc, and differs from '.code16' in that 'call', 'ret', 'enter',
>> > 'leave', 'push', 'pop', 'pusha', 'popa', 'pushf', and 'popf'
>> > instructions default to 32-bit size.  This is so that the stack pointer
>> > is manipulated in the same way over function calls, allowing access to
>> > function parameters at the same stack offsets as in 32-bit mode.
>> > '.code16gcc' also automatically adds address size prefixes where
>> > necessary to use the 32-bit addressing modes that gcc generates.
>> > ---
>> >
>> > It encodes 32-bit assembly instructions generated by GCC in 16-bit format
>> >  so that GCC can be used to generate 16-bit instructions.  To do that, the
>> >  .code16gcc directive may be placed at the very beginning of the assembly
>> >  code.  This patch adds -m16 to x86 backend by:
>> >
>> > 1. Add -m16 and make it mutually exclusive with -m32, -m64 and -mx32.
>> > 2. Treat -m16 like -m32 so that --32 is passed to assembler.
>> > 3. Output .code16gcc at the very beginning of the assembly code.
>> > 4. Turn off 64-bit ISA when -m16 is used.
>> >
>> > Tested on Linux/x86 and Linux/x86-64.  OK for trunk?
>> >
>> > Thanks.
>> >
>> > H.J.
>> > ---
>> > PR target/59672
>> > * config/i386/gnu-user64.h (SPEC_32): Add "m16|" to "m32".
>> > (SPEC_X32): Likewise.
>> > (SPEC_64): Likewise.
>> > * config/i386/i386.c (ix86_option_override_internal): Turn off
>> > OPTION_MASK_ISA_64BIT, OPTION_MASK_ABI_X32 and OPTION_MASK_ABI_64
>> > for TARGET_16BIT.
>> > (x86_file_start): Output .code16gcc for TARGET_16BIT.
>> > * config/i386/i386.h (TARGET_16BIT): New macro.
>> > (TARGET_16BIT_P): Likewise.
>> > * config/i386/i386.opt: Add m16.
>> > * doc/invoke.texi: Document -m16.
>>
>> OK for mainline, needs OK from RMs for a backport.
>
> I don't think this is suitable for the branch.  Unless there is
> tremendous need for it somewhere ...?  I like the suggested

Linux kernel people want it and clang has it.

> addition of a --code16gcc assembler flag.  Please make sure to
> document the minimum required binutils to make this work.
>

Since the .code16gcc directive was added to binutils back in 1999,
it is older than the minimum binutils required for x86 GCC.  There
is no need to specify a separate minimum binutils for it.

-- 
H.J.


Re: [PATCH][C] Fix PR59905, remove code replacing calls with abort

2014-01-29 Thread Richard Biener
On Wed, 29 Jan 2014, Richard Biener wrote:

> 
> This removes the code that tries to avoid ICEs in the middle-end when
> facing calls through an incompatible type.  The middle-end can now
> happily deal with those mismatches (and we rely on that).  Also the
> code only detects the most primitive cases like
> 
>   ((bar_get_x_func*) foo_get_x) (x)
> 
> but does not touch
> 
>   bar_get_x_func* fn = foo_get_x;
>   fn (x);
> 
> I preserved the warning (so I didn't have to remove the cast-function-1.c
> testcase) and fixed the testcase to be not optimized to nothing by the
> very first DCE pass and thus get non-empty assembler output with
> some calls and some inlines (yes, we _can_ inline some mismatches,
> esp. those refered to in the PR which is about void * vs some
> struct * type).
> 
> Bootstrap / regtest running on x86_64-unknown-linux-gnu - ok for trunk?

testing reveals diagnostic regressions

FAIL: gcc.dg/call-diag-2.c abort (test for warnings, line 12)
FAIL: gcc.dg/call-diag-2.c abort (test for warnings, line 15)
FAIL: gcc.dg/invalid-call-1.c  (test for warnings, line 16)

which may be hard to preserve (didn't investigate thoroughly yet),
one is probably emitted via the call to require_complete_type
I remove.

Is it ok to adjust the testcases expectation for what is produced now?
Otherwise I'll dump this patch for now.

Thanks,
Richard.

> Thanks,
> Richard.
> 
> 2014-01-29  Richard Biener  
> 
>   PR c/59905
>   * c-typeck.c (build_function_call_vec): Do not replace calls
>   to a function via an incompatible type with a runtime abort.
> 
>   * gcc.dg/cast-function-1.c: Adjust to survive DCE.
> 
> Index: gcc/c/c-typeck.c
> ===
> *** gcc/c/c-typeck.c  (revision 207194)
> --- gcc/c/c-typeck.c  (working copy)
> *** build_function_call_vec (location_t loc,
> *** 2907,2962 
>   return error_mark_node;
>   
> /* Check that the function is called through a compatible prototype.
> !  If it is not, replace the call by a trap, wrapped up in a compound
> !  expression if necessary.  This has the nice side-effect to prevent
> !  the tree-inliner from generating invalid assignment trees which may
> !  blow up in the RTL expander later.  */
> if (CONVERT_EXPR_P (function)
> && TREE_CODE (tem = TREE_OPERAND (function, 0)) == ADDR_EXPR
> && TREE_CODE (tem = TREE_OPERAND (tem, 0)) == FUNCTION_DECL
> && !comptypes (fntype, TREE_TYPE (tem)))
>   {
> tree return_type = TREE_TYPE (fntype);
> -   tree trap = build_function_call (loc,
> -builtin_decl_explicit (BUILT_IN_TRAP),
> -NULL_TREE);
> -   int i;
>   
> /* This situation leads to run-time undefined behavior.  We can't,
>therefore, simply error unless we can prove that all possible
>executions of the program must execute the code.  */
> !   if (warning_at (loc, 0, "function called through a non-compatible 
> type"))
> ! /* We can, however, treat "undefined" any way we please.
> !Call abort to encourage the user to fix the program.  */
> ! inform (loc, "if this code is reached, the program will abort");
> !   /* Before the abort, allow the function arguments to exit or
> !  call longjmp.  */
> !   for (i = 0; i < nargs; i++)
> ! trap = build2 (COMPOUND_EXPR, void_type_node, (*params)[i], trap);
>   
> !   if (VOID_TYPE_P (return_type))
> ! {
> !   if (TYPE_QUALS (return_type) != TYPE_UNQUALIFIED)
> ! pedwarn (loc, 0,
> !  "function with qualified void return type called");
> !   return trap;
> ! }
> !   else
> ! {
> !   tree rhs;
> ! 
> !   if (AGGREGATE_TYPE_P (return_type))
> ! rhs = build_compound_literal (loc, return_type,
> !   build_constructor (return_type,
> ! NULL),
> !   false);
> !   else
> ! rhs = build_zero_cst (return_type);
> ! 
> !   return require_complete_type (build2 (COMPOUND_EXPR, return_type,
> ! trap, rhs));
> ! }
> ! }
>   
> argarray = vec_safe_address (params);
>   
> --- 2907,2930 
>   return error_mark_node;
>   
> /* Check that the function is called through a compatible prototype.
> !  If it is not, warn.  */
> if (CONVERT_EXPR_P (function)
> && TREE_CODE (tem = TREE_OPERAND (function, 0)) == ADDR_EXPR
> && TREE_CODE (tem = TREE_OPERAND (tem, 0)) == FUNCTION_DECL
> && !comptypes (fntype, TREE_TYPE (tem)))
>   {
> tree return_type = TREE_TYPE (fntype);
>   
> /* This situation leads to run-time undefined behavior.  We can't,
>therefore, simply error unless we can prove that all possible
>executions of the program must

Re: Do not produce empty try-finally statements

2014-01-29 Thread Michael Matz
Hi,

On Tue, 28 Jan 2014, Jan Hubicka wrote:

> It is also problem of inliner quality decisions and memory use/compile 
> time. The in-memory representation of unnecesary EH is quite big.
> 
> I am quite ignorant in this area, but for -O0 can't we simply disable 
> all clobbers?

That sounds reasonable, yeah.


Ciao,
Michael.


Re: Do not produce empty try-finally statements

2014-01-29 Thread Jakub Jelinek
On Wed, Jan 29, 2014 at 03:06:45PM +0100, Michael Matz wrote:
> Hi,
> 
> On Tue, 28 Jan 2014, Jan Hubicka wrote:
> 
> > It is also problem of inliner quality decisions and memory use/compile 
> > time. The in-memory representation of unnecesary EH is quite big.
> > 
> > I am quite ignorant in this area, but for -O0 can't we simply disable 
> > all clobbers?
> 
> That sounds reasonable, yeah.

Don't we need stack sharing even for -O0?  Otherwise we could end up with
too big stack frames in some cases.
Running ehcleanup1 for -O0, even if limited to just removal of clobbers,
seems better to me.

Jakub


[PATCH] Bump LTO bytecode revision

2014-01-29 Thread Richard Biener

This bumps (very late ...) the LTO bytecode revision from 2, 2
to 3, 0 (leaves us bumps of the minor version for the 4.8 branch
if necessary).  I plan to do the next bump at the point we branch
for stage1.

Committed.

Richard.

2014-01-29  Richard Biener  

* lto-streamer.h (LTO_major_version): Bump to 3.
(LTO_minor_version): Reset to 0.

Index: gcc/lto-streamer.h
===
--- gcc/lto-streamer.h  (revision 207234)
+++ gcc/lto-streamer.h  (working copy)
@@ -140,8 +140,8 @@ along with GCC; see the file COPYING3.
sections a '.' and the section type are appended.  */
 #define LTO_SECTION_NAME_PREFIX ".gnu.lto_"
 
-#define LTO_major_version 2
-#define LTO_minor_version 2
+#define LTO_major_version 3
+#define LTO_minor_version 0
 
 typedef unsigned char  lto_decl_flags_t;
 


Re: Do not produce empty try-finally statements

2014-01-29 Thread Eric Botcazou
> That sounds reasonable, yeah.

But that will badly regress the stack usage, won't it?  If so, that's a 
blocker for Ada where we have big temporaries.

-- 
Eric Botcazou


Re: Do not produce empty try-finally statements

2014-01-29 Thread Eric Botcazou
> But that will badly regress the stack usage, won't it?  If so, that's a
> blocker for Ada where we have big temporaries.

For example this will presumably cause gnat.dg/stack_usage1.adb to fail.

-- 
Eric Botcazou


[C++ Patch] PR 58674

2014-01-29 Thread Paolo Carlini

Hi,

fix another simple ICE on invalid regression (the ICE is in 
get_innermost_template_args). Tested x86_64-linux.


Thanks,
Paolo.

PS: happens in 4_8-branch too but I don't think it's worth backporting.

/
/cp
2014-01-29  Paolo Carlini  

PR c++/58674
* pt.c (instantiate_template_1): Check for error_mark_node the second
argument too.

/testsuite
2014-01-29  Paolo Carlini  

PR c++/58674
* g++.dg/cpp0x/pr58674.C: New.
Index: cp/pt.c
===
--- cp/pt.c (revision 207234)
+++ cp/pt.c (working copy)
@@ -15258,6 +15258,9 @@ instantiate_template_1 (tree tmpl, tree orig_args,
   return NULL_TREE;
 }
 
+  if (targ_ptr == error_mark_node)
+return error_mark_node;
+
   /* Check to see if we already have this specialization.  */
   gen_tmpl = most_general_template (tmpl);
   if (tmpl != gen_tmpl)
Index: testsuite/g++.dg/cpp0x/pr58674.C
===
--- testsuite/g++.dg/cpp0x/pr58674.C(revision 0)
+++ testsuite/g++.dg/cpp0x/pr58674.C(working copy)
@@ -0,0 +1,18 @@
+// PR c++/58674
+// { dg-do compile { target c++11 } }
+
+template struct A {};
+
+template using B = A;
+
+template struct C
+{
+  B b;  // { dg-error "not usable" }
+};
+
+struct X
+{
+  static const int i;
+};
+
+C c;


[PATCH] Fix remainder of PR58742

2014-01-29 Thread Richard Biener

This fixes the rest, adding p + (q - p) pattern matching and
(p + o1) + o2 associating (similar to the fold-const code).

And it adds testcases for the whole series.

Bootstrapped and tested on x86_64-unknown-linux-gnu and applied.

Richard.

2014-01-29  Richard Biener  

PR tree-optimization/58742
* tree-ssa-forwprop.c (associate_pointerplus): Rename to
associate_pointerplus_align.
(associate_pointerplus_diff): New function.
(associate_pointerplus): Likewise.  Call associate_pointerplus_align
and associate_pointerplus_diff.

* gcc.dg/pr58742-1.c: New testcase.
* gcc.dg/pr58742-2.c: Likewise.
* gcc.dg/pr58742-3.c: Likewise.

Index: gcc/tree-ssa-forwprop.c
===
*** gcc/tree-ssa-forwprop.c (revision 207234)
--- gcc/tree-ssa-forwprop.c (working copy)
*** out:
*** 2802,2808 
 true if anything changed, false otherwise.  */
  
  static bool
! associate_pointerplus (gimple_stmt_iterator *gsi)
  {
gimple stmt = gsi_stmt (*gsi);
gimple def_stmt;
--- 2802,2808 
 true if anything changed, false otherwise.  */
  
  static bool
! associate_pointerplus_align (gimple_stmt_iterator *gsi)
  {
gimple stmt = gsi_stmt (*gsi);
gimple def_stmt;
*** associate_pointerplus (gimple_stmt_itera
*** 2848,2853 
--- 2848,2950 
update_stmt (stmt);
  
return true;
+ }
+ 
+ /* Associate operands of a POINTER_PLUS_EXPR assignmen at *GSI.  Returns
+true if anything changed, false otherwise.  */
+ 
+ static bool
+ associate_pointerplus_diff (gimple_stmt_iterator *gsi)
+ {
+   gimple stmt = gsi_stmt (*gsi);
+   gimple def_stmt;
+   tree ptr1, rhs;
+ 
+   /* Pattern match
+tem1 = (long) ptr1;
+tem2 = (long) ptr2;
+tem3 = tem2 - tem1;
+tem4 = (unsigned long) tem3;
+tem5 = ptr1 + tem4;
+  and produce
+tem5 = ptr2;  */
+   ptr1 = gimple_assign_rhs1 (stmt);
+   rhs = gimple_assign_rhs2 (stmt);
+   if (TREE_CODE (rhs) != SSA_NAME)
+ return false;
+   gimple minus = SSA_NAME_DEF_STMT (rhs);
+   /* Conditionally look through a sign-changing conversion.  */
+   if (is_gimple_assign (minus)
+   && CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (minus))
+   && (TYPE_PRECISION (TREE_TYPE (gimple_assign_rhs1 (minus)))
+ == TYPE_PRECISION (TREE_TYPE (rhs)))
+   && TREE_CODE (gimple_assign_rhs1 (minus)) == SSA_NAME)
+ minus = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (minus));
+   if (!is_gimple_assign (minus))
+ return false;
+   if (gimple_assign_rhs_code (minus) != MINUS_EXPR)
+ return false;
+   rhs = gimple_assign_rhs2 (minus);
+   if (TREE_CODE (rhs) != SSA_NAME)
+ return false;
+   def_stmt = SSA_NAME_DEF_STMT (rhs);
+   if (!is_gimple_assign (def_stmt)
+   || ! CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt))
+   || gimple_assign_rhs1 (def_stmt) != ptr1)
+ return false;
+   rhs = gimple_assign_rhs1 (minus);
+   if (TREE_CODE (rhs) != SSA_NAME)
+ return false;
+   def_stmt = SSA_NAME_DEF_STMT (rhs);
+   if (!is_gimple_assign (def_stmt)
+   || ! CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt)))
+ return false;
+   rhs = gimple_assign_rhs1 (def_stmt);
+   if (! useless_type_conversion_p (TREE_TYPE (ptr1), TREE_TYPE (rhs)))
+ return false;
+ 
+   gimple_assign_set_rhs_with_ops (gsi, TREE_CODE (rhs), rhs, NULL_TREE);
+   update_stmt (stmt);
+ 
+   return true;
+ }
+ 
+ /* Associate operands of a POINTER_PLUS_EXPR assignmen at *GSI.  Returns
+true if anything changed, false otherwise.  */
+ 
+ static bool
+ associate_pointerplus (gimple_stmt_iterator *gsi)
+ {
+   gimple stmt = gsi_stmt (*gsi);
+   gimple def_stmt;
+   tree ptr, off1, off2;
+ 
+   if (associate_pointerplus_align (gsi)
+   || associate_pointerplus_diff (gsi))
+ return true;
+ 
+   /* Associate (p +p off1) +p off2 as (p +p (off1 + off2)).  */
+   ptr = gimple_assign_rhs1 (stmt);
+   off1 = gimple_assign_rhs2 (stmt);
+   if (TREE_CODE (ptr) != SSA_NAME)
+ return false;
+   def_stmt = SSA_NAME_DEF_STMT (ptr);
+   if (!is_gimple_assign (def_stmt)
+   || gimple_assign_rhs_code (def_stmt) != POINTER_PLUS_EXPR)
+ return false;
+   ptr = gimple_assign_rhs1 (def_stmt);
+   off2 = gimple_assign_rhs2 (def_stmt);
+   if (!types_compatible_p (TREE_TYPE (off1), TREE_TYPE (off2)))
+ return false;
+ 
+   tree off = make_ssa_name (TREE_TYPE (off1), NULL);
+   gimple ostmt = gimple_build_assign_with_ops (PLUS_EXPR, off, off1, off2);
+   gsi_insert_before (gsi, ostmt, GSI_SAME_STMT);
+ 
+   gimple_assign_set_rhs_with_ops (gsi, POINTER_PLUS_EXPR, ptr, off);
+   update_stmt (stmt);
+ 
+   return true;
  }
  
  /* Combine two conversions in a row for the second conversion at *GSI.
Index: gcc/testsuite/gcc.dg/pr58742-1.c
===
*** gcc/testsuite/gcc.dg/pr58742-1.c(revision 0)
--- g

Re: Fwd: [RFC][gomp4] Offloading patches (2/3): Add tables generation

2014-01-29 Thread Bernd Schmidt

On 01/28/2014 01:52 PM, Ilya Verbin wrote:

The table is used in libgomp (see my patch [1]), as proposed by Jakub
(see [2]).  The idea is that the order of entries in the host and
target tables must be identical.  This allows to set up one-to-one
correspondence between host and target addresses.


I was worried the answer was going to be something like this. These are 
produced by two different compilers/linkers, aren't they? This seems 
really fragile to me and a recipe for hard-to-debug silent failures.


For ptx, I think we can create both tables at the same time in the 
image-generating tool, so I'm hoping that it won't be a problem. I'll 
let you know what I find, but it would still be nice to come up with 
something more robust.



Could you please describe how functions would be invoked on
PTX?


First we let the driver compile and load all the ptx code, then we'd 
call a cuda library function with the name of the function passed as a 
string. So I guess the host table would contain pointers to the host 
version of the functions, and the target table would contain a pointer 
to the name.



Bernd



Re: PATCH: PR target/59672: Add -m16 support for x86

2014-01-29 Thread Alexander Monakov

On Wed, 29 Jan 2014, H.J. Lu wrote:
> Since the .code16gcc directive was added to binutils back in 1999,
> it is older than the minimum binutils required for x86 GCC.  There
> is no need to specify a separate minimum binutils for it.

It's not clear to me why the compiler should be involved in providing this
functionality.  Can the assembler simply support '-mcode16gcc' command-line
flag, which would have the effect of enabling .code16gcc for the whole
translation unit?  That way, you could simply add -Wa,-mcode16gcc to the GCC
command line and avoid the need to patch the compiler.  Am I missing
something?

Thanks.

Alexander


Re: Do not produce empty try-finally statements

2014-01-29 Thread Michael Matz
Hi,

On Wed, 29 Jan 2014, Jakub Jelinek wrote:

> > > It is also problem of inliner quality decisions and memory 
> > > use/compile time. The in-memory representation of unnecesary EH is 
> > > quite big.
> > > 
> > > I am quite ignorant in this area, but for -O0 can't we simply 
> > > disable all clobbers?
> > 
> > That sounds reasonable, yeah.
> 
> Don't we need stack sharing even for -O0?  Otherwise we could end up with
> too big stack frames in some cases.

Well, where to draw the line?  Using -O0 could also end up with too slow 
code in some cases, still we don't enable optimizations.

> Running ehcleanup1 for -O0, even if limited to just removal of clobbers,
> seems better to me.

OTOH -O0 is also supposed to be quick compilation...  Well, I have no hard 
opinions there.


Ciao,
Michael.


[patch] fix a couple of std::allocator_traits bugs

2014-01-29 Thread Jonathan Wakely

std::allocator_traits::allocate(a, n, hint) could fail to compile
if the const_void_pointer passed as the hint was a non-trivial type,
because it was passed to a varargs function.

std::vector was not using std::allocator_traits for calls to
A::allocate and A::deallocate.

Also remove some redundant conditions in std::vector and _Rb_tree and
in allocator_traits simplify SFINAE uses and use true_type / false_type
to avoid needing definitions for static const bool members.

I added PointerBase to testsuite_allocator.h to help create custom
pointer types for testing because it's non-trivial to define the whole
thing every time you need one. There's also a new test to verify the
allocator_traits typedefs are correct.

Tested x86_64-linux, committed to trunk.
(I didn't fix up some dg-error line numbers relating to stl_vector.h
because I'm also committing another patch that changes them again, so
I only did it once.)

   * include/bits/alloc_traits.h (allocator_traits::_S_allocate): Do
   not use varargs when argument could be non-POD.
   (__alloctr_rebind_helper): Eliminate static const bool member by
   using true_type and false_type.
   (allocator_traits::__allocate_helper): Likewise.
   (allocator_traits::__construct_helper): Likewise.
   (allocator_traits::__destroy_helper): Likewise.
   (allocator_traits::__maxsize_helper): Likewise.
   (allocator_traits::__select_helper): Likewise.
   * include/bits/ptr_traits.h (__ptrtr_rebind_helper): Likewise.
   * include/bits/stl_tree.h (_Rb_tree::operator=(const _Rb_tree&)):
   Remove redundant condition.
   * include/bits/stl_vector.h (vector::operator=(const vector&)):
   Likewise.
   (_Vector_impl::_M_allocate, _Vector_impl::_M_deallocate): Use
   indirection through __alloc_traits.
   * include/ext/alloc_traits.h (__allocator_always_compares_equal):
   Eliminate static const bool members by using true_type and false_type.
   (__gnu_cxx::__alloc_traits::__is_custom_pointer): Optimize.
   * testsuite/util/testsuite_allocator.h (PointerBase): Define.
   * testsuite/20_util/allocator_traits/members/allocate_hint_nonpod.cc:
   New.
   * testsuite/20_util/allocator_traits/requirements/typedefs2.cc: New.

commit fa11899fe418aaee495c5fd3ed4215a9df319e33
Author: Jonathan Wakely 
Date:   Tue Apr 16 22:19:59 2013 +0100

* include/bits/alloc_traits.h (allocator_traits::_S_allocate): Do
not use varargs when argument could be non-POD.
(__alloctr_rebind_helper): Eliminate static const bool member by
using true_type and false_type.
(allocator_traits::__allocate_helper): Likewise.
(allocator_traits::__construct_helper): Likewise.
(allocator_traits::__destroy_helper): Likewise.
(allocator_traits::__maxsize_helper): Likewise.
(allocator_traits::__select_helper): Likewise.
* include/bits/ptr_traits.h (__ptrtr_rebind_helper): Likewise.
* include/bits/stl_tree.h (_Rb_tree::operator=(const _Rb_tree&)):
Remove redundant condition.
* include/bits/stl_vector.h (vector::operator=(const vector&)):
Likewise.
(_Vector_impl::_M_allocate, _Vector_impl::_M_deallocate): Use
indirection through __alloc_traits.
* include/ext/alloc_traits.h (__allocator_always_compares_equal):
Eliminate static const bool members by using true_type and false_type.
(__gnu_cxx::__alloc_traits::__is_custom_pointer): Optimize.
* testsuite/util/testsuite_allocator.h (PointerBase): Define.
* testsuite/20_util/allocator_traits/members/allocate_hint_nonpod.cc:
New.
* testsuite/20_util/allocator_traits/requirements/typedefs2.cc: New.

diff --git a/libstdc++-v3/include/bits/alloc_traits.h 
b/libstdc++-v3/include/bits/alloc_traits.h
index 86ed222..23fe8de 100644
--- a/libstdc++-v3/include/bits/alloc_traits.h
+++ b/libstdc++-v3/include/bits/alloc_traits.h
@@ -44,24 +44,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 class __alloctr_rebind_helper
 {
   template
-   static constexpr bool
-   _S_chk(typename _Alloc2::template rebind<_Tp2>::other*)
-   { return true; }
+   static constexpr true_type
+   _S_chk(typename _Alloc2::template rebind<_Tp2>::other*);
 
   template
-static constexpr bool
-   _S_chk(...)
-   { return false; }
+   static constexpr false_type
+   _S_chk(...);
 
 public:
-  static const bool __value = _S_chk<_Alloc, _Tp>(nullptr);
+  using __type = decltype(_S_chk<_Alloc, _Tp>(nullptr));
 };
 
-  template
-const bool __alloctr_rebind_helper<_Alloc, _Tp>::__value;
-
   template::__value>
+  bool = __alloctr_rebind_helper<_Alloc, _Tp>::__type::value>
 struct __alloctr_rebind;
 
   template
@@ -71,7 +66,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 };
 
   template class _Alloc, typename _Tp,
-typename _Up, typename... _Args>
+

[C++ Patch] PR 58846

2014-01-29 Thread Paolo Carlini

Hi,

a very minor ICE on invalid regression, but since we explicitly allow 
for redeclarations (also see comments in declare_global_var) we may as 
well avoid crashing, at least in mainline. Tested x86_64-linux.


Thanks,
Paolo.

/
/cp
2014-01-29  Paolo Carlini  

PR c++/58846
* decl.c (get_dso_handle_node): Don't crash if dso_handle_node
== error_mark_node.

/testsuite
2014-01-29  Paolo Carlini  

PR c++/58846
* g++.dg/init/dso_handle2.C: New.
Index: cp/decl.c
===
--- cp/decl.c   (revision 207234)
+++ cp/decl.c   (working copy)
@@ -6709,8 +6709,11 @@ get_dso_handle_node (void)
ptr_type_node);
 
 #ifdef HAVE_GAS_HIDDEN
-  DECL_VISIBILITY (dso_handle_node) = VISIBILITY_HIDDEN;
-  DECL_VISIBILITY_SPECIFIED (dso_handle_node) = 1;
+  if (dso_handle_node != error_mark_node)
+{
+  DECL_VISIBILITY (dso_handle_node) = VISIBILITY_HIDDEN;
+  DECL_VISIBILITY_SPECIFIED (dso_handle_node) = 1;
+}
 #endif
 
   return dso_handle_node;
Index: testsuite/g++.dg/init/dso_handle2.C
===
--- testsuite/g++.dg/init/dso_handle2.C (revision 0)
+++ testsuite/g++.dg/init/dso_handle2.C (working copy)
@@ -0,0 +1,10 @@
+// PR c++/58846
+
+extern "C" { char* __dso_handle; }
+
+struct A
+{
+  ~A();
+};
+
+A a;  // { dg-error "conflicting declaration" }


[Ada] Generated name of task that is a record component

2014-01-29 Thread Arnaud Charlet
This patch removes a spurious initialization on the string that builds the
name of task that is a record component, when Initialize_Scalars is enabled.
This is both efficient, and prevents anomalies in the handling of dynamic
objects on the secondary stack, that would result in a mangled name for such
a task.

The following commands:

   gnatmake -q -O1 p.adb
   p

must yield:

   where.container.a_tt_000100800E00

---
with Alloc;
procedure P is
begin
   Alloc.Alloc_One (1);
end;
---
package Alloc is
   procedure Alloc_One (Index : Integer);
end;
---
with CC; use CC;
package body Alloc is
   type Container_Pointer is access all Container;

   type Container_With_Ref_Count_Type is record
  Container : Container_Pointer;
  Ref_Count : Natural;
   end record;

   Containers : array (1 .. 3) of Container_With_Ref_Count_Type
 := (others => (null, 0));

   procedure Alloc_One (Index : Integer) is
  Where : Container_With_Ref_Count_Type renames Containers (Index);
   begin
  Where.Container := new Container;
   end;
end;
---
with Ada.Task_Identification; use Ada.Task_Identification;
with Ada.Text_IO; use Ada.Text_IO;
package body CC is
   task body TT is
   begin
  Put_Line (Image (Current_Task));
  delay 1.0;
   end;
end;
---
package CC is
   type Container;
   task type TT (C : not null access Container); 
   type Container is limited record
  A_TT : TT (Container'Access);
   end record;
end;
---
pragma Initialize_Scalars;
---

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-29  Ed Schonberg  

* exp_util.adb (Build_Task_Image_Prefix): Indicate that the
resulting string is an internal entity. and thus requires no
initialization. This is relevant when Initialize_ Scalars is
enabled, because the resultant spurious initialization may lead to
secondary stack anomalies that produce a mangled name for a task.

Index: exp_util.adb
===
--- exp_util.adb(revision 207241)
+++ exp_util.adb(working copy)
@@ -1403,6 +1403,12 @@
  Low_Bound => Make_Integer_Literal (Loc, 1),
  High_Bound => New_Occurrence_Of (Len, Loc)));
 
+  --  Indicate that the result is an internal temporary, so it does not
+  --  receive a bogus initialization when declaration is expanded. This
+  --  is both efficient, and prevents anomalies in the handling of
+  --  dynamic objects on the secondary stack.
+
+  Set_Is_Internal (Res);
   Pos := Make_Temporary (Loc, 'P');
 
   Append_To (Decls,


[Ada] Implement new rules for pragma SPARK_Mode

2014-01-29 Thread Arnaud Charlet
The rules for pragma SPARK_Mode have changed. In particular, the mode
is not inherited anymore from a the spec to the body, and the body
should not have a mode if the spec did not have one. These new rules
are checked now. A minor change is that SPARK_Mode is set even on
subprograms for which Comes_From_Source returns False (including
internal subprograms), as we need this information on subprograms
from instances of generics.

The following test now generates an error:

 1. package SPARKcode is
 2.pragma SPARK_Mode (On);
 3.procedure P1;
 4.procedure P2 with SPARK_Mode => On;
 5.procedure P3 with SPARK_Mode => Off;
 6. end SPARKcode;

 1. package body SPARKcode is
 2.pragma SPARK_Mode (On);
 3.procedure P1 is begin null; end;
 4.procedure P2 is begin null; end;
 5.procedure P3 is begin null; end;
   |
>>> incorrect application of SPARK_Mode at line 2
>>> value Off was set for SPARK_Mode on "P3" at sparkcode.ads:5

 6. end SPARKcode;

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-29  Yannick Moy  

* sem_ch6.adb (Analyze_Subprogram_Body_Helper): SPARK_Mode
not inherited from spec anymore. Check consistency
rules after processing of declarations.
* sem_ch7.adb (Analyze_Package_Body_Helper): SPARK_Mode not inherited
from spec anymore. Check consistency rules after processing of
declarations.
(Analyze_Package_Declaration): Set SPARK_Mode only for non-generic
packages.
* sem_prag.adb (Analyze_Pragma/Pragma_SPARK_Mode): Implement new
consistency rules.

Index: sem_ch7.adb
===
--- sem_ch7.adb (revision 207241)
+++ sem_ch7.adb (working copy)
@@ -346,29 +346,20 @@
 
   Push_Scope (Spec_Id);
 
-  --  Set SPARK_Mode from private part of spec if it has a SPARK pragma.
-  --  Note that in the default case, SPARK_Aux_Pragma will be a copy of
-  --  SPARK_Pragma in the spec, so this properly handles the case where
-  --  there is no explicit SPARK_Pragma mode in the private part.
+  --  Set SPARK_Mode only for non-generic package
 
-  if Present (SPARK_Pragma (Spec_Id)) then
- SPARK_Mode_Pragma := SPARK_Aux_Pragma (Spec_Id);
- SPARK_Mode := Get_SPARK_Mode_From_Pragma (SPARK_Mode_Pragma);
+  if Ekind (Spec_Id) = E_Package then
+ --  Set SPARK_Mode from context
+
  Set_SPARK_Pragma (Body_Id, SPARK_Mode_Pragma);
  Set_SPARK_Pragma_Inherited (Body_Id, True);
 
-  --  Otherwise set from context
+ --  Set elaboration code SPARK mode the same for now
 
-  else
- Set_SPARK_Pragma (Body_Id, SPARK_Mode_Pragma);
- Set_SPARK_Pragma_Inherited (Body_Id, True);
+ Set_SPARK_Aux_Pragma (Body_Id, SPARK_Pragma (Body_Id));
+ Set_SPARK_Aux_Pragma_Inherited (Body_Id, True);
   end if;
 
-  --  Set elaboration code SPARK mode the same for now
-
-  Set_SPARK_Aux_Pragma (Body_Id, SPARK_Pragma (Body_Id));
-  Set_SPARK_Aux_Pragma_Inherited (Body_Id, True);
-
   Set_Categorization_From_Pragmas (N);
 
   Install_Visible_Declarations (Spec_Id);
@@ -400,6 +391,32 @@
  Inspect_Deferred_Constant_Completion (Declarations (N));
   end if;
 
+  --  After declarations have been analyzed, the body has been set
+  --  its final value of SPARK_Mode. Check that SPARK_Mode for body
+  --  is consistent with SPARK_Mode for spec.
+
+  if Present (SPARK_Pragma (Body_Id)) then
+ if Present (SPARK_Aux_Pragma (Spec_Id)) then
+if Get_SPARK_Mode_From_Pragma (SPARK_Aux_Pragma (Spec_Id)) = Off
+ and then
+   Get_SPARK_Mode_From_Pragma (SPARK_Pragma (Body_Id)) = On
+then
+   Error_Msg_Sloc := Sloc (SPARK_Pragma (Body_Id));
+   Error_Msg_N ("incorrect application of SPARK_Mode#", N);
+   Error_Msg_Sloc := Sloc (SPARK_Aux_Pragma (Spec_Id));
+   Error_Msg_NE ("\value Off was set for SPARK_Mode on & #",
+ N, Spec_Id);
+end if;
+
+ else
+Error_Msg_Sloc := Sloc (SPARK_Pragma (Body_Id));
+Error_Msg_N ("incorrect application of SPARK_Mode#", N);
+Error_Msg_Sloc := Sloc (Spec_Id);
+Error_Msg_NE ("\no value was set for SPARK_Mode on & #",
+  N, Spec_Id);
+ end if;
+  end if;
+
   --  Analyze_Declarations has caused freezing of all types. Now generate
   --  bodies for RACW primitives and stream attributes, if any.
 
@@ -814,12 +831,14 @@
   Set_Etype(Id, Standard_Void_Type);
   Set_Contract (Id, Make_Contract (Sloc (Id)));
 
-  --  Inherit spark mode from context for now
+  --  Set SPARK_Mode from context only for non-generic package
 
-  Set_SPARK_Pragma   (Id, SPARK_Mode_Pragm

[Ada] Remove Complete_Single_Entry_Body

2014-01-29 Thread Arnaud Charlet
This procedure was empty, so no need to insert a call to it.
No functional change.

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-29  Tristan Gingold  

* exp_ch9.adb (Build_Protected_Entry): Do not call
Complete_Entry_Body anymore.
* rtsfind.ads (RE_Complete_Single_Entry_Body): Remove.
* s-tposen.ads, s-tposen.adb (Complete_Single_Entry_Body): Remove.

Index: exp_ch9.adb
===
--- exp_ch9.adb (revision 207246)
+++ exp_ch9.adb (working copy)
@@ -3847,9 +3847,10 @@
 Build_Protected_Entry_Specification (Loc, Edef, Empty);
 
   --  Add the following declarations:
+
   --type poVP is access poV;
   --_object : poVP := poVP (_O);
-  --
+
   --  where _O is the formal parameter associated with the concurrent
   --  object. These declarations are needed for Complete_Entry_Body.
 
@@ -3861,35 +3862,42 @@
   Add_Formal_Renamings (Espec, Op_Decls, Ent, Loc);
   Debug_Private_Data_Declarations (Decls);
 
+  --  Put the declarations and the statements from the entry
+
+  Op_Stats :=
+New_List (
+  Make_Block_Statement (Loc,
+Declarations => Decls,
+Handled_Statement_Sequence =>
+  Handled_Statement_Sequence (N)));
+
   case Corresponding_Runtime_Package (Pid) is
  when System_Tasking_Protected_Objects_Entries =>
-Complete :=
-  New_Reference_To (RTE (RE_Complete_Entry_Body), Loc);
+Append_To (Op_Stats,
+  Make_Procedure_Call_Statement (End_Loc,
+Name   =>
+  New_Reference_To (RTE (RE_Complete_Entry_Body), Loc),
+Parameter_Associations => New_List (
+  Make_Attribute_Reference (End_Loc,
+Prefix =>
+  Make_Selected_Component (End_Loc,
+Prefix=>
+  Make_Identifier (End_Loc, Name_uObject),
+Selector_Name =>
+  Make_Identifier (End_Loc, Name_uObject)),
+Attribute_Name => Name_Unchecked_Access;
 
  when System_Tasking_Protected_Objects_Single_Entry =>
-Complete :=
-  New_Reference_To (RTE (RE_Complete_Single_Entry_Body), Loc);
 
+--  Historically, a call to Complete_Single_Entry_Body was
+--  inserted, but it was a null procedure.
+
+null;
+
  when others =>
 raise Program_Error;
   end case;
 
-  Op_Stats := New_List (
-Make_Block_Statement (Loc,
-  Declarations => Decls,
-  Handled_Statement_Sequence =>
-Handled_Statement_Sequence (N)),
-
-Make_Procedure_Call_Statement (End_Loc,
-  Name => Complete,
-  Parameter_Associations => New_List (
-Make_Attribute_Reference (End_Loc,
-  Prefix =>
-Make_Selected_Component (End_Loc,
-  Prefix=> Make_Identifier (End_Loc, Name_uObject),
-  Selector_Name => Make_Identifier (End_Loc, Name_uObject)),
-  Attribute_Name => Name_Unchecked_Access;
-
   --  When exceptions can not be propagated, we never need to call
   --  Exception_Complete_Entry_Body
 
Index: rtsfind.ads
===
--- rtsfind.ads (revision 207241)
+++ rtsfind.ads (working copy)
@@ -1747,7 +1747,6 @@
  RE_Unlock_Entry,-- Protected_Objects.Single_Entry
  RE_Protected_Single_Entry_Call, -- Protected_Objects.Single_Entry
  RE_Service_Entry,   -- Protected_Objects.Single_Entry
- RE_Complete_Single_Entry_Body,  -- Protected_Objects.Single_Entry
  RE_Exceptional_Complete_Single_Entry_Body,
  RE_Protected_Count_Entry,   -- Protected_Objects.Single_Entry
  RE_Protected_Single_Entry_Caller,   -- Protected_Objects.Single_Entry
@@ -3057,8 +3056,6 @@
System_Tasking_Protected_Objects_Single_Entry,
  RE_Service_Entry=>
System_Tasking_Protected_Objects_Single_Entry,
- RE_Complete_Single_Entry_Body   =>
-   System_Tasking_Protected_Objects_Single_Entry,
  RE_Exceptional_Complete_Single_Entry_Body =>
System_Tasking_Protected_Objects_Single_Entry,
  RE_Protected_Count_Entry=>
Index: s-tposen.adb
===
--- s-tposen.adb(revision 207241)
+++ s-tposen.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 --B o d y   --
 --  --
--- Copyright (C) 1998-2009, Free Software Foundation

[Ada] Crash with big strings in System.OS_Lib.Normalize_Pathname

2014-01-29 Thread Arnaud Charlet
This patch prevents the copy of too big names to fixed-size buffers from
overflowing. Instead, when too big strings are provided, treat them as
invalid and return an empty string.

The execution of the following example must print "OK":

$ gnatmake foo && ./foo

with Ada.Text_IO; use Ada.Text_IO;
with GNAT.OS_Lib; use GNAT.OS_Lib;

procedure Foo is
   Max_Path : Integer;
   pragma Import (C, Max_Path, "__gnat_max_path_len");

   Valid_Path : String (1 .. Max_Path) :=
 (1 => '/', others => 'a');
   Invalid_Path : String (1 .. Max_Path + 1) :=
 (1 => '/', others => 'a');
begin
   if Normalize_Pathname (Valid_Path) /= ""
  and then
  Normalize_Pathname (Invalid_Path) = ""
   then
  Put_Line ("OK");
   else
  Put_Line ("FAIL");
   end if;
end Foo;

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-29  Pierre-Marie Derodat  

* s-os_lib.adb, s-os_lib.ads (Normalize_Pathname): Return an empty
string when the Name input bigger than allowed. Adapt the function
specification.

Index: s-os_lib.adb
===
--- s-os_lib.adb(revision 207241)
+++ s-os_lib.adb(working copy)
@@ -1927,9 +1927,10 @@
--  Start of processing for Normalize_Pathname
 
begin
-  --  Special case, if name is null, then return null
+  --  Special case, return null if name is null, or if it is bigger than
+  --  the biggest name allowed.
 
-  if Name'Length = 0 then
+  if Name'Length = 0 or else Name'Length > Max_Path then
  return "";
   end if;
 
Index: s-os_lib.ads
===
--- s-os_lib.ads(revision 207241)
+++ s-os_lib.ads(working copy)
@@ -445,9 +445,10 @@
--  directory pointed to. This is slightly less efficient, since it
--  requires system calls.
--
-   --  If Name cannot be resolved or is null on entry (for example if there is
-   --  symbolic link circularity, e.g. A is a symbolic link for B, and B is a
-   --  symbolic link for A), then Normalize_Pathname returns an empty  string.
+   --  If Name cannot be resolved, is invalid (for example if it is too big) or
+   --  is null on entry (for example if there is symbolic link circularity,
+   --  e.g. A is a symbolic link for B, and B is a symbolic link for A), then
+   --  Normalize_Pathname returns an empty string.
--
--  In VMS, if Name follows the VMS syntax file specification, it is first
--  converted into Unix syntax. If the conversion fails, Normalize_Pathname


Re: [patch] proposed fix for libstdc++/59829

2014-01-29 Thread Jonathan Wakely

On 27/01/14 23:37 +, Jonathan Wakely wrote:

On 27 January 2014 20:35, Jonathan Wakely wrote:

On 27 January 2014 20:12, Marc Glisse wrote:

On Mon, 27 Jan 2014, Jonathan Wakely wrote:


This is the best I've come up with to avoid dereferencing an invalid
pointer when calling vector::data() on an empty vector.

For C++03 we reurn the vector's pointer type, so can just return the
internal pointer, but for C++11 we need to convert that to a raw
pointer, which we do by dereferencing, so we must check if it's valid
first.



For comparison, libc++ has 2 paths. If pointer really is a pointer, it just
returns it, no need to pay for a comparison in that case. And otherwise, it
calls _M_start.operator-> and crosses its fingers. There is a helper
function doing that used throughout the library.


Ah yes, I remember Howard posting a get_raw_pointer() function to the
reflector that used operator->() on user-defined types ... I don't
really like calling that on a potentially invalid pointer though. The
user-defined pointer type in my new testcase could just as easily
throw if operator-> is called on an invalid pointer.  As Paolo also
mentioned avoiding the branch for built-in pointers I'll do that.


Here's what I'm committing, the testcase is simplified by reusing the
new PointerBase type I added to testsuite_allocator.h

Tested x86_64-linux, committed to trunk.
commit 36805f8b1b6ef6733c4e018ef005efb1575b75c6
Author: Jonathan Wakely 
Date:   Tue Jan 28 12:47:25 2014 +

PR libstdc++/59829
* include/bits/stl_vector.h (vector::data()): Call _M_data_ptr.
(vector::_M_data_ptr): New overloaded functions to ensure empty
vectors do not dereference the pointer.
* testsuite/23_containers/vector/59829.cc: New.
* testsuite/23_containers/vector/requirements/dr438/assign_neg.cc:
Adjust dg-error line number.
* testsuite/23_containers/vector/requirements/dr438/
constructor_1_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/
constructor_2_neg.cc: Likewise.
* testsuite/23_containers/vector/requirements/dr438/insert_neg.cc:
Likewise.

diff --git a/libstdc++-v3/include/bits/stl_vector.h 
b/libstdc++-v3/include/bits/stl_vector.h
index 98ac708..7e52fde 100644
--- a/libstdc++-v3/include/bits/stl_vector.h
+++ b/libstdc++-v3/include/bits/stl_vector.h
@@ -888,7 +888,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   pointer
 #endif
   data() _GLIBCXX_NOEXCEPT
-  { return std::__addressof(front()); }
+  { return _M_data_ptr(this->_M_impl._M_start); }
 
 #if __cplusplus >= 201103L
   const _Tp*
@@ -896,7 +896,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   const_pointer
 #endif
   data() const _GLIBCXX_NOEXCEPT
-  { return std::__addressof(front()); }
+  { return _M_data_ptr(this->_M_impl._M_start); }
 
   // [23.2.4.3] modifiers
   /**
@@ -1470,6 +1470,23 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
  }
   }
 #endif
+
+#if __cplusplus >= 201103L
+  template
+   _Up*
+   _M_data_ptr(_Up* __ptr) const
+   { return __ptr; }
+
+  template
+   typename std::pointer_traits<_Ptr>::element_type*
+   _M_data_ptr(_Ptr __ptr) const
+   { return empty() ? nullptr : std::__addressof(*__ptr); }
+#else
+  template
+   _Ptr
+   _M_data_ptr(_Ptr __ptr) const
+   { return __ptr; }
+#endif
 };
 
 
diff --git a/libstdc++-v3/testsuite/23_containers/vector/59829.cc 
b/libstdc++-v3/testsuite/23_containers/vector/59829.cc
new file mode 100644
index 000..1818c89
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/59829.cc
@@ -0,0 +1,67 @@
+// Copyright (C) 2014 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library 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 this library; see the file COPYING3.  If not see
+// .
+
+// { dg-options "-std=gnu++11" }
+
+// libstdc++/59829
+
+#include 
+#include 
+
+// User-defined pointer type that throws if a null pointer is dereferenced.
+template
+struct Pointer : __gnu_test::PointerBase, T>
+{
+  using __gnu_test::PointerBase, T>::PointerBase;
+
+  T& operator*() const
+  {
+if (!this->value)
+  throw "Dereferenced invalid pointer";
+return *this->value;
+  }
+};
+
+// Minimal allocator using Pointer
+template
+struct Alloc
+{
+  typedef T value_type;
+  typedef Pointer pointer;
+
+  Alloc() = default;

Re: [PING] Re: Add const char* constructors for exception classes in

2014-01-29 Thread Jonathan Wakely

On 26/01/14 15:15 +0100, Oleg Endo wrote:

Files in libstdc++-v3/src/c++98/ seem to be never compiled with C++11.
Thus I can think of two options:
1) Add const char* ctors for C++98 and C++11.
2) Add #ifdef'ed declarations to libstdc++-v3/include/std/stdexcept and
add a new file libstdc++-v3/src/c++11/stdexcept.cc with the
implementations.


3) Move stdexcept.cc from src/c++98 to src/c++11
4) Define the functions inline using forwarding constructors, which
   means we don't need new exports.


The attached patch does 1).


I don't think we want the constructors in C++03 mode though, it could
break some valid programs e.g. a custom string type with implicit
conversion to const char* and std::string can be passed to an exception
constructor in C++03, but adding the overloads would make it
ambiguous.

I think I prefer option 4, it avoids adding new exports during Stage 3
(although the patch was initially posted during Stage 1, it is now
quite late to add new exports, which is not your fault but still a
concern.)




[Ada] Analyze instance with SPARK_Mode at point of instantiation

2014-01-29 Thread Arnaud Charlet
A generic instance should be analyzed with the value of SPARK_Mode
defined at the point of instantiation. Now, the following code
compiles without errors:

$ gcc -c -gnatec=test.adc pinst.adb

--  test.adc
 1. pragma SPARK_Mode (On);

--  pinst.ads
 1. with Ada.Containers.Formal_Doubly_Linked_Lists;
 2. package Pinst is
 3.function Eq (X, Y : Integer) return Boolean is (X = Y);
 4.package My_Lists is new
 Ada.Containers.Formal_Doubly_Linked_Lists (Integer, Eq);
 5.procedure P;
 6. end Pinst;

--  pinst.adb
 1. package body Pinst is
 2.procedure P is begin null; end;
 3. end Pinst;

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-29  Yannick Moy  

* inline.ads (Pending_Body_Info): Add SPARK_Mode and
SPARK_Mode_Pragma components to be able to analyze generic
instance.
* sem_ch12.adb (Analyze_Package_Instantiation,
Inline_Instance_Body, Need_Subprogram_Instance_Body,
Load_Parent_Of_Generic): Pass in SPARK_Mode from instantiation
for future analysis of the instance.
(Instantiate_Package_Body,
Instantiate_Subprogram_Body, Set_Instance_Inv): Set SPARK_Mode
from instantiation to analyze the instance.

Index: inline.ads
===
--- inline.ads  (revision 207241)
+++ inline.ads  (working copy)
@@ -96,6 +96,11 @@
 
   Warnings : Warning_Record;
   --  Capture values of warning flags
+
+  SPARK_Mode: SPARK_Mode_Type;
+  SPARK_Mode_Pragma : Node_Id;
+  --  SPARK_Mode for an instance is the one applicable at the point of
+  --  instantiation.
end record;
 
package Pending_Instantiations is new Table.Table (
Index: sem_ch12.adb
===
--- sem_ch12.adb(revision 207241)
+++ sem_ch12.adb(working copy)
@@ -3899,7 +3899,9 @@
Local_Suppress_Stack_Top => Local_Suppress_Stack_Top,
Version  => Ada_Version,
Version_Pragma   => Ada_Version_Pragma,
-   Warnings => Save_Warnings));
+   Warnings => Save_Warnings,
+   SPARK_Mode   => SPARK_Mode,
+   SPARK_Mode_Pragma=> SPARK_Mode_Pragma));
 end if;
  end if;
 
@@ -4245,7 +4247,9 @@
Local_Suppress_Stack_Top => Local_Suppress_Stack_Top,
Version  => Ada_Version,
Version_Pragma   => Ada_Version_Pragma,
-   Warnings => Save_Warnings)),
+   Warnings => Save_Warnings,
+   SPARK_Mode   => SPARK_Mode,
+   SPARK_Mode_Pragma=> SPARK_Mode_Pragma)),
 Inlined_Body => True);
 
  Pop_Scope;
@@ -4363,7 +4367,9 @@
Local_Suppress_Stack_Top => Local_Suppress_Stack_Top,
Version  => Ada_Version,
Version_Pragma   => Ada_Version_Pragma,
-   Warnings => Save_Warnings)),
+   Warnings => Save_Warnings,
+   SPARK_Mode   => SPARK_Mode,
+   SPARK_Mode_Pragma=> SPARK_Mode_Pragma)),
 Inlined_Body => True);
   end if;
end Inline_Instance_Body;
@@ -4421,7 +4427,9 @@
  Local_Suppress_Stack_Top => Local_Suppress_Stack_Top,
  Version  => Ada_Version,
  Version_Pragma   => Ada_Version_Pragma,
- Warnings => Save_Warnings));
+ Warnings => Save_Warnings,
+ SPARK_Mode   => SPARK_Mode,
+ SPARK_Mode_Pragma=> SPARK_Mode_Pragma));
  return True;
 
   --  Here if not inlined, or we ignore the inlining
@@ -9913,6 +9921,8 @@
   Opt.Ada_Version  := Body_Info.Version;
   Opt.Ada_Version_Pragma   := Body_Info.Version_Pragma;
   Restore_Warnings (Body_Info.Warnings);
+  Opt.SPARK_Mode   := Body_Info.SPARK_Mode;
+  Opt.SPARK_Mode_Pragma:= Body_Info.SPARK_Mode_Pragma;
 
   if No (Gen_Body_Id) then
  Load_Parent_Of_Generic
@@ -10203,6 +10213,8 @@
   Opt.Ada_Version  := Body_Info.Version;
   Opt.Ada_Version_Pragma   := Body_Info.Version_Pragma;
   Restore_Warnings (Body_Info.Warnings);
+  Opt.SPARK_Mode   := Body_Info.SPARK_Mode;
+  Opt.SPARK_Mode_Pragma:= Body_Info.SPARK_Mode_Pragma;
 
   if No (Gen_Body_Id) then
 
@@ -12091,7 +12103,9 @@
 Local_Suppress_Stack_Top,
   Version  => Ada_Version,
   Version_Pragma   => Ada_Version_Pragma,
- 

Re: Disable accumulate-outgoing-args for Generic and Buldozers

2014-01-29 Thread Richard Biener
On Wed, Jan 29, 2014 at 11:02 AM, Jakub Jelinek  wrote:
> On Tue, Jan 28, 2014 at 07:26:47AM +0100, Jakub Jelinek wrote:
>> > I wonder if this is just some of --enable-checking tests in dwarf2out 
>> > going wild
>> > or if it is just expensive sanity checking code?
>> > I used to have chroot environment for 32bit builds, I will need to 
>> > re-install it now.
>>
>>  variable tracking   :2914.85 (83%) usr   1.88 ( 7%) sys2931.22 (82%) 
>> wall   80844 kB ( 3%) ggc
>>  var-tracking dataflow   :  18.19 ( 1%) usr   0.19 ( 1%) sys  18.49 ( 1%) 
>> wall   10899 kB ( 0%) ggc
>>  var-tracking emit   :  29.41 ( 1%) usr   0.11 ( 0%) sys  29.65 ( 1%) 
>> wall  148128 kB ( 6%) ggc
>>  TOTAL :3525.9725.73  3570.33
>> 2321043 kB
>>
>> So, strangely both vt_find_locations and vt_emit_notes, typically the most 
>> expensive ones,
>> are quite unexpensive and most of the time is spent elsewhere, in 
>> vt_initialize?
>
> So, most of the time seems to be spent in cselib.c remove_useless_values
> (both from Ctrl-C in gdb profiling, and callgrind).  For callgrind I've
> actually built 64-bit cc1plus with --enable-checking=release, and still 
> compiled
> the same --enable-checking=yes,rtl -m32 -O2 -g insn-recog.c, the build then
> took just 14 minutes instead of 60 minutes, and in that case only about 30%
> of compile time has been spent in var-tracking and 20% of compile time
> in remove_useless_values in particular.
>
> The problem with remove_useless_values is that we have quickly very big
> cselib hash table (over 20 entries) and very large number of very small
> basic blocks (over 34000) and at the end of every basic block we call
> cselib_preserve_only_values which walks the whole hash table, and e.g.
> references_value_p is called 845114869x from discard_useless_locs.

It looks like remove_useless_values () is an "optimization" (shrinks the
hashtable) and thus can be omitted?  After all it's already limited:

  if (n_useless_values > MAX_USELESS_VALUES
  /* remove_useless_values is linear in the hash table size.  Avoid
 quadratic behavior for very large hashtables with very few
 useless elements.  */
  && ((unsigned int)n_useless_values
  > (cselib_hash_table.elements () - n_debug_values) / 4))
remove_useless_values ();

why don't we remove them at the point we discover them useless?
Thus when n_useless_values increases?  Can't we do that in O(1)
there (with a hashtable lookup?)

> A micro-optimization could be e.g. to turn references_value_p into a
> template where only_useless would be a template parameter rather than actual
> parameter (due to recursion inlining doesn't help here) or just two
> functions.
>
> Also, for RTL checking, I wonder if the functions like reference_values_p
> and similar ones that use GET_RTX_FORMAT/GET_RTX_LENGTH to walk the elements
> couldn't use special non-checking macros in doing so if the compiler can't
> figure out checking is redundant there because it is being performed by hand
> by the function (haven't verified).  And, perhaps also an approach similar
> to http://gcc.gnu.org/ml/gcc-patches/2014-01/msg00140.html for
> GET_RTX_FORMAT and/or GET_RTX_LENGTH (so that at least for the cases where
> the compiler knows which rtx code it is (if some code is guarded with
> specific GET_CODE () == test), it could avoid loading from the const
> arrays).
>
> Anyway, I guess more important is whether all the values in the
> cselib_hash_table will be ever useful for some lookup, or if there are
> e.g. values that only reference preserved values where none of those
> referenced values have any locations other than preserved values.
>
> Or if we can somehow quickly find out what VALUEs have changed during
> processing of the last bb and only process that subset instead of all the
> hash table entries all the time.
>
> Alex?  Your thoughts?
>
> Jakub


[Ada] Generate optimized code for protected subprograms if no exceptions.

2014-01-29 Thread Arnaud Charlet
If exceptions aren't propagated, the optimized path of
Exp_Ch9.Build_Protected_Subprogram_Body could be used.

No functional change, so no testcase.

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-29  Tristan Gingold  

* exp_ch9.adb (Is_Exception_Safe): Return true if no exceptions.

Index: exp_ch9.adb
===
--- exp_ch9.adb (revision 207243)
+++ exp_ch9.adb (working copy)
@@ -13425,6 +13425,14 @@
--  Start of processing for Is_Exception_Safe
 
begin
+
+  --  When exceptions can not be propagated, the subprogram will always
+  --  return normaly.
+
+  if No_Exception_Handlers_Set then
+ return True;
+  end if;
+
   --  If the checks handled by the back end are not disabled, we cannot
   --  ensure that no exception will be raised.
 


Re: How to generate AVX512 instructions now (just to look at them).

2014-01-29 Thread Kirill Yukhin
Hello,
I think its time to remove `XPASS' from corresponding tests.
On 03 Jan 22:11, Jakub Jelinek wrote:
> Hi!
> 
> On Fri, Jan 03, 2014 at 08:58:30PM +0100, Toon Moene wrote:
> > I don't doubt that would work, what I'm interested in, is (cat verintlin.f):
> 
> Well, you need gather loads for that and there you hit PR target/59617.

testsuite/
PR target/59617
* gcc.target/i386/avx512f-gather-2.c: Remove XPASS
* gcc.target/i386/avx512f-gather-5.c: Ditto.

Patch in the bottom. Updated tests pass.
Is it ok for trunk?

--
Thanks, K

 gcc/testsuite/gcc.target/i386/avx512f-gather-2.c | 8 
 gcc/testsuite/gcc.target/i386/avx512f-gather-5.c | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/testsuite/gcc.target/i386/avx512f-gather-2.c 
b/gcc/testsuite/gcc.target/i386/avx512f-gather-2.c
index 8664192..f20d3db 100644
--- a/gcc/testsuite/gcc.target/i386/avx512f-gather-2.c
+++ b/gcc/testsuite/gcc.target/i386/avx512f-gather-2.c
@@ -3,9 +3,9 @@
 
 #include "avx512f-gather-1.c"
 
-/* { dg-final { scan-assembler-not "gather\[^\n\]*ymm\[^\n\]*ymm" { xfail { 
*-*-* } } } } */  /* PR59617 */
-/* { dg-final { scan-assembler-not "gather\[^\n\]*xmm\[^\n\]*ymm" { xfail { 
*-*-* } } } } */  /* PR59617 */
-/* { dg-final { scan-assembler-not "gather\[^\n\]*ymm\[^\n\]*xmm" { xfail { 
*-*-* } } } } */  /* PR59617 */
-/* { dg-final { scan-assembler-not "gather\[^\n\]*xmm\[^\n\]*xmm" { xfail { 
lp64 } } } } */  /* PR59617 */
+/* { dg-final { scan-assembler-not "gather\[^\n\]*ymm\[^\n\]*ymm" } } */
+/* { dg-final { scan-assembler-not "gather\[^\n\]*xmm\[^\n\]*ymm" } } */
+/* { dg-final { scan-assembler-not "gather\[^\n\]*ymm\[^\n\]*xmm" } } */
+/* { dg-final { scan-assembler-not "gather\[^\n\]*xmm\[^\n\]*xmm" } } */
 /* { dg-final { scan-tree-dump-times "note: vectorized 1 loops in function" 16 
"vect" } } */
 /* { dg-final { cleanup-tree-dump "vect" } } */
diff --git a/gcc/testsuite/gcc.target/i386/avx512f-gather-5.c 
b/gcc/testsuite/gcc.target/i386/avx512f-gather-5.c
index 5edd446..d2237da 100644
--- a/gcc/testsuite/gcc.target/i386/avx512f-gather-5.c
+++ b/gcc/testsuite/gcc.target/i386/avx512f-gather-5.c
@@ -3,8 +3,8 @@
 
 #include "avx512f-gather-4.c"
 
-/* { dg-final { scan-assembler "gather\[^\n\]*zmm" { xfail { *-*-* } } } } */ 
/* PR59617 */
-/* { dg-final { scan-assembler-not "gather\[^\n\]*ymm\[^\n\]*ymm" { xfail { 
*-*-* } } } } */ /* PR59617 */
+/* { dg-final { scan-assembler "gather\[^\n\]*zmm" } } */
+/* { dg-final { scan-assembler-not "gather\[^\n\]*ymm\[^\n\]*ymm" } } */
 /* { dg-final { scan-assembler-not "gather\[^\n\]*xmm\[^\n\]*ymm" } } */
 /* { dg-final { scan-assembler-not "gather\[^\n\]*ymm\[^\n\]*xmm" } } */
 /* { dg-final { scan-assembler-not "gather\[^\n\]*xmm\[^\n\]*xmm" } } */


Re: Do not produce empty try-finally statements

2014-01-29 Thread Jan Hubicka
Hi,
I tested the following patch. It makes inliner to ignore empty EH clenaup
regions regadless they are internal or external in anticipation they will be
removed.  It also make tree-eh to not do any cleanups pre-inline. This is
independent change, but I wanted to stress the code bit more.

Here are stats of tramp3d compilation:

Mainline:
einline: 27894 inlined calls
Inlined 31427 calls, eliminated 6496 functions
   textdata bss dec hex
 575081  401082  576203   8cacb

Patch to avoid EH regions with clobbers (the one I started
thread with):
einline: 27954 inlined calls
Inlined 31512 calls, eliminated 6496 functions
   textdata bss dec hex
 572117  401082  573239   8bf37

New patch:
einline: 27954 inlined calls
Inlined 31502 calls, eliminated 6494 functions
   textdata bss dec hex
 579248  401082  580370   8db12

No exceptions:
einline: 25528 inlined calls
Inlined 29194 calls, eliminated 6527 functions
   textdata bss dec hex 
 551555  401082  552677   86ee5 

It seems tha tthis patch still does bit worse than the original (wrong)
proposed patch, but it gets things better than mainline.  I wonder what other
kinds of cleanups we are missing.

Note that the number of inlines in no-exception case is lower probably because
quite few inlines are dtors in EH cleanups.  Also the text size includes
EH tables, as usual for size.

Bootrstrapped/regtested x86_64-linux. I plan to commit the ipa-inline-analysis.c
change if there are no complains.  Does the tree-eh change look resonable based
on this thread?

I agree WRT eh cleanup and -O0. Shall I make a patch?

* tree-eh.c (optimize_clobbers): Do nothing before inlining
* ipa-inline-analysis.c (clobber_only_eh_bb_p): New function.
(estimate_function_body_sizes): Use it.

Index: tree-eh.c
===
--- tree-eh.c   (revision 206946)
+++ tree-eh.c   (working copy)
@@ -3381,6 +3381,11 @@
   edge_iterator ei;
   edge e;
 
+  /* Before inlining we do not want to optimize away clobbers that may become
+ internal when inlined.  */
+  if (optimize && !cfun->after_inlining)
+return;
+
   /* Only optimize anything if the bb contains at least one clobber,
  ends with resx (checked by caller), optionally contains some
  debug stmts or labels, or at most one __builtin_stack_restore
Index: ipa-inline-analysis.c
===
--- ipa-inline-analysis.c   (revision 206946)
+++ ipa-inline-analysis.c   (working copy)
@@ -2347,6 +2347,56 @@
   return NULL;
 }
 
+/* Return true when the basic blocks contains only clobbers followed by RESX.
+   Such BBs are kept around to make removal of dead stores possible with
+   presence of EH and will be optimized out by optimize_clobbers later in the
+   game. 
+
+   NEED_EH is used to recurse in case the clobber has non-EH predecestors
+   that can be clobber only, too.. When it is false, the RESX is not necessary
+   on the end of basic block.  */
+
+static bool
+clobber_only_eh_bb_p (basic_block bb, bool need_eh = true)
+{
+  gimple_stmt_iterator gsi = gsi_last_bb (bb);
+  edge_iterator ei;
+  edge e;
+
+  if (need_eh)
+{
+  if (gsi_end_p (gsi))
+   return false;
+  if (gimple_code (gsi_stmt (gsi)) != GIMPLE_RESX)
+return false;
+  gsi_prev (&gsi);
+}
+  else if (!single_succ_p (bb))
+return false;
+
+  for (; !gsi_end_p (gsi); gsi_prev (&gsi))
+{
+  gimple stmt = gsi_stmt (gsi);
+  if (is_gimple_debug (stmt))
+   continue;
+  if (gimple_clobber_p (stmt))
+   continue;
+  if (gimple_code (stmt) == GIMPLE_LABEL)
+   break;
+  return false;
+}
+
+  /* See if all predecestors are either throws or clobber only BBs.  */
+  FOR_EACH_EDGE (e, ei, bb->preds)
+if (!(e->flags & EDGE_EH)
+   && !clobber_only_eh_bb_p (e->src, false))
+  return false;
+
+  if (!need_eh)
+debug_bb (bb);
+  return true;
+}
+
 /* Compute function body size parameters for NODE.
When EARLY is true, we compute only simple summaries without
non-trivial predicates to drive the early inliner.  */
@@ -2410,6 +2460,14 @@
 {
   bb = BASIC_BLOCK_FOR_FN (cfun, order[n]);
   freq = compute_call_stmt_bb_frequency (node->decl, bb);
+  if (clobber_only_eh_bb_p (bb))
+   {
+ if (dump_file && (dump_flags & TDF_DETAILS))
+   fprintf (dump_file, "\n Ignoring BB %i;"
+" it will be optimized away by cleanup_clobbers\n",
+bb->index);
+ continue;
+   }
 
   /* TODO: Obviously predicates can be propagated down across CFG.  */
   if (parms_info)


[AArch64, Committed] Fix sfp-machine.h _FP_I_TYPE definition.

2014-01-29 Thread Marcus Shawcroft
The definition of _FP_I_TYPE in AArch64 libgcc sfp-machine.h is wrong, 
this patch ensures the definition matches that provided by glibc's 
AArch64 sfp-machine.h


Committed
/Marcus

2014-01-29  Marcus Shawcroft  

* config/aarch64/sfp-machine.h (_FP_I_TYPE): Define
as long long.diff --git a/libgcc/config/aarch64/sfp-machine.h b/libgcc/config/aarch64/sfp-machine.h
index 61b5f72..ddb67fb 100644
--- a/libgcc/config/aarch64/sfp-machine.h
+++ b/libgcc/config/aarch64/sfp-machine.h
@@ -26,7 +26,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #define _FP_W_TYPE_SIZE		64
 #define _FP_W_TYPE		unsigned long long
 #define _FP_WS_TYPE		signed long long
-#define _FP_I_TYPE		int
+#define _FP_I_TYPE		long long
 
 typedef int TItype __attribute__ ((mode (TI)));
 typedef unsigned int UTItype __attribute__ ((mode (TI)));

RE: [PING] [PATCH] _Cilk_for for C and C++

2014-01-29 Thread Iyer, Balaji V
Hi Jakub,

> -Original Message-
> From: Jakub Jelinek [mailto:ja...@redhat.com]
> Sent: Wednesday, January 29, 2014 6:31 AM
> To: Iyer, Balaji V
> Cc: 'Jason Merrill'; 'Jeff Law'; 'Aldy Hernandez'; 'gcc-patches@gcc.gnu.org';
> 'r...@redhat.com'
> Subject: Re: [PING] [PATCH] _Cilk_for for C and C++
> 
> On Tue, Jan 28, 2014 at 04:55:38PM +, Iyer, Balaji V wrote:
> > I thought about it a bit more, and the main issue here is that we
> > need access to the _Cilk_for loop's components both inside the child
> > function and the parent function.
> 
> I guess for the C++ iterators, if in the _Cilk_for model you need to provide
> number of iterations before parallelization, it really depends on what the
> standard allows and what you want to do exactly.

Yes, I need the value before the parallelization context hits. This is why in 
my last patch I had the parallel around the body and omp for around the 
_Cilk-for statement. 


> If you need to provide the iteration count before spawning the threads and
> the standard allows you that, then just lower it in the C++ FE already so that
> you do:
>   vector::iterator temp = array.begin ();
>   sizetype tempcount = (array.end () - temp); before the parallel, and then
>   #pragma omp parallel firstprivate(temp, tempcount)
> _Cilk_for (sizetype temp2 = 0; temp2 < tempcount; temp2++)
>   {
> vector::iterator ii = temp + temp2;
> 
>   }

This is kind of what I did (atlest tried to accomplish what you mentioned 
above). I can look into doing this, but is it possible for you to accept the 
patch as-is and we will look into fixing it in the future?

Thanks,

Balaji V. Iyer.

> or similar.  The C++ FE needs to lower the C++ iterators anyway, the middle-
> end can really only work with integral or pointer iterators, and it depends on
> how exactly the Cilk+ standard defines _Cilk_for with iterators (what
> methods must be implemented on the iterators and what methods and in
> what order should be called).
> 
>   Jakub


Re: Disable accumulate-outgoing-args for Generic and Buldozers

2014-01-29 Thread Richard Biener
On Wed, Jan 29, 2014 at 4:24 PM, Richard Biener
 wrote:
> On Wed, Jan 29, 2014 at 11:02 AM, Jakub Jelinek  wrote:
>> On Tue, Jan 28, 2014 at 07:26:47AM +0100, Jakub Jelinek wrote:
>>> > I wonder if this is just some of --enable-checking tests in dwarf2out 
>>> > going wild
>>> > or if it is just expensive sanity checking code?
>>> > I used to have chroot environment for 32bit builds, I will need to 
>>> > re-install it now.
>>>
>>>  variable tracking   :2914.85 (83%) usr   1.88 ( 7%) sys2931.22 (82%) 
>>> wall   80844 kB ( 3%) ggc
>>>  var-tracking dataflow   :  18.19 ( 1%) usr   0.19 ( 1%) sys  18.49 ( 1%) 
>>> wall   10899 kB ( 0%) ggc
>>>  var-tracking emit   :  29.41 ( 1%) usr   0.11 ( 0%) sys  29.65 ( 1%) 
>>> wall  148128 kB ( 6%) ggc
>>>  TOTAL :3525.9725.73  3570.33   
>>>  2321043 kB
>>>
>>> So, strangely both vt_find_locations and vt_emit_notes, typically the most 
>>> expensive ones,
>>> are quite unexpensive and most of the time is spent elsewhere, in 
>>> vt_initialize?
>>
>> So, most of the time seems to be spent in cselib.c remove_useless_values
>> (both from Ctrl-C in gdb profiling, and callgrind).  For callgrind I've
>> actually built 64-bit cc1plus with --enable-checking=release, and still 
>> compiled
>> the same --enable-checking=yes,rtl -m32 -O2 -g insn-recog.c, the build then
>> took just 14 minutes instead of 60 minutes, and in that case only about 30%
>> of compile time has been spent in var-tracking and 20% of compile time
>> in remove_useless_values in particular.
>>
>> The problem with remove_useless_values is that we have quickly very big
>> cselib hash table (over 20 entries) and very large number of very small
>> basic blocks (over 34000) and at the end of every basic block we call
>> cselib_preserve_only_values which walks the whole hash table, and e.g.
>> references_value_p is called 845114869x from discard_useless_locs.
>
> It looks like remove_useless_values () is an "optimization" (shrinks the
> hashtable) and thus can be omitted?  After all it's already limited:
>
>   if (n_useless_values > MAX_USELESS_VALUES
>   /* remove_useless_values is linear in the hash table size.  Avoid
>  quadratic behavior for very large hashtables with very few
>  useless elements.  */
>   && ((unsigned int)n_useless_values
>   > (cselib_hash_table.elements () - n_debug_values) / 4))
> remove_useless_values ();
>
> why don't we remove them at the point we discover them useless?
> Thus when n_useless_values increases?  Can't we do that in O(1)
> there (with a hashtable lookup?)

Actually best would be to avoid generating so many useless values
in the first place ... still, quadraticness is a complete no-go.

>> A micro-optimization could be e.g. to turn references_value_p into a
>> template where only_useless would be a template parameter rather than actual
>> parameter (due to recursion inlining doesn't help here) or just two
>> functions.
>>
>> Also, for RTL checking, I wonder if the functions like reference_values_p
>> and similar ones that use GET_RTX_FORMAT/GET_RTX_LENGTH to walk the elements
>> couldn't use special non-checking macros in doing so if the compiler can't
>> figure out checking is redundant there because it is being performed by hand
>> by the function (haven't verified).  And, perhaps also an approach similar
>> to http://gcc.gnu.org/ml/gcc-patches/2014-01/msg00140.html for
>> GET_RTX_FORMAT and/or GET_RTX_LENGTH (so that at least for the cases where
>> the compiler knows which rtx code it is (if some code is guarded with
>> specific GET_CODE () == test), it could avoid loading from the const
>> arrays).
>>
>> Anyway, I guess more important is whether all the values in the
>> cselib_hash_table will be ever useful for some lookup, or if there are
>> e.g. values that only reference preserved values where none of those
>> referenced values have any locations other than preserved values.
>>
>> Or if we can somehow quickly find out what VALUEs have changed during
>> processing of the last bb and only process that subset instead of all the
>> hash table entries all the time.
>>
>> Alex?  Your thoughts?
>>
>> Jakub


[Committed, AArch64] Fix a couple of white space nits.

2014-01-29 Thread Marcus Shawcroft

Fix a couple of white space nits, committed.

/Marcus

2014-01-29  Marcus Shawcroft  

* config/aarch64/aarch64.c (aarch64_expand_mov_immediate)
(aarch64_legitimate_address_p, aarch64_class_max_nregs): Adjust
whitespace.diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 57b6645..d3c5cbc 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -916,7 +916,7 @@ aarch64_expand_mov_immediate (rtx dest, rtx imm)
 	  if (offset != const0_rtx
 	  && targetm.cannot_force_const_mem (mode, imm))
 	{
-	  gcc_assert(can_create_pseudo_p ());
+	  gcc_assert (can_create_pseudo_p ());
 	  base = aarch64_force_temporary (mode, dest, base);
 	  base = aarch64_add_offset (mode, NULL, base, INTVAL (offset));
 	  aarch64_emit_move (dest, base);
@@ -3249,7 +3249,7 @@ aarch64_legitimate_address_hook_p (enum machine_mode mode, rtx x, bool strict_p)
pair operation.  */
 bool
 aarch64_legitimate_address_p (enum machine_mode mode, rtx x,
-			   RTX_CODE outer_code, bool strict_p)
+			  RTX_CODE outer_code, bool strict_p)
 {
   struct aarch64_address_info addr;
 
@@ -4256,7 +4256,7 @@ aarch64_class_max_nregs (reg_class_t regclass, enum machine_mode mode)
 case FP_LO_REGS:
   return
 	aarch64_vector_mode_p (mode) ? (GET_MODE_SIZE (mode) + 15) / 16 :
-    (GET_MODE_SIZE (mode) + 7) / 8;
+   (GET_MODE_SIZE (mode) + 7) / 8;
 case STACK_REG:
   return 1;
 
-- 
1.7.9.5


Re: How to generate AVX512 instructions now (just to look at them).

2014-01-29 Thread Jakub Jelinek
On Wed, Jan 29, 2014 at 06:33:21PM +0300, Kirill Yukhin wrote:
> I think its time to remove `XPASS' from corresponding tests.
> On 03 Jan 22:11, Jakub Jelinek wrote:
> > Hi!
> > 
> > On Fri, Jan 03, 2014 at 08:58:30PM +0100, Toon Moene wrote:
> > > I don't doubt that would work, what I'm interested in, is (cat 
> > > verintlin.f):
> > 
> > Well, you need gather loads for that and there you hit PR target/59617.
> 
> testsuite/
>   PR target/59617
>   * gcc.target/i386/avx512f-gather-2.c: Remove XPASS
>   * gcc.target/i386/avx512f-gather-5.c: Ditto.
> 
> Patch in the bottom. Updated tests pass.
> Is it ok for trunk?

Ok, thanks.  Sorry for not removing those myself.

Jakub


[Ada] gnatmake, aggregate and aggregate library projects

2014-01-29 Thread Arnaud Charlet
gnatmake, gnatclean, gnatname and the gnat driver now fail immediately
if the main project is an aggregate project or if there is an aggregate
library project in the project tree.

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-29  Vincent Celier  

* clean.adb (Gnatclean): Fail if main project is an aggregate
project or if there is an aggregate library project in the
project tree.
* gnatcmd.adb: Fail if the main project is an aggregate project
or if there is an aggegate library project in the project tree.
* make.adb (Initialize): : Fail if main project is an aggregate
project or if there is an aggregate library project in the
project tree.
* makeutl.ads (Aggregate_Libraries_In): New Boolean function.
* prj-makr.adb (Initialize): Fail if the main project is an
aggregate project or an aggregate library project.

Index: gnatcmd.adb
===
--- gnatcmd.adb (revision 207241)
+++ gnatcmd.adb (working copy)
@@ -1939,6 +1939,12 @@
 
  if Project = Prj.No_Project then
 Fail ( & Project_File.all & """ processing failed");
+
+ elsif Project.Qualifier = Aggregate then
+Fail ("aggregate projects are not supported");
+
+ elsif Aggregate_Libraries_In (Project_Tree) then
+Fail ("aggregate library projects are not supported");
  end if;
 
  --  Check if a package with the name of the tool is in the project
Index: make.adb
===
--- make.adb(revision 207241)
+++ make.adb(working copy)
@@ -6617,6 +6617,13 @@
   ( & Project_File_Name.all & """ processing failed");
  end if;
 
+ if Main_Project.Qualifier = Aggregate then
+Make_Failed ("aggregate projects are not supported");
+
+ elsif Aggregate_Libraries_In (Project_Tree) then
+Make_Failed ("aggregate library projects are not supported");
+ end if;
+
  Create_Mapping_File := True;
 
  if Verbose_Mode then
Index: prj-makr.adb
===
--- prj-makr.adb(revision 207241)
+++ prj-makr.adb(working copy)
@@ -889,6 +889,14 @@
 if No (Project_Node) then
Prj.Com.Fail ("parsing of existing project file failed");
 
+elsif Project_Qualifier_Of (Project_Node, Tree) = Aggregate then
+   Prj.Com.Fail ("aggregate projects are not supported");
+
+elsif Project_Qualifier_Of (Project_Node, Tree) =
+Aggregate_Library
+then
+   Prj.Com.Fail ("aggregate library projects are not supported");
+
 else
--  If parsing was successful, remove the components that are
--  automatically generated, if any, so that they will be
Index: makeutl.adb
===
--- makeutl.adb (revision 207252)
+++ makeutl.adb (working copy)
@@ -171,6 +171,26 @@
   end;
end Absolute_Path;
 
+   
+   -- Aggregate_Libraries_In --
+   
+
+   function Aggregate_Libraries_In (Tree : Project_Tree_Ref) return Boolean is
+  List : Project_List;
+
+   begin
+  List := Tree.Projects;
+  while List /= null loop
+ if List.Project.Qualifier = Aggregate_Library then
+return True;
+ end if;
+
+ List := List.Next;
+  end loop;
+
+  return False;
+   end Aggregate_Libraries_In;
+
-
-- Base_Name_Index_For --
-
Index: makeutl.ads
===
--- makeutl.ads (revision 207241)
+++ makeutl.ads (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- S p e c  --
 --  --
---  Copyright (C) 2004-2012, Free Software Foundation, Inc. --
+--  Copyright (C) 2004-2013, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -216,6 +216,10 @@
--  The source directories of imported projects are only included if one
--  of the declared languages is in the list Languages.
 
+   function Aggregate_Libraries_In (Tree : Project_Tree_Ref) return Boolean;
+   --  Return True iff there is one or more aggregate library projects in
+   --  the project tree Tree.
+
procedure Write_Path_File

Re: Fwd: [RFC][gomp4] Offloading patches (2/3): Add tables generation

2014-01-29 Thread Ilya Verbin
2014/1/29 Bernd Schmidt :
> I was worried the answer was going to be something like this. These are
> produced by two different compilers/linkers, aren't they? This seems really
> fragile to me and a recipe for hard-to-debug silent failures.

Yes.

> First we let the driver compile and load all the ptx code, then we'd call a
> cuda library function with the name of the function passed as a string. So I
> guess the host table would contain pointers to the host version of the
> functions, and the target table would contain a pointer to the name.

We also wanted to use function names at the beginning of our work [1].
Then Jakub noticed that the names aren't necessarily unique: [2], [3], [4], etc.
This led to the current approach of host/target address tables.

>
> Bernd
>

[1] http://gcc.gnu.org/ml/gcc/2013-08/msg00251.html
[2] http://gcc.gnu.org/ml/gcc-patches/2013-09/msg00250.html
[3] http://gcc.gnu.org/ml/gcc/2013-09/msg00146.html
[4] http://gcc.gnu.org/ml/gcc/2013-10/msg00184.html

  -- Ilya


Re: [PATCH] Fix handling of context diff patches in mklog

2014-01-29 Thread Yury Gribov

Diego wrote:
>> Ok to commit?
>
> OK. Thanks.

Done in r207265.

-Y


PR testsuite/59971: multilib_flags is placed with the wrong order

2014-01-29 Thread H.J. Lu
Hi,

Some testcases need explicit GCC options to properly run, like
gcc.target/i386/sse2-init-v2di-2.c has

/* { dg-options "-O2 -msse4 -march=core2 -dp" } */

-march=core2 is specified explicitly.  But with multlib, like

make check-gcc RUNTESTFLAGS="--target_board='unix{-march=k8}'

-march=k8 is appended to the command line options, which overrides
the the command line options specified by dg-options.  multlib flags
should be placed at the beginning of the command line options, not at
the end.  This patch adds gcc_default_target_compile, which is
almost identical to default_target_compile in dejagnu, except that
it has

if {[board_info $dest exists multilib_flags]} {
set add_flags "[board_info $dest multilib_flags] $add_flags"
}

instead of

if {[board_info $dest exists multilib_flags]} {
append add_flags " [board_info $dest multilib_flags]"
}

It replaces default_target_compile with gcc_default_target_compile.
Tested on Linux/x86-64 with RUNTESTFLAGS="--target_board='unix{-m32,}'".
OK for trunk?

Thanks.

H.J.
---
2014-01-29  H.J. Lu  

PR testsuite/59971
* lib/gcc-defs.exp (gcc_default_target_compile): New.  Replace
default_target_compile with gcc_default_target_compile.

diff --git a/gcc/testsuite/lib/gcc-defs.exp b/gcc/testsuite/lib/gcc-defs.exp
index 69a5971..a3fb3d4 100644
--- a/gcc/testsuite/lib/gcc-defs.exp
+++ b/gcc/testsuite/lib/gcc-defs.exp
@@ -290,3 +290,365 @@ proc gcc-set-multilib-library-path { compiler } {
 
 return $libpath
 }
+
+# This is almost identical to default_target_compile, except that
+# multilib_flags is prepended to add_flags instead of append so that
+# testcase can provide compiler options to override multilib_flags.
+
+proc gcc_default_target_compile {source destfile type options} {
+global target_triplet
+global tool_root_dir
+global CFLAGS_FOR_TARGET
+global compiler_flags
+
+if { $destfile == "" && $type != "preprocess" && $type != "none" } {
+   error "Must supply an output filename for the compile to 
default_target_compile"
+}
+
+set add_flags ""
+set libs ""
+set compiler_type "c"
+set compiler ""
+set ldflags ""
+set dest [target_info name]
+
+if {[info exists CFLAGS_FOR_TARGET]} {
+   append add_flags " $CFLAGS_FOR_TARGET"
+}
+
+if {[info exists target_info(host,name)]} {
+   set host [host_info name]
+} else {
+   set host "unix"
+}
+
+foreach i $options {
+
+   if { $i == "ada" } {
+   set compiler_type "ada"
+   if {[board_info $dest exists adaflags]} {
+   append add_flags " [target_info adaflags]"
+   }
+   if {[board_info $dest exists gnatmake]} {
+   set compiler [target_info gnatmake];
+   } else {
+   set compiler [find_gnatmake];
+   }
+   }
+   
+   if { $i == "c++" } {
+   set compiler_type "c++"
+   if {[board_info $dest exists cxxflags]} {
+   append add_flags " [target_info cxxflags]"
+   }
+   append add_flags " [g++_include_flags]"
+   if {[board_info $dest exists c++compiler]} {
+   set compiler [target_info c++compiler]
+   } else {
+   set compiler [find_g++]
+   }
+   }
+
+   if { $i == "f77" } {
+   set compiler_type "f77"
+   if {[board_info $dest exists f77flags]} {
+   append add_flags " [target_info f77flags]"
+   }
+   if {[board_info $dest exists f77compiler]} {
+   set compiler [target_info f77compiler]
+   } else {
+   set compiler [find_g77]
+   }
+   }
+
+   if { $i == "f90" } {
+   set compiler_type "f90"
+   if {[board_info $dest exists f90flags]} {
+   append add_flags " [target_info f90flags]"
+   }
+   if {[board_info $dest exists f90compiler]} {
+   set compiler [target_info f90compiler]
+   } else {
+   set compiler [find_gfortran]
+   }
+   }
+
+   if {[regexp "^dest=" $i]} {
+   regsub "^dest=" $i "" tmp
+   if {[board_info $tmp exists name]} {
+   set dest [board_info $tmp name]
+   } else {
+   set dest $tmp
+   }
+   }
+   if {[regexp "^compiler=" $i]} {
+   regsub "^compiler=" $i "" tmp
+   set compiler $tmp
+   }
+   if {[regexp "^additional_flags=" $i]} {
+   regsub "^additional_flags=" $i "" tmp
+   append add_flags " $tmp"
+   }
+   if {[regexp "^ldflags=" $i]} {
+   regsub "^ldflags=" $i "" tmp
+   append ldflags " $tmp"
+   }
+   if {[regexp "^libs=" $i]} {
+   regsub "^libs=" $i "" tmp
+   append libs " $tmp"
+   }
+   if {[regexp "^incdir=" $i]} {
+   regsub "^incdir=" $i "-I" tmp
+   append add_flags " $tmp"
+   

[jit] API change: access fields via (gcc_jit_field *) rather than by name

2014-01-29 Thread David Malcolm
Committed to branch dmalcolm/jit:

Currently there's almost no type-checking within libgccjit - if client
code uses the API in such a way as to generate bogus code, this is
likely to violate assumptions made later on within GCC proper, leading
to errors deep inside GCC (e.g. with
internal compiler error: verify_gimple failed
when converting tree to gimple, when expanding gimple to RTL, or indeed
in other places; see the results of test-fuzzer.c for examples).

The API will be more developer-friendly if we catch such type errors
at the API boundary (similar to how the other language frontends enforce
these assumptions).

As a step towards this, change the API for accessing fields to use
gcc_jit_field pointers, rather than passing field name as strings,
avoiding the need to do a lookup in the replay code, and allowing
for the possibility of directly examining the type of the
field when implementing type-checking.

gcc/jit/
* libgccjit.h (gcc_jit_lvalue_access_field): Require
a (gcc_jit_field *) rather than a field name.
(gcc_jit_rvalue_access_field): Likewise.
(gcc_jit_rvalue_dereference_field): Likewise.

* libgccjit.c (gcc_jit_lvalue_access_field): Require
a (gcc_jit_field *) rather than a field name.
(gcc_jit_rvalue_access_field): Likewise.
(gcc_jit_rvalue_dereference_field): Likewise.

* internal-api.c (gcc::jit::recording::rvalue::access_field):
Require a field rather than a fieldname string.
(gcc::jit::recording::rvalue::dereference_field): Likewise.
(gcc::jit::recording::lvalue::access_field): Likewise.

(gcc::jit::recording::access_field_of_lvalue::replay_into): Update
given that this now has a field, rather than a fieldname.
(gcc::jit::recording::access_field_rvalue::replay_into): Likewise.
(gcc::jit::recording::dereference_field_rvalue::replay_into): Likewise.

(get_field): Delete, as we no longer need to convert
from (struct, identifier) pairs to fields, instead directly using
fields.

(gcc::jit::playback::context::new_field_access): Require a field
rather than a fieldname, removing the need to look up the field by
name within the struct.

(gcc::jit::playback::lvalue::access_field): Likewise.
(gcc::jit::playback::rvalue::access_field): Likewise.
(gcc::jit::playback::rvalue::dereference_field): Likewise.

* internal-api.h (gcc::jit::recording::rvalue::access_field):
Require a field rather than a fieldname string.
(gcc::jit::recording::rvalue::dereference_field): Likewise.
(gcc::jit::recording::lvalue::access_field): Likewise.

(gcc::jit::recording::access_field_of_lvalue::access_field_of_lvalue):
Likewise.
(gcc::jit::recording::access_field_of_lvalue::m_fieldname): Drop
string field in favor of...
(gcc::jit::recording::access_field_of_lvalue::m_field):
..."field" field, as it were.

(gcc::jit::recording::access_field_of_rvalue::access_field_of_rvalue):
Likewise.
(gcc::jit::recording::access_field_of_rvalue::m_fieldname): Drop
string field in favor of...
(gcc::jit::recording::access_field_of_rvalue::m_field):
..."field" field.

(gcc::jit::recording::dereference_field_rvalue::
dereference_field_rvalue): Likewise.
(gcc::jit::recording::dereference_field_rvalue::m_fieldname): Drop
string field in favor of...
(gcc::jit::recording::dereference_field_rvalue::m_field):
..."field" field.

(gcc::jit::playback::context::new_field_access): Require a field
rather than a fieldname string.
(gcc::jit::playback::context::access_field): Likewise.
(gcc::jit::playback::context::dereference_field): Likewise.
(gcc::jit::playback::rvalue::access_field):

gcc/testsuite/
* jit.dg/test-accessing-struct.c (create_code): Update for API change
for accessing fields in terms of gcc_jit_field pointers rather than
by name.
* jit.dg/test-nested-contexts.c (make_calc_discriminant): Likewise.
(make_test_quadratic): Likewise.
* jit.dg/test-quadratic.c (make_calc_discriminant): Likewise.
(make_test_quadratic): Likewise.
* jit.dg/test-reading-struct.c (create_code): Likewise.
* jit.dg/test-types.c: Likewise.
---
 gcc/jit/ChangeLog.jit|  66 ++
 gcc/jit/internal-api.c   |  59 +++--
 gcc/jit/internal-api.h   |  34 ++---
 gcc/jit/libgccjit.c  |  18 +--
 gcc/jit/libgccjit.h  |   6 +-
 gcc/testsuite/ChangeLog.jit  |  12 ++
 gcc/testsuite/jit.dg/test-accessing-struct.c |   6 +-
 gcc/testsuite/jit.dg/test-nested-contexts.c  |  20 +--
 gcc/testsuite/jit.dg/test-quadratic.c|  20 +--
 gcc/testsuite/jit.dg/test-readi

Re: PATCH: PR target/59672: Add -m16 support for x86

2014-01-29 Thread H.J. Lu
On Wed, Jan 29, 2014 at 6:41 AM, Alexander Monakov  wrote:
>
> On Wed, 29 Jan 2014, H.J. Lu wrote:
>> Since the .code16gcc directive was added to binutils back in 1999,
>> it is older than the minimum binutils required for x86 GCC.  There
>> is no need to specify a separate minimum binutils for it.
>
> It's not clear to me why the compiler should be involved in providing this
> functionality.  Can the assembler simply support '-mcode16gcc' command-line
> flag, which would have the effect of enabling .code16gcc for the whole
> translation unit?  That way, you could simply add -Wa,-mcode16gcc to the GCC
> command line and avoid the need to patch the compiler.  Am I missing
> something?

-m16 is used by Linux kernel, which checks if the compiler supports -m16
and uses it if it does. Adding gas --code16gcc check is an additional change
in Linux kernel.  Clang already supports -m16, which generates objects
directly.  Adding gas --code16gcc check doesn't help clang.  Add -m16
to gcc makes gcc and clang consistent to Linux kernel build.


-- 
H.J.


Re: C++ PATCH for c++/53756 (-g and C++1y auto)

2014-01-29 Thread Jason Merrill

On 01/28/2014 04:35 PM, Paolo Carlini wrote:

+  if (is_cxx ())
+   {
+ tree name = TYPE_NAME (type);
+ if (TREE_CODE (name) == TYPE_DECL)
+   name = DECL_NAME (name);
+ if (name == get_identifier ("auto"))
+   return 0;


Rather than duplicate this code, let's factor it out into a separate 
function.


Also, your ChangeLog has nothing to do with the patch.  :)

Jason



Re: [PATCH] Improve EDGE_ABNORMAL construction (PR middle-end/59917, tree-optimization/59920)

2014-01-29 Thread Jeff Law

On 01/29/14 02:47, Richard Biener wrote:


I wonder if you can't simply prune the edges for the OpenMP regions
(similar as to how we could prune some of the edges from setjmp
to calls before that setjmp call)?  Eventually this asks for delaying
of abnormal edge creation (but that's what you do anyway) to be able
to compute dominators between "regular" CFG creation and abnormal
edge creation.
I'd been pondering this after I looked at the code we generated for 
59919.  The question in my mind is how many edges can we really 
avoid/prune in real world code.   I meant to open a PR for this so that 
we can track it in the next stage1 cycle -- I'll do that now ;-)



For 59917/59920 we really have to avoid generating the edges in the 
first place though.


jeff



Re: C++ PATCH for c++/53756 (-g and C++1y auto)

2014-01-29 Thread Paolo Carlini

On 01/29/2014 05:42 PM, Jason Merrill wrote:

On 01/28/2014 04:35 PM, Paolo Carlini wrote:

+  if (is_cxx ())
+{
+  tree name = TYPE_NAME (type);
+  if (TREE_CODE (name) == TYPE_DECL)
+name = DECL_NAME (name);
+  if (name == get_identifier ("auto"))
+return 0;


Rather than duplicate this code, let's factor it out into a separate 
function.
Yeah, you are totally right, we have at least 3/4 uses of that. Care to 
propose a name?

Also, your ChangeLog has nothing to do with the patch.  :)

:) I attached 58581 instead of 58561.

Paolo.


Re: PATCH: PR target/59672: Add -m16 support for x86

2014-01-29 Thread Jakub Jelinek
On Wed, Jan 29, 2014 at 08:39:55AM -0800, H.J. Lu wrote:
> -m16 is used by Linux kernel, which checks if the compiler supports -m16
> and uses it if it does. Adding gas --code16gcc check is an additional change
> in Linux kernel.  Clang already supports -m16, which generates objects
> directly.  Adding gas --code16gcc check doesn't help clang.  Add -m16
> to gcc makes gcc and clang consistent to Linux kernel build.

Not everything clang/llvm comes up with is a good idea to follow (numerous
examples in mind, won't list them here, don't want to start a flamewar).
Given that .code16gcc is really a hack in the assembler, I really think it
would be much better idea to just let kernel use -Wa,--code16gcc for this hack.
Sure, if somebody started a full-blown 16-bit code generation support as
opposed to .code16gcc, -m16 would make sense (unless it would be a separate
backend).

Jakub


Re: [C++ Patch] PR 58674

2014-01-29 Thread Jason Merrill

OK.

Jason


Re: C++ PATCH for c++/53756 (-g and C++1y auto)

2014-01-29 Thread Jason Merrill

On 01/29/2014 05:37 AM, Andreas Schwab wrote:

Jason Merrill  writes:


+// { dg-final { scan-assembler "a1.*(0x\[0-9a-f\]+)\[ \t\]*# DW_AT_type.*\\1. 
DW_TAG_unspecified_type.*DW_AT_specification\[\n\r\]{1,2}\[^\n\r\]*(0x\[0-9a-f\]+)\[ 
\t\]*# DW_AT_type.*\\2. DW_TAG_base_type" } }


This regexp is completely broken.


I'll fix it shortly.

Jason




Re: C++ PATCH for c++/53756 (-g and C++1y auto)

2014-01-29 Thread Jason Merrill

On 01/29/2014 11:48 AM, Paolo Carlini wrote:

Rather than duplicate this code, let's factor it out into a separate
function.

Yeah, you are totally right, we have at least 3/4 uses of that. Care to
propose a name?


is_cxx_auto?

Jason



Re: [C++ Patch] PR 58846

2014-01-29 Thread Jason Merrill

OK.

Jason


Re: PATCH: PR target/59672: Add -m16 support for x86

2014-01-29 Thread H.J. Lu
On Wed, Jan 29, 2014 at 8:52 AM, Jakub Jelinek  wrote:
> On Wed, Jan 29, 2014 at 08:39:55AM -0800, H.J. Lu wrote:
>> -m16 is used by Linux kernel, which checks if the compiler supports -m16
>> and uses it if it does. Adding gas --code16gcc check is an additional change
>> in Linux kernel.  Clang already supports -m16, which generates objects
>> directly.  Adding gas --code16gcc check doesn't help clang.  Add -m16
>> to gcc makes gcc and clang consistent to Linux kernel build.
>
> Not everything clang/llvm comes up with is a good idea to follow (numerous
> examples in mind, won't list them here, don't want to start a flamewar).
> Given that .code16gcc is really a hack in the assembler, I really think it
> would be much better idea to just let kernel use -Wa,--code16gcc for this 
> hack.
> Sure, if somebody started a full-blown 16-bit code generation support as
> opposed to .code16gcc, -m16 would make sense (unless it would be a separate
> backend).

As for as Linux kernel is concerned, they want -m16 to generate 16-bit codes
from C source, .code16gcc or a separate 16-bit backend make no difference
to them.


-- 
H.J.


[PATCH][4.7] Backport Extremely large LPBX arrays fix (PR gcov-profile/55650)

2014-01-29 Thread Markus Trippelsdorf
This is a backport of r194470 to the gcc-4.7 branch. It fixes a case
were n_functions in coverage_obj_finish is 0 and the resulting array
contains 0x1 elements.

(Mike Hommey pointed out that Fixefox PGO-build is broken using 4.7
because of this bug)

Bootstrapped and tested on x86_64-unknown-linux-gnu.
OK for gcc-4_7-branch?

---
 gcc/ChangeLog |  9 +
 gcc/coverage.c|  3 +++
 gcc/testsuite/ChangeLog   |  9 +
 gcc/testsuite/g++.dg/other/pr55650.C  | 21 +
 gcc/testsuite/g++.dg/other/pr55650.cc |  4 
 5 files changed, 46 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/other/pr55650.C
 create mode 100644 gcc/testsuite/g++.dg/other/pr55650.cc

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c8e08cf9a40b..4cfc1b1d0c80 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2014-01-29  Markus Trippelsdorf  
+
+   Backport from mainline
+   2012-12-13  Jakub Jelinek  
+
+   PR gcov-profile/55650
+   * coverage.c (coverage_obj_init): Return false if no functions
+   are being emitted.
+
 2014-01-25  Walter Lee  
 
Backport from mainline
diff --git a/gcc/coverage.c b/gcc/coverage.c
index c64125ad58b0..8a113a50c2e2 100644
--- a/gcc/coverage.c
+++ b/gcc/coverage.c
@@ -988,6 +988,9 @@ coverage_obj_init (void)
   /* The function is not being emitted, remove from list.  */
   *fn_prev = fn->next;
 
+  if (functions_head == NULL)
+return false;
+
   for (ix = 0; ix != GCOV_COUNTERS; ix++)
 if ((1u << ix) & prg_ctr_mask)
   n_counters++;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a0320c6401b8..152554dcfcda 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2014-01-29  Markus Trippelsdorf  
+
+   Backport from mainline
+   2012-12-13  Jakub Jelinek  
+
+   PR gcov-profile/55650
+   * g++.dg/other/pr55650.C: New test.
+   * g++.dg/other/pr55650.cc: New file.
+
 2014-01-26  Mikael Morin  
 
PR fortran/58007
diff --git a/gcc/testsuite/g++.dg/other/pr55650.C 
b/gcc/testsuite/g++.dg/other/pr55650.C
new file mode 100644
index ..fc52b19f5d30
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/pr55650.C
@@ -0,0 +1,21 @@
+// PR gcov-profile/55650
+// { dg-do link }
+// { dg-options "-O2 -fprofile-generate" }
+// { dg-additional-sources "pr55650.cc" }
+
+struct A
+{
+  virtual void foo ();
+};
+
+struct B : public A
+{
+  B ();
+  void foo () {}
+};
+
+inline A *
+bar ()
+{
+  return new B;
+}
diff --git a/gcc/testsuite/g++.dg/other/pr55650.cc 
b/gcc/testsuite/g++.dg/other/pr55650.cc
new file mode 100644
index ..70b41462b57e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/pr55650.cc
@@ -0,0 +1,4 @@
+int
+main ()
+{
+}
-- 
Markus


Re: RFA: MN10300: Fix typo store_movm pattern

2014-01-29 Thread Jeff Law

On 01/29/14 03:53, Nick Clifton wrote:

Hi Alex, Hi Jeff,

   There is a typo in the MN10300 store_movm pattern.  It calls
   mn10300_store_multiple_operation to generate a bit mask of registers
   to be pushed, which it then passes to mn10300_print_reg_list.  But
   mn10300_store_multiple_operation is actually a predicate function
   (defined in predicates.md).  The function that should have been called
   is mn10300_store_multiple_operation_p.

   The patch below is the obvious fix for the typo, but I am wondering
   whether it would be better to rename the two functions.  Eg:

 mn10300_store_multiple_operation   -> mn10300_store_multiple_operation_p
 mn10300_store_multiple_operation_p -> mn10300_store_multiple_regs
Agreed, the naming seems awfully confusing right now.  Feel free to go 
forward with fixing that :-)


jeff



C++ PATCH for c++/59916 (wrong missing return warning on ARM)

2014-01-29 Thread Jason Merrill
The handling of the ARM ctor-returns-this ABI in the new decloning patch 
failed to add a RETURN_EXPR.  Fixed thus.


Tested with cross-compiler to arm-eabi, applying to trunk.
commit e1f2153a7facc47b886b24a5b3507bb4bea3e447
Author: Jason Merrill 
Date:   Wed Jan 29 09:16:51 2014 -0500

	PR c++/59916
	* optimize.c (maybe_thunk_body): Build a RETURN_EXPR for
	cdtor_returns_this case.

diff --git a/gcc/cp/optimize.c b/gcc/cp/optimize.c
index 1b3f10a..b089432 100644
--- a/gcc/cp/optimize.c
+++ b/gcc/cp/optimize.c
@@ -405,8 +405,8 @@ maybe_thunk_body (tree fn, bool force)
 	  clone_result = DECL_RESULT (clone);
 	  modify = build2 (MODIFY_EXPR, TREE_TYPE (clone_result),
 			   clone_result, call);
+	  modify = build1 (RETURN_EXPR, void_type_node, modify);
 	  add_stmt (modify);
-	  BLOCK_VARS (block) = clone_result;
 	}
 	  else
 	{
diff --git a/gcc/testsuite/g++.dg/warn/Wreturn-type-10.C b/gcc/testsuite/g++.dg/warn/Wreturn-type-10.C
new file mode 100644
index 000..2043b6c
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wreturn-type-10.C
@@ -0,0 +1,13 @@
+// PR c++/59916
+// { dg-options "-Os -Wreturn-type" }
+
+class A {};
+
+struct B : virtual public A
+{
+  B();
+  virtual ~B();
+};
+
+B::B() {}
+B::~B() {}


Re: [PATCH][C] Fix PR59905, remove code replacing calls with abort

2014-01-29 Thread Joseph S. Myers
On Wed, 29 Jan 2014, Richard Biener wrote:

> testing reveals diagnostic regressions
> 
> FAIL: gcc.dg/call-diag-2.c abort (test for warnings, line 12)
> FAIL: gcc.dg/call-diag-2.c abort (test for warnings, line 15)
> FAIL: gcc.dg/invalid-call-1.c  (test for warnings, line 16)
> 
> which may be hard to preserve (didn't investigate thoroughly yet),
> one is probably emitted via the call to require_complete_type
> I remove.
> 
> Is it ok to adjust the testcases expectation for what is produced now?

These appear to be about the "will abort" diagnostics - removing those 
dg-message tests, while keeping the dg-warning tests, is fine.

I do think we need a public ubsan todo list, if there isn't already one, 
and sanitization of calls through incompatible types should go on that 
list.

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: RFA: RL78: Fix UMUL and $FP size

2014-01-29 Thread DJ Delorie

Yup, these are OK.  Thanks!


Re: [C++ RFC/Patch] PR 58561

2014-01-29 Thread Cary Coutant
> in this bug we ICE in dwarf2out.c:is_base_type with -g, because it doesn't
> know how to handle the TEMPLATE_TYPE_PARM coming from the C++ front-end and
> representing 'auto' in this kind of C++1y code.
>
> That it shouldn't ICE and return 0 instead I'm pretty sure, I'm less sure
> about the next problem, that is what gen_type_die_with_usage should do:
> build a DW_TAG_unspecified_type, like happens for NULLPTR_TYPE or
> LANG_TYPE?!? Anyway, my wild guessing resulted in adding an hook, per the
> below draft (in any case, tentative names and comments but passes testing).
> Or we want something completely different?

We've been discussing this in the DWARF workgroup, and the current
proposal on the table is to use DW_TAG_unspecified_type, as you have
done here. This looks OK to me (although I kind of wish we had a
better way of testing for "auto" than doing a string compare!).
Depending on further discussions in the workgroup, we'll probably need
to do a bit more work to support auto return types, but I think this
is the right direction.

-cary


Re: [PATCH][PING][AArch64] Specify CRC and Crypto support for Cortex-A53, A57

2014-01-29 Thread Kyrill Tkachov

On 23/01/14 08:58, Kyrill Tkachov wrote:

On 16/01/14 18:10, Kyrill Tkachov wrote:

Hi all,

The Cortex-A53 and Cortex-A57 cores support the CRC32 and Crypto extensions to
the ARMv8-A architecture. This patch adds that information to their definitions
in aarch64-cores.def.

Tested aarch64-none-elf with no regressions.

Ok for trunk? (or next stage1)?

Thanks,
Kyrill

2014-01-16  Kyrylo Tkachov  

   * config/aarch64/aarch64-cores.def (cortex-a53): Specify CRC32
   and crypto support.
   (cortex-a57): Likewise.
   (cortex-a57.cortex-a53): Likewise.

Ping.


Ping^2

Kyrill



Kyrill







Re: C++ PATCH for c++/53756 (-g and C++1y auto)

2014-01-29 Thread Paolo Carlini

Hi,

On 01/29/2014 06:00 PM, Jason Merrill wrote:

On 01/29/2014 11:48 AM, Paolo Carlini wrote:

Rather than duplicate this code, let's factor it out into a separate
function.

Yeah, you are totally right, we have at least 3/4 uses of that. Care to
propose a name?

is_cxx_auto?

Good. I'm finishing testing the attached.

By the way, when I said 3/4 uses (in fact, at least 4 in the file), I 
meant the pattern:


tree name = TYPE_NAME (type);
if (TREE_CODE (name) == TYPE_DECL)
  name = DECL_NAME (name);

which I noticed yesterday. Could be a new macro? (post 4.9 maybe)

Thanks,
Paolo.

///
2014-01-29  Paolo Carlini  

PR c++/58561
* dwarf2out.c (is_cxx_auto): New.
(is_base_type): Use it.
(gen_type_die_with_usage): Likewise.

/testsuite
2014-01-29  Paolo Carlini  

PR c++/58561
* g++.dg/cpp1y/auto-fn23.C: New.
Index: dwarf2out.c
===
--- dwarf2out.c (revision 207273)
+++ dwarf2out.c (working copy)
@@ -10219,6 +10219,23 @@ base_type_die (tree type)
   return base_type_result;
 }
 
+/* A C++ function with deduced return type can have a TEMPLATE_TYPE_PARM
+   named 'auto' in its type: return true for it, false otherwise.  */
+
+static inline bool
+is_cxx_auto (tree type)
+{
+  if (is_cxx ())
+{
+  tree name = TYPE_NAME (type);
+  if (TREE_CODE (name) == TYPE_DECL)
+   name = DECL_NAME (name);
+  if (name == get_identifier ("auto"))
+   return true;
+}
+  return false;
+}
+
 /* Given a pointer to an arbitrary ..._TYPE tree node, return nonzero if the
given input type is a Dwarf "fundamental" type.  Otherwise return null.  */
 
@@ -10252,6 +10269,8 @@ is_base_type (tree type)
   return 0;
 
 default:
+  if (is_cxx_auto (type))
+   return 0;
   gcc_unreachable ();
 }
 
@@ -19830,24 +19849,16 @@ gen_type_die_with_usage (tree type, dw_die_ref con
   break;
 
 default:
-  // A C++ function with deduced return type can have
-  // a TEMPLATE_TYPE_PARM named 'auto' in its type.
-  if (is_cxx ())
+  if (is_cxx_auto (type))
{
- tree name = TYPE_NAME (type);
- if (TREE_CODE (name) == TYPE_DECL)
-   name = DECL_NAME (name);
- if (name == get_identifier ("auto"))
+ if (!auto_die)
{
- if (!auto_die)
-   {
- auto_die = new_die (DW_TAG_unspecified_type,
- comp_unit_die (), NULL_TREE);
- add_name_attribute (auto_die, "auto");
-   }
- equate_type_number_to_die (type, auto_die);
- break;
+ auto_die = new_die (DW_TAG_unspecified_type,
+ comp_unit_die (), NULL_TREE);
+ add_name_attribute (auto_die, "auto");
}
+ equate_type_number_to_die (type, auto_die);
+ break;
}
   gcc_unreachable ();
 }
Index: testsuite/g++.dg/cpp1y/auto-fn23.C
===
--- testsuite/g++.dg/cpp1y/auto-fn23.C  (revision 0)
+++ testsuite/g++.dg/cpp1y/auto-fn23.C  (working copy)
@@ -0,0 +1,9 @@
+// PR c++/58561
+// { dg-options "-std=c++1y -g" }
+
+auto foo();
+
+namespace N
+{
+  using ::foo;
+}


Re: [C++ RFC/Patch] PR 58561

2014-01-29 Thread Paolo Carlini

On 01/29/2014 06:41 PM, Cary Coutant wrote:

in this bug we ICE in dwarf2out.c:is_base_type with -g, because it doesn't
know how to handle the TEMPLATE_TYPE_PARM coming from the C++ front-end and
representing 'auto' in this kind of C++1y code.

That it shouldn't ICE and return 0 instead I'm pretty sure, I'm less sure
about the next problem, that is what gen_type_die_with_usage should do:
build a DW_TAG_unspecified_type, like happens for NULLPTR_TYPE or
LANG_TYPE?!? Anyway, my wild guessing resulted in adding an hook, per the
below draft (in any case, tentative names and comments but passes testing).
Or we want something completely different?

We've been discussing this in the DWARF workgroup, and the current
proposal on the table is to use DW_TAG_unspecified_type, as you have
done here. This looks OK to me (although I kind of wish we had a
better way of testing for "auto" than doing a string compare!).
Depending on further discussions in the workgroup, we'll probably need
to do a bit more work to support auto return types, but I think this
is the right direction.
Thanks Cary. I think Jason already proceeded in this direction in his 
patch for c++/53756:


http://gcc.gnu.org/ml/gcc-patches/2014-01/msg01806.html

and I'm following up with some additional bits for this bug. By the way, 
this recycling of TEMPLATE_TYPE_PARM + name seems weird to me too, I 
noticed it a couple of times already (I think it shows in an open 
diagnostic issue too). I think the alternative would an additional 
TREE_CODE and a lot of uses of it wherever now we just say 
TEMPLATE_TYPE_PARM (eg, in pt.c). Maybe it's worth it, maybe not, I 
don't know if Jason *actually* tried the idea in his local trees.


Paolo.


Re: [PATCH][4.7] Backport Extremely large LPBX arrays fix (PR gcov-profile/55650)

2014-01-29 Thread Richard Biener
On January 29, 2014 6:03:15 PM GMT+01:00, Markus Trippelsdorf 
 wrote:
>This is a backport of r194470 to the gcc-4.7 branch. It fixes a case
>were n_functions in coverage_obj_finish is 0 and the resulting array
>contains 0x1 elements.
>
>(Mike Hommey pointed out that Fixefox PGO-build is broken using 4.7
>because of this bug)
>
>Bootstrapped and tested on x86_64-unknown-linux-gnu.
>OK for gcc-4_7-branch?

Ok.

Thanks,
Richard.

>---
> gcc/ChangeLog |  9 +
> gcc/coverage.c|  3 +++
> gcc/testsuite/ChangeLog   |  9 +
> gcc/testsuite/g++.dg/other/pr55650.C  | 21 +
> gcc/testsuite/g++.dg/other/pr55650.cc |  4 
> 5 files changed, 46 insertions(+)
> create mode 100644 gcc/testsuite/g++.dg/other/pr55650.C
> create mode 100644 gcc/testsuite/g++.dg/other/pr55650.cc
>
>diff --git a/gcc/ChangeLog b/gcc/ChangeLog
>index c8e08cf9a40b..4cfc1b1d0c80 100644
>--- a/gcc/ChangeLog
>+++ b/gcc/ChangeLog
>@@ -1,3 +1,12 @@
>+2014-01-29  Markus Trippelsdorf  
>+
>+  Backport from mainline
>+  2012-12-13  Jakub Jelinek  
>+
>+  PR gcov-profile/55650
>+  * coverage.c (coverage_obj_init): Return false if no functions
>+  are being emitted.
>+
> 2014-01-25  Walter Lee  
> 
>   Backport from mainline
>diff --git a/gcc/coverage.c b/gcc/coverage.c
>index c64125ad58b0..8a113a50c2e2 100644
>--- a/gcc/coverage.c
>+++ b/gcc/coverage.c
>@@ -988,6 +988,9 @@ coverage_obj_init (void)
>   /* The function is not being emitted, remove from list.  */
>   *fn_prev = fn->next;
> 
>+  if (functions_head == NULL)
>+return false;
>+
>   for (ix = 0; ix != GCOV_COUNTERS; ix++)
> if ((1u << ix) & prg_ctr_mask)
>   n_counters++;
>diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
>index a0320c6401b8..152554dcfcda 100644
>--- a/gcc/testsuite/ChangeLog
>+++ b/gcc/testsuite/ChangeLog
>@@ -1,3 +1,12 @@
>+2014-01-29  Markus Trippelsdorf  
>+
>+  Backport from mainline
>+  2012-12-13  Jakub Jelinek  
>+
>+  PR gcov-profile/55650
>+  * g++.dg/other/pr55650.C: New test.
>+  * g++.dg/other/pr55650.cc: New file.
>+
> 2014-01-26  Mikael Morin  
> 
>   PR fortran/58007
>diff --git a/gcc/testsuite/g++.dg/other/pr55650.C
>b/gcc/testsuite/g++.dg/other/pr55650.C
>new file mode 100644
>index ..fc52b19f5d30
>--- /dev/null
>+++ b/gcc/testsuite/g++.dg/other/pr55650.C
>@@ -0,0 +1,21 @@
>+// PR gcov-profile/55650
>+// { dg-do link }
>+// { dg-options "-O2 -fprofile-generate" }
>+// { dg-additional-sources "pr55650.cc" }
>+
>+struct A
>+{
>+  virtual void foo ();
>+};
>+
>+struct B : public A
>+{
>+  B ();
>+  void foo () {}
>+};
>+
>+inline A *
>+bar ()
>+{
>+  return new B;
>+}
>diff --git a/gcc/testsuite/g++.dg/other/pr55650.cc
>b/gcc/testsuite/g++.dg/other/pr55650.cc
>new file mode 100644
>index ..70b41462b57e
>--- /dev/null
>+++ b/gcc/testsuite/g++.dg/other/pr55650.cc
>@@ -0,0 +1,4 @@
>+int
>+main ()
>+{
>+}




[C PATCH] Improve locinfo in the C FE (PR c/59940)

2014-01-29 Thread Marek Polacek
Finally I managed to get this patch into regression-free shape.  It
should improve the column info for quite a lot of warnings, fixing
PR59940 on the way.  I had to add location_t to bunch of functions;
SET_EXPR_LOCATION is of no use here - we're dealing with
{VAR,PARM}_DECLs, which do not carry a locus info.  Yet the function
parameters are often called expr...
I had to use expansion_point_location_if_in_system_header to
get this working even with -ftrack-macro-expansion.

Surely there are lots of other spots to fix, but this should be
a step forward.  Interestingly, adding locs here and there sometimes
reminds me of a Whac-A-Mole game.

Regtested/bootstrapped on x86_64-linux, ok for trunk?

2014-01-29  Marek Polacek  

PR c/59940
c-family/
* c-common.h (unsafe_conversion_p): Adjust declaration.
(warnings_for_convert_and_check): Likewise.
(convert_and_check): Likewise.
* c-common.c (unsafe_conversion_p): Add location parameter.  Call
expansion_point_location_if_in_system_header on it.
(warnings_for_convert_and_check): Add location parameter.  Call
expansion_point_location_if_in_system_header on it.  Use it.
(convert_and_check): Add location parameter.  Use it.
(conversion_warning): Likewise.
(c_add_case_label): Adjust convert_and_check calls.
(scalar_to_vector): Adjust unsafe_conversion_p calls.
cp/
* typeck.c (build_ptrmemfunc1): Call convert_and_check with
input_location.
* cvt.c (cp_convert_and_check): Call warnings_for_convert_and_check
with input_location.
* call.c (build_conditional_expr_1): Call unsafe_conversion_p with
loc parameter.
c/
* c-typeck.c (build_function_call_vec): Use loc parameter.
(convert_arguments): Add location parameter.  Use it.
(ep_convert_and_check): Likewise.
(build_atomic_assign): Adjust convert_for_assignment call.
(build_modify_expr): Likewise.
(digest_init): Likewise.
(c_finish_return): Likewise.
(build_conditional_expr): Adjust ep_convert_and_check calls.
(convert_for_assignment): Add rhs_loc parameter.  Use it.
(build_binary_op): Adjust convert_and_check and ep_convert_and_check
calls.
testsuite/
* gcc.dg/pr59940.c: New test.
* gcc.dg/pr35635.c (func3): Move dg-warning.

--- gcc/c-family/c-common.h.mp  2014-01-29 16:32:49.169712645 +0100
+++ gcc/c-family/c-common.h 2014-01-29 16:50:21.980492697 +0100
@@ -749,7 +749,8 @@ extern tree c_common_signed_type (tree);
 extern tree c_common_signed_or_unsigned_type (int, tree);
 extern void c_common_init_ts (void);
 extern tree c_build_bitfield_integer_type (unsigned HOST_WIDE_INT, int);
-extern enum conversion_safety unsafe_conversion_p (tree, tree, bool);
+extern enum conversion_safety unsafe_conversion_p (location_t, tree, tree,
+  bool);
 extern bool decl_with_nonnull_addr_p (const_tree);
 extern tree c_fully_fold (tree, bool, bool *);
 extern tree decl_constant_value_for_optimization (tree);
@@ -769,8 +770,8 @@ extern bool strict_aliasing_warning (tre
 extern void sizeof_pointer_memaccess_warning (location_t *, tree,
  vec *, tree *,
  bool (*) (tree, tree));
-extern void warnings_for_convert_and_check (tree, tree, tree);
-extern tree convert_and_check (tree, tree);
+extern void warnings_for_convert_and_check (location_t, tree, tree, tree);
+extern tree convert_and_check (location_t, tree, tree);
 extern void overflow_warning (location_t, tree);
 extern bool warn_if_unused_value (const_tree, location_t);
 extern void warn_logical_operator (location_t, enum tree_code, tree,
--- gcc/c-family/c-common.c.mp  2014-01-29 16:27:45.487493021 +0100
+++ gcc/c-family/c-common.c 2014-01-29 19:04:53.176531941 +0100
@@ -2526,23 +2526,24 @@ shorten_binary_op (tree result_type, tre
   return result_type;
 }
 
-/* Checks if expression EXPR of real/integer type cannot be converted 
+/* Checks if expression EXPR of real/integer type cannot be converted
to the real/integer type TYPE. Function returns non-zero when:
-   * EXPR is a constant which cannot be exactly converted to TYPE 
-   * EXPR is not a constant and size of EXPR's type > than size of TYPE, 
+   * EXPR is a constant which cannot be exactly converted to TYPE.
+   * EXPR is not a constant and size of EXPR's type > than size of TYPE,
  for EXPR type and TYPE being both integers or both real.
-   * EXPR is not a constant of real type and TYPE is an integer.  
-   * EXPR is not a constant of integer type which cannot be 
- exactly converted to real type.  
+   * EXPR is not a constant of real type and TYPE is an integer.
+   * EXPR is not a constant of integer type which cannot be
+ exactly converted to real type.
Function allows conversi

Re: [PATCH][C] Fix PR59905, remove code replacing calls with abort

2014-01-29 Thread Marek Polacek
On Wed, Jan 29, 2014 at 05:06:43PM +, Joseph S. Myers wrote:
> I do think we need a public ubsan todo list, if there isn't already one, 
> and sanitization of calls through incompatible types should go on that 
> list.

I've put that TODO on my TODO. :)
(But firstly the wiki has to let me create an account...)

Marek


Re: profile mode fix

2014-01-29 Thread François Dumont
Here is the patch that simply consider 55083 as not supported 
except in normal mode. This is a temporary workaround for 4.9 release so 
I prefer not to introduce a dg-profile-mode-unsupported or something 
like that. Those tests will simply appear as not supported for debug and 
parallel mode even if they are, not a big deal, no ?


Tested under Linux x86_64 normal and profile mode.

2014-01-29  François Dumont 

PR libstdc++/55083
* testsuite/23_containers/unordered_multimap/55043.cc: Add
dg-require-normal-mode because not supported in profile mode.
* testsuite/23_containers/unordered_set/55043.cc: Likewise.
* testsuite/23_containers/unordered_multiset/55043.cc: Likewise.
* testsuite/23_containers/unordered_map/55043.cc: Likewise.

Ok to commit ?

François


On 01/27/2014 11:18 PM, François Dumont wrote:
Indeed, default constructor and copy constructor shall not be noexcept 
qualified.


IMO we should be able to make move constructor noexcept by using a 
special allocator for the underlying unordered_map that would allow to 
replace an entry with an other one without requiring a 
deallocate/allocate. It would be the same kind of allocator keeping a 
released instance in cache that you already talk about to enhance 
std::deque behavior especially when used in a std::queue.


For 4.9 we could consider that this test is not supported in profile 
mode and I will work on it for next version.


François





Index: testsuite/23_containers/unordered_multimap/55043.cc
===
--- testsuite/23_containers/unordered_multimap/55043.cc	(revision 207207)
+++ testsuite/23_containers/unordered_multimap/55043.cc	(working copy)
@@ -1,5 +1,6 @@
 // { dg-options "-std=gnu++0x" }
 // { dg-do compile }
+// { dg-require-normal-mode "" }
 
 // Copyright (C) 2013-2014 Free Software Foundation, Inc.
 //
Index: testsuite/23_containers/unordered_set/55043.cc
===
--- testsuite/23_containers/unordered_set/55043.cc	(revision 207207)
+++ testsuite/23_containers/unordered_set/55043.cc	(working copy)
@@ -1,5 +1,6 @@
 // { dg-options "-std=gnu++0x" }
 // { dg-do compile }
+// { dg-require-normal-mode "" }
 
 // Copyright (C) 2013-2014 Free Software Foundation, Inc.
 //
Index: testsuite/23_containers/unordered_multiset/55043.cc
===
--- testsuite/23_containers/unordered_multiset/55043.cc	(revision 207207)
+++ testsuite/23_containers/unordered_multiset/55043.cc	(working copy)
@@ -1,5 +1,6 @@
 // { dg-options "-std=gnu++0x" }
 // { dg-do compile }
+// { dg-require-normal-mode "" }
 
 // Copyright (C) 2013-2014 Free Software Foundation, Inc.
 //
Index: testsuite/23_containers/unordered_map/55043.cc
===
--- testsuite/23_containers/unordered_map/55043.cc	(revision 207207)
+++ testsuite/23_containers/unordered_map/55043.cc	(working copy)
@@ -1,5 +1,6 @@
 // { dg-options "-std=gnu++0x" }
 // { dg-do compile }
+// { dg-require-normal-mode "" }
 
 // Copyright (C) 2013-2014 Free Software Foundation, Inc.
 //



Re: profile mode fix

2014-01-29 Thread Jonathan Wakely
On 29 January 2014 20:06, François Dumont  wrote:
> Here is the patch that simply consider 55083 as not supported except in
> normal mode. This is a temporary workaround for 4.9 release so I prefer not
> to introduce a dg-profile-mode-unsupported or something like that. Those
> tests will simply appear as not supported for debug and parallel mode even
> if they are, not a big deal, no ?

But with that change we don't find out if those tests regress in debug mode  :-(

I prefer to just add noexcept to the profile mode move constructor,
and if it throws then the program terminates.  If you run out of
memory when using profile mode then terminating seems reasonable to
me;  I don't think people are using profile mode to test how their
programs handle std::bad_alloc.

Put another way, if your program runs out of memory *because* of
profile mode, then the results of the profiling will not give you
useful data about how your program usually behaves. Using profile mode
has altered the behaviour of the program.  So in that situation simply
calling std::terminate() makes sense.


C++ PATCH for c++/59956 (ICE with friend template)

2014-01-29 Thread Jason Merrill
In this testcase, tsubst_friend_function was getting confused trying to 
instantiate the friend template because it didn't recognize that it was 
a template.  Fixed by keeping the TEMPLATE_DECL on the friends list and 
dealing with that appropriately in tsubst_friend_function. 
is_specialization_of_friend already handles it fine.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 0440d57fa786b012113a7dca2161557546b9b70b
Author: Jason Merrill 
Date:   Wed Jan 29 15:14:23 2014 -0500

	PR c++/59956
	* friend.c (do_friend): Pass the TEMPLATE_DECL to add_friend if we
	have a friend template in a class template.
	* pt.c (tsubst_friend_function): Look through it.
	(push_template_decl_real): A friend member template is
	primary.

diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c
index 4fd6ffa..150b392 100644
--- a/gcc/cp/friend.c
+++ b/gcc/cp/friend.c
@@ -501,7 +501,13 @@ do_friend (tree ctype, tree declarator, tree decl,
   ? current_template_parms
   : NULL_TREE);
 
-	  if (template_member_p && decl && TREE_CODE (decl) == FUNCTION_DECL)
+	  if ((template_member_p
+	   /* Always pull out the TEMPLATE_DECL if we have a friend
+		  template in a class template so that it gets tsubsted
+		  properly later on (59956).  tsubst_friend_function knows
+		  how to tell this apart from a member template.  */
+	   || (class_template_depth && friend_depth))
+	  && decl && TREE_CODE (decl) == FUNCTION_DECL)
 	decl = DECL_TI_TEMPLATE (decl);
 
 	  if (decl)
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 7f1b6d5..548e191 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -4615,7 +4615,8 @@ push_template_decl_real (tree decl, bool is_friend)
 DECL_CONTEXT (decl) = FROB_CONTEXT (current_namespace);
 
   /* See if this is a primary template.  */
-  if (is_friend && ctx)
+  if (is_friend && ctx
+  && uses_template_parms_level (ctx, processing_template_decl))
 /* A friend template that specifies a class context, i.e.
  template  friend void A::f();
is not primary.  */
@@ -8424,10 +8425,17 @@ tsubst_friend_function (tree decl, tree args)
 
   if (COMPLETE_TYPE_P (context))
 	{
+	  tree fn = new_friend;
+	  /* do_friend adds the TEMPLATE_DECL for any member friend
+	 template even if it isn't a member template, i.e.
+	   template  friend A::f();
+	 Look through it in that case.  */
+	  if (TREE_CODE (fn) == TEMPLATE_DECL
+	  && !PRIMARY_TEMPLATE_P (fn))
+	fn = DECL_TEMPLATE_RESULT (fn);
 	  /* Check to see that the declaration is really present, and,
 	 possibly obtain an improved declaration.  */
-	  tree fn = check_classfn (context,
-   new_friend, NULL_TREE);
+	  fn = check_classfn (context, fn, NULL_TREE);
 
 	  if (fn)
 	new_friend = fn;
diff --git a/gcc/testsuite/g++.dg/template/friend55.C b/gcc/testsuite/g++.dg/template/friend55.C
new file mode 100644
index 000..4abe6ce
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/friend55.C
@@ -0,0 +1,18 @@
+// PR c++/59956
+
+template  struct A;
+template  class B {
+  int i;
+  template  friend void A::impl();
+};
+
+B<0> b1;
+templatestruct A { void impl(); };
+B<1> b2;
+
+template void A::impl() { ++b1.i; ++b2.i; }
+
+int main()
+{
+  A<0>().impl();
+}


[patch] fix libstdc++/21609 - deprecate __gnu_cxx::array_allocator

2014-01-29 Thread Jonathan Wakely

This deprecates this GNU extension which isn't really a conforming
allocator anyway.

PR libstdc++/21609
* include/ext/array_allocator.h: Add deprecated attribute.

Tested x86_64-linux, committed to trunk.

I'll update the gcc-4.9/changes.html page to note this.
commit e6682598d14537b97975e0dc5ee8a96353af2712
Author: Jonathan Wakely 
Date:   Wed Jan 29 20:20:57 2014 +

PR libstdc++/21609
* include/ext/array_allocator.h: Add deprecated attribute.

diff --git a/libstdc++-v3/include/ext/array_allocator.h 
b/libstdc++-v3/include/ext/array_allocator.h
index f584b5b..f807495 100644
--- a/libstdc++-v3/include/ext/array_allocator.h
+++ b/libstdc++-v3/include/ext/array_allocator.h
@@ -95,7 +95,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   void 
   destroy(pointer __p) { __p->~_Tp(); }
 #endif
-};  
+} _GLIBCXX_DEPRECATED;
 
   /**
*  @brief  An allocator that uses previously allocated memory.
@@ -128,7 +128,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 public:
  template
 struct rebind
-{ typedef array_allocator<_Tp1, _Array1> other; };
+{
+ typedef array_allocator<_Tp1, _Array1> other _GLIBCXX_DEPRECATED;
+   } _GLIBCXX_DEPRECATED;
 
   array_allocator(array_type* __array = 0) _GLIBCXX_USE_NOEXCEPT 
   : _M_array(__array), _M_used(size_type()) { }
@@ -152,7 +154,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
_M_used += __n;
return __ret;
   }
-};
+} _GLIBCXX_DEPRECATED;
 
   template
 inline bool


Re: C++ PATCH for c++/53756 (-g and C++1y auto)

2014-01-29 Thread Jason Merrill

OK, thanks.


By the way, when I said 3/4 uses (in fact, at least 4 in the file), I meant the 
pattern:

tree name = TYPE_NAME (type);
if (TREE_CODE (name) == TYPE_DECL)
  name = DECL_NAME (name);

which I noticed yesterday. Could be a new macro? (post 4.9 maybe)


Sure.  Maybe call it TYPE_IDENTIFIER, replacing the one in cp-tree.h 
with a conditional one in tree.h.


Jason


C++ PATCH for c++/58466 (ICE with variadics and partial specialization)

2014-01-29 Thread Jason Merrill
Here the problem was that when we built up A<'X'> the arguments to A 
were 'X' and the empty set for the parameter pack.  When we then use 
that to deduce the arguments for C, we got confused by the empty set and 
tried to treat it as another argument, leading to bad times.  Fixed by 
calling expand_template_argument_pack in unify_pack_expansion.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 8494bec4e85a987375b3e1044574ddb89fa6e120
Author: Jason Merrill 
Date:   Wed Jan 29 15:37:41 2014 -0500

	PR c++/58466
	* pt.c (unify_pack_expansion): Call expand_template_argument_pack.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 943255d..9be9171 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -16897,6 +16897,9 @@ unify_pack_expansion (tree tparms, tree targs, tree packed_parms,
   tree pattern = PACK_EXPANSION_PATTERN (parm);
   tree pack, packs = NULL_TREE;
   int i, start = TREE_VEC_LENGTH (packed_parms) - 1;
+
+  packed_args = expand_template_argument_pack (packed_args);
+
   int len = TREE_VEC_LENGTH (packed_args);
 
   /* Determine the parameter packs we will be deducing from the
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic147.C b/gcc/testsuite/g++.dg/cpp0x/variadic147.C
new file mode 100644
index 000..7f606d8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic147.C
@@ -0,0 +1,10 @@
+// PR c++/58466
+// { dg-require-effective-target c++11 }
+
+template struct A;
+
+template struct B;
+
+template struct B> {};
+
+B> b;


Re: [PING] Re: Add const char* constructors for exception classes in

2014-01-29 Thread Oleg Endo
On Wed, 2014-01-29 at 15:21 +, Jonathan Wakely wrote:
> On 26/01/14 15:15 +0100, Oleg Endo wrote:
> >> Files in libstdc++-v3/src/c++98/ seem to be never compiled with C++11.
> >> Thus I can think of two options:
> >> 1) Add const char* ctors for C++98 and C++11.
> >> 2) Add #ifdef'ed declarations to libstdc++-v3/include/std/stdexcept and
> >> add a new file libstdc++-v3/src/c++11/stdexcept.cc with the
> >> implementations.
> 
> 3) Move stdexcept.cc from src/c++98 to src/c++11
> 4) Define the functions inline using forwarding constructors, which
> means we don't need new exports.
> 
> >> The attached patch does 1).
> 
> I don't think we want the constructors in C++03 mode though, it could
> break some valid programs e.g. a custom string type with implicit
> conversion to const char* and std::string can be passed to an exception
> constructor in C++03, but adding the overloads would make it
> ambiguous.

Good point.

> 
> I think I prefer option 4, it avoids adding new exports during Stage 3
> (although the patch was initially posted during Stage 1, it is now
> quite late to add new exports, which is not your fault but still a
> concern.)

My original intention was to eliminate code bloat when doing something
like  throw std::logic_error ("cold coffee");
If the const char* overloads are inlined it will emit code to construct
an std::string from const char* in user code where the exception is
being constructed over and over again.  The idea was to move that code
into the std library.
BTW the original patch was posted during Stage 3 (19.12.2013).  I don't
mind waiting until Stage 1 if adding exports now is a problem.

Cheers,
Oleg



Re: [C PATCH] Improve locinfo in the C FE (PR c/59940)

2014-01-29 Thread Joseph S. Myers
On Wed, 29 Jan 2014, Marek Polacek wrote:

> Finally I managed to get this patch into regression-free shape.  It
> should improve the column info for quite a lot of warnings, fixing
> PR59940 on the way.  I had to add location_t to bunch of functions;
> SET_EXPR_LOCATION is of no use here - we're dealing with
> {VAR,PARM}_DECLs, which do not carry a locus info.  Yet the function
> parameters are often called expr...
> I had to use expansion_point_location_if_in_system_header to
> get this working even with -ftrack-macro-expansion.
> 
> Surely there are lots of other spots to fix, but this should be
> a step forward.  Interestingly, adding locs here and there sometimes
> reminds me of a Whac-A-Mole game.
> 
> Regtested/bootstrapped on x86_64-linux, ok for trunk?

The c/ and c-family/ changes are OK.  (One of the other things left to fix 
would be that it looks like convert_arguments could do with locations for 
each argument, rather than just a single main location.)

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: [PATCH][C] Fix PR59905, remove code replacing calls with abort

2014-01-29 Thread Joseph S. Myers
On Wed, 29 Jan 2014, Marek Polacek wrote:

> On Wed, Jan 29, 2014 at 05:06:43PM +, Joseph S. Myers wrote:
> > I do think we need a public ubsan todo list, if there isn't already one, 
> > and sanitization of calls through incompatible types should go on that 
> > list.
> 
> I've put that TODO on my TODO. :)
> (But firstly the wiki has to let me create an account...)

Creating an account isn't supposed to be hard, but once one's created 
someone needs to add it to the list of approved editors.  
( has my thoughts 
on what we might ideally track for possible sanitization.)

-- 
Joseph S. Myers
jos...@codesourcery.com


Re: C++ PATCH for c++/53756 (-g and C++1y auto)

2014-01-29 Thread Paolo Carlini

Hi,

On 01/29/2014 09:49 PM, Jason Merrill wrote:

OK, thanks.

Applied.
By the way, when I said 3/4 uses (in fact, at least 4 in the file), I 
meant the pattern:


tree name = TYPE_NAME (type);
if (TREE_CODE (name) == TYPE_DECL)
  name = DECL_NAME (name);

which I noticed yesterday. Could be a new macro? (post 4.9 maybe)


Sure.  Maybe call it TYPE_IDENTIFIER, replacing the one in cp-tree.h 
with a conditional one in tree.h.
Interesting. If you like we can do now the below, as preparatory 
clean-up for the above, which I would do when 4.9 branches.


Thanks,
Paolo.

/
2014-01-29  Paolo Carlini  

* decl.c (duplicate_decls, typename_hash, typename_compare):
Use TYPE_IDENTIFIER.
* error.c (dump_type): Likewise.
* mangle.c (dump_substitution_candidates): Likewise.
Index: decl.c
===
--- decl.c  (revision 207281)
+++ decl.c  (working copy)
@@ -1381,7 +1381,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool
 
if (TYPE_PTR_P (t)
&& TYPE_NAME (TREE_TYPE (t))
-   && DECL_NAME (TYPE_NAME (TREE_TYPE (t)))
+   && TYPE_IDENTIFIER (TREE_TYPE (t))
   == get_identifier ("FILE")
&& compparms (TREE_CHAIN (t1), TREE_CHAIN (t2)))
  {
@@ -3213,7 +3213,7 @@ typename_hash (const void* k)
   const_tree const t = (const_tree) k;
 
   hash = (htab_hash_pointer (TYPE_CONTEXT (t))
- ^ htab_hash_pointer (DECL_NAME (TYPE_NAME (t;
+ ^ htab_hash_pointer (TYPE_IDENTIFIER (t)));
 
   return hash;
 }
@@ -3235,7 +3235,7 @@ typename_compare (const void * k1, const void * k2
   const_tree const t1 = (const_tree) k1;
   const typename_info *const t2 = (const typename_info *) k2;
 
-  return (DECL_NAME (TYPE_NAME (t1)) == t2->name
+  return (TYPE_IDENTIFIER (t1) == t2->name
  && TYPE_CONTEXT (t1) == t2->scope
  && TYPENAME_TYPE_FULLNAME (t1) == t2->template_id
  && TYPENAME_IS_ENUM_P (t1) == t2->enum_p
Index: error.c
===
--- error.c (revision 207281)
+++ error.c (working copy)
@@ -512,7 +512,7 @@ dump_type (cxx_pretty_printer *pp, tree t, int fla
  pp_cxx_colon_colon (pp);
}
   pp_cxx_ws_string (pp, "template");
-  dump_type (pp, DECL_NAME (TYPE_NAME (t)), flags);
+  dump_type (pp, TYPE_IDENTIFIER (t), flags);
   break;
 
 case TYPEOF_TYPE:
Index: mangle.c
===
--- mangle.c(revision 207281)
+++ mangle.c(working copy)
@@ -323,7 +323,7 @@ dump_substitution_candidates (void)
   else if (TREE_CODE (el) == TREE_LIST)
name = IDENTIFIER_POINTER (DECL_NAME (TREE_VALUE (el)));
   else if (TYPE_NAME (el))
-   name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (el)));
+   name = IDENTIFIER_POINTER (TYPE_IDENTIFIER (el));
   fprintf (stderr, " S%d_ = ", i - 1);
   if (TYPE_P (el) &&
  (CP_TYPE_RESTRICT_P (el)


Re: [PING] Re: Add const char* constructors for exception classes in

2014-01-29 Thread Jonathan Wakely
On 29 January 2014 21:17, Oleg Endo wrote:
> My original intention was to eliminate code bloat when doing something
> like  throw std::logic_error ("cold coffee");
> If the const char* overloads are inlined it will emit code to construct
> an std::string from const char* in user code where the exception is
> being constructed over and over again.  The idea was to move that code
> into the std library.

That's exactly what happens today with the constructors that only take
a std::string, so it wouldn't be any worse than what we have now,
would it?

> BTW the original patch was posted during Stage 3 (19.12.2013).  I don't
> mind waiting until Stage 1 if adding exports now is a problem.

OK, let's wait and decide how we want to do it properly in stage 1.

(If we're going to make various changes that impact the ABI during the
next stage 1 we might even want to consider changing the
std::exception base class to store something like a
std::shared_ptr so that copying an exception object will
never throw an exception, which is something I've been thinking about
recently.)


Re: [C PATCH] Improve locinfo in the C FE (PR c/59940)

2014-01-29 Thread Marek Polacek
On Wed, Jan 29, 2014 at 09:19:35PM +, Joseph S. Myers wrote:
> The c/ and c-family/ changes are OK.  (One of the other things left to fix 
> would be that it looks like convert_arguments could do with locations for 
> each argument, rather than just a single main location.)

Thanks.  Yes, tweaking convert_arguments is my next task; it's PR59963.

Jason, is that (tiny) C++ part ok with you?

Marek


C++ PATCH for c++/59989 (ICE with variadics)

2014-01-29 Thread Jason Merrill
We counted the pack and all the elements of the pack, giving us a final 
count one too high.


Tested x86_64-pc-linux-gnu, applying to trunk and 4.8.
commit b75c08746dc30ac50e908e8d520042f4157281f9
Author: Jason Merrill 
Date:   Wed Jan 29 16:41:23 2014 -0500

	PR c++/59989
	* pt.c (expand_template_argument_pack): Correct
	non_default_args_count calculation.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 9be9171..c9c6b37 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -3471,7 +3471,7 @@ expand_template_argument_pack (tree args)
   for (i = 0; i < num_packed; ++i, ++out_arg)
 TREE_VEC_ELT (result_args, out_arg) = TREE_VEC_ELT(packed, i);
 	  if (non_default_args_count > 0)
-	non_default_args_count += num_packed;
+	non_default_args_count += num_packed - 1;
 }
   else
 {
diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic148.C b/gcc/testsuite/g++.dg/cpp0x/variadic148.C
new file mode 100644
index 000..a4ee635
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/variadic148.C
@@ -0,0 +1,6 @@
+// PR c++/59989
+// { dg-require-effective-target c++11 }
+
+template struct X {};
+template class D, typename ...U> int test(D*);
+int n = test(0);	// { dg-error "no match" }


Re: [PING] Re: Add const char* constructors for exception classes in

2014-01-29 Thread Oleg Endo
On Wed, 2014-01-29 at 21:38 +, Jonathan Wakely wrote:
> On 29 January 2014 21:17, Oleg Endo wrote:
> > My original intention was to eliminate code bloat when doing something
> > like  throw std::logic_error ("cold coffee");
> > If the const char* overloads are inlined it will emit code to construct
> > an std::string from const char* in user code where the exception is
> > being constructed over and over again.  The idea was to move that code
> > into the std library.
> 
> That's exactly what happens today with the constructors that only take
> a std::string, so it wouldn't be any worse than what we have now,
> would it?

Sorry, I'm not sure I understand your question.  Maybe you meant "any
better than what we have"?  Anyway, I've attached two outputs that show
what I mean.  The version with the const char* ctor overloads
implemented in the library is significantly shorter in the throwing path
(5x function call vs. 7x function call + other inlined std::string ctor
code).

> 
> > BTW the original patch was posted during Stage 3 (19.12.2013).  I don't
> > mind waiting until Stage 1 if adding exports now is a problem.
> 
> OK, let's wait and decide how we want to do it properly in stage 1.

Sure.  Actually I've missed some of the other exception types in
system_error, which should be added, too.  That would eliminate the
   TODO: Add const char* ctors to all exceptions.

I'd also propose moving the system_error ctor implementations into the
library as well, for the same reasons as above.

> 
> (If we're going to make various changes that impact the ABI during the
> next stage 1 we might even want to consider changing the
> std::exception base class to store something like a
> std::shared_ptr so that copying an exception object will
> never throw an exception, which is something I've been thinking about
> recently.)

Wouldn't using std::shared_ptr introduce an additional heap
allocation when creating the exception, though?
How about storing the exception message in a plain zero terminated
string instead?  This would require only one heap allocation if the
string data is prefixed with a refcount variable.  Basically,
std::make_shared re-invented because it doesn't work with arrays.
Or maybe implement N3640 + N3641 first (even if for library internal use
only as a start)...

Cheers,
Oleg
	.file	"sh_tmp.cpp"
	.text
	.little
	.section	.rodata.str1.4,"aMS",@progbits,1
	.align 2
.LC0:
	.string	"multiplication by zero"
	.text
	.align 1
	.align 2
	.global	__Z6test03ii
	.type	__Z6test03ii, @function
__Z6test03ii:
.LFB746:
	.cfi_startproc
	.cfi_personality 0,___gxx_personality_v0
	.cfi_lsda 0xb,.LLSDA746
	mov.l	r8,@-r15	! 183	movsi_ie/9	[length = 2]
	.cfi_def_cfa_offset 4
	.cfi_offset 8, -4
	mov.l	r9,@-r15	! 184	movsi_ie/9	[length = 2]
	.cfi_def_cfa_offset 8
	.cfi_offset 9, -8
	sts.l	pr,@-r15	! 185	movsi_ie/11	[length = 2]
	.cfi_def_cfa_offset 12
	.cfi_offset 17, -12
	add	#-8,r15	! 186	*addsi3_compact	[length = 2]
	.cfi_def_cfa_offset 20
	tst	r5,r5	! 7	cmpeqsi_t/1	[length = 2]
	bt/s	.L19	! 8	*cbranch_t	[length = 2]
	mul.l	r5,r4	! 68	mul_l	[length = 2]
	sts	macl,r0	! 116	movsi_ie/7	[length = 2]
	add	#8,r15	! 191	*addsi3_compact	[length = 2]
	.cfi_remember_state
	.cfi_def_cfa_offset 12
	lds.l	@r15+,pr	! 193	movsi_ie/15	[length = 2]
	.cfi_restore 17
	.cfi_def_cfa_offset 8
	mov.l	@r15+,r9	! 194	movsi_ie/6	[length = 2]
	.cfi_restore 9
	.cfi_def_cfa_offset 4
	rts		! 197	*return_i	[length = 2]
	mov.l	@r15+,r8	! 195	movsi_ie/6	[length = 2]
	.cfi_def_cfa_offset 0
	.cfi_restore 8
	.align 1
.L19:
	.cfi_restore_state
	mov.l	.L21,r0	! 171	movsi_ie/1	[length = 2]
	jsr	@r0	! 12	call_valuei	[length = 2]
	mov	#8,r4	! 11	movsi_ie/3	[length = 2]
	mov.l	.L22,r1	! 170	movsi_ie/1	[length = 2]
	mov	r15,r4	! 174	movsi_ie/2	[length = 2]
	mov	r15,r6	! 175	movsi_ie/2	[length = 2]
	mov	r0,r9	! 13	movsi_ie/2	[length = 2]
	add	#4,r4	! 19	*addsi3_compact	[length = 2]
	mov.l	.L23,r5	! 20	movsi_ie/1	[length = 2]
.LEHB0:
	jsr	@r1	! 22	calli	[length = 2]
	add	#2,r6	! 21	*addsi3_compact	[length = 2]
.LEHE0:
	mov.l	.L24,r1	! 169	movsi_ie/1	[length = 2]
	mov	r15,r5	! 176	movsi_ie/2	[length = 2]
	mov	r9,r4	! 26	movsi_ie/2	[length = 2]
.LEHB1:
	jsr	@r1	! 28	calli	[length = 2]
	add	#4,r5	! 27	*addsi3_compact	[length = 2]
.LEHE1:
	mov.l	@(4,r15),r1	! 32	movsi_ie/6	[length = 2]
	mov.l	.L33,r2	! 34	movsi_ie/1	[length = 2]
	mov	r1,r4	! 177	movsi_ie/2	[length = 2]
	add	#-12,r4	! 33	*addsi3_compact	[length = 2]
	cmp/eq	r2,r4	! 35	cmpeqsi_t/3	[length = 2]
	bf/s	.L20	! 36	*cbranch_t	[length = 2]
	add	#-64,r1	! 42	*addsi3_compact	[length = 2]
.L4:
	mov.l	.L26,r1	! 167	movsi_ie/1	[length = 2]
	mov.l	.L27,r5	! 62	movsi_ie/1	[length = 2]
	mov.l	.L28,r6	! 63	movsi_ie/1	[length = 2]
.LEHB2:
	jsr	@r1	! 64	calli	[length = 2]
	mov	r9,r4	! 61	movsi_ie/2	[length = 2]
	.align 1
.L11:
	mov	r4,r8	! 123	movsi_ie/2	[length = 2]
.L17:
	mov.l	.L34,r1	! 147	movsi_ie/1	[length = 2]
	lds.l	@r1+,fpscr	! 207	fpu_switch/2	[length = 2]
.L10:
	mov.l	.L30,r1	! 165	movsi_ie/1	[length = 2]
	j

[patch] fix libstdc++/57266 - pretty printer docs

2014-01-29 Thread Jonathan Wakely

Some doc improvements. I decided it's time to regenerate the HTML
pages too.

Committed to trunk.

commit bbf5d74cf6f1399413217bc70ebfecb360efe822
Author: Jonathan Wakely 
Date:   Wed Jan 29 20:31:07 2014 +

PR libstdc++/57226
* doc/xml/manual/debug.xml (debug.gdb): Update documentation for
installation and use of python printers.
* doc/xml/manual/status_cxx2011.xml: Update.
* doc/html/*: Regenerate.

diff --git a/libstdc++-v3/doc/xml/manual/debug.xml 
b/libstdc++-v3/doc/xml/manual/debug.xml
index c354207..5e84495 100644
--- a/libstdc++-v3/doc/xml/manual/debug.xml
+++ b/libstdc++-v3/doc/xml/manual/debug.xml
@@ -263,8 +263,8 @@
 
 
   These settings can either be switched on in at the GDB command line,
-  or put into a .gdbint file to establish default debugging
-  characteristics, like so:
+  or put into a .gdbinit file to establish default
+  debugging characteristics, like so:
 
 
 
@@ -278,40 +278,26 @@
 
 
   Starting with version 7.0, GDB includes support for writing
-  pretty-printers in Python.  Pretty printers for STL classes are
-  distributed with GCC from version 4.5.0.  The most recent version of
-  these printers are always found in libstdc++ svn repository.
-  To enable these printers, check-out the latest printers to a local
-  directory:
+  pretty-printers in Python.  Pretty printers for containers and other
+  classes are distributed with GCC from version 4.5.0 and should be installed
+  alongside the libstdc++ shared library files and found automatically by
+  GDB.
 
 
-
-  svn co svn://gcc.gnu.org/svn/gcc/trunk/libstdc++-v3/python
-
-
 
-  Next, add the following section to your ~/.gdbinit  The path must
-  match the location where the Python module above was checked-out.
-  So if checked out to: /home/maude/gdb_printers/, the path would be as
-  written in the example below.
+  Depending where libstdc++ is installed, GDB might refuse to auto-load
+  the python printers and print a warning instead.
+  If this happens the python printers can be enabled by following the
+  instructions GDB gives for setting your auto-load safe-path
+  in your .gdbinit configuration file.
 
 
-
-  python
-  import sys
-  sys.path.insert(0, '/home/maude/gdb_printers/python')
-  from libstdcxx.v6.printers import register_libstdcxx_printers
-  register_libstdcxx_printers (None)
-  end
-
-
 
-  The path should be the only element that needs to be adjusted in the
-  example.  Once loaded, STL classes that the printers support
+  Once loaded, standard library classes that the printers support
   should print in a more human-readable format.  To print the classes
-  in the old style, use the /r (raw) switch in the print command
-  (i.e., print /r foo).  This will print the classes as if the Python
-  pretty-printers were not loaded.
+  in the old style, use the /r (raw) switch in the
+  print command (i.e., print /r foo).  This will
+  print the classes as if the Python pretty-printers were not loaded.
 
 
 
@@ -332,8 +318,7 @@
 
   The verbose
   termination handler gives information about uncaught
-  exceptions which are killing the program.  It is described in the
-  linked-to page.
+  exceptions which kill the program.
 
 
 
@@ -347,14 +332,14 @@
 Compile Time 
Checking
 
The Compile-Time
-  Checks Extension has compile-time checks for many algorithms.
+  Checks extension has compile-time checks for many algorithms.
   
 
 
 Profile-based Performance 
Analysis
 
The Profile-based
-  Performance Analysis Extension has performance checks for many
+  Performance Analysis extension has performance checks for many
   algorithms.
   
 
diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2011.xml 
b/libstdc++-v3/doc/xml/manual/status_cxx2011.xml
index bda8a79..b3c24d8 100644
--- a/libstdc++-v3/doc/xml/manual/status_cxx2011.xml
+++ b/libstdc++-v3/doc/xml/manual/status_cxx2011.xml
@@ -79,7 +79,7 @@ particular release.
   18.2
   Types
   Partial
-  Missing offsetof, max_align_t
+  Missing offsetof
 
 
   18.3
@@ -999,10 +999,9 @@ particular release.
   
 
 
-  
   20.12
   Scoped allocator adaptor
-  Partial
+  Y
   
 
 
@@ -1113,10 +1112,11 @@ particular release.
   
 
 
+  
   21.4
   Class template basic_string
-  Y
-  
+  Partial
+  Non-conforming Copy-On-Write implementation
 
 
   21.5
@@ -2133,6 +2133,7 @@ particular release.
 Missing move and swap operations on basic_ios.
 Missing io_errc and iostream_category.
 ios_base::failure is not derived from 
system_error.
+   Missing ios_base::hexfloat.
   
 
 


[google gcc-4_8] gcov-tool: some new LIPO supports.

2014-01-29 Thread Rong Xu
Hi,

The attached patch adds some new features to gcov-tool. It aims to
rewrite LIPO profile for reuse, debug or performance tuning purpose.

-l, --modu_list   Only use the modules in this file
-r, --string Replace string in path
-u, --use_imports_file Use the grouping in import files.

-l uses only the modules in specified file to compute module grouping
(and subsequent dumping).
-r replaces the pattern specified in the argument. The format is:
old_str1:new_str1[,old_str2:new_str2]*, only the first occurrence is
replaced.
-u skips the run-time module grouping computation and reuses the one
comes with the profiles (which is user editable).

Tested with profiles from google internal benchmarks.

-Rong
2014-01-29  Rong Xu  

* gcc/gcov-tool.c (mod_name_id): New type of the hashtable entry.
(mod_name_id_htab_hash): Hash function for module-name and module-id
hashtab.
(mod_name_id_hash_eq): Comparison function for the hashtab.
(module_name_hash_lookup): Lookup function of the hashtab.
(is_lipo_source_type): Find if a file is of LIPO target source.
(lipo_process_name_string): Support of -l.
(lipo_process_modu_list): Ditto.
(is_module_available): Support of -u.
(get_module_id_from_name): Ditto.
(print_rewrite_usage_message): Add -u -l and -r support.
(do_rewrite): Ditto.
(print_version): Ditto.
(process_args): Ditto.
* libgcc/dyn-ipa.c (flag_use_existing_grouping): New flag for -u.
(init_dyn_call_graph): Support of -l.
(__gcov_finalize_dyn_callgraph): Ditto.
(gcov_build_callgraph): Ditto.
(gcov_compute_cutoff_count): Ditto.
(gcov_process_cgraph_node): Ditto.
(build_modu_graph): Ditto.
(gcov_compute_module_groups_eager_propagation): Ditto.
(gcov_compute_random_module_groups): Ditto.
(gcov_write_module_infos): Ditto.
(gcov_dump_callgraph): Ditto.
(set_use_existing_grouping): Support of -u.
(open_imports_file): Ditto.
(read_modu_groups_from_imports_files): Ditto.
(__gcov_compute_module_groups): Ditto.
* libgcc/libgcov-util.c (substitute_string): Support -r.
(lipo_set_substitute_string): Ditto.
(lipo_process_substitute_string_1): Ditto.
(lipo_process_substitute_string): Ditto.
(read_gcda_file): Ditto.
(flag_use_modu_list): Support of -l
(set_use_modu_list): Ditto.
(ftw_read_file): Ditto.
(source_profile_dir): Support of -u.
(get_source_profile_dir): Ditto.
(gcov_read_profile_dir): Ditto.

Index: gcc/gcov-tool.c
===
--- gcc/gcov-tool.c (revision 207055)
+++ gcc/gcov-tool.c (working copy)
@@ -29,6 +29,7 @@ see the files COPYING3 and COPYING.RUNTIME respect
 #include "coretypes.h"
 #include "tm.h"
 #include "intl.h"
+#include "hashtab.h"
 #include "diagnostic.h"
 #include "version.h"
 #include "gcov-io.h"
@@ -38,6 +39,7 @@ see the files COPYING3 and COPYING.RUNTIME respect
 #include 
 #include 
 #include "params.h"
+#include 
 
 extern int gcov_profile_merge (struct gcov_info*, struct gcov_info*, int, int);
 extern int gcov_profile_normalize (struct gcov_info*, gcov_type);
@@ -47,9 +49,11 @@ extern struct gcov_info* gcov_read_profile_dir (co
 extern void gcov_exit (void);
 extern void set_gcov_list (struct gcov_info *);
 extern void gcov_set_verbose (void);
+extern void set_use_existing_grouping (void);
+extern void set_use_modu_list (void);
+extern void lipo_set_substitute_string (const char *);
 
-static int verbose;
-
+/* The following defines are needed by dyn-ipa.c.  */
 gcov_unsigned_t __gcov_lipo_grouping_algorithm;
 gcov_unsigned_t __gcov_lipo_merge_modu_edges;
 gcov_unsigned_t __gcov_lipo_weak_inclusion;
@@ -60,6 +64,8 @@ gcov_unsigned_t __gcov_lipo_random_seed;
 gcov_unsigned_t __gcov_lipo_dump_cgraph;
 gcov_unsigned_t __gcov_lipo_propagate_scale;
 
+static int verbose;
+
 /* Remove file NAME if it has a gcda suffix. */
 
 static int
@@ -285,6 +291,189 @@ profile_rewrite (const char *d1, const char *out,
   return 0;
 }
 
+/* This is the hashtab entry to store a name and mod_id pair. */
+typedef struct {
+  const char *name;
+  unsigned id;
+} mod_name_id;
+
+/* Hash and comparison functions for strings.  */
+
+static unsigned
+mod_name_id_htab_hash (const void *s_p)
+{
+  const char *s = ((const mod_name_id *) s_p)->name;
+  return (*htab_hash_string) (s);
+}
+
+static int
+mod_name_id_hash_eq (const void *s1_p, const void *s2_p)
+{
+  return strcmp (((const mod_name_id *) s1_p)->name,
+ ((const mod_name_id *) s2_p)->name) == 0;
+}
+
+static htab_t mod_name_id_hash_table;
+
+/* Look up an entry in the hash table. STRING is the module name.
+   CREATE controls to insert to htab or not.
+   If (*ID_P != 0), we write (*ID_P) to htab.
+   If (*ID_P == 0), we wr

Re: [C++,doc] vector conditional expression

2014-01-29 Thread Gerald Pfeifer
On Sat, 25 Jan 2014, Marc Glisse wrote:
> Good luck, catching up always seems to take forever...

Thanks!

And thanks for your explanations.  With those, I am fine.  (Might it make 
sense to add some of the background you shared to the documentation to
describe the limitations?  "No" or "Yes, but I don't have the time now"
both are valid answers and should not block you applying your patch.)

Gerald


[msp430] add -minrt

2014-01-29 Thread DJ Delorie

Minor change to support some new functionality in newlib.  Committed.

* config/msp430/msp430.opt (-minrt): New.
* config/msp430/msp430.h (STARTFILE_SPEC): Link alternate runtime
if -minrt given.
(ENDFILE_SPEC): Likewise.

Index: gcc/config/msp430/msp430.opt
===
--- gcc/config/msp430/msp430.opt(revision 207293)
+++ gcc/config/msp430/msp430.opt(working copy)
@@ -25,6 +25,10 @@ Select small model - 16-bit addresses/po
 mrelax
 Target Report
 Optimize opcode sizes at link time
 
 mOs
 Target Undocumented Mask(OPT_SPACE)
+
+minrt
+Target Report Mask(MINRT) RejectNegative
+Use a minimum runtime (no static initializers or ctors) for memory-constrained 
devices.
Index: gcc/config/msp430/msp430.h
===
--- gcc/config/msp430/msp430.h  (revision 207293)
+++ gcc/config/msp430/msp430.h  (working copy)
@@ -42,17 +42,17 @@ extern bool msp430x;
   else \
builtin_assert ("cpu=MSP430");  \
 }   \
   while (0)
 
 #undef  STARTFILE_SPEC
-#define STARTFILE_SPEC "%{pg:gcrt0.o%s}%{!pg:crt0.o%s} crtbegin.o%s"
+#define STARTFILE_SPEC 
"%{pg:gcrt0.o%s}%{!pg:%{minrt:crt0-minrt.o%s}%{!minrt:crt0.o%s}} 
%{!minrt:crtbegin.o%s}"
 
 /* -lgcc is included because crtend.o needs __mspabi_func_epilog_1.  */
 #undef  ENDFILE_SPEC
-#define ENDFILE_SPEC "crtend.o%s crtn.o%s -lgcc"
+#define ENDFILE_SPEC "%{!minrt:crtend.o%s} 
%{minrt:crtn-minrt.o%s}%{!minrt:crtn.o%s} -lgcc"
 
 #define ASM_SPEC "-mP " /* Enable polymorphic instructions.  */ \
   "%{mcpu=*:-mcpu=%*}%{!mcpu=*:%{mmcu=*:-mmcu=%*}} " /* Pass the CPU type on 
to the assembler.  */ \
   "%{mrelax=-mQ} " /* Pass the relax option on to the assembler.  */ \
   "%{mlarge:-ml} " /* Tell the assembler if we are building for the LARGE 
pointer model.  */ \
   "%{!msim:-md} %{msim:%{mlarge:-md}}" /* Copy data from ROM to RAM if 
necessary.  */ \


RFA: cgraph PATCH for c++/59645 (ICE with covariant virtual function with volatile parameter)

2014-01-29 Thread Jason Merrill
If a parameter of a covariant virtual function is volatile, we can't 
just use the parameter directly in the call we build for the thunk, or 
the gimple verifier will complain.  We need to copy it into a temporary 
first.


Tested x86_64-pc-linux-gnu.  OK for trunk?
commit 0cbf28df997d109615545f113b01ac233d64879f
Author: Jason Merrill 
Date:   Wed Jan 29 20:47:54 2014 -0500

	PR c++/59645
	* cgraphunit.c (expand_thunk): Copy volatile arg to a temporary.

diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index d22265a..38c91df 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1592,7 +1592,18 @@ expand_thunk (struct cgraph_node *node, bool output_asm_thunks)
 
   if (nargs)
 for (i = 1, arg = DECL_CHAIN (a); i < nargs; i++, arg = DECL_CHAIN (arg))
-	  vargs.quick_push (arg);
+	  {
+	tree tmp = arg;
+	if (TREE_THIS_VOLATILE (TREE_TYPE (arg)))
+	  {
+		gcc_assert (is_gimple_reg_type (TREE_TYPE (arg)));
+		tmp = create_tmp_reg (TYPE_MAIN_VARIANT
+  (TREE_TYPE (arg)), "arg");
+		gimple stmt = gimple_build_assign (tmp, arg);
+		gsi_insert_after (&bsi, stmt, GSI_NEW_STMT);
+	  }
+	vargs.quick_push (tmp);
+	  }
   call = gimple_build_call_vec (build_fold_addr_expr_loc (0, alias), vargs);
   node->callees->call_stmt = call;
   gimple_call_set_from_thunk (call, true);
diff --git a/gcc/testsuite/g++.dg/inherit/covariant21.C b/gcc/testsuite/g++.dg/inherit/covariant21.C
new file mode 100644
index 000..42cdf87
--- /dev/null
+++ b/gcc/testsuite/g++.dg/inherit/covariant21.C
@@ -0,0 +1,17 @@
+// PR c++/59645
+
+struct A { virtual ~A(); };
+struct B { virtual ~B(); };
+struct C : A, B {};
+
+struct X
+{
+  virtual B* foo(volatile int);
+};
+
+struct Y : X
+{
+  virtual C* foo(volatile int);
+};
+
+C* Y::foo(volatile int) { return 0; }


[PATCH, rs6000] Implement -maltivec=be for vec_splat builtins

2014-01-29 Thread Bill Schmidt
Hi,

This continues the series of -maltivec=be patches, this one handling
vec_splat.  Since vec_splat is no longer treated as a true intrinsic,
its default behavior for little endian is changed to use right-to-left
element indexing for selecting the element to splat.  With -maltivec=be
for little endian, this reverts to left-to-right element indexing.

The main changes are in altivec.md, and are quite similar to what was
done for vector merge high/low.  Each of the vector splat builtins is
split into a define_expand and an "_internal" define_insn.  The expand
uses the natural element order for the target, unless we have
-maltivec=be for an LE target, in which case the order is reversed.  The
_internal insn modifies the element number on the hardware instruction
for LE to account for the instruction's big-endian bias.

For those of the vector splat instructions that are generated
internally, rather than through a builtin, a "_direct" insn is supplied
that generates precisely the instruction requested.

vsx.md contains the same changes for V4SI and V4SF patterns when VSX
instructions are enabled.  We don't need a separate define_expand for
this one because the define_expand for altivec_vspltw is used to
generate the pattern that is recognized by vsx_xxspltw_.  Either
vsx_xxspltw_ or *altivec_vspltw_internal handles the pattern,
depending on whether or not VSX instructions are enabled.

Most of the changes in rs6000.c are to use the new _direct forms.  There
is one other change to rs6000_expand_vector_init, where the modification
of the selector field for a generated splat pattern is removed.  That is
properly handled instead by the code in altivec.md and vsx.md.

As usual, there are four new test cases to cover the various vector
types for VMX and VSX.  Two existing test cases require adjustment
because of the change in the default semantics of vec_splat for little
endian.

Bootstrapped and tested on powerpc64{,le}-unknown-linux-gnu with no
regressions.  Ok for trunk?

Thanks,
Bill


gcc:

2014-01-29  Bill Schmidt  

* gcc/config/rs6000/rs6000.c (rs6000_expand_vector_init): Use
gen_vsx_xxspltw_v4sf_direct instead of gen_vsx_xxspltw_v4sf;
remove element index adjustment for endian (now handled in vsx.md
and altivec.md).
(altivec_expand_vec_perm_const): Use
gen_altivec_vsplt[bhw]_direct instead of gen_altivec_vsplt[bhw].
* gcc/config/rs6000/vsx.md (UNSPEC_VSX_XXSPLTW): New unspec.
(vsx_xxspltw_): Adjust element index for little endian.
* gcc/config/rs6000/altivec.md (altivec_vspltb): Divide into a
define_expand and a new define_insn *altivec_vspltb_internal;
adjust for -maltivec=be on a little endian target.
(altivec_vspltb_direct): New.
(altivec_vsplth): Divide into a define_expand and a new
define_insn *altivec_vsplth_internal; adjust for -maltivec=be on a
little endian target.
(altivec_vsplth_direct): New.
(altivec_vspltw): Divide into a define_expand and a new
define_insn *altivec_vspltw_internal; adjust for -maltivec=be on a
little endian target.
(altivec_vspltw_direct): New.
(altivec_vspltsf): Divide into a define_expand and a new
define_insn *altivec_vspltsf_internal; adjust for -maltivec=be on
a little endian target.

gcc/testsuite:

2014-01-29  Bill Schmidt  

* gcc.dg/vmx/splat.c: New.
* gcc.dg/vmx/splat-vsx.c: New.
* gcc.dg/vmx/splat-be-order.c: New.
* gcc.dg/vmx/splat-vsx-be-order.c: New.
* gcc.dg/vmx/eg-5.c: Remove special casing for little endian.
* gcc.dg/vmx/sn7153.c: Add special casing for little endian.


Index: gcc/testsuite/gcc.dg/vmx/splat.c
===
--- gcc/testsuite/gcc.dg/vmx/splat.c(revision 0)
+++ gcc/testsuite/gcc.dg/vmx/splat.c(revision 0)
@@ -0,0 +1,47 @@
+#include "harness.h"
+
+static void test()
+{
+  /* Input vectors.  */
+  vector unsigned char vuc = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
+  vector signed char vsc = {-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7};
+  vector unsigned short vus = {0,1,2,3,4,5,6,7};
+  vector signed short vss = {-4,-3,-2,-1,0,1,2,3};
+  vector unsigned int vui = {0,1,2,3};
+  vector signed int vsi = {-2,-1,0,1};
+  vector float vf = {-2.0,-1.0,0.0,1.0};
+
+  /* Result vectors.  */
+  vector unsigned char vucr;
+  vector signed char vscr;
+  vector unsigned short vusr;
+  vector signed short vssr;
+  vector unsigned int vuir;
+  vector signed int vsir;
+  vector float vfr;
+
+  /* Expected result vectors.  */
+  vector unsigned char vucer = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
+  vector signed char vscer = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+  vector unsigned short vuser = {7,7,7,7,7,7,7,7};
+  vector signed short vsser = {-4,-4,-4,-4,-4,-4,-4,-4};
+  vector unsigned int vuier = {2,2,2,2};
+  vector signed int vsier = {1,1,1,1};
+  vector float vfer = {-1.0,-1

C++ PATCH for c++/59707 (ICE with binary operation and template conversion)

2014-01-29 Thread Jason Merrill
We've previously tweaked a few rules to avoid creating builtin 
candidates with dependent types, but things keep slipping through the 
cracks.  This should be a more complete solution.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit aca790abae74da31099bcfb3ceb1459b6c2b6f05
Author: Jason Merrill 
Date:   Wed Jan 29 17:09:04 2014 -0500

	PR c++/59707
	* call.c (add_builtin_candidate): Catch dependent types.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index f6566cf..f572bc1 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -2329,7 +2329,6 @@ add_builtin_candidate (struct z_candidate **candidates, enum tree_code code,
 
 case INDIRECT_REF:
   if (TYPE_PTR_P (type1)
-	  && !uses_template_parms (TREE_TYPE (type1))
 	  && (TYPE_PTROB_P (type1)
 	  || TREE_CODE (TREE_TYPE (type1)) == FUNCTION_TYPE))
 	break;
@@ -2467,15 +2466,13 @@ add_builtin_candidate (struct z_candidate **candidates, enum tree_code code,
 	  && TREE_CODE (type2) == ENUMERAL_TYPE)
 	break;
   if (TYPE_PTR_P (type1) 
-	  && null_ptr_cst_p (args[1])
-	  && !uses_template_parms (type1))
+	  && null_ptr_cst_p (args[1]))
 	{
 	  type2 = type1;
 	  break;
 	}
   if (null_ptr_cst_p (args[0]) 
-	  && TYPE_PTR_P (type2)
-	  && !uses_template_parms (type2))
+	  && TYPE_PTR_P (type2))
 	{
 	  type1 = type2;
 	  break;
@@ -2642,6 +2639,28 @@ add_builtin_candidate (struct z_candidate **candidates, enum tree_code code,
   gcc_unreachable ();
 }
 
+  /* Make sure we don't create builtin candidates with dependent types.  */
+  bool u1 = uses_template_parms (type1);
+  bool u2 = type2 ? uses_template_parms (type2) : false;
+  if (u1 || u2)
+{
+  /* Try to recover if one of the types is non-dependent.  But if
+	 there's only one type, there's nothing we can do.  */
+  if (!type2)
+	return;
+  /* And we lose if both are dependent.  */
+  if (u1 && u2)
+	return;
+  /* Or if they have different forms.  */
+  if (TREE_CODE (type1) != TREE_CODE (type2))
+	return;
+
+  if (u1 && !u2)
+	type1 = type2;
+  else if (u2 && !u1)
+	type2 = type1;
+}
+
   /* If we're dealing with two pointer types or two enumeral types,
  we need candidates for both of them.  */
   if (type2 && !same_type_p (type1, type2)
diff --git a/gcc/testsuite/g++.dg/template/operator12.C b/gcc/testsuite/g++.dg/template/operator12.C
new file mode 100644
index 000..bc8e91d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/operator12.C
@@ -0,0 +1,9 @@
+// PR c++/59707
+
+struct T {
+template operator D*() const;
+};
+
+void f(T x) {
+x < x;			// { dg-error "no match" }
+}


[PATCH] Fix PR 58960

2014-01-29 Thread Andrey Belevantsev

Hello,

As detailed in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58960#c6, we 
fail to use the DF liveness info in the register pressure sensitive 
scheduling for the new blocks as we do not properly compute it in this 
case.  The patch fixes this by avoiding to use the sched-pressure for the 
new regions, as currently these are only ia64 recovery blocks and supposed 
to be cold.  In the case we'd get other cases of the new blocks, this may 
be reconsidered.  The other options of computing the DF info sketched at 
the above link do not seem plausible for this stage.


Bootstrapped and tested on ia64, also tested by Andreas Schwab on ia64 (see 
PR log).  OK for trunk?


Andrey

2013-01-30  Andrey Belevantsev  

PR rtl-optimization/58960

* haifa-sched.c (alloc_global_sched_pressure_data): New, factored out 
from ...
(sched_init) ... here.
(free_global_sched_pressure_data): New, factored out from ...
(sched_finish): ... here.
* sched-int.h (free_global_sched_pressure_data): Declare.
* sched-rgn.c (nr_regions_initial): New static global.
(haifa_find_rgns): Initialize it.
(schedule_region): Disable sched-pressure for the newly generated 
regions.
diff --git a/gcc/haifa-sched.c b/gcc/haifa-sched.c
index 4d51984..45398bf 100644
--- a/gcc/haifa-sched.c
+++ b/gcc/haifa-sched.c
@@ -6553,6 +6553,53 @@ setup_sched_dump (void)
 		? stderr : dump_file);
 }
 
+/* Allocate data for register pressure sensitive scheduling.  */
+static void
+alloc_global_sched_pressure_data (void)
+{
+  if (sched_pressure != SCHED_PRESSURE_NONE)
+{
+  int i, max_regno = max_reg_num ();
+
+  if (sched_dump != NULL)
+	/* We need info about pseudos for rtl dumps about pseudo
+	   classes and costs.  */
+	regstat_init_n_sets_and_refs ();
+  ira_set_pseudo_classes (true, sched_verbose ? sched_dump : NULL);
+  sched_regno_pressure_class
+	= (enum reg_class *) xmalloc (max_regno * sizeof (enum reg_class));
+  for (i = 0; i < max_regno; i++)
+	sched_regno_pressure_class[i]
+	  = (i < FIRST_PSEUDO_REGISTER
+	 ? ira_pressure_class_translate[REGNO_REG_CLASS (i)]
+	 : ira_pressure_class_translate[reg_allocno_class (i)]);
+  curr_reg_live = BITMAP_ALLOC (NULL);
+  if (sched_pressure == SCHED_PRESSURE_WEIGHTED)
+	{
+	  saved_reg_live = BITMAP_ALLOC (NULL);
+	  region_ref_regs = BITMAP_ALLOC (NULL);
+	}
+}
+}
+
+/*  Free data for register pressure sensitive scheduling.  */
+void
+free_global_sched_pressure_data (void)
+{
+  if (sched_pressure != SCHED_PRESSURE_NONE)
+{
+  if (regstat_n_sets_and_refs != NULL)
+	regstat_free_n_sets_and_refs ();
+  if (sched_pressure == SCHED_PRESSURE_WEIGHTED)
+	{
+	  BITMAP_FREE (region_ref_regs);
+	  BITMAP_FREE (saved_reg_live);
+	}
+  BITMAP_FREE (curr_reg_live);
+  free (sched_regno_pressure_class);
+}
+}
+
 /* Initialize some global state for the scheduler.  This function works
with the common data shared between all the schedulers.  It is called
from the scheduler specific initialization routine.  */
@@ -6656,29 +6703,7 @@ sched_init (void)
   if (targetm.sched.init_global)
 targetm.sched.init_global (sched_dump, sched_verbose, get_max_uid () + 1);
 
-  if (sched_pressure != SCHED_PRESSURE_NONE)
-{
-  int i, max_regno = max_reg_num ();
-
-  if (sched_dump != NULL)
-	/* We need info about pseudos for rtl dumps about pseudo
-	   classes and costs.  */
-	regstat_init_n_sets_and_refs ();
-  ira_set_pseudo_classes (true, sched_verbose ? sched_dump : NULL);
-  sched_regno_pressure_class
-	= (enum reg_class *) xmalloc (max_regno * sizeof (enum reg_class));
-  for (i = 0; i < max_regno; i++)
-	sched_regno_pressure_class[i]
-	  = (i < FIRST_PSEUDO_REGISTER
-	 ? ira_pressure_class_translate[REGNO_REG_CLASS (i)]
-	 : ira_pressure_class_translate[reg_allocno_class (i)]);
-  curr_reg_live = BITMAP_ALLOC (NULL);
-  if (sched_pressure == SCHED_PRESSURE_WEIGHTED)
-	{
-	  saved_reg_live = BITMAP_ALLOC (NULL);
-	  region_ref_regs = BITMAP_ALLOC (NULL);
-	}
-}
+  alloc_global_sched_pressure_data ();
 
   curr_state = xmalloc (dfa_state_size);
 }
@@ -6777,18 +6802,7 @@ void
 sched_finish (void)
 {
   haifa_finish_h_i_d ();
-  if (sched_pressure != SCHED_PRESSURE_NONE)
-{
-  if (regstat_n_sets_and_refs != NULL)
-	regstat_free_n_sets_and_refs ();
-  if (sched_pressure == SCHED_PRESSURE_WEIGHTED)
-	{
-	  BITMAP_FREE (region_ref_regs);
-	  BITMAP_FREE (saved_reg_live);
-	}
-  BITMAP_FREE (curr_reg_live);
-  free (sched_regno_pressure_class);
-}
+  free_global_sched_pressure_data ();
   free (curr_state);
 
   if (targetm.sched.finish_global)
diff --git a/gcc/sched-int.h b/gcc/sched-int.h
index 3b1106f..b5481b9 100644
--- a/gcc/sched-int.h
+++ b/gcc/sched-int.h
@@ -1337,6 +1337,7 @@ extern void debug_ds (ds_t);
 extern void initialize_live_range_shrinkage (void);
 extern void finish_live_range_shrinkage (void);
 extern voi

  1   2   >