RE: [PATCH, i386] Handle extended family cpuid info for AMD

2014-08-01 Thread Gopalasubramanian, Ganesh
Uros!

 I would like to have a check for a family at the beginning, something like:

  if (name == signature_NSC_ebx)
processor = PROCESSOR_GEODE;
  else if (family == 22)
{
  if (has_movbe)

I get your idea of having the family checked first and then differentiating 
with cpuid info later.
But, this case is getting interesting because, BTVER1 and BTVER2 are two 
variants but don't really have same family numbers.
BTVER1 is family 14h and BTVER2 is family 16h. I don't see near term plans for 
any additional cpus to either 14h or 16h.
Given that fact, this particular check is applicable only for BTVER2.
In that case, having 

  else if (family == 22)
if (has_movbe)
   processor = PROCESSOR_BTVER2;

looks odd. 

Regards
Ganesh


Re: [AArch64] Implement movmem for the benefit of inline memcpy

2014-08-01 Thread Andrew Pinski
On Fri, Jun 6, 2014 at 1:50 AM, James Greenhalgh
james.greenha...@arm.com wrote:

 Hi,

 The move_by_pieces infrastructure performs a copy by repeatedly trying
 the largest safe copy it can make. So for a 15-byte copy we might see:

 offset   amount  bytes copied
 08   0-7
 84   8-11
 12   2   12-13
 14   1   14

 However, we can implement a 15-byte copy as so:

 offset   amount  bytes copied
 08   0-7
 78   7-14

 Which can prove more efficient for both space and speed.

 In this patch we set MOVE_RATIO low to avoid using move_by_pieces, and
 implement the movmem pattern name to expand small block copy cases. Note, this
 optimization does not apply for -mstrict-align targets, which must continue
 copying byte-by-byte.

 Setting MOVE_RATIO low in this way causes a few tests to begin failing,
 both of these are documented in the test-case as expected to fail for
 low MOVE_RATIO targets, which do not allow certain Tree-Level optimizations.


I think you should reevaluate setting MOVE_RATIO this low.  It is used
for SRA and IPA-SRA which both are very useful; more useful than
memmove optimizations can do.

In fact this optimization is not even valid for volatile variables.
Here is a testcase for the volatile issue:
struct __attribute__((packed)) t15{
  long long t8;
  int t4;
  short t2;
  unsigned char t1;
};
volatile struct t15 t15;
int f(struct t15 *a)
{
  t15 = *a;
}

Notice how we are writing to byte 7 twice to t15 in the outputted code.

Thanks,
Andrew Pinski


 Bootstrapped on aarch64-unknown-linux-gnu with no issues.

 OK for trunk?

 Thanks,
 James

 ---
 gcc/

 2014-06-06  James Greenhalgh  james.greenha...@arm.com

 * config/aarch64/aarch64-protos.h (aarch64_expand_movmem): New.
 * config/aarch64/aarch64.c (aarch64_move_pointer): New.
 (aarch64_progress_pointer): Likewise.
 (aarch64_copy_one_part_and_move_pointers): Likewise.
 (aarch64_expand_movmen): Likewise.
 * config/aarch64/aarch64.h (MOVE_RATIO): Set low.
 * config/aarch64/aarch64.md (movmemmode): New.

 gcc/testsuite/

 2014-06-06  James Greenhalgh  james.greenha...@arm.com

 * gcc.dg/tree-ssa/pr42585.c: Skip for AArch64.
 * gcc.dg/tree-ssa/sra-12.c: Likewise.


Re: [PATCH] Keep patch file permissions in mklog

2014-08-01 Thread Tom de Vries

On 01-08-14 06:21, Yury Gribov wrote:

Cc Diego.

---
From: Tom de Vries tom_devr...@mentor.com
Sent:  Saturday, May 31, 2014 11:47AM
To: Geoff Keating geo...@geoffk.org
Cc: GCC Patches
Subject: [PATCH] Keep patch file permissions in mklog

On 05/31/2014 11:47 AM, Tom de Vries wrote:
Geoff,

Currently, mklog resets the permissions on a patch file:


Yuri,
Diego,

The permissions problem does not occur anymore with the latests versions of 
mklog, since it doesn't modify the patch file anymore.


This patch adds a script contrib/mklog-in-patch, which uses mklog to generate 
the skeleton log, but generates the log at the start of the patch as mklog did 
before (which is how I like to use it).


OK for trunk?

I can also try to add an --inline option to mklog instead.

Thanks,
- Tom


2014-08-01  Tom de Vries  t...@codesourcery.com

	* mklog-in-patch: New script.

diff --git a/contrib/mklog-in-patch b/contrib/mklog-in-patch
new file mode 100755
index 000..6d041eb
--- /dev/null
+++ b/contrib/mklog-in-patch
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+# 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 COPYING.  If not, write to
+# the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+
+# Check for errors
+set -e
+
+scriptdir=$(dirname $0)
+prog=$(basename $0)
+
+diff=$1
+
+if [ $diff =  ]; then
+   usage
+echo EOF
+usage: $prog file.diff
+
+Invokes mklog, and prepends the generated log to file.diff.
+EOF
+elif [ ! -r $diff ]; then
+echo Could not open file $diff for reading
+exit 1
+fi
+
+temp=$(mktemp)
+
+# Generate log in $temp
+if ! $scriptdir/mklog $diff  $temp; then
+echo Could not write log file to $temp
+exit 1
+fi
+
+# Append patch to $temp, and move $temp to $patch.  For the latter, we use cat
+# rather than mv to keep $diff permissions the same.
+if ! ( cat $diff $temp  cat $temp $diff ); then
+echo Could not add the ChangeLog entry to $diff
+exit 1
+fi
+
+if ! rm $temp; then
+echo Could not remove $temp
+exit 1
+fi


Re: [PATCH] Fix PR61375: cancel bswap optimization when value doesn't fit in a HOST_WIDE_INT

2014-08-01 Thread Jakub Jelinek
On Thu, Jul 31, 2014 at 02:57:34PM +0800, Thomas Preud'homme wrote:
 Now that GCC 4.9 branch is opened again and GCC 4.8 branch still open, is
 the following backported patch ok for both branches?

Ok.

  Ok, what about the following patch and associated ChangeLog entries?
  
  2014-06-24  Thomas Preud'homme  thomas.preudho...@arm.com
  
  PR tree-optimization/61375
  * tree-ssa-math-opts.c (find_bswap_or_nop_1): Cancel optimization
  if
  symbolic number cannot be represented in an unsigned
  HOST_WIDE_INT.
  (execute_optimize_bswap): Cancel optimization if CHAR_BIT != 8.
  
  2014-06-24  Thomas Preud'homme  thomas.preudho...@arm.com
  
  PR tree-optimization/61375
  * gcc.c-torture/execute/pr61375-1.c: New test.

Jakub


Re: [PATCH] Move Asan instrumentation to sanopt pass

2014-08-01 Thread Jakub Jelinek
On Mon, Jul 28, 2014 at 06:14:08PM +0400, Yury Gribov wrote:
 On 07/24/2014 11:48 AM, Jakub Jelinek wrote:
  So, either support for just EAF*, or perhaps support for DECL_ATTRIBUTES
  for internal-fns, say by having some tree array where you'd store what you
  stick into DECL_ATTRIBUTES normally.
 
 I'd prefer to avoid attributes. Would something like this be enough?
 (not yet fully tested, just ran asan.exp tests).

I think I'd prefer if you'd specify the fnspec as either NULL (most internal
functions) or normal string and reuse the string parsing in
gimple_call_arg_flags.
So, you'd just replace the:
  tree attr = gimple_call_fnspec (stmt);

  if (!attr || 1 + arg = (unsigned) TREE_STRING_LENGTH (attr))
return 0;

  switch (TREE_STRING_POINTER (attr)[1 + arg])
with:
  const char *fnspec;
  if (gimple_call_arg_flags (stmt))
{
  fnspec = ...;
  if (!fnspec || 1 + arg = strlen (fnspec))
return 0;
}
  else
{
  tree attr = gimple_call_fnspec (stmt);

  if (!attr || 1 + arg = (unsigned) TREE_STRING_LENGTH (attr))
return 0;

  fnspec = TREE_STRING_POINTER (attr);
}
  switch (fnspec[1 + arg])

Jakub


Re: [PATCH] Keep patch file permissions in mklog

2014-08-01 Thread Yury Gribov

On 08/01/2014 10:52 AM, Tom de Vries wrote:

This patch adds a script contrib/mklog-in-patch, which uses mklog to
generate the skeleton log, but generates the log at the start of the
patch as mklog did before (which is how I like to use it).


Yeah, we had some argument about this but kind of agreed that separate 
log is preferred.



I can also try to add an --inline option to mklog instead.


I'd prefer this.

-Y


Re: FWD: Re: OpenACC subarray specifications in the GCC Fortran front end

2014-08-01 Thread Jakub Jelinek
On Wed, Jul 23, 2014 at 05:42:32PM -0700, Cesar Philippidis wrote:
  Jakub, before your Fortran OpenMP 4 target changes, Ilmir had written the
  test case gcc/testsuite/gfortran.dg/gomp/map-1.f90 (based on his
  interpretation and implementation of OpenMP 4 target), which I have now
  amended with XFAILs and changed error messages -- anything in there that
  you'd like to see addressed for Fortran OpenMP 4 target?
  
  +  !$omp target map(j(5:4)) ! { dg-error Lower bound of OpenMP array 
  section in greater than upper  { xfail *-*-* } }
  +  !$omp end target
  
  I think this isn't an error in Fortran, if low bound is above upper bound,
  then it is considered a zero size array section.  Though supposedly for
  depend clause we might want to diagnose that.
  
  +  !$omp target map(aas) ! { dg-error The upper bound in the last 
  dimension must appear  { xfail *-*-* } }
  +  !$omp end target
  
  Assumed-size in map without array section would be indeed nice thing to
  diagnose.
  
  +  !$omp target map(tt%i) ! { dg-error Syntax error in OpenMP variable 
  list }
  +  !$omp end target ! { dg-bogus Unexpected !\\\$OMP END TARGET 
  statement  { xfail *-*-* } }
  
  Right now the parsing of !$omp directives in case of parsing error rejects
  the whole directive, perhaps it should be reconsidered unless it is a fatal
  error from which there is no easy way out.
  
  +  !$omp target map(tt%j(1)) ! { dg-bogus Syntax error in OpenMP variable 
  list  { xfail *-*-* } }
  +  !$omp end target ! { dg-bogus Unexpected !\\\$OMP END TARGET 
  statement  { xfail *-*-* } }
  +
  +  !$omp target map(tt%j(1:)) ! { dg-bogus Syntax error in OpenMP 
  variable list  { xfail *-*-* } }
  +  !$omp end target ! { dg-bogus Unexpected !\\\$OMP END TARGET 
  statement  { xfail *-*-* } }
  
  These two are pending resolution on omp-lang, I had exchanged a few mails
  about it, I think we shouldn't support those for consistency with the C/C++
  support, where tt.j[1] or tt.j[1:] and similar is explicitly invalid.
 
 Jakub, should I drop the map-1.f90 test?

Not the whole testcase, just the problematic parts (or, just remove the
dg-error/xfail or replace dg-bogus xfail with dg-error), for the j(5:4)
and tt%j(1)/tt%j(1:) cases?

Jakub


Re: [PATCH, i386] Handle extended family cpuid info for AMD

2014-08-01 Thread Uros Bizjak
On Fri, Aug 1, 2014 at 8:18 AM, Gopalasubramanian, Ganesh
ganesh.gopalasubraman...@amd.com wrote:

 I would like to have a check for a family at the beginning, something like:

  if (name == signature_NSC_ebx)
processor = PROCESSOR_GEODE;
  else if (family == 22)
{
  if (has_movbe)

 I get your idea of having the family checked first and then differentiating 
 with cpuid info later.
 But, this case is getting interesting because, BTVER1 and BTVER2 are two 
 variants but don't really have same family numbers.
 BTVER1 is family 14h and BTVER2 is family 16h. I don't see near term plans 
 for any additional cpus to either 14h or 16h.
 Given that fact, this particular check is applicable only for BTVER2.
 In that case, having

   else if (family == 22)
 if (has_movbe)
processor = PROCESSOR_BTVER2;

 looks odd.

In this case, having only check for family ID should be enough. If
BTVER1 and BTVER2 can be uniquely determined by their family IDs ,
then:

... (signature checks)
else if (family == 0x16h)
  processor = PROCESSOR_BTVER2;
else if (family == 0x14h)
  processor = PROCESSOR_BTVER1;
else
  ... (detect processor in a generic way by its cpuid features.)

IMO, this would be the most future-proof approach. Signature checks
will override family id checks which will override cpuid checks.

Uros.


Re: [PATCH][Ping v5] Add patch for debugging compiler ICEs

2014-08-01 Thread Jakub Jelinek
On Thu, Jul 24, 2014 at 04:39:28PM +0400, Maxim Ostapenko wrote:
 Ping.

Don't want to review a patch I wrote partially, so just a few comments:
1) IMHO it should be configure time selectable (not sure about the default,
but for non-release branches IMHO it should default to off, for release
branches I don't know).  The point is that while it is useful for
people to report gcc bugs in production compilers, it is not useful for
gcc developers on their boxes, having ICEs take 3 times as long is not
desirable for people who deal with those all the time
2) recently a bug has been reported that some ICEs which print RTL
to stderr are considered non-reproduceable, because the addresses e.g.
in call_insn fndecl change through address space randomization.  For the
retries the driver should supposedly append -fdump-noaddr.

Jakub


Re: [Patch] PR 61692 - Fix for inline asm ICE

2014-08-01 Thread David Wohlferd


On 7/30/2014 9:58 PM, Jeff Law wrote:

On 07/28/14 16:39, David Wohlferd wrote:


On 7/28/2014 12:42 PM, Jeff Law wrote:

On 07/27/14 01:26, David Wohlferd wrote:

I'm not sure which maintainer to cc for inline asm stuff?

I have a release on file with the FSF, but don't have SVN write 
access.


Problem:
extract_insn() in recog.c will ICE if (noperands  
MAX_RECOG_OPERANDS).
Normally this isn't a problem since expand_asm_operands() in 
cfgexpand.c

catches and reports a proper error for this condition. However,
expand_asm_operands() only checks (ninputs + noutputs) instead of
(ninputs + noutputs + nlabels), so you can get the ICE when using asm
goto.  See the bugzilla entry for sample code.

ChangeLog:
2014-07-27  David Wohlferd  d...@limegreensocks.com

 PR target/61692
 * cfgexpand.c (expand_asm_operands): Count all inline asm
parameters.

You should also include 'nclobbers'.


Reading thru asm_noperands (which is what extract_insn uses to count
operands), I would have thought you were right.  But while making this
fail with nLabels was easy, I wasn't able to get this to ICE at all
using clobbers (30 labels + 11 clobbers still didn't ICE).

And I'm reluctant to propose that change unless I can see it fail.
I understand, but I'm still quite confident it's the right thing to 
do.  Running that 30 label + 11 clobber testcase under valgrind might 
show the problem, if you can stand waiting that long...


I'd love to.  Unfortunately, my platform doesn't support valgrind.


Also, please include the testcase you had nlabels part.


I have created the testcase for the 31 labels problem.  However, not so 
much for the nclobbers part.  And if I'm going to patch both, I should 
have testcases for both.


I also worry about potentially breaking existing code.  While the 31 
labels thing I proposed won't break existing code (it would have been 
ICE-ing), adding nclobbers to the count of parameters could do so.


When Jeff Law says that something is so about gcc, I tend to believe 
that it is so.  But, unless I can see an example of the actual problem 
here, I have no idea how to create a test case for it.  So I spent the 
last several hours hunting for it.


If valgrind was going to show the problem, presumably we were expecting 
some type of array overrun.  And there are a LOT of places that do 
foo[MAX_RECOG_OPERANDS].  Absent valgrind, I resorted to using printfs 
sprinkled throughout the code to check indices. However, despite my best 
efforts, I was unable to see any out of range accesses, gcc_asserts, 
segment faults or any other indications of a problem.  All the places I 
tried seem to treat clobbers separately.  That doesn't prove anything: I 
could easily have missed something.  But I did make a sincere effort.


Given how confident you are that there's a problem, could you point out 
a place+condition I should focus on?  That way I can create the 
additional test case, satisfy my curiosity, and sleep soundly at night 
knowing I haven't (unnecessarily) broken people's code.


Thanks,
dw


[Ada] Remove VMS handling in most tools

2014-08-01 Thread Arnaud Charlet
Continuation of VMS removal in the GNAT front-end.

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

2014-08-01  Arnaud Charlet  char...@adacore.com

* binde.adb, bindgen.adb, butil.adb, clean.adb, gnatbind.adb,
gnatchop.adb, gnatcmd.adb, gnatls.adb, gnatname.adb, krunch.adb,
make.adb, makeutl.adb, memtrack.adb, mlib-prj.adb, mlib.adb,
mlib.ads, tempdir.adb: Remove VMS handling.

Index: binde.adb
===
--- binde.adb   (revision 213263)
+++ binde.adb   (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  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- --
@@ -31,7 +31,6 @@
 with Opt;  use Opt;
 with Osint;
 with Output;   use Output;
-with Targparm; use Targparm;
 
 with System.Case_Util; use System.Case_Util;
 
@@ -1089,12 +1088,7 @@
   if Pessimistic_Elab_Order
 and not Dynamic_Elaboration_Checks_Specified
   then
- if OpenVMS_On_Target then
-Error_Msg (?use of /PESSIMISTIC_ELABORATION questionable);
- else
-Error_Msg (?use of -p switch questionable);
- end if;
-
+ Error_Msg (?use of -p switch questionable);
  Error_Msg (?since all units compiled with static elaboration model);
   end if;
 
Index: bindgen.adb
===
--- bindgen.adb (revision 213329)
+++ bindgen.adb (working copy)
@@ -52,10 +52,6 @@
Last : Natural := 0;
--  Last location in Statement_Buffer currently set
 
-   With_DECGNAT : Boolean := False;
-   --  Flag which indicates whether the program uses the DECGNAT library
-   --  (presence of the unit DEC).
-
With_GNARL : Boolean := False;
--  Flag which indicates whether the program uses the GNARL library
--  (presence of the unit System.OS_Interface)
@@ -325,9 +321,7 @@
--  Move routine for sorting linker options
 
procedure Resolve_Binder_Options;
-   --  Set the value of With_GNARL and With_DECGNAT. The latter only on VMS
-   --  since it tests for a package named dec which might cause a conflict
-   --  on non-VMS systems.
+   --  Set the value of With_GNARL.
 
procedure Set_Char (C : Character);
--  Set given character in Statement_Buffer at the Last + 1 position
@@ -659,36 +653,6 @@
  __gnat_finalize_library_objects););
  end if;
 
- --  Import entry point for environment feature enable/disable
- --  routine, and indication that it's been called previously.
-
- if OpenVMS_On_Target then
-WBI ();
-WBI (  procedure Set_Features;);
-WBI (  pragma Import (C, Set_Features,  
- __gnat_set_features););
-WBI ();
-WBI (  Features_Set : Integer;);
-WBI (  pragma Import (C, Features_Set,  
- __gnat_features_set););
-
-if Opt.Heap_Size /= 0 then
-   WBI ();
-   WBI (  Heap_Size : Integer;);
-   WBI (  pragma Import (C, Heap_Size,  
-__gl_heap_size););
-
-   Write_Statement_Buffer;
-end if;
-
-WBI ();
-WBI (  Float_Format : Character;);
-WBI (  pragma Import (C, Float_Format,  
-__gl_float_format););
-
-Write_Statement_Buffer;
- end if;
-
  --  Initialize stack limit variable of the environment task if the
  --  stack check method is stack limit and stack check is enabled.
 
@@ -886,44 +850,6 @@
 WBI ( Install_Handler;);
 WBI (  end if;);
  end if;
-
- --  Generate call to Set_Features
-
- if OpenVMS_On_Target then
-
---  Set_Features will call IEEE$SET_FP_CONTROL appropriately
---  depending on the setting of Float_Format.
-
-WBI ();
-Set_String (  Float_Format := ');
-
-if Float_Format_Specified = 'G'
- or else
-   Float_Format_Specified = 'D'
-then
-   Set_Char ('V');
-else
-   Set_Char ('I');
-end if;
-
-Set_String (';);
-Write_Statement_Buffer;
-
-WBI ();
-WBI (  if Features_Set = 0 then);
-WBI ( Set_Features;);
-

Re: [PATCH][Ping v5] Add patch for debugging compiler ICEs

2014-08-01 Thread Yury Gribov

On 08/01/2014 12:00 PM, Jakub Jelinek wrote:

Don't want to review a patch I wrote partially, so just a few comments:
1) IMHO it should be configure time selectable (not sure about the default,
but for non-release branches IMHO it should default to off, for release
branches I don't know).  The point is that while it is useful for
people to report gcc bugs in production compilers, it is not useful for
gcc developers on their boxes, having ICEs take 3 times as long is not
desirable for people who deal with those all the time


I think we should use David Malcolm's approach i.e. add some 
--report-bug flag
to driver. This could be enabled by default at configure time via 
--with-spec.



2) recently a bug has been reported that some ICEs which print RTL
to stderr are considered non-reproduceable, because the addresses e.g.
in call_insn fndecl change through address space randomization.  For the
etries the driver should supposedly append -fdump-noaddr.


+1

-Y


[Ada] More VMS clean ups

2014-08-01 Thread Arnaud Charlet
In various parts of the front-end.

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

2014-08-01  Robert Dewar  de...@adacore.com

* inline.adb, inline.ads, fe.h, einfo.adb, einfo.ads, sem_util.adb,
sem_util.ads, exp_ch4.adb, exp_ch11.adb, exp_ch6.adb, cstand.adb,
sem_mech.adb, sem_ch6.adb, sem_ch8.adb, sem_ch11.adb, snames.ads-tmpl:
Remove VMS-specific code.

Index: inline.adb
===
--- inline.adb  (revision 213373)
+++ inline.adb  (working copy)
@@ -165,10 +165,10 @@
 
function Has_Single_Return (N : Node_Id) return Boolean;
--  In general we cannot inline functions that return unconstrained type.
-   --  However, we can handle such functions if all return statements return
-   --  a local variable that is the only declaration in the body of the
-   --  function. In that case the call can be replaced by that local
-   --  variable as is done for other inlined calls.
+   --  However, we can handle such functions if all return statements return a
+   --  local variable that is the only declaration in the body of the function.
+   --  In that case the call can be replaced by that local variable as is done
+   --  for other inlined calls.
 
function In_Main_Unit_Or_Subunit (E : Entity_Id) return Boolean;
--  Return True if E is in the main unit or its spec or in a subunit
@@ -429,7 +429,7 @@
 
   procedure Register_Backend_Not_Inlined_Subprogram (Subp : Entity_Id);
   --  Append Subp to the list of subprograms that cannot be inlined by
-  --  the backend
+  --  the backend.
 
   
   -- Back_End_Cannot_Inline --
@@ -3332,7 +3332,7 @@
 --  expanded into a procedure call which must be added after the
 --  object declaration.
 
-if Is_Unc_Decl and then Back_End_Inlining then
+if Is_Unc_Decl and Back_End_Inlining then
Insert_Action_After (Parent (N), Blk);
 else
Set_Expression (Parent (N), Empty);
@@ -4329,9 +4329,9 @@
   return False;
end Has_Initialized_Type;
 
-   
-   --  Has_Single_Return --
-   
+   ---
+   -- Has_Single_Return --
+   ---
 
function Has_Single_Return (N : Node_Id) return Boolean is
   Return_Statement : Node_Id := Empty;
@@ -4376,8 +4376,8 @@
return Abandon;
 end if;
 
- --  We can only inline a build-in-place function if
- --  it has a single extended return.
+ --  We can only inline a build-in-place function if it has a single
+ --  extended return.
 
  elsif Nkind (N) = N_Extended_Return_Statement then
 if No (Return_Statement) then
@@ -4572,6 +4572,8 @@
-- Number_Of_Statements --
--
 
+   --  Why not List_Length???
+
function Number_Of_Statements (Stats : List_Id) return Natural is
   Stat_Count : Integer := 0;
   Stmt   : Node_Id;
Index: inline.ads
===
--- inline.ads  (revision 213373)
+++ inline.ads  (working copy)
@@ -131,6 +131,9 @@
  Table_Increment  = Alloc.Pending_Instantiations_Increment,
  Table_Name   = Pending_Descriptor);
 
+   --  The following should be initialized in an init call in Frontend, we
+   --  have thoughts of making the frontend reusable in future ???
+
Inlined_Calls : Elist_Id := No_Elist;
--  List of frontend inlined calls
 
@@ -242,13 +245,14 @@
function Has_Excluded_Declaration
  (Subp  : Entity_Id;
   Decls : List_Id) return Boolean;
-   --  Check for declarations that make inlining not worthwhile inlining Subp
+   --  Check a list of declarations, Decls, that make the inlining of Subp not
+   --  worthwhile
 
function Has_Excluded_Statement
  (Subp  : Entity_Id;
   Stats : List_Id) return Boolean;
-   --  Check for statements that make inlining not worthwhile: any tasking
-   --  statement, nested at any level.
+   --  Check a list of statements, Stats, that make inlining of Subp not
+   --  worthwhile, including any tasking statement, nested at any level.
 
procedure Register_Backend_Call (N : Node_Id);
--  Append N to the list Backend_Calls
Index: fe.h
===
--- fe.h(revision 213353)
+++ fe.h(working copy)
@@ -154,11 +154,6 @@
 
 extern Boolean Is_Fully_Repped_Tagged_Type  (Entity_Id);
 
-/* exp_vfpt: */
-
-#define Get_Vax_Real_Literal_As_Signed exp_vfpt__get_vax_real_literal_as_signed
-extern Ureal Get_Vax_Real_Literal_As_Signed (Node_Id);
-
 /* lib: */
 
 #define Cunit  lib__cunit
Index: einfo.adb
===
--- einfo.adb   (revision 213371)
+++ einfo.adb   (working copy)
@@ -195,7 +195,6 @@

[PATCH][AArch64] Improve TARGET_LEGITIMIZE_ADDRESS_P hook

2014-08-01 Thread Jiong Wang

currently, aarch64 LEGITIMIZE_ADDRESS_P hook will reject all reg + offset 
address given
offset is beyond supported range.

while this may be too strict. we should honor the strict_p parameter in the 
hook. before
reload, we accept all offset if it's a frame access, because the offset may 
change during
later register elimination.

the early reject of reg + offset may cause extra registers created, and if 
that register
live range is across function invoking then callee saved reg needed, thus 
introduce extra
reg save/restore also.

give a simple example as:

int
test15 (void)
{
  unsigned char a[480];
  initialize_array (a, 480);

  if (a[0] == 0x10)
return 1;

  return 0;
}

.S before the patch
(-O2 -fPIC)
===
test15:
sub sp, sp, #480
mov w1, 480
stp x29, x30, [sp, -32]!
add x29, sp, 0
str x19, [sp, 16]
add x19, x29, 32
mov x0, x19
bl  initialize_array
ldrbw0, [x19]
ldr x19, [sp, 16]
ldp x29, x30, [sp], 32
cmp w0, 16
csetw0, eq
add sp, sp, 480
ret

.S after the patch
===
test15:
stp x29, x30, [sp, -496]!
mov w1, 480
add x29, sp, 0
add x0, x29, 16
bl  initialize_array
ldrbw0, [x29, 16]
ldp x29, x30, [sp], 496
cmp w0, 16
csetw0, eq
ret

test done
=
no regression on aarch64-none-elf bare metal.
bootstrap OK on aarch64.

OK for trunk?

thanks.

gcc/
  * config/aarch64/aarch64.c (aarch64_classify_address): Accept all offset for 
frame access
  when strict_p is false.

gcc/testsuite
  * gcc.target/aarch64/legitimize_stack_var_before_reload_1.c: New testcase.
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index ed80269..c8e5808 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -3248,6 +3248,21 @@ aarch64_classify_address (struct aarch64_address_info *info,
 case PLUS:
   op0 = XEXP (x, 0);
   op1 = XEXP (x, 1);
+
+  if (! strict_p
+	   GET_CODE (op0) == REG
+	   (op0 == virtual_stack_vars_rtx
+	  || op0 == frame_pointer_rtx
+	  || op0 == arg_pointer_rtx)
+	   GET_CODE (op1) == CONST_INT)
+	{
+	  info-type = ADDRESS_REG_IMM;
+	  info-base = op0;
+	  info-offset = op1;
+
+	  return true;
+	}
+
   if (GET_MODE_SIZE (mode) != 0
 	   CONST_INT_P (op1)
 	   aarch64_base_register_rtx_p (op0, strict_p))
diff --git a/gcc/testsuite/gcc.target/aarch64/legitimize_stack_var_before_reload_1.c b/gcc/testsuite/gcc.target/aarch64/legitimize_stack_var_before_reload_1.c
new file mode 100644
index 000..e5f0bd1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/legitimize_stack_var_before_reload_1.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options -O2 -fdump-rtl-expand } */
+
+extern void initialize_array (unsigned char *, int);
+
+int
+test15 (void)
+{
+  unsigned char a[480];
+
+  initialize_array (a, 480);
+
+  if (a[0] == 0x10)
+return 1;
+
+  return 0;
+}
+
+/* { dg-final { scan-rtl-dump mem/j/c:QI \\(plus:DI expand } } */
+
+/* { dg-final { cleanup-rtl-dump expand } } */

Re: [PATCH][1-3] New configure options that make the compiler use -fPIE and -pie as default option

2014-08-01 Thread Rainer Orth
Hi Magnus,

a couple of comments, mostly nits.

 2014-07-31  Magnus Granberg  zo...@gentoo.org

   /gcc
   * config/gnu-user.h: Define PIE_DRIVER_SELF_SPECS for PIE 
   as default and GNU_DRIVER_SELF_SPECS.
   * config/i386/gnu-user-common.h: Define DRIVER_SELF_SPECS
   * configure.ac: Add new option that enable PIE as default.
   * configure, config.in: Rebuild.
   * Makefile.in: Disable PIE when building the compiler.
   * doc/install.texi: Add the new configure option default PIE.
   * doc/invoke.texi: Add note for the new configure option default PIE.

Many of those entries are mis-formatted.  See other examples and the GNU
Coding Standards for details.  E.g. the first would be

* config/gnu-user.h (PIE_DRIVER_SELF_SPECS): Define.

In general, you need to mention which macro, variable, manual section
you change.  Emacs' add-change-log-entry does the basics for you.
Besides, you only state what changed, not why.

Apart from that, I don't think defining PIE_DRIVER_SELF_SPECS in
gnu-user.h is a good idea.  This way, every other target supporting the
option would have to duplicate that stuff.

* testsuite/gcc/default-pie.c: New test for new configure option
--enale-default-pie

gcc/testsuite has its own ChangeLog file.  Typo for --enale-...

* testsuite/gcc.dg/other/anon5.C: Add skip test as it fail to link
on effective_target default_pie.

should be

* g++.dg/other/anon5.C: Skip if default_pie.

No explanations in ChangeLog entries; they belong into the code.
Besides, you had the first dir component wrong.  Again, Emacs does this
for you.

* testsuite/lib/target-supports.exp (check_profiling_available):
We can't use profiling on effective target default_pie. 
(check_effective_target_pie): Add check_effective_target_default_pie.

Wrong: should be

* lib/target-supports.exp (check_effective_target_default_pie):
New proc.

The new default_pic effective-target keyword needs to be documented in
doc/sourcebuild.texi.

--- a/gcc/testsuite/gcc.dg/default-pie.c2013-11-09 21:07:16.741479728 
+0100
+++ b/gcc/testsuite/gcc.dg/default-pie.c2013-11-09 21:05:07.801479218 
+0100
@@ -0,0 +1,12 @@
+/* { dg-do compile { target *-*-linux* *-*-gnu* } } */
+/* { dg-require-effective-target default_pie } */

Why restrict to Linux, GNU?  default_pie should be enough once other
targets add this.

--- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-3.c   2012-03-14 
17:33:37.0 +0100
+++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-store-ccp-3.c   2014-07-29 
00:55:17.421086416 +0200
@@ -2,6 +2,9 @@
 /* Skipped on MIPS GNU/Linux target because __PIC__ can be
defined for executables as well as shared libraries.  */
 /* { dg-skip-if  { *-*-darwin* hppa*64*-*-* mips*-*-linux* *-*-mingw* } { 
* } {  } } */
+/* Skipped on default_pie targets because __PIC__ is
+   defined for executables.  */
+/* { dg-skip-if  { default_pie } { * } {  } }  */

Emit those default args, they're unnecessary.  Also in g++.dg/other/anon5.C.

--- a/gcc/testsuite/g++.dg/other/anon5.C2012-11-10 15:34:42.0 
+0100
+++ b/gcc/testsuite/g++.dg/other/anon5.C2013-11-09 14:49:52.281390127 
+0100
@@ -1,5 +1,6 @@
 // PR c++/34094
 // { dg-do link { target { ! { *-*-darwin* *-*-hpux* *-*-solaris2.* } } } }
+// { dg-skip-if  { default_pie } { * } {  } }

The first arg to dg-skip-if should explain why you're skipping the test.

--- a/gcc/testsuite/lib/target-supports.exp 2013-10-01 11:18:30.0 
+0200
+++ b/gcc/testsuite/lib/target-supports.exp 2013-10-25 22:01:46.743388469 
+0200
@@ -474,6 +474,11 @@ proc check_profiling_available { test_wh
}
 }
 
+# Profiling don't work with default -fPIE -pie.

Grammar: doesn't work.

+# Return 1 if -pie, -fPIE are default enable, 0 otherwise.
+
+proc check_effective_target_default_pie { } {

Hard to understand, perhaps

# Return 1 if -pie -fPIE are enabled by default, 0 otherwise.

--- a/gcc/doc/invoke.texi   2013-10-03 19:13:50.0 +0200
+++ b/gcc/doc/invoke.texi   2013-11-17 21:30:02.784220111 +0100
@@ -10535,6 +10535,12 @@ For predictable results, you must also s
 used for compilation (@option{-fpie}, @option{-fPIE},
 or model suboptions) when you specify this linker option.
 
+NOTE: With configure --enable-default-pie this option is enabled by default

With the @option{--enable-default-pie} configure option, ...

+for C, C++, ObjC, ObjC++, if none of @option{-fno-PIE}, @option{-fno-pie},
+@option{-fPIC}, @option{-fpic}, @option{-fno-PIC}, @option{-fno-pic},
+@option{-nostdlib}, @option{-nostartfiles}, @option{-shared},
+@option{-nodefaultlibs}, nor @option{static} are found.

@option{-static}.

Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [PATCH, Cilk+] Fix for PR61962

2014-08-01 Thread Richard Biener
On Thu, Jul 31, 2014 at 9:51 PM, Zamyatin, Igor igor.zamya...@intel.com wrote:
 Hi!

 This patch fixes endless compilation for the case of array notation for an 
 array which is a structure member

 Ok for trunk/4.9 once testing finished?

 Thanks,
 Igor

 Changelog:

 gcc/c-family:

 2014-07-31  Igor Zamyatin  igor.zamya...@intel.com

 PR other/61962
 * array-notation-common.c (find_rank): Added handling for other
 types of references.


 gcc/testsuite:

 2014-07-31  Igor Zamyatin  igor.zamya...@intel.com

 PR other/61962
 * c-c++-common/cilk-plus/AN/pr61962.c: New test.



 diff --git a/gcc/c-family/array-notation-common.c 
 b/gcc/c-family/array-notation-common.c
 index c010039..5db14c6 100644
 --- a/gcc/c-family/array-notation-common.c
 +++ b/gcc/c-family/array-notation-common.c
 @@ -221,7 +221,9 @@ find_rank (location_t loc, tree orig_expr, tree expr, 
 bool ignore_builtin_fn,
   current_rank++;
   ii_tree = ARRAY_NOTATION_ARRAY (ii_tree);
 }
 - else if (TREE_CODE (ii_tree) == ARRAY_REF)
 + else if (TREE_CODE (ii_tree) == ARRAY_REF
 +  || TREE_CODE (ii_tree) == INDIRECT_REF
 +  || TREE_CODE (ii_tree) == COMPONENT_REF)

Maybe you want handled_component_p (ii_tree)?  The above misses
REALPART_EXPR, IMAGPART_EXRP, VIEW_CONVERT_EXPR
and BIT_FIELD_REF.

And I'm missing a

   else
  gcc_unreachable ();

Richard.

 ii_tree = TREE_OPERAND (ii_tree, 0);
   else if (TREE_CODE (ii_tree) == PARM_DECL
|| TREE_CODE (ii_tree) == VAR_DECL)
 diff --git a/gcc/testsuite/c-c++-common/cilk-plus/AN/pr61962.c 
 b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr61962.
 new file mode 100644
 index 000..08d4fe2
 --- /dev/null
 +++ b/gcc/testsuite/c-c++-common/cilk-plus/AN/pr61962.c
 @@ -0,0 +1,14 @@
 +/* PR other/61962 */
 +/* { dg-do compile } */
 +/* { dg-options -fcilkplus } */
 +
 +struct FloatStruct
 +{
 +float *f;
 +};
 +
 +/* Either SRC or DST must be a struct, otherwise the bug does not occur.  */
 +void f (struct FloatStruct* dst, float *src, unsigned int length)
 +{
 +dst-f[0:length] = src[0:length];
 +}


RE: [PATCH, Cilk+] Fix for PR61962

2014-08-01 Thread Zamyatin, Igor
  diff --git a/gcc/c-family/array-notation-common.c
  b/gcc/c-family/array-notation-common.c
  index c010039..5db14c6 100644
  --- a/gcc/c-family/array-notation-common.c
  +++ b/gcc/c-family/array-notation-common.c
  @@ -221,7 +221,9 @@ find_rank (location_t loc, tree orig_expr, tree expr,
 bool ignore_builtin_fn,
current_rank++;
ii_tree = ARRAY_NOTATION_ARRAY (ii_tree);
  }
  - else if (TREE_CODE (ii_tree) == ARRAY_REF)
  + else if (TREE_CODE (ii_tree) == ARRAY_REF
  +  || TREE_CODE (ii_tree) == INDIRECT_REF
  +  || TREE_CODE (ii_tree) == COMPONENT_REF)
 
 Maybe you want handled_component_p (ii_tree)?  The above misses
 REALPART_EXPR, IMAGPART_EXRP, VIEW_CONVERT_EXPR and
 BIT_FIELD_REF.
 
 And I'm missing a
 
else
   gcc_unreachable ();

Thanks, will look at it.

Igor

 
 Richard.
 
  ii_tree = TREE_OPERAND (ii_tree, 0);
else if (TREE_CODE (ii_tree) == PARM_DECL
 || TREE_CODE (ii_tree) == VAR_DECL) diff --git


Re: [AArch64] Implement movmem for the benefit of inline memcpy

2014-08-01 Thread Richard Biener
On Fri, Aug 1, 2014 at 8:38 AM, Andrew Pinski pins...@gmail.com wrote:
 On Fri, Jun 6, 2014 at 1:50 AM, James Greenhalgh
 james.greenha...@arm.com wrote:

 Hi,

 The move_by_pieces infrastructure performs a copy by repeatedly trying
 the largest safe copy it can make. So for a 15-byte copy we might see:

 offset   amount  bytes copied
 08   0-7
 84   8-11
 12   2   12-13
 14   1   14

 However, we can implement a 15-byte copy as so:

 offset   amount  bytes copied
 08   0-7
 78   7-14

 Which can prove more efficient for both space and speed.

 In this patch we set MOVE_RATIO low to avoid using move_by_pieces, and
 implement the movmem pattern name to expand small block copy cases. Note, 
 this
 optimization does not apply for -mstrict-align targets, which must continue
 copying byte-by-byte.

 Setting MOVE_RATIO low in this way causes a few tests to begin failing,
 both of these are documented in the test-case as expected to fail for
 low MOVE_RATIO targets, which do not allow certain Tree-Level optimizations.


 I think you should reevaluate setting MOVE_RATIO this low.  It is used
 for SRA and IPA-SRA which both are very useful; more useful than
 memmove optimizations can do.

Maybe we should finally decouple SRA and IPA-SRA from MOVE_RATIO
and have a --param to control the heuristic a target can adjust separately.
(we can still default to MOVE_RATIO here).  Ok, maybe we need
two params, one for size and one for speed optimization (though
the size effects are hard to estimate).

Richard.

 In fact this optimization is not even valid for volatile variables.
 Here is a testcase for the volatile issue:
 struct __attribute__((packed)) t15{
   long long t8;
   int t4;
   short t2;
   unsigned char t1;
 };
 volatile struct t15 t15;
 int f(struct t15 *a)
 {
   t15 = *a;
 }

 Notice how we are writing to byte 7 twice to t15 in the outputted code.

 Thanks,
 Andrew Pinski


 Bootstrapped on aarch64-unknown-linux-gnu with no issues.

 OK for trunk?

 Thanks,
 James

 ---
 gcc/

 2014-06-06  James Greenhalgh  james.greenha...@arm.com

 * config/aarch64/aarch64-protos.h (aarch64_expand_movmem): New.
 * config/aarch64/aarch64.c (aarch64_move_pointer): New.
 (aarch64_progress_pointer): Likewise.
 (aarch64_copy_one_part_and_move_pointers): Likewise.
 (aarch64_expand_movmen): Likewise.
 * config/aarch64/aarch64.h (MOVE_RATIO): Set low.
 * config/aarch64/aarch64.md (movmemmode): New.

 gcc/testsuite/

 2014-06-06  James Greenhalgh  james.greenha...@arm.com

 * gcc.dg/tree-ssa/pr42585.c: Skip for AArch64.
 * gcc.dg/tree-ssa/sra-12.c: Likewise.


Re: [PATCH] Move Asan instrumentation to sanopt pass

2014-08-01 Thread Richard Biener
On Fri, Aug 1, 2014 at 9:17 AM, Jakub Jelinek ja...@redhat.com wrote:
 On Mon, Jul 28, 2014 at 06:14:08PM +0400, Yury Gribov wrote:
 On 07/24/2014 11:48 AM, Jakub Jelinek wrote:
  So, either support for just EAF*, or perhaps support for DECL_ATTRIBUTES
  for internal-fns, say by having some tree array where you'd store what you
  stick into DECL_ATTRIBUTES normally.

 I'd prefer to avoid attributes. Would something like this be enough?
 (not yet fully tested, just ran asan.exp tests).

 I think I'd prefer if you'd specify the fnspec as either NULL (most internal
 functions) or normal string and reuse the string parsing in
 gimple_call_arg_flags.

Yeah, me too.

Richard.

 So, you'd just replace the:
   tree attr = gimple_call_fnspec (stmt);

   if (!attr || 1 + arg = (unsigned) TREE_STRING_LENGTH (attr))
 return 0;

   switch (TREE_STRING_POINTER (attr)[1 + arg])
 with:
   const char *fnspec;
   if (gimple_call_arg_flags (stmt))
 {
   fnspec = ...;
   if (!fnspec || 1 + arg = strlen (fnspec))
 return 0;
 }
   else
 {
   tree attr = gimple_call_fnspec (stmt);

   if (!attr || 1 + arg = (unsigned) TREE_STRING_LENGTH (attr))
 return 0;

   fnspec = TREE_STRING_POINTER (attr);
 }
   switch (fnspec[1 + arg])

 Jakub


Re: [AArch64] Implement movmem for the benefit of inline memcpy

2014-08-01 Thread pinskia


 On Jun 6, 2014, at 1:50 AM, James Greenhalgh james.greenha...@arm.com wrote:
 
 
 Hi,
 
 The move_by_pieces infrastructure performs a copy by repeatedly trying
 the largest safe copy it can make. So for a 15-byte copy we might see:
 
 offset   amount  bytes copied
 08   0-7
 84   8-11
 12   2   12-13
 14   1   14
 
 However, we can implement a 15-byte copy as so:
 
 offset   amount  bytes copied
 08   0-7
 78   7-14
 
 Which can prove more efficient for both space and speed.
 
 In this patch we set MOVE_RATIO low to avoid using move_by_pieces, and
 implement the movmem pattern name to expand small block copy cases. Note, this
 optimization does not apply for -mstrict-align targets, which must continue
 copying byte-by-byte.

Why not change move_by_pieces instead of having a target specific code? This 
seems like a better option. You can check is unaligned slow target macro to see 
if you want to do this optimization too.   As I mentioned in the other email 
make sure you check the volatile ness of the from and to before doing this 
optimization. 

Thanks,
Andrew


 
 Setting MOVE_RATIO low in this way causes a few tests to begin failing,
 both of these are documented in the test-case as expected to fail for
 low MOVE_RATIO targets, which do not allow certain Tree-Level optimizations.
 
 Bootstrapped on aarch64-unknown-linux-gnu with no issues.
 
 OK for trunk?
 
 Thanks,
 James
 
 ---
 gcc/
 
 2014-06-06  James Greenhalgh  james.greenha...@arm.com
 
* config/aarch64/aarch64-protos.h (aarch64_expand_movmem): New.
* config/aarch64/aarch64.c (aarch64_move_pointer): New.
(aarch64_progress_pointer): Likewise.
(aarch64_copy_one_part_and_move_pointers): Likewise.
(aarch64_expand_movmen): Likewise.
* config/aarch64/aarch64.h (MOVE_RATIO): Set low.
* config/aarch64/aarch64.md (movmemmode): New.
 
 gcc/testsuite/
 
 2014-06-06  James Greenhalgh  james.greenha...@arm.com
 
* gcc.dg/tree-ssa/pr42585.c: Skip for AArch64.
* gcc.dg/tree-ssa/sra-12.c: Likewise.
 0001-AArch64-Implement-movmem-for-the-benefit-of-inline-m.patch


[Ada] Remove xgnatugn in doc generation

2014-08-01 Thread Arnaud Charlet
[
Note: the previous related change was rejected due to a too large
patch file attached. The mail was:

This is another step in removing VMS code, and also a step in converting the
documentation to the rest/sphinx format.

The xgnatugn preprocessing step will also soon be removed.

2014-08-01  Ben Brosgol  bros...@adacore.com

* gnat_ugn.texi, projects.texi, xgnatugn.adb: Removed all VMS
conditionalization from gnat_ugn.texi and projects.texi, and updated
(considerably simplified) xgnatugn.adb, to be removed soon.
]

Following up from previous doc clean ups (see above), this change removes the
preprocessing step needed to generate gnat_ugn.info.

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

2014-08-01  Arnaud Charlet  char...@adacore.com

* ug_words, xgnatugn.adb, gcc-interface/Make-lang.in: Remove
xgnatugn.adb and ug_words.

Index: ug_words
===
--- ug_words(revision 213263)
+++ ug_words(working copy)
@@ -1,271 +0,0 @@
-b_  ^ B_
-b~  ^ B__
-cc1 ^ CC1
-Cc1 ^ CC1
-emacs   ^ EMACS
-Emacs   ^ EMACS
-gdb ^ GDB
-Gdb ^ GDB
-gnat1   ^ GNAT1
-Gnat1   ^ GNAT1
-gnatbind^ GNAT BIND
-Gnatbind^ GNAT BIND
-gnatcheck   ^ GNAT CHECK
-Gnatcheck   ^ GNAT CHECK
-gnatchop^ GNAT CHOP
-Gnatchop^ GNAT CHOP
-gnatclean   ^ GNAT CLEAN
-Gnatclean   ^ GNAT CLEAN
-gnatelim^ GNAT ELIM
-Gnatelim^ GNAT ELIM
-gnatf   ^ GNAT XREF
-Gnatf   ^ GNAT XREF
-gnatfind^ GNAT FIND
-Gnatfind^ GNAT FIND
-gnatkr  ^ GNAT KRUNCH
-Gnatkr  ^ GNAT KRUNCH
-gnatlink^ GNAT LINK
-Gnatlink^ GNAT LINK
-gnatls  ^ GNAT LIST
-Gnatls  ^ GNAT LIST
-gnatmake^ GNAT MAKE
-Gnatmake^ GNAT MAKE
-gnatmetric  ^ GNAT METRIC
-Gnatmetric  ^ GNAT METRIC
-gnatname^ GNAT NAME
-Gnatname^ GNAT NAME
-gnatpp  ^ GNAT PRETTY
-Gnatpp  ^ GNAT PRETTY
-gnatprep^ GNAT PREPROCESS
-Gnatprep^ GNAT PREPROCESS
-gnatstub^ GNAT STUB
-Gnatstub^ GNAT STUB
-gnatxref^ GNAT XREF
-Gnatxref^ GNAT XREF
-gcc ^ GNAT COMPILE
-gcc -c  ^ GNAT COMPILE
--fno-inline ^ /INLINE=SUPPRESS
--fstack-check   ^ /CHECKS=STACK
--fno-strict-aliasing ^ /OPTIMIZE=NO_STRICT_ALIASING
--gnata  ^ /CHECKS=ASSERTIONS
--gnatA  ^ /NO_GNAT_ADC
--gnatb  ^ /REPORT_ERRORS=BRIEF
--gnatB  ^ /ASSUME_VALID
--gnatc  ^ /NOLOAD
--gnatct ^ /NOLOAD /TREE_OUTPUT
--gnatdc ^ /TRACE_UNITS
--gnatdO ^ /REPORT_ERRORS=IMMEDIATE
--gnatC  ^ /COMPRESS_NAMES
--gnatDG ^ /XDEBUG /EXPAND_SOURCEA
--gnatD  ^ /XDEBUG
--gnateA ^ /ALIASING_CHECK
--gnatec ^ /CONFIGURATION_PRAGMAS_FILE
--gnated ^ /DISABLE_ATOMIC_SYNCHRONIZATION
--gnateD ^ /SYMBOL_PREPROCESSING
--gnateE ^ /EXTRA_EXCEPTION_INFORMATION
--gnatef ^ /FULL_PATH_IN_BRIEF_MESSAGES
--gnateF ^ /FLOAT_OVERFLOW_CHECK
--gnateG ^ /GENERATE_PROCESSED_SOURCE
--gnatei ^ /MAX_INSTANTIATIONS=
--gnateI ^ /MULTI_UNIT_INDEX=
--gnatel ^ /ELABORATION_INFO_MESSAGES
--gnateL ^ /NOELABORATION_INFO_MESSAGES
--gnatem ^ /MAPPING_FILE
--gnatep ^ /DATA_PREPROCESSING
--gnateP ^ /CATEGORIZATION_WARNINGS
--gnateS ^ /SCO_OUTPUT
--gnatet ^ /WRITE_TARGET_DEPENDENT_INFO
--gnateT ^ /READ_TARGET_DEPENDENT_INFO
--gnateu ^ /IGNORE_UNRECOGNIZED
--gnateV ^ /PARAMETER_VALIDITY_CHECK
--gnateY ^ /IGNORE_STYLE_CHECKS_PRAGMAS
--gnatE  ^ /CHECKS=ELABORATION
--gnatf  ^ /REPORT_ERRORS=FULL
--gnatF  ^ /UPPERCASE_EXTERNALS
--gnatg  ^ /STYLE_CHECKS=GNAT
--gnatG  ^ /EXPAND_SOURCE
--gnatk  ^ /FILE_NAME_MAX_LENGTH
--gnatl  ^ /LIST
--gnatL  ^ /LONGJMP_SETJMP
--gnatj  ^ /JUSTIFY_MESSAGES
--gnatj0 ^ /NO_JUSTIFY_MESSAGES
--gnatjnn^ /JUSTIFY_MESSAGES=nn
--gnatL  ^ /INTERSPERSE_SOURCE
--gnatm  ^ /ERROR_LIMIT
--gnatm2 ^ /ERROR_LIMIT=2
--gnatn  ^ /INLINE=PRAGMA
--gnatn1 ^ /INLINE=PRAGMA_LEVEL_1
--gnatn2 ^ /INLINE=PRAGMA_LEVEL_2
--gnatN  ^ /INLINE=FULL
--gnato  ^ /CHECKS=OVERFLOW
--gnato? ^ /OVERFLOW_CHECKS=?
--gnato??^ /OVERFLOW_CHECKS=??
--gnatp  ^ /CHECKS=SUPPRESS_ALL
--gnat-p ^ /CHECKS=UNSUPPRESS_ALL
--gnatP  ^ /POLLING
--gnatR  ^ /REPRESENTATION_INFO
--gnatR0 ^ /REPRESENTATION_INFO=NONE
--gnatR1 ^ /REPRESENTATION_INFO=ARRAYS
--gnatR2 ^ /REPRESENTATION_INFO=OBJECTS
--gnatR3 ^ /REPRESENTATION_INFO=SYMBOLIC
--gnatq  ^ /TRY_SEMANTICS
--gnatQ  ^ /FORCE_ALI
--gnatr  ^ 

[Ada] Generate Machine, Model and Rounding FP attributes in line

2014-08-01 Thread Arnaud Charlet
This change makes it so that the Machine, Model and Rounding FP attributes
are generated in line by the compiler (in conjunction with a conversion to
an integer type for the third) and optimized on architectures that do not
make use of internal extended precision in the FPU.

The following function must be optimized into a return on PowerPC and SPARC:

function Machine (F: Float) return Float is
begin
  return Float'Machine (F);
end;

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

2014-08-01  Eric Botcazou  ebotca...@adacore.com

* exp_attr.adb (Expand_N_Attribute_Reference): Check whether
expansion can be avoid for Machine, Model and Rounding.
(Is_Inline_Floating_Point_Attribute): Return true for Machine
 Model, as well as Rounding if wrapped in a conversion to an
integer type.
* sem_res.adb (Simplify_Type_Conversion): Deal with Rounding as well.
* gcc-interface/gigi.h (fp_arith_may_widen): Declare.
* gcc-interface/utils.c (fp_arith_may_widen): New global variable.
* gcc-interface/misc.c (enumerate_modes): Compute it.
* gcc-interface/trans.c (FP_ARITH_MAY_WIDEN): Delete.
(lvalue_required_for_attribute_p): Deal with Descriptor_Size,
Machine and Model.
(Attribute_to_gnu) Attr_Model: New case.
Attr_Machine): Likewise.
(convert_with_check): Test
fp_arith_may_widen variable.

Index: exp_attr.adb
===
--- exp_attr.adb(revision 213371)
+++ exp_attr.adb(working copy)
@@ -4068,10 +4068,13 @@
   -
 
   --  Transforms 'Machine into a call to the floating-point attribute
-  --  function Machine in Fat_xxx (where xxx is the root type)
+  --  function Machine in Fat_xxx (where xxx is the root type).
+  --  Expansion is avoided for cases the back end can handle directly.
 
   when Attribute_Machine =
- Expand_Fpt_Attribute_R (N);
+ if not Is_Inline_Floating_Point_Attribute (N) then
+Expand_Fpt_Attribute_R (N);
+ end if;
 
   --
   -- Machine_Rounding --
@@ -4335,10 +4338,13 @@
   ---
 
   --  Transforms 'Model into a call to the floating-point attribute
-  --  function Model in Fat_xxx (where xxx is the root type)
+  --  function Model in Fat_xxx (where xxx is the root type).
+  --  Expansion is avoided for cases the back end can handle directly.
 
   when Attribute_Model =
- Expand_Fpt_Attribute_R (N);
+ if not Is_Inline_Floating_Point_Attribute (N) then
+Expand_Fpt_Attribute_R (N);
+ end if;
 
   -
   -- Object_Size --
@@ -5411,9 +5417,12 @@
 
   --  Transforms 'Rounding into a call to the floating-point attribute
   --  function Rounding in Fat_xxx (where xxx is the root type)
+  --  Expansion is avoided for cases the back end can handle directly.
 
   when Attribute_Rounding =
- Expand_Fpt_Attribute_R (N);
+ if not Is_Inline_Floating_Point_Attribute (N) then
+Expand_Fpt_Attribute_R (N);
+ end if;
 
   -
   -- Scaling --
@@ -7946,7 +7955,10 @@
   Id : constant Attribute_Id := Get_Attribute_Id (Attribute_Name (N));
 
begin
-  if Nkind (Parent (N)) /= N_Type_Conversion
+  if Id = Attribute_Machine or else Id = Attribute_Model then
+ return True;
+
+  elsif Nkind (Parent (N)) /= N_Type_Conversion
 or else not Is_Integer_Type (Etype (Parent (N)))
   then
  return False;
@@ -7955,7 +7967,7 @@
   --  Should also support 'Machine_Rounding and 'Unbiased_Rounding, but
   --  required back end support has not been implemented yet ???
 
-  return Id = Attribute_Truncation;
+  return Id = Attribute_Rounding or else Id = Attribute_Truncation;
end Is_Inline_Floating_Point_Attribute;
 
 end Exp_Attr;
Index: sem_res.adb
===
--- sem_res.adb (revision 213373)
+++ sem_res.adb (working copy)
@@ -259,7 +259,7 @@
procedure Simplify_Type_Conversion (N : Node_Id);
--  Called after N has been resolved and evaluated, but before range checks
--  have been applied. Currently simplifies a combination of floating-point
-   --  to integer conversion and Truncation attribute.
+   --  to integer conversion and Rounding or Truncation attribute.
 
function Unique_Fixed_Point_Type (N : Node_Id) return Entity_Id;
--  A universal_fixed expression in an universal context is unambiguous if
@@ -11082,29 +11082,36 @@
 Opnd_Typ   : constant Entity_Id := Etype (Operand);
 
  begin
-if Is_Floating_Point_Type (Opnd_Typ)
-  and then
-(Is_Integer_Type (Target_Typ)
-   or else (Is_Fixed_Point_Type (Target_Typ)
-  and then Conversion_OK (N)))
- 

Re: [PATCH] Extended if-conversion for loops marked with pragma omp simd.

2014-08-01 Thread Richard Biener
On Wed, Jun 25, 2014 at 4:06 PM, Yuri Rumyantsev ysrum...@gmail.com wrote:
 Hi All,

 We implemented additional support for pragma omp simd in part of
 extended if-conversion loops with such pragma. These extensions
 include:

 1. All extensions are performed only if considered loop or its outer
loop was marked with pragma omp simd (force_vectorize); For ordinary
loops behavior was not changed.
 2. Took off cfg restriction on basic block which can have more than 2
predecessors.
 3. Put additional restriction on phi nodes which was missed in current design:
all phi nodes must be in non-predicated basic block to conform
semantic of COND_EXPR which is used for transformation.

How is that so?  If the PHI is predicated then its result will be used
in a PHI node again and thus we'd create a sequence of COND_EXPRs.

No?

 4. Extend predication of phi nodes: phi may have more than 2 arguments
 with some limitations:
- for phi nodes which have more than 2 arguments, but only two
arguments are different and one of them has the only occurence,
 transformation to  single COND_EXPR can be done.
- if phi node has more different arguments and all edge predicates
correspondent to phi-arguments are disjoint, a chain of COND_EXPR
will be generated for it. In current design very simple check is used:
check starting from end that two edges correspondent to neighbor
 arguments have common predecessor which is used for further check
 with next edge.
  These guarantee that phi predication will produce the correct result.

Btw, you can think of these extensions as unfactoring a PHI node by
inserting forwarder blocks.  Thus

   x = PHI 1(2), 1(3), 2(4)

becomes

  bb 5: forwarder-from(2)-and(3)

  x = PHI 1(5), 2(4)

and

  x = PHI 1(2), 2(3), 3(4)

becomes

  bb 5:
  x' = PHI 1(2), 2(3)

  b = PHIx'(5), 3(4)

which means that 3) has to work.  Note that we want this kind of
PHI transforms for out-of-SSA as well to reduce the number of
copies we need to insert on edges.

Thus it would be nice if you implemented 4) in terms of a pre-pass
over the force_vect loops PHI nodes, applying that CFG transform.
And make 3) work properly if it doesn't already.

It looks like you introduce a negate predicate to work around the
critical edge limitation?  Please instead change if-conversion to
work with edge predicates (as opposed to BB predicates).

Thanks,
Richard.


 Here is example of such extended predication (compile with -march=core-avx2):
 #pragma omp simd safelen(8)
   for (i=0; i512; i++)
   {
 float t = a[i];
 if (t  0  t  1.0e+17f)
   if (c[i] != 0)
 res += 1;
   }
   bb 4:
   # res_15 = PHI res_1(5), 0(3)
   # i_16 = PHI i_11(5), 0(3)
   # ivtmp_17 = PHI ivtmp_14(5), 512(3)
   t_5 = a[i_16];
   _6 = t_5  0.0;
   _7 = t_5  9.998430674944e+16;
   _8 = _7  _6;
   _ifc__28 = (unsigned int) _8;
   _10 = c[i_16];
   _ifc__36 = _ifc__28 != 0 ? 4294967295 : 0;
   _9 = MASK_LOAD (_10, 0B, _ifc__36);
   _ifc__29 = _ifc__28 != 0 ? 1 : 0;
   _ifc__30 = (int) _ifc__29;
   _ifc__31 = _9 != 0 ? _ifc__30 : 0;
   _ifc__32 = _ifc__28 != 0 ? 1 : 0;
   _ifc__33 = (int) _ifc__32;
   _ifc__34 = _9 == 0 ? _ifc__33 : 0;
   _ifc__35 = _ifc__31 != 0 ? 1 : 0;
   res_1 = res_15 + _ifc__35;
   i_11 = i_16 + 1;
   ivtmp_14 = ivtmp_17 - 1;
   if (ivtmp_14 != 0)
 goto bb 4;

 Bootstrap and regression testing did not show any new failures.

 gcc/ChageLog

 2014-06-25  Yuri Rumyantsev  ysrum...@gmail.com

 * tree-if-conv.c (flag_force_vectorize): New variable.
 (struct bb_predicate_s): Add negate_predicate field.
 (bb_negate_predicate): New function.
 (set_bb_negate_predicate): New function.
 (bb_copy_predicate): New function.
 (add_stmt_to_bb_predicate_gimplified_stmts): New function.
 (init_bb_predicate): Add initialization of negate_predicate field.
 (reset_bb_predicate): Reset negate_predicate to NULL_TREE.
 (convert_name_to_cmp): New function.
 (get_type_for_cond): New function.
 (convert_bool_predicate): New function.
 (predicate_disjunction): New function.
 (predicate_conjunction): New function.
 (add_to_predicate_list): Add convert_bool argument.
 Add call of predicate_disjunction if convert_bool argument is true.
 (add_to_dst_predicate_list): Add convert_bool argument.
 Add early function exit if edge target block is always executed.
 Add call of predicate_conjunction if convert_bool argument is true.
 Pass convert_bool argument for add_to_predicate_list.
 (equal_phi_args): New function.
 (phi_has_two_different_args): New function.
 (phi_args_disjoint): New function.
 (if_convertible_phi_p): Accept phi nodes with more than two args
 for loops marked with pragma omp simd. Add check that phi nodes are
 in non-predicated basic blocks.
 (ifcvt_can_use_mask_load_store): Use flag_force_vectorize.
 (all_edges_are_critical): New function.
 (if_convertible_bb_p): Allow bb has more than two predecessors if
 flag_force_vectorize was setup. Use call of all_edges_are_critical
 to reject block 

[C++ Patch, committed] Use DECL_TYPE_TEMPLATE_P

2014-08-01 Thread Paolo Carlini

Hi,

committed as obvious the below.

Thanks,
Paolo.

///
2014-08-01  Paolo Carlini  paolo.carl...@oracle.com

* pt.c (lookup_template_class_1): Use DECL_TYPE_TEMPLATE_P.
Index: pt.c
===
--- pt.c(revision 213428)
+++ pt.c(working copy)
@@ -7414,9 +7414,7 @@ lookup_template_class_1 (tree d1, tree arglist, tr
   templ = TYPE_TI_TEMPLATE (d1);
   d1 = DECL_NAME (templ);
 }
