Re: [Ada] Out parameters of a null-excluding access type in entries.

2014-07-30 Thread Duncan Sands

Hi Arnaud,

On 29/07/14 16:02, Arnaud Charlet wrote:

If a procedure or entry has an formal out-parameter of a null-excluding access
type, there is no check applied to the actual before the call. This patch
removes a spurious access check on such parameters on entry calls.

Compiling and executing p.adb must yield;

 Procedure version did not raise exception
 Entry version did not raise exception

---
with Ada.Text_IO; use Ada.Text_IO;
procedure P is
type Integer_Access is access all Integer;

An_Integer : aliased Integer;

procedure Procedure_Version (A : out not null Integer_Access) is
begin
   A := An_Integer'Access;
end Procedure_Version;

protected Object is
   entry Entry_Version (A : out not null Integer_Access);
end Object;

protected body Object is
   entry Entry_Version (A : out not null Integer_Access) when True is
  Junk : integer := 0;


this variable "Junk" seems useless.


   begin
  A := An_Integer'Access;
   end Entry_Version;
end Object;

A : Integer_Access;
begin
A := null;
Procedure_Version (A);
Put_Line ("Procedure version did not raise exception");

A := null;
Object.Entry_Version (A);
Put_Line ("Entry version did not raise exception");
end;


Ciao, Duncan.



Re: [Patch, avr] Add device name to cpp_builtins

2014-07-30 Thread Senthil Kumar Selvaraj
On Mon, Jul 28, 2014 at 08:09:28PM +0200, Georg-Johann Lay wrote:
> Senthil Kumar Selvaraj schrieb:
> >The below patch adds a new preprocessor define for the device name
> >(__AVR_DEVICE_NAME__) that was passed to the compiler.
> >
> >While the device name macro (say __AVR_ATmega128__) can be used to check
> >for a specific device, there is no way right now for code to get the
> >device name it is being compiled against (without checking
> >for every possible device).
> 
> Shouldn't this also be added to the documentation?
> There's a section "AVR Built-in Macros" in the manual.

Thanks for reminding me, Johann. Here's the patch - if ok, could someone
commit please?

Regards
Senthil

2014-07-30  Senthil Kumar Selvaraj  

* doc/invoke.texi (AVR Options): Add documentation about 
__AVR_DEVICE_NAME__ built-in macro.

diff --git gcc/doc/invoke.texi gcc/doc/invoke.texi
index 7cebb9e..e201496 100644
--- gcc/doc/invoke.texi
+++ gcc/doc/invoke.texi
@@ -13114,6 +13114,14 @@ the device name as from the AVR user manual. The 
difference between
 If @var{device} is not a device but only a core architecture like
 @code{avr51}, this macro will not be defined.
 
+@item   __AVR_DEVICE_NAME__
+Setting @code{-mmcu=@var{device}} defines this built-in macro to
+the device's name. For example, with @code{-mmcu=atmega8} the macro
+will be defined to @code{atmega8}.
+
+If @var{device} is not a device but only a core architecture like
+@code{avr51}, this macro will not be defined.
+
 @item __AVR_XMEGA__
 The device / architecture belongs to the XMEGA family of devices.
 



Re: [PATCH] PR61868

2014-07-30 Thread Richard Biener
On Tue, Jul 29, 2014 at 3:01 PM, Bingfeng Mei  wrote:
> Hi,
> Please find the patches for pr61868. The problem is that even with 
> -frandom-seed gcc always uses 0 instead of specified number/string for places 
> such as lto section names. init_random_seed is never called with 
> -frandom-seed. Bootstrapped and tested on x86-64. OK for trunk?

Hmm, but -frandom-seed= is honored by opts.c calling set_random_seed?

Andi, wasn't this used to support partial linking of LTO objects?  Thus,
this shortcut was on purpose?  Otherwise passing -frandom-seed to
LTO would break that?

Bingfeng, did you test if LTO bootstrap still works after this patch?

Thanks,
Richard.

> Thanks,
> Bingfeng Mei
>
>
> ===
> --- ChangeLog   (revision 213152)
> +++ ChangeLog   (working copy)
> @@ -1,3 +1,9 @@
> +2014-07-29  Bingfeng Mei 
> +
> +   PR lto/61868
> +   * toplev.c (init_random_seed): Generate random seed when
> +   flag_random_seed is specified.
> +
>  2014-07-28  Jan Hubicka  
>
> * cgraph.c (cgraph_node::create_indirect_edge): Copy speculative data.
> Index: toplev.c
> ===
> --- toplev.c(revision 213152)
> +++ toplev.c(working copy)
> @@ -301,7 +301,7 @@ init_random_seed (void)
>  HOST_WIDE_INT
>  get_random_seed (bool noinit)
>  {
> -  if (!flag_random_seed && !noinit)
> +  if (!noinit)
>  init_random_seed ();
>return random_seed;
>  }
> Index: testsuite/ChangeLog
> ===
> --- testsuite/ChangeLog (revision 213152)
> +++ testsuite/ChangeLog (working copy)
> @@ -1,3 +1,8 @@
> +2014-07-29  Bingfeng Mei  
> +
> +   PR lto/61868
> +   * gcc.dg/pr61868.c: New test.
> +
>  2014-07-28  Richard Biener  
>
> PR rtl-optimization/61801
> Index: testsuite/gcc.dg/pr61868.c
> ===
> --- testsuite/gcc.dg/pr61868.c  (revision 0)
> +++ testsuite/gcc.dg/pr61868.c  (revision 0)
> @@ -0,0 +1,9 @@
> +/* { dg-do compile } */
> +/* { dg-options "-flto -frandom-seed=0x12345" }  */
> +extern int foo (int);
> +int main ()
> +{
> +  foo (100);
> +  return 0;
> +}
> +/* { dg-final { scan-assembler "\.gnu\.lto.*.12345" } } */
>


Re: [GSoC][match-and-simplify] include is-a.h

2014-07-30 Thread Richard Biener
On Tue, Jul 29, 2014 at 4:10 PM, Prathamesh Kulkarni
 wrote:
> On Mon, Jul 28, 2014 at 7:30 PM, David Malcolm  wrote:
>> On Mon, 2014-07-28 at 02:35 +0530, Prathamesh Kulkarni wrote:
>>> -  if (o->type == operand::OP_CAPTURE)
>>> +  if (is_a (o))
>>>  {
>>> -  capture *c = static_cast (o);
>>> -  fprintf (f, "@%s", (static_cast (o))->where);
>>> +  capture *c = as_a (o);
>>
>> FWIW, if you're doing an is_a followed by a new declaration with an
>> as_a, that can be done in one line with is-a.h as:
>>
>>  if (capture *c = dyn_cast  (o))
>>
>>
>>
> Thanks, fixed in this patch.
>
> * genmatch.c (print_operand): Adjust to use dyn_cast.

Committed.

Richard.

> Regards,
> Prathamesh


Re: [PATCH] LTO streamer reorg - try to reduce WPA memory use

2014-07-30 Thread Jan Hubicka
> > Updated patch passing LTO bootstrap (one warning fix) and
> > with a memory leak fixed.
> 
> Testing with Firefox is impossible at the moment because of PR61885.
> One thing I've noticed (before the ICE) is that virtual memory usage is
> very high:
> 
> AddressKbytes  RSSDirty  Mode  Mapping
> 004016344 90840  r-x-- lto1
> 013f6000   36   36   28  rw--- lto1
> 013ff000 1072  276  276  rw---   [ anon ]
> 034aa000 10154940  1540384  1540384  rw---   [ anon ]
> 2acf04af2000  136  1360  r-x-- ld-2.19.90.so
> 2acf04b14000   88   88   88  rw---   [ anon ]
> ...
>   ---  ---  --- 
> total kB 12022060  3388396  3377708

You should get into the memory peak caused by streaming before we get
to the ICE.  I am about to commit the second half of the ipa-devirt
speculation changes that fixes the ICE.

Honza
> 
> -- 
> Markus


Add debug output to speculative polymorphic contextes, testcase and fix an ICE

2014-07-30 Thread Jan Hubicka
Hi,
this patch adds testcase, renames nonconstruction_targets to the new meaning
and adds debug info.
I also noticed that hunk from possible_polymorphic_call_targets got lost from
previous patch, so I re-added it. It actually adds the logic using the 
speculation.
This should also fixes ICE seen during Firefox builds.

Honza

* g++.dg/ipa/devirt-34.C: New testcase.
* ipa-devirt.c (polymorphic_call_target_d): Rename 
nonconstruction_targets
to speculative_targets
(get_class_context): Fix handling of contextes without outer type;
avoid matching non-polymorphic types in LTO.
(possible_polymorphic_call_targets): Trun nonconstruction_targetsp
parameter to speculative_targetsp; handle speculation.
(dump_possible_polymorphic_call_targets): Update dumping.
Index: testsuite/g++.dg/ipa/devirt-34.C
===
--- testsuite/g++.dg/ipa/devirt-34.C(revision 0)
+++ testsuite/g++.dg/ipa/devirt-34.C(revision 0)
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-devirt"  } */
+struct A {virtual int t(){return 42;}};
+struct B:A {virtual int t(){return 1;}};
+int
+t(struct B *b)
+{
+  struct A *a=b;
+  a->t();
+}
+
+/* We should guess that the pointer of type B probably points to an instance
+   of B or its derivates and exclude A::t from list of likely targets.  */
+
+/* { dg-final { scan-ipa-dump "Targets that are not likely"  "devirt"  } } */
+/* { dg-final { scan-ipa-dump "1 speculatively devirtualized"  "devirt"  } } */
+/* { dg-final { cleanup-ipa-dump "devirt" } } */
Index: ipa-devirt.c
===
--- ipa-devirt.c(revision 213152)
+++ ipa-devirt.c(working copy)
@@ -1615,7 +1615,7 @@ struct polymorphic_call_target_d
   ipa_polymorphic_call_context context;
   odr_type type;
   vec  targets;
-  int nonconstruction_targets;
+  int speculative_targets;
   bool complete;
 };
 