-  else if (TREE_CODE (d1) == TEMPLATE_DECL
-DECL_TEMPLATE_RESULT (d1)
-   TREE_CODE (DECL_TEMPLATE_RESULT (d1)) == TYPE_DECL)
+  else if (DECL_TYPE_TEMPLATE_P (d1))
 {
   templ = d1;
   d1 = DECL_NAME (templ);


[Ada] Improve messages for lack of inlining in GNATprove mode

2014-08-01 Thread Arnaud Charlet
Expression functions with a separate declarations should never be inlined
in GNATprove mode, hence no message should be issued for these. Correct a
problem in call resolution which lead to such a message. Also change the
message for lack of inlining in GNATprove mode, so that an info message is
issued instead of a warning.

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

2014-08-01  Yannick Moy  m...@adacore.com

* inline.adb (Cannot_Inline): Issue info message instead of
warning for subprograms not inlined in GNATprove mode.
* sem_res.adb (Resolve_Call): Take body into account for deciding
whether subprogram can be inlined in GNATprove mode or not.

Index: inline.adb
===
--- inline.adb  (revision 213437)
+++ inline.adb  (working copy)
@@ -1239,11 +1239,12 @@
 and then Msg (Msg'First .. Msg'First + 12) = cannot inline
   then
  declare
-Len1 : constant Positive := 13;  --  cannot inline
-Len2 : constant Positive := 25;  --  no contextual analysis of
+Len1 : constant Positive := 13;  --  length of cannot inline
+Len2 : constant Positive := 31;
+--  lenth of info: no contextual analysis of
 New_Msg : String (1 .. Msg'Length + Len2 - Len1);
  begin
-New_Msg (1 .. Len2) := no contextual analysis of;
+New_Msg (1 .. Len2) := info: no contextual analysis of;
 New_Msg (Len2 + 1 .. Msg'Length + Len2 - Len1) :=
   Msg (Msg'First + Len1 .. Msg'Last);
 Cannot_Inline (New_Msg, N, Subp, Is_Serious);
Index: sem_res.adb
===
--- sem_res.adb (revision 213441)
+++ sem_res.adb (working copy)
@@ -6217,8 +6217,9 @@
  --  being inlined.
 
  declare
-Nam_UA : constant Entity_Id := Ultimate_Alias (Nam);
-Decl   : constant Node_Id   := Unit_Declaration_Node (Nam_UA);
+Nam_UA  : constant Entity_Id := Ultimate_Alias (Nam);
+Decl: constant Node_Id   := Unit_Declaration_Node (Nam_UA);
+Body_Id : constant Entity_Id := Corresponding_Body (Decl);
 
  begin
 --  If the subprogram is not eligible for inlining in GNATprove
@@ -6226,7 +6227,7 @@
 
 if Nkind (Decl) /= N_Subprogram_Declaration
   or else not Is_Inlined_Always (Nam_UA)
-  or else not Can_Be_Inlined_In_GNATprove_Mode (Nam_UA, Empty)
+  or else not Can_Be_Inlined_In_GNATprove_Mode (Nam_UA, Body_Id)
 then
null;
 
@@ -6245,7 +6246,7 @@
--  With the one-pass inlining technique, a call cannot be
--  inlined if the corresponding body has not been seen yet.
 
-   if No (Corresponding_Body (Decl)) then
+   if No (Body_Id) then
   Error_Msg_NE
 (?no contextual analysis of  (body not seen yet),
  N, Nam);


gcov tidy up

2014-08-01 Thread Nathan Sidwell

In developing the next patch I found some places to tidy up first.  Committed.

nathan
2014-08-01  Nathan Sidwell  nat...@acm.org

* Makefile.in (LIBGCOV_MERGE, LIBGCOV_PROFILER,
LIBGCOV_INTERFACE): Reformat.
* libgcov-driver.c (gcov_exit, __gcov_init): Disable when
IN_GCOV_TOOL.
* libgcov-interface.c: Reformat some comments.
(__gcov_flush_mx): Add declaration.  Tidy up definition.

Index: libgcc/Makefile.in
===
--- libgcc/Makefile.in  (revision 213384)
+++ libgcc/Makefile.in  (working copy)
@@ -852,13 +852,15 @@ include $(iterator)
 
 # Build libgcov components.
 
-LIBGCOV_MERGE = _gcov_merge_add _gcov_merge_single _gcov_merge_delta 
_gcov_merge_ior \
- _gcov_merge_time_profile
-LIBGCOV_PROFILER = _gcov_interval_profiler _gcov_pow2_profiler 
_gcov_one_value_profiler \
-_gcov_indirect_call_profiler _gcov_average_profiler _gcov_ior_profiler \
-_gcov_indirect_call_profiler_v2 _gcov_time_profiler
-LIBGCOV_INTERFACE = _gcov_flush _gcov_fork _gcov_execl _gcov_execlp 
_gcov_execle \
-_gcov_execv _gcov_execvp _gcov_execve _gcov_reset _gcov_dump
+LIBGCOV_MERGE = _gcov_merge_add _gcov_merge_single _gcov_merge_delta   \
+   _gcov_merge_ior _gcov_merge_time_profile
+LIBGCOV_PROFILER = _gcov_interval_profiler _gcov_pow2_profiler \
+   _gcov_one_value_profiler _gcov_indirect_call_profiler   \
+   _gcov_average_profiler _gcov_ior_profiler   \
+   _gcov_indirect_call_profiler_v2 _gcov_time_profiler
+LIBGCOV_INTERFACE = _gcov_flush _gcov_fork _gcov_execl _gcov_execlp\
+   _gcov_execle _gcov_execv _gcov_execvp _gcov_execve _gcov_reset \
+   _gcov_dump
 LIBGCOV_DRIVER = _gcov 
 
 libgcov-merge-objects = $(patsubst %,%$(objext),$(LIBGCOV_MERGE))
Index: libgcc/libgcov-driver.c
===
--- libgcc/libgcov-driver.c (revision 213384)
+++ libgcc/libgcov-driver.c (working copy)
@@ -775,6 +775,7 @@ gcov_do_dump (struct gcov_info *list, in
   free (gf.filename);
 }
 
+#if !IN_GCOV_TOOL
 void
 gcov_exit (void)
 {
@@ -840,6 +841,6 @@ __gcov_init (struct gcov_info *info)
 }
   info-version = 0;
 }
-
+#endif /* !IN_GCOV_TOOL */
 #endif /* L_gcov */
 #endif /* inhibit_libc */
Index: libgcc/libgcov-interface.c
===
--- libgcc/libgcov-interface.c  (revision 213384)
+++ libgcc/libgcov-interface.c  (working copy)
@@ -44,20 +44,21 @@ void __gcov_dump (void) {}
 
 extern void gcov_clear (void) ATTRIBUTE_HIDDEN;
 extern void gcov_exit (void) ATTRIBUTE_HIDDEN;
+extern __gthread_mutex_t __gcov_flush_mx ATTRIBUTE_HIDDEN;
 
 #ifdef L_gcov_flush
-
 #ifdef __GTHREAD_MUTEX_INIT
-ATTRIBUTE_HIDDEN __gthread_mutex_t __gcov_flush_mx = __GTHREAD_MUTEX_INIT;
+__gthread_mutex_t __gcov_flush_mx = __GTHREAD_MUTEX_INIT;
 #define init_mx_once()
 #else
-__gthread_mutex_t __gcov_flush_mx ATTRIBUTE_HIDDEN;
+__gthread_mutex_t __gcov_flush_mx;
 
 static void
 init_mx (void)
 {
   __GTHREAD_MUTEX_INIT_FUNCTION (__gcov_flush_mx);
 }
+
 static void
 init_mx_once (void)
 {
@@ -160,8 +161,8 @@ __gcov_execl (const char *path, char *ar
 #endif
 
 #ifdef L_gcov_execlp
-/* A wrapper for the execlp function.  Flushes the accumulated profiling data, 
so
-   that they are not lost.  */
+/* A wrapper for the execlp function.  Flushes the accumulated
+   profiling data, so that they are not lost.  */
 
 int
 __gcov_execlp (const char *path, char *arg, ...)
@@ -191,8 +192,8 @@ __gcov_execlp (const char *path, char *a
 #endif
 
 #ifdef L_gcov_execle
-/* A wrapper for the execle function.  Flushes the accumulated profiling data, 
so
-   that they are not lost.  */
+/* A wrapper for the execle function.  Flushes the accumulated
+   profiling data, so that they are not lost.  */
 
 int
 __gcov_execle (const char *path, char *arg, ...)
@@ -224,8 +225,8 @@ __gcov_execle (const char *path, char *a
 #endif
 
 #ifdef L_gcov_execv
-/* A wrapper for the execv function.  Flushes the accumulated profiling data, 
so
-   that they are not lost.  */
+/* A wrapper for the execv function.  Flushes the accumulated
+   profiling data, so that they are not lost.  */
 
 int
 __gcov_execv (const char *path, char *const argv[])
@@ -236,8 +237,8 @@ __gcov_execv (const char *path, char *co
 #endif
 
 #ifdef L_gcov_execvp
-/* A wrapper for the execvp function.  Flushes the accumulated profiling data, 
so
-   that they are not lost.  */
+/* A wrapper for the execvp function.  Flushes the accumulated
+   profiling data, so that they are not lost.  */
 
 int
 __gcov_execvp (const char *path, char *const argv[])
@@ -248,8 +249,8 @@ __gcov_execvp (const char *path, char *c
 #endif
 
 #ifdef L_gcov_execve
-/* A wrapper for the execve function.  Flushes the accumulated profiling data, 
so
-   that they are not lost.  */
+/* A wrapper for the execve function.  Flushes the accumulated
+   

[Ada] Legality checks involving aspect Import

2014-08-01 Thread Arnaud Charlet
This patch adds some missing legality checks on uses of aspect Import. These
checks were performed properly in the presence of pragmas, but were incomplete
when using aspects.

Compiling q.ads must yield:

q.ads:2:28: imported entities cannot have explicit initialization (RM 8.1 (24))
q.ads:6:24: no initialization allowed for declaration of J at line 5
q.ads:6:24: imported entities cannot be initialized (RM B.1(24))
q.ads:9:24: no initialization allowed for declaration of K at line 8
q.ads:9:24: imported entities cannot be initialized (RM B.1(24))

---
package Q is
   R : constant Integer := 42 with Import, Volatile;
   Q1 : constant := R*R + R*R;

   J : constant Integer := -999 with Volatile;
   pragma Import (Ada, J);

   K : Integer := 1123;
   pragma Import (Ada, K);
end;

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

2014-08-01  Ed Schonberg  schonb...@adacore.com

* sem_ch13.adb (Analyze_Aspect_Specifications, case Aspect_Import):
Set Is_Imported flag at once, to simplify subsequent legality
checks. Reject the aspect on an object whose declaration has an
explicit initial value.
* sem_prag.adb (Process_Import_Or_Interface): Use original node
to check legality of an initial value for an imported entity.
Set Is_Imported flag in case of error to prevent cascaded errors.
Do not set the Is_Imported flag if the pragma comes from an
aspect, because it is already done when analyzing the aspect.

Index: sem_prag.adb
===
--- sem_prag.adb(revision 213440)
+++ sem_prag.adb(working copy)
@@ -7838,8 +7838,14 @@
 --  the code generator making an implicit initialization explicit.
 
 elsif Present (Expression (Parent (Def_Id)))
-  and then Comes_From_Source (Expression (Parent (Def_Id)))
+  and then Comes_From_Source
+ (Original_Node (Expression (Parent (Def_Id
 then
+
+   --  Set imported flag to prevent cascaded errors.
+
+   Set_Is_Imported (Def_Id);
+
Error_Msg_Sloc := Sloc (Def_Id);
Error_Pragma_Arg
  (no initialization allowed for declaration of #,
@@ -7847,7 +7853,13 @@
   Arg2);
 
 else
-   Set_Imported (Def_Id);
+   --  If the pragma comes from an aspect specification the
+   --  Is_Imported flag has already been set.
+
+   if not From_Aspect_Specification (N) then
+  Set_Imported (Def_Id);
+   end if;
+
Process_Interface_Name (Def_Id, Arg3, Arg4);
 
--  Note that we do not set Is_Public here. That's because we
@@ -7922,8 +7934,13 @@
   exit;
 
else
-  Set_Imported (Def_Id);
+  --  If the pragma comes from an aspect specification the
+  --  Is_Imported flag has already been set.
 
+  if not From_Aspect_Specification (N) then
+ Set_Imported (Def_Id);
+  end if;
+
   --  Reject an Import applied to an abstract subprogram
 
   if Is_Subprogram (Def_Id)
Index: sem_ch13.adb
===
--- sem_ch13.adb(revision 213446)
+++ sem_ch13.adb(working copy)
@@ -2915,6 +2915,21 @@
  --  that verifed that there was a matching convention
  --  is now obsolete.
 
+ if A_Id = Aspect_Import then
+Set_Is_Imported (E);
+
+--  An imported entity cannot have an explicit
+--  initialization.
+
+if Nkind (N) = N_Object_Declaration
+  and then Present (Expression (N))
+then
+   Error_Msg_N
+ (imported entities cannot be initialized 
+   (RM B.1(24)), Expression (N));
+end if;
+ end if;
+
  goto Continue;
   end if;
 
@@ -2930,7 +2945,7 @@
 and then Nkind (Parent (N)) /= N_Compilation_Unit
   then
  Error_Msg_N
-(incorrect context for library unit aspect, Id);
+   (incorrect context for library unit aspect, Id);
  goto Continue;
   end if;
 


[Ada] Add support for non-capturing parenthesis in GNAT.Regpat

2014-08-01 Thread Arnaud Charlet
It is now possible to use the (?:...) syntax to group elements in
a regular expression without making their matched substring available
in the Match_Array.

The following test must output:
   Matched (0)= 1.. 6
   Matched (1)= 5.. 5
   Matched (2)= 0.. 0

   with GNAT.Regpat;   use GNAT.Regpat;
   with Ada.Text_IO;   use Ada.Text_IO;
   procedure Main is
  P : constant Pattern_Matcher := Compile (ab(?:a*)(a+)b);
  M : Match_Array (0 .. 3);
   begin
  Match (P, abaaab, M);
  if M (0) /= No_Match then
 Put_Line (Matched (0)=  M (0).First'Img  ..  M (0).Last'Img);
 Put_Line (Matched (1)=  M (1).First'Img  ..  M (1).Last'Img);
 Put_Line (Matched (2)=  M (2).First'Img  ..  M (2).Last'Img);
  end if;
   end Main;

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

2014-08-01  Emmanuel Briot  br...@adacore.com

* g-regpat.adb (Parse): Add support for non-capturing parenthesis.


Index: s-regpat.adb
===
--- s-regpat.adb(revision 213263)
+++ s-regpat.adb(working copy)
@@ -7,7 +7,7 @@
 -- B o d y  --
 --  --
 --   Copyright (C) 1986 by University of Toronto.   --
---  Copyright (C) 1999-2013, AdaCore--
+--  Copyright (C) 1999-2014, AdaCore--
 --  --
 -- 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- --
@@ -410,10 +410,13 @@
 
   procedure Parse
 (Parenthesized : Boolean;
+ Capturing : Boolean;
  Flags : out Expression_Flags;
  IP: out Pointer);
   --  Parse regular expression, i.e. main body or parenthesized thing
   --  Caller must absorb opening parenthesis.
+  --  Capturing should be set to True when we have an open parenthesis
+  --  from which we want the user to extra text.
 
   procedure Parse_Branch
 (Flags : out Expression_Flags;
@@ -831,9 +834,10 @@
   --  the branches to what follows makes it hard to avoid.
 
   procedure Parse
- (Parenthesized  : Boolean;
-  Flags  : out Expression_Flags;
-  IP : out Pointer)
+ (Parenthesized : Boolean;
+  Capturing : Boolean;
+  Flags : out Expression_Flags;
+  IP: out Pointer)
   is
  E   : String renames Expression;
  Br, Br2 : Pointer;
@@ -847,7 +851,7 @@
 
  --  Make an OPEN node, if parenthesized
 
- if Parenthesized then
+ if Parenthesized and then Capturing then
 if Matcher.Paren_Count  Max_Paren_Count then
Fail (too many ());
 end if;
@@ -856,7 +860,6 @@
 Matcher.Paren_Count := Matcher.Paren_Count + 1;
 IP := Emit_Node (OPEN);
 Emit (Character'Val (Par_No));
-
  else
 IP := 0;
 Par_No := 0;
@@ -913,14 +916,19 @@
  --  Make a closing node, and hook it on the end
 
  if Parenthesized then
-Ender := Emit_Node (CLOSE);
-Emit (Character'Val (Par_No));
+if Capturing then
+   Ender := Emit_Node (CLOSE);
+   Emit (Character'Val (Par_No));
+   Link_Tail (IP, Ender);
+else
+   --  need to keep looking after the closing parenthesis
+   null;
+end if;
  else
 Ender := Emit_Node (EOP);
+Link_Tail (IP, Ender);
  end if;
 
- Link_Tail (IP, Ender);
-
  if Have_Branch and then Emit_Ptr = PM.Size + 1 then
 
 --  Hook the tails of the branches to the closing node
@@ -945,7 +953,7 @@
 
  elsif Parse_Pos = Parse_End then
 if E (Parse_Pos) = ')'  then
-   Fail (unmatched ());
+   Fail (unmatched ')');
 else
Fail (junk on end); -- Can't happen
 end if;
@@ -1003,16 +1011,24 @@
   New_Flags : Expression_Flags;
 
begin
-  Parse (True, New_Flags, IP);
-
-  if IP = 0 then
- return;
+  if Parse_Pos = Parse_End - 1
+ and then Expression (Parse_Pos) = '?'
+ and then Expression (Parse_Pos + 1) = ':'
+  then
+ Parse_Pos := Parse_Pos + 2;
+ --  non-capturing parenthesis
+ Parse (True, False, New_Flags, IP);
+  else
+ --  capturing parenthesis
+  

[RFC][Vectorizer, AArch64] Fix PR/61114 by redefining REDUC_xxx_EXPR tree codes to return scalars

2014-08-01 Thread Alan Lawrence

This fixes PR/61114 by redefining the REDUC_{MIN,MAX,PLUS}_EXPR tree codes.

These are presently documented as producing a vector with the result in element 
0, and this is inconsistent with their use in tree-vect-loop.c (which on 
bigendian targets pulls the bits out of the other end of the vector result). 
This leads to bugs on bigendian targets - see 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61114 for a small testcase.


I discounted fixing the vectorizer (to always read from element 0) and then 
making the optab reverse the result on bigendian targets (whose architectural 
insn produces the result in lane N-1), as optimization of vectors in RTL seems 
unlikely to remove such a reverse/permute and so this would lead to a 
performance regression (specifically on PowerPC).


Instead it seems more natural for the tree code to produce a scalar result 
(producing a vector with the result in lane 0 has already caused confusion, e.g. 
https://gcc.gnu.org/ml/gcc-patches/2012-10/msg01100.html).


This patch preserves the meaning of the existing optab (producing a result in 
lane 0 on little-endian architectures or N-1 on bigendian), thus generally 
avoiding the need to change backends. Hence, expr.c extracts an 
endianness-dependent element from the optab result to give the result expected 
for the tree code.


Significant complication in the AArch64 backend stems from the existence of 
builtins for reduction operations, which are gimple_fold'd to the tree code. 
Hence, I introduce new define_expands, and map the existing 
__builtin_aarch64_reduc_s{plus,min,max}_mode functions to those, with scalar 
result types, matching the result of the tree code to which these are still 
gimple_folded.


If the above/proposed solution is acceptable, I'd make a longer patch series, 
including some cleanup to tree-vect-loop.c (vect_create_epilog_for_reduction now 
has only one case where extract_scalar_result == true), and separating out 
AArch64 changes. Further, I'd like to propose creating a new optab that directly 
outputs a scalar, as a migration path away from the existing optab whose meaning 
is endianness-dependent, i.e. such that expand_unop falls back to the existing 
optab only if the new one is not defined.


Patch as it stands has been bootstrapped on x86_64 and regression tested on 
aarch64 and aarch64_be without regressions. On x86_64 there is a regression in 
gcc.target/i386/pr51235.c, where it seems my check in tree-cfg.c is too strict - 
we end up with a reduction from vector (4) unsigned long int to void *. 
(Even if I modify tree-vect-loop.c to build the REDUC_..._EXPR as returning the 
element type of the input vector, its return type is later changed.) It seems I 
can get away with a less-strict check in tree-cfg.c, i.e. allowing the case 
where the modes of the expected and actual result types match (rather than 
useless_type_conversion_p holding between said types), but if anyone can 
suggest an alternative/better check then it'd be great to hear it...


--Alandiff --git a/gcc/config/aarch64/aarch64-builtins.c b/gcc/config/aarch64/aarch64-builtins.c
index fee17ecf637436c8704f565be2eb9ef23891209a..77ed36ecc4cade4c2c6cafd16070198dacb0b869 100644
--- a/gcc/config/aarch64/aarch64-builtins.c
+++ b/gcc/config/aarch64/aarch64-builtins.c
@@ -1396,21 +1396,21 @@ aarch64_gimple_fold_builtin (gimple_stmt_iterator *gsi)
 
 	  switch (fcode)
 	{
-	  BUILTIN_VALL (UNOP, reduc_splus_, 10)
+	  BUILTIN_VALL (UNOP, reduc_splus_, 0)
 		new_stmt = gimple_build_assign_with_ops (
 		REDUC_PLUS_EXPR,
 		gimple_call_lhs (stmt),
 		args[0],
 		NULL_TREE);
 		break;
-	  BUILTIN_VDQIF (UNOP, reduc_smax_, 10)
+	  BUILTIN_VDQIF (UNOP, reduc_smax_, 0)
 		new_stmt = gimple_build_assign_with_ops (
 		REDUC_MAX_EXPR,
 		gimple_call_lhs (stmt),
 		args[0],
 		NULL_TREE);
 		break;
-	  BUILTIN_VDQIF (UNOP, reduc_smin_, 10)
+	  BUILTIN_VDQIF (UNOP, reduc_smin_, 0)
 		new_stmt = gimple_build_assign_with_ops (
 		REDUC_MIN_EXPR,
 		gimple_call_lhs (stmt),
diff --git a/gcc/config/aarch64/aarch64-simd-builtins.def b/gcc/config/aarch64/aarch64-simd-builtins.def
index 268432cc117b7027ee9472fc5a4f9b1ea13bea0f..ef363c676bf5bb05cfdaf0f111324d42c3f3d992 100644
--- a/gcc/config/aarch64/aarch64-simd-builtins.def
+++ b/gcc/config/aarch64/aarch64-simd-builtins.def
@@ -251,13 +251,19 @@
   BUILTIN_VSDQ_I_DI (BINOP, cmgtu, 0)
   BUILTIN_VSDQ_I_DI (BINOP, cmtst, 0)
 
+  /* Implemented by aarch64_reduc_splus_mode.  */
+  BUILTIN_VALL (UNOP, reduc_splus_, 0)
+
   /* Implemented by reduc_surplus_mode.  */
-  BUILTIN_VALL (UNOP, reduc_splus_, 10)
   BUILTIN_VDQ (UNOP, reduc_uplus_, 10)
 
+  /* Implemented by aarch64_reduc_smax_mode.  */
+  BUILTIN_VDQIF (UNOP, reduc_smax_, 0)
+
+  /* Implemented by aarch64_reduc_smin_mode.  */
+  BUILTIN_VDQIF (UNOP, reduc_smin_, 0)
+
   /* Implemented by reduc_maxmin_uns_mode.  */
-  BUILTIN_VDQIF (UNOP, reduc_smax_, 10)
-  BUILTIN_VDQIF (UNOP, 

Re: Patch for constexpr variable templates

2014-08-01 Thread Braden Obrzut

On 07/31/2014 08:53 AM, Jason Merrill wrote:
In the original mail you mentioned doing it in cp_parser_template_id; 
I agree that we probably don't want to do it there because of the 
complications you are seeing.  I was thinking about doing it when we 
normally resolve an id-expression that refers to a variable, once we 
know we're looking at an expression and not a declarator-id.  But I 
think my suggestion of cp_parser_id_expression was wrong, and it would 
be better in finish_id_expression.


Jason

Ahh sorry, I misread the function name you gave. finish_id_expression 
works just fine and doesn't require any extra work.  How does this patch 
look?


- Braden Obrzut

2014-08-01  Braden Obrzut  ad...@maniacsvault.net

* decl.c (grokvardecl): Handle specializations of variable templates.
(grokdeclarator): Handle variable template id expressions and NULL_TREE
return from grokvardecl.
* decl2.c (check_member_template): Allow declaration of template member
variables.
* parser.c (cp_parser_template_id): Build a TEMPLATE_ID_EXPR for
variable templates.
* pt.c (determine_specialization): Accept variable templates.
(check_template_variable): Fixed wanted template header count and
change non static data member error to variable template warning.
(check_explicit_specialization): Handle and check for malformed
variable template specializations.
(lookup_template_variable): New.
(tsubst_decl): Handle variable template specializations.
(do_decl_instantiation): Handle template variables.
(instantiate_decl): Handle template variables.
* semantics.c (finish_template_variable): New.
(finish_id_expression): Instantiate variable templates.

2014-08-01  Braden Obrzut  ad...@maniacsvault.net

* g++.dg/cpp1y/var-templ1.C: New.
* g++.dg/cpp1y/var-templ2.C: New.
* g++.dg/cpp1y/var-templ3.C: New.
* g++.dg/cpp1y/var-templ4.C: New.
* g++.dg/cpp1y/var-templ5.C: New.
* g++.dg/cpp1y/pr59638.C: Marked xfail for template variables as
function pointers taking auto are considered templates at the moment.
* g++.dg/parse/error50.C: Malformed statements look like variable 
templ.

* g++.dg/template/crash71.C: Looks like variable templ.
* g++.old-deja/g++.oliva/template10.C: Looks like variable templ.
* g++.old-deja/g++.pt/var1.C: Non-constexpr variable templ.

2013-03-29  Gabriel Dos Reis  g...@integrable-solutions.net

* cp-tree.h (variable_template_p): Do not check scope.
* pt.c (check_template_variable): Fix thinko from previous change.
(push_template_decl_real): Fix formatting.


2013-03-29  Gabriel Dos Reis  g...@integrable-solutions.net

* cp-tree.h (variable_template_p): New.
* pt.c (check_template_variable): Accept variable temploids at
non-class scope.
(push_template_decl_real): The current instantiation of a template
can be a VAR_DECL.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 4a5cb98..c6c 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -5027,6 +5027,17 @@ class_of_this_parm (const_tree fntype)
   return TREE_TYPE (type_of_this_parm (fntype));
 }
 
+/* True if T designates a variable template declaration.  */
+inline bool
+variable_template_p (tree t)
+{
+  if (TREE_CODE (t) != TEMPLATE_DECL)
+return false;
+  if (tree r = DECL_TEMPLATE_RESULT (t))
+return VAR_P (r);
+  return false;
+}
+
 /* A parameter list indicating for a function with no parameters,
e.g  int f(void).  */
 extern cp_parameter_declarator *no_parameters;
@@ -5554,6 +5565,7 @@ extern bool redeclare_class_template		(tree, tree);
 extern tree lookup_template_class		(tree, tree, tree, tree,
 		 int, tsubst_flags_t);
 extern tree lookup_template_function		(tree, tree);
+extern tree lookup_template_variable		(tree, tree);
 extern int uses_template_parms			(tree);
 extern int uses_template_parms_level		(tree, int);
 extern bool in_template_function		(void);
@@ -5816,6 +5828,7 @@ extern tree perform_koenig_lookup		(tree, vectree, va_gc *,
 		 tsubst_flags_t);
 extern tree finish_call_expr			(tree, vectree, va_gc **, bool,
 		 bool, tsubst_flags_t);
+extern tree finish_template_variable	(tree);
 extern tree finish_increment_expr		(tree, enum tree_code);
 extern tree finish_this_expr			(void);
 extern tree finish_pseudo_destructor_expr   (tree, tree, tree, location_t);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index dae85c2..2ac0472 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -80,8 +80,8 @@ static int ambi_op_p (enum tree_code);
 static int unary_op_p (enum tree_code);
 static void push_local_name (tree);
 static tree grok_reference_init (tree, tree, tree, int);
-static tree grokvardecl (tree, tree, const cp_decl_specifier_seq *,
-			 int, int, tree);
+static tree grokvardecl (tree, tree, tree, const cp_decl_specifier_seq *,
+			 int, int, int, tree);
 static int check_static_variable_definition (tree, tree);
 static void record_unknown_type (tree, const char *);
 

[Ada] Spurious warning on generated with_clause for renamed unit

2014-08-01 Thread Arnaud Charlet
This patch suppresses spurious warnings that may be generated when the prefix
of a with_clause for a child unit denotes the renaming of a parent unit.
Such renamings generate internal with_clauses that are not marked Implicit_With
because they must be properly installed as part of the context, but they are
never redundant with explicit with_clauses.

The following must compile quietly:

   gcc -c -gnatwa pkg_b2.adb

---
with Renamed_Pkg_A;
package Pkg_B2
is
   procedure Proc_1( Val_1 : in out Renamed_Pkg_A.Type_A );
end Pkg_B2;
---
package Pkg_A
is
   type Type_A is ( A1, A2 );
end Pkg_A;
---
with Pkg_A;
package Renamed_Pkg_A renames Pkg_A;
---
package Pkg_A.Child_A
is
   type Type_B is ( B1, B2 );
end Pkg_A.Child_A;
---
with Renamed_Pkg_A.Child_A;
package body Pkg_B2
is
   use type Renamed_Pkg_A.Child_A.Type_B;

   Val_B : Renamed_Pkg_A.Child_A.Type_B := Renamed_Pkg_A.Child_A.Type_B'First;
   
   procedure Proc_1( Val_1 : in out Renamed_Pkg_A.Type_A )
   is
   begin
  if Val_B = Renamed_Pkg_A.Child_A.Type_B'First then
 Val_1 := Renamed_Pkg_A.Type_A'Last;
 Val_B := Renamed_Pkg_A.Child_A.Type_B'Last;
  else 
 Val_B := Renamed_Pkg_A.Child_A.Type_B'First;
  end if;
   end Proc_1;
end Pkg_B2;

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

2014-08-01  Ed Schonberg  schonb...@adacore.com

* sem_ch10.adb (Analyze_Compilation_Unit): Do not place a
warning on a with_clause created for the renaming of a parent
unit in an explicit with_clause.

Index: sem_ch10.adb
===
--- sem_ch10.adb(revision 213440)
+++ sem_ch10.adb(working copy)
@@ -242,7 +242,7 @@
--  on the context. Note that in contrast with the handling of private
--  types, the limited view and the non-limited view of a type are treated
--  as separate entities, and no entity exchange needs to take place, which
-   --  makes the implementation must simpler than could be feared.
+   --  makes the implementation much simpler than could be feared.
 
--
-- Analyze_Compilation_Unit --
@@ -507,11 +507,15 @@
 
 --  Avoid checking implicitly generated with clauses, limited with
 --  clauses or withs that have pragma Elaborate or Elaborate_All.
+--  With_clauses introduced for renamings of parent clauses are not
+--  marked implicit because they need to be properly installed, but
+--  they do not come from source and do not require warnings.
 
 if Nkind (Clause) = N_With_Clause
   and then not Implicit_With (Clause)
   and then not Limited_Present (Clause)
   and then not Elaborate_Present (Clause)
+  and then Comes_From_Source (Clause)
 then
--  Package body-to-spec check
 


[Ada] Conformance checking in instantiations

2014-08-01 Thread Arnaud Charlet
Within an instance, a subprogram declaration and the corresponding body may be
fully conformant, but one may use in its profile a formal type while the other
uses a declared subtype of that formal. The routine Same_Generic_Actual is used
to recognize this case and prevent a spurious conformance error or the creation
of two different subprograms, which leads to errors at link time. This patch
makes the check symmetric, so that either the spec or the body may use a
declared subtype of the generic formal.

The following must execute quietly:

   gnatmake -q main

---
with specific_vector;
procedure main is
   sv : specific_vector.Object := (1.0, 2.0, 3.0);
begin
   sv := specific_vector.-(Right = sv);
end main;
---
with Vector_Types;
generic
   type Vector_Element is digits ;
   type Vector  is array (Vector_Types.Coordinate) of Vector_Element;
Package Generic_Vector is
   subtype Object is Vector;

   function - (Right : Object) return Object;
end Generic_Vector;
---
with Vector_Types;
package body Generic_Vector is

   function - (Right : Vector) return Vector is
  Negated_Vector : Vector := (vector_types.X = -Right(vector_types.X),
  vector_types.Y = -Right(vector_types.Y),
  vector_types.Z = -Right(vector_types.Z) );
   begin
  return Negated_Vector;
   end -;
end Generic_Vector;
---
with interfaces;
with Vector_Types;
with Generic_Vector;
package Specific_Vector is new
  Generic_Vector(Vector_Element = Interfaces.IEEE_Float_64,
 Vector = Vector_Types.Float_Vector_64);
---
with interfaces;
package Vector_Types is
   type Coordinate is (X, Y, Z);
   type Float_Vector_64 is array (Coordinate) of Interfaces.IEEE_Float_64;
end Vector_Types;

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

2014-08-01  Ed Schonberg  schonb...@adacore.com

* sem_ch6.adb (Same_Generic_Actual): Make function symmetric,
because either type may be a subtype of the other.

Index: sem_ch6.adb
===
--- sem_ch6.adb (revision 213434)
+++ sem_ch6.adb (working copy)
@@ -7274,21 +7274,38 @@
  --  Check that the types of corresponding formals have the same
  --  generic actual if any. We have to account for subtypes of a
  --  generic formal, declared between a spec and a body, which may
- --  appear distinct in an instance but matched in the generic.
+ --  appear distinct in an instance but matched in the generic, and
+ --  the subtype may be used either in the spec or the body of the
+ --  subprogram being checked.
 
  -
  -- Same_Generic_Actual --
  -
 
  function Same_Generic_Actual (T1, T2 : Entity_Id) return Boolean is
+
+function Is_Declared_Subtype (S1, S2 : Entity_Id) return Boolean;
+--  Predicate to check whether S1 is a subtype of S2 in the source
+--  of the instance.
+
+-
+-- Is_Declared_Subtype --
+-
+
+function Is_Declared_Subtype (S1, S2 : Entity_Id) return Boolean is
+begin
+   return Comes_From_Source (Parent (S1))
+ and then Nkind (Parent (S1)) = N_Subtype_Declaration
+ and then Is_Entity_Name (Subtype_Indication (Parent (S1)))
+ and then Entity (Subtype_Indication (Parent (S1))) = S2;
+end Is_Declared_Subtype;
+
+ --  Start of processing for Same_Generic_Actual
+
  begin
 return Is_Generic_Actual_Type (T1) = Is_Generic_Actual_Type (T2)
-  or else
-(Present (Parent (T1))
-  and then Comes_From_Source (Parent (T1))
-  and then Nkind (Parent (T1)) = N_Subtype_Declaration
-  and then Is_Entity_Name (Subtype_Indication (Parent (T1)))
-  and then Entity (Subtype_Indication (Parent (T1))) = T2);
+  or else Is_Declared_Subtype (T1, T2)
+  or else Is_Declared_Subtype (T2, T1);
  end Same_Generic_Actual;
 
   --  Start of processing for Different_Generic_Profile


Re: [PATCH][testsuite] Don't run cproj-fails-with-broken-glibc.c for broken glibc

2014-08-01 Thread Rainer Orth
Hi Tom,

 The test-case cproj-fails-with-broken-glibc.c does not work with broken
 glibcs, as the header comment mentions:
 ...
Check the runtime behavior of the C library's cproj() function and
whether it follows the standard.  Versions of GLIBC through 2.11.1
had an incorrect implementation which will conflict with GCC's
builtin cproj().  GLIBC 2.12+ should be okay.
 ...

 This patch skips the test for known broken glibcs. OK for trunk?

I'm not at all happy with this patch: unless absolutely necessary, we
shouldn't check for version numbers when there's any way to check for
working/broken features instead.

I'm all for keeping testsuite results clean, but this seems like a total
corner case to me.  Which distributions do still use affected glibc
versions?

That test, even if we go the glibc version route, needs to be XFAILed
instead of requiring the working version.  Apart from that, new
effective-target keywords need documenting in doc/sourcebuild.texi.

Thanks.
Rainer

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


[PATCH] convert many pointer_map to hash_map

2014-08-01 Thread tsaunders
From: Trevor Saunders tsaund...@mozilla.com

Hi,

This patch replaces a bunch of usage of pointer_map with hash_map.  It also
adds an overload to hash_map::traverse that allows modifying the value, and a
remove method.

bootstrapped + regtested on x86_64-unknown-linux-gnu, ok?

Trev

c-family/

* cilk.c: Use hash_map instead of pointer_map.

c/

* c-typeck.c: Use hash_map instead of pointer_map.

cp/

* optimize.c, semantics.c: Use hash_map instead of pointer_map.

gcc/

* hash-map.h (default_hashmap_traits::mark_key_deleted):
Fix cast.
(hash_map::remove): New method.
(hash_map::traverse): New method.
* cgraph.h, except.c, except.h, gimple-ssa-strength-reduction.c,
ipa-utils.c, lto-cgraph.c, lto-streamer.h, omp-low.c, predict.c,
tree-cfg.c, tree-cfgcleanup.c, tree-eh.c, tree-eh.h, tree-inline.c,
tree-inline.h, tree-nested.c, tree-sra.c, tree-ssa-loop-im.c,
tree-ssa-loop-ivopts.c, tree-ssa-reassoc.c, tree-ssa-structalias.c,
tree-ssa.c, tree-ssa.h, var-tracking.c: Use hash_map instead of
 pointer_map.
diff --git a/gcc/c-family/cilk.c b/gcc/c-family/cilk.c
index b864bb1..e0d1141 100644
--- a/gcc/c-family/cilk.c
+++ b/gcc/c-family/cilk.c
@@ -64,7 +64,7 @@ struct wrapper_data
   /* Containing function.  */
   tree context;
   /* Disposition of all variables in the inner statement.  */
-  struct pointer_map_t *decl_map;
+  hash_maptree, tree *decl_map;
   /* True if this function needs a static chain.  */
   bool nested;
   /* Arguments to be passed to wrapper function, currently a list.  */
@@ -335,12 +335,11 @@ create_cilk_helper_decl (struct wrapper_data *wd)
 
 /* A function used by walk tree to find wrapper parms.  */
 
-static bool
-wrapper_parm_cb (const void *key0, void **val0, void *data)
+bool
+wrapper_parm_cb (tree const key0, tree *val0, wrapper_data *wd)
 {
-  struct wrapper_data *wd = (struct wrapper_data *) data;
-  tree arg = * (tree *)key0;
-  tree val = (tree)*val0;
+  tree arg = key0;
+  tree val = *val0;
   tree parm;
 
   if (val == error_mark_node || val == arg)
@@ -387,7 +386,7 @@ build_wrapper_type (struct wrapper_data *wd)
   wd-parms = NULL_TREE;
   wd-argtypes = void_list_node;
 
-  pointer_map_traverse (wd-decl_map, wrapper_parm_cb, wd);
+  wd-decl_map-traversewrapper_data *, wrapper_parm_cb (wd);
   gcc_assert (wd-type != CILK_BLOCK_FOR);
 
   /* Now build a function.
@@ -452,25 +451,22 @@ copy_decl_for_cilk (tree decl, copy_body_data *id)
 
 /* Copy all local variables.  */
 
-static bool
-for_local_cb (const void *k_v, void **vp, void *p)
+bool
+for_local_cb (tree const k, tree *vp, copy_body_data *id)
 {
-  tree k = *(tree *) k_v;
-  tree v = (tree) *vp;
+  tree v = *vp;
 
   if (v == error_mark_node)
-*vp = copy_decl_no_change (k, (copy_body_data *) p);
+*vp = copy_decl_no_change (k, id);
   return true;
 }
 
 /* Copy all local declarations from a _Cilk_spawned function's body.  */
 
-static bool
-wrapper_local_cb (const void *k_v, void **vp, void *data)
+bool
+wrapper_local_cb (tree const key, tree *vp, copy_body_data *id)
 {
-  copy_body_data *id = (copy_body_data *) data;
-  tree key = *(tree *) k_v;
-  tree val = (tree) *vp;
+  tree val = *vp;
 
   if (val == error_mark_node)
 *vp = copy_decl_for_cilk (key, id);
@@ -514,8 +510,11 @@ cilk_outline (tree inner_fn, tree *stmt_p, void *w)
   insert_decl_map (id, wd-block, DECL_INITIAL (inner_fn));
 
   /* We don't want the private variables any more.  */
-  pointer_map_traverse (wd-decl_map, nested ? for_local_cb : wrapper_local_cb,
-   id);
+  if (nested)
+wd-decl_map-traversecopy_body_data *, for_local_cb (id);
+  else
+wd-decl_map-traversecopy_body_data *, wrapper_local_cb (id);
+
   walk_tree (stmt_p, copy_tree_body_r, (void *) id, NULL);
 
   /* See if this function can throw or calls something that should
@@ -576,7 +575,7 @@ init_wd (struct wrapper_data *wd, enum cilk_block_type type)
   wd-type = type;
   wd-fntype = NULL_TREE;
   wd-context = current_function_decl;
-  wd-decl_map = pointer_map_create ();
+  wd-decl_map = new hash_maptree, tree;
   /* _Cilk_for bodies are always nested.  Others start off as 
  normal functions.  */
   wd-nested = (type == CILK_BLOCK_FOR);
@@ -590,7 +589,7 @@ init_wd (struct wrapper_data *wd, enum cilk_block_type type)
 static void
 free_wd (struct wrapper_data *wd)
 {
-  pointer_map_destroy (wd-decl_map);
+  delete wd-decl_map;
   wd-nested = false;
   wd-arglist = NULL_TREE;
   wd-argtypes = NULL_TREE;
@@ -618,12 +617,11 @@ free_wd (struct wrapper_data *wd)
(var, ???) -- Pure output argument, handled similarly to above.
 */
 
-static bool
-declare_one_free_variable (const void *var0, void **map0,
-  void *data ATTRIBUTE_UNUSED)
+bool
+declare_one_free_variable (tree const var0, tree *map0, wrapper_data )
 {
-  const_tree var = (const_tree) var0;
-  tree map = (tree)*map0;
+  const_tree var = var0;
+  tree map = *map0;
   

Re: [RFC][Vectorizer, AArch64] Fix PR/61114 by redefining REDUC_xxx_EXPR tree codes to return scalars

2014-08-01 Thread Richard Biener
On Fri, Aug 1, 2014 at 12:19 PM, Alan Lawrence alan.lawre...@arm.com wrote:
 This fixes PR/61114 by redefining the REDUC_{MIN,MAX,PLUS}_EXPR tree codes.

 These are presently documented as producing a vector with the result in
 element 0, and this is inconsistent with their use in tree-vect-loop.c
 (which on bigendian targets pulls the bits out of the other end of the
 vector result). This leads to bugs on bigendian targets - see
 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61114 for a small testcase.

 I discounted fixing the vectorizer (to always read from element 0) and
 then making the optab reverse the result on bigendian targets (whose
 architectural insn produces the result in lane N-1), as optimization of
 vectors in RTL seems unlikely to remove such a reverse/permute and so this
 would lead to a performance regression (specifically on PowerPC).

 Instead it seems more natural for the tree code to produce a scalar result
 (producing a vector with the result in lane 0 has already caused confusion,
 e.g. https://gcc.gnu.org/ml/gcc-patches/2012-10/msg01100.html).

 This patch preserves the meaning of the existing optab (producing a result
 in lane 0 on little-endian architectures or N-1 on bigendian), thus
 generally avoiding the need to change backends. Hence, expr.c extracts an
 endianness-dependent element from the optab result to give the result
 expected for the tree code.

 Significant complication in the AArch64 backend stems from the existence of
 builtins for reduction operations, which are gimple_fold'd to the tree code.
 Hence, I introduce new define_expands, and map the existing
 __builtin_aarch64_reduc_s{plus,min,max}_mode functions to those, with
 scalar result types, matching the result of the tree code to which these are
 still gimple_folded.

 If the above/proposed solution is acceptable, I'd make a longer patch
 series, including some cleanup to tree-vect-loop.c
 (vect_create_epilog_for_reduction now has only one case where
 extract_scalar_result == true), and separating out AArch64 changes. Further,
 I'd like to propose creating a new optab that directly outputs a scalar, as
 a migration path away from the existing optab whose meaning is
 endianness-dependent, i.e. such that expand_unop falls back to the existing
 optab only if the new one is not defined.

 Patch as it stands has been bootstrapped on x86_64 and regression tested on
 aarch64 and aarch64_be without regressions. On x86_64 there is a regression
 in gcc.target/i386/pr51235.c, where it seems my check in tree-cfg.c is too
 strict - we end up with a reduction from vector (4) unsigned long int to
 void *. (Even if I modify tree-vect-loop.c to build the REDUC_..._EXPR as
 returning the element type of the input vector, its return type is later
 changed.) It seems I can get away with a less-strict check in tree-cfg.c,
 i.e. allowing the case where the modes of the expected and actual result
 types match (rather than useless_type_conversion_p holding between said
 types), but if anyone can suggest an alternative/better check then it'd be
 great to hear it...

We should fix the vectorizer code-generation instead.

Makes sense to me - non-aarch64 parts of the patch are ok.  The optab
migration strategy is as well.

Thanks,
Richard.

 --Alan


Re: [PATCH] convert many pointer_map to hash_map

2014-08-01 Thread Richard Biener
On Fri, Aug 1, 2014 at 12:34 PM,  tsaund...@mozilla.com wrote:
 From: Trevor Saunders tsaund...@mozilla.com

 Hi,

 This patch replaces a bunch of usage of pointer_map with hash_map.  It also
 adds an overload to hash_map::traverse that allows modifying the value, and a
 remove method.

 bootstrapped + regtested on x86_64-unknown-linux-gnu, ok?

Ok.

Thanks,
Richard.

 Trev

 c-family/

 * cilk.c: Use hash_map instead of pointer_map.

 c/

 * c-typeck.c: Use hash_map instead of pointer_map.

 cp/

 * optimize.c, semantics.c: Use hash_map instead of pointer_map.

 gcc/

 * hash-map.h (default_hashmap_traits::mark_key_deleted):
 Fix cast.
 (hash_map::remove): New method.
 (hash_map::traverse): New method.
 * cgraph.h, except.c, except.h, gimple-ssa-strength-reduction.c,
 ipa-utils.c, lto-cgraph.c, lto-streamer.h, omp-low.c, predict.c,
 tree-cfg.c, tree-cfgcleanup.c, tree-eh.c, tree-eh.h, tree-inline.c,
 tree-inline.h, tree-nested.c, tree-sra.c, tree-ssa-loop-im.c,
 tree-ssa-loop-ivopts.c, tree-ssa-reassoc.c, tree-ssa-structalias.c,
 tree-ssa.c, tree-ssa.h, var-tracking.c: Use hash_map instead of
  pointer_map.
 diff --git a/gcc/c-family/cilk.c b/gcc/c-family/cilk.c
 index b864bb1..e0d1141 100644
 --- a/gcc/c-family/cilk.c
 +++ b/gcc/c-family/cilk.c
 @@ -64,7 +64,7 @@ struct wrapper_data
/* Containing function.  */
tree context;
/* Disposition of all variables in the inner statement.  */
 -  struct pointer_map_t *decl_map;
 +  hash_maptree, tree *decl_map;
/* True if this function needs a static chain.  */
bool nested;
/* Arguments to be passed to wrapper function, currently a list.  */
 @@ -335,12 +335,11 @@ create_cilk_helper_decl (struct wrapper_data *wd)

  /* A function used by walk tree to find wrapper parms.  */

 -static bool
 -wrapper_parm_cb (const void *key0, void **val0, void *data)
 +bool
 +wrapper_parm_cb (tree const key0, tree *val0, wrapper_data *wd)
  {
 -  struct wrapper_data *wd = (struct wrapper_data *) data;
 -  tree arg = * (tree *)key0;
 -  tree val = (tree)*val0;
 +  tree arg = key0;
 +  tree val = *val0;
tree parm;

if (val == error_mark_node || val == arg)
 @@ -387,7 +386,7 @@ build_wrapper_type (struct wrapper_data *wd)
wd-parms = NULL_TREE;
wd-argtypes = void_list_node;

 -  pointer_map_traverse (wd-decl_map, wrapper_parm_cb, wd);
 +  wd-decl_map-traversewrapper_data *, wrapper_parm_cb (wd);
gcc_assert (wd-type != CILK_BLOCK_FOR);

/* Now build a function.
 @@ -452,25 +451,22 @@ copy_decl_for_cilk (tree decl, copy_body_data *id)

  /* Copy all local variables.  */

 -static bool
 -for_local_cb (const void *k_v, void **vp, void *p)
 +bool
 +for_local_cb (tree const k, tree *vp, copy_body_data *id)
  {
 -  tree k = *(tree *) k_v;
 -  tree v = (tree) *vp;
 +  tree v = *vp;

if (v == error_mark_node)
 -*vp = copy_decl_no_change (k, (copy_body_data *) p);
 +*vp = copy_decl_no_change (k, id);
return true;
  }

  /* Copy all local declarations from a _Cilk_spawned function's body.  */

 -static bool
 -wrapper_local_cb (const void *k_v, void **vp, void *data)
 +bool
 +wrapper_local_cb (tree const key, tree *vp, copy_body_data *id)
  {
 -  copy_body_data *id = (copy_body_data *) data;
 -  tree key = *(tree *) k_v;
 -  tree val = (tree) *vp;
 +  tree val = *vp;

if (val == error_mark_node)
  *vp = copy_decl_for_cilk (key, id);
 @@ -514,8 +510,11 @@ cilk_outline (tree inner_fn, tree *stmt_p, void *w)
insert_decl_map (id, wd-block, DECL_INITIAL (inner_fn));

/* We don't want the private variables any more.  */
 -  pointer_map_traverse (wd-decl_map, nested ? for_local_cb : 
 wrapper_local_cb,
 -   id);
 +  if (nested)
 +wd-decl_map-traversecopy_body_data *, for_local_cb (id);
 +  else
 +wd-decl_map-traversecopy_body_data *, wrapper_local_cb (id);
 +
walk_tree (stmt_p, copy_tree_body_r, (void *) id, NULL);

/* See if this function can throw or calls something that should
 @@ -576,7 +575,7 @@ init_wd (struct wrapper_data *wd, enum cilk_block_type 
 type)
wd-type = type;
wd-fntype = NULL_TREE;
wd-context = current_function_decl;
 -  wd-decl_map = pointer_map_create ();
 +  wd-decl_map = new hash_maptree, tree;
/* _Cilk_for bodies are always nested.  Others start off as
   normal functions.  */
wd-nested = (type == CILK_BLOCK_FOR);
 @@ -590,7 +589,7 @@ init_wd (struct wrapper_data *wd, enum cilk_block_type 
 type)
  static void
  free_wd (struct wrapper_data *wd)
  {
 -  pointer_map_destroy (wd-decl_map);
 +  delete wd-decl_map;
wd-nested = false;
wd-arglist = NULL_TREE;
wd-argtypes = NULL_TREE;
 @@ -618,12 +617,11 @@ free_wd (struct wrapper_data *wd)
 (var, ???) -- Pure output argument, handled similarly to above.
  */

 -static bool
 -declare_one_free_variable (const void *var0, void **map0,
 -  void *data ATTRIBUTE_UNUSED)
 

Re: [PATCH][AArch64] Improve TARGET_LEGITIMIZE_ADDRESS_P hook

2014-08-01 Thread Venkataramanan Kumar
Hi Jiong,

(Snip)
+   (op0 == virtual_stack_vars_rtx
+  || op0 == frame_pointer_rtx
+  || op0 == arg_pointer_rtx)
(Snip)

The above check is means that these are the ways to access the frame.
is it possible to have stack_pointer_rtx has op0?


On 1 August 2014 14:01, Jiong Wang jiong.w...@arm.com wrote:
 currently, aarch64 LEGITIMIZE_ADDRESS_P hook will reject all reg + offset
 address given
 offset is beyond supported range.

 while this may be too strict. we should honor the strict_p parameter in
 the hook. before
 reload, we accept all offset if it's a frame access, because the offset may
 change during
 later register elimination.

 the early reject of reg + offset may cause extra registers created, and if
 that register
 live range is across function invoking then callee saved reg needed, thus
 introduce extra
 reg save/restore also.

 give a simple example as:

 int
 test15 (void)
 {
   unsigned char a[480];
   initialize_array (a, 480);

   if (a[0] == 0x10)
 return 1;

   return 0;
 }

 .S before the patch
 (-O2 -fPIC)
 ===
 test15:
 sub sp, sp, #480
 mov w1, 480
 stp x29, x30, [sp, -32]!
 add x29, sp, 0
 str x19, [sp, 16]
 add x19, x29, 32
 mov x0, x19
 bl  initialize_array
 ldrbw0, [x19]
 ldr x19, [sp, 16]
 ldp x29, x30, [sp], 32
 cmp w0, 16
 csetw0, eq
 add sp, sp, 480
 ret

 .S after the patch
 ===
 test15:
 stp x29, x30, [sp, -496]!
 mov w1, 480
 add x29, sp, 0
 add x0, x29, 16
 bl  initialize_array
 ldrbw0, [x29, 16]
 ldp x29, x30, [sp], 496
 cmp w0, 16
 csetw0, eq
 ret

 test done
 =
 no regression on aarch64-none-elf bare metal.
 bootstrap OK on aarch64.

 OK for trunk?

 thanks.

 gcc/
   * config/aarch64/aarch64.c (aarch64_classify_address): Accept all offset
 for frame access
   when strict_p is false.

 gcc/testsuite
   * gcc.target/aarch64/legitimize_stack_var_before_reload_1.c: New testcase.


Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-01 Thread Richard Biener
On Fri, Aug 1, 2014 at 6:51 AM, Kugan kugan.vivekanandara...@linaro.org wrote:
 +  lhs_type = lang_hooks.types.type_for_mode (lhs_mode, lhs_uns);
 ...
 +   ((!lhs_uns  !wi::neg_p (min, TYPE_SIGN (lhs_type)))
 ...
 +  type_min = wide_int::from (TYPE_MIN_VALUE (lhs_type), prec,
 +TYPE_SIGN (TREE_TYPE (ssa)));
 +  type_max = wide_int::from (TYPE_MAX_VALUE (lhs_type), prec,
 +TYPE_SIGN (TREE_TYPE (ssa)));

 you shouldn't try getting at lhs_type.  Btw, do you want to constrain
 lhs_mode to MODE_INTs somewhere?

 Is this in addition to !INTEGRAL_TYPE_P (TREE_TYPE (ssa)))? Do you mean
 that I should check lhs_mode as well?

No, that's probably enough.

 For TYPE_SIGN use lhs_uns instead, for the min/max value you
 should use wi::min_value () and wi::max_value () instead.

 You are still using TYPE_SIGN (TREE_TYPE (ssa)) here and later,
 but we computed rhs_uns properly using PROMOTE_MODE.
 I think  the code with re-setting lhs_uns if rhs_uns != lhs_uns
 and later using TYPE_SIGN again is pretty hard to follow.

 Btw, it seems you need to conditionalize the call to PROMOTE_MODE
 on its availability.

 Isn't it simply about choosing a proper range we need to restrict
 ssa to?  That is, dependent on rhs_uns computed by PROMOTE_MODE,
 simply:

 +  mode = TYPE_MODE (TREE_TYPE (ssa));
 +  rhs_uns = TYPE_UNSIGNED (TREE_TYPE (ssa));
 #ifdef PROMOTE_MODE
 +  PROMOTE_MODE (mode, rhs_uns, TREE_TYPE (ssa));
 #endif

  if (rhs_uns)
return wi::ge_p (min, 0);  // if min = 0 then range contains positive 
 values
  else
return wi::le_p (max, wi::max_value (TYPE_PRECISION (TREE_TYPE
 (ssa)), SIGNED);  // if max = signed-max-of-type then range doesn't
 need sign-extension

 I think we will have to check that ssa has necessary sign/zero extension
 when assigned to lhs_type. If PROMOTE_MODE tells us that ssa's type will
 be interpreted differently, the value range of ssa also will have
 corresponding range.  In this cases, shouldn’t we have to check for
 upper and lower limit for both min and max?

Hmm?  That's exactly what the check is testing...  we know that
min = max thus if min = 0 then max = 0.

zero_extension will never do anything on [0, INF]

If max  MAX-SIGNED then sign-extension will not do anything.  Ok,
sign-extension will do sth for negative values still.  So rather

  if (rhs_uns)
return wi::geu_p (min, 0);
  else
return wi::ges_p (min, 0)  wi::les_p (max, wi::max_value
(TYPE_PRECISION (TREE_TYPE (ssa)), SIGNED));

?

I don't like the use of int_fits_type_p you propose.

Richard.

 How about this?

 bool
 promoted_for_type_p (tree ssa, enum machine_mode lhs_mode, bool lhs_uns)
 {
   wide_int min, max;
   tree lhs_type, rhs_type;
   bool rhs_uns;
   enum machine_mode rhs_mode;
   tree min_tree, max_tree;

   if (ssa == NULL_TREE
   || TREE_CODE (ssa) != SSA_NAME
   || !INTEGRAL_TYPE_P (TREE_TYPE (ssa)))
 return false;

   /* Return FALSE if value_range is not recorded for SSA.  */
   if (get_range_info (ssa, min, max) != VR_RANGE)
 return false;

   rhs_uns = TYPE_UNSIGNED (TREE_TYPE (ssa));
   if (rhs_uns != lhs_uns)
 {
   /* Signedness of LHS and RHS differs and values also cannot be
  represented in LHS range.  */
   unsigned int prec = min.get_precision ();
   if ((lhs_uns  wi::neg_p (min, rhs_uns ? UNSIGNED : SIGNED))
   || (!lhs_uns  !wi::le_p (max,
 wi::max_value (prec, SIGNED),
 rhs_uns ? UNSIGNED : SIGNED)))
 return false;
 }

   /* In some architectures, modes are promoted and sign changed with
  target defined PROMOTE_MODE macro.  If PROMOTE_MODE tells you to
  promote _not_ according to ssa's sign then honour that.  */
   rhs_mode = TYPE_MODE (TREE_TYPE (ssa));
 #ifdef PROMOTE_MODE
   PROMOTE_MODE (rhs_mode, rhs_uns, TREE_TYPE (ssa));
 #endif

   rhs_type = lang_hooks.types.type_for_mode (rhs_mode, rhs_uns);
   lhs_type = lang_hooks.types.type_for_mode (lhs_mode, lhs_uns);
   min_tree = wide_int_to_tree (rhs_type, min);
   max_tree = wide_int_to_tree (rhs_type, max);

   /* Check if values lies in-between the type range.  */
   if (int_fits_type_p (min_tree, lhs_type)
int_fits_type_p (max_tree, lhs_type))
 return true;
   else
 return false;
 }


 Thanks,
 Kugan


Re: [RFC, PATCH 3/n] IPA C++ refactoring

2014-08-01 Thread Martin Liška

On 08/01/2014 02:34 AM, Trevor Saunders wrote:
 +++ b/gcc/cgraph.h
 @@ -27,6 +27,7 @@ along with GCC; see the file COPYING3.  If not see
  #include basic-block.h
  #include function.h
  #include ipa-ref.h
 +#include indexed-set.h
 you don't actually use that here so why are you including it?

 +++ b/gcc/cgraphunit.c
 @@ -211,11 +211,12 @@ along with GCC; see the file COPYING3.  If not see
  #include tree-nested.h
  #include gimplify.h
  #include dbgcnt.h
 +#include indexed-set.h
 afaict you don't use it here either.

 @@ -529,9 +529,9 @@ cgraph_node::add_new_function (tree fndecl, bool lowered)
}
  if (lowered)
node-lowered = true;
 -if (!cgraph_new_nodes)
 -  cgraph_new_nodes = cgraph_node_set_new ();
 -cgraph_node_set_add (cgraph_new_nodes, node);
 +if (!cgraph_new_nodes.exists ())
 +  cgraph_new_nodes.create (4);
 I don't think you need this, if the vector doesn't exist it will point
 at null, and safe_push knows how to handle that.

 +++ b/gcc/indexed-set.h
 +templatetypename T
 +class indexed_set
 per below I don't think you actually need this class after all.

 +{
 +public:
 +  class iterator
 +  {
 +  public:
 +iterator (const vecT *v, unsigned index) : m_index (index), m_vector 
 (v) {};
 +
 +inline T operator * ()
 +{
 +  gcc_assert (m_index  m_vector-length ());
 +
 +  return (*m_vector)[m_index];
 +}
 +
 +inline iterator operator ++ ()
 +{
 +  m_index++;
 +  return *this;
 +}
 +
 +bool operator != (const iterator other) const
 +{
 +  return m_vector != other.m_vector || m_index != other.m_index;
 +}
 +
 +inline int
 +get_index (void) const
 +{
 +  return m_index;
 +}
 +
 +  private:
 +unsigned m_index;
 +const vec T *m_vector;
 +  };
 +
 +  /* Iterator to the start of data structure.  */
 +
 +  iterator begin () const
 +  {
 +gcc_assert (!is_empty ());
 it seems to me it would be better to just return the iterator for end ()
 if there's no elements.

 +
 +iterator iter (m_vector, 0);
 +return iter;
 +  }
 +
 +  /* Iterator to the end of data structure.  */
 +
 +  iterator end () const
 +  {
 +return iterator (m_vector, m_vector.length ());
 +  }
 +
 +  /* Add item V to data structure.  */
 +
 +  inline void
 afaik defining within the class implies inline.

 +  add (T v)
  You are passing by value here, which you probably don't want to do if T
  is big.

 +  {
 +m_map.put (v, m_vector.length ());
 +m_vector.safe_push (v);
 I think this blows up if v was already in the map, so assert it isn't?

 +  }
 +
 +  /* Return iterator for an item V.  */
 +
 +  inline iterator
 +  find (T v)
 +  {
 +int *item = m_map.get (v);
 +gcc_unreachable ();
 +
 +return item ?  iterator (m_vector, *item) : end ();
 returning an iterator here seems silly, the only information you get is
 the index and if the element exists in the map, so just return an int?

 +  }
 +
 +  /* Return if the data structure is empty.  */
 +
 +  inline bool
 +  is_empty (void) const
 +  {
 +return m_vector.is_empty ();
 +  }
 +
 +  /* Return number of items stored in data structure.  */
 +
 +  inline unsigned
 +  length (void)
 +  {
 +return m_vector.length ();
 +  }
 +
 +
 +private:
 +  hash_mapT, int m_map;
 +  auto_vecT m_vector;
 I know you don't use this with anything but pointers now, but this will
 do weird things if T is some sort of object.

 +};
 +
 +#endif
 diff --git a/gcc/tree-emutls.c b/gcc/tree-emutls.c
 index 89197c7..9c06aec 100644
 --- a/gcc/tree-emutls.c
 +++ b/gcc/tree-emutls.c
 @@ -42,6 +42,7 @@ along with GCC; see the file COPYING3.  If not see
  #include target.h
  #include targhooks.h
  #include tree-iterator.h
 +#include indexed-set.h
  
  
  /* Whenever a target does not support thread-local storage (TLS) natively,
 @@ -70,7 +71,7 @@ along with GCC; see the file COPYING3.  If not see
  /* These two vectors, once fully populated, are kept in lock-step so that
 the index of a TLS variable equals the index of its control variable in
 the other vector.  */
 -static varpool_node_set tls_vars;
 +static indexed_setvarpool_node * tls_vars;
 Note that will create a static initializer that calls malloc, and tls
 emulation probably isn't needed on many targets, so I'd guess your
 better off using a hash_map * with new and delete as annoying as that is.

  static vecvarpool_node * control_vars;
 so, looking at this thing more closely it looks like this is just a
 weirdo implementation of a hash map from varpool_node * to (varpool_node
 *, tree) so I think you could just do

 struct tls_var_data
 {
   varpool_node *control_var;
   tree access;
 };

 hash_mapvar_pool_node *, tls_var_data

 Thanks!

 Trev

Hello,
   I followed Trevor's advice and indexed_set won't be needed.

There's a new patch that utilizes just sent hash_map modification 
(hash_map::traverse can modify values).
Regtested on x86_64-pc-linux-gnu with --enable-tls=no.

Thanks,
Martin

Re: [RFC, PATCH 3/n] IPA C++ refactoring

2014-08-01 Thread Jakub Jelinek
Hi!

Just a random comment:

On Fri, Aug 01, 2014 at 01:35:47PM +0200, Martin Liška wrote:
 @@ -357,8 +356,8 @@ cgraph_process_new_functions (void)
 break;
   }
  }
 -  free_cgraph_node_set (cgraph_new_nodes);
 -  cgraph_new_nodes = NULL;
 +
 +cgraph_new_nodes.release ();
  }

Please watch out formatting.  This used to be indented by 2 spaces, but
you changed it to 4, that doesn't look right.

Jakub


Re: [RFC, PATCH 3/n] IPA C++ refactoring

2014-08-01 Thread Martin Liška
Hi,
   thank you for your comment. Fixed.

Martin

On 08/01/2014 01:46 PM, Jakub Jelinek wrote:
 Hi!

 Just a random comment:

 On Fri, Aug 01, 2014 at 01:35:47PM +0200, Martin Liška wrote:
 @@ -357,8 +356,8 @@ cgraph_process_new_functions (void)
break;
  }
  }
 -  free_cgraph_node_set (cgraph_new_nodes);
 -  cgraph_new_nodes = NULL;
 +
 +cgraph_new_nodes.release ();
  }
 Please watch out formatting.  This used to be indented by 2 spaces, but
 you changed it to 4, that doesn't look right.

   Jakub

diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index d8651e2..edf3f7f 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -1200,41 +1200,6 @@ public:
   unsigned calls_comdat_local : 1;
 };
 
-/* A cgraph node set is a collection of cgraph nodes.  A cgraph node
-   can appear in multiple sets.  */
-struct cgraph_node_set_def
-{
-  struct pointer_map_t *map;
-  veccgraph_node * nodes;
-};
-
-typedef cgraph_node_set_def *cgraph_node_set;
-typedef struct varpool_node_set_def *varpool_node_set;
-
-class varpool_node;
-
-/* A varpool node set is a collection of varpool nodes.  A varpool node
-   can appear in multiple sets.  */
-struct varpool_node_set_def
-{
-  struct pointer_map_t * map;
-  vecvarpool_node * nodes;
-};
-
-/* Iterator structure for cgraph node sets.  */
-struct cgraph_node_set_iterator
-{
-  cgraph_node_set set;
-  unsigned index;
-};
-
-/* Iterator structure for varpool node sets.  */
-struct varpool_node_set_iterator
-{
-  varpool_node_set set;
-  unsigned index;
-};
-
 /* Structure containing additional information about an indirect call.  */
 
 struct GTY(()) cgraph_indirect_call_info
@@ -1509,7 +1474,7 @@ enum cgraph_state
 };
 extern enum cgraph_state cgraph_state;
 extern bool cgraph_function_flags_ready;
-extern cgraph_node_set cgraph_new_nodes;
+extern veccgraph_node * cgraph_new_nodes;
 
 extern GTY(()) struct asm_node *asm_nodes;
 extern GTY(()) int symtab_order;
@@ -1615,24 +1580,7 @@ void record_references_in_initializer (tree, bool);
 
 /* In ipa.c  */
 bool symtab_remove_unreachable_nodes (bool, FILE *);
-cgraph_node_set cgraph_node_set_new (void);
-cgraph_node_set_iterator cgraph_node_set_find (cgraph_node_set,
-	   cgraph_node *);
-void cgraph_node_set_add (cgraph_node_set, cgraph_node *);
-void cgraph_node_set_remove (cgraph_node_set, cgraph_node *);
-void dump_cgraph_node_set (FILE *, cgraph_node_set);
-void debug_cgraph_node_set (cgraph_node_set);
-void free_cgraph_node_set (cgraph_node_set);
 void cgraph_build_static_cdtor (char which, tree body, int priority);
-
-varpool_node_set varpool_node_set_new (void);
-varpool_node_set_iterator varpool_node_set_find (varpool_node_set,
-		 varpool_node *);
-void varpool_node_set_add (varpool_node_set, varpool_node *);
-void varpool_node_set_remove (varpool_node_set, varpool_node *);
-void dump_varpool_node_set (FILE *, varpool_node_set);
-void debug_varpool_node_set (varpool_node_set);
-void free_varpool_node_set (varpool_node_set);
 void ipa_discover_readonly_nonaddressable_vars (void);
 
 /* In predict.c  */
@@ -1948,93 +1896,6 @@ cgraph_next_function_with_gimple_body (cgraph_node *node)
 /* Create a new static variable of type TYPE.  */
 tree add_new_static_var (tree type);
 
-/* Return true if iterator CSI points to nothing.  */
-static inline bool
-csi_end_p (cgraph_node_set_iterator csi)
-{
-  return csi.index = csi.set-nodes.length ();
-}
-
-/* Advance iterator CSI.  */
-static inline void
-csi_next (cgraph_node_set_iterator *csi)
-{
-  csi-index++;
-}
-
-/* Return the node pointed to by CSI.  */
-static inline cgraph_node *
-csi_node (cgraph_node_set_iterator csi)
-{
-  return csi.set-nodes[csi.index];
-}
-
-/* Return an iterator to the first node in SET.  */
-static inline cgraph_node_set_iterator
-csi_start (cgraph_node_set set)
-{
-  cgraph_node_set_iterator csi;
-
-  csi.set = set;
-  csi.index = 0;
-  return csi;
-}
-
-/* Return true if SET contains NODE.  */
-static inline bool
-cgraph_node_in_set_p (cgraph_node *node, cgraph_node_set set)
-{
-  cgraph_node_set_iterator csi;
-  csi = cgraph_node_set_find (set, node);
-  return !csi_end_p (csi);
-}
-
-/* Return number of nodes in SET.  */
-static inline size_t
-cgraph_node_set_size (cgraph_node_set set)
-{
-  return set-nodes.length ();
-}
-
-/* Return true if iterator VSI points to nothing.  */
-static inline bool
-vsi_end_p (varpool_node_set_iterator vsi)
-{
-  return vsi.index = vsi.set-nodes.length ();
-}
-
-/* Advance iterator VSI.  */
-static inline void
-vsi_next (varpool_node_set_iterator *vsi)
-{
-  vsi-index++;
-}
-
-/* Return the node pointed to by VSI.  */
-static inline varpool_node *
-vsi_node (varpool_node_set_iterator vsi)
-{
-  return vsi.set-nodes[vsi.index];
-}
-
-/* Return an iterator to the first node in SET.  */
-static inline varpool_node_set_iterator
-vsi_start (varpool_node_set set)
-{
-  varpool_node_set_iterator vsi;
-
-  vsi.set = set;
-  vsi.index = 0;
-  return vsi;
-}
-
-/* Return number of nodes in SET.  */
-static 

[C++ PATCH] Improve location info [1/many]

2014-08-01 Thread Marek Polacek
This is the first patch in a series that strives to improve C++ location info.

The following is more like a base for another improvements, thus it contains
only one small test.  It adds a location_t parameter and a vector of location_t
of arguments to finish_call_expr - so functions such as build_over_call and
build_new_method_call can have this info as well.  Next patch will pass these
locations down to build_cxx_call/build_call_a/... functions - I hope we'll then
get rid of that pesky issue that the caret points to final ) of the function,
which is a pain in gdb if the function declarator spans multiple lines.

I'd prefer to do smaller (1000 lines) incremental patches, where every patch
improves something concrete, rather than one huge megapatch.
Maybe you'll want to preapprove similar patches (add location_t to get better
diagnostics) in due course - up to you.

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

2014-08-01  Marek Polacek  pola...@redhat.com

* call.c (convert_like, convert_like_with_context): Add location_t
parameter.
(build_user_type_conversion): Adjust convert_like call.
(build_integral_nontype_arg_conv): Likewise.
(build_new_function_call): Add location_t and veclocation_t
parameters.  Use them.
(build_operator_new_call): Adjust build_over_call call.
(build_op_call_1): Adjust build_over_call and
convert_like_with_context calls.
(build_new_op_1): Likewise.
(build_conditional_expr_1): Adjust convert_like call.
(convert_like_real): Add location_t parameter.  Use it.
(build_over_call): Add location_t and veclocation_t parameters.
Use them.
(build_special_member_call): Adjust build_new_method_call call.
(build_new_method_call_1): Add location_t and veclocation_t
parameters.  Use them.
(build_new_method_call): Likewise.
(perform_implicit_conversion_flags): Adjust convert_like call.
(perform_direct_initialization_if_possible): Adjust convert_like_real
call.
(initialize_reference): Adjust convert_like calls.
* cp-array-notation.c (expand_sec_reduce_builtin): Adjust
finish_call_expr call.
* cp-tree.h: Adjust declarations.
* init.c (build_new_1): Adjust build_new_method_call call.
(build_dtor_call): Likewise.
* method.c (locate_fn_flags): Likewise.
* parser.c (cp_parser_userdef_char_literal): Adjust finish_call_expr
call.
(cp_parser_userdef_numeric_literal): Likewise.
(cp_parser_userdef_string_literal): Likewise.
(cp_parser_postfix_expression): New vector of locations.  Adjust
cp_parser_parenthesized_expression_list call.  Make it fill the
vector of locations of arguments.  Adjust build_new_method_call
and finish_call_expr calls.  Release the vector of locations.
(cp_parser_parenthesized_expression_list): Fill the vector of
locations of arguments.
(cp_parser_new_placement): Adjust
cp_parser_parenthesized_expression_list call.
(cp_parser_new_initializer): Likewise.
(cp_parser_mem_initializer): Likewise.
(cp_parser_initializer): Likewise.
(cp_parser_gnu_attribute_list): Likewise.
(cp_parser_std_attribute): Likewise.
(cp_parser_functional_cast): Likewise.
(cp_parser_omp_declare_reduction_exprs): Likewise.
(cp_parser_perform_range_for_lookup): Adjust finish_call_expr calls.
(cp_parser_range_for_member_function): Likewise.
* pt.c (tsubst_copy_and_build): Adjust build_new_method_call and
finish_call_expr calls.
* semantics.c (finish_call_expr): Add location_t and veclocation_t
parameters.  Use them.
(finish_omp_barrier): Update finish_call_expr call.
(finish_omp_flush): Likewise.
(finish_omp_taskwait): Likewise.
(finish_omp_taskyield): Likewise.
(finish_omp_cancel): Likewise.
(finish_omp_cancellation_point): Likewise.

* g++.dg/diagnostic/location-1.C: New test.

diff --git gcc/cp/call.c gcc/cp/call.c
index 4d37c65..b9db4b9 100644
--- gcc/cp/call.c
+++ gcc/cp/call.c
@@ -148,18 +148,19 @@ static int equal_functions (tree, tree);
 static int joust (struct z_candidate *, struct z_candidate *, bool,
  tsubst_flags_t);
 static int compare_ics (conversion *, conversion *);
-static tree build_over_call (struct z_candidate *, int, tsubst_flags_t);
+static tree build_over_call (location_t, veclocation_t,
+struct z_candidate *, int, tsubst_flags_t);
 static tree build_java_interface_fn_ref (tree, tree);
-#define convert_like(CONV, EXPR, COMPLAIN) \
-  convert_like_real ((CONV), (EXPR), NULL_TREE, 0, 0,  \
-/*issue_conversion_warnings=*/true,\
-/*c_cast_p=*/false, (COMPLAIN))
-#define convert_like_with_context(CONV, 

Re: [PATCH][AArch64] Improve TARGET_LEGITIMIZE_ADDRESS_P hook

2014-08-01 Thread Jiong Wang

Hi Venkataramanan,

thanks for review.

On 01/08/14 11:59, Venkataramanan Kumar wrote:

Hi Jiong,

(Snip)
+   (op0 == virtual_stack_vars_rtx
+  || op0 == frame_pointer_rtx
+  || op0 == arg_pointer_rtx)
(Snip)

The above check is means that these are the ways to access the frame.
is it possible to have stack_pointer_rtx has op0?


I think there is no necessary to add stack_pointer_rtx check here.

because normally all local variables will be addressed using 
virtual_stack_vars_rtx,
and then rebased to frame_pointer_rtx in instantiate_new_reg, and finally 
eliminated
to fp/sp during reload depending on whether frame pointer is needed. so

+   (op0 == virtual_stack_vars_rtx
+  || op0 == frame_pointer_rtx

could actually catch almost all we want.

-- Jiong




On 1 August 2014 14:01, Jiong Wang jiong.w...@arm.com wrote:

currently, aarch64 LEGITIMIZE_ADDRESS_P hook will reject all reg + offset
address given
offset is beyond supported range.

while this may be too strict. we should honor the strict_p parameter in
the hook. before
reload, we accept all offset if it's a frame access, because the offset may
change during
later register elimination.

the early reject of reg + offset may cause extra registers created, and if
that register
live range is across function invoking then callee saved reg needed, thus
introduce extra
reg save/restore also.

give a simple example as:

int
test15 (void)
{
   unsigned char a[480];
   initialize_array (a, 480);

   if (a[0] == 0x10)
 return 1;

   return 0;
}

.S before the patch
(-O2 -fPIC)
===
test15:
 sub sp, sp, #480
 mov w1, 480
 stp x29, x30, [sp, -32]!
 add x29, sp, 0
 str x19, [sp, 16]
 add x19, x29, 32
 mov x0, x19
 bl  initialize_array
 ldrbw0, [x19]
 ldr x19, [sp, 16]
 ldp x29, x30, [sp], 32
 cmp w0, 16
 csetw0, eq
 add sp, sp, 480
 ret

.S after the patch
===
test15:
 stp x29, x30, [sp, -496]!
 mov w1, 480
 add x29, sp, 0
 add x0, x29, 16
 bl  initialize_array
 ldrbw0, [x29, 16]
 ldp x29, x30, [sp], 496
 cmp w0, 16
 csetw0, eq
 ret

test done
=
no regression on aarch64-none-elf bare metal.
bootstrap OK on aarch64.

OK for trunk?

thanks.

gcc/
   * config/aarch64/aarch64.c (aarch64_classify_address): Accept all offset
for frame access
   when strict_p is false.

gcc/testsuite
   * gcc.target/aarch64/legitimize_stack_var_before_reload_1.c: New testcase.





Re: [PATCH][AArch64] Improve TARGET_LEGITIMIZE_ADDRESS_P hook

2014-08-01 Thread Marcus Shawcroft
On 1 August 2014 09:31, Jiong Wang jiong.w...@arm.com wrote:

 gcc/
   * config/aarch64/aarch64.c (aarch64_classify_address): Accept all offset
 for frame access
   when strict_p is false.


This part is OK.

 gcc/testsuite
   * gcc.target/aarch64/legitimize_stack_var_before_reload_1.c: New testcase.

This test case relies on:
+/* { dg-final { scan-rtl-dump mem/j/c:QI \\(plus:DI expand } } */
... which is not very specific.  Can we tighten this up to look for
something directly related to the relevant frame access?

/Marcus


[PATCH] Fix PR61762 testcase

2014-08-01 Thread Richard Biener

After trying to fix the missed optimization on strict-align targets
in a fancy way for some time I gave up and this fixes the testcase
instead.

Tested on a sparc cross and on x86_64-unknown-linux-gnu, applied.

Richard.

2014-08-01  Richard Biener  rguent...@suse.de

PR middle-end/61762
* gcc.dg/pr61762.c: Align the string to make the testcase work
on strict-align targets.

Index: gcc/testsuite/gcc.dg/pr61762.c
===
--- gcc/testsuite/gcc.dg/pr61762.c  (revision 213342)
+++ gcc/testsuite/gcc.dg/pr61762.c  (working copy)
@@ -3,7 +3,7 @@
 
 unsigned int f()
 {
-  static const char string[] = Private;
+  static const char string[] __attribute__((aligned(sizeof(int = Private;
 
   unsigned int priv;
   __builtin_memcpy(priv, string[0], sizeof(priv));


[PATCH] Move memory builtin foldings to GIMPLE

2014-08-01 Thread Richard Biener

The following patch removes folding of bzero, memset, bcopy,
memcpy, mempcpy and memmove from builtins.c and re-implements
them in gimple-fold.c.  This means those foldings are no longer
accessible from GENERIC folding.

Bootstrapped on x86_64-unknown-linux-gnu - testing seems to reveal
some testsuite fallout I still have to look into.

Does this look sensible?  In particular, does any Frontend maintainer
object to no longer getting these simplifications?  Note they
will still apply during gimplification and given they now work
on GENERIC we can simplify them quite a bit (but as followup).

Thanks,
Richard.

2014-08-01  Richard Biener  rguent...@suse.de

* builtins.c (fold_builtin_memory_op, var_decl_component_p,
fold_builtin_memset): Move to gimple-fold.c.
(fold_builtin_2): Remove handling of bzero, memset, bcopy,
memcpy, mempcpy and memmove.
* gimple-fold.h (gimple_fold_builtin): Adjust signature.
* gimple-fold.c: Include output.h.
(readonly_data_expr): New function copied from builtins.c.
(var_decl_component_p): Moved from builtins.c.
(gimple_fold_builtin_memory_op): Moved from builtins.c
fold_builtin_memory_op and rewritten to GIMPLE.
(gimple_fold_builtin_memset): Likewise.
(gimple_fold_builtin_1): Split out from gimple_fold_builtin.
(gimple_fold_builtin): Change signature and handle
bzero, memset, bcopy, memcpy, mempcpy and memmove folding
here.
(gimple_fold_call): Adjust.
* tree-ssa-ccp.c (pass_fold_builtins::execute): Adjust
for gimple_fold_builtin change.

Index: gcc/builtins.c
===
*** gcc/builtins.c.orig 2014-07-31 15:10:04.127659292 +0200
--- gcc/builtins.c  2014-08-01 13:59:34.686001948 +0200
*** static tree fold_builtin_ceil (location_
*** 164,170 
  static tree fold_builtin_round (location_t, tree, tree);
  static tree fold_builtin_int_roundingfn (location_t, tree, tree);
  static tree fold_builtin_bitop (tree, tree);
- static tree fold_builtin_memory_op (location_t, tree, tree, tree, tree, bool, 
int);
  static tree fold_builtin_strchr (location_t, tree, tree, tree);
  static tree fold_builtin_memchr (location_t, tree, tree, tree, tree);
  static tree fold_builtin_memcmp (location_t, tree, tree, tree);
--- 164,169 
*** fold_builtin_exponent (location_t loc, t
*** 8496,8961 
return NULL_TREE;
  }
  
- /* Return true if VAR is a VAR_DECL or a component thereof.  */
- 
- static bool
- var_decl_component_p (tree var)
- {
-   tree inner = var;
-   while (handled_component_p (inner))
- inner = TREE_OPERAND (inner, 0);
-   return SSA_VAR_P (inner);
- }
- 
- /* Fold function call to builtin memset.  Return
-NULL_TREE if no simplification can be made.  */
- 
- static tree
- fold_builtin_memset (location_t loc, tree dest, tree c, tree len,
-tree type, bool ignore)
- {
-   tree var, ret, etype;
-   unsigned HOST_WIDE_INT length, cval;
- 
-   if (! validate_arg (dest, POINTER_TYPE)
-   || ! validate_arg (c, INTEGER_TYPE)
-   || ! validate_arg (len, INTEGER_TYPE))
- return NULL_TREE;
- 
-   if (! tree_fits_uhwi_p (len))
- return NULL_TREE;
- 
-   /* If the LEN parameter is zero, return DEST.  */
-   if (integer_zerop (len))
- return omit_one_operand_loc (loc, type, dest, c);
- 
-   if (TREE_CODE (c) != INTEGER_CST || TREE_SIDE_EFFECTS (dest))
- return NULL_TREE;
- 
-   var = dest;
-   STRIP_NOPS (var);
-   if (TREE_CODE (var) != ADDR_EXPR)
- return NULL_TREE;
- 
-   var = TREE_OPERAND (var, 0);
-   if (TREE_THIS_VOLATILE (var))
- return NULL_TREE;
- 
-   etype = TREE_TYPE (var);
-   if (TREE_CODE (etype) == ARRAY_TYPE)
- etype = TREE_TYPE (etype);
- 
-   if (!INTEGRAL_TYPE_P (etype)
-!POINTER_TYPE_P (etype))
- return NULL_TREE;
- 
-   if (! var_decl_component_p (var))
- return NULL_TREE;
- 
-   length = tree_to_uhwi (len);
-   if (GET_MODE_SIZE (TYPE_MODE (etype)) != length
-   || get_pointer_alignment (dest) / BITS_PER_UNIT  length)
- return NULL_TREE;
- 
-   if (length  HOST_BITS_PER_WIDE_INT / BITS_PER_UNIT)
- return NULL_TREE;
- 
-   if (integer_zerop (c))
- cval = 0;
-   else
- {
-   if (CHAR_BIT != 8 || BITS_PER_UNIT != 8 || HOST_BITS_PER_WIDE_INT  64)
-   return NULL_TREE;
- 
-   cval = TREE_INT_CST_LOW (c);
-   cval = 0xff;
-   cval |= cval  8;
-   cval |= cval  16;
-   cval |= (cval  31)  1;
- }
- 
-   ret = build_int_cst_type (etype, cval);
-   var = build_fold_indirect_ref_loc (loc,
-fold_convert_loc (loc,
-  build_pointer_type (etype),
-  dest));
-   ret = build2 (MODIFY_EXPR, etype, var, ret);
-   if (ignore)
- return ret;
- 
-   return omit_one_operand_loc (loc, type, dest, ret);
- }

Re: [PATCH, libfortran] Backport xmallocarray to 4.8/4.9 (CVE-2014-5044)

2014-08-01 Thread Jakub Jelinek
On Thu, Jul 31, 2014 at 11:32:12PM +0300, Janne Blomqvist wrote:
 a while ago I committed a patch to trunk adding a function
 xmallocarray to libgfortran, which is a malloc wrapper like xmalloc
 but has two arguments and does an overflow check before multiplying
 them together.

That seems to be unnecessarily expensive for the common case where both
nmemb and size are small.

calloc in glibc uses something like following to avoid the division most of
the time, if both nmemb and size are small enough then nmemb * size can't
overflow.  At least for 64-bit architectures small is smaller than 4GB
for both numbers.

2014-08-01  Jakub Jelinek  ja...@redhat.com

* runtime/memory.c (xmallocarray): Avoid division for the common case.

--- libgfortran/runtime/memory.c.jj 2014-06-18 08:50:33.0 +0200
+++ libgfortran/runtime/memory.c2014-08-01 14:41:08.385856116 +0200
@@ -56,7 +56,9 @@ xmallocarray (size_t nmemb, size_t size)
 
   if (!nmemb || !size)
 size = nmemb = 1;
-  else if (nmemb  SIZE_MAX / size)
+#define HALF_SIZE_T (((size_t) 1)  (__CHAR_BIT__ * sizeof (size_t) / 2))
+  else if (__builtin_expect ((nmemb | size) = HALF_SIZE_T, 0)
+   nmemb  SIZE_MAX / size)
 {
   errno = ENOMEM;
   os_error (Integer overflow in xmallocarray);


Jakub


Re: [PATCH][AArch64] Improve TARGET_LEGITIMIZE_ADDRESS_P hook

2014-08-01 Thread Jiong Wang


On 01/08/14 13:20, Marcus Shawcroft wrote:

On 1 August 2014 09:31, Jiong Wang jiong.w...@arm.com wrote:


gcc/
   * config/aarch64/aarch64.c (aarch64_classify_address): Accept all offset
for frame access
   when strict_p is false.


This part is OK.


gcc/testsuite
   * gcc.target/aarch64/legitimize_stack_var_before_reload_1.c: New testcase.

This test case relies on:
+/* { dg-final { scan-rtl-dump mem/j/c:QI \\(plus:DI expand } } */
... which is not very specific.  Can we tighten this up to look for
something directly related to the relevant frame access?


Hmm... thanks for pointing this out.


updated the patch to match three keyword. mem, plus and virtual-stack-vars

ok for trunk?

thanks.

-- Jiong

gcc/
   * config/aarch64/aarch64.c (aarch64_classify_address): Accept all offset for 
frame access
   when strict_p is false.

gcc/testsuite
   * gcc.target/aarch64/legitimize_stack_var_before_reload_1.c: New testcase.
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index ed80269..c8e5808 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -3248,6 +3248,21 @@ aarch64_classify_address (struct aarch64_address_info *info,
 case PLUS:
   op0 = XEXP (x, 0);
   op1 = XEXP (x, 1);
+
+  if (! strict_p
+	   GET_CODE (op0) == REG
+	   (op0 == virtual_stack_vars_rtx
+	  || op0 == frame_pointer_rtx
+	  || op0 == arg_pointer_rtx)
+	   GET_CODE (op1) == CONST_INT)
+	{
+	  info-type = ADDRESS_REG_IMM;
+	  info-base = op0;
+	  info-offset = op1;
+
+	  return true;
+	}
+
   if (GET_MODE_SIZE (mode) != 0
 	   CONST_INT_P (op1)
 	   aarch64_base_register_rtx_p (op0, strict_p))
diff --git a/gcc/testsuite/gcc.target/aarch64/legitimize_stack_var_before_reload_1.c b/gcc/testsuite/gcc.target/aarch64/legitimize_stack_var_before_reload_1.c
new file mode 100644
index 000..e5f0bd1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/legitimize_stack_var_before_reload_1.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options -O2 -fdump-rtl-expand } */
+
+extern void initialize_array (unsigned char *, int);
+
+int
+test15 (void)
+{
+  unsigned char a[480];
+
+  initialize_array (a, 480);
+
+  if (a[0] == 0x10)
+return 1;
+
+  return 0;
+}
+
+/* { dg-final { scan-rtl-dump \\(mem\[^\\n\]*\\(plus\[^\\n\]*virtual-stack-vars expand } } */
+
+/* { dg-final { cleanup-rtl-dump expand } } */

[Ada] Don't unconditionally define _LARGEFILE_SOURCE

2014-08-01 Thread Rainer Orth
This patch

2014-08-01  Pascal Obry  o...@adacore.com

* cstreams.c: Only enable large file support on know supported
platforms. Add missing defines/includes.

broke Ada bootstrap on Solaris:

/vol/gcc/src/hg/trunk/local/gcc/ada/cstreams.c:34:0: error: _LARGEFILE_SOURCE 
redefined [-Werror]
 #define _LARGEFILE_SOURCE
 ^
built-in: note: this is the location of the previous definition

Fixed as follows, i386-pc-solaris2.10 bootstrap is past the failure now.

Ok for mainline?

Rainer


2014-08-01  Rainer Orth  r...@cebitec.uni-bielefeld.de

gcc/ada:
* cstreams.c (_LARGEFILE_SOURCE): Guard definition.

diff --git a/gcc/ada/cstreams.c b/gcc/ada/cstreams.c
--- a/gcc/ada/cstreams.c
+++ b/gcc/ada/cstreams.c
@@ -31,7 +31,9 @@
 
 /* Routines required for implementing routines in Interfaces.C.Streams.  */
 
+#ifndef _LARGEFILE_SOURCE
 #define _LARGEFILE_SOURCE
+#endif
 #define _FILE_OFFSET_BITS 64
 /* the define above will make off_t a 64bit type on GNU/Linux */
 

-- 
-
Rainer Orth, Center for Biotechnology, Bielefeld University


Re: [Ada] Don't unconditionally define _LARGEFILE_SOURCE

2014-08-01 Thread Arnaud Charlet
 2014-08-01  Pascal Obry  o...@adacore.com
 
 * cstreams.c: Only enable large file support on know supported
 platforms. Add missing defines/includes.
 
 broke Ada bootstrap on Solaris:
 
 /vol/gcc/src/hg/trunk/local/gcc/ada/cstreams.c:34:0: error:
 _LARGEFILE_SOURCE redefined [-Werror]
  #define _LARGEFILE_SOURCE
  ^
 built-in: note: this is the location of the previous definition
 
 Fixed as follows, i386-pc-solaris2.10 bootstrap is past the failure now.
 
 Ok for mainline?

Yes, thanks.


Re: [PATCH][AArch64]Fix offset glitch in load reg pair pattern

2014-08-01 Thread Marcus Shawcroft
On 29 July 2014 16:25, Jiong Wang jiong.w...@arm.com wrote:

 gcc/
   * config/aarch64/aarch64.md (loadwb_pairGPI:mode_P:mode): Fix offset.
   (loadwb_pairGPI:mode_P:mode): Likewise.
   * config/aarch64/aarch64.c (aarch64_gen_loadwb_pair): Likewise.

OK
/Marcus


Re: [PATCH][AArch64] Add constrain to address offset in storewb_pair/loadwb_pair insns

2014-08-01 Thread Marcus Shawcroft
On 29 July 2014 16:31, Jiong Wang jiong.w...@arm.com wrote:

 gcc/
 * config/aarch64/aarch64.c (offset_7bit_signed_scaled_p): Rename to
   aarch64_offset_7bit_signed_scaled_p, remove static and use it .
   * config/aarch64/aarch64-protos.h (aarch64_offset_7bit_signed_scaled_p):
 Declaration.
   * config/aarch64/predicates.md (aarch64_mem_pair_offset): Define new
 predicate.
   * config/aarch64/aarch64.md (loadwb_pair, storewb_pair): Use
 aarch64_mem_pair_offset.


OK
/Marcus


Re: [PATCH][AArch64] Improve TARGET_LEGITIMIZE_ADDRESS_P hook

2014-08-01 Thread Marcus Shawcroft
On 1 August 2014 13:49, Jiong Wang jiong.w...@arm.com wrote:



 Hmm... thanks for pointing this out.


 updated the patch to match three keyword. mem, plus and
 virtual-stack-vars

 ok for trunk?

OK /Marcus


[Ada] Give missing entity messages in -gnatc mode

2014-08-01 Thread Arnaud Charlet
This patch forces expansion on (but not actual code generation) for
configurable run time mode or no run time mode in -gnatc mode. This
means that we get error messages about unsupported features even in
-gnatc mode, which was not true before. The following is compiled
in -gnatc mode with a gnat.adc file containing pragma No_Run_Time:

 1. function CRT_GNATC (X : Integer) return Integer is
 2. begin
 3.return X ** X;
|
 construct not allowed in no run time mode
 entity System.Exp_Int.Exp_Integer not defined

 4. end;

prior to this patch, no message was given in -gnatc mode. A debug
flag -gnatd.Z can be used to disable this behavior in case we run
into any trouble from doing the expansion in the future.

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

2014-08-01  Robert Dewar  de...@adacore.com

* debug.adb: Document debug switch -gnatd.Z.
* sem.adb (Semantics): Force expansion on in no or configurable
run time mode.

Index: debug.adb
===
--- debug.adb   (revision 213453)
+++ debug.adb   (working copy)
@@ -143,7 +143,7 @@
--  d.W  Print out debugging information for Walk_Library_Items
--  d.X  Old treatment of indexing aspects
--  d.Y
-   --  d.Z
+   --  d.Z  Do not enable expansion in configurable run-time mode
 
--  d1   Error msgs have node numbers where possible
--  d2   Eliminate error flags in verbose form error messages
@@ -686,6 +686,12 @@
--   is preserved temporarily for use by the modelling project under
--   debug flag d.X.
 
+   --  d.Z  Normally we always enable expansion in configurable run-time mode
+   --   to make sure we get error messages about unsupported features even
+   --   when compiling in -gnatc mode. But expansion is turned off in this
+   --   case if debug flag -gnatd.Z is used. This is to deal with the case
+   --   where we discover difficulties in this new processing.
+
--  d1   Error messages have node numbers where possible. Normally error
--   messages have only source locations. This option is useful when
--   debugging errors caused by expanded code, where the source location
Index: sem.adb
===
--- sem.adb (revision 213437)
+++ sem.adb (working copy)
@@ -1410,11 +1410,33 @@
  GNAT_Mode := True;
   end if;
 
+  --  For generic main, never do expansion
+
   if Generic_Main then
  Expander_Mode_Save_And_Set (False);
+
+  --  Non generic case
+
   else
  Expander_Mode_Save_And_Set
-   (Operating_Mode = Generate_Code or Debug_Flag_X);
+
+   --  Turn on expansion if generating code
+
+   (Operating_Mode = Generate_Code
+
+ --  or if special debug flag -gnatdx is set
+
+ or else Debug_Flag_X
+
+ --  Or if in configuration run-time mode. We do this so we get
+ --  error messages about missing entities in the run-time even
+ --  if we are compiling in -gnatc (no code generation) mode.
+ --  Similar processing applies to No_Run_Time_Mode. However,
+ --  don't do this if debug flag -gnatd.Z is set (this is to handle
+ --  a situation where this new processing causes trouble).
+
+ or else ((Configurable_Run_Time_Mode or No_Run_Time_Mode)
+   and not Debug_Flag_Dot_ZZ));
   end if;
 
   Full_Analysis  := True;


[Ada] Improved handling of info messages

2014-08-01 Thread Arnaud Charlet
The count of info messages is now separated from the count of warnings
and -gnatwe never turns info messages into errors. The following
compiles as shown, and generates object code since no error is found
when compilation options -gnatwe -gnatld7 -gnatj55 are used.

Compiling: infoerr.adb

 1. with Text_IO; use Text_IO;
 2. procedure InfoErr is
 3.J : Natural;
 4. begin
 5.J := 1;
 6.ENTER
   |
 info: code between label and backwards
goto rewritten as loop

 7.Put_Line (J'Img);
 8.J := J + 1;
 9.if J  3 then
10.   goto DONE;
11.end if;
12.goto ENTER;
13.DONE
14.null;
15. end;

 15 lines: No errors, 1 info message

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

2014-08-01  Robert Dewar  de...@adacore.com

* atree.ads (Info_Messages): New counter.
* err_vars.ads: Minor comment update.
* errout.adb (Delete_Warning_And_Continuations): Deal
with new Info_Messages counter.
(Error_Msg_Internal): ditto.
(Delete_Warning): ditto.
(Initialize): ditto.
(Write_Error_Summary): ditto.
(Output_Messages): ditto.
(To_Be_Removed): ditto.
* erroutc.adb (Delete_Msg): Deal with Info_Messages counter.
(Compilation_Errors): ditto.
* errutil.adb (Error_Msg): Deal with Info_Messages counter.
(Finalize): ditto.
(Initialize): ditto.
* sem_prag.adb (Analyze_Pragma): Minor comment addition.
* gnat_ugn.texi: Document that -gnatwe does not affect info
messages.

Index: atree.ads
===
--- atree.ads   (revision 213263)
+++ atree.ads   (working copy)
@@ -313,8 +313,13 @@
 
Warnings_Detected : Nat := 0;
--  Number of warnings detected. Initialized to zero at the start of
-   --  compilation. Initialized for -gnatVa use, see comment above.
+   --  compilation. Initialized for -gnatVa use, see comment above. This
+   --  count includes the count of style and info messages.
 
+   Info_Messages : Nat := 0;
+   --  Number of info messages generated. Info messages are neved treated as
+   --  errors (whether from use of the pragma, or the compiler switch -gnatwe).
+
Warnings_Treated_As_Errors : Nat := 0;
--  Number of warnings changed into errors as a result of matching a pattern
--  given in a Warning_As_Error configuration pragma.
Index: err_vars.ads
===
--- err_vars.ads(revision 213431)
+++ err_vars.ads(working copy)
@@ -39,10 +39,10 @@
--  from invalid values in such cases.
 
--  Note on error counts (Serious_Errors_Detected, Total_Errors_Detected,
-   --  Warnings_Detected). These counts might more logically appear in this
-   --  unit, but we place them in atree.ads, because of licensing issues. We
-   --  need to be able to access these counts from units that have the more
-   --  general licensing conditions.
+   --  Warnings_Detected, Info_Messages). These counts might more logically
+   --  appear in this unit, but we place them instead in atree.ads, because of
+   --  licensing issues. We need to be able to access these counts from units
+   --  that have the more general licensing conditions.
 
--
-- Error Message Mode Variables --
Index: errout.adb
===
--- errout.adb  (revision 213369)
+++ errout.adb  (working copy)
@@ -261,8 +261,12 @@
M.Deleted := True;
Warnings_Detected := Warnings_Detected - 1;
 
+   if M.Info then
+  Info_Messages := Info_Messages - 1;
+   end if;
+
if M.Warn_Err then
-  Warnings_Treated_As_Errors := Warnings_Treated_As_Errors + 1;
+  Warnings_Treated_As_Errors := Warnings_Treated_As_Errors - 1;
end if;
 end if;
 
@@ -1132,6 +1136,10 @@
   if Errors.Table (Cur_Msg).Warn or else Errors.Table (Cur_Msg).Style then
  Warnings_Detected := Warnings_Detected + 1;
 
+ if Errors.Table (Cur_Msg).Info then
+Info_Messages := Info_Messages + 1;
+ end if;
+
   else
  Total_Errors_Detected := Total_Errors_Detected + 1;
 
@@ -1340,8 +1348,12 @@
 Errors.Table (E).Deleted := True;
 Warnings_Detected := Warnings_Detected - 1;
 
+if Errors.Table (E).Info then
+   Info_Messages := Info_Messages - 1;
+end if;
+
 if Errors.Table (E).Warn_Err then
-   Warnings_Treated_As_Errors := Warnings_Treated_As_Errors + 1;
+   Warnings_Treated_As_Errors := Warnings_Treated_As_Errors - 1;
 end if;
  end if;
   end Delete_Warning;
@@ -1566,6 +1578,7 @@
   Total_Errors_Detected := 0;

[Ada] Parameterless calls to protected operations on selected components.

2014-08-01 Thread Arnaud Charlet
A multi-level selected component can designate a call to a parameterless
protected operation whose target object is itself given by a selected component.
When the node is rewritten as a function call, it is necessary to preserve the
tree structure of the name, so that overload information and subsequent action
insertions work properly.

THe following must compile quietly:

gcc -c ia-ib-ic-d.adb

---
WITH Ada.Unchecked_Deallocation;

PACKAGE BODY ia.ib.ic.d IS

   -- 
   -- Protected declaration
   -- 

   PROTECTED TYPE network_state_controller IS
  PROCEDURE set_send_success (success : IN Boolean);
  PROCEDURE set_receive_success (success : IN Boolean);
  PROCEDURE set_connected;
  PROCEDURE set_disconnected;
  PROCEDURE set_open_connection;
  PROCEDURE set_close_connection;
  FUNCTION is_connected RETURN Boolean;
  FUNCTION is_opened RETURN Boolean;
  ENTRY wait_disconnected;
  ENTRY wait_connected;
   PRIVATE
  connected   : Boolean := False;
  open_connection : Boolean := False;

  send_success: Boolean := True;
  receive_success : Boolean := True;
   END network_state_controller;

   TYPE internals IS RECORD
  -- object management
  -- -
  is_initialized : Boolean := False;

  -- Network
  -- ---

  network_state : network_state_controller;

  -- values that may be sent to the gun
  -- --

  -- values reported back by the gun
  -- ---

  -- raw telegram buffers
  -- 

  -- comms house keeping and control
  -- ---

  -- fire zone comms
  -- ---
  fire_zone_request_timeout: Natural := 0; -- 10 ms cycle count
  fire_zone_request_started_at : Natural := 0;-- 10 ms cycle count

  -- Trace
  -- -
  use_tracer_position_entry : Boolean := False;

  tracer_dusc   : Boolean := False;
  tracer_dusc_overwrite : Boolean := False;
  tracer_zoom_overwrite : Boolean := False;

  print_counter : Positive := 1; -- for debugging information

  call_counter : Natural := 0;
  tick_cycle   : Natural := 0;

  proceed_counter : Natural   := 0; -- for test purpose
  self: reference := NULL;

  trace_alarm : Boolean := False;
  trace_fire  : Boolean := False;

   END RECORD;

   FUNCTION create RETURN reference IS
  ref : reference := NEW object;

   BEGIN
  ref.hidden  := NEW internals;
  ref.hidden.self := ref;
  RETURN ref;
   EXCEPTION
  WHEN error : OTHERS =
 RETURN NULL;
   END create;

   PROCEDURE initialize (obj : IN OUT object; success : OUT Boolean) IS
   BEGIN
  IF NOT obj.hidden.is_initialized THEN
 obj.hidden.is_initialized := True;
 success := True;
  END IF;
   EXCEPTION
  WHEN error : OTHERS =
 success := False;
   END initialize;

   -- 

   PROCEDURE free IS NEW Ada.Unchecked_Deallocation (object'class, reference);
   PROCEDURE free IS NEW Ada.Unchecked_Deallocation
 (internals,
  access_internals);

   -- 

   PROCEDURE finalize (obj : IN OUT reference) IS
   BEGIN
  IF obj /= NULL THEN
 IF obj.hidden /= NULL THEN
free (obj.hidden);
 END IF;
 free (obj);
  END IF;

   EXCEPTION
  WHEN error : OTHERS =
 NULL;
   END finalize;

   FUNCTION is_connected (obj : IN object) RETURN Boolean IS
   BEGIN
  IF obj.hidden.network_state.is_opened
  AND THEN obj.hidden.network_state.is_connected THEN
 RETURN True;
  ELSE
 RETURN False;
  END IF;
   EXCEPTION
  WHEN error : OTHERS =
 RETURN False;
   END is_connected;

   max_before_reconnect : CONSTANT Positive := 100;

   PROTECTED BODY network_state_controller IS

  PROCEDURE set_send_success (success : IN Boolean) IS
  BEGIN
 send_success := success;
  END set_send_success;

  PROCEDURE set_receive_success (success : IN Boolean) IS
  BEGIN
 receive_success := success;
  END set_receive_success;

  PROCEDURE set_connected IS
  BEGIN
 connected := True;
  END set_connected;

  PROCEDURE set_disconnected IS
  BEGIN
 connected := False;
  END set_disconnected;

  FUNCTION is_connected RETURN Boolean IS
  BEGIN
 RETURN open_connection AND THEN connected;
  END is_connected;

  FUNCTION is_opened RETURN Boolean IS
  BEGIN
 RETURN open_connection;
  END is_opened;

  PROCEDURE set_close_connection IS
  BEGIN
 connected   := 

[PATCH] Add target macro to override DWARF2 frame register size

2014-08-01 Thread Matthew Fortune
This patch adds a target macro to allow a backend to override the size
of a dwarf frame register.  This is already supported to some extent
by allowing the HARD_REGNO_CALL_PART_CLOBBERED to reduce the size of
a specific register to only that which is saved.  However, for the
new MIPS O32 FP64 ABI extension I need more control.

The standard MIPS O32 ABI has 32-bit floating point-registers which
are saved as pairs to form 64-bit values.  The FP64 extension widens
all floating-point registers to 64-bit but only saves the even numbered
registers thus not increasing the callee-saved state.  In order to
support interlinking between the standard O32 ABI and the extension I
must keep the layout of the frame information the same.  The dwarf
frame registers are therefore re-interpreted to refer to the low and
high parts of even numbered 64-bit registers rather than 32 32-bit
registers.  To achieve this I must artificially reduce the size of the
frame registers for the widened 64-bit registers down to 32-bit but
cannot use the HARD_REGNO_CALL_PART_CLOBBERED macro to achieve this.

Thanks,
Matthew

gcc/
* dwarf2cfi (DWARF_REG_MODE): Define with default implementation.
(expand_builtin_init_dwarf_reg_sizes): Use DWARF_REG_MODE.
* doc/tm.texi.in (DWARF_REG_MODE): Document.
* doc/tm.texi: Regenerate.
---
 gcc/doc/tm.texi.in | 9 +
 gcc/dwarf2cfi.c| 5 +
 2 files changed, 14 insertions(+)

diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index dd72b98..71799f7 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -2809,6 +2809,12 @@ in DWARF 2 debug information.  The default is zero.  A 
different value
 may reduce the size of debug information on some ports.
 @end defmac
 
+@defmac DWARF_REG_MODE (@var{N}, @var{mode})
+If defined, a C expression whose value is a mode that should be used
+to represent the @var{N}th DWARF frame register.  By default this is
+the same @var{mode} as the hard register it relates to.
+@end defmac
+
 @node Exception Handling
 @subsection Exception Handling Support
 @cindex exception handling
diff --git a/gcc/dwarf2cfi.c b/gcc/dwarf2cfi.c
index 85cfb60..163db5d 100644
--- a/gcc/dwarf2cfi.c
+++ b/gcc/dwarf2cfi.c
@@ -252,6 +252,10 @@ init_return_column_size (enum machine_mode mode, rtx mem, 
unsigned int c)
  gen_int_mode (size, mode));
 }
 
+#ifndef DWARF_REG_MODE
+#define DWARF_REG_MODE(REGNO, MODE) (MODE)
+#endif
+
 /* Generate code to initialize the register size table.  */
 
 void
@@ -276,6 +280,7 @@ expand_builtin_init_dwarf_reg_sizes (tree address)
 
  if (HARD_REGNO_CALL_PART_CLOBBERED (i, save_mode))
save_mode = choose_hard_reg_mode (i, 1, true);
+ save_mode = DWARF_REG_MODE (i, save_mode);
  if (dnum == DWARF_FRAME_RETURN_COLUMN)
{
  if (save_mode == VOIDmode)
-- 
1.9.4



[Ada] Crash on entry call with preconditions and access parameters

2014-08-01 Thread Arnaud Charlet
When an entry has preconditions, the entry call is wrapped in a procedure call
that incorporates the precondition checks. To prevent a double expansion, with
possible duplication of extra formals, that procedure call must only be pre-
nalyzed and resolved. Expansion takes place upon return to the caller
Resolve_Call.

No short example available.

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

2014-08-01  Ed Schonberg  schonb...@adacore.com

* sem_res.adb (Resolve_Entry_Call): When an entry has
preconditions, the entry call is wrapped in a procedure call
that incorporates the precondition checks. To prevent a double
expansion, with possible duplication of extra formals, that
procedure call must only be pre-analyzed and resolved. Expansion
takes place upon return to the caller Resolve_Call.

Index: sem_res.adb
===
--- sem_res.adb (revision 213460)
+++ sem_res.adb (working copy)
@@ -7176,7 +7176,11 @@
   New_Occurrence_Of (PPC_Wrapper (Nam), Loc),
 Parameter_Associations = New_Actuals);
 Rewrite (N, New_Call);
-Analyze_And_Resolve (N);
+
+--  Preanalyze and resolve new call. Current procedure is called
+--  from Resolve_Call, after which expansion will take place.
+
+Preanalyze_And_Resolve (N);
 return;
  end;
   end if;


[Ada] Access types that designate limited views of types with tasks.

2014-08-01 Thread Arnaud Charlet
This patch fixes the handling of access types whose designated types are
limited views of untagged types with tasks.

executing the following:

   gnatmake -q main.adb
   main

must yield:

   Task started
   Task started

---
with Package_Common; use Package_Common;
with Package_A; use Package_A;

procedure Main is
  pClassA : Class_A_Ptr := new Class_A;
  aClassA : access Class_A := new Class_A;
  pTypeA  : Type_A_Ptr := new Type_A;
  aTypeA  : access Type_A := new Type_A;
  pTaskA  : Task_A_Ptr := new Task_A;
  aTaskA  : access Task_A := new Task_A;
begin
  -- OK
  pClassA.Start;
  pClassA.Start;
  Start (pTypeA);
  Start (aTypeA);

  pTaskA.Start;

  aTaskA.Start;
end Main;
---
package Package_A is
  type Class_A is tagged null record;

  procedure Start (self : in out Class_A) is null;

  type Type_A is null record;

  procedure Start (obj : access Type_A) is null;

  task type Task_A is
entry Start;
  end Task_A;
end Package_A;
---
limited with Package_A;
package Package_Common is

  type Class_A_Ptr is access all Package_A.Class_A;

  type Type_A_Ptr is access all Package_A.Type_A;

  type Task_A_Ptr is access all Package_A.Task_A;

end Package_Common;
---
with text_IO; use text_IO;
package body Package_A is

  task body Task_A is
  begin
accept Start do
  Put_Line (Task started);
end;
  end Task_A;
end Package_A;

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

2014-08-01  Ed Schonberg  schonb...@adacore.com

* sem_ch3.adb (Access_Type_Declaration): If designated type is
a limited view, create a master entity (as is already done for
class-wide types) in case the full view designates a type that
contains tasks.
* sem_ch8.adb (Find_Selected_Component): If prefix is a dereference
and the designated type is a limited view, use the non-limited
view if available.

Index: sem_ch3.adb
===
--- sem_ch3.adb (revision 213451)
+++ sem_ch3.adb (working copy)
@@ -1331,9 +1331,23 @@
 
  if Ekind (Root_Type (Entity (S))) = E_Incomplete_Type then
 Set_Directly_Designated_Type (T, Entity (S));
+
+--  If the designated type is a limited view, we cannot tell if
+--  the full view contains tasks, and there is no way to handle
+--  that full view in a client. We create a master entity for the
+--  scope, which will be used when a client determines that one
+--  is needed.
+
+if From_Limited_With (Entity (S))
+  and then not Is_Class_Wide_Type (Entity (S))
+then
+   Set_Ekind (T, E_Access_Type);
+   Build_Master_Entity (T);
+   Build_Master_Renaming (T);
+end if;
+
  else
-Set_Directly_Designated_Type (T,
-  Process_Subtype (S, P, T, 'P'));
+Set_Directly_Designated_Type (T, Process_Subtype (S, P, T, 'P'));
  end if;
 
  --  If the access definition is of the form: ACCESS NOT NULL ..
Index: sem_ch8.adb
===
--- sem_ch8.adb (revision 213440)
+++ sem_ch8.adb (working copy)
@@ -6236,6 +6236,25 @@
 Write_Entity_Info (P_Type,   ); Write_Eol;
  end if;
 
+ --  The designated type may be a limited view with no components.
+ --  Check whether the non-limited view is available, because in some
+ --  cases this will not be set when instlling the context.
+
+ if Is_Access_Type (P_Type) then
+declare
+   D : constant Entity_Id := Directly_Designated_Type (P_Type);
+begin
+   if Is_Incomplete_Type (D)
+ and then not Is_Class_Wide_Type (D)
+ and then From_Limited_With (D)
+ and then Present (Non_Limited_View (D))
+ and then not Is_Class_Wide_Type (Non_Limited_View (D))
+   then
+  Set_Directly_Designated_Type (P_Type,  Non_Limited_View (D));
+   end if;
+end;
+ end if;
+
  --  First check for components of a record object (not the
  --  result of a call, which is handled below).
 


[Ada] Minor internal cleanup

2014-08-01 Thread Arnaud Charlet
Underlying_Type now recursively goes down the chain of private derivations,
including the Underlying_Full_View if any, so we call it instead of making
the descent manually in Build_Initialization_Call.  No functional changes.

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

2014-08-01  Eric Botcazou  ebotca...@adacore.com

* exp_ch3.adb (Build_Initialization_Call): Call Underlying_Type
to go down the chain of private derivations.
* freeze.adb (Freeze_Entity): Fix typo in comment.

Index: freeze.adb
===
--- freeze.adb  (revision 213463)
+++ freeze.adb  (working copy)
@@ -5034,7 +5034,7 @@
--  Otherwise freeze full view and patch the pointers so that
--  the freeze node will elaborate both views in the back end.
--  However, if full view is itself private, freeze underlying
-   --  full view instead and patch the pointer so that the freeze
+   --  full view instead and patch the pointers so that the freeze
--  node will elaborate the three views in the back end.
 
else
Index: exp_ch3.adb
===
--- exp_ch3.adb (revision 213439)
+++ exp_ch3.adb (working copy)
@@ -1491,15 +1491,21 @@
  return Empty_List;
   end if;
 
-  --  Go to full view if private type. In the case of successive
-  --  private derivations, this can require more than one step.
+  --  Go to full view or underlying full view if private type. In the case
+  --  of successive private derivations, this can require two steps.
 
-  while Is_Private_Type (Full_Type)
+  if Is_Private_Type (Full_Type)
 and then Present (Full_View (Full_Type))
-  loop
+  then
  Full_Type := Full_View (Full_Type);
-  end loop;
+  end if;
 
+  if Is_Private_Type (Full_Type)
+and then Present (Underlying_Full_View (Full_Type))
+  then
+ Full_Type := Underlying_Full_View (Full_Type);
+  end if;
+
   --  If Typ is derived, the procedure is the initialization procedure for
   --  the root type. Wrap the argument in an conversion to make it type
   --  honest. Actually it isn't quite type honest, because there can be
@@ -1583,12 +1589,6 @@
 begin
if Is_Protected_Type (T) then
   T := Corresponding_Record_Type (T);
-
-   elsif Is_Private_Type (T)
- and then Present (Underlying_Full_View (T))
- and then Is_Protected_Type (Underlying_Full_View (T))
-   then
-  T := Corresponding_Record_Type (Underlying_Full_View (T));
end if;
 
Arg :=


[Ada] Crash on generic instance with class-wide actual

2014-08-01 Thread Arnaud Charlet
This patch reimplements part of the support for AI05-0071 which deals with
generic/instance scenarios involving a formal type with unknown discriminants,
a generic primitive operation of the formal type declared with a box and an
actual class-wide type.


-- Source --


--  types.ads

package Types is
   type T1 is tagged null record;
   procedure Prim_Op (Param : T1);

   type T2 is tagged null record;
   procedure Prim_Op (Param : T2'Class);

   type T3 is tagged null record;
   procedure Prim_Op (Param : T3);
   procedure Prim_Op (Param : T3'Class);

   type T4 is tagged null record;
end Types;

--  gen.ads

generic
   type Formal_Typ () is private;
   with procedure Prim_Op (Param : Formal_Typ) is ;
package Gen is
end Gen;

--  instances.ads

with Gen;
with Types; use Types;

package Instances is
   package Inst1 is new Gen (T1'Class);  --  OK
   package Inst2 is new Gen (T2'Class);  --  OK
   package Inst3 is new Gen (T3'Class);  --  ERROR, two primitives visible
   package Inst4 is new Gen (T4'Class);  --  ERROR, no  primitives visible
end Instances;


-- Compilation and output --


$ gcc -c instances.ads
instances.ads:7:04: instantiation error at gen.ads:3
instances.ads:7:04: ambiguous actual for generic subprogram Prim_Op
instances.ads:7:04: possible interpretation: Prim_Op defined at types.ads:10
instances.ads:7:04: possible interpretation: Prim_Op defined at types.ads:9
instances.ads:8:04: instantiation error at gen.ads:3
instances.ads:8:04: no visible subprogram matches the specification for
  Prim_Op

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

2014-08-01  Hristian Kirtchev  kirtc...@adacore.com

* sem_ch8.adb (Analyze_Subprogram_Renaming): Alphabetize
globals and move certain variables to the local
variable section. Call Build_Class_Wide_Wrapper when
renaming a default actual subprogram with a class-wide actual.
(Build_Class_Wide_Wrapper): New routine.
(Check_Class_Wide_Actual): Removed.
(Find_Renamed_Entity): Code reformatting.
(Has_Class_Wide_Actual): Alphabetize. Change the
logic of the predicate as the renamed name may not necessarely
denote the correct subprogram.

Index: sem_ch8.adb
===
--- sem_ch8.adb (revision 213464)
+++ sem_ch8.adb (working copy)
@@ -1812,18 +1812,51 @@
-
 
procedure Analyze_Subprogram_Renaming (N : Node_Id) is
-  Formal_Spec : constant Node_Id := Corresponding_Formal_Spec (N);
-  Is_Actual   : constant Boolean := Present (Formal_Spec);
-  Inst_Node   : Node_Id   := Empty;
+  Formal_Spec : constant Entity_Id:= Corresponding_Formal_Spec (N);
+  Is_Actual   : constant Boolean  := Present (Formal_Spec);
   Nam : constant Node_Id  := Name (N);
-  New_S   : Entity_Id;
-  Old_S   : Entity_Id := Empty;
-  Rename_Spec : Entity_Id;
   Save_AV : constant Ada_Version_Type := Ada_Version;
   Save_AVP: constant Node_Id  := Ada_Version_Pragma;
   Save_AV_Exp : constant Ada_Version_Type := Ada_Version_Explicit;
   Spec: constant Node_Id  := Specification (N);
 
+  Old_S   : Entity_Id := Empty;
+  Rename_Spec : Entity_Id;
+
+  procedure Build_Class_Wide_Wrapper
+(Ren_Id  : out Entity_Id;
+ Wrap_Id : out Entity_Id);
+  --  Ada 2012 (AI05-0071): A generic/instance scenario involving a formal
+  --  type with unknown discriminants and a generic primitive operation of
+  --  the said type with a box require special processing when the actual
+  --  is a class-wide type:
+
+  --generic
+  --   type Formal_Typ () is private;
+  --   with procedure Prim_Op (Param : Formal_Typ) is ;
+  --package Gen is ...
+
+  --package Inst is new Gen (Actual_Typ'Class);
+
+  --  In this case the general renaming mechanism used in the prologue of
+  --  an instance no longer applies:
+
+  --procedure Prim_Op (Param : Formal_Typ) renames Prim_Op;
+
+  --  The above is replaced the following wrapper/renaming combination:
+
+  --procedure Prim_Op (Param : Formal_Typ) is  --  wrapper
+  --begin
+  --   Prim_Op (Param);--  primitive
+  --end Wrapper;
+
+  --procedure Dummy (Param : Formal_Typ) renames Prim_Op;
+
+  --  This transformation applies only if there is no explicit visible
+  --  class-wide operation at the point of the instantiation. Ren_Id is
+  --  the entity of the renaming declaration. Wrap_Id is the entity of
+  --  the generated class-wide wrapper (or Any_Id).
+
   procedure Check_Null_Exclusion
 (Ren : Entity_Id;
  Sub : Entity_Id);
@@ -1845,6 +1878,11 @@
   --  

Re: [RFC: Patch, PR 60102] [4.9/4.10 Regression] powerpc fp-bit ices@dwf_regno

2014-08-01 Thread Ulrich Weigand
Rohit,

 #define DWARF_REG_TO_UNWIND_COLUMN(r) \
-  ((r)  1200 ? ((r) - 1200 + (DWARF_FRAME_REGISTERS - 32)) : (r))
+  ((r) = 1200 ? ((r) - 1200 + (DWARF_FRAME_REGISTERS - 32)) : (r))

OK, makes sense.
 
 /* Use gcc hard register numbering for eh_frame.  */
-#define DWARF_FRAME_REGNUM(REGNO) (REGNO)
+#define DWARF_FRAME_REGNUM(REGNO) \
+  ((REGNO) = FIRST_SPE_HIGH_REGNO ? ((REGNO) - FIRST_SPE_HIGH_REGNO + 1200) 
: (REGNO))

Any reason for not using SPE_HIGH_REGNO_P here, just in case we
do get other hard registers at some point?

Otherwise this now looks good to me.  (Of course, I cannot
approve the patch myself.)

Thanks,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  ulrich.weig...@de.ibm.com



[Ada] Fix breach of privacy with type derived from private discriminated

2014-08-01 Thread Arnaud Charlet
This fixes a breach of privacy for types derived from private discriminated
record types whose full view has no discriminants, as well as factors out
the code doing the full derivation in the various cases into a single child
procedure of Build_Derived_Private_Type.  As a consequence, this removes
obsolete code that was catching the privacy breach in some specific cases.

The following specs p1.ads, p2.ads, p3.ads and p4.ads must be rejected:

p1.ads:8:18: invalid prefix in selected component A
p2.ads:12:18: invalid prefix in selected component A
p3.ads:8:18: invalid prefix in selected component A
p4.ads:12:18: invalid prefix in selected component A

with Q;

package P1 is

  type My_Data is new Q.Data;

  A : My_Data;
  B : Natural := A.Length;

end P1;
with Q;

package P2 is

  type My_Data is private;

private

  type My_Data is new Q.Data;

  A : My_Data;
  B : Natural := A.Length;

end P2;
package Q is

  type Data is private;

private

  type Small is range 1 .. 10;

  type Data (D : Small := 1) is record
Length : Natural;
  end record;

end Q;
with Q2;

package P3 is

  type My_Data is new Q2.Data;

  A : My_Data;
  B : Natural := A.Length;

end P3;
with Q2;

package P4 is

  type My_Data is limited private;

private

  type My_Data is new Q2.Data;

  A : My_Data;
  B : Natural := A.Length;

end P4;
package Q2 is

  type Data is limited private;

private

  type Small is range 1 .. 10;

  type Data (D : Small := 1) is tagged limited record
Length : Natural;
  end record;

end Q2;

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

2014-08-01  Eric Botcazou  ebotca...@adacore.com

* einfo.ads (Has_Private_Ancestor): Remove obsolete usage.
* exp_ch4.adb (Expand_Composite_Equality): Add conversion
of the actuals in the case of untagged record types too.
* sem_ch3.adb (Build_Full_Derivation): New procedure to create the
full derivation of a derived private type, extracted from...
(Copy_And_Build): In the case of record types and most
enumeration types, copy the original declaration.  Build the
full derivation according to the approach extracted from...
(Build_Derived_Private_Type): ...here.  Call Build_Full_Derivation
to create the full derivation in all existing cases and also
create it in the no-discriminants/discriminants case instead of
deriving directly from the full view.
(Is_Visible_Component): Remove obsolete code.
* sem_aggr.adb (Resolve_Record_Aggregate): Likewise.

Index: sem_aggr.adb
===
--- sem_aggr.adb(revision 213458)
+++ sem_aggr.adb(working copy)
@@ -3984,21 +3984,6 @@
  --  Typ is not a derived tagged type
 
  else
---  A type derived from an untagged private type whose full view
---  has discriminants is constructed as a record type but there
---  are no legal aggregates for it.
-
-if Is_Derived_Type (Typ)
-  and then Has_Private_Ancestor (Typ)
-  and then Nkind (N) /= N_Extension_Aggregate
-then
-   Error_Msg_Node_2 := Base_Type (Etype (Typ));
-   Error_Msg_NE
- (no aggregate available for type derived from 
-   private type, N, Typ);
-   return;
-end if;
-
 Record_Def := Type_Definition (Parent (Base_Type (Typ)));
 
 if Null_Present (Record_Def) then
Index: sem_ch3.adb
===
--- sem_ch3.adb (revision 213471)
+++ sem_ch3.adb (working copy)
@@ -6543,40 +6543,143 @@
   Loc : constant Source_Ptr := Sloc (N);
   Der_Base: Entity_Id;
   Discr   : Entity_Id;
-  Full_Decl   : Node_Id := Empty;
   Full_Der: Entity_Id;
   Full_P  : Entity_Id;
   Last_Discr  : Entity_Id;
   Par_Scope   : constant Entity_Id := Scope (Base_Type (Parent_Type));
-  Swapped : Boolean := False;
 
+  procedure Build_Full_Derivation;
+  --  Build full derivation, i.e. derive from the full view
+
   procedure Copy_And_Build;
   --  Copy derived type declaration, replace parent with its full view,
-  --  and analyze new declaration.
+  --  and build derivation
 
+  ---
+  -- Build_Full_Derivation --
+  ---
+
+  procedure Build_Full_Derivation is
+  begin
+ --  If parent scope is not open, install the declarations
+
+ if not In_Open_Scopes (Par_Scope) then
+Install_Private_Declarations (Par_Scope);
+Install_Visible_Declarations (Par_Scope);
+Copy_And_Build;
+Uninstall_Declarations (Par_Scope);
+
+ --  If parent scope is open and in another unit, and parent has a
+ --  completion, then the derivation is taking place in the visible
+ 

[COMMITTED] Add myself to MAINTAINERS file (Write After Approval)

2014-08-01 Thread Jiong Wang

Hi,

This patch adds myself to the MAINTAINERS file (Write After Approval).  
Commmitted as 213481

Thanks.

-- Jiong

Index: MAINTAINERS
===
--- MAINTAINERS (revision 213472)
+++ MAINTAINERS (working copy)
@@ -564,6 +564,7 @@
 Tom de Vries   t...@codesourcery.com
 Nenad Vukicevicne...@intrepid.com
 Feng Wang  fengw...@nudt.edu.cn
+Jiong Wang jiong.w...@arm.com
 Stephen M. Webb
stephen.w...@bregmasoft.com
 John Wehle j...@feith.com
 Florian Weimer f...@deneb.enyo.de




RE: [PATCH, i386] Handle extended family cpuid info for AMD

2014-08-01 Thread Gopalasubramanian, Ganesh
 In this case, having only check for family ID should be enough. If
BTVER1 and BTVER2 can be uniquely determined by their family IDs ,

IMO, this would be the most future-proof approach. Signature checks will 
override family id checks which will override cpuid checks.

Thank you Uros!

I have modified source only for BTVER2. 
The way BTVER1 is currently assigned to processor includes more than one 
family. So, I am leaving that unmoved.

Bootstrap passes.
Is it OK for trunk and backport to open branches.

Regards
-Ganesh


diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 706fedc..202bd99 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2014-08-01  Ganesh Gopalasubramanian  ganesh.gopalasubraman...@amd.com
+
+   * config/i386/driver-i386.c (host_detect_local_cpu): Handle AMD's 
extended family
+   information. Handle BTVER2 cpu with cpuid family value.  
+
 2014-07-31  James Greenhalgh  james.greenha...@arm.com
 
* config/aarch64/arm_neon.h (vpadd_suf8,16,32,64): Move to
diff --git a/gcc/config/i386/driver-i386.c b/gcc/config/i386/driver-i386.c
index 1c6385f..0402c90 100644
--- a/gcc/config/i386/driver-i386.c
+++ b/gcc/config/i386/driver-i386.c
@@ -432,7 +432,8 @@ const char *host_detect_local_cpu (int argc, const char 
**argv)
 
   model = (eax  4)  0x0f;
   family = (eax  8)  0x0f;
-  if (vendor == signature_INTEL_ebx)
+  if ((vendor == signature_INTEL_ebx) ||
+  (vendor == signature_AMD_ebx))
 {
   unsigned int extended_model, extended_family;
 
@@ -576,7 +577,7 @@ const char *host_detect_local_cpu (int argc, const char 
**argv)
 
   if (name == signature_NSC_ebx)
processor = PROCESSOR_GEODE;
-  else if (has_movbe)
+  else if (family == 22)
processor = PROCESSOR_BTVER2;
   else if (has_avx2)
 processor = PROCESSOR_BDVER4;


Re: [PATCH] Add target macro to override DWARF2 frame register size

2014-08-01 Thread Steven Bosscher
On Fri, Aug 1, 2014 at 3:31 PM, Matthew Fortune wrote:
 This patch adds a target macro

Please don't add target macros. Add a hook if you must, but we're
supposed to remove target macros, not add new ones :-)

Ciao!
Steven


Re: [PATCH, i386] Handle extended family cpuid info for AMD

2014-08-01 Thread Jakub Jelinek
On Fri, Aug 01, 2014 at 02:52:28PM +, Gopalasubramanian, Ganesh wrote:
 --- a/gcc/config/i386/driver-i386.c
 +++ b/gcc/config/i386/driver-i386.c
 @@ -432,7 +432,8 @@ const char *host_detect_local_cpu (int argc, const char 
 **argv)
  
model = (eax  4)  0x0f;
family = (eax  8)  0x0f;
 -  if (vendor == signature_INTEL_ebx)
 +  if ((vendor == signature_INTEL_ebx) ||
 +  (vendor == signature_AMD_ebx))

Wrong formatting.  No ()s around the comparisons needed, and
|| should go on the second line, not first.

 @@ -576,7 +577,7 @@ const char *host_detect_local_cpu (int argc, const char 
 **argv)
  
if (name == signature_NSC_ebx)
   processor = PROCESSOR_GEODE;
 -  else if (has_movbe)
 +  else if (family == 22)
   processor = PROCESSOR_BTVER2;

Wouldn't it be safer to use has_movbe  family == 22?
I mean, especially with emulators which choose to provide some architecture,
but disable some CPUID flags it is IMHO safer to also check the flags.

Jakub


[PATCH AArch64] Removed unused get_lane and dup_lane builtins.

2014-08-01 Thread Alan Lawrence
None of the variants of __builtin_aarch64_get_lane or __builtin_aarch64_dup_lane 
are used in arm_neon.h (vdup_lane uses vget_lane and vdup_n, vget_lane uses 
be_checked_get_lane to do an endianness swap, vdup_n uses gcc vector extension 
code). So remove them.


Regression tested on aarch64-none-elf.

gcc/ChangeLog:

* gcc/config/aarch64/aarch64-simd-builtins.def
(dup_lane, get_lane): Delete.

--

Index: gcc/config/aarch64/aarch64-simd-builtins.def
===
--- gcc/config/aarch64/aarch64-simd-builtins.def(revision 213452)
+++ gcc/config/aarch64/aarch64-simd-builtins.def(working copy)
@@ -47,8 +47,6 @@
   VAR1 (UNOP, addp, 0, di)
   BUILTIN_VDQ_BHSI (UNOP, clz, 2)

-  BUILTIN_VALL (GETLANE, get_lane, 0)
-  VAR1 (GETLANE, get_lane, 0, di)
   BUILTIN_VALL (GETLANE, be_checked_get_lane, 0)

   VAR1 (REINTERP_SS, reinterpretdi, 0, v1df)
@@ -74,7 +72,6 @@
   VAR1 (REINTERP_PS, reinterpretv2si, 0, v1df)
   VAR1 (REINTERP_PS, reinterpretv2sf, 0, v1df)

-  BUILTIN_VDQ_I (BINOP, dup_lane, 0)
   /* Implemented by aarch64_surqrshlmode.  */
   BUILTIN_VSDQ_I (BINOP, sqshl, 0)
   BUILTIN_VSDQ_I (BINOP_UUS, uqshl, 0)



Re: [PATCH] PowerPC: Implement TARGET_ATOMIC_ASSIGN_EXPAND_FENV

2014-08-01 Thread Joseph S. Myers
On Thu, 31 Jul 2014, David Edelsohn wrote:

 Thanks for implementing the FENV support.  The patch generally looks 
 good to me.
 
 My one concern is a detail in the implementation of update. I do not
 have enough experience with GENERIC to verify the details and it seems
 like it is missing building an outer COMPOUND_EXPR containing
 update_mffs and the CALL_EXPR for update mtfsf.

I suppose what's actually odd there is that you have

+  tree update_mffs = build2 (MODIFY_EXPR, void_type_node, old_fenv, call_mffs);
+
+  tree old_llu = build1 (VIEW_CONVERT_EXPR, uint64_type_node, update_mffs);

so you build a MODIFY_EXPR in void_type_node but then convert it with a 
VIEW_CONVERT_EXPR.  If you'd built the MODIFY_EXPR in double_type_node 
then the VIEW_CONVERT_EXPR would be meaningful (the value of an assignment 
a = b being the new value of a), but reinterpreting a void value doesn't 
make sense.  Or you could probably just use call_mffs directly in the 
VIEW_CONVERT_EXPR without explicitly creating the old_fenv variable.

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


Re: [Ada] Remove xgnatugn in doc generation

2014-08-01 Thread Joseph S. Myers
On Fri, 1 Aug 2014, Arnaud Charlet wrote:

 [
 Note: the previous related change was rejected due to a too large
 patch file attached. The mail was:
 
 This is another step in removing VMS code, and also a step in converting the
 documentation to the rest/sphinx format.
 
 The xgnatugn preprocessing step will also soon be removed.
 
 2014-08-01  Ben Brosgol  bros...@adacore.com
 
 * gnat_ugn.texi, projects.texi, xgnatugn.adb: Removed all VMS
 conditionalization from gnat_ugn.texi and projects.texi, and updated
 (considerably simplified) xgnatugn.adb, to be removed soon.
 ]
 
 Following up from previous doc clean ups (see above), this change removes the
 preprocessing step needed to generate gnat_ugn.info.
 
 Tested on x86_64-pc-linux-gnu, committed on trunk
 
 2014-08-01  Arnaud Charlet  char...@adacore.com
 
   * ug_words, xgnatugn.adb, gcc-interface/Make-lang.in: Remove
   xgnatugn.adb and ug_words.

Could you check if this needs any changes to the support in 
update_web_docs_svn for generating the online manuals, which would 
previously have run this preprocessing step?

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


Re: [PATCH][Ping v5] Add patch for debugging compiler ICEs

2014-08-01 Thread Andi Kleen
Jakub Jelinek ja...@redhat.com writes:
 Don't want to review a patch I wrote partially, so just a few comments:
 1) IMHO it should be configure time selectable (not sure about the default,
 but for non-release branches IMHO it should default to off, for release
 branches I don't know).  The point is that while it is useful for
 people to report gcc bugs in production compilers, it is not useful for
 gcc developers on their boxes, having ICEs take 3 times as long is not
 desirable for people who deal with those all the time

It may also not be desirable for LTO builds, which can take very long
by themselves.

-Andi
-- 
a...@linux.intel.com -- Speaking for myself only


Re: [Ada] Generate Machine, Model and Rounding FP attributes in line

2014-08-01 Thread Joseph S. Myers
On Fri, 1 Aug 2014, Arnaud Charlet wrote:

 This change makes it so that the Machine, Model and Rounding FP attributes
 are generated in line by the compiler (in conjunction with a conversion to
 an integer type for the third) and optimized on architectures that do not
 make use of internal extended precision in the FPU.

Using TARGET_FLT_EVAL_METHOD would be better than basing this on examining 
the machine modes (after all, on x86_64, you have XFmode but use of SSE 
means there are no excess previous issues; likewise, ia64 has XFmode but 
proper floating-point operations for all modes, including the formatOf 
operations that take wider operands and produce a narrower result without 
double rounding).

Except that S/390 defines TARGET_FLT_EVAL_METHOD to 1 for historical 
reasons (but doesn't, I think, actually have any excess precision issues 
with the back end - excess precision would only really be used for C with 
-fexcess-precision=standard), so strictly you'd need a different macro 
that differs from TARGET_FLT_EVAL_METHOD only on S/390 (i.e., a macro that 
describes what FLT_EVAL_METHOD is at back-end level rather than what it is 
at C API level with -fexcess-precision=standard).

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


Re: [PATCH][Ping v5] Add patch for debugging compiler ICEs

2014-08-01 Thread Jakub Jelinek
On Fri, Aug 01, 2014 at 08:43:27AM -0700, Andi Kleen wrote:
 Jakub Jelinek ja...@redhat.com writes:
  Don't want to review a patch I wrote partially, so just a few comments:
  1) IMHO it should be configure time selectable (not sure about the default,
  but for non-release branches IMHO it should default to off, for release
  branches I don't know).  The point is that while it is useful for
  people to report gcc bugs in production compilers, it is not useful for
  gcc developers on their boxes, having ICEs take 3 times as long is not
  desirable for people who deal with those all the time
 
 It may also not be desirable for LTO builds, which can take very long
 by themselves.

Indeed, and preparing preprocessed sources for all the files is hard in that
case anyway.  But as it is keyed on cc1 substring being present in the
compiler's name and lto uses lto1, it shouldn't trigger for that.
Only if you get ICEs with -flto already when compiling from C/C++ source,
but then it doesn't take very long usually and there is preprocessed source
available.

Jakub


Re: [PATCH AArch64] Removed unused get_lane and dup_lane builtins.

2014-08-01 Thread Marcus Shawcroft
On 1 August 2014 16:09, Alan Lawrence alan.lawre...@arm.com wrote:
 None of the variants of __builtin_aarch64_get_lane or
 __builtin_aarch64_dup_lane are used in arm_neon.h (vdup_lane uses vget_lane
 and vdup_n, vget_lane uses be_checked_get_lane to do an endianness swap,
 vdup_n uses gcc vector extension code). So remove them.

 Regression tested on aarch64-none-elf.

 gcc/ChangeLog:

 * gcc/config/aarch64/aarch64-simd-builtins.def
 (dup_lane, get_lane): Delete.

OK /Marcus


Re: [PATCH][Ping v5] Add patch for debugging compiler ICEs

2014-08-01 Thread Jakub Jelinek
On Fri, Aug 01, 2014 at 12:13:18PM +0400, Yury Gribov wrote:
 On 08/01/2014 12:00 PM, Jakub Jelinek wrote:
 Don't want to review a patch I wrote partially, so just a few comments:
 1) IMHO it should be configure time selectable (not sure about the default,
 but for non-release branches IMHO it should default to off, for release
 branches I don't know).  The point is that while it is useful for
 people to report gcc bugs in production compilers, it is not useful for
 gcc developers on their boxes, having ICEs take 3 times as long is not
 desirable for people who deal with those all the time
 
 I think we should use David Malcolm's approach i.e. add some --report-bug
 flag
 to driver. This could be enabled by default at configure time via
 --with-spec.

-freport-bug or whatever we call it should not be, at least if it attempts
to communicate over the network, should not be required though, lots of
people do e.g. package builds in various chroots etc. and you really don't
want to perform any network activity from there.  Still, having
info whether an ICE was reproduceable or not is useful in that case, and
having preprocessed source left in /tmp with the path printed to stderr
is also useful, you can e.g. grab those /tmp/cc*.out files from the chroot
and allow people to report later on.  The ICE message can of course suggest
an option or script or command line to run to report the bug or navigate the
user through bug reporting process.

Jakub


Re: [PATCH] Move memory builtin foldings to GIMPLE

2014-08-01 Thread Joseph S. Myers
On Fri, 1 Aug 2014, Richard Biener wrote:

 Does this look sensible?  In particular, does any Frontend maintainer
 object to no longer getting these simplifications?  Note they
 will still apply during gimplification and given they now work
 on GENERIC we can simplify them quite a bit (but as followup).

I see no problems with this in C terms.  I expect some code may well do 
things like

static size_t len = __builtin_strlen (foo);

and expect the static initializer to get folded, but that's only an issue 
with folding for constant arguments to pure functions - not for the 
functions involved here, whose whole purpose is to modify memory.

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


Re: [PATCH 2/2] Enable elimination of zext/sext

2014-08-01 Thread Kugan
  if (rhs_uns)
return wi::ge_p (min, 0);  // if min = 0 then range contains positive 
 values
  else
return wi::le_p (max, wi::max_value (TYPE_PRECISION (TREE_TYPE
 (ssa)), SIGNED);  // if max = signed-max-of-type then range doesn't
 need sign-extension

 I think we will have to check that ssa has necessary sign/zero extension
 when assigned to lhs_type. If PROMOTE_MODE tells us that ssa's type will
 be interpreted differently, the value range of ssa also will have
 corresponding range.  In this cases, shouldn’t we have to check for
 upper and lower limit for both min and max?
 
 Hmm?  That's exactly what the check is testing...  we know that
 min = max thus if min = 0 then max = 0.
 
 zero_extension will never do anything on [0, INF]
 
 If max  MAX-SIGNED then sign-extension will not do anything.  Ok,
 sign-extension will do sth for negative values still.  So rather
 
   if (rhs_uns)
 return wi::geu_p (min, 0);
   else
 return wi::ges_p (min, 0)  wi::les_p (max, wi::max_value
 (TYPE_PRECISION (TREE_TYPE (ssa)), SIGNED));
 
 ?

Thanks for the explanation. I agree. Don’t we have to however check this
on lhs_uns as this function is checking if ssa is promoted for lhs_sign
and lhs_mode?

Here is an attempt based on this. I ran regression testing with
arm-none-linux-gnueabi on qemu-arm without any new regressions.

Sine I am not comparing value ranges to see if it can be represented in
lhs_sigh, I can now skip the PROMOTED_MODE check.

I am still using wide_int::from (instead of wi::max_value) to get the
limit as I have to match the precision with min, max precision.
otherwise wide_int comparisons will not work. Is there a better way for
this?

/* Return TRUE if value in SSA is already zero/sign extended for lhs type
   (type here is the combination of LHS_MODE and LHS_UNS) using value range
   information stored.  Return FALSE otherwise.  */
bool
promoted_for_type_p (tree ssa, enum machine_mode lhs_mode, bool lhs_uns)
{
  wide_int min, max, limit;
  tree lhs_type;
  bool rhs_uns;
  signop rhs_signop;

  if (ssa == NULL_TREE
  || TREE_CODE (ssa) != SSA_NAME
  || !INTEGRAL_TYPE_P (TREE_TYPE (ssa)))
return false;

  /* Return FALSE if value_range is not recorded for SSA.  */
  if (get_range_info (ssa, min, max) != VR_RANGE)
return false;

  rhs_uns = TYPE_UNSIGNED (TREE_TYPE (ssa));
  rhs_signop = rhs_uns ? UNSIGNED : SIGNED;
  lhs_type = lang_hooks.types.type_for_mode (lhs_mode, lhs_uns);
  limit = wide_int::from (TYPE_MAX_VALUE (lhs_type),
  TYPE_PRECISION (TREE_TYPE (ssa)), SIGNED);

  if (lhs_uns)
/* If min = 0 then range contains positive values and doesnt need
   zero-extension.  */
return wi::ge_p (min, 0, rhs_signop);
  else
/* If min = 0 and max = signed-max-of-type then range doesn't need
   sign-extension.  */
return wi::ge_p (min, 0, rhs_signop)  wi::le_p (max, limit,
rhs_signop);
}

Thanks,
Kugan


Re: [Ada] Legality checks involving aspect Import

2014-08-01 Thread Mike Stump
On Aug 1, 2014, at 3:16 AM, Arnaud Charlet char...@adacore.com wrote:
 This patch adds some missing legality checks

No, GNU English doesn’t have us using legal/illegal unless the motivation is a 
law of some specific jurisdiction.

 q.ads:2:28: imported entities cannot have explicit initialization (RM 8.1 
 (24))
 q.ads:6:24: no initialization allowed for declaration of J at line 5
 q.ads:6:24: imported entities cannot be initialized (RM B.1(24))
 q.ads:9:24: no initialization allowed for declaration of K at line 8
 q.ads:9:24: imported entities cannot be initialized (RM B.1(24))

There are ok, but…

   * sem_ch13.adb (Analyze_Aspect_Specifications, case Aspect_Import):
   Set Is_Imported flag at once, to simplify subsequent legality

Not this.

   checks. Reject the aspect on an object whose declaration has an
   explicit initial value.
   * sem_prag.adb (Process_Import_Or_Interface): Use original node
   to check legality of an initial value for an imported entity.

Nor this.

Re: [PATCH] Move memory builtin foldings to GIMPLE

2014-08-01 Thread Jeff Law

On 08/01/14 06:43, Richard Biener wrote:


The following patch removes folding of bzero, memset, bcopy,
memcpy, mempcpy and memmove from builtins.c and re-implements
them in gimple-fold.c.  This means those foldings are no longer
accessible from GENERIC folding.

Bootstrapped on x86_64-unknown-linux-gnu - testing seems to reveal
some testsuite fallout I still have to look into.

Does this look sensible?  In particular, does any Frontend maintainer
object to no longer getting these simplifications?  Note they
will still apply during gimplification and given they now work
on GENERIC we can simplify them quite a bit (but as followup).
Given the general need to move folding out of the FEs and into the 
gimple optimizers, I'm all for this.  Obviously we have to deal will 
fallout, but I'm all for the general direction this is going.


Thanks,
Jeff



a patch was backported to gcc 4.9 branch

2014-08-01 Thread Vladimir Makarov

The following patch was backported from mainline to gcc-4.9 branch:

https://gcc.gnu.org/ml/gcc-patches/2014-07/msg00845.html

Committed as rev. 213497.

2014-08-01  Vladimir Makarov  vmaka...@redhat.com

* lra-constraints.c (remove_inheritance_pseudos): Process
destination pseudo too.


RE: [RFC: Patch, PR 60102] [4.9/4.10 Regression] powerpc fp-bit ices@dwf_regno

2014-08-01 Thread rohitarul...@freescale.com
Hello Ulrich,

Thanks.

  /* Use gcc hard register numbering for eh_frame.  */ -#define
 DWARF_FRAME_REGNUM(REGNO) (REGNO)
 +#define DWARF_FRAME_REGNUM(REGNO) \
 +  ((REGNO) = FIRST_SPE_HIGH_REGNO ? ((REGNO) -
 FIRST_SPE_HIGH_REGNO +
 +1200) : (REGNO))
 
 Any reason for not using SPE_HIGH_REGNO_P here, just in case we do get
 other hard registers at some point?

Yes, we can use it. I just have to move the definition of SPE_HIGH_REGNO_P 
macro before DWARF_FRAME_REGNUM macro definition.
 [Previously, I had defined and placed SPE_HIGH_REGNO_P macro along with 
similar macros ALTIVEC_REGNO_P etc.]

I had updated the patch as required (For this last change, I have 
checked/tested only the builds: ppc64 trunk, e500v2 v4.9.1 bareboard  linux 
build).

PR target/60102

[libgcc]
2014-07-31  Rohit  rohitarul...@freescale.com
* config/rs6000/linux-unwind.h (ppc_fallback_frame_state): Update
  based on change in SPE high register numbers and 3 HTM registers.

[gcc]
2014-07-31  Rohit  rohitarul...@freescale.com
* config/rs6000/rs6000.c
  (rs6000_reg_names) : Add SPE high register names.
  (alt_reg_names) : Likewise.
  (rs6000_dwarf_register_span) : For SPE high registers, replace
  dwarf register numbers with GCC hard register numbers.
  (rs6000_init_dwarf_reg_sizes_extra) : Likewise.
  (rs6000_dbx_register_number): For SPE high registers, return dwarf
  register number for the corresponding GCC hard register number.

* config/rs6000/rs6000.h
  (FIRST_PSEUDO_REGISTER) : Update based on 32 newly added GCC hard
  register numbers for SPE high registers.
  (DWARF_FRAME_REGISTERS) :  Likewise.
  (DWARF_REG_TO_UNWIND_COLUMN) : Likewise.
  (DWARF_FRAME_REGNUM) : Likewise.
  (FIXED_REGISTERS) : Likewise.
  (CALL_USED_REGISTERS) : Likewise.
  (CALL_REALLY_USED_REGISTERS) : Likewise.
  (REG_ALLOC_ORDER) : Likewise.
  (enum reg_class) : Likewise.
  (REG_CLASS_NAMES) : Likewise.
  (REG_CLASS_CONTENTS) : Likewise.
  (SPE_HIGH_REGNO_P) : New macro to identify SPE high registers.

* gcc.target/powerpc/pr60102.c: New testcase.

Regards,
Rohit


pr60102.patch
Description: pr60102.patch


Re: [RFC: Patch, PR 60102] [4.9/4.10 Regression] powerpc fp-bit ices@dwf_regno

2014-08-01 Thread Jakub Jelinek
On Fri, Aug 01, 2014 at 06:03:56PM +, rohitarul...@freescale.com wrote:
   PR target/60102

--- libgcc/config/rs6000/linux-unwind.h (revision 213110)   
   
+++ libgcc/config/rs6000/linux-unwind.h (working copy)  
   
@@ -274,8 +274,8 @@ ppc_fallback_frame_state (struct _Unwind
   
 #ifdef __SPE__ 
   
   for (i = 14; i  32; i++)
   
 {  
   
-  fs-regs.reg[i + FIRST_PSEUDO_REGISTER - 1].how = REG_SAVED_OFFSET;  
   
-  fs-regs.reg[i + FIRST_PSEUDO_REGISTER - 1].loc.offset   
   
+  fs-regs.reg[i + FIRST_SPE_HIGH_REGNO - 4].how = REG_SAVED_OFFSET;   
   
+  fs-regs.reg[i + FIRST_SPE_HIGH_REGNO - 4].loc.offset
   
= (long) regs-vregs - new_cfa + 4 * i;
   
 }  
   
 #endif 
   

is a different index, previously i + 116, newly i + 113, is that
intentional?

Jakub


Re: [RFC, PATCH 3/n] IPA C++ refactoring

2014-08-01 Thread Jeff Law

On 08/01/14 05:35, Martin Liška wrote:

2014-07-31  Martin Liskamli...@suse.cz

* cgraph.h (cgraph_node_set, varpool_node_set): Removed structs and all
related functions that manipulated these data structures.
(cgraph_new_nodes): vec replaces cgraph_node_set.
* cgraphunit.c (cgraph_new_nodes): Likewise.
(cgraph_process_new_functions): Likewise.
(cgraph_node::add_new_function): Likewise.
* ipa-inline-transform.c (can_remove_node_now_p_1): Likewise.
* ipa-utils.c: Implementations of legacy data structures removed,
data structure was replaced by a hash_map.
* tree-emutls.c (tls_vars): hash_map replaces varpool_node_set.
(emutls_index): New functions are used.
(ipa_lower_emutls): Likewise.
Looks like a good cleanup.  Just aone nit left with the most recent 
version (the one where you fixed the indention issues pointed out by Jakub):






symtab-node-removal.patch


diff --git a/gcc/tree-emutls.c b/gcc/tree-emutls.c
index 89197c7..2c9cfe4 100644
--- a/gcc/tree-emutls.c
+++ b/gcc/tree-emutls.c
@@ -608,13 +581,20 @@ lower_emutls_phi_arg (gimple phi, unsigned int i, struct 
lower_emutls_data *d)
  }
  }

+bool
+reset_access (varpool_node * const , tls_var_data *data, void *)
+{
+  data-access = NULL;
+
+  return true;
+}

Need a comment for this function.


Approved once you add that comment.  Please post the final patch for 
archival purposes.


Thanks,
Jeff



RE: [RFC: Patch, PR 60102] [4.9/4.10 Regression] powerpc fp-bit ices@dwf_regno

2014-08-01 Thread rohitarul...@freescale.com
Jakub,

 On Fri, Aug 01, 2014 at 06:03:56PM +, rohitarul...@freescale.com wrote:
  PR target/60102
 
 --- libgcc/config/rs6000/linux-unwind.h (revision 213110)
 +++ libgcc/config/rs6000/linux-unwind.h (working copy)
 @@ -274,8 +274,8 @@ ppc_fallback_frame_state (struct _Unwind
  #ifdef __SPE__
for (i = 14; i  32; i++)
  {
 -  fs-regs.reg[i + FIRST_PSEUDO_REGISTER - 1].how = REG_SAVED_OFFSET;
 -  fs-regs.reg[i + FIRST_PSEUDO_REGISTER - 1].loc.offset
 +  fs-regs.reg[i + FIRST_SPE_HIGH_REGNO - 4].how = REG_SAVED_OFFSET;
 +  fs-regs.reg[i + FIRST_SPE_HIGH_REGNO - 4].loc.offset
 = (long) regs-vregs - new_cfa + 4 * i;
  }
  #endif
 
 is a different index, previously i + 116, newly i + 113, is that intentional?
 

Yes, it is intentional.
This part of code wasn't updated after the introduction of three HTM registers.

Regards,
Rohit


Re: [PATCH, i386] Handle extended family cpuid info for AMD

2014-08-01 Thread Uros Bizjak
On Fri, Aug 1, 2014 at 5:00 PM, Jakub Jelinek ja...@redhat.com wrote:
 --- a/gcc/config/i386/driver-i386.c
 +++ b/gcc/config/i386/driver-i386.c
 @@ -432,7 +432,8 @@ const char *host_detect_local_cpu (int argc, const char 
 **argv)

model = (eax  4)  0x0f;
family = (eax  8)  0x0f;
 -  if (vendor == signature_INTEL_ebx)
 +  if ((vendor == signature_INTEL_ebx) ||
 +  (vendor == signature_AMD_ebx))

 Wrong formatting.  No ()s around the comparisons needed, and
 || should go on the second line, not first.

 @@ -576,7 +577,7 @@ const char *host_detect_local_cpu (int argc, const char 
 **argv)

if (name == signature_NSC_ebx)
   processor = PROCESSOR_GEODE;
 -  else if (has_movbe)
 +  else if (family == 22)
   processor = PROCESSOR_BTVER2;

 Wouldn't it be safer to use has_movbe  family == 22?
 I mean, especially with emulators which choose to provide some architecture,
 but disable some CPUID flags it is IMHO safer to also check the flags.

OK, after rethinking this, let's go with the safer original patch
(sorry for a bit of confusion, but we cleared a lot of open questions
during the discussion).

The original patch is OK for mainline and branches.

OTOH, it looks we will have to redesign -march=native someday to only
pass options, derived from cpuid and eventually pass -mtune based on
detected family.

Thanks,
Uros.


Re: [PATCH][testsuite] Don't run cproj-fails-with-broken-glibc.c for broken glibc

2014-08-01 Thread Mike Stump
On Aug 1, 2014, at 3:35 AM, Rainer Orth r...@cebitec.uni-bielefeld.de wrote:
 I'm not at all happy with this patch

 That test, even if we go the glibc version route, needs to be XFAILed
 instead of requiring the working version.  Apart from that, new
 effective-target keywords need documenting in doc/sourcebuild.texi.

Some background folks:

  https://gcc.gnu.org/ml/gcc-patches/2010-04/msg00490.html

So I too agree that skipping the test case on known broken systems when the 
entire design of the test case is to fail on exactly those broken systems is 
borked.

So, what should we do with it instead.  Either xfailing it on known bad 
systems, or removing it entirely as misguided seem to be the two choices that 
make sense.

What are people in favor of?  Clearly the original author wanted at least the 
xfail.  I lean toward removal I think.  Why?  The gcc test suite, while it 
could be a filesystem test suite, an OS test suite, a libc test suite, 
generally speaking that is beyond the scope of this project.

From the test case:

   Check the runtime behavior of the C library's cproj() function and
   whether it follows the standard.  Versions of GLIBC through 2.11.1
   had an incorrect implementation which will conflict with GCC's
   builtin cproj().  GLIBC 2.12+ should be okay.

Re: [Patch] PR 61692 - Fix for inline asm ICE

2014-08-01 Thread Jeff Law

On 08/01/14 02:07, David Wohlferd wrote:


I'd love to.  Unfortunately, my platform doesn't support valgrind.

Ah.




Also, please include the testcase you had nlabels part.


I have created the testcase for the 31 labels problem.  However, not so
much for the nclobbers part.  And if I'm going to patch both, I should
have testcases for both.
Tell you what, pass along what you've got and I'll run it under valgrind 
here.  I'm quite confident both need to be changed -- though it is 
possible nothing will trigger with the nclobbers stuff if it is indeed 
handled separately throughout the guts of GCC.



Jeff


Re: [C++ Patch] DR 217 follow up (and more)

2014-08-01 Thread Jason Merrill

On 07/31/2014 01:36 PM, Paolo Carlini wrote:

The problem is that when grokfndecl calls duplicate_decls in such member cases 
it looks through TEMPLATE_DECLs
and then telling apart the two cases above is tough, both are FUNCTION_DECLs

Ideas about the best way to handle that?


Could you just condition it on DECL_TEMPLATE_INFO?


  tree t2 = TYPE_ARG_TYPES (TREE_TYPE (newdecl));
  int i = 1;

- if (TREE_CODE (TREE_TYPE (newdecl)) == METHOD_TYPE)
+ if (DECL_NONSTATIC_MEMBER_FUNCTION_P (newdecl))
t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2);


Let's use FUNCTION_FIRST_USER_PARMTYPE instead.


- if (TREE_CODE (TREE_TYPE (newdecl)) == METHOD_TYPE
+ if (DECL_FUNCTION_MEMBER_P (newdecl)


This change is OK.

and in the predicate patch:


- || TREE_CODE (TREE_TYPE (target_type)) != METHOD_TYPE);
+ || !DECL_NONSTATIC_MEMBER_FUNCTION_P (target_type));


This is wrong because target_type is not a FUNCTION_DECL.  We should 
probably either add FUNCTION_DECL_CHECK to 
DECL_NONSTATIC_MEMBER_FUNCTION_P or make it false if the argument isn't 
a FUNCTION_DECL.


There are a bunch of instances of this in the patch.


   if (TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE
-  || TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE
+  || DECL_NONSTATIC_MEMBER_FUNCTION_P (expr)


Changing this instance and similar ones doesn't make much sense since 
the condition is looking for any kind of function, not just a non-static 
member function.


Jason



Re: [Ada] Remove xgnatugn in doc generation

2014-08-01 Thread Arnaud Charlet
  2014-08-01  Arnaud Charlet  char...@adacore.com
  
  * ug_words, xgnatugn.adb, gcc-interface/Make-lang.in: Remove
  xgnatugn.adb and ug_words.
 
 Could you check if this needs any changes to the support in 
 update_web_docs_svn for generating the online manuals, which would
 previously have run this preprocessing step?

Thanks for the note.

Updated as follows, this should do the trick as far as I can tell:

* update_web_docs_svn: Simplify build of gnat_ugn.

--
Index: update_web_docs_svn
===
--- update_web_docs_svn (revision 213156)
+++ update_web_docs_svn (working copy)
@@ -20,11 +20,7 @@ MANUALS=cpp
   gcj
   gfortran
   gfc-internals
-  gnat_ug_unx
-  gnat_ug_vms
-  gnat_ug_vxw
-  gnat_ug_wnt
-  gnat_ugn_unw
+  gnat_ugn
   gnat-style
   gnat_rm
   libgomp
@@ -118,8 +114,6 @@ fi
 find gcc -type f \( -name '*.texi' \
   -o -path gcc/gcc/doc/install.texi2html \
   -o -path gcc/gcc/doc/include/texinfo.tex \
-  -o -path gcc/gcc/ada/xgnatugn.adb \
-  -o -path gcc/gcc/ada/ug_words \
   -o -path gcc/gcc/BASE-VER \
   -o -path gcc/gcc/DEV-PHASE \
   -o -print0 \) | xargs -0 rm -f
@@ -131,14 +125,6 @@ tar cf docs-sources.tar gcc
 # and fdl.texi.
 includedir=gcc/gcc/doc/include
 
-# Generate gnat_ugn_unw
-
-if [ -f gcc/gcc/ada/xgnatugn.adb ]; then
-   gnatmake -q gcc/gcc/ada/xgnatugn
-   ./xgnatugn unw gcc/gcc/ada/gnat_ugn.texi \
- gcc/gcc/ada/ug_words gnat_ugn_unw.texi
-fi
-
 # Generate gcc-vers.texi.
 (
echo @set version-GCC $(cat gcc/gcc/BASE-VER)
@@ -161,7 +147,7 @@ for file in $MANUALS; do
   filename=`find . -name ${file}.texi`
   if [ ${filename} ]; then
 includes=-I ${includedir} -I `dirname ${filename}`
-if [ $file = gnat_ugn_unw ]; then
+if [ $file = gnat_ugn ]; then
   includes=$includes -I gcc/gcc/ada
 fi
 makeinfo --html $includes -o ${file} ${filename}


Re: [PATCH][Ping v5] Add patch for debugging compiler ICEs

2014-08-01 Thread Jeff Law

On 08/01/14 02:00, Jakub Jelinek wrote:

On Thu, Jul 24, 2014 at 04:39:28PM +0400, Maxim Ostapenko wrote:

Ping.


Don't want to review a patch I wrote partially, so just a few comments:
1) IMHO it should be configure time selectable (not sure about the default,
but for non-release branches IMHO it should default to off, for release
branches I don't know).  The point is that while it is useful for
people to report gcc bugs in production compilers, it is not useful for
gcc developers on their boxes, having ICEs take 3 times as long is not
desirable for people who deal with those all the time
We definitely want the ability to select.  Waiting on an ICE to trigger 
3 times would be painful for the developers.  So I'd think that enabled 
for the release branches and disabled for the trunk would be the right 
default.




2) recently a bug has been reported that some ICEs which print RTL
to stderr are considered non-reproduceable, because the addresses e.g.
in call_insn fndecl change through address space randomization.  For the
retries the driver should supposedly append -fdump-noaddr.

Right.  I think we discussed this at Cauldron.

I think it's conceptually ok with those two changes, then it's just 
reviewing the details.


If you or Maxim could make those changes and repost, I'll cover the review.

jeff


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

2014-08-01 Thread Jonathan Wakely

On 30/07/14 23:36 +0800, Zifei Tong wrote:

On Wed, Jul 30, 2014 at 11:25 PM, Jonathan Wakely jwak...@redhat.com 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!


I've committed the attached patch to trunk, I'll apply it to the 4.8
and 4.9 branches soon too.

Tested x86_64-linux, with both glibc 2.11 and 2.18 so with and without
__cxa_thread_atexit_impl.

Thanks again for the report and patch.

commit ecaf491ba1a82e858b8a0654efeee74e55c74c05
Author: Jonathan Wakely jwak...@redhat.com
Date:   Fri Aug 1 19:53:58 2014 +0100

2014-08-01  Zifei Tong  zifeit...@gmail.com

	* libsupc++/atexit_thread.cc (HAVE___CXA_THREAD_ATEXIT_IMPL): Add
	_GLIBCXX_ prefix to macro.

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 new
 #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 */


Re: [C++ Patch] DR 217 follow up (and more)

2014-08-01 Thread Paolo Carlini

Hi,

On 08/01/2014 08:30 PM, Jason Merrill wrote:

On 07/31/2014 01:36 PM, Paolo Carlini wrote:
The problem is that when grokfndecl calls duplicate_decls in such 
member cases it looks through TEMPLATE_DECLs
and then telling apart the two cases above is tough, both are 
FUNCTION_DECLs


Ideas about the best way to handle that?

Could you just condition it on DECL_TEMPLATE_INFO?
Of course, thanks! I have no idea why I thought I was unable to go back 
to the template information :( Then the whole issue - of course, again - 
is easy.



   tree t2 = TYPE_ARG_TYPES (TREE_TYPE (newdecl));
   int i = 1;

-  if (TREE_CODE (TREE_TYPE (newdecl)) == METHOD_TYPE)
+  if (DECL_NONSTATIC_MEMBER_FUNCTION_P (newdecl))
 t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2);


Let's use FUNCTION_FIRST_USER_PARMTYPE instead.


-  if (TREE_CODE (TREE_TYPE (newdecl)) == METHOD_TYPE
+  if (DECL_FUNCTION_MEMBER_P (newdecl)


This change is OK.

Thanks, I'm attaching below what I'm going to apply.

I will return to the separate DECL_NONSTATIC_MEMBER_FUNCTION_P mini 
project after c++/15339.


Paolo.
Index: decl.c
===
--- decl.c  (revision 213439)
+++ decl.c  (working copy)
@@ -1706,14 +1706,11 @@ duplicate_decls (tree newdecl, tree olddecl, bool
;
   else if (TREE_CODE (olddecl) == FUNCTION_DECL)
{
- tree t1 = TYPE_ARG_TYPES (TREE_TYPE (olddecl));
- tree t2 = TYPE_ARG_TYPES (TREE_TYPE (newdecl));
+ tree t1 = FUNCTION_FIRST_USER_PARMTYPE (olddecl);
+ tree t2 = FUNCTION_FIRST_USER_PARMTYPE (newdecl);
  int i = 1;
 
- if (TREE_CODE (TREE_TYPE (newdecl)) == METHOD_TYPE)
-   t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2);
-
- if (TREE_CODE (TREE_TYPE (newdecl)) == METHOD_TYPE
+ if (DECL_FUNCTION_MEMBER_P (newdecl)
   CLASSTYPE_TEMPLATE_INFO (CP_DECL_CONTEXT (newdecl)))
{
  /* C++11 8.3.6/6.


Re: [Patch, Fortran] -fcoarray=lib - support CRITICAL, prepare for locking support

2014-08-01 Thread Alessandro Fanfarillo
Hello,

I was implementing lock/unlock on the library side when I found a
possible problem in the patch:

if (is_lock_type == GFC_CAF_CRITICAL)
+reg_type = sym-attr.artificial ? GFC_CAF_CRITICAL : GFC_CAF_LOCK_STATIC;
+  else
+reg_type = GFC_CAF_COARRAY_STATIC;

the if statement cannot be true since is_lock_type is a boolean and
GFC_CAF_CRITICAL is 4.

Using if (is_lock_type) it produces the right result for the lock registration.


Regards

Alessandro

2014-07-28 14:37 GMT-06:00 Tobias Burnus bur...@net-b.de:
 This patch implements -fcoarray=lib support for CRITICAL blocks and includes
 some preparatory work for locking. In particular:

 * Updated the documentation for locking/critical, minor cleanup. The patch
 goes on top of the unreviewed patch
 https://gcc.gnu.org/ml/fortran/2014-07/msg00155.html
 * Add libcaf_single implementation for lock/unlock
 * Add lock/unlock calls for CRITICAL
 * Register static/SAVEd locking variables and locking variables for critical
 sections.

 Build and currently regtesting on x86-64-gnu-linux.
 OK when it regtested successfully?

  * * *

 Still to be done as follow up:
 * Handling the registering of lock-type components in statically allocated
 derived types
 * Handling the registering of lock-type variables and components with
 allocate and with implicit/explicit deallocate
 * Calling lock/unlock function for those
 * Test case for locking and critical blocks

 Other coarray to-do items:
 * Type-conversion test case missing
 * Vector subscript library implementation + test cases
 * Extending the documentation
 * Issues with striding for coarray components of derived types
 * Nonallocatable polymophic coarrays and select type/associated
 * Allocatable/pointer components of coarrays; co_reduce and co_broadcast

 Tobias


Re: [PATCH, libfortran] Backport xmallocarray to 4.8/4.9 (CVE-2014-5044)

2014-08-01 Thread Janne Blomqvist
On Fri, Aug 1, 2014 at 3:49 PM, Jakub Jelinek ja...@redhat.com wrote:
 On Thu, Jul 31, 2014 at 11:32:12PM +0300, Janne Blomqvist wrote:
 a while ago I committed a patch to trunk adding a function
 xmallocarray to libgfortran, which is a malloc wrapper like xmalloc
 but has two arguments and does an overflow check before multiplying
 them together.

 That seems to be unnecessarily expensive for the common case where both
 nmemb and size are small.

 calloc in glibc uses something like following to avoid the division most of
 the time, if both nmemb and size are small enough then nmemb * size can't
 overflow.  At least for 64-bit architectures small is smaller than 4GB
 for both numbers.

 2014-08-01  Jakub Jelinek  ja...@redhat.com

 * runtime/memory.c (xmallocarray): Avoid division for the common case.

 --- libgfortran/runtime/memory.c.jj 2014-06-18 08:50:33.0 +0200
 +++ libgfortran/runtime/memory.c2014-08-01 14:41:08.385856116 +0200
 @@ -56,7 +56,9 @@ xmallocarray (size_t nmemb, size_t size)

if (!nmemb || !size)
  size = nmemb = 1;
 -  else if (nmemb  SIZE_MAX / size)
 +#define HALF_SIZE_T (((size_t) 1)  (__CHAR_BIT__ * sizeof (size_t) / 2))
 +  else if (__builtin_expect ((nmemb | size) = HALF_SIZE_T, 0)
 +   nmemb  SIZE_MAX / size)
  {
errno = ENOMEM;
os_error (Integer overflow in xmallocarray);

Nice, though as os_error() has the _Noreturn specifier the
__builtin_expect() is not necessary, right? In libgfortran.h we have
in the comment block above the likely/unlikely macros, which are
wrappers around __builtin_expect:

...as __builtin_expect overrides the compiler
heuristic, do not use in conditions where one of the branches ends with a
call to a function with __attribute__((noreturn)): the compiler internal
heuristic will mark this branch as much less likely as unlikely() would
do.

Ok for trunk/4.9/4.8. If you choose to leave the __builtin_expect
there, please explain why?

-- 
Janne Blomqvist


Re: [PATCH, libfortran] Backport xmallocarray to 4.8/4.9 (CVE-2014-5044)

2014-08-01 Thread Jakub Jelinek
On Sat, Aug 02, 2014 at 12:09:24AM +0300, Janne Blomqvist wrote:
  --- libgfortran/runtime/memory.c.jj 2014-06-18 08:50:33.0 +0200
  +++ libgfortran/runtime/memory.c2014-08-01 14:41:08.385856116 +0200
  @@ -56,7 +56,9 @@ xmallocarray (size_t nmemb, size_t size)
 
 if (!nmemb || !size)
   size = nmemb = 1;
  -  else if (nmemb  SIZE_MAX / size)
  +#define HALF_SIZE_T (((size_t) 1)  (__CHAR_BIT__ * sizeof (size_t) / 2))
  +  else if (__builtin_expect ((nmemb | size) = HALF_SIZE_T, 0)
  +   nmemb  SIZE_MAX / size)
   {
 errno = ENOMEM;
 os_error (Integer overflow in xmallocarray);
 
 Nice, though as os_error() has the _Noreturn specifier the
 __builtin_expect() is not necessary, right? In libgfortran.h we have

The reason for __builtin_expect here was to make already the
nmemb  SIZE_MAX / size
computation as unlikely, the noreturn predictor will of course DTRT with the
{} block.

Jakub


[C++ Patch] PR 15339

2014-08-01 Thread Paolo Carlini

Hi,

thus this is what I have tested for c++/15339. By the way, I figured out 
why yesterday I got stupidly confused about DECL_TEMPLATE_INFO: at this 
point, for a member function template, newdecl does *not* have 
DECL_TEMPLATE_INFO set, only olddecl does. Consistently, I adjusted all 
the code in the condition to work on olddecl. Tested x86_64-linux.


Thanks,
Paolo.

//
/cp
2014-08-01  Paolo Carlini  paolo.carl...@oracle.com

PR c++/15339
* decl.c (duplicate_decls): Handle default arguments in function
templates.

/testsuite
2014-08-01  Paolo Carlini  paolo.carl...@oracle.com

PR c++/15339
* g++.dg/other/default9.C: New.
* g++.dg/other/default3.C: Remove xfail.
Index: cp/decl.c
===
--- cp/decl.c   (revision 213505)
+++ cp/decl.c   (working copy)
@@ -1704,19 +1704,23 @@ duplicate_decls (tree newdecl, tree olddecl, bool
 
   if (DECL_LANG_SPECIFIC (olddecl)  DECL_USE_TEMPLATE (olddecl))
;
-  else if (TREE_CODE (olddecl) == FUNCTION_DECL)
+  else if (DECL_DECLARES_FUNCTION_P (olddecl))
{
  tree t1 = FUNCTION_FIRST_USER_PARMTYPE (olddecl);
  tree t2 = FUNCTION_FIRST_USER_PARMTYPE (newdecl);
  int i = 1;
 
- if (DECL_FUNCTION_MEMBER_P (newdecl)
-  CLASSTYPE_TEMPLATE_INFO (CP_DECL_CONTEXT (newdecl)))
+ if (DECL_FUNCTION_TEMPLATE_P (olddecl)
+ || (DECL_FUNCTION_MEMBER_P (olddecl)
+  (/* grokfndecl passes member function templates too
+as FUNCTION_DECLs.  */
+ DECL_TEMPLATE_INFO (olddecl)
+ /* C++11 8.3.6/6.
+Default arguments for a member function of a class
+template shall be specified on the initial declaration
+of the member function within the class template.  */
+ || CLASSTYPE_TEMPLATE_INFO (CP_DECL_CONTEXT (olddecl)
{
- /* C++11 8.3.6/6.
-Default arguments for a member function of a class template
-shall be specified on the initial declaration of the member
-function within the class template.  */
  for (; t2  t2 != void_list_node; t2 = TREE_CHAIN (t2))
if (TREE_PURPOSE (t2))
  {
Index: testsuite/g++.dg/other/default3.C
===
--- testsuite/g++.dg/other/default3.C   (revision 213504)
+++ testsuite/g++.dg/other/default3.C   (working copy)
@@ -25,7 +25,7 @@ templatetypename void g3(int, int);
 templatetypename void g3(int = 0, int);// { dg-error default }
 
 templatetypename void g4(int, int);
-templatetypename void g4(int = 0, int) {}  // { dg-error default  { 
xfail *-*-* } }
+templatetypename void g4(int = 0, int) {}  // { dg-error default }
 
 templatetypename void g5();
 templatetypename void g5(int = 0, int);// { dg-error default }
Index: testsuite/g++.dg/other/default9.C
===
--- testsuite/g++.dg/other/default9.C   (revision 0)
+++ testsuite/g++.dg/other/default9.C   (working copy)
@@ -0,0 +1,18 @@
+// PR c++/15339
+
+templatetypename void fun(int); 
+templatetypename void fun(int = 0);  // { dg-error default arguments }
+
+class A
+{
+  templatetypename void fun(int);
+};
+
+templatetypename void A::fun(int = 0) { } // { dg-error default arguments }
+
+class B
+{
+  void fun(int);
+};
+
+void B::fun(int = 0) { }


Re: FWD: Re: OpenACC subarray specifications in the GCC Fortran front end

2014-08-01 Thread Cesar Philippidis
On 08/01/2014 12:48 AM, Jakub Jelinek wrote:
 On Wed, Jul 23, 2014 at 05:42:32PM -0700, Cesar Philippidis wrote:
 Jakub, before your Fortran OpenMP 4 target changes, Ilmir had written the
 test case gcc/testsuite/gfortran.dg/gomp/map-1.f90 (based on his
 interpretation and implementation of OpenMP 4 target), which I have now
 amended with XFAILs and changed error messages -- anything in there that
 you'd like to see addressed for Fortran OpenMP 4 target?

 +  !$omp target map(j(5:4)) ! { dg-error Lower bound of OpenMP array 
 section in greater than upper  { xfail *-*-* } }
 +  !$omp end target

 I think this isn't an error in Fortran, if low bound is above upper bound,
 then it is considered a zero size array section.  Though supposedly for
 depend clause we might want to diagnose that.

 +  !$omp target map(aas) ! { dg-error The upper bound in the last 
 dimension must appear  { xfail *-*-* } }
 +  !$omp end target

 Assumed-size in map without array section would be indeed nice thing to
 diagnose.

 +  !$omp target map(tt%i) ! { dg-error Syntax error in OpenMP variable 
 list }
 +  !$omp end target ! { dg-bogus Unexpected !\\\$OMP END TARGET 
 statement  { xfail *-*-* } }

 Right now the parsing of !$omp directives in case of parsing error rejects
 the whole directive, perhaps it should be reconsidered unless it is a fatal
 error from which there is no easy way out.

 +  !$omp target map(tt%j(1)) ! { dg-bogus Syntax error in OpenMP variable 
 list  { xfail *-*-* } }
 +  !$omp end target ! { dg-bogus Unexpected !\\\$OMP END TARGET 
 statement  { xfail *-*-* } }
 +
 +  !$omp target map(tt%j(1:)) ! { dg-bogus Syntax error in OpenMP 
 variable list  { xfail *-*-* } }
 +  !$omp end target ! { dg-bogus Unexpected !\\\$OMP END TARGET 
 statement  { xfail *-*-* } }

 These two are pending resolution on omp-lang, I had exchanged a few mails
 about it, I think we shouldn't support those for consistency with the C/C++
 support, where tt.j[1] or tt.j[1:] and similar is explicitly invalid.

 Jakub, should I drop the map-1.f90 test?
 
 Not the whole testcase, just the problematic parts (or, just remove the
 dg-error/xfail or replace dg-bogus xfail with dg-error), for the j(5:4)
 and tt%j(1)/tt%j(1:) cases?

Thank you for the feedback. I've committed those changes to gomp-4_0-branch.

Cesar

2014-08-01  Cesar Philippidis  ce...@codesourcery.com

	gcc/testsuite/
	* gfortran.dg/gomp/map-1.f90 (test): Update error reporting.


diff --git a/gcc/testsuite/gfortran.dg/gomp/map-1.f90 b/gcc/testsuite/gfortran.dg/gomp/map-1.f90
index de96ed2..e4b8b86 100644
--- a/gcc/testsuite/gfortran.dg/gomp/map-1.f90
+++ b/gcc/testsuite/gfortran.dg/gomp/map-1.f90
@@ -45,7 +45,7 @@ subroutine test(aas)
   !$omp target map(j(0:)) ! { dg-warning out of bounds }
   !$omp end target
 
-  !$omp target map(j(5:4)) ! { dg-error Lower bound of OpenMP array section in greater than upper  { xfail *-*-* } }
+  !$omp target map(j(5:4))
   !$omp end target
 
   !$omp target map(j(5:))
@@ -93,16 +93,17 @@ subroutine test(aas)
   !$omp end target
 
   !$omp target map(tt%i) ! { dg-error Syntax error in OpenMP variable list }
-  !$omp end target ! { dg-bogus Unexpected !\\\$OMP END TARGET statement  { xfail *-*-* } }
+  !$omp end target ! { dg-error Unexpected !\\\$OMP END TARGET statement }
 
   !$omp target map(tt%j) ! { dg-error Syntax error in OpenMP variable list }
-  !$omp end target ! { dg-bogus Unexpected !\\\$OMP END TARGET statement  { xfail *-*-* } }
+  !$omp end target ! { dg-error Unexpected !\\\$OMP END TARGET statement }
 
-  !$omp target map(tt%j(1)) ! { dg-bogus Syntax error in OpenMP variable list  { xfail *-*-* } }
-  !$omp end target ! { dg-bogus Unexpected !\\\$OMP END TARGET statement  { xfail *-*-* } }
+  ! broken test
+  !$omp target map(tt%j(1)) ! { dg-error Syntax error in OpenMP variable list }
+  !$omp end target ! { dg-error Unexpected !\\\$OMP END TARGET statement }
 
-  !$omp target map(tt%j(1:)) ! { dg-bogus Syntax error in OpenMP variable list  { xfail *-*-* } }
-  !$omp end target ! { dg-bogus Unexpected !\\\$OMP END TARGET statement  { xfail *-*-* } }
+  !$omp target map(tt%j(1:)) ! { dg-error Syntax error in OpenMP variable list }
+  !$omp end target ! { dg-error Unexpected !\\\$OMP END TARGET statement }
 
   !$omp target map(tp) ! { dg-error THREADPRIVATE object 'tp' in MAP clause }
   !$omp end target


Re: C++ PATCH for c++/60417 (explicit ctor vs aggregate init)

2014-08-01 Thread Jason Merrill

On 03/04/2014 05:14 PM, Jason Merrill wrote:

In C++11, copy-list-initialization by explicit constructor is an error,
even for the default constructor.  But this combined with the change of
aggregate initialization to use {} for any missing initializers means
that well-formed C++03 code becomes ill-formed in C++11.  Until the
committee decides what to do about this, let's call the implicit
initializers direct-initialization.


...and for array initialization as well.

Tested x86_64-pc-linux-gnu, applying to trunk.


commit ef09581840cc49d85599a2a9f2c855d8c8b60d9f
Author: Jason Merrill ja...@redhat.com
Date:   Fri Aug 1 16:13:54 2014 -0400

	PR c++/60417
	* init.c (build_vec_init): Set CONSTRUCTOR_IS_DIRECT_INIT on
	init-list for trailing elements.
	* typeck2.c (process_init_constructor_array): Likewise.

diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index f8cae28..5bb3 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -3545,19 +3545,11 @@ build_vec_init (tree base, tree maxindex, tree init,
   try_block = begin_try_block ();
 }
 
-  /* If the initializer is {}, then all elements are initialized from {}.
- But for non-classes, that's the same as value-initialization.  */
+  bool empty_list = false;
   if (init  BRACE_ENCLOSED_INITIALIZER_P (init)
CONSTRUCTOR_NELTS (init) == 0)
-{
-  if (CLASS_TYPE_P (type))
-	/* Leave init alone.  */;
-  else
-	{
-	  init = NULL_TREE;
-	  explicit_value_init_p = true;
-	}
-}
+/* Skip over the handling of non-empty init lists.  */
+empty_list = true;
 
   /* Maybe pull out constant value when from_array? */
 
@@ -3677,14 +3669,8 @@ build_vec_init (tree base, tree maxindex, tree init,
 	vec_free (new_vec);
 	}
 
-  /* Any elements without explicit initializers get {}.  */
-  if (cxx_dialect = cxx11  AGGREGATE_TYPE_P (type))
-	init = build_constructor (init_list_type_node, NULL);
-  else
-	{
-	  init = NULL_TREE;
-	  explicit_value_init_p = true;
-	}
+  /* Any elements without explicit initializers get T{}.  */
+  empty_list = true;
 }
   else if (from_array)
 {
@@ -3699,6 +3685,26 @@ build_vec_init (tree base, tree maxindex, tree init,
 	}
 }
 
+  /* If the initializer is {}, then all elements are initialized from T{}.
+ But for non-classes, that's the same as value-initialization.  */
+  if (empty_list)
+{
+  if (cxx_dialect = cxx11  AGGREGATE_TYPE_P (type))
+	{
+	  if (BRACE_ENCLOSED_INITIALIZER_P (init)
+	   CONSTRUCTOR_NELTS (init) == 0)
+	/* Reuse it.  */;
+	  else
+	init = build_constructor (init_list_type_node, NULL);
+	  CONSTRUCTOR_IS_DIRECT_INIT (init) = true;
+	}
+  else
+	{
+	  init = NULL_TREE;
+	  explicit_value_init_p = true;
+	}
+}
+
   /* Now, default-initialize any remaining elements.  We don't need to
  do that if a) the type does not need constructing, or b) we've
  already initialized all the elements.
diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c
index 59a4760..20523fa 100644
--- a/gcc/cp/typeck2.c
+++ b/gcc/cp/typeck2.c
@@ -1239,8 +1239,9 @@ process_init_constructor_array (tree type, tree init,
 	  {
 	/* If this type needs constructors run for default-initialization,
 	   we can't rely on the back end to do it for us, so make the
-	   initialization explicit by list-initializing from {}.  */
+	   initialization explicit by list-initializing from T{}.  */
 	next = build_constructor (init_list_type_node, NULL);
+	CONSTRUCTOR_IS_DIRECT_INIT (next) = true;
 	next = massage_init_elt (TREE_TYPE (type), next, complain);
 	if (initializer_zerop (next))
 	  /* The default zero-initialization is fine for us; don't
diff --git a/gcc/testsuite/g++.dg/init/explicit2.C b/gcc/testsuite/g++.dg/init/explicit2.C
new file mode 100644
index 000..d1dbb39
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/explicit2.C
@@ -0,0 +1,8 @@
+// PR c++/60417
+
+struct A { explicit A(int = 0); };
+
+int main()
+{
+  A a[1] = { };
+}


libgo patch committed: Ignore small argv[0] for backtrace

2014-08-01 Thread Ian Lance Taylor
Reportedly in some cases Docker starts processes with argv[0] pointing
to an empty file.  That would cause libgo to pass that empty file to
libbacktrace, which would then fail to do any backtraces.  Everything
should work fine if libbacktrace falls back to /proc/self/exe.

This patch to libgo works around the problem by ignoring argv[0] if it
is a small file, or if stat fails.  This is not a perfect fix but it's
an unusual problem.

This is PR 61895.

Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline and 4.9 branch.

Ian

diff -r 3674ebeb1d40 libgo/runtime/go-caller.c
--- a/libgo/runtime/go-caller.c	Sun Jul 20 12:24:14 2014 -0700
+++ b/libgo/runtime/go-caller.c	Fri Aug 01 17:41:05 2014 -0700
@@ -7,6 +7,9 @@
 /* Implement runtime.Caller.  */
 
 #include stdint.h
+#include sys/types.h
+#include sys/stat.h
+#include unistd.h
 
 #include backtrace.h
 
@@ -99,6 +102,7 @@
   if (back_state == NULL)
 {
   const char *filename;
+  struct stat s;
 
   filename = (const char *) runtime_progname ();
 
@@ -108,6 +112,14 @@
   if (__builtin_strchr (filename, '/') == NULL)
 	filename = NULL;
 
+  /* If the file is small, then it's not the real executable.
+	 This is specifically to deal with Docker, which uses a bogus
+	 argv[0] (http://gcc.gnu.org/PR61895).  It would be nice to
+	 have a better check for whether this file is the real
+	 executable.  */
+  if (stat (filename, s)  0 || s.st_size  1024)
+	filename = NULL;
+
   back_state = backtrace_create_state (filename, 1, error_callback, NULL);
 }
   runtime_unlock (back_state_lock);


Re: [C++ Patch] PR 15339

2014-08-01 Thread Paolo Carlini

... the below seems better to me:
1- FUNCTION_DECLs and TEMPLATE_DECLs are handled in their own places.
2- When I tweaked default3.C I didn't notice at first the real reason 
for the existing xfail: in such case we didn't give the 
check_default_args diagnostics. Restored in the below.
3- By handling TEMPLATE_DECLs separately, we can give the 
check_redeclaration_no_default_args permerror and the check_default_args 
error in a consistent order, that is the former before the latter, which 
makes most sense to me (also matches the clang order).


Thanks!
Paolo.

//
/cp
2014-08-01  Paolo Carlini  paolo.carl...@oracle.com

PR c++/15339
* decl.c (check_redeclaration_no_default_args): New.
(duplicate_decls): Use it, handle default arguments
in redeclarations of function templates.

/testsuite
2014-08-01  Paolo Carlini  paolo.carl...@oracle.com

PR c++/15339
* g++.dg/other/default9.C: New.
* g++.dg/other/default10.C: Likewise.
* g++.dg/other/default3.C: Remove xfail.
Index: cp/decl.c
===
--- cp/decl.c   (revision 213505)
+++ cp/decl.c   (working copy)
@@ -1236,6 +1236,27 @@ validate_constexpr_redeclaration (tree old_decl, t
   return true;
 }
 
+/* DECL is a redeclaration of a function or function template.  If
+   it does have default arguments issue a diagnostic.  Note: this
+   function is used to enforce the requirements in C++11 8.3.6 about
+   no default arguments in redeclarations.  */
+
+static void
+check_redeclaration_no_default_args (tree decl)
+{
+  gcc_assert (DECL_DECLARES_FUNCTION_P (decl));
+
+  for (tree t = FUNCTION_FIRST_USER_PARMTYPE (decl);
+   t  t != void_list_node; t = TREE_CHAIN (t))
+if (TREE_PURPOSE (t))
+  {
+   permerror (input_location,
+  redeclaration of %q#D may not have default 
+  arguments, decl);
+   return;
+  }
+}
+
 #define GNU_INLINE_P(fn) (DECL_DECLARED_INLINE_P (fn)  \
   lookup_attribute (gnu_inline,\
   DECL_ATTRIBUTES (fn)))
@@ -1706,28 +1727,23 @@ duplicate_decls (tree newdecl, tree olddecl, bool
;
   else if (TREE_CODE (olddecl) == FUNCTION_DECL)
{
- tree t1 = FUNCTION_FIRST_USER_PARMTYPE (olddecl);
- tree t2 = FUNCTION_FIRST_USER_PARMTYPE (newdecl);
- int i = 1;
-
- if (DECL_FUNCTION_MEMBER_P (newdecl)
-  CLASSTYPE_TEMPLATE_INFO (CP_DECL_CONTEXT (newdecl)))
-   {
- /* C++11 8.3.6/6.
-Default arguments for a member function of a class template
-shall be specified on the initial declaration of the member
-function within the class template.  */
- for (; t2  t2 != void_list_node; t2 = TREE_CHAIN (t2))
-   if (TREE_PURPOSE (t2))
- {
-   permerror (input_location,
-  redeclaration of %q#D may not have default 
-  arguments, newdecl);
-   break;
- }
-   }
+ /* Note: free functions, as TEMPLATE_DECLs, are handled below.  */
+ if (DECL_FUNCTION_MEMBER_P (olddecl)
+  (/* grokfndecl passes member function templates too
+as FUNCTION_DECLs.  */
+ DECL_TEMPLATE_INFO (olddecl)
+ /* C++11 8.3.6/6.
+Default arguments for a member function of a class
+template shall be specified on the initial declaration
+of the member function within the class template.  */
+ || CLASSTYPE_TEMPLATE_INFO (CP_DECL_CONTEXT (olddecl
+   check_redeclaration_no_default_args (newdecl);
  else
{
+ tree t1 = FUNCTION_FIRST_USER_PARMTYPE (olddecl);
+ tree t2 = FUNCTION_FIRST_USER_PARMTYPE (newdecl);
+ int i = 1;
+
  for (; t1  t1 != void_list_node;
   t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2), i++)
if (TREE_PURPOSE (t1)  TREE_PURPOSE (t2))
@@ -1864,6 +1880,12 @@ duplicate_decls (tree newdecl, tree olddecl, bool
 
   if (DECL_FUNCTION_TEMPLATE_P (newdecl))
{
+ /* Per C++11 8.3.6/4, default arguments cannot be added in later
+declarations of a function template.  */
+ check_redeclaration_no_default_args (newdecl);
+
+ check_default_args (newdecl);
+
  if (GNU_INLINE_P (old_result) != GNU_INLINE_P (new_result)
   DECL_INITIAL (new_result))
{
Index: testsuite/g++.dg/other/default10.C
===
--- testsuite/g++.dg/other/default10.C  (revision 0)
+++ testsuite/g++.dg/other/default10.C  (working copy)
@@ -0,0 +1,4 @@
+// PR c++/15339
+

  1   2   >