@@ -1770,8 +1770,8 @@ get_class_context (ipa_polymorphic_call_
 
  if (!context->outer_type)
{
- context->outer_type = expected_type;
- context->offset = offset;
+ type = context->outer_type = expected_type;
+ context->offset = offset = 0;
}
   /* See if speculative type seem to be derrived from outer_type.
  Then speculation is valid only if it really is a derivate and derived 
types
@@ -1807,6 +1807,10 @@ get_class_context (ipa_polymorphic_call_
 
   /* On a match, just return what we found.  */
   if (TREE_CODE (type) == TREE_CODE (expected_type)
+ && (!in_lto_p
+ || (TREE_CODE (type) == RECORD_TYPE
+ && TYPE_BINFO (type)
+ && polymorphic_type_binfo_p (TYPE_BINFO (type
  && types_same_for_odr (type, expected_type))
{
  if (speculative)
@@ -2518,9 +2522,10 @@ devirt_variable_node_removal_hook (varpo
in the target cache.  If user needs to visit every target list
just once, it can memoize them.
 
-   NONCONSTRUCTION_TARGETS specify number of targets with asumption that
-   the type is not in the construction.  Those targets appear first in the
-   vector returned.
+   SPECULATION_TARGETS specify number of targets that are speculatively
+   likely.  These include targets specified by the speculative part
+   of polymoprhic call context and also exclude all targets for classes
+   in construction.
 
Returned vector is placed into cache.  It is NOT caller's responsibility
to free it.  The vector can be freed on cgraph_remove_node call if
@@ -2532,7 +2537,7 @@ possible_polymorphic_call_targets (tree
   ipa_polymorphic_call_context context,
   bool *completep,
   void **cache_token,
-  int *nonconstruction_targetsp)
+  int *speculative_targetsp)
 {
   static struct cgraph_node_hook_list *node_removal_hook_holder;
   pointer_set_t *inserted;
@@ -2557,8 +2562,8 @@ possible_polymorphic_call_targets (tree
*completep = false;
   if (cache_token)
*cache_token = NULL;
-  if (nonconstruction_targetsp)
-   *nonconstruction_targetsp = 0;
+  if (speculative_targetsp)
+   *speculative_targetsp = 0;
   return nodes;
 }
 
@@ -2569,8 +2574,8 @@ possible_polymorphic_call_targets (tree
*completep = true;
   if (cache_token)
*cache_token = NULL;
-  if (nonconstruction_targetsp)
-   *nonconstruction_targetsp = 0;
+  if (speculative_targetsp)
+   *speculative_targetsp = 0;
   return nodes;
 }
 
@@ -2581,15 +2586,15 @@ possible_polymorphic_call_targets (tree
  || TYPE_MAIN_VARIANT (context.outer_type) == context.outer_type);
 
   /* Lookup the outer class type we want to walk.  */
-  if (context.outer_type
+  if ((context.outer_type || context.speculative_outer_type)
  

Re: [GSoC] type of an isl_ast_expr_id

2014-07-30 Thread Roman Gareev
> Blindly converting type sizes is not a good idea and may be problematic when
> we switch to smaller types. As we can obviously only improve this when we
> have the appropriate support in isl, I think the attached patch is fine.
> However, please add a fixme that states that this should
> be looked at again at the moment when we get isl support to derive the
> optimal types.

I've attached a patch, which contains the fixme.

> Please have a look at the original bug report:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=35356
>
> The isl ast generator should produce something like:
>
>   for (i = 0; i < min (n, k); i++)
>  a[i] = i;
>   if (k >= 0 && k < n)
>  a[k] = 1;
>   for (i = max(k+1,0); i < n; i++)
>  a[i] = i;
>
> CLooG does not generate optimal code either, but the code generated by isl
> is a regression compared to CLooG.
>
> Can you generate an isl_codegen input for this test case and verify that the
> latest public version of isl does not generate this optimal code either. If
> it does not, please report this as an optimization bug to the isl mailing
> list.
>
> After you got feedback, I think it is OK to disable this test and to
> add a FIXME explaining why this test is disabled and if we can expect a fix
> in later versions of isl.

I've generated the code using the isl-0.13

if (n >= k + 1) {
  for (int c1 = 0; c1 < n; c1 += 1) {
if (c1 >= k + 1) {
  S_7(c1);
} else if (k >= c1 + 1) {
  S_7(c1);
} else
  S_6(k);
  }
} else
  for (int c1 = 0; c1 < n; c1 += 1)
S_7(c1);

If I'm not mistaken it's also a regression compared to ClooG and it's
better to report this to the isl mailing list.

> What is the problem with this last test case?

It is related to checking for the loop parallelism, which is not yet
implemented in the current version of graphite-isl-ast-to-gimple.c.

--
   Cheers, Roman Gareev.
2014-07-30  Roman Gareev  

[gcc/]

* graphite-isl-ast-to-gimple.c:
(gcc_expression_from_isl_ast_expr_id): Add calling of fold_convert.
(gcc_expression_from_isl_expression): Pass type to
gcc_expression_from_isl_ast_expr_id.
Index: gcc/graphite-isl-ast-to-gimple.c
===
--- gcc/graphite-isl-ast-to-gimple.c(revision 213109)
+++ gcc/graphite-isl-ast-to-gimple.c(working copy)
@@ -122,10 +122,14 @@
ivs_params &ip);
 
 /* Return the tree variable that corresponds to the given isl ast identifier
- expression (an isl_ast_expr of type isl_ast_expr_id).  */
+   expression (an isl_ast_expr of type isl_ast_expr_id).
 
+   FIXME: We should replace blind conversation of id's type with derivation
+   of the optimal type when we get the corresponding isl support.  */
+
 static tree
-gcc_expression_from_isl_ast_expr_id (__isl_keep isl_ast_expr *expr_id,
+gcc_expression_from_isl_ast_expr_id (tree type,
+__isl_keep isl_ast_expr *expr_id,
 ivs_params &ip)
 {
   gcc_assert (isl_ast_expr_get_type (expr_id) == isl_ast_expr_id);
@@ -136,7 +140,7 @@
   gcc_assert (res != ip.end () &&
   "Could not map isl_id to tree expression");
   isl_ast_expr_free (expr_id);
-  return res->second;
+  return fold_convert (type, res->second);
 }
 
 /* Converts an isl_ast_expr_int expression E to a GCC expression tree of
@@ -351,7 +355,7 @@
   switch (isl_ast_expr_get_type (expr))
 {
 case isl_ast_expr_id:
-  return gcc_expression_from_isl_ast_expr_id (expr, ip);
+  return gcc_expression_from_isl_ast_expr_id (type, expr, ip);
 
 case isl_ast_expr_int:
   return gcc_expression_from_isl_expr_int (type, expr);


Re: [PATCH] Further cleanup loop-distribution

2014-07-30 Thread Richard Biener
On Tue, Jul 29, 2014 at 9:46 PM, Mike Stump  wrote:
> On Sep 12, 2013, at 1:47 AM, Richard Biener  wrote:
>> ! #if 0
>> !   FILE *file = fopen ("/tmp/rdg.dot", "w");
>> !   gcc_assert (file != NULL);
>> !
>>dot_rdg_1 (file, rdg);
>> !   fclose (file);
>> !
>> !   system ("dotty /tmp/rdg.dot &");
>>  #else
>>dot_rdg_1 (stderr, rdg);
>>  #endif
>> --- 276,290 
>>  DEBUG_FUNCTION void
>>  dot_rdg (struct graph *rdg)
>>  {
>> !   /* When debugging, you may want to enable the following code.  */
>> ! #if 1
>> !   FILE *file = popen("dot -Tx11", "w");
>> !   if (!file)
>> ! return;
>>dot_rdg_1 (file, rdg);
>> !   fflush (file);
>> !   close (fileno (file));
>> !   pclose (file);
>>  #else
>>dot_rdg_1 (stderr, rdg);
>>  #endif
>
> So I do compiler testing on my toaster oven by doing native builds of gcc 
> running on a binutils simulator and it doesn’t have a working popen (it’s in 
> my newlib, but it wants vfork, which I don’t have).  I do have fork and 
> system however.  :-) Could we replace the if 1 with if HAVE_popen where that 
> is done by an autoconf link test?

Sure - patches welcome.  You could also use _POSIX_C_SOURCE >= 2
|| _XOPEN_SOURCE || _BSD_SOURCE || _SVID_SOURCE which I'm sure
your newlib provide anyway(?)

Richard.


Re: [PATCH] Making it easier to set breakpoints in gdb on pass->execute methods

2014-07-30 Thread Richard Biener
On Tue, Jul 29, 2014 at 10:44 PM, David Malcolm  wrote:
> A complaint I heard at Cauldron with the C++ification of GCC passes is
> that it's become much more difficult to set breakpoints on the execute
> hooks of a pass, now that the passes are classes within anonymous
> namespaces.
>
> When this was first done, the execute methods were trivial
> implementations that called into the existing named functions, which are
> still easy to put a breakpoint on by name (assuming you know the name of
> the function), but some of these have now been converted so that the
> "execute" method is the body of the pass.
>
> I did some experimentation, on this box with
> gdb-7.6.50.20130731-19.fc20.x86_64 and gcc trunk r212913 (the latter
> from a week ago).
>
> You *can* set a breakpoint by name on such an execute method, but it's
> tedious to type:
> (gdb) break '(anonymous namespace)::pass_expand::execute'
> Breakpoint 7 at 0x655220: file ../../src/gcc/cfgexpand.c, line
>
> ...since tab-completion doesn't work well:
>
> (gdb) break '(a
> does tab complete to:
> (gdb) break '(anonymous namespace)::
>
> but typing anything else then hitting tab returns back to:
> (gdb) break '(anonymous namespace)::
>
> Is anyone else seeing this?

Yes, I filed a gdb bug about this.

> I had a go at implementing a workaround, for the lack of tab completion
> (and the general verbosity) using gdbhooks.py.
>
> Attached is a patch to gdbhooks.py which adds a new command
> "break-on-pass" to gdb; in particular, it locates and parses passes.def,
> so that it can tab-complete on pass classnames:
>
> Example of use from the script: putting a breakpoint on "final", i.e.
> classname "pass_final":
>
>   (gdb) break-on-pass
> Press ; it autocompletes to "pass_":
>   (gdb) break-on-pass pass_
> Press :
>   Display all 219 possibilities? (y or n)
> Press "n"; then type "f":
>   (gdb) break-on-pass pass_f
> Press  to autocomplete to pass classnames beginning with "pass_f":
>   pass_fast_rtl_dce  pass_fold_builtins
>   pass_feedback_split_functions  pass_forwprop
>   pass_final pass_fre
>   pass_fixup_cfg pass_free_cfg
> Type "in" to complete to "pass_final":
>   (gdb) break-on-pass pass_final
> ...and hit :
>   Breakpoint 6 at 0x8396ba: file ../../src/gcc/final.c, line 4526.
> ...and we have a breakpoint set; continue execution:
>   (gdb) cont
>   Continuing.
>   Breakpoint 6, (anonymous namespace)::pass_final::execute (this=0x17fb990) 
> at ../../src/gcc/final.c:4526
>   4526virtual unsigned int execute (function *) { return 
> rest_of_handle_final (); }
>
> This assumes you've suitably enabled gdbhooks.py, as documented at the
> top of that file.
>
> Thoughts?

Works for me though I'm not able to review python ;)

Richard.

> Dave
>
> gcc/
> * gdbhooks.py (find_gcc_source_dir): New helper function.
> (class PassNames): New class, locating and parsing passes.def.
> (class BreakOnPass): New command "break-on-pass".
>


Re: [patch] update for test ftrapv-1.c

2014-07-30 Thread Richard Biener
On Wed, Jul 30, 2014 at 7:31 AM, Doug Gilmore  wrote:
> With r213117 we are seeing additional failures while testing a bare-iron 
> build:
>
> FAIL: gcc.dg/torture/ftrapv-1.c   -O0  (test for excess errors)
> ...
>
> This newly added test does a fork, though it has a guard
> to prevent testing targets that don't support fork, but the
> guard needs to be tweaked:
>
> diff --git a/gcc/testsuite/gcc.dg/torture/ftrapv-1.c 
> b/gcc/testsuite/gcc.dg/torture/ftrapv-1.c
> index 4fdccd8..4fee1e1 100644
> --- a/gcc/testsuite/gcc.dg/torture/ftrapv-1.c
> +++ b/gcc/testsuite/gcc.dg/torture/ftrapv-1.c
> @@ -1,7 +1,7 @@
>  /* { dg-do run } */
>  /* { dg-additional-options "-ftrapv" } */
>  /* { dg-require-effective-target trapping } */
> -/* { dg-require-fork } */
> +/* { dg-require-fork unused } */
>
>  #include 
>  #include 
> --- end of patch
>
> OK to commit?

Ok.

Thanks,
Richard.

> Thanks,
>
> Doug


Re: [PATCH] LTO streamer reorg - try to reduce WPA memory use

2014-07-30 Thread Richard Biener
On Wed, Jul 30, 2014 at 7:51 AM, Markus Trippelsdorf
 wrote:
> On 2014.07.29 at 15:10 +0200, Richard Biener wrote:
>> On Tue, 29 Jul 2014, Richard Biener wrote:
>>
>> >
>> > This re-organizes the LTO streamer to do compression transparently
>> > in the data-streamer routines (and disables section compression
>> > by defaulting to -flto-compression-level=0).  This avoids
>> > keeping the whole uncompressed sections in memory, only retaining
>> > the compressed ones.
>> >
>> > The downside is that we lose compression of at least the string
>> > parts (they are abusing the streaming interface quite awkwardly
>> > and doing random-accesses with offsets into the uncompressed
>> > section).  With a little bit of surgery we can get that back I
>> > think (but we'd have to keep the uncompressed piece in memory
>> > somewhere which means losing the memory use advantage).
>> >
>> > Very lightly tested sofar (running lto.exp).  I'll try a LTO
>> > bootstrap now.
>> >
>> > I wonder what the change is on WPA memory use for larger
>> > projects and what the effect on object file size is.
>>
>> Updated patch passing LTO bootstrap (one warning fix) and
>> with a memory leak fixed.
>
> Testing with Firefox is impossible at the moment because of PR61885.
> One thing I've noticed (before the ICE) is that virtual memory usage is
> very high:
>
> AddressKbytes  RSSDirty  Mode  Mapping
> 004016344 90840  r-x-- lto1
> 013f6000   36   36   28  rw--- lto1
> 013ff000 1072  276  276  rw---   [ anon ]
> 034aa000 10154940  1540384  1540384  rw---   [ anon ]
> 2acf04af2000  136  1360  r-x-- ld-2.19.90.so
> 2acf04b14000   88   88   88  rw---   [ anon ]
> ...
>   ---  ---  ---
> total kB 12022060  3388396  3377708

Maybe there is still a memleak (just checked that LTOing int main() {}
doesn't leak).

Otherwise I forgot to enable compression at all ;)

Richard.

> --
> Markus


Re: [GSoC] type of an isl_ast_expr_id

2014-07-30 Thread Tobias Grosser

On 30/07/2014 09:56, Roman Gareev wrote:

Blindly converting type sizes is not a good idea and may be problematic when
>we switch to smaller types. As we can obviously only improve this when we
>have the appropriate support in isl, I think the attached patch is fine.
>However, please add a fixme that states that this should
>be looked at again at the moment when we get isl support to derive the
>optimal types.

I've attached a patch, which contains the fixme.


OK. I proposed a slightly longer description. With the updated 
description, you can commit this patch.



>Please have a look at the original bug report:
>
>https://gcc.gnu.org/bugzilla/show_bug.cgi?id=35356
>
>The isl ast generator should produce something like:
>
>   for (i = 0; i < min (n, k); i++)
>  a[i] = i;
>   if (k >= 0 && k < n)
>  a[k] = 1;
>   for (i = max(k+1,0); i < n; i++)
>  a[i] = i;
>
>CLooG does not generate optimal code either, but the code generated by isl
>is a regression compared to CLooG.
>
>Can you generate an isl_codegen input for this test case and verify that the
>latest public version of isl does not generate this optimal code either. If
>it does not, please report this as an optimization bug to the isl mailing
>list.
>
>After you got feedback, I think it is OK to disable this test and to
>add a FIXME explaining why this test is disabled and if we can expect a fix
>in later versions of isl.

I've generated the code using the isl-0.13

if (n >= k + 1) {
   for (int c1 = 0; c1 < n; c1 += 1) {
 if (c1 >= k + 1) {
   S_7(c1);
 } else if (k >= c1 + 1) {
   S_7(c1);
 } else
   S_6(k);
   }
} else
   for (int c1 = 0; c1 < n; c1 += 1)
 S_7(c1);

If I'm not mistaken it's also a regression compared to ClooG and it's
better to report this to the isl mailing list.


That's what I suggested earlier, no? The only thing I would like you to 
check beforehand is if the very same problem still exists with isl 
trunk. For this you need to generate an input file for the 'isl_codegen' 
tool as it comes with isl that allows to reproduce the bug. The very 
same input file can then be submitted to the isl mailing list as a bug 
report. Could you do the reporting (and CC me)?



>What is the problem with this last test case?

It is related to checking for the loop parallelism, which is not yet
implemented in the current version of graphite-isl-ast-to-gimple.c.


OK. So yes, you are right that we need the parallelism test soon.

Cheers,
Tobias



Re: [PATCH] LTO streamer reorg - try to reduce WPA memory use

2014-07-30 Thread Markus Trippelsdorf
On 2014.07.30 at 10:31 +0200, Richard Biener wrote:
> On Wed, Jul 30, 2014 at 7:51 AM, Markus Trippelsdorf
>  wrote:
> > On 2014.07.29 at 15:10 +0200, Richard Biener wrote:
> >> On Tue, 29 Jul 2014, Richard Biener wrote:
> >>
> >> >
> >> > This re-organizes the LTO streamer to do compression transparently
> >> > in the data-streamer routines (and disables section compression
> >> > by defaulting to -flto-compression-level=0).  This avoids
> >> > keeping the whole uncompressed sections in memory, only retaining
> >> > the compressed ones.
> >> >
> >> > The downside is that we lose compression of at least the string
> >> > parts (they are abusing the streaming interface quite awkwardly
> >> > and doing random-accesses with offsets into the uncompressed
> >> > section).  With a little bit of surgery we can get that back I
> >> > think (but we'd have to keep the uncompressed piece in memory
> >> > somewhere which means losing the memory use advantage).
> >> >
> >> > Very lightly tested sofar (running lto.exp).  I'll try a LTO
> >> > bootstrap now.
> >> >
> >> > I wonder what the change is on WPA memory use for larger
> >> > projects and what the effect on object file size is.
> >>
> >> Updated patch passing LTO bootstrap (one warning fix) and
> >> with a memory leak fixed.
> >
> > Testing with Firefox is impossible at the moment because of PR61885.
> > One thing I've noticed (before the ICE) is that virtual memory usage is
> > very high:
> >
> > AddressKbytes  RSSDirty  Mode  Mapping
> > 004016344 90840  r-x-- lto1
> > 013f6000   36   36   28  rw--- lto1
> > 013ff000 1072  276  276  rw---   [ anon ]
> > 034aa000 10154940  1540384  1540384  rw---   [ anon ]
> > 2acf04af2000  136  1360  r-x-- ld-2.19.90.so
> > 2acf04b14000   88   88   88  rw---   [ anon ]
> > ...
> >   ---  ---  ---
> > total kB 12022060  3388396  3377708
> 
> Maybe there is still a memleak (just checked that LTOing int main() {}
> doesn't leak).
> 
> Otherwise I forgot to enable compression at all ;)

He. Also parallel streaming stopped working.

-- 
Markus


Re: [PATCH i386 AVX512] [1/n] Introduce `-mavx512dq' switch

2014-07-30 Thread Uros Bizjak
On Sun, Jul 27, 2014 at 2:50 PM, Kirill Yukhin  wrote:

> With this patch we'd like to start merge process of avx-512vlbwdq
> branch into main trunk.
>
> This patch introduces new switch `-mavx512dq'
>
> Bootstrapped.
>
> Is it ok for trunk?
>
> * common/config/i386/i386-common.c
> (OPTION_MASK_ISA_AVX512DQ_SET): Define.
> (OPTION_MASK_ISA_AVX512DQ_UNSET): Ditto.
> (ix86_handle_option): Handle OPT_mavx512dq.
> * config/i386/cpuid.h (bit_AVX512DQ): Define.
> * config/i386/driver-i386.c (host_detect_local_cpu): Detect avx512dq,
> set -mavx512dq accordingly.
> * config/i386/i386-c.c (ix86_target_macros_internal): Handle
> OPTION_MASK_ISA_AVX512DQ.
> * config/i386/i386.c (ix86_target_string): Handle -mavx512dq.
> (ix86_option_override_internal): Define PTA_AVX512DQ, handle
> PTA_AVX512DQ and OPTION_MASK_ISA_AVX512DQ.
> (ix86_valid_target_attribute_inner_p): Handle OPT_mavx512dq.
> * config/i386/i386.h (TARGET_AVX512DQ): Define.
> (TARGET_AVX512DQ_P(x)): Ditto.
> * config/i386/i386.opt: Add mavx512dq.

OK.

(Please take care not to break bootstrap after every part, so the
source will always be bisectable).

Thanks,
Uros.


RE: [PATCH] PR61868

2014-07-30 Thread Bingfeng Mei
Yes, opts-global.c fills flag_random_seed with string passed in command line. 
But init_random_seed in toplev.c is the one that processes the flag and set 
random_seed variable, which is returned by get_random_seed function. 

By default, my configuration enables LTO. How to test LTO bootstrap? 

Bingfeng

> -Original Message-
> From: Richard Biener [mailto:richard.guent...@gmail.com]
> Sent: 30 July 2014 08:47
> To: Bingfeng Mei; Andi Kleen
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [PATCH] PR61868
> 
> On Tue, Jul 29, 2014 at 3:01 PM, Bingfeng Mei  wrote:
> > Hi,
> > Please find the patches for pr61868. The problem is that even with -
> frandom-seed gcc always uses 0 instead of specified number/string for
> places such as lto section names. init_random_seed is never called with
> -frandom-seed. Bootstrapped and tested on x86-64. OK for trunk?
> 
> Hmm, but -frandom-seed= is honored by opts.c calling set_random_seed?
> 
> Andi, wasn't this used to support partial linking of LTO objects?  Thus,
> this shortcut was on purpose?  Otherwise passing -frandom-seed to
> LTO would break that?
> 
> Bingfeng, did you test if LTO bootstrap still works after this patch?
> 
> Thanks,
> Richard.
> 
> > Thanks,
> > Bingfeng Mei
> >
> >
> > ===
> > --- ChangeLog   (revision 213152)
> > +++ ChangeLog   (working copy)
> > @@ -1,3 +1,9 @@
> > +2014-07-29  Bingfeng Mei 
> > +
> > +   PR lto/61868
> > +   * toplev.c (init_random_seed): Generate random seed when
> > +   flag_random_seed is specified.
> > +
> >  2014-07-28  Jan Hubicka  
> >
> > * cgraph.c (cgraph_node::create_indirect_edge): Copy
> speculative data.
> > Index: toplev.c
> > ===
> > --- toplev.c(revision 213152)
> > +++ toplev.c(working copy)
> > @@ -301,7 +301,7 @@ init_random_seed (void)
> >  HOST_WIDE_INT
> >  get_random_seed (bool noinit)
> >  {
> > -  if (!flag_random_seed && !noinit)
> > +  if (!noinit)
> >  init_random_seed ();
> >return random_seed;
> >  }
> > Index: testsuite/ChangeLog
> > ===
> > --- testsuite/ChangeLog (revision 213152)
> > +++ testsuite/ChangeLog (working copy)
> > @@ -1,3 +1,8 @@
> > +2014-07-29  Bingfeng Mei  
> > +
> > +   PR lto/61868
> > +   * gcc.dg/pr61868.c: New test.
> > +
> >  2014-07-28  Richard Biener  
> >
> > PR rtl-optimization/61801
> > Index: testsuite/gcc.dg/pr61868.c
> > ===
> > --- testsuite/gcc.dg/pr61868.c  (revision 0)
> > +++ testsuite/gcc.dg/pr61868.c  (revision 0)
> > @@ -0,0 +1,9 @@
> > +/* { dg-do compile } */
> > +/* { dg-options "-flto -frandom-seed=0x12345" }  */
> > +extern int foo (int);
> > +int main ()
> > +{
> > +  foo (100);
> > +  return 0;
> > +}
> > +/* { dg-final { scan-assembler "\.gnu\.lto.*.12345" } } */
> >


[PATCH][LTO] Do not use the data streamer when we are not using it

2014-07-30 Thread Richard Biener

The following patch avoids going though the data streamer when we
only end up outputting raw data via lto_output_data_stream.  The
patch adds a simple lto_write_data which writes to the current
section.  symtab producing may want to use an obstack similar to
lto-opts.c, but I didn't bother to adjust it.

Affected are for example writing the LTO headers.

This also avoids needless copying of the function body data
at WPA time.

(LTO) bootstrap and regtest pending on x86_64-unknown-linux-gnu.

Richard.

2014-07-30  Richard Biener  

* lto-streamer.h (lto_write_data): New function.
* langhooks.c (lhd_append_data): Do not free block.
* lto-section-out.c (lto_write_data): New function writing
raw data to the current section.
(lto_write_stream): Adjust for langhook semantic change.
(lto_destroy_simple_output_block): Write header directly.
* lto-opts.c (lto_write_options): Write options directly.
* lto-streamer-out.c (produce_asm): Write heaeder directly.
(lto_output_toplevel_asms): Likewise.
(copy_function_or_variable): Copy data directly.
(write_global_references): Output index table directly.
(lto_output_decl_state_refs): Likewise.
(write_symbol): Write data directly.
(produce_symtab): Adjust.
(produce_asm_for_decls): Output header and refs directly.

lto/
* lto-object.c (lto_obj_append_data): Do not free block.

Index: gcc/lto-streamer.h
===
--- gcc/lto-streamer.h  (revision 213152)
+++ gcc/lto-streamer.h  (working copy)
@@ -777,6 +777,7 @@ extern void lto_value_range_error (const
 /* In lto-section-out.c  */
 extern void lto_begin_section (const char *, bool);
 extern void lto_end_section (void);
+extern void lto_write_data (const void *, unsigned int);
 extern void lto_write_stream (struct lto_output_stream *);
 extern void lto_output_data_stream (struct lto_output_stream *, const void *,
size_t);
Index: gcc/lto-section-out.c
===
--- gcc/lto-section-out.c   (revision 213152)
+++ gcc/lto-section-out.c   (working copy)
@@ -98,6 +98,16 @@ lto_end_section (void)
   lang_hooks.lto.end_section ();
 }
 
+/* Write SIZE bytes starting at DATA to the assembler.  */
+
+void
+lto_write_data (const void *data, unsigned int size)
+{
+  if (compression_stream)
+lto_compress_block (compression_stream, (const char *)data, size);
+  else
+lang_hooks.lto.append_data ((const char *)data, size, NULL);
+}
 
 /* Write all of the chars in OBS to the assembler.  Recycle the blocks
in obs as this is being done.  */
@@ -128,12 +138,10 @@ lto_write_stream (struct lto_output_stre
  blocks up output differently to the way it's blocked here.  So for
  now, we don't compress WPA output.  */
   if (compression_stream)
-   {
- lto_compress_block (compression_stream, base, num_chars);
- lang_hooks.lto.append_data (NULL, 0, block);
-   }
+   lto_compress_block (compression_stream, base, num_chars);
   else
lang_hooks.lto.append_data (base, num_chars, block);
+  free (block);
   block_size *= 2;
 }
 }
@@ -335,7 +343,6 @@ lto_destroy_simple_output_block (struct
 {
   char *section_name;
   struct lto_simple_header header;
-  struct lto_output_stream *header_stream;
 
   section_name = lto_get_section_name (ob->section_type, NULL, NULL);
   lto_begin_section (section_name, !flag_wpa);
@@ -346,15 +353,9 @@ lto_destroy_simple_output_block (struct
   memset (&header, 0, sizeof (struct lto_simple_header));
   header.lto_header.major_version = LTO_major_version;
   header.lto_header.minor_version = LTO_minor_version;
-
   header.compressed_size = 0;
-
   header.main_size = ob->main_stream->total_size;
-
-  header_stream = XCNEW (struct lto_output_stream);
-  lto_output_data_stream (header_stream, &header, sizeof header);
-  lto_write_stream (header_stream);
-  free (header_stream);
+  lto_write_data (&header, sizeof header);
 
   lto_write_stream (ob->main_stream);
 
Index: gcc/langhooks.c
===
--- gcc/langhooks.c (revision 213152)
+++ gcc/langhooks.c (working copy)
@@ -661,14 +661,13 @@ lhd_begin_section (const char *name)
 
 
 /* Write DATA of length LEN to the current LTO output section.  This default
-   implementation just calls assemble_string and frees BLOCK.  */
+   implementation just calls assemble_string.  */
 
 void
-lhd_append_data (const void *data, size_t len, void *block)
+lhd_append_data (const void *data, size_t len, void *)
 {
   if (data)
 assemble_string ((const char *)data, len);
-  free (block);
 }
 
 
Index: gcc/lto/lto-object.c
===
--- gcc/lto/lto-object.c(revision 213152)
+++ gcc/lto/lto-object.

Re: [PATCH] LTO streamer reorg - try to reduce WPA memory use

2014-07-30 Thread Richard Biener
On Wed, 30 Jul 2014, Markus Trippelsdorf wrote:

> On 2014.07.30 at 10:31 +0200, Richard Biener wrote:
> > On Wed, Jul 30, 2014 at 7:51 AM, Markus Trippelsdorf
> >  wrote:
> > > On 2014.07.29 at 15:10 +0200, Richard Biener wrote:
> > >> On Tue, 29 Jul 2014, Richard Biener wrote:
> > >>
> > >> >
> > >> > This re-organizes the LTO streamer to do compression transparently
> > >> > in the data-streamer routines (and disables section compression
> > >> > by defaulting to -flto-compression-level=0).  This avoids
> > >> > keeping the whole uncompressed sections in memory, only retaining
> > >> > the compressed ones.
> > >> >
> > >> > The downside is that we lose compression of at least the string
> > >> > parts (they are abusing the streaming interface quite awkwardly
> > >> > and doing random-accesses with offsets into the uncompressed
> > >> > section).  With a little bit of surgery we can get that back I
> > >> > think (but we'd have to keep the uncompressed piece in memory
> > >> > somewhere which means losing the memory use advantage).
> > >> >
> > >> > Very lightly tested sofar (running lto.exp).  I'll try a LTO
> > >> > bootstrap now.
> > >> >
> > >> > I wonder what the change is on WPA memory use for larger
> > >> > projects and what the effect on object file size is.
> > >>
> > >> Updated patch passing LTO bootstrap (one warning fix) and
> > >> with a memory leak fixed.
> > >
> > > Testing with Firefox is impossible at the moment because of PR61885.
> > > One thing I've noticed (before the ICE) is that virtual memory usage is
> > > very high:
> > >
> > > AddressKbytes  RSSDirty  Mode  Mapping
> > > 004016344 90840  r-x-- lto1
> > > 013f6000   36   36   28  rw--- lto1
> > > 013ff000 1072  276  276  rw---   [ anon ]
> > > 034aa000 10154940  1540384  1540384  rw---   [ anon ]
> > > 2acf04af2000  136  1360  r-x-- ld-2.19.90.so
> > > 2acf04b14000   88   88   88  rw---   [ anon ]
> > > ...
> > >   ---  ---  ---
> > > total kB 12022060  3388396  3377708
> > 
> > Maybe there is still a memleak (just checked that LTOing int main() {}
> > doesn't leak).
> > 
> > Otherwise I forgot to enable compression at all ;)
> 
> He. Also parallel streaming stopped working.

Interesting.  Meanwhile after enabling compression the benefit of the
patch is the reduction in LTRANS file size (stage3 cc1) from
460MB to 178MB because we now compress here.

Object file size of stage3-gcc/*.o is increased to 540MB from 506MB
(note LTO bootstrap is with fat LTO objects, so the increase in
LTO IL size is bigger that it looks like).  I suppose mainly due
to no longer compressing strings.

I also can observe the appearant memleak - will try to hunt it down.

Richard.


Re: [wwwdocs] Add gcc-5/{changes,criteria}.html

2014-07-30 Thread Richard Biener
On Wed, Jul 30, 2014 at 8:35 AM, Marek Polacek  wrote:
> On Wed, Jul 30, 2014 at 08:31:35AM +0200, Tobias Burnus wrote:
>> This patch adds the files gcc-5/{changes,criteria}.html - and populates the
>> former with Fortran changes; the latter is a copy of the GCC 4.9 file.
>>
>> Is the patch OK?
>
> Thanks for the patch!
>
>>  gcc-5/changes.html  |   60 +
>>  gcc-5/criteria.html |  144 
>> 
>>  index.html  |3 -
>>  3 files changed, 206 insertions(+), 1 deletion(-)
>>
>> Index: htdocs/index.html
>> ===
>> RCS file: /cvs/gcc/wwwdocs/htdocs/index.html,v
>> retrieving revision 1.932
>> diff -u -r1.932 index.html
>> --- htdocs/index.html 16 Jul 2014 14:26:39 -  1.932
>> +++ htdocs/index.html 30 Jul 2014 06:30:21 -
>> @@ -161,7 +161,8 @@
>>  
>>
>>  Development:
>> -  GCC 4.10.0 (release criteria)
>> +  GCC 4.10.0 (release criteria,
>
> I guess s/GCC 4.10.0/GCC 5.0/.
>
>> +  changes)
>>  
>>Status:
>>
>
> Here as well.

Ok with those changes.

Richard.

> Marek


Re: [PATCH] PR61868

2014-07-30 Thread Richard Biener
On Wed, Jul 30, 2014 at 10:52 AM, Bingfeng Mei  wrote:
> Yes, opts-global.c fills flag_random_seed with string passed in command line. 
> But init_random_seed in toplev.c is the one that processes the flag and set 
> random_seed variable, which is returned by get_random_seed function.

Err, I meant opts-global.c:handle_common_deferred_options

> By default, my configuration enables LTO. How to test LTO bootstrap?

configure with --with-build-config=bootstrap-lto (and reduce the
set of languages to c,c++ to get a sane bootstrap time).

Richard.

> Bingfeng
>
>> -Original Message-
>> From: Richard Biener [mailto:richard.guent...@gmail.com]
>> Sent: 30 July 2014 08:47
>> To: Bingfeng Mei; Andi Kleen
>> Cc: gcc-patches@gcc.gnu.org
>> Subject: Re: [PATCH] PR61868
>>
>> On Tue, Jul 29, 2014 at 3:01 PM, Bingfeng Mei  wrote:
>> > Hi,
>> > Please find the patches for pr61868. The problem is that even with -
>> frandom-seed gcc always uses 0 instead of specified number/string for
>> places such as lto section names. init_random_seed is never called with
>> -frandom-seed. Bootstrapped and tested on x86-64. OK for trunk?
>>
>> Hmm, but -frandom-seed= is honored by opts.c calling set_random_seed?
>>
>> Andi, wasn't this used to support partial linking of LTO objects?  Thus,
>> this shortcut was on purpose?  Otherwise passing -frandom-seed to
>> LTO would break that?
>>
>> Bingfeng, did you test if LTO bootstrap still works after this patch?
>>
>> Thanks,
>> Richard.
>>
>> > Thanks,
>> > Bingfeng Mei
>> >
>> >
>> > ===
>> > --- ChangeLog   (revision 213152)
>> > +++ ChangeLog   (working copy)
>> > @@ -1,3 +1,9 @@
>> > +2014-07-29  Bingfeng Mei 
>> > +
>> > +   PR lto/61868
>> > +   * toplev.c (init_random_seed): Generate random seed when
>> > +   flag_random_seed is specified.
>> > +
>> >  2014-07-28  Jan Hubicka  
>> >
>> > * cgraph.c (cgraph_node::create_indirect_edge): Copy
>> speculative data.
>> > Index: toplev.c
>> > ===
>> > --- toplev.c(revision 213152)
>> > +++ toplev.c(working copy)
>> > @@ -301,7 +301,7 @@ init_random_seed (void)
>> >  HOST_WIDE_INT
>> >  get_random_seed (bool noinit)
>> >  {
>> > -  if (!flag_random_seed && !noinit)
>> > +  if (!noinit)
>> >  init_random_seed ();
>> >return random_seed;
>> >  }
>> > Index: testsuite/ChangeLog
>> > ===
>> > --- testsuite/ChangeLog (revision 213152)
>> > +++ testsuite/ChangeLog (working copy)
>> > @@ -1,3 +1,8 @@
>> > +2014-07-29  Bingfeng Mei  
>> > +
>> > +   PR lto/61868
>> > +   * gcc.dg/pr61868.c: New test.
>> > +
>> >  2014-07-28  Richard Biener  
>> >
>> > PR rtl-optimization/61801
>> > Index: testsuite/gcc.dg/pr61868.c
>> > ===
>> > --- testsuite/gcc.dg/pr61868.c  (revision 0)
>> > +++ testsuite/gcc.dg/pr61868.c  (revision 0)
>> > @@ -0,0 +1,9 @@
>> > +/* { dg-do compile } */
>> > +/* { dg-options "-flto -frandom-seed=0x12345" }  */
>> > +extern int foo (int);
>> > +int main ()
>> > +{
>> > +  foo (100);
>> > +  return 0;
>> > +}
>> > +/* { dg-final { scan-assembler "\.gnu\.lto.*.12345" } } */
>> >


Re: [PATCH] Make sra_modify_assign's stmt prameter gimple (as opposed to gimple *)

2014-07-30 Thread Martin Jambor
Hi,

On Fri, Jul 25, 2014 at 10:56:10AM -0700, Sebastian Pop wrote:
> On Fri, Jul 25, 2014 at 9:50 AM, Martin Jambor  wrote:
> > Hi,
> >
> > parameter stmt of sra_modify_assign and sra_modify_constructor_assign
> > is currently gimple*, although there is no need for the extra level of
> > indirection and dereferencing.  Thus this patch removes quite few
> > stars and one ampersand.
> 
> Looks good to me.
> Can you please also remove the * from "gimple *stmt_ptr" in
> sra_ipa_modify_assign?
> 

Sure, I will commit the following as obvious later today, after a
round of bootstrap and testsuite finishes.

Thanks,

Martin

2014-07-29  Martin Jambor  

* tree-sra.c (sra_ipa_modify_assign): Change type fo the first
parameter to gimple.

diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index d90f00a..340d072 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -4579,17 +4579,15 @@ replace_removed_params_ssa_names (gimple stmt,
   return true;
 }
 
-/* If the statement pointed to by STMT_PTR contains any expressions that need
-   to replaced with a different one as noted by ADJUSTMENTS, do so.  Handle any
-   potential type incompatibilities (GSI is used to accommodate conversion
-   statements and must point to the statement).  Return true iff the statement
-   was modified.  */
+/* If the statement STMT contains any expressions that need to replaced with a
+   different one as noted by ADJUSTMENTS, do so.  Handle any potential type
+   incompatibilities (GSI is used to accommodate conversion statements and must
+   point to the statement).  Return true iff the statement was modified.  */
 
 static bool
-sra_ipa_modify_assign (gimple *stmt_ptr, gimple_stmt_iterator *gsi,
+sra_ipa_modify_assign (gimple stmt, gimple_stmt_iterator *gsi,
   ipa_parm_adjustment_vec adjustments)
 {
-  gimple stmt = *stmt_ptr;
   tree *lhs_p, *rhs_p;
   bool any;
 
@@ -4676,7 +4674,7 @@ ipa_sra_modify_function_body (ipa_parm_adjustment_vec 
adjustments)
  break;
 
case GIMPLE_ASSIGN:
- modified |= sra_ipa_modify_assign (&stmt, &gsi, adjustments);
+ modified |= sra_ipa_modify_assign (stmt, &gsi, adjustments);
  modified |= replace_removed_params_ssa_names (stmt, adjustments);
  break;
 


[Ada] Internal cleanup for Predicate_Tests_On_Arguments

2014-07-30 Thread Arnaud Charlet
Some additional cases of internal routines are now detected and skip
predicate tests on arguments. Not clear if this fixes additional
problems or not, but it is certainly a desirable change. No further
test required.

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

2014-07-30  Robert Dewar  

* sem_util.adb (Predicate_Tests_On_Arguments): Omit tests for
some additional cases of internally generated routines.

Index: sem_util.adb
===
--- sem_util.adb(revision 213212)
+++ sem_util.adb(working copy)
@@ -14723,32 +14723,42 @@
 
function Predicate_Tests_On_Arguments (Subp : Entity_Id) return Boolean is
begin
+  --  Always test predicates on indirect call
+
+  if Ekind (Subp) = E_Subprogram_Type then
+ return True;
+
   --  Do not test predicates on call to generated default Finalize, since
   --  we are not interested in whether something we are finalizing (and
   --  typically destroying) satisfies its predicates.
 
-  if Chars (Subp) = Name_Finalize
+  elsif Chars (Subp) = Name_Finalize
 and then not Comes_From_Source (Subp)
   then
  return False;
 
- --  Do not test predicates on call to Init_Proc, since if needed the
- --  predicate test will occur at some other point.
+  --  Do not test predicates on any internally generated routines
 
+  elsif Is_Internal_Name (Chars (Subp)) then
+ return False;
+
+  --  Do not test predicates on call to Init_Proc, since if needed the
+  --  predicate test will occur at some other point.
+
   elsif Is_Init_Proc (Subp) then
  return False;
 
- --  Do not test predicates on call to predicate function, since this
- --  would cause infinite recursion.
+  --  Do not test predicates on call to predicate function, since this
+  --  would cause infinite recursion.
 
   elsif Ekind (Subp) = E_Function
 and then (Is_Predicate_Function (Subp)
-  or else
+or else
   Is_Predicate_Function_M (Subp))
   then
  return False;
 
- --  For now, no other exceptions
+  --  For now, no other exceptions
 
   else
  return True;


[Ada] Inheritance of variables in extending projects

2014-07-30 Thread Arnaud Charlet
A variable V declared in a project A that is extended by a project B is
now inherited in project B; it can be referenced as V in project B or as
B.V in any other project that imports B.

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

2014-07-30  Vincent Celier  

* prj-proc.adb (Imported_Or_Extended_Project_From): New Boolean
parameter No_Extending, defaulted to False. When No_Extending
is True, do not look for an extending project.
(Expression): For a variable reference that is not for the current
project, get its Id calling Imported_Or_Extended_Project_From
with No_Extending set to True.
* prj-strt.adb (Parse_Variable_Reference): If a referenced
variable is not found in the current project, check if it is
defined in one of the projects it extends.

Index: prj-proc.adb
===
--- prj-proc.adb(revision 213201)
+++ prj-proc.adb(working copy)
@@ -118,8 +118,9 @@
--  of an expression and return it as a Variable_Value.
 
function Imported_Or_Extended_Project_From
- (Project   : Project_Id;
-  With_Name : Name_Id) return Project_Id;
+ (Project  : Project_Id;
+  With_Name: Name_Id;
+  No_Extending : Boolean := False) return Project_Id;
--  Find an imported or extended project of Project whose name is With_Name
 
function Package_From
@@ -705,8 +706,9 @@
  The_Name :=
Name_Of (Term_Project, From_Project_Node_Tree);
  The_Project := Imported_Or_Extended_Project_From
-  (Project   => Project,
-   With_Name => The_Name);
+  (Project  => Project,
+   With_Name=> The_Name,
+   No_Extending => True);
   end if;
 
   if Present (Term_Package) then
@@ -1261,8 +1263,9 @@
---
 
function Imported_Or_Extended_Project_From
- (Project   : Project_Id;
-  With_Name : Name_Id) return Project_Id
+ (Project  : Project_Id;
+  With_Name: Name_Id;
+  No_Extending : Boolean := False) return Project_Id
is
   List: Project_List;
   Result  : Project_Id;
@@ -1304,7 +1307,12 @@
 Proj := Result.Extends;
 while Proj /= No_Project loop
if Proj.Name = With_Name then
-  Temp_Result := Result;
+  if No_Extending then
+ Temp_Result := Proj;
+  else
+ Temp_Result := Result;
+  end if;
+
   exit;
end if;
 
Index: prj-strt.adb
===
--- prj-strt.adb(revision 213201)
+++ prj-strt.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 2001-2010, Free Software Foundation, Inc. --
+--  Copyright (C) 2001-2014, 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- --
@@ -1162,7 +1162,7 @@
 
 --  If we have not found the variable in the package, check if the
 --  variable has been declared in the project, or in any of its
---  ancestors.
+--  ancestors, or in any of the project it extends.
 
 if No (Current_Variable) then
declare
@@ -1182,8 +1182,15 @@
 
  exit when Present (Current_Variable);
 
- Proj := Parent_Project_Of (Proj, In_Tree);
+ if No (Parent_Project_Of (Proj, In_Tree)) then
+Proj :=
+  Extended_Project_Of
+(Project_Declaration_Of (Proj, In_Tree), In_Tree);
 
+ else
+Proj := Parent_Project_Of (Proj, In_Tree);
+ end if;
+
  Set_Project_Node_Of (Variable, In_Tree, To => Proj);
 
  exit when No (Proj);


[AArch64_be] Fix vec_select hi/lo mask confusions.

2014-07-30 Thread James Greenhalgh

Hi,

A vec_select mask exists in GCC's world-view of lane ordering. The
"low-half" of the vector { a, b, c, d } is { a, b }, which on big-endian
will be in the high bits of the architectural register. On little-endian,
these lanes will be in the low bits of the architectural register.
We therefore need different masks depending on our target endian-ness.
The diagram below may help.

We must draw the distinction when building masks which select one half of the
vector.  An instruction selecting architectural low-lanes for a big-endian
target, must be described using a mask selecting GCC high-lanes.

 Big-Endian Little-Endian

GCC 0   1   2   3   3   2   1   0
  | x | x | x | x |   | x | x | x | x |
Architecture3   2   1   0   3   2   1   0

Low Mask: { 2, 3 }{ 0, 1 }
High Mask:{ 0, 1 }{ 2, 3 }

The way we implement this requires some "there is no spoon" thinking to avoid
pattern duplication. We define a vec_par_cnst_lo_half mask to always
refer to the low architectural lanes. I gave some thought to renaming this
vec_par_cnst_arch_lo_half, but it didn't add much meaning. I'm happy to
take bike-shedding towards a more self-documenting naming scheme.

No regressions spotted on aarch64_be-none-elf or aarch64-none-elf.

OK for trunk?

Thanks,
James

---
gcc/

2014-07-30  James Greenhalgh  

* config/aarch64/aarch64.c (aarch64_simd_vect_par_cnst_half): Vary
the generated mask based on BYTES_BIG_ENDIAN.
(aarch64_simd_check_vect_par_cnst_half): New.
* config/aarch64/aarch64-protos.h
(aarch64_simd_check_vect_par_cnst_half): New.
* config/aarch64/predicates.md (vect_par_cnst_hi_half): Refactor
the check out to aarch64_simd_check_vect_par_cnst_half.
(vect_par_cnst_lo_half): Likewise.
* config/aarch64/aarch64-simd.md
(aarch64_simd_move_hi_quad_): Always use vec_par_cnst_lo_half.
(move_hi_quad_): Always generate a low mask.
diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index 53023ba..927a20e 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -200,6 +200,8 @@ bool aarch64_pad_arg_upward (enum machine_mode, const_tree);
 bool aarch64_pad_reg_upward (enum machine_mode, const_tree, bool);
 bool aarch64_regno_ok_for_base_p (int, bool);
 bool aarch64_regno_ok_for_index_p (int, bool);
+bool aarch64_simd_check_vect_par_cnst_half (rtx op, enum machine_mode mode,
+	bool high);
 bool aarch64_simd_imm_scalar_p (rtx x, enum machine_mode mode);
 bool aarch64_simd_imm_zero_p (rtx, enum machine_mode);
 bool aarch64_simd_scalar_immediate_valid_for_move (rtx, enum machine_mode);
diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md
index 6300b9b6c7ac06384d2e59bbac1a0d5445975bb6..0d4b37e53b758919aea382c22d1c600f113a8b54 100644
--- a/gcc/config/aarch64/aarch64-simd.md
+++ b/gcc/config/aarch64/aarch64-simd.md
@@ -1022,7 +1022,7 @@ (define_insn "aarch64_simd_move_hi_quad_
 	  (match_operand: 1 "register_operand" "w,r")
   (vec_select:
 (match_dup 0)
-(match_operand:VQ 2 "vect_par_cnst_hi_half" ""]
+(match_operand:VQ 2 "vect_par_cnst_lo_half" ""]
   "TARGET_SIMD && BYTES_BIG_ENDIAN"
   "@
ins\\t%0.d[1], %1.d[0]
@@ -1035,7 +1035,7 @@ (define_expand "move_hi_quad_"
   (match_operand: 1 "register_operand" "")]
  "TARGET_SIMD"
 {
-  rtx p = aarch64_simd_vect_par_cnst_half (mode, BYTES_BIG_ENDIAN);
+  rtx p = aarch64_simd_vect_par_cnst_half (mode, false);
   if (BYTES_BIG_ENDIAN)
 emit_insn (gen_aarch64_simd_move_hi_quad_be_ (operands[0],
 		operands[1], p));
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index ed80269..2ea55e8 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -7900,23 +7900,81 @@ aarch64_simd_scalar_immediate_valid_for_move (rtx op, enum machine_mode mode)
   return aarch64_simd_valid_immediate (op_v, vmode, false, NULL);
 }
 
-/* Construct and return a PARALLEL RTX vector.  */
+/* Construct and return a PARALLEL RTX vector with elements numbering the
+   lanes of either the high (HIGH == TRUE) or low (HIGH == FALSE) half of
+   the vector - from the perspective of the architecture.  This does not
+   line up with GCC's perspective on lane numbers, so we end up with
+   different masks depending on our target endian-ness.  The diagram
+   below may help.  We must draw the distinction when building masks
+   which select one half of the vector.  An instruction selecting
+   architectural low-lanes for a big-endian target, must be described using
+   a mask selecting GCC high-lanes.
+
+ Big-Endian Little-Endian
+
+GCC 0   1   2   3   3   2   1   0
+  | x | x | x | x |   | x | x | x | x |
+Architecture3   2 

[AArch64_be] Don't fold reduction intrinsics.

2014-07-30 Thread James Greenhalgh

Hi,

Reduction operations are defined in tree.def to

   return a vector of the same type, with the first element in the vector
   holding the result of the reduction of all elements of the operand.  The
   content of the other elements in the returned vector is undefined.

The reduction intrinsics map to AArch64's reduction instructions (addv and
friends). These return their result in architectural lane 0. In GCC's view,
this is at the opposite end of the vector from element 0.

It is therefore not correct to make this fold for BYTES_BIG_ENDIAN.

Tested big/little-endian with no issues on aarch64-none-elf.

OK?

Thanks,
James

---
gcc/

2014-07-28  James Greenhalgh  

* config/aarch64/aarch64-builtins.c
(aarch64_gimple_fold_builtin): Don't fold reduction operations for
BYTES_BIG_ENDIAN.
diff --git a/gcc/config/aarch64/aarch64-builtins.c b/gcc/config/aarch64/aarch64-builtins.c
index fee17ec..58db77e 100644
--- a/gcc/config/aarch64/aarch64-builtins.c
+++ b/gcc/config/aarch64/aarch64-builtins.c
@@ -1383,6 +1383,20 @@ aarch64_gimple_fold_builtin (gimple_stmt_iterator *gsi)
   tree call = gimple_call_fn (stmt);
   tree fndecl;
   gimple new_stmt = NULL;
+
+  /* The operations folded below are reduction operations.  These are
+ defined to leave their result in the 0'th element (from the perspective
+ of GCC).  The architectural instruction we are folding will leave the
+ result in the 0'th element (from the perspective of the architecture).
+ For big-endian systems, these perspectives are not aligned.
+
+ It is therefore wrong to perform this fold on big-endian.  There
+ are some tricks we could play with shuffling, but the mid-end is
+ inconsistent in the way it treats reduction operations, so we will
+ end up in difficulty.  Until we fix the ambiguity - just bail out.  */
+  if (BYTES_BIG_ENDIAN)
+return false;
+
   if (call)
 {
   fndecl = gimple_call_fndecl (stmt);

Re: [AArch64_be] Fix vec_select hi/lo mask confusions.

2014-07-30 Thread Richard Biener
On Wed, Jul 30, 2014 at 12:10 PM, James Greenhalgh
 wrote:
>
> Hi,
>
> A vec_select mask exists in GCC's world-view of lane ordering. The
> "low-half" of the vector { a, b, c, d } is { a, b }, which on big-endian
> will be in the high bits of the architectural register. On little-endian,
> these lanes will be in the low bits of the architectural register.
> We therefore need different masks depending on our target endian-ness.
> The diagram below may help.
>
> We must draw the distinction when building masks which select one half of the
> vector.  An instruction selecting architectural low-lanes for a big-endian
> target, must be described using a mask selecting GCC high-lanes.
>
>  Big-Endian Little-Endian
>
> GCC 0   1   2   3   3   2   1   0
>   | x | x | x | x |   | x | x | x | x |
> Architecture3   2   1   0   3   2   1   0
>
> Low Mask: { 2, 3 }{ 0, 1 }
> High Mask:{ 0, 1 }{ 2, 3 }
>
> The way we implement this requires some "there is no spoon" thinking to avoid
> pattern duplication. We define a vec_par_cnst_lo_half mask to always
> refer to the low architectural lanes. I gave some thought to renaming this
> vec_par_cnst_arch_lo_half, but it didn't add much meaning. I'm happy to
> take bike-shedding towards a more self-documenting naming scheme.
>
> No regressions spotted on aarch64_be-none-elf or aarch64-none-elf.
>
> OK for trunk?

Please make sure the above is still correct if you rip out all
if (BYTES_BIG_ENDIAN) cases from tree-vect*.c.

Richard.

> Thanks,
> James
>
> ---
> gcc/
>
> 2014-07-30  James Greenhalgh  
>
> * config/aarch64/aarch64.c (aarch64_simd_vect_par_cnst_half): Vary
> the generated mask based on BYTES_BIG_ENDIAN.
> (aarch64_simd_check_vect_par_cnst_half): New.
> * config/aarch64/aarch64-protos.h
> (aarch64_simd_check_vect_par_cnst_half): New.
> * config/aarch64/predicates.md (vect_par_cnst_hi_half): Refactor
> the check out to aarch64_simd_check_vect_par_cnst_half.
> (vect_par_cnst_lo_half): Likewise.
> * config/aarch64/aarch64-simd.md
> (aarch64_simd_move_hi_quad_): Always use vec_par_cnst_lo_half.
> (move_hi_quad_): Always generate a low mask.


[Ada] Improve run time performance for large array reset

2014-07-30 Thread Arnaud Charlet
This patch makes the compiler generate faster code to reset a large array of
integers to 0 by means of an aggregate with a single Others choice and, more
generally, to set a large array of storage units to a single value by the
same means, for example:

  type Arr is array (1 .. 1) of Integer;
  A : Arr := (others => 0);

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

2014-07-30  Eric Botcazou  

* exp_aggr.adb (Aggr_Assignment_OK_For_Backend): New predicate.
(Expand_Array_Aggregate): Also enable in-place expansion for
code generated by the compiler.  For an object declaration,
set the kind of the object in addition to its type.  If an
in-place assignment is to be generated and it can be directly
done by the back-end, do not expand the aggregate.
* fe.h (Is_Others_Aggregate): Declare.
* gcc-interface/trans.c
(gnat_to_gnu) : Add support for an
aggregate with a single Others choice on the RHS by means of
__builtin_memset.  Tidy up.

Index: fe.h
===
--- fe.h(revision 213201)
+++ fe.h(working copy)
@@ -202,6 +202,11 @@
 extern void Check_Elaboration_Code_Allowed (Node_Id);
 extern void Check_Implicit_Dynamic_Code_Allowed (Node_Id);
 
+/* sem_aggr:  */
+#define Is_Others_Aggregatesem_aggr__is_others_aggregate
+
+extern Boolean Is_Others_Aggregate (Node_Id);
+
 /* sem_aux:  */
 
 #define Ancestor_Subtype   sem_aux__ancestor_subtype
Index: exp_aggr.adb
===
--- exp_aggr.adb(revision 213216)
+++ exp_aggr.adb(working copy)
@@ -3945,6 +3945,9 @@
   Aggr_Index_Typ : array (1 .. Aggr_Dimension) of Entity_Id;
   --  The type of each index
 
+  In_Place_Assign_OK_For_Declaration : Boolean := False;
+  --  True if we are to generate an in place assignment for a declaration
+
   Maybe_In_Place_OK : Boolean;
   --  If the type is neither controlled nor packed and the aggregate
   --  is the expression in an assignment, assignment in place may be
@@ -3955,6 +3958,9 @@
   --  If Others_Present (J) is True, then there is an others choice
   --  in one of the sub-aggregates of N at dimension J.
 
+  function Aggr_Assignment_OK_For_Backend (N : Node_Id) return Boolean;
+  --  Returns true if an aggregate assignment can be done by the back end
+
   procedure Build_Constrained_Type (Positional : Boolean);
   --  If the subtype is not static or unconstrained, build a constrained
   --  type using the computable sizes of the aggregate and its sub-
@@ -3991,6 +3997,108 @@
   --  built directly into the target of the assignment it must be free
   --  of side-effects.
 
+  
+  -- Aggr_Assignment_OK_For_Backend --
+  
+
+  --  Backend processing by Gigi/gcc is possible only if all the following
+  --  conditions are met:
+
+  --1. N consists of a single OTHERS choice, possibly recursively
+
+  --2. The component type is discrete
+
+  --3. The component size is a multiple of Storage_Unit
+
+  --4. The component size is exactly Storage_Unit or the expression is
+  --   an integer whose unsigned value is the binary concatenation of
+  --   K times its remainder modulo 2**Storage_Unit.
+
+  --  The ultimate goal is to generate a call to a fast memset routine
+  --  specifically optimized for the target.
+
+  function Aggr_Assignment_OK_For_Backend (N : Node_Id) return Boolean is
+ Ctyp  : Entity_Id;
+ Expr  : Node_Id := N;
+ Remainder : Uint;
+ Value : Uint;
+ Nunits: Nat;
+
+  begin
+ --  Recurse as far as possible to find the innermost component type
+
+ Ctyp := Etype (N);
+ while Is_Array_Type (Ctyp) loop
+if Nkind (Expr) /= N_Aggregate
+  or else not Is_Others_Aggregate (Expr)
+then
+   return False;
+end if;
+
+Expr := Expression (First (Component_Associations (Expr)));
+
+for J in 1 .. Number_Dimensions (Ctyp) - 1 loop
+   if Nkind (Expr) /= N_Aggregate
+ or else not Is_Others_Aggregate (Expr)
+   then
+  return False;
+   end if;
+
+   Expr := Expression (First (Component_Associations (Expr)));
+end loop;
+
+Ctyp := Component_Type (Ctyp);
+ end loop;
+
+ if not Is_Discrete_Type (Ctyp)
+   or else RM_Size (Ctyp) mod System_Storage_Unit /= 0
+ then
+return False;
+ end if;
+
+ --  The expression needs to be analyzed if True is returned
+
+ Analyze_And_Resolve (Expr, Ctyp);
+
+ Nunits := UI_To_Int (RM_Size (Ctyp) / S

Re: [PATCH] add hash_set

2014-07-30 Thread Richard Biener
On Tue, Jul 29, 2014 at 2:50 PM,   wrote:
> From: Trevor Saunders 
>
> Hi,
>
> this adds a hash_set wrapper around hash_table, and then replaces usage of 
> pointer_set with it.
>
> bootstrapped +regtested on x86_64-unknown-linux-gnu, ok?

Ok.

Thanks,
Richard.

> Trev
>
> ada/
>
> * gcc-interface/trans.c: Use hash_set instead of pointer_set.
>
> c-family/
>
> * c-gimplify.c: Use hash_set instead of pointer_set.
>
> c/
>
> * c-decl.c: Use hash_set instead of pointer_set.
>
> cp/
>
> * class.c, cp-gimplify.c, cp-tree.h, decl.c, decl2.c, error.c,
> method.c, name-lookup.c, pt.c, semantics.c, tree.c: Use hash_set
> instead of pointer_set.
>
> fortran/
>
> * openmp.c, trans-decl.c: Use hash_set instead of pointer_set.
>
> gcc/
>
> * hash-set.h: new File.
> * cfgexpand.c, cfgloop.c, cgraph.c, cgraphbuild.c, cgraphunit.c,
> cprop.c, cse.c, gimple-walk.c, gimple-walk.h, gimplify.c, godump.c,
> ipa-devirt.c, ipa-pure-const.c, ipa-visibility.c, ipa.c, lto-cgraph.c,
> lto-streamer-out.c, stmt.c, tree-cfg.c, tree-core.h, tree-eh.c,
> tree-inline.c, tree-inline.h, tree-nested.c, tree-pretty-print.c,
> tree-ssa-loop-niter.c, tree-ssa-phiopt.c, tree-ssa-threadedge.c,
> tree-ssa-uninit.c, tree.c, tree.h, value-prof.c, varasm.c,
> varpool.c: Use hash_set instead of pointer_set.
>
> lto/
>
> * lto-partition.c, lto-partition.h: Use hash_set instead of
> pointer_set.
> diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
> index f42ac7f..6961838 100644
> --- a/gcc/ada/gcc-interface/trans.c
> +++ b/gcc/ada/gcc-interface/trans.c
> @@ -36,7 +36,7 @@
>  #include "output.h"
>  #include "libfuncs.h"  /* For set_stack_check_libfunc.  */
>  #include "tree-iterator.h"
> -#include "pointer-set.h"
> +#include "hash-set.h"
>  #include "gimple-expr.h"
>  #include "gimplify.h"
>  #include "bitmap.h"
> @@ -3054,7 +3054,7 @@ struct nrv_data
>bitmap nrv;
>tree result;
>Node_Id gnat_ret;
> -  struct pointer_set_t *visited;
> +  hash_set *visited;
>  };
>
>  /* Return true if T is a Named Return Value.  */
> @@ -3188,7 +3188,7 @@ finalize_nrv_r (tree *tp, int *walk_subtrees, void 
> *data)
>/* Avoid walking into the same tree more than once.  Unfortunately, we
>   can't just use walk_tree_without_duplicates because it would only
>   call us for the first occurrence of NRVs in the function body.  */
> -  if (pointer_set_insert (dp->visited, *tp))
> +  if (dp->visited->add (*tp))
>  *walk_subtrees = 0;
>
>return NULL_TREE;
> @@ -3328,7 +3328,7 @@ finalize_nrv_unc_r (tree *tp, int *walk_subtrees, void 
> *data)
>/* Avoid walking into the same tree more than once.  Unfortunately, we
>   can't just use walk_tree_without_duplicates because it would only
>   call us for the first occurrence of NRVs in the function body.  */
> -  if (pointer_set_insert (dp->visited, *tp))
> +  if (dp->visited->add (*tp))
>  *walk_subtrees = 0;
>
>return NULL_TREE;
> @@ -3376,13 +3376,13 @@ finalize_nrv (tree fndecl, bitmap nrv, vec va_gc> *other, Node_Id gnat_ret
>data.nrv = nrv;
>data.result = DECL_RESULT (fndecl);
>data.gnat_ret = gnat_ret;
> -  data.visited = pointer_set_create ();
> +  data.visited = new hash_set;
>if (TYPE_RETURN_UNCONSTRAINED_P (TREE_TYPE (fndecl)))
>  func = finalize_nrv_unc_r;
>else
>  func = finalize_nrv_r;
>walk_tree (&DECL_SAVED_TREE (fndecl), func, &data, NULL);
> -  pointer_set_destroy (data.visited);
> +  delete data.visited;
>  }
>
>  /* Return true if RET_VAL can be used as a Named Return Value for the
> diff --git a/gcc/c-family/c-gimplify.c b/gcc/c-family/c-gimplify.c
> index 2b5ce5b..4898217 100644
> --- a/gcc/c-family/c-gimplify.c
> +++ b/gcc/c-family/c-gimplify.c
> @@ -74,7 +74,7 @@ along with GCC; see the file COPYING3.  If not see
>  static tree
>  ubsan_walk_array_refs_r (tree *tp, int *walk_subtrees, void *data)
>  {
> -  struct pointer_set_t *pset = (struct pointer_set_t *) data;
> +  hash_set *pset = (hash_set *) data;
>
>/* Since walk_tree doesn't call the callback function on the decls
>   in BIND_EXPR_VARS, we have to walk them manually.  */
> @@ -116,10 +116,9 @@ c_genericize (tree fndecl)
>
>if (flag_sanitize & SANITIZE_BOUNDS)
>  {
> -  struct pointer_set_t *pset = pointer_set_create ();
> -  walk_tree (&DECL_SAVED_TREE (fndecl), ubsan_walk_array_refs_r, pset,
> -pset);
> -  pointer_set_destroy (pset);
> +  hash_set pset;
> +  walk_tree (&DECL_SAVED_TREE (fndecl), ubsan_walk_array_refs_r, &pset,
> +&pset);
>  }
>
>/* Dump the C-specific tree IR.  */
> diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c
> index 2a4b439..050ddff 100644
> --- a/gcc/c/c-decl.c
> +++ b/gcc/c/c-decl.c
> @@ -59,7 +59,7 @@ along with GCC; see the file COPYING3.  If not see
>  #include "cgraph.h"
>  #include "hash-table.h"
>  #incl

[Ada] New unit GNAT.Formatted_String providing C/C++ format string support

2014-07-30 Thread Arnaud Charlet
The following code:

  with Ada.Text_IO;   use Ada.Text_IO;
  with GNAT.Formatted_String; use GNAT.Formatted_String;

  procedure Fout is
 F  : Formatted_String := +"%c %% %#08x";
 Vc : Character := 'v';
 Vi : Integer := 12;
  begin
 F := F & Vc & Vi;
 Put_Line (-F);
  end Fout;

Should output:

   v % 0x0c

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

2014-07-30  Pascal Obry  

* g-forstr.adb, g-forstr.ads: New.
* gnat_rm.texi, impunit.adb Makefile.rtl: Add new unit
GNAT.Formatted_String.

Index: gnat_rm.texi
===
--- gnat_rm.texi(revision 213240)
+++ gnat_rm.texi(working copy)
@@ -594,6 +594,7 @@
 * GNAT.Expect (g-expect.ads)::
 * GNAT.Expect.TTY (g-exptty.ads)::
 * GNAT.Float_Control (g-flocon.ads)::
+* GNAT.Formatted_String (g-forstr.ads)::
 * GNAT.Heap_Sort (g-heasor.ads)::
 * GNAT.Heap_Sort_A (g-hesora.ads)::
 * GNAT.Heap_Sort_G (g-hesorg.ads)::
@@ -18934,6 +18935,7 @@
 * GNAT.Expect (g-expect.ads)::
 * GNAT.Expect.TTY (g-exptty.ads)::
 * GNAT.Float_Control (g-flocon.ads)::
+* GNAT.Formatted_String (g-forstr.ads)::
 * GNAT.Heap_Sort (g-heasor.ads)::
 * GNAT.Heap_Sort_A (g-hesora.ads)::
 * GNAT.Heap_Sort_G (g-hesorg.ads)::
@@ -19860,6 +19862,18 @@
 library calls may cause this mode to be modified, and the Reset procedure
 in this package can be used to reestablish the required mode.
 
+@node GNAT.Formatted_String (g-forstr.ads)
+@section @code{GNAT.Formatted_String} (@file{g-forstr.ads})
+@cindex @code{GNAT.Formatted_String} (@file{g-forstr.ads})
+@cindex Formatted String
+
+@noindent
+Provides support for C/C++ printf() formatted string. The format is
+copied from the printf() routine and should therefore gives identical
+output. Some generic routines are provided to be able to use types
+derived from Integer, Float or enumerations as values for the
+formatted string.
+
 @node GNAT.Heap_Sort (g-heasor.ads)
 @section @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
 @cindex @code{GNAT.Heap_Sort} (@file{g-heasor.ads})
Index: impunit.adb
===
--- impunit.adb (revision 213201)
+++ impunit.adb (working copy)
@@ -273,6 +273,7 @@
 ("g-expect", F),  -- GNAT.Expect
 ("g-exptty", F),  -- GNAT.Expect.TTY
 ("g-flocon", F),  -- GNAT.Float_Control
+("g-forstr", F),  -- GNAT.Formatted_String
 ("g-heasor", F),  -- GNAT.Heap_Sort
 ("g-hesora", F),  -- GNAT.Heap_Sort_A
 ("g-hesorg", F),  -- GNAT.Heap_Sort_G
Index: Makefile.rtl
===
--- Makefile.rtl(revision 213201)
+++ Makefile.rtl(working copy)
@@ -411,6 +411,7 @@
   g-expect$(objext) \
   g-exptty$(objext) \
   g-flocon$(objext) \
+  g-forstr$(objext) \
   g-heasor$(objext) \
   g-hesora$(objext) \
   g-hesorg$(objext) \
Index: g-forstr.adb
===
--- g-forstr.adb(revision 0)
+++ g-forstr.adb(revision 0)
@@ -0,0 +1,951 @@
+--
+--  --
+-- GNAT COMPILER COMPONENTS --
+--  --
+--G N A T . F O R M A T T E D _ S T R I N G --
+--  --
+-- B o d y  --
+--  --
+-- Copyright (C) 2014, 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- --
+-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
+-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
+-- or FITNESS FOR A PARTICULAR PURPOSE. --
+--  --
+-- As a special exception under Section 7 of GPL version 3, you are granted --
+-- additional permissions described in the GCC Runtime Library Exception,   --
+-- version 3.1, as published by the Free Software Foundation.   --
+--  --
+-- You should have received a copy of the GNU General Public License and--
+-- a copy of the GCC Runtime Library Exception along with this program; --
+-- see the files COPYING3 and COPYING.RUNTIME respectively.  If 

[Ada] Illegal external aspects not detected

2014-07-30 Thread Arnaud Charlet
This patch modifies the categorization of aspects Async_Readers, Async_Writers,
Effective_Reads and Effective_Writes to no longer require delayed actions. This
in turn ensures that the analysis of their aspect form correctly creates their
pragma counterparts.


-- Source --


--  illegal_externals.ads

package Illegal_Externals with SPARK_Mode => On is
   type I  is range 1 .. 10 with Async_Readers;
   type I2 is range 1 .. 10 with Async_Readers => True; 
   type I3 is range 1 .. 10 with Async_Readers => False; 
   type T1 is array (I) of Integer with Volatile; 
   type T2 is array (I) of Integer
 with Volatile,
  Async_Readers=> True, 
  Async_Writers=> False,
  Effective_Writes => False,
  Effective_Reads  => False;
   subtype S1 is Integer range 1 .. 10 with Async_Readers; 
   subtype S2 is Integer range 1 .. 10 with Async_Readers => True; 
   subtype S3 is Integer range 1 .. 10 with Async_Readers => False; 
   procedure P1 
 with Import,
  Convention => C;
   procedure P2
 with Import,
  Async_Readers, 
  Convention => C;
end Illegal_Externals;


-- Compilation and output --


$ gcc -c illegal_externals.ads
illegal_externals.ads:2:34: aspect "Async_Readers" must apply to a volatile
  object
illegal_externals.ads:3:34: aspect "Async_Readers" must apply to a volatile
  object
illegal_externals.ads:4:34: aspect "Async_Readers" must apply to a volatile
  object
illegal_externals.ads:8:11: aspect "Async_Readers" must apply to a volatile
  object
illegal_externals.ads:9:11: aspect "Async_Writers" must apply to a volatile
  object
illegal_externals.ads:10:11: aspect "Effective_Writes" must apply to a volatile
  object
illegal_externals.ads:11:11: aspect "Effective_Reads" must apply to a volatile
  object
illegal_externals.ads:12:45: aspect "Async_Readers" must apply to a volatile
  object
illegal_externals.ads:13:45: aspect "Async_Readers" must apply to a volatile
  object
illegal_externals.ads:14:45: aspect "Async_Readers" must apply to a volatile
  object
illegal_externals.ads:20:11: aspect "Async_Readers" must apply to a volatile
  object

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

2014-07-30  Hristian Kirtchev  

* aspects.ads Aspects Async_Readers, Async_Writers,
Effective_Reads and Effective_Writes do not need to be delayed.
* sem_ch13.adb (Analyze_Aspect_Specifications): Propagate the
optional Boolean expression when generating the corresponding
pragma for an external property aspect.
* sem_prag.adb (Analyze_External_Property_In_Decl_Part): Remove
local constant Obj. Add local constant Obj_Id. Reimplement the
check which ensures that the related variable is in fact volatile.
(Analyze_Pragma): Reimplement the analysis of external property pragmas.
* sem_util.adb (Is_Enabled): New routine.
(Variable_Has_Enabled_Property): Reimplement the detection of
an enabled external property.

Index: sem_prag.adb
===
--- sem_prag.adb(revision 213211)
+++ sem_prag.adb(working copy)
@@ -1834,29 +1834,28 @@
  (N: Node_Id;
   Expr_Val : out Boolean)
is
-  Arg1 : constant Node_Id := First (Pragma_Argument_Associations (N));
-  Obj  : constant Node_Id := Get_Pragma_Arg (Arg1);
-  Expr : constant Node_Id := Get_Pragma_Arg (Next (Arg1));
+  Arg1   : constant Node_Id   := First (Pragma_Argument_Associations (N));
+  Obj_Id : constant Entity_Id := Entity (Get_Pragma_Arg (Arg1));
+  Expr   : constant Node_Id   := Get_Pragma_Arg (Next (Arg1));
 
begin
   Error_Msg_Name_1 := Pragma_Name (N);
 
-  --  The Async / Effective pragmas must apply to a volatile object other
-  --  than a formal subprogram parameter (SPARK RM 7.1.3(2)).
+  --  An external property pragma must apply to a volatile object other
+  --  than a formal subprogram parameter (SPARK RM 7.1.3(2)). The check
+  --  is performed at the end of the declarative region due to a possible
+  --  out-of-order arrangement of pragmas:
+  --
+  --Obj : ...;
+  --pragma Async_Readers (Obj);
+  --pragma Volatile (Obj);
 
-  if Is_SPARK_Volatile_Object (Obj) then
- if Is_Entity_Name (Obj)
-   and then Present (Entity (Obj))
-   and then Is_Formal (Entity (Obj))
- then
-SPARK_Msg_N ("external property % cannot apply to parameter", N);
- end if;
-  else
+  if not Is_SPARK_Volatile (Obj_Id) then
  SPARK_Msg_N
("external property % must apply to a volatile object", N);
   end if;
 
-  --  Ensure that the expression (if present) is static Boolean. A missing
+  --  Ensure that the Boolean expression (if present) is static. A missing
   --  argument def

[Ada] Add query function to distinguish code of inlining from instances

2014-07-30 Thread Arnaud Charlet
In GNATprove, we need to distinguish code form inlined subprograms and code
from generic instances, based on their source locations, to have better
messages. This new query does precisely this.

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

2014-07-30  Yannick Moy  

* sinput.ads, sinput.adb (Comes_From_Inlined_Body): New function that
returns True for source pointer for an inlined body.

Index: sinput.adb
===
--- sinput.adb  (revision 213201)
+++ sinput.adb  (working copy)
@@ -302,6 +302,17 @@
   end case;
end Check_For_BOM;
 
+   -
+   -- Comes_From_Inlined_Body --
+   -
+
+   function Comes_From_Inlined_Body (S : Source_Ptr) return Boolean is
+  SIE : Source_File_Record renames
+Source_File.Table (Get_Source_File_Index (S));
+   begin
+  return SIE.Inlined_Body;
+   end Comes_From_Inlined_Body;
+
---
-- Get_Column_Number --
---
Index: sinput.ads
===
--- sinput.ads  (revision 213201)
+++ sinput.ads  (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- S p e c  --
 --  --
---  Copyright (C) 1992-2013, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2014, 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- --
@@ -638,6 +638,13 @@
--  value of the instantiation if this location is within an instance.
--  If S is not within an instance, then this returns No_Location.
 
+   function Comes_From_Inlined_Body (S : Source_Ptr) return Boolean;
+   pragma Inline (Comes_From_Inlined_Body);
+   --  Given a source pointer S, returns whether it comes from an inlined body.
+   --  This allows distinguishing these source pointers from those that come
+   --  from instantiation of generics, since Instantiation_Location returns a
+   --  valid location in both cases.
+
function Top_Level_Location (S : Source_Ptr) return Source_Ptr;
--  Given a source pointer S, returns the argument unchanged if it is
--  not in an instantiation. If S is in an instantiation, then it returns


[Ada] Front-end inlining in GNATprove mode

2014-07-30 Thread Arnaud Charlet
In GNATprove mode, all subprograms are candidates for front-end inlining, to
simplify proofs.  This patch extends this transformation to subprogam bodies
that do not have a previous subprogram declaration. In this case the compiler
builds a declaration, transfers aspects, if any, from body to declaration, and
attempts to create a body_to_inline, as if the Inline_Always pragma was present
on every such body.

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

2014-07-30  Ed Schonberg  

* sem_ch6.adb (Hanalyze_Subprogram_Body_Helper): In GNATprove
mode, subprogram bodies without a previous declaration are also
candidates for front-end inlining.

Index: sem_ch6.adb
===
--- sem_ch6.adb (revision 213240)
+++ sem_ch6.adb (working copy)
@@ -2952,6 +2952,42 @@
Spec_Id := Disambiguate_Spec;
 else
Spec_Id := Find_Corresponding_Spec (N);
+
+   --  In GNATprove mode, if the body has no previous spec, create
+   --  one so that the inlining machinery can operate properly.
+   --  Transfer aspects, if any, to the new spec, so that they
+   --  are legal and can be processed ahead of the body.
+   --  We make two copies of the given spec, one for the new
+   --  declaration, and one for the body.
+
+   --  This cannot be done for a compilation unit, which is not
+   --  in a context where we can insert a new spec.
+
+   if No (Spec_Id)
+ and then GNATprove_Mode
+ and then Debug_Flag_QQ
+ and then Full_Analysis
+ and then Comes_From_Source (Body_Id)
+ and then Is_List_Member (N)
+   then
+  declare
+ Body_Spec : constant Node_Id :=
+   Copy_Separate_Tree (Specification (N));
+ New_Decl : constant Node_Id :=
+   Make_Subprogram_Declaration
+(Loc, Copy_Separate_Tree (Specification (N)));
+
+  begin
+ Insert_Before (N, New_Decl);
+ Move_Aspects (From => N, To => New_Decl);
+ Analyze (New_Decl);
+ Spec_Id := Defining_Entity (New_Decl);
+
+ Set_Specification (N, Body_Spec);
+ Body_Id := Analyze_Subprogram_Specification (Body_Spec);
+ Set_Corresponding_Spec (N, Spec_Id);
+  end;
+   end if;
 end if;
 
 --  If this is a duplicate body, no point in analyzing it


[Ada] SPARK 2014 aspects should not be delayed

2014-07-30 Thread Arnaud Charlet
This patch changes the categorization of SPARK 2014 aspects from delayed to
non-delayed. These aspects are equivalent to source pragmas which appear after
their related constructs. To deal with forward references, the generatd pragmas
are stored in N_Contract nodes and later analyzed at the end of the declarative
region containing the related construct. No test needed, no change in behavior.

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

2014-07-30  Hristian Kirtchev  

* aspects.ads Add a comment explaining why SPARK 2014 aspects are
not delayed. Update the delay status of most SPARK 2014 aspects.
* sem_ch13.adb (Analyze_Aspect_Specifications): Update all calls
to Decorate_Aspect_And_Pragma and Insert_Delayed_Pragma to refert
to Decorate and Insert_Pragma. Add various comments concerning
the delay status of several SPARK 2014 aspects. The insertion
of Refined_State now uses routine Insert_After_SPARK_Mode.
(Decorate): New routine.
(Decorate_Aspect_And_Pragma): Removed.
(Insert_Delayed_Pragma): Removed.
(Insert_Pragma): New routine.

Index: aspects.ads
===
--- aspects.ads (revision 213242)
+++ aspects.ads (revision 213243)
@@ -543,6 +543,14 @@
--  information from the parent type, which must be frozen at that point
--  (since freezing the derived type first freezes the parent type).
 
+   --  SPARK 2014 aspects do not follow the general delay mechanism as they
+   --  act as annotations and cannot modify the attributes of their related
+   --  constructs. To handle forward references in such aspects, the compiler
+   --  delays the analysis of their respective pragmas by collecting them in
+   --  N_Contract nodes. The pragmas are then analyzed at the end of the
+   --  declarative region which contains the related construct. For details,
+   --  see routines Analyze_xxx_In_Decl_Part.
+
--  The following shows which aspects are delayed. There are three cases:
 
type Delay_Type is
@@ -593,12 +601,10 @@
   Aspect_Asynchronous => Always_Delay,
   Aspect_Attach_Handler   => Always_Delay,
   Aspect_Constant_Indexing=> Always_Delay,
-  Aspect_Contract_Cases   => Always_Delay,
   Aspect_CPU  => Always_Delay,
   Aspect_Default_Iterator => Always_Delay,
   Aspect_Default_Value=> Always_Delay,
   Aspect_Default_Component_Value  => Always_Delay,
-  Aspect_Depends  => Always_Delay,
   Aspect_Discard_Names=> Always_Delay,
   Aspect_Dispatching_Domain   => Always_Delay,
   Aspect_Dynamic_Predicate=> Always_Delay,
@@ -607,15 +613,12 @@
   Aspect_External_Tag => Always_Delay,
   Aspect_Export   => Always_Delay,
   Aspect_Favor_Top_Level  => Always_Delay,
-  Aspect_Global   => Always_Delay,
   Aspect_Implicit_Dereference => Always_Delay,
   Aspect_Import   => Always_Delay,
   Aspect_Independent  => Always_Delay,
   Aspect_Independent_Components   => Always_Delay,
   Aspect_Inline   => Always_Delay,
   Aspect_Inline_Always=> Always_Delay,
-  Aspect_Initial_Condition=> Always_Delay,
-  Aspect_Initializes  => Always_Delay,
   Aspect_Input=> Always_Delay,
   Aspect_Interrupt_Handler=> Always_Delay,
   Aspect_Interrupt_Priority   => Always_Delay,
@@ -639,9 +642,6 @@
   Aspect_Pure => Always_Delay,
   Aspect_Pure_Function=> Always_Delay,
   Aspect_Read => Always_Delay,
-  Aspect_Refined_Depends  => Always_Delay,
-  Aspect_Refined_Global   => Always_Delay,
-  Aspect_Refined_State=> Always_Delay,
   Aspect_Relative_Deadline=> Always_Delay,
   Aspect_Remote_Access_Type   => Always_Delay,
   Aspect_Remote_Call_Interface=> Always_Delay,
@@ -671,13 +671,21 @@
   Aspect_Annotate => Never_Delay,
   Aspect_Async_Readers=> Never_Delay,
   Aspect_Async_Writers=> Never_Delay,
+  Aspect_Contract_Cases   => Never_Delay,
   Aspect_Convention   => Never_Delay,
+  Aspect_Depends  => Never_Delay,
   Aspect_Dimension=> Never_Delay,
   Aspect_Dimension_System => Never_Delay,
   Aspect_Effective_Reads  => Never_Delay,
   Aspect_Effective_Writes => Never_Delay,
+  Aspect_Global   => Never_Delay,
+  Aspect_Init

Re: [PATCH] LTO streamer reorg - try to reduce WPA memory use

2014-07-30 Thread Richard Biener
On Wed, 30 Jul 2014, Richard Biener wrote:

> On Wed, Jul 30, 2014 at 7:51 AM, Markus Trippelsdorf
>  wrote:
> > On 2014.07.29 at 15:10 +0200, Richard Biener wrote:
> >> On Tue, 29 Jul 2014, Richard Biener wrote:
> >>
> >> >
> >> > This re-organizes the LTO streamer to do compression transparently
> >> > in the data-streamer routines (and disables section compression
> >> > by defaulting to -flto-compression-level=0).  This avoids
> >> > keeping the whole uncompressed sections in memory, only retaining
> >> > the compressed ones.
> >> >
> >> > The downside is that we lose compression of at least the string
> >> > parts (they are abusing the streaming interface quite awkwardly
> >> > and doing random-accesses with offsets into the uncompressed
> >> > section).  With a little bit of surgery we can get that back I
> >> > think (but we'd have to keep the uncompressed piece in memory
> >> > somewhere which means losing the memory use advantage).
> >> >
> >> > Very lightly tested sofar (running lto.exp).  I'll try a LTO
> >> > bootstrap now.
> >> >
> >> > I wonder what the change is on WPA memory use for larger
> >> > projects and what the effect on object file size is.
> >>
> >> Updated patch passing LTO bootstrap (one warning fix) and
> >> with a memory leak fixed.
> >
> > Testing with Firefox is impossible at the moment because of PR61885.
> > One thing I've noticed (before the ICE) is that virtual memory usage is
> > very high:
> >
> > AddressKbytes  RSSDirty  Mode  Mapping
> > 004016344 90840  r-x-- lto1
> > 013f6000   36   36   28  rw--- lto1
> > 013ff000 1072  276  276  rw---   [ anon ]
> > 034aa000 10154940  1540384  1540384  rw---   [ anon ]
> > 2acf04af2000  136  1360  r-x-- ld-2.19.90.so
> > 2acf04b14000   88   88   88  rw---   [ anon ]
> > ...
> >   ---  ---  ---
> > total kB 12022060  3388396  3377708
> 
> Maybe there is still a memleak (just checked that LTOing int main() {}
> doesn't leak).

Found it:

Index: gcc/lto-section-in.c
===
--- gcc/lto-section-in.c.orig   2014-07-30 12:40:27.950225826 +0200
+++ gcc/lto-section-in.c2014-07-30 12:37:44.179237102 +0200
@@ -249,7 +249,7 @@ lto_destroy_simple_input_block (struct l
struct lto_input_block *ib,
const char *data, size_t len)
 {
-  free (ib);
+  delete ib;
   lto_free_section_data (file_data, section_type, NULL, data, len);
 }
 
Richard.


[Ada] Implement compilation date and time output and functions

2014-07-30 Thread Arnaud Charlet
This patch causes the compiler to print the compilation time in
-gnatv or -gnatl mode (suppressible with debug flag -gnatd7).

It also provides new functions in GNAT.Source_Info to obtain
the compilation date and time (in a form compatible with the
use of the C macros __DATE__ and __TIME__.

Finally a new function System.OS_Lib.Current_Time_String is
introduced (and used by the compiler to implement the above).

The following test is compiled with -gnatl:

Compiling: ctime.adb
Source file time stamp: 2014-04-04 14:00:32
Compiled at: 2014-04-04 10:03:24

 1. with Text_IO; use Text_IO;
 2. with GNAT.Source_Info; use GNAT.Source_Info;
 3. procedure Ctime is
 4. begin
 5.Put_Line (Compilation_Date);
 6.Put_Line (Compilation_Time);
 7. end;

When run, the output is:

Jul 30 2014
10:03:24

Note: by its very nature, the above test is not suitable as a standard
regression test since of course its output changes each time it is run.

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

2014-07-30  Robert Dewar  

* debug.adb: Document that d7 suppresses compilation time output.
* errout.adb (Write_Header): Include compilation time in
header output.
* exp_intr.adb (Expand_Intrinsic_Call): Add
Compilation_Date/Compilation_Time (Expand_Source_Info): Expand
Compilation_Date/Compilation_Time.
* g-souinf.ads (Compilation_Date): New function
(Compilation_Time): New function.
* gnat1drv.adb (Gnat1drv): Set Opt.Compilation_Time.
* gnat_rm.texi (Compilation_Date): New function
(Compilation_Time): New function.
* opt.ads (Compilation_Time): New variable.
* s-os_lib.ads, s-os_lib.adb (Current_Time_String): New function.
* sem_intr.adb (Compilation_Date): New function.
(Compilation_Time): New function.
* snames.ads-tmpl (Name_Compilation_Date): New entry.
(Name_Compilation_Time): New entry.

Index: gnat_rm.texi
===
--- gnat_rm.texi(revision 213242)
+++ gnat_rm.texi(working copy)
@@ -14637,6 +14637,8 @@
 
 @menu
 * Intrinsic Operators::
+* Compilation_Date::
+* Compilation_Time::
 * Enclosing_Entity::
 * Exception_Information::
 * Exception_Message::
@@ -14694,12 +14696,34 @@
 It is also possible to specify such operators for private types, if the
 full views are appropriate arithmetic types.
 
+@node Compilation_Date
+@section Compilation_Date
+@cindex Compilation_Date
+@noindent
+This intrinsic subprogram is used in the implementation of the
+library package @code{GNAT.Source_Info}.  The only useful use of the
+intrinsic import in this case is the one in this unit, so an
+application program should simply call the function
+@code{GNAT.Source_Info.Compilation_Date} to obtain the date of
+the current compilation (in local time format MMM DD ).
+
+@node Compilation_Time
+@section Compilation_Time
+@cindex Compilation_Time
+@noindent
+This intrinsic subprogram is used in the implementation of the
+library package @code{GNAT.Source_Info}.  The only useful use of the
+intrinsic import in this case is the one in this unit, so an
+application program should simply call the function
+@code{GNAT.Source_Info.Compilation_Time} to obtain the time of
+the current compilation (in local time format HH:MM:SS).
+
 @node Enclosing_Entity
 @section Enclosing_Entity
 @cindex Enclosing_Entity
 @noindent
 This intrinsic subprogram is used in the implementation of the
-library routine @code{GNAT.Source_Info}.  The only useful use of the
+library package @code{GNAT.Source_Info}.  The only useful use of the
 intrinsic import in this case is the one in this unit, so an
 application program should simply call the function
 @code{GNAT.Source_Info.Enclosing_Entity} to obtain the name of
@@ -14710,7 +14734,7 @@
 @cindex Exception_Information'
 @noindent
 This intrinsic subprogram is used in the implementation of the
-library routine @code{GNAT.Current_Exception}.  The only useful
+library package @code{GNAT.Current_Exception}.  The only useful
 use of the intrinsic import in this case is the one in this unit,
 so an application program should simply call the function
 @code{GNAT.Current_Exception.Exception_Information} to obtain
@@ -14721,7 +14745,7 @@
 @cindex Exception_Message
 @noindent
 This intrinsic subprogram is used in the implementation of the
-library routine @code{GNAT.Current_Exception}.  The only useful
+library package @code{GNAT.Current_Exception}.  The only useful
 use of the intrinsic import in this case is the one in this unit,
 so an application program should simply call the function
 @code{GNAT.Current_Exception.Exception_Message} to obtain
@@ -14732,7 +14756,7 @@
 @cindex Exception_Name
 @noindent
 This intrinsic subprogram is used in the implementation of the
-library routine @code{GNAT.Current_Exception}.  The only useful
+library package @code{GNAT.Current_Exception}.  The only usefu

Re: [AArch64_be] Fix vec_select hi/lo mask confusions.

2014-07-30 Thread James Greenhalgh
On Wed, Jul 30, 2014 at 11:21:40AM +0100, Richard Biener wrote:
> On Wed, Jul 30, 2014 at 12:10 PM, James Greenhalgh
>  wrote:
> >
> > Hi,
> >
> > A vec_select mask exists in GCC's world-view of lane ordering. The
> > "low-half" of the vector { a, b, c, d } is { a, b }, which on big-endian
> > will be in the high bits of the architectural register. On little-endian,
> > these lanes will be in the low bits of the architectural register.
> > We therefore need different masks depending on our target endian-ness.
> > The diagram below may help.
> >
> > We must draw the distinction when building masks which select one half of 
> > the
> > vector.  An instruction selecting architectural low-lanes for a big-endian
> > target, must be described using a mask selecting GCC high-lanes.
> >
> >  Big-Endian Little-Endian
> >
> > GCC 0   1   2   3   3   2   1   0
> >   | x | x | x | x |   | x | x | x | x |
> > Architecture3   2   1   0   3   2   1   0
> >
> > Low Mask: { 2, 3 }{ 0, 1 }
> > High Mask:{ 0, 1 }{ 2, 3 }
> >
> > The way we implement this requires some "there is no spoon" thinking to 
> > avoid
> > pattern duplication. We define a vec_par_cnst_lo_half mask to always
> > refer to the low architectural lanes. I gave some thought to renaming this
> > vec_par_cnst_arch_lo_half, but it didn't add much meaning. I'm happy to
> > take bike-shedding towards a more self-documenting naming scheme.
> >
> > No regressions spotted on aarch64_be-none-elf or aarch64-none-elf.
> >
> > OK for trunk?
> 
> Please make sure the above is still correct if you rip out all
> if (BYTES_BIG_ENDIAN) cases from tree-vect*.c.

It will be, yes.

The RTL and Tree/Gimple level representations will have a consistent view
that still won't match up with the way the architecture thinks of lanes and
elements. On our big-endian systems, the lowest address in memory gets loaded
to the highest numbered lane in register. GCC thinks of the lowest address
in memory as the lowest element in its vectors, which makes sense, but causes
a mismatch. So when GCC wants bits 0-32 of a V4SI vector extracted it really
means it wants what would be array element 0, so we need to map that to
extract bits 94-127 from the register.

This is all just back-end magic to keep the mid-end endianness agnostic.

There will, of course, be some patterns we'll have to clean up after we fix
tree-vect*.c, but this fundamental mismatch of lane numbering won't change.
We'll just have the same pain as the other big-endian backends adjusting
patterns as needed.

Cheers,
James

> 
> Richard.
> 
> > Thanks,
> > James
> >
> > ---
> > gcc/
> >
> > 2014-07-30  James Greenhalgh  
> >
> > * config/aarch64/aarch64.c (aarch64_simd_vect_par_cnst_half): Vary
> > the generated mask based on BYTES_BIG_ENDIAN.
> > (aarch64_simd_check_vect_par_cnst_half): New.
> > * config/aarch64/aarch64-protos.h
> > (aarch64_simd_check_vect_par_cnst_half): New.
> > * config/aarch64/predicates.md (vect_par_cnst_hi_half): Refactor
> > the check out to aarch64_simd_check_vect_par_cnst_half.
> > (vect_par_cnst_lo_half): Likewise.
> > * config/aarch64/aarch64-simd.md
> > (aarch64_simd_move_hi_quad_): Always use vec_par_cnst_lo_half.
> > (move_hi_quad_): Always generate a low mask.
> 



[Ada] Forbid the use of <> in attribute 'Update

2014-07-30 Thread Arnaud Charlet
This patch implements the following SPARK 2014 rule:

   4.4.1 (1) - The box symbol, <>, may not appear in any expression appearing
   in an update expression.

The patch also cleans up the analysis of attribute 'Update.


-- Source --


--  box_update.ads

package Box_Update with SPARK_Mode => On is
   type I  is range 1 .. 5;
   type T1 is range 1 .. 10
 with Default_Value => 5;

   type A1 is array (I) of T1;

   procedure Init1 (X : out A1);
end Box_Update;

--  box_update.adb

package body Box_Update with SPARK_Mode => On is
   procedure Init1 (X : out A1) is
  T : constant A1 := A1'(1 => 6, others => <>);
   begin
  X := T'Update(1 => <>);
   end Init1;
end Box_Update;


-- Compilation and output --


$ gcc -c box_update.adb
box_update.adb:5:23: default initialization not allowed in attribute "Update"

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

2014-07-30  Hristian Kirtchev  

* sem_attr.adb (Analyze_Array_Component_Update): New routine.
(Analyze_Attribute): Major cleanup of attribute
'Update. The logic is now split into two distinct routines
depending on the type of the prefix. The use of <> is now illegal
in attribute 'Update.
(Analyze_Record_Component_Update): New routine.
(Check_Component_Reference): Removed.
(Resolve_Attribute): Remove the return statement and ??? comment
following the processing for attribute 'Update. As a result,
the attribute now freezes its prefix.

Index: sem_attr.adb
===
--- sem_attr.adb(revision 213212)
+++ sem_attr.adb(working copy)
@@ -6220,69 +6220,158 @@
   
 
   when Attribute_Update => Update : declare
+ Common_Typ : Entity_Id;
+ --  The common type of a multiple component update for a record
+
  Comps : Elist_Id := No_Elist;
- Expr  : Node_Id;
+ --  A list used in the resolution of a record update. It contains the
+ --  entities of all record components processed so far.
 
- procedure Check_Component_Reference
-   (Comp : Entity_Id;
-Typ  : Entity_Id);
- --  Comp is a record component (possibly a discriminant) and Typ is a
- --  record type. Determine whether Comp is a legal component of Typ.
- --  Emit an error if Comp mentions a discriminant or is not a unique
- --  component reference in the update aggregate.
+ procedure Analyze_Array_Component_Update (Assoc : Node_Id);
+ --  Analyze and resolve array_component_association Assoc against the
+ --  index of array type P_Type.
 
- ---
- -- Check_Component_Reference --
- ---
+ procedure Analyze_Record_Component_Update (Comp : Node_Id);
+ --  Analyze and resolve record_component_association Comp against
+ --  record type P_Type.
 
- procedure Check_Component_Reference
-   (Comp : Entity_Id;
-Typ  : Entity_Id)
- is
-Comp_Name : constant Name_Id := Chars (Comp);
+ 
+ -- Analyze_Array_Component_Update --
+ 
 
-function Is_Duplicate_Component return Boolean;
---  Determine whether component Comp already appears in list Comps
+ procedure Analyze_Array_Component_Update (Assoc : Node_Id) is
+Expr  : Node_Id;
+High  : Node_Id;
+Index : Node_Id;
+Index_Typ : Entity_Id;
+Low   : Node_Id;
 
-
--- Is_Duplicate_Component --
-
+ begin
+--  The current association contains a sequence of indexes denoting
+--  an element of a multidimensional array:
 
-function Is_Duplicate_Component return Boolean is
-   Comp_Elmt : Elmt_Id;
+--(Index_1, ..., Index_N)
 
-begin
-   if Present (Comps) then
-  Comp_Elmt := First_Elmt (Comps);
-  while Present (Comp_Elmt) loop
- if Chars (Node (Comp_Elmt)) = Comp_Name then
-return True;
+--  Examine each individual index and resolve it against the proper
+--  index type of the array.
+
+if Nkind (First (Choices (Assoc))) = N_Aggregate then
+   Expr := First (Choices (Assoc));
+   while Present (Expr) loop
+
+  --  The use of others is illegal (SPARK RM 4.4.1(12))
+
+  if Nkind (Expr) = N_Others_Choice then
+ Error_Attr
+   ("others choice not allowed in attribut

RE: [PATCH] PR61868

2014-07-30 Thread Bingfeng Mei
It did take a lot of time, but passed the LTO bootstrap.

Bingfeng

> -Original Message-
> From: Richard Biener [mailto:richard.guent...@gmail.com]
> Sent: 30 July 2014 10:43
> To: Bingfeng Mei
> Cc: Andi Kleen; gcc-patches@gcc.gnu.org
> Subject: Re: [PATCH] PR61868
> 
> On Wed, Jul 30, 2014 at 10:52 AM, Bingfeng Mei  wrote:
> > Yes, opts-global.c fills flag_random_seed with string passed in
> command line. But init_random_seed in toplev.c is the one that processes
> the flag and set random_seed variable, which is returned by
> get_random_seed function.
> 
> Err, I meant opts-global.c:handle_common_deferred_options
> 
> > By default, my configuration enables LTO. How to test LTO bootstrap?
> 
> configure with --with-build-config=bootstrap-lto (and reduce the
> set of languages to c,c++ to get a sane bootstrap time).
> 
> Richard.
> 
> > Bingfeng
> >
> >> -Original Message-
> >> From: Richard Biener [mailto:richard.guent...@gmail.com]
> >> Sent: 30 July 2014 08:47
> >> To: Bingfeng Mei; Andi Kleen
> >> Cc: gcc-patches@gcc.gnu.org
> >> Subject: Re: [PATCH] PR61868
> >>
> >> On Tue, Jul 29, 2014 at 3:01 PM, Bingfeng Mei 
> wrote:
> >> > Hi,
> >> > Please find the patches for pr61868. The problem is that even with
> -
> >> frandom-seed gcc always uses 0 instead of specified number/string for
> >> places such as lto section names. init_random_seed is never called
> with
> >> -frandom-seed. Bootstrapped and tested on x86-64. OK for trunk?
> >>
> >> Hmm, but -frandom-seed= is honored by opts.c calling set_random_seed?
> >>
> >> Andi, wasn't this used to support partial linking of LTO objects?
> Thus,
> >> this shortcut was on purpose?  Otherwise passing -frandom-seed to
> >> LTO would break that?
> >>
> >> Bingfeng, did you test if LTO bootstrap still works after this patch?
> >>
> >> Thanks,
> >> Richard.
> >>
> >> > Thanks,
> >> > Bingfeng Mei
> >> >
> >> >
> >> > ===
> >> > --- ChangeLog   (revision 213152)
> >> > +++ ChangeLog   (working copy)
> >> > @@ -1,3 +1,9 @@
> >> > +2014-07-29  Bingfeng Mei 
> >> > +
> >> > +   PR lto/61868
> >> > +   * toplev.c (init_random_seed): Generate random seed when
> >> > +   flag_random_seed is specified.
> >> > +
> >> >  2014-07-28  Jan Hubicka  
> >> >
> >> > * cgraph.c (cgraph_node::create_indirect_edge): Copy
> >> speculative data.
> >> > Index: toplev.c
> >> > ===
> >> > --- toplev.c(revision 213152)
> >> > +++ toplev.c(working copy)
> >> > @@ -301,7 +301,7 @@ init_random_seed (void)
> >> >  HOST_WIDE_INT
> >> >  get_random_seed (bool noinit)
> >> >  {
> >> > -  if (!flag_random_seed && !noinit)
> >> > +  if (!noinit)
> >> >  init_random_seed ();
> >> >return random_seed;
> >> >  }
> >> > Index: testsuite/ChangeLog
> >> > ===
> >> > --- testsuite/ChangeLog (revision 213152)
> >> > +++ testsuite/ChangeLog (working copy)
> >> > @@ -1,3 +1,8 @@
> >> > +2014-07-29  Bingfeng Mei  
> >> > +
> >> > +   PR lto/61868
> >> > +   * gcc.dg/pr61868.c: New test.
> >> > +
> >> >  2014-07-28  Richard Biener  
> >> >
> >> > PR rtl-optimization/61801
> >> > Index: testsuite/gcc.dg/pr61868.c
> >> > ===
> >> > --- testsuite/gcc.dg/pr61868.c  (revision 0)
> >> > +++ testsuite/gcc.dg/pr61868.c  (revision 0)
> >> > @@ -0,0 +1,9 @@
> >> > +/* { dg-do compile } */
> >> > +/* { dg-options "-flto -frandom-seed=0x12345" }  */
> >> > +extern int foo (int);
> >> > +int main ()
> >> > +{
> >> > +  foo (100);
> >> > +  return 0;
> >> > +}
> >> > +/* { dg-final { scan-assembler "\.gnu\.lto.*.12345" } } */
> >> >


Re: [PATCH, ARM] Fix PR61948 (ICE with DImode shift by 1 bit)

2014-07-30 Thread Richard Earnshaw
On 29/07/14 20:53, Charles Baylis wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61948
> 
> The lshrdi3_neon,ashrdi3_neon,ashldi3_neon patterns can call
> gen_arm_di3_1bit without checking that the register allocation
> constraints of the resulting insn are satisfied. This results in an
> ICE:
> 
> $ arm-unknown-linux-gnueabihf-gcc -O2 -mfpu=neon -mthumb -c t.c
> t.c: In function ‘f’:
> t.c:8:1: error: insn does not satisfy its constraints:
>  }
>  ^
> (insn 18 7 14 2 (parallel [
> (set (reg/i:DI 0 r0)
> (ashiftrt:DI (reg/v:DI 1 r1 [orig:110 t ] [110])
> (const_int 1 [0x1])))
> (clobber (reg:CC 100 cc))
> ]) t.c:8 131 {arm_ashrdi3_1bit}
>  (expr_list:REG_DEAD (reg:SI 2 r2)
> (expr_list:REG_UNUSED (reg:CC 100 cc)
> (nil
> t.c:8:1: internal compiler error: in copyprop_hardreg_forward_1, at
> regcprop.c:775
> 
> Here, the destination registers are [r0,r1], partially overlapping
> with the source registers are [r1,r2].
> 
> The arm_ashrdi3_1bit pattern has constraints:
>   [(set (match_operand:DI  0 "s_register_operand" "=r,&r")
> (ashiftrt:DI (match_operand:DI 1 "s_register_operand" "0,r")
> 
> This permits the input and output registers to overlap fully, or to
> have no overlap.
> 
> The invalid insn with partial overlap is caused when ashrdi3_neon is split:
> if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) == 1)
>   /* This clobbers CC.  */
>   emit_insn (gen_arm_ashldi3_1bit (operands[0], operands[1]));
> else ...
> 
> The proposed fix is to add an additional check for the partial overlap
> of the input and output operands, and to fall back to the general
> shift by constant pattern if they do overlap.
> 
> It would also be possible to relax the constraints on the
> arm_di3_1bit patterns and allow them to emit an extra move
> where needed to support overlapped input/output registers. This would
> give slightly better code in the overlapped case here, but would be
> more complex to validate to ensure that it didn't regress code size in
> non-Neon builds (as the relaxed constraints would enable a longer code
> sequence to be used), and would be more complex to validate for
> correctness as it would need to be tested both for both little/big
> endian.
> 
> Tested using qemu with make check for arm-unknown-linux-gnueabihf
> --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=vfpv3-d16
> --with-float=hard --with-mode=thumb. No regressions
> 
> 
> gcc/ChangeLog:
> 2014-07-29  Charles Baylis  
> 
> PR target/61948
> * config/arm/neon.md (ashldi3_neon): Don't emit arm_ashldi3_1bit unless
> constraints are satisfied.
> (di3_neon): Likewise.
> 

This is OK, but...
> 
> gcc/testsuite/ChangeLog:
> 2014-07-29  Charles Baylis  
> 
> PR target/61948
> * gcc.target/arm/pr61948.c: New test case.
> 

I think this should be using something like:


/* { dg-do compile } */
/* { dg-require-effective-target arm_neon_ok } */
/* { dg-require-effective-target arm_thumb2_ok } */
/* { dg-options "-O2 -mthumb" } */
/* { dg-add-options arm_neon } */

rather than explicitly adding -mfpu=neon.

R.



Re: [PATCH] LTO streamer reorg - try to reduce WPA memory use

2014-07-30 Thread Martin Liška


On 07/30/2014 11:41 AM, Richard Biener wrote:

On Wed, 30 Jul 2014, Richard Biener wrote:


On Wed, Jul 30, 2014 at 7:51 AM, Markus Trippelsdorf
 wrote:

On 2014.07.29 at 15:10 +0200, Richard Biener wrote:

On Tue, 29 Jul 2014, Richard Biener wrote:


This re-organizes the LTO streamer to do compression transparently
in the data-streamer routines (and disables section compression
by defaulting to -flto-compression-level=0).  This avoids
keeping the whole uncompressed sections in memory, only retaining
the compressed ones.

The downside is that we lose compression of at least the string
parts (they are abusing the streaming interface quite awkwardly
and doing random-accesses with offsets into the uncompressed
section).  With a little bit of surgery we can get that back I
think (but we'd have to keep the uncompressed piece in memory
somewhere which means losing the memory use advantage).

Very lightly tested sofar (running lto.exp).  I'll try a LTO
bootstrap now.

I wonder what the change is on WPA memory use for larger
projects and what the effect on object file size is.

Updated patch passing LTO bootstrap (one warning fix) and
with a memory leak fixed.

Testing with Firefox is impossible at the moment because of PR61885.
One thing I've noticed (before the ICE) is that virtual memory usage is
very high:

AddressKbytes  RSSDirty  Mode  Mapping
004016344 90840  r-x-- lto1
013f6000   36   36   28  rw--- lto1
013ff000 1072  276  276  rw---   [ anon ]
034aa000 10154940  1540384  1540384  rw---   [ anon ]
2acf04af2000  136  1360  r-x-- ld-2.19.90.so
2acf04b14000   88   88   88  rw---   [ anon ]
...
  ---  ---  ---
total kB 12022060  3388396  3377708

Maybe there is still a memleak (just checked that LTOing int main() {}
doesn't leak).

Found it:

Index: gcc/lto-section-in.c
===
--- gcc/lto-section-in.c.orig   2014-07-30 12:40:27.950225826 +0200
+++ gcc/lto-section-in.c2014-07-30 12:37:44.179237102 +0200
@@ -249,7 +249,7 @@ lto_destroy_simple_input_block (struct l
 struct lto_input_block *ib,
 const char *data, size_t len)
  {
-  free (ib);
+  delete ib;
lto_free_section_data (file_data, section_type, NULL, data, len);
  }
  
Richard.

Hello,
   there's memory/CPU usage for the patch. for both, I used sync and 
drop_caches.

Url: 
https://drive.google.com/file/d/0B0pisUJ80pO1andOX19JMHV3LVE/edit?usp=sharing

Martin



[PATCH, DOC]: New value 'default' for --enable-languages

2014-07-30 Thread Martin Liška

Hello,
   as discussed in previous thread 
(https://gcc.gnu.org/ml/gcc-patches/2014-07/msg02010.html), I would like to add 
more intuitive behavior for --enable-languages configure option.

Thank you,
Martin
2014-07-30  Martin Liska  

* configure: New value for configure option
--enable-languages added (default).
* configure.ac: Likewise.
* doc/install.texi (enable-languages): New value usage explained.
diff --git a/configure b/configure
index c8b20b6..c50b5c6 100755
--- a/configure
+++ b/configure
@@ -6209,7 +6209,7 @@ if test -d ${srcdir}/gcc; then
   enable_languages="${LANGUAGES}"
 echo configure.in: warning: setting LANGUAGES is deprecated, use --enable-languages instead 1>&2
 else
-  enable_languages=all
+  enable_languages=default
 fi
   else
 if test x"${enable_languages}" = x ||
@@ -6261,6 +6261,7 @@ if test -d ${srcdir}/gcc; then
 for other in ${lang_requires} ${lang_requires_boot_languages}; do
   case ,${enable_languages}, in
 	*,$other,*) ;;
+	*,default,*) ;;
 	*,all,*) ;;
 	*,$language,*)
 	  echo " \`$other' language required by \`$language'; enabling" 1>&2
@@ -6272,6 +6273,7 @@ if test -d ${srcdir}/gcc; then
 	  if test "$other" != "c"; then
 	case ,${enable_stage1_languages}, in
 	  *,$other,*) ;;
+	  *,default,*) ;;
 	  *,all,*) ;;
 	  *)
 		case ,${enable_languages}, in
@@ -6304,7 +6306,7 @@ if test -d ${srcdir}/gcc; then
   fi
 
 
-  missing_languages=`echo ",$enable_languages," | sed -e s/,all,/,/ -e s/,c,/,/ `
+  missing_languages=`echo ",$enable_languages," | sed -e s/,all,/,/ -e s/,default,/,/ -e s/,c,/,/ `
   potential_languages=,c,
 
   enabled_target_libs=
@@ -6344,12 +6346,18 @@ if test -d ${srcdir}/gcc; then
 	  add_this_lang=yes
 	fi
 ;;
-  *,all,*)
-# 'all' was selected, select it if it is a default language
+  *,default,*)
+# 'default' was selected, select it if it is a default language
 	if test "$language" != "c"; then
 	  add_this_lang=${build_by_default}
 	fi
 ;;
+  *,all,*)
+# 'all' was selected, add the language
+	if test "$language" != "c"; then
+	  add_this_lang=yes
+	fi
+;;
 esac
 
 # Disable languages that need other directories if these aren't available.
diff --git a/configure.ac b/configure.ac
index 163de5f..29281dd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1756,7 +1756,7 @@ if test -d ${srcdir}/gcc; then
   enable_languages="${LANGUAGES}"
 echo configure.in: warning: setting LANGUAGES is deprecated, use --enable-languages instead 1>&2
 else
-  enable_languages=all
+  enable_languages=default
 fi
   else
 if test x"${enable_languages}" = x ||
@@ -1808,6 +1808,7 @@ if test -d ${srcdir}/gcc; then
 for other in ${lang_requires} ${lang_requires_boot_languages}; do
   case ,${enable_languages}, in
 	*,$other,*) ;;
+	*,default,*) ;;
 	*,all,*) ;;
 	*,$language,*)
 	  echo " \`$other' language required by \`$language'; enabling" 1>&2
@@ -1819,6 +1820,7 @@ if test -d ${srcdir}/gcc; then
 	  if test "$other" != "c"; then
 	case ,${enable_stage1_languages}, in
 	  *,$other,*) ;;
+	  *,default,*) ;;
 	  *,all,*) ;;
 	  *)
 		case ,${enable_languages}, in
@@ -1851,7 +1853,7 @@ if test -d ${srcdir}/gcc; then
   fi
   AC_SUBST(extra_host_libiberty_configure_flags)
 
-  missing_languages=`echo ",$enable_languages," | sed -e s/,all,/,/ -e s/,c,/,/ `
+  missing_languages=`echo ",$enable_languages," | sed -e s/,all,/,/ -e s/,default,/,/ -e s/,c,/,/ `
   potential_languages=,c,
 
   enabled_target_libs=
@@ -1891,12 +1893,18 @@ if test -d ${srcdir}/gcc; then
 	  add_this_lang=yes
 	fi
 ;;
-  *,all,*)
-# 'all' was selected, select it if it is a default language
+  *,default,*)
+# 'default' was selected, select it if it is a default language
 	if test "$language" != "c"; then
 	  add_this_lang=${build_by_default}
 	fi
 ;;
+  *,all,*)
+# 'all' was selected, add the language
+	if test "$language" != "c"; then
+	  add_this_lang=yes
+	fi
+;;
 esac
 
 # Disable languages that need other directories if these aren't available.
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index 31b8c8b..c9c6dea 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -1423,12 +1423,13 @@ their runtime libraries should be built.  For a list of valid values for
 grep language= */config-lang.in
 @end smallexample
 Currently, you can use any of the following:
-@code{all}, @code{ada}, @code{c}, @code{c++}, @code{fortran},
+@code{default}, @code{all}, @code{ada}, @code{c}, @code{c++}, @code{fortran},
 @code{go}, @code{java}, @code{objc}, @code{obj-c++}.
 Building the Ada compiler has special requireme

Re: [PATCH] LTO streamer reorg - try to reduce WPA memory use

2014-07-30 Thread Richard Biener
On Wed, Jul 30, 2014 at 1:14 PM, Martin Liška  wrote:
>
> On 07/30/2014 11:41 AM, Richard Biener wrote:
>>
>> On Wed, 30 Jul 2014, Richard Biener wrote:
>>
>>> On Wed, Jul 30, 2014 at 7:51 AM, Markus Trippelsdorf
>>>  wrote:

 On 2014.07.29 at 15:10 +0200, Richard Biener wrote:
>
> On Tue, 29 Jul 2014, Richard Biener wrote:
>
>> This re-organizes the LTO streamer to do compression transparently
>> in the data-streamer routines (and disables section compression
>> by defaulting to -flto-compression-level=0).  This avoids
>> keeping the whole uncompressed sections in memory, only retaining
>> the compressed ones.
>>
>> The downside is that we lose compression of at least the string
>> parts (they are abusing the streaming interface quite awkwardly
>> and doing random-accesses with offsets into the uncompressed
>> section).  With a little bit of surgery we can get that back I
>> think (but we'd have to keep the uncompressed piece in memory
>> somewhere which means losing the memory use advantage).
>>
>> Very lightly tested sofar (running lto.exp).  I'll try a LTO
>> bootstrap now.
>>
>> I wonder what the change is on WPA memory use for larger
>> projects and what the effect on object file size is.
>
> Updated patch passing LTO bootstrap (one warning fix) and
> with a memory leak fixed.

 Testing with Firefox is impossible at the moment because of PR61885.
 One thing I've noticed (before the ICE) is that virtual memory usage is
 very high:

 AddressKbytes  RSSDirty  Mode  Mapping
 004016344 90840  r-x-- lto1
 013f6000   36   36   28  rw--- lto1
 013ff000 1072  276  276  rw---   [ anon ]
 034aa000 10154940  1540384  1540384  rw---   [ anon ]
 2acf04af2000  136  1360  r-x-- ld-2.19.90.so
 2acf04b14000   88   88   88  rw---   [ anon ]
 ...
   ---  ---  ---
 total kB 12022060  3388396  3377708
>>>
>>> Maybe there is still a memleak (just checked that LTOing int main() {}
>>> doesn't leak).
>>
>> Found it:
>>
>> Index: gcc/lto-section-in.c
>> ===
>> --- gcc/lto-section-in.c.orig   2014-07-30 12:40:27.950225826 +0200
>> +++ gcc/lto-section-in.c2014-07-30 12:37:44.179237102 +0200
>> @@ -249,7 +249,7 @@ lto_destroy_simple_input_block (struct l
>>  struct lto_input_block *ib,
>>  const char *data, size_t len)
>>   {
>> -  free (ib);
>> +  delete ib;
>> lto_free_section_data (file_data, section_type, NULL, data, len);
>>   }
>>   Richard.
>
> Hello,
>there's memory/CPU usage for the patch. for both, I used sync and
> drop_caches.
>
> Url:
> https://drive.google.com/file/d/0B0pisUJ80pO1andOX19JMHV3LVE/edit?usp=sharing

Ok, it turns out setting -flto-compression-level to 0 doesn't really
short-circuit zlib for sections.  So the following does that the hard
but effective way.

Index: gcc/lto-section-out.c
===
--- gcc/lto-section-out.c.orig  2014-07-30 13:33:06.634008355 +0200
+++ gcc/lto-section-out.c   2014-07-30 13:29:19.468023995 +0200
@@ -80,7 +80,7 @@ lto_begin_section (const char *name, boo
  data is anything other than assembler output.  The effect here is that
  we get compression of IL only in non-ltrans object files.  */
   gcc_assert (compression_stream == NULL);
-  if (compress)
+  if (compress && 0)
 compression_stream = lto_start_compression (lto_append_data, NULL);
 }

Index: gcc/lto-section-in.c
===
--- gcc/lto-section-in.c.orig   2014-07-30 13:33:06.637008355 +0200
+++ gcc/lto-section-in.c2014-07-30 13:31:57.329013126 +0200
@@ -153,7 +153,7 @@ lto_get_section_data (struct lto_file_de

   /* FIXME lto: WPA mode does not write compressed sections, so for now
  suppress uncompression if flag_ltrans.  */
-  if (!flag_ltrans)
+  if (!flag_ltrans && 0)
 {
   /* Create a mapping header containing the underlying data and length,
 and prepend this to the uncompression buffer.  The uncompressed data
@@ -200,7 +200,7 @@ lto_free_section_data (struct lto_file_d

   /* FIXME lto: WPA mode does not write compressed sections, so for now
  suppress uncompression mapping if flag_ltrans.  */
-  if (flag_ltrans)
+  if (flag_ltrans || 1)
 {
   (free_section_f) (file_data, section_type, name, data, len);
   return;

does that change anything?

Thanks,
Richard.

> Martin
>


Re: [c++-concepts] Allow function parameters to be referenced in trailing requires clauses

2014-07-30 Thread Andrew Sutton
Applied an updated version of this patch.

2014-7-30  Braden Obrzut  
* gcc/cp/parser.c (cp_parser_trailing_requirements): Handle requires
keyword manually so that we can push function parameters back into
scope.
* gcc/cp/decl.c (push_function_parms): New. Recovers and reopens
function parameter scope from declarator.
* gcc/testsuite/g++.dg/concepts/req*.C: New tests.

2014-07-30  Andrew Sutton  
* gcc/testsuite/g++.dg/concepts/test.C: Removed.

Andrew Sutton


On Tue, Jun 17, 2014 at 5:06 AM, Braden Obrzut  wrote:
> This patch allows function parameters to be referenced by trailing requires
> clauses.  Typically this is used to refer to the type of an implicitly
> generated template.  For example, the following should now be valid (where C
> is some previously defined concept):
>
> auto f1 (auto x) requires C ();
>
> Note that the test case trailing-requires-overload.C will fail to compile
> unless the previously submitted patch is applied first.
>
> 2014-06-17  Braden Obrzut  
> * gcc/cp/parser.c (cp_parser_trailing_requirements): Handle requires
> keyword manually so that we can push function parameters back into
> scope.
> * gcc/cp/decl.c (push_function_parms): New. Recovers and reopens
> function parameter scope from declarator.
> * gcc/testsuite/g++.dg/concepts/trailing-requires.C: New tests.
> * gcc/testsuite/g++.dg/concepts/trailing-requires-overload.C: New tests.
Index: gcc/testsuite/g++.dg/concepts/traits1.C
===
--- gcc/testsuite/g++.dg/concepts/traits1.C	(revision 212456)
+++ gcc/testsuite/g++.dg/concepts/traits1.C	(working copy)
@@ -79,21 +79,21 @@ void f18() requires Enum();
 
 
 int main() { 
-  f1(); // { dg-error "cannot" }
-  f2(); // { dg-error "cannot" }
-  f3(); // { dg-error "cannot" }
-  f4(); // { dg-error "cannot" }
-  f5(); // { dg-error "cannot" }
-  f6(); // { dg-error "cannot" }
-  f7(); // { dg-error "cannot" }
-  f8(); // { dg-error "cannot" }
-  f9(); // { dg-error "cannot" }
-  f10(); // { dg-error "cannot" }
-  f11(); // { dg-error "cannot" }
-  f12(); // { dg-error "cannot" }
-  f13(); // { dg-error "cannot" }
-  f14(); // { dg-error "cannot" }
-  f15(); // { dg-error "cannot" }
-  f16(); // { dg-error "cannot" }
-  f17(); // { dg-error "cannot" }
+  f1(); // { dg-error "cannot call" }
+  f2(); // { dg-error "cannot call" }
+  f3(); // { dg-error "cannot call" }
+  f4(); // { dg-error "cannot call" }
+  f5(); // { dg-error "cannot call" }
+  f6(); // { dg-error "cannot call" }
+  f7(); // { dg-error "cannot call" }
+  f8(); // { dg-error "cannot call" }
+  f9(); // { dg-error "cannot call" }
+  f10(); // { dg-error "cannot call" }
+  f11(); // { dg-error "cannot call" }
+  f12(); // { dg-error "cannot call" }
+  f13(); // { dg-error "cannot call" }
+  f14(); // { dg-error "cannot call" }
+  f15(); // { dg-error "cannot call" }
+  f16(); // { dg-error "cannot call" }
+  f17(); // { dg-error "cannot call" }
 }
Index: gcc/testsuite/g++.dg/concepts/req1.C
===
--- gcc/testsuite/g++.dg/concepts/req1.C	(revision 0)
+++ gcc/testsuite/g++.dg/concepts/req1.C	(revision 0)
@@ -0,0 +1,15 @@
+// { dg-do run }
+// { dg-options "-std=c++1z" }
+
+template
+  concept bool Class () { return __is_class(T); }
+
+void f1(auto a) requires Class() { }
+void f2(auto a) requires requires (decltype(a) x) { -x; } { }
+
+struct S { } s;
+
+int main() {
+  f1(s);
+  f2(0);
+}
Index: gcc/testsuite/g++.dg/concepts/req2.C
===
--- gcc/testsuite/g++.dg/concepts/req2.C	(revision 0)
+++ gcc/testsuite/g++.dg/concepts/req2.C	(revision 0)
@@ -0,0 +1,21 @@
+// { dg-options "-std=c++1z" }
+
+#include 
+
+template
+  concept bool Class () { return __is_class(T); }
+
+void f1 (auto a) requires Class() { }
+
+  // FIXME: This is generating excess errors related to pretty
+  // printing the trailing requires expression.
+void f2(auto a) 
+  requires requires (decltype(a) x) { -x; } 
+{ } 
+
+struct S { } s;
+
+int main() {
+  f1(0); // { dg-error "matching" }
+  f2((void*)0); // { dg-error "matching" }
+}
Index: gcc/testsuite/g++.dg/concepts/req3.C
===
--- gcc/testsuite/g++.dg/concepts/req3.C	(revision 0)
+++ gcc/testsuite/g++.dg/concepts/req3.C	(revision 0)
@@ -0,0 +1,18 @@
+// { dg-do run }
+// { dg-options "-std=c++1z" }
+
+template
+  concept bool Class () { return __is_class(T); }
+
+struct Test {
+  void f(auto a) requires Class();
+} test;
+
+struct S { }s;
+
+int main() {
+  test.f(s);
+}
+
+void Test::f(auto a) requires Class() { }
+
Index: gcc/testsuite/g++.dg/concepts/test.C
===
--- gcc/testsuite/g++.dg/concepts/test.C	(revision 212100)
+++ gcc/testsuite/g++.dg/concepts/test.C	(working copy)
@@ -1,17 +0,0 @@
-/

Re: Warn when returning the address of a temporary (middle-end) v2

2014-07-30 Thread Marc Glisse

On Tue, 29 Jul 2014, David Malcolm wrote:


On Tue, 2014-07-29 at 19:36 +0200, Marc Glisse wrote:

On Sun, 27 Jul 2014, Richard Sandiford wrote:


Marc Glisse  writes:

Hello,

I followed the advice in this discussion:
https://gcc.gnu.org/ml/gcc-patches/2014-04/msg00269.html

and here is a new patch. I made an effort to isolate a path in at least
one subcase so it doesn't look too strange that the warning is in this
file. Computing the dominance info just to tweak the warning message may
be a bit excessive.


How about only calculating it once you've decided to issue a message?


+ if (always_executed)
+   msg = "function returns address of local variable";
+ else
+   msg = "function may return address of local variable";


I think you need _(...) here, unless some magic makes that unnecessary now.


Current version, which passed bootstrap+testsuite on x86_64-linux-gnu.
(the original discussion is at
https://gcc.gnu.org/ml/gcc-patches/2014-06/msg01692.html )


This is possibly a dumb question, but what happens for a static local,
rather than an auto local? e.g.

int *f (void)
{
   static int i;
   return &i;
}

(e.g. should the test case cover this?)


New version with a static local variable in the testcase, and without 
using build_compound_expr in the C front-end to avoid extra warnings.


Same ChangeLog, same testsuite results.

--
Marc GlisseIndex: gcc/c/c-typeck.c
===
--- gcc/c/c-typeck.c(revision 213251)
+++ gcc/c/c-typeck.c(working copy)
@@ -9330,22 +9330,26 @@ c_finish_return (location_t loc, tree re
 
  if (DECL_P (inner)
  && !DECL_EXTERNAL (inner)
  && !TREE_STATIC (inner)
  && DECL_CONTEXT (inner) == current_function_decl)
{
  if (TREE_CODE (inner) == LABEL_DECL)
warning_at (loc, OPT_Wreturn_local_addr,
"function returns address of label");
  else
-   warning_at (loc, OPT_Wreturn_local_addr,
-   "function returns address of local variable");
+   {
+ warning_at (loc, OPT_Wreturn_local_addr,
+ "function returns address of local variable");
+ tree zero = build_zero_cst (TREE_TYPE (res));
+ t = build2 (COMPOUND_EXPR, TREE_TYPE (res), t, zero);
+   }
}
  break;
 
default:
  break;
}
 
  break;
}
 
Index: gcc/c-family/c.opt
===
--- gcc/c-family/c.opt  (revision 213251)
+++ gcc/c-family/c.opt  (working copy)
@@ -698,24 +698,20 @@ ObjC ObjC++ Var(warn_protocol) Init(1) W
 Warn if inherited methods are unimplemented
 
 Wredundant-decls
 C ObjC C++ ObjC++ Var(warn_redundant_decls) Warning
 Warn about multiple declarations of the same object
 
 Wreorder
 C++ ObjC++ Var(warn_reorder) Warning LangEnabledBy(C++ ObjC++,Wall)
 Warn when the compiler reorders code
 
-Wreturn-local-addr
-C ObjC C++ ObjC++ Var(warn_return_local_addr) Init(1) Warning
-Warn about returning a pointer/reference to a local or temporary variable.
-
 Wreturn-type
 C ObjC C++ ObjC++ Var(warn_return_type) Warning LangEnabledBy(C ObjC C++ 
ObjC++,Wall)
 Warn whenever a function's return type defaults to \"int\" (C), or about 
inconsistent return types (C++)
 
 Wselector
 ObjC ObjC++ Var(warn_selector) Warning
 Warn if a selector has multiple methods
 
 Wshadow-ivar
 ObjC ObjC++ Var(warn_shadow_ivar) EnabledBy(Wshadow) Init(1) Warning
Index: gcc/common.opt
===
--- gcc/common.opt  (revision 213251)
+++ gcc/common.opt  (working copy)
@@ -600,20 +600,24 @@ Common Var(warn_packed) Warning
 Warn when the packed attribute has no effect on struct layout
 
 Wpadded
 Common Var(warn_padded) Warning
 Warn when padding is required to align structure members
 
 Wpedantic
 Common Var(pedantic) Warning
 Issue warnings needed for strict compliance to the standard
 
+Wreturn-local-addr
+Common Var(warn_return_local_addr) Init(1) Warning
+Warn about returning a pointer/reference to a local or temporary variable.
+
 Wshadow
 Common Var(warn_shadow) Warning
 Warn when one local variable shadows another
 
 Wstack-protector
 Common Var(warn_stack_protect) Warning
 Warn when not issuing stack smashing protection for some reason
 
 Wstack-usage=
 Common Joined RejectNegative UInteger Var(warn_stack_usage) Init(-1) Warning
Index: gcc/cp/typeck.c
===
--- gcc/cp/typeck.c (revision 213251)
+++ gcc/cp/typeck.c (working copy)
@@ -49,21 +49,21 @@ static tree convert_for_assignment (tree
 static tree cp_pointer_int_

Re: [PATCH] LTO streamer reorg - try to reduce WPA memory use

2014-07-30 Thread Martin Liška


On 07/30/2014 12:37 PM, Richard Biener wrote:

On Wed, Jul 30, 2014 at 1:14 PM, Martin Liška  wrote:

On 07/30/2014 11:41 AM, Richard Biener wrote:

On Wed, 30 Jul 2014, Richard Biener wrote:


On Wed, Jul 30, 2014 at 7:51 AM, Markus Trippelsdorf
 wrote:

On 2014.07.29 at 15:10 +0200, Richard Biener wrote:

On Tue, 29 Jul 2014, Richard Biener wrote:


This re-organizes the LTO streamer to do compression transparently
in the data-streamer routines (and disables section compression
by defaulting to -flto-compression-level=0).  This avoids
keeping the whole uncompressed sections in memory, only retaining
the compressed ones.

The downside is that we lose compression of at least the string
parts (they are abusing the streaming interface quite awkwardly
and doing random-accesses with offsets into the uncompressed
section).  With a little bit of surgery we can get that back I
think (but we'd have to keep the uncompressed piece in memory
somewhere which means losing the memory use advantage).

Very lightly tested sofar (running lto.exp).  I'll try a LTO
bootstrap now.

I wonder what the change is on WPA memory use for larger
projects and what the effect on object file size is.

Updated patch passing LTO bootstrap (one warning fix) and
with a memory leak fixed.

Testing with Firefox is impossible at the moment because of PR61885.
One thing I've noticed (before the ICE) is that virtual memory usage is
very high:

AddressKbytes  RSSDirty  Mode  Mapping
004016344 90840  r-x-- lto1
013f6000   36   36   28  rw--- lto1
013ff000 1072  276  276  rw---   [ anon ]
034aa000 10154940  1540384  1540384  rw---   [ anon ]
2acf04af2000  136  1360  r-x-- ld-2.19.90.so
2acf04b14000   88   88   88  rw---   [ anon ]
...
  ---  ---  ---
total kB 12022060  3388396  3377708

Maybe there is still a memleak (just checked that LTOing int main() {}
doesn't leak).

Found it:

Index: gcc/lto-section-in.c
===
--- gcc/lto-section-in.c.orig   2014-07-30 12:40:27.950225826 +0200
+++ gcc/lto-section-in.c2014-07-30 12:37:44.179237102 +0200
@@ -249,7 +249,7 @@ lto_destroy_simple_input_block (struct l
  struct lto_input_block *ib,
  const char *data, size_t len)
   {
-  free (ib);
+  delete ib;
 lto_free_section_data (file_data, section_type, NULL, data, len);
   }
   Richard.

Hello,
there's memory/CPU usage for the patch. for both, I used sync and
drop_caches.

Url:
https://drive.google.com/file/d/0B0pisUJ80pO1andOX19JMHV3LVE/edit?usp=sharing

Ok, it turns out setting -flto-compression-level to 0 doesn't really
short-circuit zlib for sections.  So the following does that the hard
but effective way.

Index: gcc/lto-section-out.c
===
--- gcc/lto-section-out.c.orig  2014-07-30 13:33:06.634008355 +0200
+++ gcc/lto-section-out.c   2014-07-30 13:29:19.468023995 +0200
@@ -80,7 +80,7 @@ lto_begin_section (const char *name, boo
   data is anything other than assembler output.  The effect here is that
   we get compression of IL only in non-ltrans object files.  */
gcc_assert (compression_stream == NULL);
-  if (compress)
+  if (compress && 0)
  compression_stream = lto_start_compression (lto_append_data, NULL);
  }

Index: gcc/lto-section-in.c
===
--- gcc/lto-section-in.c.orig   2014-07-30 13:33:06.637008355 +0200
+++ gcc/lto-section-in.c2014-07-30 13:31:57.329013126 +0200
@@ -153,7 +153,7 @@ lto_get_section_data (struct lto_file_de

/* FIXME lto: WPA mode does not write compressed sections, so for now
   suppress uncompression if flag_ltrans.  */
-  if (!flag_ltrans)
+  if (!flag_ltrans && 0)
  {
/* Create a mapping header containing the underlying data and length,
  and prepend this to the uncompression buffer.  The uncompressed data
@@ -200,7 +200,7 @@ lto_free_section_data (struct lto_file_d

/* FIXME lto: WPA mode does not write compressed sections, so for now
   suppress uncompression mapping if flag_ltrans.  */
-  if (flag_ltrans)
+  if (flag_ltrans || 1)
  {
(free_section_f) (file_data, section_type, name, data, len);
return;

does that change anything?

Thanks,
Richard.

There are new numbers: 
https://drive.google.com/file/d/0B0pisUJ80pO1aG83N2JXLWNVUW8/edit?usp=sharing, 
where I reduced the scale to to 10GB to identify better any differences.

Martin


Martin





Re: [GSoC] type of an isl_ast_expr_id

2014-07-30 Thread Roman Gareev
> OK. I proposed a slightly longer description. With the updated description,
> you can commit this patch.

I've fixed the fixme.

FIXME: We should replace blind conversation of id's type with
derivation of the optimal type when we get the corresponding isl
support. Blindly converting type sizes may be problematic when we
switch to smaller types.

Would you add anything to it?

> That's what I suggested earlier, no? The only thing I would like you to
> check beforehand is if the very same problem still exists with isl trunk.
> For this you need to generate an input file for the 'isl_codegen' tool as it
> comes with isl that allows to reproduce the bug. The very same input file
> can then be submitted to the isl mailing list as a bug report. Could you do
> the reporting (and CC me)?

Yes, I wanted to make sure that the code generated by the isl-0.13 is
also not optimal (I sent you the code generated by isl-0.12.2 before).
The report has been sent to the isl mailing list and CC you.

--
   Cheers, Roman Gareev.


Re: [GSoC] type of an isl_ast_expr_id

2014-07-30 Thread Tobias Grosser

On 30/07/2014 14:32, Roman Gareev wrote:

OK. I proposed a slightly longer description. With the updated description,
you can commit this patch.


I've fixed the fixme.

FIXME: We should replace blind conversation of id's type with
derivation of the optimal type when we get the corresponding isl
support. Blindly converting type sizes may be problematic when we
switch to smaller types.



Would you add anything to it?


Fine with me.


That's what I suggested earlier, no? The only thing I would like you to
check beforehand is if the very same problem still exists with isl trunk.
For this you need to generate an input file for the 'isl_codegen' tool as it
comes with isl that allows to reproduce the bug. The very same input file
can then be submitted to the isl mailing list as a bug report. Could you do
the reporting (and CC me)?


Yes, I wanted to make sure that the code generated by the isl-0.13 is
also not optimal (I sent you the code generated by isl-0.12.2 before).
The report has been sent to the isl mailing list and CC you.


Great. Thanks.

(Sven already replied)

Two comments on your bug report:

1) It would be helpful to also point give the output CLooG generates for 
similar input


2) The input is a little involved. If you can provide a minimal test 
case, this normally helps in getting bugs fixed faster.



Cheers,
Tobias



[Ada] Use Is_Inlined flag to mark fully inlined subp in GNATprove mode

2014-07-30 Thread Arnaud Charlet
In GNATprove mode, some subprograms may be partially inlined, due to
recursion, or because some calls are in a potentially unevaluated context,
which would lead to code that GNATprove would not be able to handle. In
those cases, the body-to-inline has been built, and potentially already be
inlined. Hence, the separate flag Is_Inlined is used to convey the
information that not all calls have been inlined, by setting it to False.
GNATprove uses this information to decide which subprograms to analyze.

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

2014-07-30  Yannick Moy  

* einfo.ads (Is_Inlined): Document new use in GNATprove mode.
* inline.adb (Can_Be_Inlined_In_GNATprove_Mode): Add comments
to explain rationale for inlining or not in GNATprove mode.
(Expand_Inlined_Call): In GNATprove mode, set Is_Inlined flag
to False when inlining is not possible.
* sem_ch6.adb (Analyze_Subprogram_Body_Helper): Set Is_Inlined
flag to indicate that subprogram is fully inlined. To be reversed
if inlining problem is found.
* sem_res.adb (Resolve_Call): Set Is_Inlined flag to False when
call in potentially unevaluated context.

Index: inline.adb
===
--- inline.adb  (revision 213254)
+++ inline.adb  (working copy)
@@ -1558,10 +1558,15 @@
  Id := Body_Id;
   end if;
 
-  --  General note. The following comments clearly say what cannot be
-  --  inlined, but they do not give any clue on the motivation for the
-  --  exclusion. It would be good to document the motivations ???
+  --  Only local subprograms without contracts are inlined in GNATprove
+  --  mode, as these are the subprograms which a user is not interested in
+  --  analyzing in isolation, but rather in the context of their call. This
+  --  is a convenient convention, that could be changed for an explicit
+  --  pragma/aspect one day.
 
+  --  In a number of special cases, inlining is not desirable or not
+  --  possible, see below.
+
   --  Do not inline unit-level subprograms
 
   if Nkind (Parent (Id)) = N_Defining_Program_Unit_Name then
@@ -1584,19 +1589,22 @@
   then
  return False;
 
-  --  Do not inline expression functions
+  --  Do not inline expression functions, which are directly inlined at the
+  --  prover level.
 
   elsif (Present (Spec_Id) and then Is_Expression_Function (Spec_Id))
 or else Is_Expression_Function (Body_Id)
   then
  return False;
 
-  --  Do not inline generic subprogram instances
+  --  Do not inline generic subprogram instances. The visibility rules of
+  --  generic instances plays badly with inlining.
 
   elsif Is_Generic_Instance (Spec_Id) then
  return False;
 
-  --  Only inline subprograms whose body is marked SPARK_Mode On
+  --  Only inline subprograms whose body is marked SPARK_Mode On. Other
+  --  subprogram bodies should not be analyzed.
 
   elsif No (SPARK_Pragma (Body_Id))
 or else Get_SPARK_Mode_From_Pragma (SPARK_Pragma (Body_Id)) /= On
@@ -2952,11 +2960,11 @@
   function Process_Sloc (Nod : Node_Id) return Traverse_Result;
   --  If the call being expanded is that of an internal subprogram, set the
   --  sloc of the generated block to that of the call itself, so that the
-  --  expansion is skipped by the "next" command in gdb.
-  --  Same processing for a subprogram in a predefined file, e.g.
-  --  Ada.Tags. If Debug_Generated_Code is true, suppress this change to
-  --  simplify our own development. Same in in GNATprove mode, to ensure
-  --  that warnings and diagnostics point to the proper location.
+  --  expansion is skipped by the "next" command in gdb. Same processing
+  --  for a subprogram in a predefined file, e.g. Ada.Tags. If
+  --  Debug_Generated_Code is true, suppress this change to simplify our
+  --  own development. Same in GNATprove mode, to ensure that warnings and
+  --  diagnostics point to the proper location.
 
   procedure Reset_Dispatching_Calls (N : Node_Id);
   --  In subtree N search for occurrences of dispatching calls that use the
@@ -3634,8 +3642,9 @@
  if Present (Renamed_Object (F)) then
 
 --  If expander is active, it is an error to try to inline a
---  recursive program. In GNATprove mode, just indicate that
---  the inlining will not happen.
+--  recursive program. In GNATprove mode, just indicate that the
+--  inlining will not happen, and mark the subprogram as not always
+--  inlined.
 
 if Expander_Active then
Error_Msg_N
@@ -3643,6 +3652,7 @@
 else
Cannot_Inline
  ("cannot inline call to recursive subprogram?", N, Subp);
+   Set_Is_Inlined (Subp

[Ada] Fix race conditions related to independent tasks

2014-07-30 Thread Arnaud Charlet
This patch fixes several race conditions involving independent tasks.
The main thing is to make sure the activating task waits for them
to become independent. Otherwise (for example) the environment task
can race ahead to Finalize_Global_Tasks and find things in an
inconsistent state, causing programs to intermittently hang.

In addition, we fix several data structures used by various independent tasks
to be reliably initialized before those tasks get activated.

No simple test case is available.

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

2014-07-30  Bob Duff  

* s-tasuti.ads, s-tasuti.adb (Make_Independent): Change this
from a procedure to a function, so that it can more easily be
called before the "begin" of a task.
* s-taasde.ads (Delay_Block): Make this type immutably limited,
so we can use a build-in-place function call to initialize
Timer_Queue in the body.
* a-rttiev.adb, s-asthan-vms-alpha.adb, s-asthan-vms-ia64.adb,
* s-interr.adb, s-interr-hwint.adb, s-interr-sigaction.adb,
* s-interr-vms.adb, s-taasde.adb: Each independent task now calls
Make_Independent before reaching its "begin", to avoid race
conditions. This causes the activating task to wait until after
Make_Independent is complete before proceeding.  In addition,
we initialize data structures used by independent tasks before
activating those tasks, to avoid possible use of uninitialized data.
* s-interr.ads, s-intman.ads, s-taspri-posix.ads, s-tasdeb.ads:
Minor comment fixes.

Index: s-tasuti.adb
===
--- s-tasuti.adb(revision 213201)
+++ s-tasuti.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 --  B o d y --
 --  --
--- Copyright (C) 1992-2011, Free Software Foundation, Inc.  --
+-- Copyright (C) 1992-2014, Free Software Foundation, Inc.  --
 --  --
 -- GNARL 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- --
@@ -242,7 +242,7 @@
-- Make_Independent --
--
 
-   procedure Make_Independent is
+   function Make_Independent return Boolean is
   Self_Id   : constant Task_Id := STPO.Self;
   Environment_Task  : constant Task_Id := STPO.Environment_Task;
   Parent: constant Task_Id := Self_Id.Common.Parent;
@@ -321,6 +321,8 @@
   end if;
 
   Initialization.Undefer_Abort (Self_Id);
+
+  return True; -- return value doesn't matter
end Make_Independent;
 
--
Index: s-tasuti.ads
===
--- s-tasuti.ads(revision 213201)
+++ s-tasuti.ads(working copy)
@@ -6,7 +6,7 @@
 --  --
 --  S p e c --
 --  --
--- Copyright (C) 1992-2009, Free Software Foundation, Inc.  --
+-- Copyright (C) 1992-2014, Free Software Foundation, Inc.  --
 --  --
 -- GNARL 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- --
@@ -44,7 +44,7 @@
-- Task_Stage Related routines --
-
 
-   procedure Make_Independent;
+   function Make_Independent return Boolean;
--  Move the current task to the outermost level (level 2) of the master
--  hierarchy of the environment task. That is one level further out
--  than normal tasks defined in library-level packages (level 3). The
@@ -63,9 +63,35 @@
--  will change the task's parent. This assumption is particularly
--  important for master level completion and for the computation of
--  Independent_Task_Count.
+   --
+   --  NOTE WELL: Make_Independent should be called before the task reaches its
+   --  "begin", like this:
+   --
+   -- task body Some_Independent_Task is
+   --...
+   --Ignore : constant Boolean := Make_Independent;
+   --pragma Unreferenced (Ignore);
+   --...
+   -- begin
+   --
+   --  The return value is meaningless; the only reason this is a function is
+   --  to get around the Ada limitation that makes a procedure call
+   --  syntactically illegal before the "begin".
+   --
+   --  Calling it before "begin" ensures that the ca

RE: [PATCH] PR61868

2014-07-30 Thread Bingfeng Mei
On the second thought, maybe the change should be made in set_random_seed. 
Otherwise, init_random_seed is invoked every time get_random_seed get called 
(not sure how often). What do you think? 

const char *
set_random_seed (const char *val)
{
  const char *old = flag_random_seed;
  flag_random_seed = val;
+ init_random_seed ();
  return old;
}

Bingfeng

> -Original Message-
> From: Richard Biener [mailto:richard.guent...@gmail.com]
> Sent: 30 July 2014 10:43
> To: Bingfeng Mei
> Cc: Andi Kleen; gcc-patches@gcc.gnu.org
> Subject: Re: [PATCH] PR61868
> 
> On Wed, Jul 30, 2014 at 10:52 AM, Bingfeng Mei  wrote:
> > Yes, opts-global.c fills flag_random_seed with string passed in
> command line. But init_random_seed in toplev.c is the one that processes
> the flag and set random_seed variable, which is returned by
> get_random_seed function.
> 
> Err, I meant opts-global.c:handle_common_deferred_options
> 
> > By default, my configuration enables LTO. How to test LTO bootstrap?
> 
> configure with --with-build-config=bootstrap-lto (and reduce the
> set of languages to c,c++ to get a sane bootstrap time).
> 
> Richard.
> 
> > Bingfeng
> >
> >> -Original Message-
> >> From: Richard Biener [mailto:richard.guent...@gmail.com]
> >> Sent: 30 July 2014 08:47
> >> To: Bingfeng Mei; Andi Kleen
> >> Cc: gcc-patches@gcc.gnu.org
> >> Subject: Re: [PATCH] PR61868
> >>
> >> On Tue, Jul 29, 2014 at 3:01 PM, Bingfeng Mei 
> wrote:
> >> > Hi,
> >> > Please find the patches for pr61868. The problem is that even with
> -
> >> frandom-seed gcc always uses 0 instead of specified number/string for
> >> places such as lto section names. init_random_seed is never called
> with
> >> -frandom-seed. Bootstrapped and tested on x86-64. OK for trunk?
> >>
> >> Hmm, but -frandom-seed= is honored by opts.c calling set_random_seed?
> >>
> >> Andi, wasn't this used to support partial linking of LTO objects?
> Thus,
> >> this shortcut was on purpose?  Otherwise passing -frandom-seed to
> >> LTO would break that?
> >>
> >> Bingfeng, did you test if LTO bootstrap still works after this patch?
> >>
> >> Thanks,
> >> Richard.
> >>
> >> > Thanks,
> >> > Bingfeng Mei
> >> >
> >> >
> >> > ===
> >> > --- ChangeLog   (revision 213152)
> >> > +++ ChangeLog   (working copy)
> >> > @@ -1,3 +1,9 @@
> >> > +2014-07-29  Bingfeng Mei 
> >> > +
> >> > +   PR lto/61868
> >> > +   * toplev.c (init_random_seed): Generate random seed when
> >> > +   flag_random_seed is specified.
> >> > +
> >> >  2014-07-28  Jan Hubicka  
> >> >
> >> > * cgraph.c (cgraph_node::create_indirect_edge): Copy
> >> speculative data.
> >> > Index: toplev.c
> >> > ===
> >> > --- toplev.c(revision 213152)
> >> > +++ toplev.c(working copy)
> >> > @@ -301,7 +301,7 @@ init_random_seed (void)
> >> >  HOST_WIDE_INT
> >> >  get_random_seed (bool noinit)
> >> >  {
> >> > -  if (!flag_random_seed && !noinit)
> >> > +  if (!noinit)
> >> >  init_random_seed ();
> >> >return random_seed;
> >> >  }
> >> > Index: testsuite/ChangeLog
> >> > ===
> >> > --- testsuite/ChangeLog (revision 213152)
> >> > +++ testsuite/ChangeLog (working copy)
> >> > @@ -1,3 +1,8 @@
> >> > +2014-07-29  Bingfeng Mei  
> >> > +
> >> > +   PR lto/61868
> >> > +   * gcc.dg/pr61868.c: New test.
> >> > +
> >> >  2014-07-28  Richard Biener  
> >> >
> >> > PR rtl-optimization/61801
> >> > Index: testsuite/gcc.dg/pr61868.c
> >> > ===
> >> > --- testsuite/gcc.dg/pr61868.c  (revision 0)
> >> > +++ testsuite/gcc.dg/pr61868.c  (revision 0)
> >> > @@ -0,0 +1,9 @@
> >> > +/* { dg-do compile } */
> >> > +/* { dg-options "-flto -frandom-seed=0x12345" }  */
> >> > +extern int foo (int);
> >> > +int main ()
> >> > +{
> >> > +  foo (100);
> >> > +  return 0;
> >> > +}
> >> > +/* { dg-final { scan-assembler "\.gnu\.lto.*.12345" } } */
> >> >


[PINGv2][PATCH] Fix for PR 61561

2014-07-30 Thread Marat Zakirov

On 07/23/2014 05:33 PM, Marat Zakirov wrote:

Hi all!

This is a friendly reminder message.

On 07/17/2014 03:22 PM, Marat Zakirov wrote:


On 07/16/2014 01:32 PM, Kyrill Tkachov wrote:


On 16/07/14 10:22, Marat Zakirov wrote:

Christophe,

Please look at a new patch.  Draft tests are OK.
I'll ask your commit approval when full regression (ARM/thumb1/thumb2)
tests are done.

Hi Marat,

I was about to propose the thumb2.md hunk myself, but I'll defer to 
the arm maintainers to comment on the other parts.


Also, in the ChangeLog it is helpful to specify which patterns are 
being affected, so in your case it would be something like:


* config/arm/thumb1.md (*thumb1_movhi_insn): Handle stack pointer.
(*thumb1_movqi_insn): Likewise.
* config/arm/thumb2.md (*thumb2_movhi_insn): Ditto.


Kyrill



Christophe, Kirill,

finally I've finished regression testing.
Please check if my patch is OK for trunk.

The following configures were used:

configure --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu 
--target=arm-linux-gnueabi  --with-interwork --enable-long-long 
--enable-languages=c,c++,fortran --enable-shared --with-gnu-as 
--with-gnu-ld --with-arch=$ARCH --with-mode=$MODE


Thumb-1

$ARCH=armv4t
$MODE=thumb

Thumb-2

$ARCH=armv7
$MODE=thumb

ARM

$ARCH=armv7-a
$MODE=arm

No regressions detected, test pr61561.c passed in all cases.

Thank you all.
--Marat





gcc/ChangeLog:

2014-07-16  Marat Zakirov  

	* config/arm/thumb1.md (*thumb1_movhi_insn): Handle stack pointer.
	(*thumb1_movqi_insn): Likewise.
	* config/arm/thumb2.md (*thumb2_movhi_insn): Likewise.

diff --git a/gcc/config/arm/thumb1.md b/gcc/config/arm/thumb1.md
index c044fd5..47b5cbd 100644
--- a/gcc/config/arm/thumb1.md
+++ b/gcc/config/arm/thumb1.md
@@ -708,7 +708,7 @@
 
 (define_insn "*thumb1_movhi_insn"
   [(set (match_operand:HI 0 "nonimmediate_operand" "=l,l,m,*r,*h,l")
-	(match_operand:HI 1 "general_operand"   "l,m,l,*h,*r,I"))]
+	(match_operand:HI 1 "general_operand"   "lk,m,l,*h,*r,I"))]
   "TARGET_THUMB1
&& (   register_operand (operands[0], HImode)
|| register_operand (operands[1], HImode))"
@@ -762,7 +762,7 @@
 
 (define_insn "*thumb1_movqi_insn"
   [(set (match_operand:QI 0 "nonimmediate_operand" "=l,l,m,*r,*h,l")
-	(match_operand:QI 1 "general_operand"  "l, m,l,*h,*r,I"))]
+	(match_operand:QI 1 "general_operand"  "lk, m,l,*h,*r,I"))]
   "TARGET_THUMB1
&& (   register_operand (operands[0], QImode)
|| register_operand (operands[1], QImode))"
diff --git a/gcc/config/arm/thumb2.md b/gcc/config/arm/thumb2.md
index 6ea0810..7228069 100644
--- a/gcc/config/arm/thumb2.md
+++ b/gcc/config/arm/thumb2.md
@@ -318,7 +318,7 @@
 ;; of the messiness associated with the ARM patterns.
 (define_insn "*thumb2_movhi_insn"
   [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,l,r,m,r")
-	(match_operand:HI 1 "general_operand"  "r,I,Py,n,r,m"))]
+	(match_operand:HI 1 "general_operand"  "rk,I,Py,n,r,m"))]
   "TARGET_THUMB2
   && (register_operand (operands[0], HImode)
  || register_operand (operands[1], HImode))"


Re: [PATCH] PR61868

2014-07-30 Thread Richard Biener
On Wed, Jul 30, 2014 at 2:48 PM, Bingfeng Mei  wrote:
> On the second thought, maybe the change should be made in set_random_seed. 
> Otherwise, init_random_seed is invoked every time get_random_seed get called 
> (not sure how often). What do you think?
>
> const char *
> set_random_seed (const char *val)
> {
>   const char *old = flag_random_seed;
>   flag_random_seed = val;
> + init_random_seed ();
>   return old;
> }

I think it makes more sense to move the if (flag_random_seed)
code from init_random_seed inline here as init_random_seed is
never called with flag_random_set == true.

Richard.

> Bingfeng
>
>> -Original Message-
>> From: Richard Biener [mailto:richard.guent...@gmail.com]
>> Sent: 30 July 2014 10:43
>> To: Bingfeng Mei
>> Cc: Andi Kleen; gcc-patches@gcc.gnu.org
>> Subject: Re: [PATCH] PR61868
>>
>> On Wed, Jul 30, 2014 at 10:52 AM, Bingfeng Mei  wrote:
>> > Yes, opts-global.c fills flag_random_seed with string passed in
>> command line. But init_random_seed in toplev.c is the one that processes
>> the flag and set random_seed variable, which is returned by
>> get_random_seed function.
>>
>> Err, I meant opts-global.c:handle_common_deferred_options
>>
>> > By default, my configuration enables LTO. How to test LTO bootstrap?
>>
>> configure with --with-build-config=bootstrap-lto (and reduce the
>> set of languages to c,c++ to get a sane bootstrap time).
>>
>> Richard.
>>
>> > Bingfeng
>> >
>> >> -Original Message-
>> >> From: Richard Biener [mailto:richard.guent...@gmail.com]
>> >> Sent: 30 July 2014 08:47
>> >> To: Bingfeng Mei; Andi Kleen
>> >> Cc: gcc-patches@gcc.gnu.org
>> >> Subject: Re: [PATCH] PR61868
>> >>
>> >> On Tue, Jul 29, 2014 at 3:01 PM, Bingfeng Mei 
>> wrote:
>> >> > Hi,
>> >> > Please find the patches for pr61868. The problem is that even with
>> -
>> >> frandom-seed gcc always uses 0 instead of specified number/string for
>> >> places such as lto section names. init_random_seed is never called
>> with
>> >> -frandom-seed. Bootstrapped and tested on x86-64. OK for trunk?
>> >>
>> >> Hmm, but -frandom-seed= is honored by opts.c calling set_random_seed?
>> >>
>> >> Andi, wasn't this used to support partial linking of LTO objects?
>> Thus,
>> >> this shortcut was on purpose?  Otherwise passing -frandom-seed to
>> >> LTO would break that?
>> >>
>> >> Bingfeng, did you test if LTO bootstrap still works after this patch?
>> >>
>> >> Thanks,
>> >> Richard.
>> >>
>> >> > Thanks,
>> >> > Bingfeng Mei
>> >> >
>> >> >
>> >> > ===
>> >> > --- ChangeLog   (revision 213152)
>> >> > +++ ChangeLog   (working copy)
>> >> > @@ -1,3 +1,9 @@
>> >> > +2014-07-29  Bingfeng Mei 
>> >> > +
>> >> > +   PR lto/61868
>> >> > +   * toplev.c (init_random_seed): Generate random seed when
>> >> > +   flag_random_seed is specified.
>> >> > +
>> >> >  2014-07-28  Jan Hubicka  
>> >> >
>> >> > * cgraph.c (cgraph_node::create_indirect_edge): Copy
>> >> speculative data.
>> >> > Index: toplev.c
>> >> > ===
>> >> > --- toplev.c(revision 213152)
>> >> > +++ toplev.c(working copy)
>> >> > @@ -301,7 +301,7 @@ init_random_seed (void)
>> >> >  HOST_WIDE_INT
>> >> >  get_random_seed (bool noinit)
>> >> >  {
>> >> > -  if (!flag_random_seed && !noinit)
>> >> > +  if (!noinit)
>> >> >  init_random_seed ();
>> >> >return random_seed;
>> >> >  }
>> >> > Index: testsuite/ChangeLog
>> >> > ===
>> >> > --- testsuite/ChangeLog (revision 213152)
>> >> > +++ testsuite/ChangeLog (working copy)
>> >> > @@ -1,3 +1,8 @@
>> >> > +2014-07-29  Bingfeng Mei  
>> >> > +
>> >> > +   PR lto/61868
>> >> > +   * gcc.dg/pr61868.c: New test.
>> >> > +
>> >> >  2014-07-28  Richard Biener  
>> >> >
>> >> > PR rtl-optimization/61801
>> >> > Index: testsuite/gcc.dg/pr61868.c
>> >> > ===
>> >> > --- testsuite/gcc.dg/pr61868.c  (revision 0)
>> >> > +++ testsuite/gcc.dg/pr61868.c  (revision 0)
>> >> > @@ -0,0 +1,9 @@
>> >> > +/* { dg-do compile } */
>> >> > +/* { dg-options "-flto -frandom-seed=0x12345" }  */
>> >> > +extern int foo (int);
>> >> > +int main ()
>> >> > +{
>> >> > +  foo (100);
>> >> > +  return 0;
>> >> > +}
>> >> > +/* { dg-final { scan-assembler "\.gnu\.lto.*.12345" } } */
>> >> >


Re: [PATCH, DOC]: New value 'default' for --enable-languages

2014-07-30 Thread Richard Biener
On Wed, Jul 30, 2014 at 1:37 PM, Martin Liška  wrote:
> Hello,
>as discussed in previous thread
> (https://gcc.gnu.org/ml/gcc-patches/2014-07/msg02010.html), I would like to
> add more intuitive behavior for --enable-languages configure option.

It works for me, but as I'm currently always testing all,ada,obj-c++ how
can I easily continue to do that - that is, not test go?  ;)

Thanks,
Richard.

> Thank you,
> Martin


Re: [PATCH, DOC]: New value 'default' for --enable-languages

2014-07-30 Thread Richard Biener
On Wed, Jul 30, 2014 at 3:19 PM, Richard Biener
 wrote:
> On Wed, Jul 30, 2014 at 1:37 PM, Martin Liška  wrote:
>> Hello,
>>as discussed in previous thread
>> (https://gcc.gnu.org/ml/gcc-patches/2014-07/msg02010.html), I would like to
>> add more intuitive behavior for --enable-languages configure option.
>
> It works for me, but as I'm currently always testing all,ada,obj-c++ how
> can I easily continue to do that - that is, not test go?  ;)

Of course with default,ada,obj-c++ ... stupid me.

Richard.

> Thanks,
> Richard.
>
>> Thank you,
>> Martin


[Ada] Reimplement Ada.Task_Attributes

2014-07-30 Thread Arnaud Charlet
This change reimplements from scratch the Ada.Task_Attributes package,
taking advantage of RM permission C.7.2(28), and putting a maximum number
of task attributes supported to simplify the implementation and make it
more efficient. In addition, a special ("Fast_Path") case is made for
task attributes holding in an address/pointer and whose Initial_Value is
0/null, which is more efficient and doesn't require the use of an indirection
(and therefore, no extra dynamic memory allocation, and no locking).

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

2014-07-30  Arnaud Charlet  

* s-taskin.ads (Direct_Index, Direct_Index_Range,
Direct_Attribute_Element, Direct_Attribute_Array,
Direct_Index_Vector, Direct_Attributes, Is_Defined,
Indirect_Attributes): Removed.  (Atomic_Address,
Attribute_Array, Attributes): New.
* s-tasini.ads, s-tasini.adb (Proc_T, Initialize_Attributes,
Finalize_Attributes_Link, Initialize_Attributes_Link): Removed.
(Finalize_Attributes): Reimplement.
* s-tassta.adb (Create_Task): Remove call to
Initialize_Attributes_Link (Free_Task, Vulnerable_Free_Task):
Replace Finalize_Attributes_Link by Finalize_Attributes.
* a-tasatt.ads, a-tasatt.adb, s-tataat.ads, s-tataat.adb:
Reimplement from scratch, using a simpler and more efficient
implementation.
* s-tporft.adb (Register_Foreign_Thread): Remove now obsolete comment.
* s-parame.ads, s-parame-hpux.ads,
* s-parame-vms-alpha.ads, s-parame-vms-ia64.ads,
* s-parame-vxworks.ads (Max_Attribute_Count): New, replace
Default_Attribute_Count.

Index: s-tataat.adb
===
--- s-tataat.adb(revision 213263)
+++ s-tataat.adb(working copy)
@@ -6,8 +6,7 @@
 --  --
 --  B o d y --
 --  --
--- Copyright (C) 1991-1994, Florida State University--
--- Copyright (C) 1995-2013, AdaCore --
+--  Copyright (C) 1995-2014, 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- --
@@ -30,189 +29,60 @@
 --  --
 --
 
-with Ada.Unchecked_Conversion;
+with System.Parameters; use System.Parameters;
+with System.Tasking.Initialization; use System.Tasking.Initialization;
 
-with System.Task_Primitives.Operations;
-with System.Tasking.Initialization;
-
 package body System.Tasking.Task_Attributes is
 
-   use Task_Primitives.Operations;
-   use Tasking.Initialization;
+   
+   -- Next_Index --
+   
 
-   function To_Access_Address is new Ada.Unchecked_Conversion
- (Access_Node, Access_Address);
-   --  Store pointer to indirect attribute list
+   type Index_Info is record
+  Used, Require_Finalization : Boolean;
+   end record;
+   --  Used is True if a given index is used by an instantiation of
+   --  Ada.Task_Attributes, False otherwise.
+   --  Require_Finalization is True is the attribute requires finalization.
 
-   --
-   -- Finalize --
-   --
+   Index_Array : array (1 .. Max_Attribute_Count) of Index_Info :=
+ (others => (False, False));
 
-   procedure Finalize (X : in out Instance) is
-  Q, To_Be_Freed : Access_Node;
-  Self_Id: constant Task_Id := Self;
-
+   function Next_Index (Require_Finalization : Boolean) return Integer is
+  Self_Id : constant Task_Id := Self;
begin
-  --  Defer abort. Note that we use the nestable versions of Defer_Abort
-  --  and Undefer_Abort, because abort can already deferred when this is
-  --  called during finalization, which would cause an assert failure
-  --  in Defer_Abort.
+  Task_Lock (Self_Id);
 
-  Defer_Abort_Nestable (Self_Id);
-  Lock_RTS;
-
-  --  Remove this instantiation from the list of all instantiations
-
-  declare
- P : Access_Instance;
- Q : Access_Instance := All_Attributes;
-
-  begin
- while Q /= null and then Q /= X'Unchecked_Access loop
-P := Q; Q := Q.Next;
- end loop;
-
- pragma Assert (Q /= null);
-
- if P = null then
-All_Attributes := Q.Next;
- else
-P.Next := Q.Next;
+  for J in Index_Array'Range loop
+ if not Index_Array (J).Used then
+Index_Array (J).Used := True;
+Index_Array (J).R

RE: [PATCH, Fortan] fix initialization of flag_errno_math and flag_associative_math

2014-07-30 Thread VandeVondele Joost
Dominque, 

after Janne's OK, and FX judgement, I wonder if you have reached a conclusion. 
If so, the fsf assignment is now complete, and the patch could be applied.

Joost

> Ok for trunk. Thanks!

Please don't rush! The behavior of -fno-signed-zeros -fno-trapping-math
implying associative math has been changed (as in reverted) between r165758
(implied associative math) and r165930 (lost associative math). AFAICT
it could be due to 165823. Investigating! I am also lookinf for the introduction
of *frontend_set*.

TIA

Dominique


Re: [PATCH v3 3/3] Port libstdc++ pretty-printers to Python 2 + Python 3

2014-07-30 Thread Tom Tromey
>> I don't think this comment is applicable.
>> The libstdc++ pretty-printers use gdb.Value.lazy_string, not the
>> built-in Python types.

Samuel> Hmm, doesn't that just make it a timebomb -- a value that will
Samuel> explode if, at some point in the future, someone tries to treat
Samuel> it as a string?

I don't think so.
The results from the pretty-printer, when called from gdb, are generally
either printed or discarded.
In any case the comment still doesn't seem correct.

Tom


[Ada] Ability to compute range of floating-point expression for analyzers

2014-07-30 Thread Arnaud Charlet
Analyzers based on the frontend can benefit from knowing the range of
possible values of a floating-point expression. For example, it might be
useful to decide that a range check or an overflow check cannot fail.
Implement such a procedure Determine_Range_R in checks.adb, similar to
the existing Determine_Range. Make it handle all cases of multiplication
and division. This is only available for IEEE floating-point types, and
should be used only when switches enforce that extended precision is not
used at run time.

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

2014-07-30  Yannick Moy  

* checks.adb, checks.ads (Determine_Range_R): New procedure to
determine the possible range of a floating-point expression.

Index: checks.adb
===
--- checks.adb  (revision 213264)
+++ checks.adb  (working copy)
@@ -61,7 +61,6 @@
 with Targparm; use Targparm;
 with Tbuild;   use Tbuild;
 with Ttypes;   use Ttypes;
-with Urealp;   use Urealp;
 with Validsw;  use Validsw;
 
 package body Checks is
@@ -4076,18 +4075,20 @@
type Cache_Index is range 0 .. Cache_Size - 1;
--  Determine size of below cache (power of 2 is more efficient)
 
-   Determine_Range_Cache_N  : array (Cache_Index) of Node_Id;
-   Determine_Range_Cache_V  : array (Cache_Index) of Boolean;
-   Determine_Range_Cache_Lo : array (Cache_Index) of Uint;
-   Determine_Range_Cache_Hi : array (Cache_Index) of Uint;
+   Determine_Range_Cache_N: array (Cache_Index) of Node_Id;
+   Determine_Range_Cache_V: array (Cache_Index) of Boolean;
+   Determine_Range_Cache_Lo   : array (Cache_Index) of Uint;
+   Determine_Range_Cache_Hi   : array (Cache_Index) of Uint;
+   Determine_Range_Cache_Lo_R : array (Cache_Index) of Ureal;
+   Determine_Range_Cache_Hi_R : array (Cache_Index) of Ureal;
--  The above arrays are used to implement a small direct cache for
-   --  Determine_Range calls. Because of the way Determine_Range recursively
-   --  traces subexpressions, and because overflow checking calls the routine
-   --  on the way up the tree, a quadratic behavior can otherwise be
-   --  encountered in large expressions. The cache entry for node N is stored
-   --  in the (N mod Cache_Size) entry, and can be validated by checking the
-   --  actual node value stored there. The Range_Cache_V array records the
-   --  setting of Assume_Valid for the cache entry.
+   --  Determine_Range and Determine_Range_R calls. Because of the way these
+   --  subprograms recursively traces subexpressions, and because overflow
+   --  checking calls the routine on the way up the tree, a quadratic behavior
+   --  can otherwise be encountered in large expressions. The cache entry for
+   --  node N is stored in the (N mod Cache_Size) entry, and can be validated
+   --  by checking the actual node value stored there. The Range_Cache_V array
+   --  records the setting of Assume_Valid for the cache entry.
 
procedure Determine_Range
  (N: Node_Id;
@@ -4544,7 +4545,7 @@
   if OK1 then
 
  --  If the refined value of the low bound is greater than the type
- --  high bound, then reset it to the more restrictive value. However,
+ --  low bound, then reset it to the more restrictive value. However,
  --  we do NOT do this for the case of a modular type where the
  --  possible upper bound on the value is above the base type high
  --  bound, because that means the result could wrap.
@@ -4596,6 +4597,427 @@
  end if;
end Determine_Range;
 
+   ---
+   -- Determine_Range_R --
+   ---
+
+   procedure Determine_Range_R
+ (N: Node_Id;
+  OK   : out Boolean;
+  Lo   : out Ureal;
+  Hi   : out Ureal;
+  Assume_Valid : Boolean := False)
+   is
+  Typ : Entity_Id := Etype (N);
+  --  Type to use, may get reset to base type for possibly invalid entity
+
+  Lo_Left : Ureal;
+  Hi_Left : Ureal;
+  --  Lo and Hi bounds of left operand
+
+  Lo_Right : Ureal;
+  Hi_Right : Ureal;
+  --  Lo and Hi bounds of right (or only) operand
+
+  Bound : Node_Id;
+  --  Temp variable used to hold a bound node
+
+  Hbound : Ureal;
+  --  High bound of base type of expression
+
+  Lor : Ureal;
+  Hir : Ureal;
+  --  Refined values for low and high bounds, after tightening
+
+  OK1 : Boolean;
+  --  Used in lower level calls to indicate if call succeeded
+
+  Cindex : Cache_Index;
+  --  Used to search cache
+
+  Btyp : Entity_Id;
+  --  Base type
+
+  function OK_Operands return Boolean;
+  --  Used for binary operators. Determines the ranges of the left and
+  --  right operands, and if they are both OK, returns True, and puts
+  --  the results in Lo_Right, Hi_Right, Lo_Left, Hi_Left.
+
+  function Round_Machine (B : Ureal) return Ureal;
+  -

RE: [PATCH, Fortran] PR61234: -Wuse-no-only

2014-07-30 Thread VandeVondele Joost
>> This explicitly tests that no bogus error message is issued
>> for a use statement that has an only qualifier ?
>
>I don't see the need for '! { dg-bogus "has no ONLY qualifier" }'.
>AFAICT there is no warning emitted for this line (unless you add -Wall)
>and if some day it happens that an error/warning is issued, the test will fail.
>
>Otherwise the new patch is OK for me.

if so, could the patch be applied by somebody with svn write permission (with 
or without the dg-bogus), fsf assignment is now OK.

Joost

Updated inchash patchkit

2014-07-30 Thread Andi Kleen
This version adds the new namespace as requested by Ritchie.
I couldn't use hash:: due to name space conflicts, but
(nearly) everything is now inchash::... 

This needed some changes in the existing files. I did all
the renamings atomically in one patch to avoid non buildable
commits.

Also I removed the unwanted comment in dwarf2out.

Passed bootstrap and testing on x86_64-linux.



[PATCH 4/7] Convert ipa-devirt to inchash

2014-07-30 Thread Andi Kleen
From: Andi Kleen 

gcc/:

2014-07-30  Andi Kleen  

* ipa-devirt.c (polymorphic_call_target_hasher::hash):
Convert to inchash.
---
 gcc/ipa-devirt.c | 27 ---
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index 4b5b2a6..fc2c31f 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -1635,25 +1635,22 @@ struct polymorphic_call_target_hasher
 inline hashval_t
 polymorphic_call_target_hasher::hash (const value_type *odr_query)
 {
-  hashval_t hash;
+  inchash::hash hstate (odr_query->otr_token);
+
+  hstate.add_wide_int (odr_query->type->id);
+  hstate.merge_hash (TYPE_UID (odr_query->context.outer_type));
+  hstate.add_wide_int (odr_query->context.offset);
 
-  hash = iterative_hash_host_wide_int
- (odr_query->otr_token,
-  odr_query->type->id);
-  hash = iterative_hash_hashval_t (TYPE_UID (odr_query->context.outer_type),
-  hash);
-  hash = iterative_hash_host_wide_int (odr_query->context.offset, hash);
   if (odr_query->context.speculative_outer_type)
 {
-  hash = iterative_hash_hashval_t
-  (TYPE_UID (odr_query->context.speculative_outer_type), hash);
-  hash = iterative_hash_host_wide_int 
(odr_query->context.speculative_offset,
-  hash);
+  hstate.merge_hash (TYPE_UID (odr_query->context.speculative_outer_type));
+  hstate.add_wide_int (odr_query->context.speculative_offset);
 }
-  return iterative_hash_hashval_t
-   (((int)odr_query->context.maybe_in_construction << 2)
-| ((int)odr_query->context.speculative_maybe_derived_type << 1)
-| (int)odr_query->context.maybe_derived_type, hash);
+  hstate.add_flag (odr_query->context.maybe_in_construction);
+  hstate.add_flag (odr_query->context.maybe_derived_type);
+  hstate.add_flag (odr_query->context.speculative_maybe_derived_type);
+  hstate.commit_flag ();
+  return hstate.end ();
 }
 
 /* Compare cache entries T1 and T2.  */
-- 
2.0.1



[PATCH 1/7] Change inchash to name space.

2014-07-30 Thread Andi Kleen
From: Andi Kleen 

Change class inchash to move into a inchash namespace as requested.
The class is now inchash::hash

Rename iterative_hstate_expr to inchash::add_expr
... and convert existing users. It wasn't possible to use hash::,
because that lead to name space conflicts with cp and objc.

So class inchash is now inchash::hash and iterative_hstate_expr
is now inchash::add_expr.

gcc/:

2014-07-30  Andi Kleen  

* inchash.h (inchash): Change inchash class to namespace.
(class hash): ... Rename from inchash.
(add_object): Move from macro to class template.
* lto-streamer-out.c (hash_tree): Change inchash
to inchash::hash.
* tree.c (build_type_attribute_qual_variant): Dito.
(type_hash_list): Dito.
(attribute_hash_list): Dito.
(iterative_hstate_expr): Rename to inchash::add_expr
(build_range_type_1): Change inchash to inchash::hash
and use hash::add_expr.
(build_array_type_1): Dito.
(build_function_type): Dito
(build_method_type_directly): Dito.
(build_offset_type): Dito.
(build_complex_type): Dito.
(make_vector_type): Dito.
* tree.h (iterative_hash_expr): Dito.

gcc/lto/:

2014-07-30  Andi Kleen  

* lto.c (hash_canonical_type): Use inchash::hash
and use inchash::add_expr.
(iterative_hash_canonical_type): Dito.
---
 gcc/inchash.h  | 18 +++-
 gcc/lto-streamer-out.c |  2 +-
 gcc/lto/lto.c  | 10 -
 gcc/tree.c | 57 +++---
 gcc/tree.h | 12 ---
 5 files changed, 59 insertions(+), 40 deletions(-)

diff --git a/gcc/inchash.h b/gcc/inchash.h
index 7af0baa..c157e30 100644
--- a/gcc/inchash.h
+++ b/gcc/inchash.h
@@ -35,12 +35,15 @@ along with GCC; see the file COPYING3.  If not see
 extern hashval_t iterative_hash_host_wide_int (HOST_WIDE_INT, hashval_t);
 extern hashval_t iterative_hash_hashval_t (hashval_t, hashval_t);
 
-class inchash
+namespace inchash
+{
+
+class hash
 {
  public:
 
   /* Start incremential hashing, optionally with SEED.  */
-  inchash (hashval_t seed = 0)
+  hash (hashval_t seed = 0)
   {
 val = seed;
 bits = 0;
@@ -83,11 +86,16 @@ class inchash
   }
 
   /* Hash in state from other inchash OTHER.  */
-  void merge (inchash &other)
+  void merge (hash &other)
   {
 merge_hash (other.val);
   }
 
+  template void add_object(T &obj)
+  {
+add (&obj, sizeof(T));
+  }
+
   /* Support for accumulating boolean flags */
 
   void add_flag (bool flag)
@@ -105,7 +113,7 @@ class inchash
  based on their value. This is useful for hashing commutative
  expressions, so that A+B and B+A get the same hash.  */
 
-  void add_commutative (inchash &a, inchash &b)
+  void add_commutative (hash &a, hash &b)
   {
 if (a.end() > b.end())
   {
@@ -124,6 +132,6 @@ class inchash
   unsigned bits;
 };
 
-#define add_object(o) add (&(o), sizeof (o))
+}
 
 #endif
diff --git a/gcc/lto-streamer-out.c b/gcc/lto-streamer-out.c
index 271fbd5..71521f5 100644
--- a/gcc/lto-streamer-out.c
+++ b/gcc/lto-streamer-out.c
@@ -732,7 +732,7 @@ DFS::DFS_write_tree_body (struct output_block *ob,
 static hashval_t
 hash_tree (struct streamer_tree_cache_d *cache, hash_map 
*map, tree t)
 {
-  inchash hstate;
+  inchash::hash hstate;
 
 #define visit(SIBLING) \
   do { \
diff --git a/gcc/lto/lto.c b/gcc/lto/lto.c
index 2de00fb..7ecdec2 100644
--- a/gcc/lto/lto.c
+++ b/gcc/lto/lto.c
@@ -267,7 +267,7 @@ static hash_map 
*canonical_type_hash_cache;
 static unsigned long num_canonical_type_hash_entries;
 static unsigned long num_canonical_type_hash_queries;
 
-static void iterative_hash_canonical_type (tree type, inchash &hstate);
+static void iterative_hash_canonical_type (tree type, inchash::hash &hstate);
 static hashval_t gimple_canonical_type_hash (const void *p);
 static void gimple_register_canonical_type_1 (tree t, hashval_t hash);
 
@@ -279,7 +279,7 @@ static void gimple_register_canonical_type_1 (tree t, 
hashval_t hash);
 static hashval_t
 hash_canonical_type (tree type)
 {
-  inchash hstate;
+  inchash::hash hstate;
 
   /* Combine a few common features of types so that types are grouped into
  smaller sets; when searching for existing matching types to merge,
@@ -327,9 +327,9 @@ hash_canonical_type (tree type)
   /* OMP lowering can introduce error_mark_node in place of
 random local decls in types.  */
   if (TYPE_MIN_VALUE (TYPE_DOMAIN (type)) != error_mark_node)
-   iterative_hstate_expr (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), hstate);
+   inchash::add_expr (TYPE_MIN_VALUE (TYPE_DOMAIN (type)), hstate);
   if (TYPE_MAX_VALUE (TYPE_DOMAIN (type)) != error_mark_node)
-   iterative_hstate_expr (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), hstate);
+   inchash::add_expr (TYPE_MAX_VALUE (TYPE_DOMAIN (type)), hstate);
 }
 
   /* Recurse for aggregates with a single element type.  */
@@ -380,7 +

[PATCH 2/7] RTL & dwarf2out changes

2014-07-30 Thread Andi Kleen
From: Andi Kleen 

Convert dwarf2out and rtl.c to the new inchash interface.

I moved the rtl hash code to another file to avoid having to link
all the hash code into the generator functions.

v2: Removed ??? comment.

gcc/:

2014-07-29  Andi Kleen  

* Makefile.in (OBJS): Add rtlhash.o
* dwarf2out.c (addr_table_entry_do_hash): Convert to inchash.
(loc_checksum): Dito.
(loc_checksum_ordered): Dito.
(hash_loc_operands): Dito.
(hash_locs): Dito.
(hash_loc_list): Dito.
* rtl.c (iterative_hash_rtx): Moved to rtlhash.c
* rtl.h (iterative_hash_rtx): Moved to rtlhash.h
* rtlhash.c: New file.
* rtlhash.h: New file.
---
 gcc/Makefile.in |   1 +
 gcc/dwarf2out.c | 125 +---
 gcc/rtl.c   |  79 +--
 gcc/rtl.h   |   1 -
 gcc/rtlhash.c   | 107 
 gcc/rtlhash.h   |  32 +++
 6 files changed, 206 insertions(+), 139 deletions(-)
 create mode 100644 gcc/rtlhash.c
 create mode 100644 gcc/rtlhash.h

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 4c578b3..a2fb5f5 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1350,6 +1350,7 @@ OBJS = \
resource.o \
rtl-error.o \
rtl.o \
+   rtlhash.o \
rtlanal.o \
rtlhooks.o \
sbitmap.o \
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 8fd1945..f90329b 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -71,6 +71,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "flags.h"
 #include "hard-reg-set.h"
 #include "regs.h"
+#include "rtlhash.h"
 #include "insn-config.h"
 #include "reload.h"
 #include "function.h"
@@ -3277,7 +3278,7 @@ static void gen_scheduled_generic_parms_dies (void);
 
 static const char *comp_dir_string (void);
 
-static hashval_t hash_loc_operands (dw_loc_descr_ref, hashval_t);
+static void hash_loc_operands (dw_loc_descr_ref, inchash::hash &);
 
 /* enum for tracking thread-local variables whose address is really an offset
relative to the TLS pointer, which will need link-time relocation, but will
@@ -4190,17 +4191,22 @@ static hashval_t
 addr_table_entry_do_hash (const void *x)
 {
   const addr_table_entry *a = (const addr_table_entry *) x;
+  inchash::hash hstate;
   switch (a->kind)
 {
   case ate_kind_rtx:
-return iterative_hash_rtx (a->addr.rtl, 0);
+   hstate.add_int (0);
+   break;
   case ate_kind_rtx_dtprel:
-return iterative_hash_rtx (a->addr.rtl, 1);
+   hstate.add_int (1);
+   break;
   case ate_kind_label:
 return htab_hash_string (a->addr.label);
   default:
 gcc_unreachable ();
 }
+  inchash::add_rtx (a->addr.rtl, hstate);
+  return hstate.end ();
 }
 
 /* Determine equality for two address_table_entries.  */
@@ -5544,11 +5550,13 @@ static inline void
 loc_checksum (dw_loc_descr_ref loc, struct md5_ctx *ctx)
 {
   int tem;
-  hashval_t hash = 0;
+  inchash::hash hstate;
+  hashval_t hash;
 
   tem = (loc->dtprel << 8) | ((unsigned int) loc->dw_loc_opc);
   CHECKSUM (tem);
-  hash = hash_loc_operands (loc, hash);
+  hash_loc_operands (loc, hstate);
+  hash = hstate.end();
   CHECKSUM (hash);
 }
 
@@ -5758,11 +5766,13 @@ loc_checksum_ordered (dw_loc_descr_ref loc, struct 
md5_ctx *ctx)
   /* Otherwise, just checksum the raw location expression.  */
   while (loc != NULL)
 {
-  hashval_t hash = 0;
+  inchash::hash hstate;
+  hashval_t hash;
 
   CHECKSUM_ULEB128 (loc->dtprel);
   CHECKSUM_ULEB128 (loc->dw_loc_opc);
-  hash = hash_loc_operands (loc, hash);
+  hash_loc_operands (loc, hstate);
+  hash = hstate.end ();
   CHECKSUM (hash);
   loc = loc->dw_loc_next;
 }
@@ -23619,10 +23629,10 @@ resolve_addr (dw_die_ref die)
This pass tries to share identical local lists in .debug_loc
section.  */
 
-/* Iteratively hash operands of LOC opcode.  */
+/* Iteratively hash operands of LOC opcode into HSTATE.  */
 
-static hashval_t
-hash_loc_operands (dw_loc_descr_ref loc, hashval_t hash)
+static void
+hash_loc_operands (dw_loc_descr_ref loc, inchash::hash &hstate)
 {
   dw_val_ref val1 = &loc->dw_loc_oprnd1;
   dw_val_ref val2 = &loc->dw_loc_oprnd2;
@@ -23681,7 +23691,7 @@ hash_loc_operands (dw_loc_descr_ref loc, hashval_t hash)
 case DW_OP_piece:
 case DW_OP_deref_size:
 case DW_OP_xderef_size:
-  hash = iterative_hash_object (val1->v.val_int, hash);
+  hstate.add_object (val1->v.val_int);
   break;
 case DW_OP_skip:
 case DW_OP_bra:
@@ -23690,36 +23700,35 @@ hash_loc_operands (dw_loc_descr_ref loc, hashval_t 
hash)
 
gcc_assert (val1->val_class == dw_val_class_loc);
offset = val1->v.val_loc->dw_loc_addr - (loc->dw_loc_addr + 3);
-   hash = iterative_hash_object (offset, hash);
+   hstate.add_object (offset);
   }
   break;
 case DW_OP_implicit_value:
- 

[PATCH 5/7] Convert tree-ssa-dom to inchash

2014-07-30 Thread Andi Kleen
From: Andi Kleen 

gcc/:

2014-07-29  Andi Kleen  

* tree-ssa-dom.c (iterative_hash_exprs_commutative):
Rename to inchash:add_expr_commutative. Convert to inchash.
(iterative_hash_hashable_expr): Rename to
inchash:add_hashable_expr. Convert to inchash.
(avail_expr_hash): Dito.
---
 gcc/tree-ssa-dom.c | 81 ++
 1 file changed, 39 insertions(+), 42 deletions(-)

diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index 08fd2fa..fec386e 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -55,6 +55,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "params.h"
 #include "tree-ssa-threadedge.h"
 #include "tree-ssa-dom.h"
+#include "inchash.h"
 
 /* This file implements optimizations on the dominator tree.  */
 
@@ -557,45 +558,42 @@ hashable_expr_equal_p (const struct hashable_expr *expr0,
 }
 
 /* Generate a hash value for a pair of expressions.  This can be used
-   iteratively by passing a previous result as the VAL argument.
+   iteratively by passing a previous result in HSTATE.
 
The same hash value is always returned for a given pair of expressions,
regardless of the order in which they are presented.  This is useful in
hashing the operands of commutative functions.  */
 
-static hashval_t
-iterative_hash_exprs_commutative (const_tree t1,
-  const_tree t2, hashval_t val)
+namespace inchash
 {
-  hashval_t one = iterative_hash_expr (t1, 0);
-  hashval_t two = iterative_hash_expr (t2, 0);
-  hashval_t t;
 
-  if (one > two)
-t = one, one = two, two = t;
-  val = iterative_hash_hashval_t (one, val);
-  val = iterative_hash_hashval_t (two, val);
+static void
+add_expr_commutative (const_tree t1, const_tree t2, hash &hstate)
+{
+  hash one, two;
 
-  return val;
+  inchash::add_expr (t1, one);
+  inchash::add_expr (t2, two);
+  hstate.add_commutative (one, two);
 }
 
 /* Compute a hash value for a hashable_expr value EXPR and a
previously accumulated hash value VAL.  If two hashable_expr
values compare equal with hashable_expr_equal_p, they must
hash to the same value, given an identical value of VAL.
-   The logic is intended to follow iterative_hash_expr in tree.c.  */
+   The logic is intended to follow inchash::add_expr in tree.c.  */
 
-static hashval_t
-iterative_hash_hashable_expr (const struct hashable_expr *expr, hashval_t val)
+static void
+add_hashable_expr (const struct hashable_expr *expr, hash &hstate)
 {
   switch (expr->kind)
 {
 case EXPR_SINGLE:
-  val = iterative_hash_expr (expr->ops.single.rhs, val);
+  inchash::add_expr (expr->ops.single.rhs, hstate);
   break;
 
 case EXPR_UNARY:
-  val = iterative_hash_object (expr->ops.unary.op, val);
+  hstate.add_object (expr->ops.unary.op);
 
   /* Make sure to include signedness in the hash computation.
  Don't hash the type, that can lead to having nodes which
@@ -603,34 +601,34 @@ iterative_hash_hashable_expr (const struct hashable_expr 
*expr, hashval_t val)
  have different hash codes.  */
   if (CONVERT_EXPR_CODE_P (expr->ops.unary.op)
   || expr->ops.unary.op == NON_LVALUE_EXPR)
-val += TYPE_UNSIGNED (expr->type);
+hstate.add_int (TYPE_UNSIGNED (expr->type));
 
-  val = iterative_hash_expr (expr->ops.unary.opnd, val);
+  inchash::add_expr (expr->ops.unary.opnd, hstate);
   break;
 
 case EXPR_BINARY:
-  val = iterative_hash_object (expr->ops.binary.op, val);
+  hstate.add_object (expr->ops.binary.op);
   if (commutative_tree_code (expr->ops.binary.op))
-   val = iterative_hash_exprs_commutative (expr->ops.binary.opnd0,
-   expr->ops.binary.opnd1, val);
+   inchash::add_expr_commutative (expr->ops.binary.opnd0,
+ expr->ops.binary.opnd1, hstate);
   else
 {
-  val = iterative_hash_expr (expr->ops.binary.opnd0, val);
-  val = iterative_hash_expr (expr->ops.binary.opnd1, val);
+  inchash::add_expr (expr->ops.binary.opnd0, hstate);
+  inchash::add_expr (expr->ops.binary.opnd1, hstate);
 }
   break;
 
 case EXPR_TERNARY:
-  val = iterative_hash_object (expr->ops.ternary.op, val);
+  hstate.add_object (expr->ops.ternary.op);
   if (commutative_ternary_tree_code (expr->ops.ternary.op))
-   val = iterative_hash_exprs_commutative (expr->ops.ternary.opnd0,
-   expr->ops.ternary.opnd1, val);
+   inchash::add_expr_commutative (expr->ops.ternary.opnd0,
+ expr->ops.ternary.opnd1, hstate);
   else
 {
-  val = iterative_hash_expr (expr->ops.ternary.opnd0, val);
-  val = iterative_hash_expr (expr->ops.ternary.opnd1, val);
+  inchash::add_expr (expr->ops.ternary.opnd0, hstate);
+  inchash:

[PATCH 6/7] Convert tree-ssa-sccvn to inchash

2014-07-30 Thread Andi Kleen
From: Andi Kleen 

gcc/:

2014-07-29  Andi Kleen  

* tree-ssa-sccvn.c (vn_reference_op_compute_hash): Convert to
inchash.
(vn_reference_compute_hash): Dito.
(vn_nary_op_compute_hash): Dito.
(vn_phi_compute_hash): Dito.
* tree-ssa-sccvn.h (vn_hash_constant_with_type): Dito.
---
 gcc/tree-ssa-sccvn.c | 44 ++--
 gcc/tree-ssa-sccvn.h |  6 --
 2 files changed, 26 insertions(+), 24 deletions(-)

diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 93314fc..ec0bf6b 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -594,17 +594,16 @@ value_id_constant_p (unsigned int v)
 
 /* Compute the hash for a reference operand VRO1.  */
 
-static hashval_t
-vn_reference_op_compute_hash (const vn_reference_op_t vro1, hashval_t result)
+static void
+vn_reference_op_compute_hash (const vn_reference_op_t vro1, inchash::hash 
&hstate)
 {
-  result = iterative_hash_hashval_t (vro1->opcode, result);
+  hstate.add_int (vro1->opcode);
   if (vro1->op0)
-result = iterative_hash_expr (vro1->op0, result);
+inchash::add_expr (vro1->op0, hstate);
   if (vro1->op1)
-result = iterative_hash_expr (vro1->op1, result);
+inchash::add_expr (vro1->op1, hstate);
   if (vro1->op2)
-result = iterative_hash_expr (vro1->op2, result);
-  return result;
+inchash::add_expr (vro1->op2, hstate);
 }
 
 /* Compute a hash for the reference operation VR1 and return it.  */
@@ -612,7 +611,8 @@ vn_reference_op_compute_hash (const vn_reference_op_t vro1, 
hashval_t result)
 hashval_t
 vn_reference_compute_hash (const vn_reference_t vr1)
 {
-  hashval_t result = 0;
+  inchash::hash hstate;
+  hashval_t result;
   int i;
   vn_reference_op_t vro;
   HOST_WIDE_INT off = -1;
@@ -634,7 +634,7 @@ vn_reference_compute_hash (const vn_reference_t vr1)
{
  if (off != -1
  && off != 0)
-   result = iterative_hash_hashval_t (off, result);
+   hstate.add_int (off);
  off = -1;
  if (deref
  && vro->opcode == ADDR_EXPR)
@@ -642,14 +642,16 @@ vn_reference_compute_hash (const vn_reference_t vr1)
  if (vro->op0)
{
  tree op = TREE_OPERAND (vro->op0, 0);
- result = iterative_hash_hashval_t (TREE_CODE (op), result);
- result = iterative_hash_expr (op, result);
+ hstate.add_int (TREE_CODE (op));
+ inchash::add_expr (op, hstate);
}
}
  else
-   result = vn_reference_op_compute_hash (vro, result);
+   vn_reference_op_compute_hash (vro, hstate);
}
 }
+  result = hstate.end ();
+  /* ??? We would ICE later if we hash instead of adding that in. */
   if (vr1->vuse)
 result += SSA_NAME_VERSION (vr1->vuse);
 
@@ -2236,7 +2238,7 @@ vn_reference_insert_pieces (tree vuse, alias_set_type 
set, tree type,
 hashval_t
 vn_nary_op_compute_hash (const vn_nary_op_t vno1)
 {
-  hashval_t hash;
+  inchash::hash hstate;
   unsigned i;
 
   for (i = 0; i < vno1->length; ++i)
@@ -2252,11 +2254,11 @@ vn_nary_op_compute_hash (const vn_nary_op_t vno1)
   vno1->op[1] = temp;
 }
 
-  hash = iterative_hash_hashval_t (vno1->opcode, 0);
+  hstate.add_int (vno1->opcode);
   for (i = 0; i < vno1->length; ++i)
-hash = iterative_hash_expr (vno1->op[i], hash);
+inchash::add_expr (vno1->op[i], hstate);
 
-  return hash;
+  return hstate.end ();
 }
 
 /* Compare nary operations VNO1 and VNO2 and return true if they are
@@ -2536,26 +2538,24 @@ vn_nary_op_insert_stmt (gimple stmt, tree result)
 static inline hashval_t
 vn_phi_compute_hash (vn_phi_t vp1)
 {
-  hashval_t result;
+  inchash::hash hstate (vp1->block->index);
   int i;
   tree phi1op;
   tree type;
 
-  result = vp1->block->index;
-
   /* If all PHI arguments are constants we need to distinguish
  the PHI node via its type.  */
   type = vp1->type;
-  result += vn_hash_type (type);
+  hstate.merge_hash (vn_hash_type (type));
 
   FOR_EACH_VEC_ELT (vp1->phiargs, i, phi1op)
 {
   if (phi1op == VN_TOP)
continue;
-  result = iterative_hash_expr (phi1op, result);
+  inchash::add_expr (phi1op, hstate);
 }
 
-  return result;
+  return hstate.end ();
 }
 
 /* Compare two phi entries for equality, ignoring VN_TOP arguments.  */
diff --git a/gcc/tree-ssa-sccvn.h b/gcc/tree-ssa-sccvn.h
index f52783a..84ea278 100644
--- a/gcc/tree-ssa-sccvn.h
+++ b/gcc/tree-ssa-sccvn.h
@@ -140,8 +140,10 @@ vn_hash_type (tree type)
 static inline hashval_t
 vn_hash_constant_with_type (tree constant)
 {
-  return (iterative_hash_expr (constant, 0)
- + vn_hash_type (TREE_TYPE (constant)));
+  inchash::hash hstate;
+  inchash::add_expr (constant, hstate);
+  hstate.merge_hash (vn_hash_type (TREE_TYPE (constant)));
+  return hstate.end ();
 }
 
 /* Compare the constants C1 and C2 with distinguishing type incompatible
-- 
2.0.1



[PATCH 3/7] Convert asan.c to inchash

2014-07-30 Thread Andi Kleen
From: Andi Kleen 

gcc/:

2014-07-30  Andi Kleen  

* asan.c (asan_mem_ref_hasher::hash): Convert to inchash.
---
 gcc/asan.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/gcc/asan.c b/gcc/asan.c
index 475dd82..4f882b5 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -348,9 +348,10 @@ struct asan_mem_ref_hasher
 inline hashval_t
 asan_mem_ref_hasher::hash (const asan_mem_ref *mem_ref)
 {
-  hashval_t h = iterative_hash_expr (mem_ref->start, 0);
-  h = iterative_hash_host_wide_int (mem_ref->access_size, h);
-  return h;
+  inchash::hash hstate;
+  inchash::add_expr (mem_ref->start, hstate);
+  hstate.add_wide_int (mem_ref->access_size);
+  return hstate.end ();
 }
 
 /* Compare two memory references.  We accept the length of either
-- 
2.0.1



[PATCH 7/7] Convert tree-ssa-tail-merge to inchash

2014-07-30 Thread Andi Kleen
From: Andi Kleen 

gcc/:

2014-07-29  Andi Kleen  

* tree-ssa-tail-merge.c (same_succ_hash): Convert to inchash.
---
 gcc/tree-ssa-tail-merge.c | 22 ++
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/gcc/tree-ssa-tail-merge.c b/gcc/tree-ssa-tail-merge.c
index 9600e28..962a92b 100644
--- a/gcc/tree-ssa-tail-merge.c
+++ b/gcc/tree-ssa-tail-merge.c
@@ -451,7 +451,7 @@ stmt_update_dep_bb (gimple stmt)
 static hashval_t
 same_succ_hash (const_same_succ e)
 {
-  hashval_t hashval = bitmap_hash (e->succs);
+  inchash::hash hstate (bitmap_hash (e->succs));
   int flags;
   unsigned int i;
   unsigned int first = bitmap_first_set_bit (e->bbs);
@@ -472,37 +472,35 @@ same_succ_hash (const_same_succ e)
continue;
   size++;
 
-  hashval = iterative_hash_hashval_t (gimple_code (stmt), hashval);
+  hstate.add_int (gimple_code (stmt));
   if (is_gimple_assign (stmt))
-   hashval = iterative_hash_hashval_t (gimple_assign_rhs_code (stmt),
-   hashval);
+   hstate.add_int (gimple_assign_rhs_code (stmt));
   if (!is_gimple_call (stmt))
continue;
   if (gimple_call_internal_p (stmt))
-   hashval = iterative_hash_hashval_t
- ((hashval_t) gimple_call_internal_fn (stmt), hashval);
+hstate.add_int (gimple_call_internal_fn (stmt));
   else
{
- hashval = iterative_hash_expr (gimple_call_fn (stmt), hashval);
+ inchash::add_expr (gimple_call_fn (stmt), hstate);
  if (gimple_call_chain (stmt))
-   hashval = iterative_hash_expr (gimple_call_chain (stmt), hashval);
+   inchash::add_expr (gimple_call_chain (stmt), hstate);
}
   for (i = 0; i < gimple_call_num_args (stmt); i++)
{
  arg = gimple_call_arg (stmt, i);
  arg = vn_valueize (arg);
- hashval = iterative_hash_expr (arg, hashval);
+ inchash::add_expr (arg, hstate);
}
 }
 
-  hashval = iterative_hash_hashval_t (size, hashval);
+  hstate.add_int (size);
   BB_SIZE (bb) = size;
 
   for (i = 0; i < e->succ_flags.length (); ++i)
 {
   flags = e->succ_flags[i];
   flags = flags & ~(EDGE_TRUE_VALUE | EDGE_FALSE_VALUE);
-  hashval = iterative_hash_hashval_t (flags, hashval);
+  hstate.add_int (flags);
 }
 
   EXECUTE_IF_SET_IN_BITMAP (e->succs, 0, s, bs)
@@ -521,7 +519,7 @@ same_succ_hash (const_same_succ e)
}
 }
 
-  return hashval;
+  return hstate.end ();
 }
 
 /* Returns true if E1 and E2 have 2 successors, and if the successor flags
-- 
2.0.1



[Ada] Internal cleanups in Cstand

2014-07-30 Thread Arnaud Charlet
The name of raise type was "any type", it is now "raise type"

We now the name before setting other fields of standard entities,
which avoids debugger blowups printing the entity when setting
one of these fields.

These are minor internal imrpovements for front-end debugging,
no external effect, no test required.

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

2014-07-30  Robert Dewar  

* cstand.adb (New_Standard_Entity): New version takes name
string to call Make_Name.
(Create_Standard): Use this routine to set name before setting other
fields.

Index: cstand.adb
===
--- cstand.adb  (revision 213263)
+++ cstand.adb  (working copy)
@@ -151,6 +151,10 @@
  (New_Node_Kind : Node_Kind := N_Defining_Identifier) return Entity_Id;
--  Builds a new entity for Standard
 
+   function New_Standard_Entity (S : String) return Entity_Id;
+   --  Builds a new entity for Standard with Nkind = N_Defining_Identifier,
+   --  and Chars of this defining identifier set to the given string S.
+
procedure Print_Standard;
--  Print representation of package Standard if switch set
 
@@ -1204,30 +1208,27 @@
   --  filled out to minimize problems with cascaded errors (for example,
   --  Any_Integer is given reasonable and consistent type and size values)
 
-  Any_Type := New_Standard_Entity;
+  Any_Type := New_Standard_Entity ("any type");
   Decl := New_Node (N_Full_Type_Declaration, Stloc);
   Set_Defining_Identifier (Decl, Any_Type);
   Set_Scope (Any_Type, Standard_Standard);
   Build_Signed_Integer_Type (Any_Type, Standard_Integer_Size);
-  Make_Name (Any_Type, "any type");
 
-  Any_Id := New_Standard_Entity;
+  Any_Id := New_Standard_Entity ("any id");
   Set_Ekind (Any_Id, E_Variable);
   Set_Scope (Any_Id, Standard_Standard);
   Set_Etype (Any_Id, Any_Type);
   Init_Esize(Any_Id);
   Init_Alignment(Any_Id);
-  Make_Name (Any_Id, "any id");
 
-  Any_Access := New_Standard_Entity;
+  Any_Access := New_Standard_Entity ("an access type");
   Set_Ekind (Any_Access, E_Access_Type);
   Set_Scope (Any_Access, Standard_Standard);
   Set_Etype (Any_Access, Any_Access);
   Init_Size (Any_Access, System_Address_Size);
   Set_Elem_Alignment(Any_Access);
-  Make_Name (Any_Access, "an access type");
 
-  Any_Character := New_Standard_Entity;
+  Any_Character := New_Standard_Entity ("a character type");
   Set_Ekind (Any_Character, E_Enumeration_Type);
   Set_Scope (Any_Character, Standard_Standard);
   Set_Etype (Any_Character, Any_Character);
@@ -1237,18 +1238,16 @@
   Init_RM_Size  (Any_Character, 8);
   Set_Elem_Alignment(Any_Character);
   Set_Scalar_Range  (Any_Character, Scalar_Range (Standard_Character));
-  Make_Name (Any_Character, "a character type");
 
-  Any_Array := New_Standard_Entity;
+  Any_Array := New_Standard_Entity ("an array type");
   Set_Ekind (Any_Array, E_Array_Type);
   Set_Scope (Any_Array, Standard_Standard);
   Set_Etype (Any_Array, Any_Array);
   Set_Component_Type(Any_Array, Any_Character);
   Init_Size_Align   (Any_Array);
-  Make_Name (Any_Array, "an array type");
   Make_Dummy_Index  (Any_Array);
 
-  Any_Boolean := New_Standard_Entity;
+  Any_Boolean := New_Standard_Entity ("a boolean type");
   Set_Ekind (Any_Boolean, E_Enumeration_Type);
   Set_Scope (Any_Boolean, Standard_Standard);
   Set_Etype (Any_Boolean, Standard_Boolean);
@@ -1257,34 +1256,30 @@
   Set_Elem_Alignment(Any_Boolean);
   Set_Is_Unsigned_Type  (Any_Boolean);
   Set_Scalar_Range  (Any_Boolean, Scalar_Range (Standard_Boolean));
-  Make_Name (Any_Boolean, "a boolean type");
 
-  Any_Composite := New_Standard_Entity;
+  Any_Composite := New_Standard_Entity ("a composite type");
   Set_Ekind (Any_Composite, E_Array_Type);
   Set_Scope (Any_Composite, Standard_Standard);
   Set_Etype (Any_Composite, Any_Composite);
   Set_Component_Size(Any_Composite, Uint_0);
   Set_Component_Type(Any_Composite, Standard_Integer);
   Init_Size_Align   (Any_Composite);
-  Make_Name (Any_Composite, "a composite type");
 
-  Any_Discrete := New_Standard_Entity;
+  Any_Discrete := New_Standard_Entity ("a discrete type");
   Set_Ekind (Any_Discrete, E_Signed_Integer_Type);
   Set_Scope (Any_Discrete, Standard_Standard);
   Set_Etype (Any_Discrete, Any_Discrete);
   Init_Size   

[Ada] Internal cleanups in handling of subtype bounds

2014-07-30 Thread Arnaud Charlet
This change causes subtype bounds to be captured in special constant
variables xxxL and xxxH, avoiding troublesome cases where the call to
Force_Evaluation generated serialized temporaries that got referenced
publicly. It also means that First/Last can be expanded out in more
cases.

No functional test required, since no functional effect, but the
following test:

 1. procedure FLastX (Q, S : in out Integer) is
 2.subtype R is Integer range 5 .. 10;
 3.subtype T is Integer range Q .. S;
 4.M : Integer;
 5. begin
 6.Q := Q + S;
 7.S := S + Q;
 8.M := R'First;
 9.M := R'Last;
10.M := T'First;
11.M := T'Last;
12. end;

generates the following expanded code, showing the changes:

procedure flastx (q : in out integer; s : in out integer) is
   subtype flastx__r is integer range 5 .. 10;
   tL : constant integer := q;
   tH : constant integer := s;
   subtype flastx__t is integer range tL .. tH;
   m : integer;
begin
   q := q + s;
   s := s + q;
   m := 5;
   m := 10;
   m := tL;
   m := tH;
   return;
end flastx;

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

2014-07-30  Robert Dewar  

* exp_attr.adb (Expand_Attribute, case First): Rewrite simple
entity reference.
(Expand_Attribute, case Last): Ditto.
* exp_ch3.adb (Constrain_Index): New calling sequence for
Process_Range_Expr_In_Decl.
(Expand_N_Object_Declaration): Avoid setting Is_Known_Valid in one
problematical case.
* sem_ch3.adb (Constrain_Index): New calling sequence for
Process_Range_Expr_In_Decl.
(Set_Scalar_Range_For_Subtype): ditto.
(Process_Range_Expr_In_Decl): Create constants to hold bounds for
subtype.
* sem_ch3.ads (Process_Range_Expr_In_Decl): Add Subtyp parameter.
* sem_eval.adb (Compile_Time_Compare): Make sure we use base
types if we are not assuming no invalid values.

Index: sem_ch3.adb
===
--- sem_ch3.adb (revision 213284)
+++ sem_ch3.adb (working copy)
@@ -12390,7 +12390,7 @@
  Set_Etype (S, T);
  R := S;
 
- Process_Range_Expr_In_Decl (R, T, Empty_List);
+ Process_Range_Expr_In_Decl (R, T);
 
  if not Error_Posted (S)
and then
@@ -19018,9 +19018,10 @@
procedure Process_Range_Expr_In_Decl
  (R: Node_Id;
   T: Entity_Id;
-  Check_List   : List_Id := Empty_List;
-  R_Check_Off  : Boolean := False;
-  In_Iter_Schm : Boolean := False)
+  Subtyp   : Entity_Id := Empty;
+  Check_List   : List_Id   := Empty_List;
+  R_Check_Off  : Boolean   := False;
+  In_Iter_Schm : Boolean   := False)
is
   Lo, Hi  : Node_Id;
   R_Checks: Check_Result;
@@ -19142,8 +19143,71 @@
 --  not supposed to occur, e.g. on default parameters of a call.
 
 if Expander_Active or GNATprove_Mode then
-   Force_Evaluation (Lo);
-   Force_Evaluation (Hi);
+
+   --  If no subtype name, then just call Force_Evaluation to
+   --  create declarations as needed to deal with side effects.
+   --  Also ignore calls from within a record type, where we
+   --  have possible scoping issues.
+
+   if No (Subtyp) or else Is_Record_Type (Current_Scope) then
+  Force_Evaluation (Lo);
+  Force_Evaluation (Hi);
+
+   --  If a subtype is given, then we capture the bounds if they
+   --  are not known at compile time, using constant identifiers
+   --  xxxL and xxxH where xxx is the name of the subtype. No need
+   --  to do that if they are already references to constants.
+
+   --  Historical note: We used to just do Force_Evaluation calls
+   --  in all cases, but it is better to capture the bounds with
+   --  proper non-serialized names, since these will be accesse
+   --  from other units, and hence may be public, and also we can
+   --  then expand 'First and 'Last references to be references to
+   --  these special names.
+
+   else
+  if not Compile_Time_Known_Value (Lo)
+and then not (Is_Entity_Name (Lo)
+   and then Is_Constant_Object (Entity (Lo)))
+  then
+ declare
+Loc : constant Source_Ptr := Sloc (Lo);
+Lov : constant Entity_Id  :=
+  Make_Defining_Identifier (Loc,
+Chars => New_External_Name (Chars (Subtyp), 'L'));
+ begin
+Insert_Action (R,
+  Make_Object_Declaration (Loc,
+

[PATCH][PING] Add support for KernelAddressSanitizer

2014-07-30 Thread Yury Gribov

On 07/18/2014 05:38 PM, Jakub Jelinek wrote:

Do you error out on -fsanitize=thread -fsanitize=kernel-address ?
Perhaps -fsanitize=kernel-address -fsanitize=address should be invalid too?


Yes, all these combinations are invalid.


But you don't error out on that.


Ok, fixed.


Then in sanitize_spec_function supposedly for "address" check
SANITIZE_USER_ADDRESS bit, for "kernel-address" added there
SANITIZE_KERNEL_ADDRESS, add all the incompatibility diagnostics for the new
invalid combinations.


This delayed detection until link phase (and even then was disabled if
-nostdlib was on)
so I decided to perform this check in finish_options (after passing
cmdline options).


Plus, toplev.c has e.g.:


Fixed as well.

-Y




commit bd51cdb807c2cf5ada0101ca7db89076b54ed18e
Author: Yury Gribov 
Date:   Tue Jul 22 11:02:03 2014 +0400

2014-07-23  Yury Gribov  

	* doc/cpp.texi (__SANITIZE_ADDRESS__): Updated description.
	* doc/invoke.texi (-fsanitize=kernel-address): Describe new option.
	* flag-types.h (SANITIZE_USER_ADDRESS, SANITIZE_KERNEL_ADDRESS):
	New enums.
	* gcc.c (sanitize_spec_function): Support new option.
	(SANITIZER_SPEC): Remove now redundant check.
	* opts.c (common_handle_option): Support new option.
	(finish_options): Check for incompatibilities.
	* toplev.c (process_options): Split userspace-specific checks.

diff --git a/gcc/doc/cpp.texi b/gcc/doc/cpp.texi
index aaed739..0a6e50c 100644
--- a/gcc/doc/cpp.texi
+++ b/gcc/doc/cpp.texi
@@ -2354,8 +2354,8 @@ This macro is defined, with value 3, when @option{-fstack-protector-strong} is
 in use.
 
 @item __SANITIZE_ADDRESS__
-This macro is defined, with value 1, when @option{-fsanitize=address} is
-in use.
+This macro is defined, with value 1, when @option{-fsanitize=address}
+or @option{-fsanitize=kernel-address} are in use.
 
 @item __TIMESTAMP__
 This macro expands to a string constant that describes the date and time
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index b5e8d98..391daf8 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -5405,6 +5405,11 @@ more details.  The run-time behavior can be influenced using the
 @url{https://code.google.com/p/address-sanitizer/wiki/Flags#Run-time_flags} for
 a list of supported options.
 
+@item -fsanitize=kernel-address
+@opindex fsanitize=kernel-address
+Enable AddressSanitizer for Linux kernel.
+See @uref{http://code.google.com/p/address-sanitizer/wiki/AddressSanitizerForKernel} for more details.
+
 @item -fsanitize=thread
 @opindex fsanitize=thread
 Enable ThreadSanitizer, a fast data race detector.
diff --git a/gcc/flag-types.h b/gcc/flag-types.h
index 2849455..bf813b6 100644
--- a/gcc/flag-types.h
+++ b/gcc/flag-types.h
@@ -214,23 +214,25 @@ enum vect_cost_model {
 enum sanitize_code {
   /* AddressSanitizer.  */
   SANITIZE_ADDRESS = 1 << 0,
+  SANITIZE_USER_ADDRESS = 1 << 1,
+  SANITIZE_KERNEL_ADDRESS = 1 << 2,
   /* ThreadSanitizer.  */
-  SANITIZE_THREAD = 1 << 1,
+  SANITIZE_THREAD = 1 << 3,
   /* LeakSanitizer.  */
-  SANITIZE_LEAK = 1 << 2,
+  SANITIZE_LEAK = 1 << 4,
   /* UndefinedBehaviorSanitizer.  */
-  SANITIZE_SHIFT = 1 << 3,
-  SANITIZE_DIVIDE = 1 << 4,
-  SANITIZE_UNREACHABLE = 1 << 5,
-  SANITIZE_VLA = 1 << 6,
-  SANITIZE_NULL = 1 << 7,
-  SANITIZE_RETURN = 1 << 8,
-  SANITIZE_SI_OVERFLOW = 1 << 9,
-  SANITIZE_BOOL = 1 << 10,
-  SANITIZE_ENUM = 1 << 11,
-  SANITIZE_FLOAT_DIVIDE = 1 << 12,
-  SANITIZE_FLOAT_CAST = 1 << 13,
-  SANITIZE_BOUNDS = 1 << 14,
+  SANITIZE_SHIFT = 1 << 5,
+  SANITIZE_DIVIDE = 1 << 6,
+  SANITIZE_UNREACHABLE = 1 << 7,
+  SANITIZE_VLA = 1 << 8,
+  SANITIZE_NULL = 1 << 9,
+  SANITIZE_RETURN = 1 << 10,
+  SANITIZE_SI_OVERFLOW = 1 << 11,
+  SANITIZE_BOOL = 1 << 12,
+  SANITIZE_ENUM = 1 << 13,
+  SANITIZE_FLOAT_DIVIDE = 1 << 14,
+  SANITIZE_FLOAT_CAST = 1 << 15,
+  SANITIZE_BOUNDS = 1 << 16,
   SANITIZE_UNDEFINED = SANITIZE_SHIFT | SANITIZE_DIVIDE | SANITIZE_UNREACHABLE
 		   | SANITIZE_VLA | SANITIZE_NULL | SANITIZE_RETURN
 		   | SANITIZE_SI_OVERFLOW | SANITIZE_BOOL | SANITIZE_ENUM
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 6cd08ea..c0fde8c 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -779,8 +779,7 @@ proper position among the other output files.  */
 #ifndef SANITIZER_SPEC
 #define SANITIZER_SPEC "\
 %{!nostdlib:%{!nodefaultlibs:%{%:sanitize(address):" LIBASAN_SPEC "\
-%{static:%ecannot specify -static with -fsanitize=address}\
-%{%:sanitize(thread):%e-fsanitize=address is incompatible with -fsanitize=thread}}\
+%{static:%ecannot specify -static with -fsanitize=address}}\
 %{%:sanitize(thread):" LIBTSAN_SPEC "\
 %{!pie:%{!shared:%e-fsanitize=thread linking must be done with -pie or -shared}}}\
 %{%:sanitize(undefined):" LIBUBSAN_SPEC "}\
@@ -8224,7 +8223,9 @@ sanitize_spec_function (int argc, const char **argv)
 return NULL;
 
   if (strcmp (argv[0], "address") == 0)
-return (flag_sanitize & SANITIZE_ADDRESS) ? "" : NULL;
+return (flag_sanitize & SANITIZE_USER_

[PATCH] libstdc++: add _GLIBCXX_ macro prefix in atexit_thread.cc

2014-07-30 Thread Zifei Tong
Hi,

I found an issue that the __cxa_thread_atexit_impl() function never called by
__cxa_thread_atexit() even with newest glibc which have __cxa_thread_atexit_impl
implemented.

It turns out that the code tried to use macro HAVE___CXA_THREAD_ATEXIT_IMPL, but
not _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL which is defined in bits/c++config.h
(generated from autoconf scripts).

This patch adds the missing macro prefix.

Thanks,
Zifei

2014-07-29  Zifei Tong 
  * libsupc++/atexit_thread.cc: add _GLIBCXX_ macro prefix

---
 libstdc++-v3/libsupc++/atexit_thread.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/libsupc++/atexit_thread.cc 
b/libstdc++-v3/libsupc++/atexit_thread.cc
index db20200..dff08e9 100644
--- a/libstdc++-v3/libsupc++/atexit_thread.cc
+++ b/libstdc++-v3/libsupc++/atexit_thread.cc
@@ -26,7 +26,7 @@
 #include 
 #include "bits/gthr.h"
 
-#if HAVE___CXA_THREAD_ATEXIT_IMPL
+#if _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL
 
 extern "C" int __cxa_thread_atexit_impl (void (*func) (void *),
 void *arg, void *d);
@@ -38,7 +38,7 @@ __cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *),
   return __cxa_thread_atexit_impl (dtor, obj, dso_handle);
 }
 
-#else /* HAVE___CXA_THREAD_ATEXIT_IMPL */
+#else /* _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
 
 namespace {
   // One element in a singly-linked stack of cleanups.
@@ -142,4 +142,4 @@ __cxxabiv1::__cxa_thread_atexit (void (*dtor)(void *), void 
*obj, void */*dso_ha
   return 0;
 }
 
-#endif /* HAVE___CXA_THREAD_ATEXIT_IMPL */
+#endif /* _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL */
-- 
2.0.3



Re: [PATCH] PR61868

2014-07-30 Thread Andi Kleen
On Wed, Jul 30, 2014 at 09:46:48AM +0200, Richard Biener wrote:
> On Tue, Jul 29, 2014 at 3:01 PM, Bingfeng Mei  wrote:
> > Hi,
> > Please find the patches for pr61868. The problem is that even with 
> > -frandom-seed gcc always uses 0 instead of specified number/string for 
> > places such as lto section names. init_random_seed is never called with 
> > -frandom-seed. Bootstrapped and tested on x86-64. OK for trunk?
> 
> Hmm, but -frandom-seed= is honored by opts.c calling set_random_seed?
> 
> Andi, wasn't this used to support partial linking of LTO objects?  Thus,
> this shortcut was on purpose?  Otherwise passing -frandom-seed to
> LTO would break that?

I don't think it was on purpose. Partial linking doesn't need
the seeds. The seeding was only to avoid compare failures in
the gcc build.

-Andi


Re: [PATCH] libjava/classpath/native/jni/java-lang/java_lang_VMProcess.c: Be sure 'errbuf' always be zero terminated.

2014-07-30 Thread Chen Gang
Hello All:

I shall stop making this kind of patch, next. The reason is that I worry
about what I have done have negative effect to others. And next, I shall
try to send another kinds of patches for gcc when I have time.

Many persons or companies use open source who never give thanks or
contribution back to open source. But open source (especially,
fundamental software) still provide common contributions to outside.

What I have done is only for contribution back to open source, so I can
understand none-reply from open source (at least, it is not the excuse
to let myself stop). But what I worry about is whether bother others.


Thanks.

On 07/29/2014 01:29 PM, Chen Gang wrote:
> Hello All:
> 
> It is a simple way for finding these kinds of issues (issues may not be
> bugs), one sample for 'strncpy' (the same way for sprintf, strcpy,
> memcpy ...):
> 
>  - grep strncpy in all source code.
> 
>  - and then check each one by one.
>  
>  - at present, I have finish check about 30% for strncpy.
> 
> Also have another ways for finding trivial patches (e.g. how to find
> resource leak when failure occurs, ...).
> 
> If these kinds of trivial patches are only bother most of members,
> please let me know, and next, I shall not send this kinds of patches.
> 
> 
> Thanks.
> 
> On 07/28/2014 08:16 PM, Chen Gang wrote:
>> 'errbuf' assumes itself will be zero terminated, and it also assumes
>> cpnative_getErrorString() may get larger length string than 'errbuf'.
>> So after strncpy(), 'errbuf' may not be zero terminated.
>>
>> strncpy() is sure of zero pad, but not be sure of zero terminated.
>>
>>
>> Signed-off-by: Chen Gang 
>> ---
>>  libjava/classpath/native/jni/java-lang/java_lang_VMProcess.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/libjava/classpath/native/jni/java-lang/java_lang_VMProcess.c 
>> b/libjava/classpath/native/jni/java-lang/java_lang_VMProcess.c
>> index a6076f2..0972a5e 100644
>> --- a/libjava/classpath/native/jni/java-lang/java_lang_VMProcess.c
>> +++ b/libjava/classpath/native/jni/java-lang/java_lang_VMProcess.c
>> @@ -210,6 +210,7 @@ Java_java_lang_VMProcess_nativeSpawn (JNIEnv * env, 
>> jobject this,
>>if (err != 0)
>>  {
>>strncpy(errbuf, cpnative_getErrorString (err), sizeof(errbuf));
>> +  errbuf[sizeof(errbuf) - 1] = '\0';
>>goto system_error;
>>  }
>>  
>>
> 


-- 
Chen Gang

Open share and attitude like air water and life which God blessed


[Ada] Notes from subunits incorrectly recorded in ALI files

2014-07-30 Thread Arnaud Charlet
This change fixes the way annotations coming from subunits are recorded in
ALI files, so that their original source location (including the source file
name of the subunit) is correctly preserved.

The following commands must produce the shown output:

$ gcc -c annot_separate.adb
$ sed -n -e '/^U/s/ .*//p' -e '/^N/p' annot_separate.ali
U annot_separate%b
N A3:4 foo bar "from pak.adb"
N A3:4:annot_separate-q.adb foo bar "from pak-q.adb"
U annot_separate%s
N A3:4 foo bar "from pak.ads"

--
package body Annot_Separate is
   pragma Annotate (Foo, Bar, "from pak.adb");
   procedure P is begin null; end P;
   procedure Q is separate;
end Annot_Separate;
--
package Annot_Separate is
   pragma Annotate (Foo, Bar, "from pak.ads");
   procedure P;
   procedure Q;
end Annot_Separate;
separate (Annot_Separate)
procedure Q is
   pragma Annotate (Foo, Bar, "from pak-q.adb");
begin
   null;
end Q;

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

2014-07-30  Thomas Quinot  

* lib.ads (Notes): Simplify. The Unit component in Notes_Entry
is redundant. Instead used the pragma Node_Id directly as the
element type.
* lib.adb (Store_Note): Store only notes that do not come from
an instance, and that are in the extended main source unit.
* lib-writ (Write_Unit_Information): Annotations from subunits
must be emitted along with those for the main unit, and they
must carry a specific file name.
* ali.ads (Notes_Record): Use a File_Name_Type instead of a
Unit_Id for the source file containing the pragma, as in the
case of annotations from subunits we might not have a readily
available unit id.
* ali.adb (Scan_ALI): Account for above change in data structure.

Index: lib.adb
===
--- lib.adb (revision 213263)
+++ lib.adb (working copy)
@@ -1046,8 +1046,16 @@

 
procedure Store_Note (N : Node_Id) is
+  Sfile : constant Source_File_Index := Get_Source_File_Index (Sloc (N));
begin
-  Notes.Append ((Pragma_Node => N, Unit => Current_Sem_Unit));
+  --  Notes for a generic are emitted when processing the template, never
+  --  in instances.
+
+  if In_Extended_Main_Code_Unit (N)
+and then Instance (Sfile) = No_Instance_Id
+  then
+ Notes.Append (N);
+  end if;
end Store_Note;
 
---
Index: lib.ads
===
--- lib.ads (revision 213263)
+++ lib.ads (working copy)
@@ -826,13 +826,8 @@
 
--  The following table stores references to pragmas that generate Notes
 
-   type Notes_Entry is record
-  Pragma_Node : Node_Id;
-  Unit: Unit_Number_Type;
-   end record;
-
package Notes is new Table.Table (
- Table_Component_Type => Notes_Entry,
+ Table_Component_Type => Node_Id,
  Table_Index_Type => Integer,
  Table_Low_Bound  => 1,
  Table_Initial=> Alloc.Notes_Initial,
Index: lib-writ.adb
===
--- lib-writ.adb(revision 213263)
+++ lib-writ.adb(working copy)
@@ -647,13 +647,26 @@
 
  for J in 1 .. Notes.Last loop
 declare
-   N : constant Node_Id  := Notes.Table (J).Pragma_Node;
+   N : constant Node_Id  := Notes.Table (J);
L : constant Source_Ptr   := Sloc (N);
-   U : constant Unit_Number_Type := Notes.Table (J).Unit;
+   U : constant Unit_Number_Type :=
+ Unit (Get_Source_File_Index (L));
C : Character;
 
+   Note_Unit : Unit_Number_Type;
+   --  The unit in whose U section this note must be emitted:
+   --  notes for subunits are emitted along with the main unit;
+   --  all other notes are emitted as part of the enclosing
+   --  compilation unit.
+
 begin
-   if U = Unit_Num then
+   if Nkind (Unit (Cunit (U))) = N_Subunit then
+  Note_Unit := Main_Unit;
+   else
+  Note_Unit := U;
+   end if;
+
+   if Note_Unit = Unit_Num then
   Write_Info_Initiate ('N');
   Write_Info_Char (' ');
 
@@ -677,6 +690,15 @@
   Write_Info_Char (':');
   Write_Info_Int (Int (Get_Column_Number (L)));
 
+  --  Indicate source file of annotation if different from
+  --  compilation unit source file (case of annotation coming
+  --  from a separate).
+
+  if Get_Source_File_Index (L) /= Source_Index (Unit_Num) then
+ Write_Info_Char (':');
+ Write_Info_Name (File_Name (Get_Source_File_Index (L)));
+  end 

Re: [C++ Patch] PR 57397

2014-07-30 Thread Paolo Carlini

Hi again,

the below tries to also fix the second problem I presented in this 
thread. Passes testing on x86_64-linux. How does it look?


Thanks,
Paolo.

///
Index: cp/pt.c
===
--- cp/pt.c (revision 213287)
+++ cp/pt.c (working copy)
@@ -5517,13 +5517,21 @@ unify_method_type_error (bool explain_p, tree arg)
 }
 
 static int
-unify_arity (bool explain_p, int have, int wanted)
+unify_arity (bool explain_p, int have, int wanted, bool least_p = false)
 {
   if (explain_p)
-inform_n (input_location, wanted,
- "  candidate expects %d argument, %d provided",
- "  candidate expects %d arguments, %d provided",
- wanted, have);
+{
+  if (least_p)
+   inform_n (input_location, wanted,
+ "  candidate expects at least %d argument, %d provided",
+ "  candidate expects at least %d arguments, %d provided",
+ wanted, have);
+  else
+   inform_n (input_location, wanted,
+ "  candidate expects %d argument, %d provided",
+ "  candidate expects %d arguments, %d provided",
+ wanted, have);
+}
   return 1;
 }
 
@@ -5534,9 +5542,10 @@ unify_too_many_arguments (bool explain_p, int have
 }
 
 static int
-unify_too_few_arguments (bool explain_p, int have, int wanted)
+unify_too_few_arguments (bool explain_p, int have, int wanted,
+bool least_p = false)
 {
-  return unify_arity (explain_p, have, wanted);
+  return unify_arity (explain_p, have, wanted, least_p);
 }
 
 static int
@@ -16546,6 +16555,7 @@ type_unification_real (tree tparms,
   const tree *args;
   unsigned int nargs;
   unsigned int ia;
+  bool non_deduced_pack;
 
   gcc_assert (TREE_CODE (tparms) == TREE_VEC);
   gcc_assert (xparms == NULL_TREE || TREE_CODE (xparms) == TREE_LIST);
@@ -16559,6 +16569,7 @@ type_unification_real (tree tparms,
   parms = xparms;
   args = xargs;
   nargs = xnargs;
+  non_deduced_pack = false;
 
   ia = 0;
   while (parms && parms != void_list_node
@@ -16577,10 +16588,13 @@ type_unification_real (tree tparms,
   parms = TREE_CHAIN (parms);
 
   if (TREE_CODE (parm) == TYPE_PACK_EXPANSION)
-   /* For a function parameter pack that does not occur at the
-  end of the parameter-declaration-list, the type of the
-  parameter pack is a non-deduced context.  */
-   continue;
+   {
+ /* For a function parameter pack that does not occur at the
+end of the parameter-declaration-list, the type of the
+parameter pack is a non-deduced context.  */
+ non_deduced_pack = true;
+ continue;
+   }
 
   arg = args[ia];
   ++ia;
@@ -16594,6 +16608,18 @@ type_unification_real (tree tparms,
   && parms != void_list_node
   && TREE_CODE (TREE_VALUE (parms)) == TYPE_PACK_EXPANSION)
 {
+  /* Eg (c++/57397):
+
+  template
+  void foo(T1, Tn..., Tm...);
+
+  int main()
+  {
+foo(1, 2);
+  }  */
+  if (ia < nargs && non_deduced_pack)
+   return unify_too_many_arguments (explain_p, nargs, ia);
+
   /* Unify the remaining arguments with the pack expansion type.  */
   tree argvec;
   tree parmvec = make_tree_vec (1);
@@ -16617,18 +16643,33 @@ type_unification_real (tree tparms,
  are present, and the parm list isn't variadic.  */
   if (ia < nargs && parms == void_list_node)
 return unify_too_many_arguments (explain_p, nargs, ia);
-  /* Fail if parms are left and they don't have default values.  */
+  /* Fail if parms are left and they don't have default values and
+ they aren't all deduced as empty packs, eg (c++/57397):
+
+ template
+ void foo(T1, Tn..., Tm...);
+
+ int main()
+ {
+   foo(1);
+ }  */
   if (parms && parms != void_list_node
   && TREE_PURPOSE (parms) == NULL_TREE)
 {
   unsigned int count = nargs;
+  bool trailing_packs = false;
   tree p = parms;
   while (p && p != void_list_node)
{
- count++;
+ if (TREE_CODE (TREE_VALUE (p)) == TYPE_PACK_EXPANSION)
+   trailing_packs = true;
+ else
+   count++;
  p = TREE_CHAIN (p);
}
-  return unify_too_few_arguments (explain_p, ia, count);
+  if (count != nargs)
+   return unify_too_few_arguments (explain_p, ia, count,
+   trailing_packs);
 }
 
   if (!subr)
Index: testsuite/g++.dg/cpp0x/vt-57397-1.C
===
--- testsuite/g++.dg/cpp0x/vt-57397-1.C (revision 0)
+++ testsuite/g++.dg/cpp0x/vt-57397-1.C (working copy)
@@ -0,0 +1,22 @@
+// PR c++/57397
+// { dg-do compile { target c++11 } }
+
+template
+void foo(T1, Tn...);
+
+template
+void bar(T1, T2, Tn...);
+
+int main()
+{
+  foo();   // { dg-error "no matching" }
+  // { dg-message "candidate expects at lea

[Ada] Display correctly directory path names

2014-07-30 Thread Arnaud Charlet
When the Project Manager is indicating that a directory cannot be created
and the full path name of the directory contains chacters that are
teated specially to modify the error message, the full path name of the
directory is not displayed correctly. This patch corrects the problem.

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

2014-07-30  Vincent Celier  

* errutil.adb (Set_Msg_Text): Process tilde ('~'): no processing
of error message.
* prj-nmsc.adb (Locate_Directory): Use a tilde ('~') in the
message to report that a directory cannot be created, to avoid
processing of the directory path that may contains special
insertion characters.

Index: prj-nmsc.adb
===
--- prj-nmsc.adb(revision 213283)
+++ prj-nmsc.adb(working copy)
@@ -6214,7 +6214,7 @@
  when Use_Error =>
 Error_Msg
   (Data.Flags,
-   "could not create " & Create &
+   "~could not create " & Create &
" directory " & Full_Path_Name.all,
Location, Project);
   end;
Index: errutil.adb
===
--- errutil.adb (revision 213263)
+++ errutil.adb (working copy)
@@ -772,6 +772,13 @@
 P := P - 1;
 Set_Msg_Insertion_Reserved_Word (Text, P);
 
+ --  Tilde: just remove '~' and do not modify the message further
+
+ elsif C = '~' then
+Set_Msg_Str
+  (Text (Text'First .. P - 2) & Text (P .. Text'Last));
+exit;
+
  --  Normal character with no special treatment
 
  else


RE: [PATCH] PR61868

2014-07-30 Thread Bingfeng Mei
Yes, that fix is better. Here are updated patches. LTO-bootstrapped and tested. 
OK?

Bingfeng

Index: ChangeLog
===
--- ChangeLog   (revision 213152)
+++ ChangeLog   (working copy)
@@ -1,3 +1,10 @@
+2014-07-29  Bingfeng Mei 
+
+   PR lto/61868
+   * toplev.c (init_random_seed): Move piece of code never called to
+   set_random_seed.
+   (set_random_seed): see above.
+
 2014-07-28  Jan Hubicka  

* cgraph.c (cgraph_node::create_indirect_edge): Copy speculative data.
Index: toplev.c
===
--- toplev.c(revision 213152)
+++ toplev.c(working copy)
@@ -282,16 +282,7 @@ init_local_tick (void)
 static void
 init_random_seed (void)
 {
-  if (flag_random_seed)
-{
-  char *endp;
-
-  /* When the driver passed in a hex number don't crc it again */
-  random_seed = strtoul (flag_random_seed, &endp, 0);
-  if (!(endp > flag_random_seed && *endp == 0))
-random_seed = crc32_string (0, flag_random_seed);
-}
-  else if (!random_seed)
+  if (!random_seed)
 random_seed = local_tick ^ getpid ();  /* Old racey fallback method */
 }

@@ -314,6 +305,15 @@ set_random_seed (const char *val)
 {
   const char *old = flag_random_seed;
   flag_random_seed = val;
+  if (flag_random_seed)
+{
+  char *endp;
+
+  /* When the driver passed in a hex number don't crc it again */
+  random_seed = strtoul (flag_random_seed, &endp, 0);
+  if (!(endp > flag_random_seed && *endp == 0))
+random_seed = crc32_string (0, flag_random_seed);
+}
   return old;
 }

Index: testsuite/ChangeLog
===
--- testsuite/ChangeLog (revision 213152)
+++ testsuite/ChangeLog (working copy)
@@ -1,3 +1,8 @@
+2014-07-29  Bingfeng Mei  
+
+   PR lto/61868
+   * gcc.dg/pr61868.c: New test.
+
 2014-07-28  Richard Biener  

PR rtl-optimization/61801
Index: testsuite/gcc.dg/pr61868.c
===
--- testsuite/gcc.dg/pr61868.c  (revision 0)
+++ testsuite/gcc.dg/pr61868.c  (revision 0)
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-flto -frandom-seed=0x12345" }  */
+extern int foo (int);
+int main ()
+{
+  foo (100);
+  return 0;
+}
+/* { dg-final { scan-assembler "\.gnu\.lto.*.12345" } } */

> -Original Message-
> From: Richard Biener [mailto:richard.guent...@gmail.com]
> Sent: 30 July 2014 14:08
> To: Bingfeng Mei
> Cc: Andi Kleen; gcc-patches@gcc.gnu.org
> Subject: Re: [PATCH] PR61868
> 
> On Wed, Jul 30, 2014 at 2:48 PM, Bingfeng Mei  wrote:
> > On the second thought, maybe the change should be made in
> set_random_seed. Otherwise, init_random_seed is invoked every time
> get_random_seed get called (not sure how often). What do you think?
> >
> > const char *
> > set_random_seed (const char *val)
> > {
> >   const char *old = flag_random_seed;
> >   flag_random_seed = val;
> > + init_random_seed ();
> >   return old;
> > }
> 
> I think it makes more sense to move the if (flag_random_seed)
> code from init_random_seed inline here as init_random_seed is
> never called with flag_random_set == true.
> 
> Richard.
> 
> > Bingfeng
> >
> >> -Original Message-
> >> From: Richard Biener [mailto:richard.guent...@gmail.com]
> >> Sent: 30 July 2014 10:43
> >> To: Bingfeng Mei
> >> Cc: Andi Kleen; gcc-patches@gcc.gnu.org
> >> Subject: Re: [PATCH] PR61868
> >>
> >> On Wed, Jul 30, 2014 at 10:52 AM, Bingfeng Mei 
> wrote:
> >> > Yes, opts-global.c fills flag_random_seed with string passed in
> >> command line. But init_random_seed in toplev.c is the one that
> processes
> >> the flag and set random_seed variable, which is returned by
> >> get_random_seed function.
> >>
> >> Err, I meant opts-global.c:handle_common_deferred_options
> >>
> >> > By default, my configuration enables LTO. How to test LTO bootstrap?
> >>
> >> configure with --with-build-config=bootstrap-lto (and reduce the
> >> set of languages to c,c++ to get a sane bootstrap time).
> >>
> >> Richard.
> >>
> >> > Bingfeng
> >> >
> >> >> -Original Message-
> >> >> From: Richard Biener [mailto:richard.guent...@gmail.com]
> >> >> Sent: 30 July 2014 08:47
> >> >> To: Bingfeng Mei; Andi Kleen
> >> >> Cc: gcc-patches@gcc.gnu.org
> >> >> Subject: Re: [PATCH] PR61868
> >> >>
> >> >> On Tue, Jul 29, 2014 at 3:01 PM, Bingfeng Mei 
> >> wrote:
> >> >> > Hi,
> >> >> > Please find the patches for pr61868. The problem is that even
> with
> >> -
> >> >> frandom-seed gcc always uses 0 instead of specified number/string
> for
> >> >> places such as lto section names. init_random_seed is never called
> >> with
> >> >> -frandom-seed. Bootstrapped and tested on x86-64. OK for trunk?
> >> >>
> >> >> Hmm, but -frandom-seed= is honored by opts.c calling
> set_random_seed?
> >> >>
> >> >> Andi, wasn't this used to support partial linking of LTO objects?
> >> T

Re: [PATCH] libjava/classpath/native/jni/java-lang/java_lang_VMProcess.c: Be sure 'errbuf' always be zero terminated.

2014-07-30 Thread Tom Tromey
> "Chen" == Chen Gang  writes:

Chen> 'errbuf' assumes itself will be zero terminated, and it also assumes
Chen> cpnative_getErrorString() may get larger length string than 'errbuf'.
Chen> So after strncpy(), 'errbuf' may not be zero terminated.

Chen> strncpy() is sure of zero pad, but not be sure of zero terminated.

It seems reasonable but Classpath patches should go upstream, to the
Classpath project.

Tom


Re: [PATCH] libjava/classpath/native/jni/java-lang/java_lang_VMProcess.c: Be sure 'errbuf' always be zero terminated.

2014-07-30 Thread Tom Tromey
> "Chen" == Chen Gang  writes:

Chen> I shall stop making this kind of patch, next. The reason is that I worry
Chen> about what I have done have negative effect to others. And next, I shall
Chen> try to send another kinds of patches for gcc when I have time.

It's customary to wait a while before pinging patches, usually one or
two weeks.  Reviewers are usually busy and don't spend all their time
reviewing.

Tom


Re: [PATCH] libstdc++: add _GLIBCXX_ macro prefix in atexit_thread.cc

2014-07-30 Thread Jonathan Wakely

On 30/07/14 22:42 +0800, Zifei Tong wrote:

Hi,

I found an issue that the __cxa_thread_atexit_impl() function never called by
__cxa_thread_atexit() even with newest glibc which have __cxa_thread_atexit_impl
implemented.

It turns out that the code tried to use macro HAVE___CXA_THREAD_ATEXIT_IMPL, but
not _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL which is defined in bits/c++config.h
(generated from autoconf scripts).

This patch adds the missing macro prefix.


The patch is correct, thanks very much.

Do you have commit access? If not I can do it for you.

Jason, any objection to putting this on the 4.8 and 4.9 branches too?



Re: [PATCH] libjava/classpath/native/jni/java-lang/java_lang_VMProcess.c: Be sure 'errbuf' always be zero terminated.

2014-07-30 Thread Andrew Haley
On 07/30/2014 04:01 PM, Chen Gang wrote:
> I shall stop making this kind of patch, next. The reason is that I worry
> about what I have done have negative effect to others. And next, I shall
> try to send another kinds of patches for gcc when I have time.
> 
> Many persons or companies use open source who never give thanks or
> contribution back to open source. But open source (especially,
> fundamental software) still provide common contributions to outside.
> 
> What I have done is only for contribution back to open source, so I can
> understand none-reply from open source (at least, it is not the excuse
> to let myself stop). But what I worry about is whether bother others.

You only posted it yesterday.  It certainly looks reasonable enough,
but you surely don't expect an instant response.  By the way, the
correct mailing list is java-patc...@gcc.gnu.org.

Andrew.



Re: [PATCH] libstdc++: add _GLIBCXX_ macro prefix in atexit_thread.cc

2014-07-30 Thread Zifei Tong
On Wed, Jul 30, 2014 at 11:25 PM, Jonathan Wakely  wrote:
> On 30/07/14 22:42 +0800, Zifei Tong wrote:
>>
>> Hi,
>>
>> I found an issue that the __cxa_thread_atexit_impl() function never called
>> by
>> __cxa_thread_atexit() even with newest glibc which have
>> __cxa_thread_atexit_impl
>> implemented.
>>
>> It turns out that the code tried to use macro
>> HAVE___CXA_THREAD_ATEXIT_IMPL, but
>> not _GLIBCXX_HAVE___CXA_THREAD_ATEXIT_IMPL which is defined in
>> bits/c++config.h
>> (generated from autoconf scripts).
>>
>> This patch adds the missing macro prefix.
>
>
> The patch is correct, thanks very much.
>
> Do you have commit access?
I don't think so, this is my first patch to gcc :)

> If not I can do it for you.
Thanks!

> Jason, any objection to putting this on the 4.8 and 4.9 branches too?
>


Re: [PATCH 0/5] let gdb reuse gcc'c C compiler

2014-07-30 Thread Tom Tromey
Tom> This patch series is half of a project to let gdb reuse gcc (which
Tom> half depends on which list you are seeing this on), so that users can
Tom> compile small snippets of code and evaluate them in the current
Tom> context of the inferior.

[ ... later ... ]
Tom> I believe we've addressed all the review comments.

Ping.
I think at least the final patch has never been approved.

Tom


[commit, s390] Fix TPF unwinder

2014-07-30 Thread Ulrich Weigand
Hello,

I've checked in a fix provided by Jim Johnston on the TPF team to fix a case
where the special TPF unwinder didn't work correctly.

Tested on TPF by Jim, committed to mainline.

Bye,
Ulrich

ChangeLog:

gcc/

2014-07-30  Ulrich Weigand  

* config/s390/s390.c (s390_emit_tpf_eh_return): Pass original return
address as second parameter to __tpf_eh_return routine.

libgcc/

2014-07-30  J. D. Johnston  

* config/s390/tpf-unwind.h: Include .
(__tpf_eh_return): Add original return address as second parameter.
Handle cases where unwinder routines were called directly, instead
of from within the C++ library.


Index: gcc/config/s390/s390.c
===
--- gcc/config/s390/s390.c  (revision 213302)
+++ gcc/config/s390/s390.c  (working copy)
@@ -10850,17 +10850,20 @@ static GTY(()) rtx s390_tpf_eh_return_sy
 void
 s390_emit_tpf_eh_return (rtx target)
 {
-  rtx insn, reg;
+  rtx insn, reg, orig_ra;
 
   if (!s390_tpf_eh_return_symbol)
 s390_tpf_eh_return_symbol = gen_rtx_SYMBOL_REF (Pmode, "__tpf_eh_return");
 
   reg = gen_rtx_REG (Pmode, 2);
+  orig_ra = gen_rtx_REG (Pmode, 3);
 
   emit_move_insn (reg, target);
+  emit_move_insn (orig_ra, get_hard_reg_initial_val (Pmode, RETURN_REGNUM));
   insn = s390_emit_call (s390_tpf_eh_return_symbol, NULL_RTX, reg,
  gen_rtx_REG (Pmode, RETURN_REGNUM));
   use_reg (&CALL_INSN_FUNCTION_USAGE (insn), reg);
+  use_reg (&CALL_INSN_FUNCTION_USAGE (insn), orig_ra);
 
   emit_move_insn (EH_RETURN_HANDLER_RTX, reg);
 }
Index: libgcc/config/s390/tpf-unwind.h
===
--- libgcc/config/s390/tpf-unwind.h (revision 213302)
+++ libgcc/config/s390/tpf-unwind.h (working copy)
@@ -24,6 +24,7 @@ see the files COPYING3 and COPYING.RUNTI
 .  */
 
 #include 
+#include 
 
 /* Function Name: __isPATrange
Parameters passed into it:  address to check
@@ -139,29 +140,38 @@ s390_fallback_frame_state (struct _Unwin
 #define TPFAREA_SIZE STACK_POINTER_OFFSET-TPFAREA_OFFSET
 #define INVALID_RETURN 0
 
-void * __tpf_eh_return (void *target);
+void * __tpf_eh_return (void *target, void *origRA);
 
 void *
-__tpf_eh_return (void *target)
+__tpf_eh_return (void *target, void *origRA)
 {
   Dl_info targetcodeInfo, currentcodeInfo;
   int retval;
   void *current, *stackptr, *destination_frame;
-  unsigned long int shifter, is_a_stub;
+  unsigned long int shifter;
+  bool is_a_stub, frameDepth2, firstIteration;
 
-  is_a_stub = 0;
+  is_a_stub = false;
+  frameDepth2 = false;
+  firstIteration = true;
 
   /* Get code info for target return's address.  */
   retval = dladdr (target, &targetcodeInfo);
 
+  /* Check if original RA is a Pat stub.  If so set flag.  */
+  if (__isPATrange (origRA))
+frameDepth2 = true;
+
   /* Ensure the code info is valid (for target).  */
   if (retval != INVALID_RETURN)
 {
-
-  /* Get the stack pointer of the stack frame to be modified by
- the exception unwinder.  So that we can begin our climb
- there.  */
-  stackptr = (void *) *((unsigned long int *) (*(PREVIOUS_STACK_PTR(;
+  /* Get the stack pointer of the first stack frame beyond the
+ unwinder or if exists the calling C++ runtime function (e.g.,
+ __cxa_throw).  */
+  if (!frameDepth2)
+stackptr = (void *) *((unsigned long int *) (*(PREVIOUS_STACK_PTR(;
+  else
+stackptr = (void *) *(PREVIOUS_STACK_PTR());
 
   /* Begin looping through stack frames.  Stop if invalid
  code information is retrieved or if a match between the
@@ -169,18 +179,26 @@ __tpf_eh_return (void *target)
  matches that of the target, calculated above.  */
   do
 {
-  /* Get return address based on our stackptr iterator.  */
-  current = (void *) *((unsigned long int *)
-  (stackptr+RA_OFFSET));
+  if (!frameDepth2 || (frameDepth2 && !firstIteration))
+{
+  /* Get return address based on our stackptr iterator.  */
+  current = (void *) *((unsigned long int *)
+   (stackptr + RA_OFFSET));
 
-  /* Is it a Pat Stub?  */
-  if (__isPATrange (current))
+  /* Is it a Pat Stub?  */
+  if (__isPATrange (current))
+{
+  /* Yes it was, get real return address in TPF stack area.  */
+  current = (void *) *((unsigned long int *)
+   (stackptr + TPFRA_OFFSET))
+  is_a_stub = true;
+}
+}
+  else
 {
-  /* Yes it was, get real return address
- in TPF stack area.  */
   current = (void *) *((unsigned long int *)
-  (stackptr+TPFRA_OFFSET));

[PATCH, trans-mem, PR 61393] Copy tm_clone field of cgraph_node when cloning the node

2014-07-30 Thread Martin Jambor
Hi,

IPA-CP can wreck havoc to transactional memory support as described in
the summary of the PR in bugzilla.  It seems the cause is that IPA-CP
clones of nodes created by trans-mem do not have their tm_clone flag
set.  For release branches we have decided to simply disable IPA-CP of
trans-mem clones but for trunk we'd like to avoid this.  I am not 100%
sure that just copying the flag is OK but it seems that it works for
the provided testcase and nobody from the trans-mem people has
commented in bugzilla for over a month.  So I suggest we commit this
patch and wait and see if something breaks.  Hopefully nothing will.

Bootstrapped and tested on x86_64-linux.  OK for trunk?

Thanks,

Martin


2014-07-29  Martin Jambor  

PR ipa/61393
* cgraphclones.c (cgraph_node::create_clone): Also copy tm_clone.

diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index f097da8..c04b5c8 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -423,6 +423,7 @@ cgraph_node::create_clone (tree decl, gcov_type gcov_count, 
int freq,
   new_node->count = count;
   new_node->frequency = frequency;
   new_node->tp_first_run = tp_first_run;
+  new_node->tm_clone = tm_clone;
 
   new_node->clone.tree_map = NULL;
   new_node->clone.args_to_skip = args_to_skip;


Re: [C++ Patch] PR 57397

2014-07-30 Thread Jason Merrill

On 07/30/2014 11:09 AM, Paolo Carlini wrote:

+  /* Eg (c++/57397):
+
+  template
+  void foo(T1, Tn..., Tm...);
+
+  int main()
+  {
+foo(1, 2);
+  }  */


I think we should accept this: T1 is int, Tn is {}, Tm is {int}.


+ template
+ void foo(T1, Tn..., Tm...);
+
+ int main()
+ {
+   foo(1);
+ }  */


And we should accept this.


   while (p && p != void_list_node)
{
- count++;
+ if (TREE_CODE (TREE_VALUE (p)) == TYPE_PACK_EXPANSION)
+   trailing_packs = true;
+ else
+   count++;
  p = TREE_CHAIN (p);
}


Only a function parameter pack at the very end should trigger the "at 
least" message.  Other packs don't matter.


Jason



C++ PATCH to set DECL_COMDAT on undefined inlines/templates

2014-07-30 Thread Jason Merrill
Since can_refer_decl_in_current_unit_p doesn't allow references to 
DECL_COMDAT entities that aren't defined in the current unit, by setting 
that flag we can avoid problems with devirtualization introducing 
references to vague linkage functions that haven't been 
synthesized/instantiated because they aren't referenced directly.


The first attached patch sets DECL_COMDAT for inlines and templates.

The second attached patch removes the -fuse-all-virtuals code, which is 
no longer needed for correctness.


Tested x86_64-pc-linux-gnu, applying to trunk.  I'm planning to apply 
the first patch to 4.9.2 if it doesn't cause trouble on trunk.
commit b591032bfe618a612ab26ace8039c64c8eac3fd2
Author: Jason Merrill 
Date:   Tue Jul 29 17:28:44 2014 -0400

	PR lto/53808
	PR c++/61659
	* pt.c (push_template_decl_real): Set DECL_COMDAT on templates.
	(check_explicit_specialization): Clear it on specializations.
	* decl.c (duplicate_decls, start_decl): Likewise.
	(grokmethod, grokfndecl): Set DECL_COMDAT on inlines.
	* method.c (implicitly_declare_fn): Set DECL_COMDAT.  Determine
	linkage after setting the appropriate flags.
	* tree.c (decl_linkage): Don't check DECL_COMDAT.
	* decl2.c (mark_needed): Mark clones.
	(import_export_decl): Not here.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index aafb917..fd5e2e5 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -2197,6 +2197,7 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend)
 		  olddecl);
 
 	  SET_DECL_TEMPLATE_SPECIALIZATION (olddecl);
+	  DECL_COMDAT (newdecl) = DECL_DECLARED_INLINE_P (olddecl);
 
 	  /* Don't propagate visibility from the template to the
 	 specialization here.  We'll do that in determine_visibility if
@@ -4683,6 +4684,10 @@ start_decl (const cp_declarator *declarator,
   if (DECL_LANG_SPECIFIC (decl) && DECL_USE_TEMPLATE (decl))
 	{
 	  SET_DECL_TEMPLATE_SPECIALIZATION (decl);
+	  if (TREE_CODE (decl) == FUNCTION_DECL)
+	DECL_COMDAT (decl) = DECL_DECLARED_INLINE_P (decl);
+	  else
+	DECL_COMDAT (decl) = false;
 
 	  /* [temp.expl.spec] An explicit specialization of a static data
 	 member of a template is a definition if the declaration
@@ -7663,7 +7668,10 @@ grokfndecl (tree ctype,
 
   /* If the declaration was declared inline, mark it as such.  */
   if (inlinep)
-DECL_DECLARED_INLINE_P (decl) = 1;
+{
+  DECL_DECLARED_INLINE_P (decl) = 1;
+  DECL_COMDAT (decl) = 1;
+}
   if (inlinep & 2)
 DECL_DECLARED_CONSTEXPR_P (decl) = true;
 
@@ -14223,6 +14231,7 @@ grokmethod (cp_decl_specifier_seq *declspecs,
 
   check_template_shadow (fndecl);
 
+  DECL_COMDAT (fndecl) = 1;
   DECL_DECLARED_INLINE_P (fndecl) = 1;
   DECL_NO_INLINE_WARNING_P (fndecl) = 1;
 
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 8fa3145..884be0a 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -1930,6 +1930,12 @@ mark_needed (tree decl)
 	 definition.  */
   struct cgraph_node *node = cgraph_node::get_create (decl);
   node->forced_by_abi = true;
+
+  /* #pragma interface and -frepo code can call mark_needed for
+  maybe-in-charge 'tors; mark the clones as well.  */
+  tree clone;
+  FOR_EACH_CLONE (clone, decl)
+	mark_needed (clone);
 }
   else if (TREE_CODE (decl) == VAR_DECL)
 {
@@ -2728,17 +2734,7 @@ import_export_decl (tree decl)
 {
   /* The repository indicates that this entity should be defined
 	 here.  Make sure the back end honors that request.  */
-  if (VAR_P (decl))
-	mark_needed (decl);
-  else if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (decl)
-	   || DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl))
-	{
-	  tree clone;
-	  FOR_EACH_CLONE (clone, decl)
-	mark_needed (clone);
-	}
-  else
-	mark_needed (decl);
+  mark_needed (decl);
   /* Output the definition as an ordinary strong definition.  */
   DECL_EXTERNAL (decl) = 0;
   DECL_INTERFACE_KNOWN (decl) = 1;
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index e5fa0c1..f86a214 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -1798,8 +1798,6 @@ implicitly_declare_fn (special_function_kind kind, tree type,
   DECL_ARGUMENTS (fn) = this_parm;
 
   grokclassfn (type, fn, kind == sfk_destructor ? DTOR_FLAG : NO_SPECIAL);
-  set_linkage_according_to_type (type, fn);
-  rest_of_decl_compilation (fn, toplevel_bindings_p (), at_eof);
   DECL_IN_AGGR_P (fn) = 1;
   DECL_ARTIFICIAL (fn) = 1;
   DECL_DEFAULTED_FN (fn) = 1;
@@ -1811,6 +1809,9 @@ implicitly_declare_fn (special_function_kind kind, tree type,
   DECL_EXTERNAL (fn) = true;
   DECL_NOT_REALLY_EXTERN (fn) = 1;
   DECL_DECLARED_INLINE_P (fn) = 1;
+  DECL_COMDAT (fn) = 1;
+  set_linkage_according_to_type (type, fn);
+  rest_of_decl_compilation (fn, toplevel_bindings_p (), at_eof);
   gcc_assert (!TREE_USED (fn));
 
   /* Restore PROCESSING_TEMPLATE_DECL.  */
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index b32cf6c..0eac771 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -2787,6 +2

Re: [PATCH] libstdc++: add _GLIBCXX_ macro prefix in atexit_thread.cc

2014-07-30 Thread Jason Merrill

On 07/30/2014 11:25 AM, Jonathan Wakely wrote:

Jason, any objection to putting this on the 4.8 and 4.9 branches too?


That should be OK.

Jason




Re: [C++ Patch] PR 57397

2014-07-30 Thread Paolo Carlini

Hi,

On 07/30/2014 07:19 PM, Jason Merrill wrote:

On 07/30/2014 11:09 AM, Paolo Carlini wrote:

+  /* Eg (c++/57397):
+
+  template
+  void foo(T1, Tn..., Tm...);
+
+  int main()
+  {
+foo(1, 2);
+  }  */


I think we should accept this: T1 is int, Tn is {}, Tm is {int}.

Thus in fact current status is fine, a simpler patch, great.



+ template
+ void foo(T1, Tn..., Tm...);
+
+ int main()
+ {
+   foo(1);
+ }  */


And we should accept this.

To be clear: we do accept this with the patch applied.




   while (p && p != void_list_node)
 {
-  count++;
+  if (TREE_CODE (TREE_VALUE (p)) == TYPE_PACK_EXPANSION)
+trailing_packs = true;
+  else
+count++;
   p = TREE_CHAIN (p);
 }


Only a function parameter pack at the very end should trigger the "at 
least" message.  Other packs don't matter.

Ok... Let me adjust code and testcases...

Thanks!
Paolo.


Re: [PATCH, DOC]: New value 'default' for --enable-languages

2014-07-30 Thread Mike Stump
On Jul 30, 2014, at 6:20 AM, Richard Biener  wrote:
> On Wed, Jul 30, 2014 at 3:19 PM, Richard Biener
>  wrote:
>> On Wed, Jul 30, 2014 at 1:37 PM, Martin Liška  wrote:
>>> Hello,
>>>   as discussed in previous thread
>>> (https://gcc.gnu.org/ml/gcc-patches/2014-07/msg02010.html), I would like to
>>> add more intuitive behavior for --enable-languages configure option.
>> 
>> It works for me, but as I'm currently always testing all,ada,obj-c++ how
>> can I easily continue to do that - that is, not test go?  ;)
> 
> Of course with default,ada,obj-c++ ... stupid me.

In time, we’ll have a all,!go….  :-)


[GSoC][match-and-simplify] split match.pd

2014-07-30 Thread Prathamesh Kulkarni
I have split match.pd in this patch.
Not sure if I have written the ChangeLog correctly though...

* match-bitwise.pd: New file.
* match-plusminus.pd: Likewise.
* match-constant-folding.pd: Likewise.
* match-builtin.pd: Likewise.
* match-rotate.pd): New file.
Adjust to use wi::eq_p and wi::add.

* (match.pd): Move plus-minus patterns to ...
  (match-pluminus.pd): ... here.
Move bitwise paterns to ...
  (match-bitwise.pd): ... here.
Move constant folding patterns to ...
  (match-constant-folding.pd): ... here.
Move patterns on built-in functions to ...
  (match-builtin.pd): ... here.
Move rotate patterns to ...
  (match-rotate.pd): ... here.
Include match-plusminus.pd.
Include match-bitwise.pd.
Include match-constant-folding.pd.
Include match-builtin.pd.
Include match-rotate.pd.

Thanks,
Prathamesh
Index: gcc/match-bitwise.pd
===
--- gcc/match-bitwise.pd	(revision 0)
+++ gcc/match-bitwise.pd	(working copy)
@@ -0,0 +1,102 @@
+/* match-and-simplify patterns for simplify_bitwise_binary
+   Copyright (C) 2014 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+.  */
+
+/* TODO bitwise patterns:
+1] x & x -> x
+2] x & 0 -> 0
+3] x & -1 -> x
+4] x & ~x -> 0
+5] ~x & ~y -> ~(x | y)
+6] ~x | ~y -> ~(x & y)
+7] x & (~x | y) -> y & x
+8] (x | CST1) & CST2  ->  (x & CST2) | (CST1 & CST2)
+9] x ^ x -> 0
+10] x ^ ~0 -> ~x
+11] (x | y) & x -> x
+12] (x & y) | x -> x
+13] (~x | y) & x -> x & y
+14] (~x & y) | x -> x | y
+15] ((a & b) & ~a) & ~b -> 0
+16] ~~x -> x
+*/
+
+/* x & x -> x */
+(match_and_simplify
+  (bit_and integral_op_p@0 @0)
+  @0)
+
+/* x & ~x -> 0 */
+(match_and_simplify
+  (bit_and:c integral_op_p@0 (bit_not @0))
+  { build_int_cst (type, 0); })
+
+/* ~x & ~y -> ~(x | y) */
+(match_and_simplify
+  (bit_and (bit_not integral_op_p@0) (bit_not @1))
+  (bit_not (bit_ior @0 @1)))
+
+/* ~x | ~y -> ~(x & y) */
+(match_and_simplify
+  (bit_ior (bit_not integral_op_p@0) (bit_not @1))
+  (bit_not (bit_and @0 @1)))
+
+/* x & (~x | y) -> y & x */
+(match_and_simplify
+  (bit_and:c integral_op_p@0 (bit_ior:c (bit_not @0) @1))
+  (bit_and @1 @0))
+
+/* (x | CST1) & CST2 -> (x & CST2) | (CST1 & CST2) */
+(match_and_simplify
+  (bit_and (bit_ior integral_op_p@0 INTEGER_CST_P@1) INTEGER_CST_P@2)
+  (bit_ior (bit_and @0 @2) (bit_and @1 @2)))
+
+/* x ^ ~0 -> ~x */
+(match_and_simplify
+  (bit_xor @0 integer_all_onesp@1)
+  (bit_not @0))
+
+/* (x | y) & x -> x */
+(match_and_simplify
+  (bit_and:c (bit_ior integral_op_p@0 @1) @0)
+  @0)
+
+/* (x & y) | x -> x */
+(match_and_simplify
+  (bit_ior:c (bit_and integral_op_p@0 @1) @0)
+  @0)
+
+/* (~x | y) & x -> x & y */
+(match_and_simplify
+  (bit_and:c (bit_ior:c (bit_not integral_op_p@0) @1) @0)
+  (bit_and @0 @1))
+
+/* (~x & y) | x -> x | y */
+(match_and_simplify
+  (bit_ior:c (bit_and:c (bit_not integral_op_p@0) @1) @0)
+  (bit_ior @0 @1))
+
+/* ~~x -> x */
+(match_and_simplify
+  (bit_not (bit_not integral_op_p@0))
+  @0)
+
+/* ((a & b) & ~a) -> 0 */
+(match_and_simplify
+  (bit_and:c (bit_and integral_op_p@0 @1) (bit_not @0))
+  { build_int_cst (type, 0); })
Index: gcc/match-builtin.pd
===
--- gcc/match-builtin.pd	(revision 0)
+++ gcc/match-builtin.pd	(working copy)
@@ -0,0 +1,44 @@
+/* match-and-simplify patterns for builtin functions
+   Copyright (C) 2014 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+.  */
+
+
+/* One builtin function to atom.  */
+(match_and_simplify
+  (BUILT_IN_SQRT (mult @0 @0))
+  @0)
+/*

mark_virtual_overrides patch

2014-07-30 Thread Jason Merrill
Here it is again, without the DECL_COMDAT pieces; now that patch is in, 
this becomes just an optimization to improve devirtualization.


As you said before, because of caching we might miss new overrides that 
are introduced as a result of instantiating/synthesizing one of the 
overrides on the first pass.  This seems likely to be rare, so perhaps 
it's not worth worrying about.  What do you think?


Jason
commit 0271948001ca26f068935b04d13155a25c979af8
Author: Jason Merrill 
Date:   Tue Jul 29 12:42:51 2014 -0400

gcc/
	* ipa-devirt.c (possible_polymorphic_call_targets): Add overload
	taking a single tree.
	* ipa-utils.h: Declare it.
gcc/cp/
	* call.c (build_over_call): Call note_fn_called_virtually.
	* class.c (get_vtable_decl): Create a varpool node.
	* cp-tree.h (FNDECL_CALLED_VIRTUALLY): New.
	* decl2.c (fns_called_virtually, note_fn_called_virtually): New.
	(mark_virtual_overrides): New.
	(cp_write_global_declarations): Call it.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 4d37c65..969e730 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -7364,6 +7364,8 @@ build_over_call (struct z_candidate *cand, int flags, tsubst_flags_t complain)
 ba_any, NULL, complain);
   gcc_assert (binfo && binfo != error_mark_node);
 
+  note_fn_called_virtually (fn);
+
   /* Warn about deprecated virtual functions now, since we're about
 	 to throw away the decl.  */
   if (TREE_DEPRECATED (fn))
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 235c68a..1401069 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -817,6 +817,9 @@ get_vtable_decl (tree type, int complete)
   decl = build_vtable (type, get_vtable_name (type), vtbl_type_node);
   CLASSTYPE_VTABLES (type) = decl;
 
+  /* Make the vtable visible to build_type_inheritance_graph.  */
+  varpool_node::get_create (decl);
+
   if (complete)
 {
   DECL_EXTERNAL (decl) = 1;
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 0c0d804..c9f248a 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -109,6 +109,7 @@ c-common.h, not after.
   BIND_EXPR_BODY_BLOCK (in BIND_EXPR)
   DECL_NON_TRIVIALLY_INITIALIZED_P (in VAR_DECL)
   CALL_EXPR_LIST_INIT_P (in CALL_EXPR, AGGR_INIT_EXPR)
+  FNDECL_CALLED_VIRTUALLY (in FUNCTION_DECL)
4: TREE_HAS_CONSTRUCTOR (in INDIRECT_REF, SAVE_EXPR, CONSTRUCTOR,
 	  or FIELD_DECL).
   IDENTIFIER_TYPENAME_P (in IDENTIFIER_NODE)
@@ -3222,6 +3223,11 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter)
 #define FNDECL_USED_AUTO(NODE) \
   TREE_LANG_FLAG_2 (FUNCTION_DECL_CHECK (NODE))
 
+/* True if NODE was called through the vtable; used to avoid duplicates in
+   fns_called_virtually.  */
+#define FNDECL_CALLED_VIRTUALLY(NODE) \
+  TREE_LANG_FLAG_3 (FUNCTION_DECL_CHECK (NODE))
+
 /* Nonzero if NODE is a DECL which we know about but which has not
been explicitly declared, such as a built-in function or a friend
declared inside a class.  In the latter case DECL_HIDDEN_FRIEND_P
@@ -5381,6 +5387,7 @@ extern tree get_tls_wrapper_fn			(tree);
 extern void mark_needed(tree);
 extern bool decl_needed_p			(tree);
 extern void note_vague_linkage_fn		(tree);
+extern void note_fn_called_virtually		(tree);
 extern tree build_artificial_parm		(tree, tree);
 extern bool possibly_inlined_p			(tree);
 extern int parm_index   (tree);
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index eafdce5..dbb669a 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -47,6 +47,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "c-family/c-common.h"
 #include "c-family/c-objc.h"
 #include "cgraph.h"
+/* For build_type_inheritance_graph and possible_polymorphic_call_targets.  */
+#include "ipa-utils.h"
 #include "tree-inline.h"
 #include "c-family/c-pragma.h"
 #include "dumpfile.h"
@@ -103,6 +105,10 @@ static GTY(()) vec *deferred_fns;
sure are defined.  */
 static GTY(()) vec *no_linkage_decls;
 
+/* A list of functions called through the vtable, so we can mark their
+   overriders as used.  */
+static GTY(()) vec *fns_called_virtually;
+
 /* Nonzero if we're done parsing and into end-of-file activities.  */
 
 int at_eof;
@@ -786,6 +792,19 @@ note_vague_linkage_fn (tree decl)
   vec_safe_push (deferred_fns, decl);
 }
 
+/* DECL is a function being called through the vtable.  Remember it so that
+   at the end of the translation unit we can mark as used any functions
+   that override it, for devirtualization.  */
+
+void
+note_fn_called_virtually (tree decl)
+{
+  if (FNDECL_CALLED_VIRTUALLY (decl))
+return;
+  FNDECL_CALLED_VIRTUALLY (decl) = true;
+  vec_safe_push (fns_called_virtually, decl);
+}
+
 /* We have just processed the DECL, which is a static data member.
The other parameters are as for cp_finish_decl.  */
 
@@ -4263,6 +4282,39 @@ dump_tu (void)
 }
 }
 
+/* Now that we've seen all the types in the translation unit, go back over
+   the list of functions called through the vtable

Re: C++ PATCH to set DECL_COMDAT on undefined inlines/templates

2014-07-30 Thread Markus Trippelsdorf
On 2014.07.30 at 13:26 -0400, Jason Merrill wrote:
> Since can_refer_decl_in_current_unit_p doesn't allow references to 
> DECL_COMDAT entities that aren't defined in the current unit, by setting 
> that flag we can avoid problems with devirtualization introducing 
> references to vague linkage functions that haven't been 
> synthesized/instantiated because they aren't referenced directly.
> 
> The first attached patch sets DECL_COMDAT for inlines and templates.
> 
> The second attached patch removes the -fuse-all-virtuals code, which is 
> no longer needed for correctness.
> 
> Tested x86_64-pc-linux-gnu, applying to trunk.  I'm planning to apply 
> the first patch to 4.9.2 if it doesn't cause trouble on trunk.

It breaks Firefox build:
...
/tmp/cc1qQHsI.ltrans2.ltrans.o:cc1qQHsI.ltrans2.o:function 
JS::AutoGCRooter::trace(JSTracer*): error: undefined reference to 
'js::frontend::MarkParser(JSTracer*, JS::AutoGCRooter*)'
collect2: error: ld returned 1 exit status
/var/tmp/mozilla-central/config/rules.mk:719: recipe for target 'js' failed

I haven't looked deeper yet. 

-- 
Markus


Re: C++ PATCH to set DECL_COMDAT on undefined inlines/templates

2014-07-30 Thread Jason Merrill

On 07/30/2014 02:05 PM, Markus Trippelsdorf wrote:

It breaks Firefox build:


/sigh.


I haven't looked deeper yet.


Let me know what you find.

Thanks,
Jason




Re: [PATCH] Further cleanup loop-distribution

2014-07-30 Thread Mike Stump
On Jul 30, 2014, at 12:59 AM, Richard Biener  wrote:
>> So I do compiler testing on my toaster oven by doing native builds of gcc 
>> running on a binutils simulator and it doesn’t have a working popen (it’s in 
>> my newlib, but it wants vfork, which I don’t have).  I do have fork and 
>> system however.  :-) Could we replace the if 1 with if HAVE_popen where that 
>> is done by an autoconf link test?
> 
> Sure - patches welcome.  You could also use _POSIX_C_SOURCE >= 2
> || _XOPEN_SOURCE || _BSD_SOURCE || _SVID_SOURCE which I'm sure
> your newlib provide anyway(?)

Autoconf trivially solves the problem.  :-)  Thanks.

Committed revision 213309.

2014-07-30  Mike Stump  

* configure.ac: Also check for popen.
* tree-loop-distribution.c (dot_rdg): Autoconfize popen use.
* configure: Regenerate.
* config.in:  Regenerate.

2014-07-30  Mike Stump  

* configure.ac: Also check for popen.
* tree-loop-distribution.c (dot_rdg): Autoconfize popen use.
* configure: Regenerate.
* config.in:  Regenerate.

Index: config.in
===
--- config.in   (revision 213308)
+++ config.in   (working copy)
@@ -1468,6 +1468,12 @@
 #endif
 
 
+/* Define to 1 if you have the `popen' function. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_POPEN
+#endif
+
+
 /* Define to 1 if you have the `putchar_unlocked' function. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_PUTCHAR_UNLOCKED
Index: configure
===
--- configure   (revision 213308)
+++ configure   (working copy)
@@ -9285,7 +9285,7 @@ fi
 
 
 for ac_func in times clock kill getrlimit setrlimit atoll atoq \
-   sysconf strsignal getrusage nl_langinfo \
+   popen sysconf strsignal getrusage nl_langinfo \
gettimeofday mbstowcs wcswidth mmap setlocale \
clearerr_unlocked feof_unlocked   ferror_unlocked fflush_unlocked 
fgetc_unlocked fgets_unlocked   fileno_unlocked fprintf_unlocked fputc_unlocked 
fputs_unlocked   fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked  
 putchar_unlocked putc_unlocked madvise
 do :
Index: configure.ac
===
--- configure.ac(revision 213308)
+++ configure.ac(working copy)
@@ -1113,7 +1113,7 @@ define(gcc_UNLOCKED_FUNCS, clearerr_unlo
   fread_unlocked fwrite_unlocked getchar_unlocked getc_unlocked dnl
   putchar_unlocked putc_unlocked)
 AC_CHECK_FUNCS(times clock kill getrlimit setrlimit atoll atoq \
-   sysconf strsignal getrusage nl_langinfo \
+   popen sysconf strsignal getrusage nl_langinfo \
gettimeofday mbstowcs wcswidth mmap setlocale \
gcc_UNLOCKED_FUNCS madvise)
 
Index: tree-loop-distribution.c
===
--- tree-loop-distribution.c(revision 213308)
+++ tree-loop-distribution.c(working copy)
@@ -228,7 +228,7 @@ DEBUG_FUNCTION void
 dot_rdg (struct graph *rdg)
 {
   /* When debugging, you may want to enable the following code.  */
-#if 1
+#ifdef HAVE_POPEN
   FILE *file = popen ("dot -Tx11", "w");
   if (!file)
 return;


Re: [C++ Patch] PR 57397

2014-07-30 Thread Paolo Carlini

... I'm finishing testing the below.

Thanks!
Paolo.

//
Index: cp/pt.c
===
--- cp/pt.c (revision 213287)
+++ cp/pt.c (working copy)
@@ -5517,13 +5517,21 @@ unify_method_type_error (bool explain_p, tree arg)
 }
 
 static int
-unify_arity (bool explain_p, int have, int wanted)
+unify_arity (bool explain_p, int have, int wanted, bool least_p = false)
 {
   if (explain_p)
-inform_n (input_location, wanted,
- "  candidate expects %d argument, %d provided",
- "  candidate expects %d arguments, %d provided",
- wanted, have);
+{
+  if (least_p)
+   inform_n (input_location, wanted,
+ "  candidate expects at least %d argument, %d provided",
+ "  candidate expects at least %d arguments, %d provided",
+ wanted, have);
+  else
+   inform_n (input_location, wanted,
+ "  candidate expects %d argument, %d provided",
+ "  candidate expects %d arguments, %d provided",
+ wanted, have);
+}
   return 1;
 }
 
@@ -5534,9 +5542,10 @@ unify_too_many_arguments (bool explain_p, int have
 }
 
 static int
-unify_too_few_arguments (bool explain_p, int have, int wanted)
+unify_too_few_arguments (bool explain_p, int have, int wanted,
+bool least_p = false)
 {
-  return unify_arity (explain_p, have, wanted);
+  return unify_arity (explain_p, have, wanted, least_p);
 }
 
 static int
@@ -16617,18 +16626,33 @@ type_unification_real (tree tparms,
  are present, and the parm list isn't variadic.  */
   if (ia < nargs && parms == void_list_node)
 return unify_too_many_arguments (explain_p, nargs, ia);
-  /* Fail if parms are left and they don't have default values.  */
+  /* Fail if parms are left and they don't have default values and
+ they aren't all deduced as empty packs, eg (c++/57397):
+
+ template
+ void foo(T1, Tn..., Tm...);
+
+ int main()
+ {
+   foo(1);
+ }  */
   if (parms && parms != void_list_node
   && TREE_PURPOSE (parms) == NULL_TREE)
 {
   unsigned int count = nargs;
   tree p = parms;
-  while (p && p != void_list_node)
+  bool type_pack_p;
+  do
{
- count++;
+ type_pack_p = TREE_CODE (TREE_VALUE (p)) == TYPE_PACK_EXPANSION;
+ if (!type_pack_p)
+   count++;
  p = TREE_CHAIN (p);
}
-  return unify_too_few_arguments (explain_p, ia, count);
+  while (p && p != void_list_node);
+  if (count != nargs)
+   return unify_too_few_arguments (explain_p, ia, count,
+   type_pack_p);
 }
 
   if (!subr)
Index: testsuite/g++.dg/cpp0x/vt-57397-1.C
===
--- testsuite/g++.dg/cpp0x/vt-57397-1.C (revision 0)
+++ testsuite/g++.dg/cpp0x/vt-57397-1.C (working copy)
@@ -0,0 +1,22 @@
+// PR c++/57397
+// { dg-do compile { target c++11 } }
+
+template
+void foo(T1, Tn...);
+
+template
+void bar(T1, T2, Tn...);
+
+int main()
+{
+  foo();   // { dg-error "no matching" }
+  // { dg-message "candidate expects at least 1 argument, 0 provided" "" { 
target *-*-* } 12 }
+  foo(1);
+  foo(1, 2);
+  bar();   // { dg-error "no matching" }
+  // { dg-message "candidate expects at least 2 arguments, 0 provided" "" { 
target *-*-* } 16 }
+  bar(1);  // { dg-error "no matching" }
+  // { dg-message "candidate expects at least 2 arguments, 1 provided" "" { 
target *-*-* } 18 }
+  bar(1, 2);
+  bar(1, 2, 3);
+}
Index: testsuite/g++.dg/cpp0x/vt-57397-2.C
===
--- testsuite/g++.dg/cpp0x/vt-57397-2.C (revision 0)
+++ testsuite/g++.dg/cpp0x/vt-57397-2.C (working copy)
@@ -0,0 +1,24 @@
+// PR c++/57397
+// { dg-do compile { target c++11 } }
+
+template
+void foo(T1, Tn..., Tm...);
+
+template
+void bar(T1, T2, Tn..., Tm...);
+
+int main()
+{
+  foo();   // { dg-error "no matching" }
+  // { dg-message "candidate expects at least 1 argument, 0 provided" "" { 
target *-*-* } 12 }
+  foo(1);
+  foo(1, 2);
+  foo(1, 2, 3);
+  bar();   // { dg-error "no matching" }
+  // { dg-message "candidate expects at least 2 arguments, 0 provided" "" { 
target *-*-* } 17 }
+  bar(1);  // { dg-error "no matching" }
+  // { dg-message "candidate expects at least 2 arguments, 1 provided" "" { 
target *-*-* } 19 }
+  bar(1, 2);
+  bar(1, 2, 3);
+  bar(1, 2, 3, 4);
+}


Re: [PATCH, DOC]: New value 'default' for --enable-languages

2014-07-30 Thread Martin Liška

On 07/30/2014 06:38 PM, Mike Stump wrote:
> On Jul 30, 2014, at 6:20 AM, Richard Biener  
> wrote:
>> On Wed, Jul 30, 2014 at 3:19 PM, Richard Biener
>>  wrote:
>>> On Wed, Jul 30, 2014 at 1:37 PM, Martin Liška  wrote:
 Hello,
   as discussed in previous thread
 (https://gcc.gnu.org/ml/gcc-patches/2014-07/msg02010.html), I would like to
 add more intuitive behavior for --enable-languages configure option.
>>> It works for me, but as I'm currently always testing all,ada,obj-c++ how
>>> can I easily continue to do that - that is, not test go?  ;)
>> Of course with default,ada,obj-c++ ... stupid me.
> In time, we’ll have a all,!go….  :-)
Does 'go' mean that the patch is ready for trunk :D ?

Martin



Re: [C++ Patch] PR 57397

2014-07-30 Thread Jason Merrill

On 07/30/2014 03:00 PM, Paolo Carlini wrote:

+  /* Fail if parms are left and they don't have default values and
+ they aren't all deduced as empty packs, eg (c++/57397):
+
+ template
+ void foo(T1, Tn..., Tm...);
+
+ int main()
+ {
+   foo(1);
+ }  */


Let's drop the testcase from the comment, and add a mention that this is 
parallel to sufficient_parms_p.  OK with that change, thanks.


Jason



Re: [PATCH 5/7] Convert tree-ssa-dom to inchash

2014-07-30 Thread Jeff Law

On 07/30/14 08:23, Andi Kleen wrote:

From: Andi Kleen 

gcc/:

2014-07-29  Andi Kleen  

* tree-ssa-dom.c (iterative_hash_exprs_commutative):
Rename to inchash:add_expr_commutative. Convert to inchash.
(iterative_hash_hashable_expr): Rename to
inchash:add_hashable_expr. Convert to inchash.
(avail_expr_hash): Dito.

This is fine once the basic inchash namespace stuff is approved.

jeff



Re: [PATCH 7/7] Convert tree-ssa-tail-merge to inchash

2014-07-30 Thread Jeff Law

On 07/30/14 08:23, Andi Kleen wrote:

From: Andi Kleen 

gcc/:

2014-07-29  Andi Kleen  

* tree-ssa-tail-merge.c (same_succ_hash): Convert to inchash.

This is fine once the basic inchash stuff is approved.

jeff



Re: Patch for constexpr variable templates

2014-07-30 Thread Jason Merrill

On 07/29/2014 07:56 AM, Braden Obrzut wrote:

@@ -6289,6 +6289,14 @@ cp_parser_postfix_expression (cp_parser *parser, bool 
address_p, bool cast_p,
  break;

default:
+ /* Convert variable template into VAR_DECL. */
+ if (TREE_CODE (postfix_expression) == TEMPLATE_ID_EXPR
+ && variable_template_p (TREE_OPERAND (postfix_expression, 0)))
+   {
+ postfix_expression = finish_template_variable 
(postfix_expression);
+   }


Why not do this in cp_parser_id_expression?


+ if (DECL_FUNCTION_TEMPLATE_P (tmpl)
+ && DECL_STATIC_FUNCTION_P (tmpl)


Indentation mismatch.

Jason



  1   2   >