[Ada] Repair No_Strict_Aliasing configuration pragma

2015-01-07 Thread Arnaud Charlet
This reimplements the No_Strict_Aliasing configuration pragma, which didn't
work neither for private types nor for access-to-unconstrained-array types.

The following program must compile quietly with -O2:

pragma No_Strict_Aliasing;
with Q; use Q;

package P is

   type Ptr is private;

   type Arr is array (Natural range ) of Integer;

   type Array_Ptr is access all Arr;

   procedure Dummy;

private

   type Rec is record
  Data : Integer;
   end record;

   type Ptr is access Rec;

end P;
with Ada.Unchecked_Conversion;

package body P is

   function Any_Ptr_To_Map_Ptr is
  new Ada.Unchecked_Conversion (Q.T_ANY_PTR, Ptr);

   function Any_Array_Ptr_To_Map_Ptr is
  new Ada.Unchecked_Conversion (Q.T_ANY_ARRAY_PTR, Array_Ptr);

   procedure Dummy is begin null; end;

end P;
package Q is

   type T_BYTE is new INTEGER range 0 .. 255;
   for T_BYTE'size use 8;

   type T_ANY_PTR is access T_BYTE;

   type T_BYTE_ARRAY is array (Natural range ) of T_BYTE;

   type T_ANY_ARRAY_PTR is access T_BYTE_ARRAY;

end Q;

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

2015-01-07  Eric Botcazou  ebotca...@adacore.com

* sem_ch3.adb (Analyze_Full_Type_Declaration): Do not
automatically set No_Strict_Aliasing on access types.
* fe.h (No_Strict_Aliasing_CP): Declare.
* gcc-interface/trans.c (gigi): Force flag_strict_aliasing to 0 if
No_Strict_Aliasing_CP is set.

Index: sem_ch3.adb
===
--- sem_ch3.adb (revision 219285)
+++ sem_ch3.adb (working copy)
@@ -2657,12 +2657,6 @@
   Add_RACW_Features (Def_Id);
end if;
 
-   --  Set no strict aliasing flag if config pragma seen
-
-   if Opt.No_Strict_Aliasing then
-  Set_No_Strict_Aliasing (Base_Type (Def_Id));
-   end if;
-
 when N_Array_Type_Definition =
Array_Type_Declaration (T, Def);
 
Index: fe.h
===
--- fe.h(revision 219191)
+++ fe.h(working copy)
@@ -176,6 +176,7 @@
 #define Generate_SCO_Instance_Tableopt__generate_sco_instance_table
 #define GNAT_Mode  opt__gnat_mode
 #define List_Representation_Info   opt__list_representation_info
+#define No_Strict_Aliasing_CP  opt__no_strict_aliasing
 
 typedef enum {Setjmp_Longjmp, Back_End_Exceptions} Exception_Mechanism_Type;
 
@@ -187,6 +188,7 @@
 extern Boolean Generate_SCO_Instance_Table;
 extern Boolean GNAT_Mode;
 extern Int List_Representation_Info;
+extern Boolean No_Strict_Aliasing_CP;
 
 /* restrict: */
 
Index: gcc-interface/trans.c
===
--- gcc-interface/trans.c   (revision 219286)
+++ gcc-interface/trans.c   (working copy)
@@ -667,6 +667,10 @@
   /* Initialize the GCC support for FP operations.  */
   gnat_init_gcc_fp ();
 
+  /* Force -fno-strict-aliasing if the configuration pragma was seen.  */
+  if (No_Strict_Aliasing_CP)
+flag_strict_aliasing = 0;
+
   /* Now translate the compilation unit proper.  */
   Compilation_Unit_to_gnu (gnat_root);
 


[Ada] Disable wrapper for SPARK in the case of External Axiomatization

2015-01-07 Thread Arnaud Charlet
Usually a wrapper is generated in the case of a classwide type as actual of a
generic package. In Gnatprove_Mode, and when the generic has external
axiomatizations, This wrapper is not only useless but confuses gnatprove, so
it is disabled here.

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

2015-01-07  Johannes Kanig  ka...@adacore.com

* sem_ch8.adb (Analyze_Subprogram_Renaming) do
not build function wrapper in gnatprove mode when the package
is externally axiomatized.

Index: sem_ch8.adb
===
--- sem_ch8.adb (revision 219282)
+++ sem_ch8.adb (working copy)
@@ -2710,7 +2710,17 @@
  --  Check whether the renaming is for a defaulted actual subprogram
  --  with a class-wide actual.
 
- if CW_Actual and then Box_Present (Inst_Node) then
+ --  The class-wide wrapper is not needed when we are in
+ --  GNATprove_Mode and there is an external axiomatization on the
+ --  package.
+
+ if CW_Actual
+and then Box_Present (Inst_Node)
+and then not (GNATprove_Mode
+  and then
+  Present (Containing_Package_With_Ext_Axioms
+ (Formal_Spec)))
+ then
 Build_Class_Wide_Wrapper (New_S, Old_S);
 
  elsif Is_Entity_Name (Nam)


[Ada] gnatmake and gnatclean with projects are obsolete

2015-01-07 Thread Arnaud Charlet
A new warning is now issued when gnatmake or gnatclean sre invoke with -P
indicationg that it is now obsolete and that the support will be removed
in the next release.

Support for project files is an advanced feature that is no longer properly
supported by gnatmake, instead the proper support has been moved to the
gprbuild tool, which contains a separate, cleaner code base, and also
extra dependencies (e.g. on xmlada, and potentially gnatcoll in the future).

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

2015-01-07  Vincent Celier  cel...@adacore.com

* clean.adb (Gnatclean): Warn that 'gnatclean -P' is obsolete.
* make.adb (Initialize): Warn that 'gnatmake -P' is obsolete.

Index: make.adb
===
--- make.adb(revision 219191)
+++ make.adb(working copy)
@@ -6486,6 +6486,14 @@
  Make_Failed (-i and -D cannot be used simultaneously);
   end if;
 
+  --  Warn about 'gnatmake -P'
+
+  if Project_File_Name /= null then
+ Write_Line
+   (warning: gnatmake -P is obsolete and will not be available  
+in the next release. Use gprbuild instead.);
+  end if;
+
   --  If --subdirs= is specified, but not -P, this is equivalent to -D,
   --  except that the directory is created if it does not exist.
 
Index: clean.adb
===
--- clean.adb   (revision 219191)
+++ clean.adb   (working copy)
@@ -1383,6 +1383,14 @@
 
   if Project_File_Name /= null then
 
+ --  Warn about 'gnatclean -P'
+
+ if Project_File_Name /= null then
+Put_Line
+  (warning: gnatclean -P is obsolete and will not be available  
+   in the next release. Use gprclean instead.);
+ end if;
+
  --  A project file was specified by a -P switch
 
  if Opt.Verbose_Mode then


[Ada] Avoid incorrect warning on limited with that item is unreferenced

2015-01-07 Thread Arnaud Charlet
Under certain complex circumstances, a LIMITED WITH clause can result in
an incorrect warning that the with'ed item is not referenced, when in fact
it is referenced. No simple test is available.

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

2015-01-07  Robert Dewar  de...@adacore.com

* sem_warn.adb (Check_One_Unit): Guard against context item
with no Entity field.

Index: sem_warn.adb
===
--- sem_warn.adb(revision 219191)
+++ sem_warn.adb(working copy)
@@ -2350,6 +2350,13 @@
 if Nkind (Item) = N_With_Clause
   and then not Implicit_With (Item)
   and then In_Extended_Main_Source_Unit (Item)
+
+  --  Guard for no entity present. Not clear under what conditions
+  --  this happens, but it does occur, and since this is only a
+  --  warning, we just suppress the warning in this case.
+
+  and then Nkind (Name (Item)) in N_Has_Entity
+  and then Present (Entity (Name (Item)))
 then
Lunit := Entity (Name (Item));
 


[Ada] Fix bootstrapping on darwin9/10 (PR ada/64349).

2015-01-07 Thread Arnaud Charlet
Use _NSGetEnviron to get environment.

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

2015-01-07  Tristan Gingold  ging...@adacore.com

PR ada/64349
* env.c (__gnat_environ): Adjust for darwin9/darwin10.

Index: env.c
===
--- env.c   (revision 219191)
+++ env.c   (working copy)
@@ -44,6 +44,12 @@
 #include stdlib.h
 #endif
 
+#if defined (__APPLE__)  !defined (__arm__)
+/* On Darwin, _NSGetEnviron must be used for shared libraries; but it is not
+   available on iOS.  */
+#include crt_externs.h
+#endif
+
 #if defined (__vxworks)
   #if defined (__RTP__)
 /* On VxWorks 6 Real-Time process mode, environ is defined in unistd.h.  */
@@ -212,6 +218,8 @@
 #elif ! (defined (__vxworks))
   extern char **environ;
   return environ;
+#elif defined (__APPLE__)  !defined (__arm__)
+  return *_NSGetEnviron ();
 #else
   return environ;
 #endif


Re: [PATCH][SH] Check for 0 length with inlined strnlen builtin

2015-01-07 Thread Oleg Endo
On Tue, 2015-01-06 at 13:13 +0100, Christian Bruel wrote:
  Please use 'gen_cmpeqsi_t (len, const0_rtx)' for comparing a value
  against zero instead of the bit test insn.
 
 OK, also then OK to replace the other occurrences of the idiom for 
 coding consistency ? (not sure if I could commit this as obvious ?).

In the end the same tst reg,reg instruction will be generated, but
with one reg operand instead of two.  It might have some impact on the
register allocation in some cases.  If it passes testing, it's OK I
think.

Cheers,
Oleg



[Ada] disable some files for SPARK cross references

2015-01-07 Thread Arnaud Charlet
Some D files do not correspond to Ada units, and as such present no interest
for SPARK cross references. Skip these files, as printing their name may
require printing the full name with spaces, which is not handled in the code
doing I/O of SPARK cross references.

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

2015-01-07  Johannes Kanig  ka...@adacore.com

* lib-xref-spark_specific.adb (Collect_SPARK_Xrefs): Skip unneeded
cross ref files.

Index: lib-xref-spark_specific.adb
===
--- lib-xref-spark_specific.adb (revision 219191)
+++ lib-xref-spark_specific.adb (working copy)
@@ -889,10 +889,18 @@
 D2 := D1;
  end if;
 
- Add_SPARK_File
-   (Ubody = Sdep_Table (D1),
-Uspec = Sdep_Table (D2),
-Dspec = D2);
+ --  Some files do not correspond to Ada units, and as such present no
+ --  interest for SPARK cross references. Skip these files, as printing
+ --  their name may require printing the full name with spaces, which
+ --  is not handled in the code doing I/O of SPARK cross references.
+
+ if Present (Cunit_Entity (Sdep_Table (D1))) then
+Add_SPARK_File
+  (Ubody = Sdep_Table (D1),
+   Uspec = Sdep_Table (D2),
+   Dspec = D2);
+ end if;
+
  D1 := D2 + 1;
   end loop;
 


[Ada] Implement RT_Resolution properly

2015-01-07 Thread Arnaud Charlet
Previously RT_Resolution was returning a hard coded dummy value.
With this change we now use the relevant system call to compute the
clock resolution.

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

2015-01-07  Doug Rupp  r...@adacore.com

* s-osinte-mingw.ads (LARGE_INTEGR): New subtype.
(QueryPerformanceFrequency): New imported procedure.
* s-taprop-mingw.adb (RT_Resolution): Call above and return
resolution vice a hardcoded value.
* s-taprop-solaris.adb (RT_Resolution): Call clock_getres and return
resolution vice a hardcoded value.
* s-linux-android.ads (clockid_t): New subtype.
* s-osinte-aix.ads (clock_getres): New imported subprogram.
* s-osinte-android.ads (clock_getres): Likewise.
* s-osinte-freebsd.ads (clock_getres): Likewise.
* s-osinte-solaris-posix.ads (clock_getres): Likewise.
* s-osinte-darwin.ads (clock_getres): New subprogram.
* s-osinte-darwin.adb (clock_getres): New subprogram.
* thread.c (__gnat_clock_get_res) [__APPLE__]: New function.
* s-taprop-posix.adb (RT_Resolution): Call clock_getres to
calculate resolution vice hard coded value.

Index: s-linux-android.ads
===
--- s-linux-android.ads (revision 219191)
+++ s-linux-android.ads (working copy)
@@ -47,6 +47,7 @@
subtype longis Interfaces.C.long;
subtype suseconds_t is Interfaces.C.long;
subtype time_t  is Interfaces.C.long;
+   subtype clockid_t   is Interfaces.C.int;
 
type timespec is record
   tv_sec  : time_t;
Index: s-osinte-aix.ads
===
--- s-osinte-aix.ads(revision 219191)
+++ s-osinte-aix.ads(working copy)
@@ -206,6 +206,11 @@
   tp   : access timespec) return int;
pragma Import (C, clock_gettime, clock_gettime);
 
+   function clock_getres
+ (clock_id : clockid_t;
+  res  : access timespec) return int;
+   pragma Import (C, clock_getres, clock_getres);
+
function To_Duration (TS : timespec) return Duration;
pragma Inline (To_Duration);
 
Index: s-osinte-android.ads
===
--- s-osinte-android.ads(revision 219191)
+++ s-osinte-android.ads(working copy)
@@ -211,6 +211,11 @@
  (clock_id : clockid_t;
   tp   : access timespec) return int;
 
+   function clock_getres
+ (clock_id : clockid_t;
+  res  : access timespec) return int;
+   pragma Import (C, clock_getres, clock_getres);
+
function To_Duration (TS : timespec) return Duration;
pragma Inline (To_Duration);
 
Index: s-osinte-darwin.adb
===
--- s-osinte-darwin.adb (revision 219191)
+++ s-osinte-darwin.adb (working copy)
@@ -129,6 +129,36 @@
   return Result;
end clock_gettime;
 
+   --
+   -- clock_getres --
+   --
+
+   function clock_getres
+ (clock_id : clockid_t;
+  res  : access timespec) return int
+   is
+  pragma Unreferenced (clock_id);
+
+  --  Darwin Threads don't have clock_getres.
+
+  Nano   : constant := 10**9;
+  nsec   : int := 0;
+  Result : int := -1;
+
+  function clock_get_res return int;
+  pragma Import (C, clock_get_res, __gnat_clock_get_res);
+
+   begin
+  nsec := clock_get_res;
+  res.all := To_Timespec (Duration (0.0) + Duration (nsec) / Nano);
+
+  if nsec  0 then
+ Result := 0;
+  end if;
+
+  return Result;
+   end clock_getres;
+
-
-- sched_yield --
-
Index: s-osinte-darwin.ads
===
--- s-osinte-darwin.ads (revision 219191)
+++ s-osinte-darwin.ads (working copy)
@@ -189,6 +189,10 @@
  (clock_id : clockid_t;
   tp   : access timespec) return int;
 
+   function clock_getres
+ (clock_id : clockid_t;
+  res  : access timespec) return int;
+
function To_Duration (TS : timespec) return Duration;
pragma Inline (To_Duration);
 
Index: s-osinte-freebsd.ads
===
--- s-osinte-freebsd.ads(revision 219191)
+++ s-osinte-freebsd.ads(working copy)
@@ -202,6 +202,11 @@
 
type clockid_t is new int;
 
+   function clock_getres
+ (clock_id : clockid_t;
+  res  : access timespec) return int;
+   pragma Import (C, clock_getres, clock_getres);
+
function clock_gettime
  (clock_id : clockid_t;
   tp   : access timespec)
Index: s-osinte-mingw.ads
===
--- s-osinte-mingw.ads  (revision 219191)
+++ s-osinte-mingw.ads  (working copy)
@@ -53,6 +53,8 @@
subtype int  is Interfaces.C.int;
subtype long is Interfaces.C.long;
 
+   subtype LARGE_INTEGER is 

[Ada] Warn on suspicious Subprogram'Access

2015-01-07 Thread Arnaud Charlet
This patch adds a warning on certain occurrences of Subprogram'Access that
could cause an access-before-elaboration error.

The following example should give a warning when compiled with the -gnatw.f
switch:

% gcc -c -gnatw.f -gnatwe elab_acc.adb
elab_acc.ads:4:31: warning: Access attribute of F before body seen
elab_acc.ads:4:31: warning: possible Program_Error on later references
%

package Elab_Acc is
   function F return Integer;
   type Funcy is access function return Integer;
   F_Ptr : constant Funcy := F'Access;
   --  Calls to F_Ptr.all before F's body can cause an
   --  access-before-elaboration error.

end Elab_Acc;

package body Elab_Acc is

   function F return Integer is
   begin
  return 123;
   end F;

end Elab_Acc;

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

2015-01-07  Bob Duff  d...@adacore.com

* sem_elab.adb (Check_Internal_Call_Continue): Give a warning
for P'Access, where P is a subprogram in the same package as
the P'Access, and the P'Access is evaluated at elaboration
time, and occurs before the body of P. For example, X : T :=
P'Access; would allow a subsequent call to X.all to be an
access-before-elaboration error; hence the warning. This warning
is enabled by the -gnatw.f switch.
* opt.ads (Warn_On_Elab_Access): New flag for warning switch.
* warnsw.adb (Set_Dot_Warning_Switch): Set Warn_On_Elab_Access.
* gnat_ugn.texi: Document the new warning.

Index: gnat_ugn.texi
===
--- gnat_ugn.texi   (revision 219252)
+++ gnat_ugn.texi   (working copy)
@@ -5048,6 +5048,23 @@
 effect of warning on unreferenced entities other than subprogram
 formals.
 
+@item -gnatw.f
+@emph{Activate warnings on suspicious subprogram 'Access.}
+@cindex @option{-gnatw.f} (@command{gcc})
+This switch causes a warning to be generated if @code{P'Access} occurs
+in the same package where subprogram P is declared, and the
+@code{P'Access} is evaluated at elaboration time, and occurs before
+the body of P has been elaborated. For example, if we have
+@code{X : T := P'Access;}, then if X.all is subsequently called before
+the body of P is elaborated, it could cause
+access-before-elaboration. The default is that these warnings are not
+generated.
+
+@item -gnatw.F
+@emph{Suppress warnings on suspicious subprogram 'Access.}
+@cindex @option{-gnatw.F} (@command{gcc})
+This switch suppresses warnings for suspicious subprogram 'Access.
+
 @item -gnatwg
 @emph{Activate warnings on unrecognized pragmas.}
 @cindex @option{-gnatwg} (@command{gcc})
Index: warnsw.adb
===
--- warnsw.adb  (revision 219191)
+++ warnsw.adb  (working copy)
@@ -326,6 +326,12 @@
  when 'e' =
 All_Warnings (True);
 
+ when 'f' =
+Warn_On_Elab_Access := True;
+
+ when 'F' =
+Warn_On_Elab_Access := False;
+
  when 'g' =
 Set_GNAT_Mode_Warnings;
 
Index: sem_elab.adb
===
--- sem_elab.adb(revision 219191)
+++ sem_elab.adb(working copy)
@@ -1990,10 +1990,21 @@
   Inst_Case : constant Boolean := Nkind (N) in N_Generic_Instantiation;
 
begin
-  --  If not function or procedure call or instantiation, then ignore
-  --  call (this happens in some error cases and rewriting cases).
+  --  For P'Access, we want to warn if the -gnatw.f switch is set, and the
+  --  node comes from source.
 
-  if not Nkind_In (N, N_Function_Call, N_Procedure_Call_Statement)
+  if Nkind (N) = N_Attribute_Reference and then
+(not Warn_On_Elab_Access or else not Comes_From_Source (N))
+  then
+ return;
+
+  --  If not function or procedure call, instantiation, or 'Access, then
+  --  ignore call (this happens in some error cases and rewriting cases).
+
+  elsif not Nkind_In
+   (N, N_Function_Call,
+   N_Procedure_Call_Statement,
+   N_Attribute_Reference)
 and then not Inst_Case
   then
  return;
@@ -2001,7 +2012,7 @@
   --  Nothing to do if this is a call or instantiation that has already
   --  been found to be a sure ABE.
 
-  elsif ABE_Is_Certain (N) then
+  elsif Nkind (N) /= N_Attribute_Reference and then ABE_Is_Certain (N) then
  return;
 
   --  Nothing to do if errors already detected (avoid cascaded errors)
@@ -2323,7 +2334,7 @@
   --  Not that special case, warning and dynamic check is required
 
   --  If we have nothing in the call stack, then this is at the outer
-  --  level, and the ABE is bound to occur.
+  --  level, and the ABE is bound to occur, unless it's a 'Access.
 
   if Elab_Call.Last = 0 then
  Error_Msg_Warn := SPARK_Mode /= On;
@@ -2331,13 +2342,19 @@
 

Re: Housekeeping work in backends.html

2015-01-07 Thread Eric Botcazou
 the attached patch removes obsolete ports (c4x, m68hc11 and ms1), toggles
 the 'p' letter and adjust accordingly (only avr, fr30, m68k, mcore, rs6000
 and sh still use define_peephole) and removes trailing spaces.

This replaces 'a' with 'i' for multiple inheritance thunks and reuses 'a' for 
LRA by default (aarch64, arm, i386, mips, nds32, s390).  Applied.

-- 
Eric BotcazouIndex: backends.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/backends.html,v
retrieving revision 1.57
diff -u -p -r1.57 backends.html
--- backends.html	7 Jan 2015 08:44:30 -	1.57
+++ backends.html	7 Jan 2015 09:23:44 -
@@ -53,8 +53,9 @@ g   Port does not define TARGET_ASM_
 m   Port does not use define_constants.
 b   Port does not use '* ...' notation for output template code.
 d   Port does not use DFA scheduler descriptions.
-a   Port generates multiple inheritance thunks using
+i   Port generates multiple inheritance thunks using
 TARGET_ASM_OUTPUT_MI(_VCALL)_THUNK.
+a   Port uses LRA (by default, i.e. unless overridden by a switch).
 t   All insns either produce exactly one assembly instruction, or
 trigger a define_split.
 e   lt;archgt;-elf is not a supported target.
@@ -64,50 +65,50 @@ s   lt;archgt;-elf is the correct 
 
 pre
|  Characteristics
-Target | HMSLQNFICBD lqrcpfgmbdates
+---
-aarch64| Qqg   a  s
-alpha  |  ?? Q   Cqg b a e
-arc|  Bg   a
-arm|   a  s
+Target | HMSLQNFICBD lqrcpfgmbdiates
+---+
+aarch64| Qqg   ia  s
+alpha  |  ?? Q   Cqg b i  e
+arc|  Bg   i
+arm|   ia  s
 avr|L  FIl  cp g bd
-bfin   |   F   g   a
-c6x|   S CBg b a
-cr16   |L  F C g  d   s
-cris   |   F  B c  g bda  s
-epiphany   | C g b a  s
-fr30   | ??FI B  p gm d   s
-frv| ??   Ba  s
-h8300  |   FI   c  g  d   s
-i386   |   ? Qqa
-ia64   |   ? Q   Cqr   a
-iq2000 | ???   FICBgt
+bfin   |   F   g   i
+c6x|   S CBg b i
+cr16   |L  F C g  ds
+cris   |   F  B c  g bdi   s
+epiphany   | C g b i   s
+fr30   | ??FI B  p gm ds
+frv| ??   Bi   s
+h8300  |   FI   c  g  ds
+i386   |   ? Qqia
+ia64   |   ? Q   Cqr   i
+iq2000 | ???   FICBg t
 lm32   |   F   g b 
-m32c   |L  FIl g  d   s
-m32r   |   FI s
-m68k   |   ?cp a
-mcore  |  ?FIp gm s
-mep|   F C gt s
-microblaze | CB  bs
-mips   | Q   CB   qr b a  s
-mmix   | HM  Q   Cq  bda e
-mn10300| ?? c  g  s
-msp430 |L  FIl g  d   s
-nds32  |   F C a  s
+m32c   |L  FIl g  ds
+m32r   |   FI  s
+m68k   |   ?cp i
+mcore  |  ?FIp gm  s
+mep|   F C g t s
+microblaze | CB  b i   s
+mips   | Q   CB   qr b ia  s
+mmix   | HM  Q   Cq  bdi  e
+mn10300| ?? c  g   i   s
+msp430 |L  FIl g  ds
+nds32  |   F C ia  s
 nios2  |   S C   b 
-pa |   ? Q   CBD  qrm  a e
-pdp11  |L   ICqrc d  e
-rs6000 | Q   Cqr p a
-s390   |   ? Qqr   g b a e
-sh | Q   CB   qr p   b a
-sparc  | Q   CB   qr   a
-spu|   ? Q  *C g b 
-stormy16   | ???L  FIC D l  m da
-tilegx |   S Q   Cqg b a e
-tilepro|   S   F C g b a e
-v850   | ??FI   c  gm s
-visium |  Bg bs
-vax|  M?I   c da e
+pa |   ? Q   CBD  qrm  i  e
+pdp11  |L   ICqrc d   e
+rs6000 | Q   Cqr p i
+s390   |   ? Qqr   g b ia e
+sh | Q   CB   qr p   b i
+sparc  | Q   CB   qr   i
+spu|   ? Q  *C g b i
+stormy16   | ???L  FIC D l  m di
+tilegx |   S Q   Cqg b i  e
+tilepro|   S   F C g b i  e
+v850   | ??FI   c  gm  s
+visium |  Bg b s
+vax|  M?I   c di  e
 xtensa | C   b 
 /pre
 

Re: [PATCH] LRA: Fix caller-save store/restore instruction for large mode

2015-01-07 Thread Kito Cheng
Hi Jeff:

It's updated patch,bootstrapped and run regression tested on arm-eabi,
arm-none-linux-uclibcgnueabi, x86_64-unknown-linux-gnu and nds32le-elf
without introducing regression.

Thanks for your review :)

2015-01-07  Kito Cheng  k...@0xlab.org

PR target/64348
* lra-constraints.c (split_reg): Fix caller-save store/restore
instruction generation.
From b6a697ee5697b84082f6e619f4a435e6c750d695 Mon Sep 17 00:00:00 2001
From: Kito Cheng k...@andestech.com
Date: Thu, 29 May 2014 23:53:23 +0800
Subject: [PATCH] Fix caller-save store/restore instruction for large mode in
 lra

 - The original code assume store/restore will always have only
   one insn, it's will fail if you split in move pattern!!!
---
 gcc/lra-constraints.c  | 14 +++---
 gcc/testsuite/gcc.target/arm/pr64348.c | 89 ++
 2 files changed, 95 insertions(+), 8 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/arm/pr64348.c

diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
index 96b10a1..f8bc12f 100644
--- a/gcc/lra-constraints.c
+++ b/gcc/lra-constraints.c
@@ -4918,15 +4918,14 @@ split_reg (bool before_p, int original_regno, rtx_insn *insn,
   reg_renumber[REGNO (new_reg)] = hard_regno;
 }
   save = emit_spill_move (true, new_reg, original_reg);
-  if (NEXT_INSN (save) != NULL_RTX)
+  if (NEXT_INSN (save) != NULL_RTX  !call_save_p)
 {
-  lra_assert (! call_save_p);
   if (lra_dump_file != NULL)
 	{
 	  fprintf
 	(lra_dump_file,
-	 	  Rejecting split %d-%d resulting in  2 %s save insns:\n,
-	 original_regno, REGNO (new_reg), call_save_p ? call : );
+	 	  Rejecting split %d-%d resulting in  2 save insns:\n,
+	 original_regno, REGNO (new_reg));
 	  dump_rtl_slim (lra_dump_file, save, NULL, -1, 0);
 	  fprintf (lra_dump_file,
 		   	\n);
@@ -4934,15 +4933,14 @@ split_reg (bool before_p, int original_regno, rtx_insn *insn,
   return false;
 }
   restore = emit_spill_move (false, new_reg, original_reg);
-  if (NEXT_INSN (restore) != NULL_RTX)
+  if (NEXT_INSN (restore) != NULL_RTX  !call_save_p)
 {
-  lra_assert (! call_save_p);
   if (lra_dump_file != NULL)
 	{
 	  fprintf (lra_dump_file,
 		   	Rejecting split %d-%d 
-		   resulting in  2 %s restore insns:\n,
-		   original_regno, REGNO (new_reg), call_save_p ? call : );
+		   resulting in  2 restore insns:\n,
+		   original_regno, REGNO (new_reg));
 	  dump_rtl_slim (lra_dump_file, restore, NULL, -1, 0);
 	  fprintf (lra_dump_file,
 		   	\n);
diff --git a/gcc/testsuite/gcc.target/arm/pr64348.c b/gcc/testsuite/gcc.target/arm/pr64348.c
new file mode 100644
index 000..b949f35
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/pr64348.c
@@ -0,0 +1,89 @@
+/* { dg-do compile } */
+/* { dg-options -O3 -fPIC -marm -mcpu=cortex-a8 } */
+
+#define vector(elcount, type)  \
+__attribute__((vector_size((elcount)*sizeof(type type
+
+#define vidx(type, vec, idx) (*((type *) (vec) + idx))
+
+#define operl(a, b, op) (a op b)
+#define operr(a, b, op) (b op a)
+
+#define check(type, count, vec0, vec1, num, op, lr) \
+do {\
+int __i; \
+for (__i = 0; __i  count; __i++) {\
+if (vidx (type, vec1, __i) != oper##lr (num, vidx (type, vec0, __i), op)) \
+__builtin_abort (); \
+}\
+} while (0)
+
+#define veccompare(type, count, v0, v1) \
+do {\
+int __i; \
+for (__i = 0; __i  count; __i++) { \
+if (vidx (type, v0, __i) != vidx (type, v1, __i)) \
+__builtin_abort (); \
+} \
+} while (0)
+
+volatile int one = 1;
+
+int main (int argc, char *argv[]) {
+#define fvec_2 (vector(4, float)){2., 2., 2., 2.}
+#define dvec_2 (vector(2, double)){2., 2.}
+
+
+vector(8, short) v0 = {one, 1, 2, 3, 4, 5, 6, 7};
+vector(8, short) v1;
+
+vector(4, float) f0 = {1., 2., 3., 4.};
+vector(4, float) f1, f2;
+
+vector(2, double) d0 = {1., 2.};
+vector(2, double) d1, d2;
+
+
+
+v1 = 2 + v0;   check (short, 8, v0, v1, 2, +, l);
+v1 = 2 - v0;   check (short, 8, v0, v1, 2, -, l);
+v1 = 2 * v0;   check (short, 8, v0, v1, 2, *, l);
+v1 = 2 / v0;   check (short, 8, v0, v1, 2, /, l);
+v1 = 2 % v0;   check (short, 8, v0, v1, 2, %, l);
+v1 = 2 ^ v0;   check (short, 8, v0, v1, 2, ^, l);
+v1 = 2  v0;   check (short, 8, v0, v1, 2, , l);
+v1 = 2 | v0;   check (short, 8, v0, v1, 2, |, l);
+v1 = 2  v0;   check (short, 8, v0, v1, 2, , l);
+v1 = 2  v0;   check (short, 8, v0, v1, 2, , l);
+
+v1 = v0 + 2;   check (short, 8, v0, v1, 2, +, r);
+v1 = v0 - 2;   check (short, 8, v0, v1, 2, -, r);
+v1 = v0 * 2;   check (short, 8, v0, v1, 2, *, r);
+v1 = v0 / 2;   check (short, 8, v0, v1, 2, /, r);
+v1 = v0 % 2;   check (short, 8, v0, v1, 2, %, r);
+v1 = v0 ^ 2;   check (short, 8, v0, v1, 2, ^, r);
+v1 = v0  2;   check (short, 8, v0, v1, 2, , r);
+v1 = v0 | 2;   check (short, 

Re: Housekeeping work in backends.html

2015-01-07 Thread Eric Botcazou
 Xtensa is now supported by the QEMU, so probably question mark in its 'S'
 slot may be removed.

Done, thanks.

-- 
Eric Botcazou


Re: [PATCH] Fix sporadic failure in g++.dg/tsan/aligned_vs_unaligned_race.C

2015-01-07 Thread Jakub Jelinek
On Wed, Jan 07, 2015 at 08:17:34AM +0100, Bernd Edlinger wrote:
 
 On Tue, 6 Jan 2015 16:32:35, Mike Stump wrote:
 
  On Jan 6, 2015, at 3:22 PM, Bernd Edlinger bernd.edlin...@hotmail.de 
  wrote:
  Yes, I think too that it can't fail under these conditions.
 
  If you mean your version… A lot has been written on how to to make racy 
  code non-racy… I’d refer you to the literature on all the various solutions 
  people have found to date. I don’t think I’ve ever seen anyone claim that 
  affinity can be used to solve race conditions like this. Do you have a 
  pointer?
 
 
 no, I agree, the affinity would just lower the likelihood, as sleep does.
 The version with affinity is just disgusting, sorry to have posted it ;-).
 
 I meant your version, with step(1)/step(2) between the race. It is probably 
 bullet-proof.
 But the version with sleep is more realistic.  That is however just a matter 
 of taste...
 
 If we can agree to use your version, then all tests in g++.dg/tsan and
 c-c++-common/tsan that currently use sleep(1) should use your step function 
 instead.
 sleep_sync.c can use step but needs still to call sleep because it triggers 
 on the
 As if synchronized via sleep diagnostic.
 
 I don't know what to make of simple_race.c, which uses usleep, but uses
 a loop to repeat the race often. Maybe leave that one as a realistic test.

I'm fine with adding the no_sanitize_thread attribute, the patch LGTM, I
think we might even have a PR for that.

But I really don't like the busy waiting.  You essentially want something
like pthread_barrier_wait that libtsan isn't aware of, right?

As tsan is only supported on x86_64-linux (and in the future could be on
some other 64-bit linuxes), I wonder if we couldn't just simplify libgomp's
config/linux/bar* for that purpose - libtsan doesn't intercept syscall(3)
and doesn't intercept futex in particular, so we could have a busy waiting
free synchronization primitive.  Or another option is to just dlopen
libpthread.so.0 and dlsym pthread_barrier_wait in it and use that, that way
libtsan won't intercept it either.

Jakub


[Ada] Fix inconsistent diagnostics for support of Atomic aspect

2015-01-07 Thread Arnaud Charlet
This changes makes it so that the compiler issues the same diagnostics on
invalid bit-packed array types with atomic component whatever the origin
of the Atomic aspect.  For the following package:

package P is

  type Arr1 is array (1 .. 16) of Boolean;
  pragma Atomic_Components (Arr1);
  for Arr1'Component_Size use 1;

  type Arr2 is array (1 .. 16) of Boolean;
  pragma Atomic_Components (Arr2);
  pragma Pack (Arr2);

  type My_Boolean is new Boolean;
  pragma Atomic (My_Boolean);

  type Arr3 is array (1 .. 16) of My_Boolean;
  for Arr3'Component_Size use 1;

  type Arr4 is array (1 .. 16) of My_Boolean;
  pragma Pack (Arr4);

end P;

the compiler must issue the expected errors on Arr3 and Arr4:

 1. package P is
 2.
 3.   type Arr1 is array (1 .. 16) of Boolean;
 4.   pragma Atomic_Components (Arr1);
 5.   for Arr1'Component_Size use 1;
  |
 incorrect component size for atomic components
 only allowed value is 8

 6.
 7.   type Arr2 is array (1 .. 16) of Boolean;
 8.   pragma Atomic_Components (Arr2);
 9.   pragma Pack (Arr2);
  |
 cannot pack atomic components

10.
11.   type My_Boolean is new Boolean;
12.   pragma Atomic (My_Boolean);
13.
14.   type Arr3 is array (1 .. 16) of My_Boolean;
15.   for Arr3'Component_Size use 1;
  |
 incorrect component size for atomic components
 only allowed value is 8

16.
17.   type Arr4 is array (1 .. 16) of My_Boolean;
18.   pragma Pack (Arr4);
  |
 cannot pack atomic components

19.
20. end P;

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

2015-01-07  Eric Botcazou  ebotca...@adacore.com

* freeze.adb (Freeze_Array_Type): Apply same handling to Is_Atomic
component type as to Has_Atomic_Components type.  Remove useless
test on Is_Aliased component type.

Index: freeze.adb
===
--- freeze.adb  (revision 219280)
+++ freeze.adb  (working copy)
@@ -2431,12 +2431,12 @@
end if;
 end;
 
---  Check for Atomic_Components or Aliased with unsuitable packing
---  or explicit component size clause given.
+--  Check for Aliased or Atomic_Components/Atomic with unsuitable
+--  packing or explicit component size clause given.
 
-if (Has_Atomic_Components  (Arr)
+if (Has_Aliased_Components (Arr)
   or else
-Has_Aliased_Components (Arr))
+Has_Atomic_Components (Arr) or else Is_Atomic (Ctyp))
   and then
 (Has_Component_Size_Clause (Arr) or else Is_Packed (Arr))
 then
@@ -2503,13 +2503,10 @@
   then
  null;
 
-  elsif Has_Aliased_Components (Arr)
-or else Is_Aliased (Ctyp)
-  then
+  elsif Has_Aliased_Components (Arr) then
  Complain_CS (aliased);
 
-  elsif Has_Atomic_Components (Arr)
-or else Is_Atomic (Ctyp)
+  elsif Has_Atomic_Components (Arr) or else Is_Atomic (Ctyp)
   then
  Complain_CS (atomic);
   end if;


Re: Housekeeping work in backends.html

2015-01-07 Thread Eric Botcazou
 the attached patch removes obsolete ports (c4x, m68hc11 and ms1), toggles
 the 'p' letter and adjust accordingly (only avr, fr30, m68k, mcore, rs6000
 and sh still use define_peephole) and removes trailing spaces.

Same treatment for the 'd' letter, the ports that do not use DFA scheduler 
descriptions are a clear minority (avr, cr16, cris, fr30, h8300, m32c, mmix, 
msp430, pdp11, stormy16, vax).  Applied.

-- 
Eric BotcazouIndex: backends.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/backends.html,v
retrieving revision 1.56
diff -u -p -r1.56 backends.html
--- backends.html	7 Jan 2015 08:10:32 -	1.56
+++ backends.html	7 Jan 2015 08:37:40 -
@@ -52,7 +52,7 @@ f   Port does not define prologue an
 g   Port does not define TARGET_ASM_FUNCTION_(PRO|EPI)LOGUE.
 m   Port does not use define_constants.
 b   Port does not use '* ...' notation for output template code.
-d   Port uses DFA scheduler descriptions.
+d   Port does not use DFA scheduler descriptions.
 a   Port generates multiple inheritance thunks using
 TARGET_ASM_OUTPUT_MI(_VCALL)_THUNK.
 t   All insns either produce exactly one assembly instruction, or
@@ -66,49 +66,49 @@ s   lt;archgt;-elf is the correct 
|  Characteristics
 Target | HMSLQNFICBD lqrcpfgmbdates
 ---+---
-aarch64| Qqg  da  s
-alpha  |  ?? Q   Cqg bda e
-arc|  Bg  da
-arm|  da  s
-avr|L  FIl  cp g b
-bfin   |   F   g  da
-c6x|   S CBg bda
-cr16   |L  F C g  s
-cris   |   F  B c  g b a  s
-epiphany   | C g bda  s
-fr30   | ??FI B  p gm s
-frv| ??   B   da  s
-h8300  |   FI   c  g  s
-i386   |   ? Qq   da
-ia64   |   ? Q   Cqr  da
-iq2000 | ???   FICBg  d t
-lm32   |   F   g bd
-m32c   |L  FIl g  s
-m32r   |   FI d   s
+aarch64| Qqg   a  s
+alpha  |  ?? Q   Cqg b a e
+arc|  Bg   a
+arm|   a  s
+avr|L  FIl  cp g bd
+bfin   |   F   g   a
+c6x|   S CBg b a
+cr16   |L  F C g  d   s
+cris   |   F  B c  g bda  s
+epiphany   | C g b a  s
+fr30   | ??FI B  p gm d   s
+frv| ??   Ba  s
+h8300  |   FI   c  g  d   s
+i386   |   ? Qqa
+ia64   |   ? Q   Cqr   a
+iq2000 | ???   FICBgt
+lm32   |   F   g b 
+m32c   |L  FIl g  d   s
+m32r   |   FI s
 m68k   |   ?cp a
-mcore  |  ?FIp gm d   s
-mep|   F C g  d t s
-microblaze | CB  bd   s
-mips   | Q   CB   qr bda  s
-mmix   | HM  Q   Cq  b a e
+mcore  |  ?FIp gm s
+mep|   F C gt s
+microblaze | CB  bs
+mips   | Q   CB   qr b a  s
+mmix   | HM  Q   Cq  bda e
 mn10300| ?? c  g  s
-msp430 |L  FIl g  s
-nds32  |   F Cda  s
-nios2  |   S C   bd
-pa |   ? Q   CBD  qrm da e
-pdp11  |L   ICqrce
-rs6000 | Q   Cqr pda
-s390   |   ? Qqr   g bda e
-sh | Q   CB   qr p   bda
-sparc  | Q   CB   qr  da
-spu|   ? Q  *C g bd
-stormy16   | ???L  FIC D l  m  a
-tilegx |   S Q   Cqg bda e
-tilepro|   S   F C g bda e
-v850   | ??FI   c  gm d   s
-visium |  Bg bd   s
-vax|  M?I   c  a e
-xtensa | C   bd
+msp430 |L  FIl g  d   s
+nds32  |   F C a  s
+nios2  |   S C   b 
+pa |   ? Q   CBD  qrm  a e
+pdp11  |L   ICqrc d  e
+rs6000 | Q   Cqr p a
+s390   |   ? Qqr   g b a e
+sh | Q   CB   qr p   b a
+sparc  | Q   CB   qr   a
+spu|   ? Q  *C g b 
+stormy16   | ???L  FIC D l  m da
+tilegx |   S Q   Cqg b a e
+tilepro|   S   F C g b a e
+v850   | ??FI   c  gm s
+visium |  Bg bs
+vax|  M?I   c da e
+xtensa | C   b 
 /pre
 
 pFor AVR simulator, see a

[Ada] Implement new Restriction No_Use_Of_Entity

2015-01-07 Thread Arnaud Charlet
A new restriction No_Use_Of_Entity is implemented. The form of this is
pragma Restriction[_Warning]s (No_Use_Of_Entity = NAME), where NAME is
a fully qualified entity name. The effect is to forbid references to
this entity in the main unit, its spec, and any subunits.

The following is compiled with -gnatl -gnatj55

 1. pragma Restrictions
 2.   (No_Use_Of_Entity = Ada.Text_IO.Put_Line);
 3. with Ada.Text_IO; use Ada.Text_IO;
 4. procedure NUOE is
 5. begin
 6.Put (Hello);
 7.Put_Line (Hello_World!);
   |
 reference to Put_Line violates
restriction No_Use_Of_Entity at line 2

 8. end;

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

2015-01-07  Robert Dewar  de...@adacore.com

* restrict.adb (Check_Restriction_No_Use_Of_Attribute):
New procedure.
(OK_No_Use_Of_Entity_Name): New function.
(Set_Restriction_No_Use_Of_Entity): New procedure.
* restrict.ads (Check_Restriction_No_Use_Of_Attribute):
New procedure.
(OK_No_Use_Of_Entity_Name): New function.
(Set_Restriction_No_Use_Of_Entity): New procedure.
* sem_ch8.adb (Find_Direct_Name): Add check for violation of
No_Use_Of_Entity.
* sem_prag.adb (Process_Restrictions_Or_Restriction_Warnings):
Add processing for new restriction No_Use_Of_Entity.

Index: sem_prag.adb
===
--- sem_prag.adb(revision 219280)
+++ sem_prag.adb(working copy)
@@ -8895,13 +8895,26 @@
   Set_Restriction_No_Use_Of_Attribute (Expr, Warn);
end if;
 
---  Case of No_Use_Of_Entity = fully-qualified-name. Note that the
---  parser already processed this case commpletely, including error
---  checking and making an entry in the No_Use_Of_Entity table.
+--  Case of No_Use_Of_Entity = fully-qualified-name
 
 elsif Id = Name_No_Use_Of_Entity then
-   null;
 
+   --  Restriction is only recognized within a configuration
+   --  pragma file, or within a unit of the main extended
+   --  program. Note: the test for Main_Unit is needed to
+   --  properly include the case of configuration pragma files.
+
+   if Current_Sem_Unit = Main_Unit
+ or else In_Extended_Main_Source_Unit (N)
+   then
+  if not OK_No_Dependence_Unit_Name (Expr) then
+ Error_Msg_N (wrong form for entity name, Expr);
+  else
+ Set_Restriction_No_Use_Of_Entity
+   (Expr, Warn, No_Profile);
+  end if;
+   end if;
+
 --  Case of No_Use_Of_Pragma = pragma-identifier
 
 elsif Id = Name_No_Use_Of_Pragma then
@@ -8909,7 +8922,6 @@
  or else not Is_Pragma_Name (Chars (Expr))
then
   Error_Msg_N (unknown pragma name??, Expr);
-
else
   Set_Restriction_No_Use_Of_Pragma (Expr, Warn);
end if;
@@ -14941,7 +14953,7 @@
  -- Independent_Components --
  
 
- --  pragma Atomic_Components (array_or_record_LOCAL_NAME);
+ --  pragma Independent_Components (array_or_record_LOCAL_NAME);
 
  when Pragma_Independent_Components = Independent_Components : declare
 E_Id : Node_Id;
Index: restrict.adb
===
--- restrict.adb(revision 219191)
+++ restrict.adb(working copy)
@@ -128,6 +128,10 @@
--  real violation, serious vs non-serious, implicit vs explicit, the second
--  message giving the profile name if needed, and the location information.
 
+   function Same_Entity (E1, E2 : Node_Id) return Boolean;
+   --  Returns True iff E1 and E2 represent the same entity. Used for handling
+   --  of No_Use_Of_Entity = fully_qualified_ENTITY restriction case.
+
function Same_Unit (U1, U2 : Node_Id) return Boolean;
--  Returns True iff U1 and U2 represent the same library unit. Used for
--  handling of No_Dependence = Unit restriction case.
@@ -681,6 +685,98 @@
end Check_Restriction_No_Use_Of_Attribute;
 

+   -- Check_Restriction_No_Use_Of_Entity --
+   
+
+   procedure Check_Restriction_No_Use_Of_Entity (N : Node_Id) is
+   begin
+  --  Error defence (not clearly necessary, but better safe)
+
+  if No (Entity (N)) then
+ return;
+  end if;
+
+  --  If simple name of entity not flagged with Boolean2 flag, then there
+  --  cannot be a matching entry in the table, so skip the search.
+
+  if Get_Name_Table_Boolean2 (Chars (Entity (N))) = False then
+ return;
+  end if;
+
+  --  Restriction is 

Re: [PATCH] LRA: Fix caller-save store/restore instruction for large mode

2015-01-07 Thread Bin.Cheng
On Wed, Jan 7, 2015 at 4:03 PM, Kito Cheng kito.ch...@gmail.com wrote:
 Hi Jeff:

 It's updated patch,bootstrapped and run regression tested on arm-eabi,
 arm-none-linux-uclibcgnueabi, x86_64-unknown-linux-gnu and nds32le-elf
 without introducing regression.

 Thanks for your review :)

 2015-01-07  Kito Cheng  k...@0xlab.org

 PR target/64348
 * lra-constraints.c (split_reg): Fix caller-save store/restore
 instruction generation.

Thanks for fixing the issue.
The PR is against existing testcase failure
gcc.c-torture/execute/scal-to-vec1.c.  Unless we can create a new
case, there is no need to include same case twice I think?  Or we can
mention the PR number in the original test case?

Thanks,
bin


Re: [PATCH] Fix for PR ipa/64503

2015-01-07 Thread Uros Bizjak
On Tue, Jan 6, 2015 at 7:25 PM, Uros Bizjak ubiz...@gmail.com wrote:

 There's suggested patch for PR ipa/64503 that was tested on x86_64 and it
 works.
 I would like to ask Uros to test it on an aplha machine before we install
 the patch.

 Yes, this works for me on all IPA tests that were failing previously [1].

 I am restarting the bootstrap + regtest, it will take ~10 hours, but I
 don't expect any surprises there.

The patch was bootstrapped and regression tested on
alphaev68-linux-gnu [2] and everything was OK.

[2] https://gcc.gnu.org/ml/gcc-testresults/2015-01/msg00577.html

Thanks,
Uros.


[gomp4] Merge trunk r219183 (2015-01-05) into gomp-4_0-branch

2015-01-07 Thread Thomas Schwinge
Hi!

In 219294, I have committed a merge from trunk r219183 (2015-01-05) into
gomp-4_0-branch.


Grüße,
 Thomas


pgpmnzHE1mEp2.pgp
Description: PGP signature


[Ada] Invariant checks on view conversion

2015-01-07 Thread Arnaud Charlet
This patch inplements RM 7.3.2 (12/3): an invariant check must be applied to
the result of a view conversion if the type of the expression has invariants.

THe following must execute quietly:

   gnatmake -q -gnata t_package_test
   t_package_test

---
with Ada.Assertions; use Ada.Assertions;
with T_Ancestor_Package;
with T_Package;
procedure T_Package_Test is
   pragma Assertion_Policy (Check);
   My_T_Ancestor : constant T_Ancestor_Package.T_Ancestor := (A = 3);
   -- Initialise My_T with something valid otherwise may get an
   --  Assertion_Error here
   My_T : T_Package.T := T_Package.Init; -- Sets to (A = 1, B = 2)
begin
   -- Should make invariant false
   T_Ancestor_Package.T_Ancestor (My_T) := My_T_Ancestor;
   raise Program_Error;
exception
   when Assertion_Error = null;
end T_Package_Test;
---
package T_Ancestor_Package is
   pragma Assertion_Policy (Check);
   type T_Ancestor is tagged record
  A : Integer;
   end record;
   function Init return T_Ancestor;
end T_Ancestor_Package;
---
package body T_Ancestor_Package is
   pragma Assertion_Policy (Check);
   function Init return T_Ancestor is
   begin
  return (A = 1);
   end Init;
end T_Ancestor_Package;
---
with T_Ancestor_Package;
package T_Package is
   pragma Assertion_Policy (Check);
   type T is new T_Ancestor_Package.T_Ancestor with private
 with
   Type_Invariant = Increasing (T);
   function Increasing (My_T : in T) return
 Boolean;
   function Init return T;
private
   type T is new T_Ancestor_Package.T_Ancestor with record
  B : Integer;
   end record;
end T_Package;
---
package body T_Package is
   pragma Assertion_Policy (Check);
   function Increasing (My_T : in T) return Boolean is
   begin
  return My_T.B  My_T.A;
   end Increasing;
   function Init return T is
   begin
  return (T_Ancestor_Package.Init with B = 2);
   end Init;
end T_Package;

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

2015-01-07  Ed Schonberg  schonb...@adacore.com

* sem_ch5.adb (Analyze_Assignment): If left-hand side is a view
conversion and type of expression has invariant, apply invariant
check on expression.

Index: sem_ch5.adb
===
--- sem_ch5.adb (revision 219280)
+++ sem_ch5.adb (working copy)
@@ -764,6 +764,18 @@
  Set_Referenced_Modified (Lhs, Out_Param = False);
   end if;
 
+  --  RM 7.3.2 (12/3)  An assignment to a view conversion (from a type
+  --  to one of its ancestors) requires an invariant check. Apply check
+  --  only if expression comes from source, otherwise it will be applied
+  --  when value is assigned to source entity.
+
+  if Nkind (Lhs) = N_Type_Conversion
+and then Has_Invariants (Etype (Expression (Lhs)))
+and then Comes_From_Source (Expression (Lhs))
+  then
+ Insert_After (N, Make_Invariant_Call (Expression (Lhs)));
+  end if;
+
   --  Final step. If left side is an entity, then we may be able to reset
   --  the current tracked values to new safe values. We only have something
   --  to do if the left side is an entity name, and expansion has not


Re: [PATCHv3][PING] New check and updates in check_GNU_style script

2015-01-07 Thread Mantas Mikaitis

On 26/12/14 06:46, Yury Gribov wrote:

On 12/19/2014 11:14 AM, Yury Gribov wrote:

Hi all,

Attached patch adds new check (all blocks of 8 spaces are replaced with
tabs) to contrib/check_GNU_style.sh. It also changes the script to allow
reading patches from stdin and strengthens the Dot, space, space, new
sentence. check.

Is this ok to commit?

Ping.


Hi,

I for one find this patch very useful in the automated code review
application I have made.

Seeing that this was pinged 2 times and that I see this patch as adding useful 
functionality I would like to
promote reviewing this.

Thank you,
Mantas M.








Re: [PATCH] Fix for PR ipa/64503

2015-01-07 Thread Martin Liška

On 01/07/2015 11:55 AM, Uros Bizjak wrote:

On Tue, Jan 6, 2015 at 7:25 PM, Uros Bizjak ubiz...@gmail.com wrote:


There's suggested patch for PR ipa/64503 that was tested on x86_64 and it
works.
I would like to ask Uros to test it on an aplha machine before we install
the patch.


Yes, this works for me on all IPA tests that were failing previously [1].

I am restarting the bootstrap + regtest, it will take ~10 hours, but I
don't expect any surprises there.


The patch was bootstrapped and regression tested on
alphaev68-linux-gnu [2] and everything was OK.


Hi.

Thanks for testing. May I take this as approval of the patch.
I don't know, if you have a permission to accept my patch ;)

Thanks,
Martin



[2] https://gcc.gnu.org/ml/gcc-testresults/2015-01/msg00577.html

Thanks,
Uros.





RE: [PATCH] Fix sporadic failure in g++.dg/tsan/aligned_vs_unaligned_race.C

2015-01-07 Thread Bernd Edlinger

On Wed, 7 Jan 2015 09:23:39, Jakub Jelinek wrote:

 But I really don't like the busy waiting. You essentially want something
 like pthread_barrier_wait that libtsan isn't aware of, right?


Yes.


 As tsan is only supported on x86_64-linux (and in the future could be on
 some other 64-bit linuxes), I wonder if we couldn't just simplify libgomp's
 config/linux/bar* for that purpose - libtsan doesn't intercept syscall(3)
 and doesn't intercept futex in particular, so we could have a busy waiting
 free synchronization primitive. Or another option is to just dlopen
 libpthread.so.0 and dlsym pthread_barrier_wait in it and use that, that way
 libtsan won't intercept it either.



That would be the honey pot.  But unfortunately I can't reach it.


I tried this,

cat barrier.h
#include dlfcn.h

static pthread_barrier_t barrier;

static int (*barrier_wait)(pthread_barrier_t *);

__attribute__((constructor(101)))
void barrier_init()
{
  pthread_barrier_init (barrier, NULL, 2);
  barrier_wait = (int (*)(pthread_barrier_t *))
 dlsym (dlopen (pthread.so.0, RTLD_NOW), 
pthread_barrier_wait);
}


But dlsym gives me only a pointer to the tsan-interceptor.


Bernd.

  

Re: [PATCH] Fix for PR ipa/64503

2015-01-07 Thread Uros Bizjak
Hello!

 There's suggested patch for PR ipa/64503 that was tested on x86_64 and it 
 works.
 I would like to ask Uros to test it on an aplha machine before we install 
 the patch.

 Yes, this works for me on all IPA tests that were failing previously [1].

 I am restarting the bootstrap + regtest, it will take ~10 hours, but I
 don't expect any surprises there.

 The patch was bootstrapped and regression tested on
 alphaev68-linux-gnu [2] and everything was OK.

 Thanks for testing. May I take this as approval of the patch.
 I don't know, if you have a permission to accept my patch ;)

Unfortunately, I have no approval power here. Luckilly, I know someone
who has ;)

Uros.


[PATCH][ARM][4.9]Backport Fix definition of __ARM_SIZEOF_WCHAR_T

2015-01-07 Thread Renlin Li

Hi all,

This is a backport patch for 
https://gcc.gnu.org/viewcvs/gcc?view=revisionrevision=213864


arm-none-eabi regression test has been done, no new issues.
Okay for branch 4.9?

gcc/ChangeLog

Fix PR target/61413
Backport from mainline.

2014-08-12 Ramana Radhakrishnan ramana.radhakrish...@arm.com

PR target/61413
* config/arm/arm.h (TARGET_CPU_CPP_BUILTINS): Fix definition
of __ARM_SIZEOF_WCHAR_T.

diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h
index c0f2184..2eb 100644
--- a/gcc/config/arm/arm.h
+++ b/gcc/config/arm/arm.h
@@ -74,8 +74,8 @@ extern char arm_arch_name[];
 	builtin_define_with_int_value (\
 	  __ARM_SIZEOF_MINIMAL_ENUM,\
 	  flag_short_enums ? 1 : 4);\
-	builtin_define_with_int_value (\
-	  __ARM_SIZEOF_WCHAR_T, WCHAR_TYPE_SIZE);		\
+	builtin_define_type_sizeof (__ARM_SIZEOF_WCHAR_T,	\
+wchar_type_node);		\
 	if (TARGET_ARM_ARCH_PROFILE)\
 	  builtin_define_with_int_value (			\
 	__ARM_ARCH_PROFILE, TARGET_ARM_ARCH_PROFILE);	\

[libatomic PATCH] [PING] Fix libatomic behavior for big endian toolchain

2015-01-07 Thread Shiva Chen
PING

https://gcc.gnu.org/ml/gcc-patches/2014-10/msg01763.html

2014-10-17 Shiva Chen shiva0...@gmail.com

Fix libatomic behavior for big endian toolchain
* cas_n.c: Fix shift amount for big endian toolchain
* config/arm/exch_n.c: Fix shift amount for big endian toolchain
* exch_n.c: Fix shift amount for big endian toolchain
* fop_n.c: Fix shift amount for big endian toolchain


Shiva


RFC: C++ PATCH to do bounds sanitation for VLA initialization

2015-01-07 Thread Jason Merrill
My recent patch to remove the C++ VLA semantics that didn't make it into 
C++14 missed a couple of spots.  While I was looking at that I noticed 
that we weren't sanitizing VLA initialization, which we ought to do; 
this patch implements that.  Marek, does my choice of VLA|BOUNDS make 
sense to you?


Tested x86_64-pc-linux-gnu.
commit 0beea6f184261c0948894ee54af27cd58ce452aa
Author: Jason Merrill ja...@redhat.com
Date:   Wed Jan 7 17:10:18 2015 -0500

	* init.c (build_vec_init): Call ubsan_instrument_bounds to check
	whether an initializer-list is too big for a VLA.
	(throw_bad_array_length): Remove.
	* cp-tree.h: Remove prototype.

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 2afa531..77f2b5b 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -5574,7 +5574,6 @@ extern tree get_nsdmi(tree, bool);
 extern tree build_offset_ref			(tree, tree, bool,
 		 tsubst_flags_t);
 extern tree throw_bad_array_new_length		(void);
-extern tree throw_bad_array_length		(void);
 extern tree build_new(vectree, va_gc **, tree, tree,
 		 vectree, va_gc **, int,
  tsubst_flags_t);
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index a5ac11c..ebc09a5 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3.  If not see
 #include target.h
 #include gimplify.h
 #include wide-int.h
+#include c-family/c-ubsan.h
 
 static bool begin_init_stmts (tree *, tree *);
 static tree finish_init_stmts (bool, tree, tree);
@@ -2241,20 +2242,6 @@ throw_bad_array_new_length (void)
   return build_cxx_call (fn, 0, NULL, tf_warning_or_error);
 }
 
-/* Call __cxa_bad_array_length to indicate that there were too many
-   initializers.  */
-
-tree
-throw_bad_array_length (void)
-{
-  tree fn = get_identifier (__cxa_throw_bad_array_length);
-  if (!get_global_value_if_present (fn, fn))
-fn = push_throw_library_fn (fn, build_function_type_list (void_type_node,
-			  NULL_TREE));
-
-  return build_cxx_call (fn, 0, NULL, tf_warning_or_error);
-}
-
 /* Generate code for a new-expression, including calling the operator
new function, initializing the object, and, if an exception occurs
during construction, cleaning up.  The arguments are as for
@@ -3419,7 +3406,6 @@ build_vec_init (tree base, tree maxindex, tree init,
   tree obase = base;
   bool xvalue = false;
   bool errors = false;
-  tree length_check = NULL_TREE;
 
   if (TREE_CODE (atype) == ARRAY_TYPE  TYPE_DOMAIN (atype))
 maxindex = array_type_nelts (atype);
@@ -3440,12 +3426,9 @@ build_vec_init (tree base, tree maxindex, tree init,
 
   /* If we have a braced-init-list, make sure that the array
  is big enough for all the initializers.  */
-  if (init  TREE_CODE (init) == CONSTRUCTOR
-   CONSTRUCTOR_NELTS (init)  0
-   !TREE_CONSTANT (maxindex)
-   flag_exceptions)
-length_check = fold_build2 (LT_EXPR, boolean_type_node, maxindex,
-size_int (CONSTRUCTOR_NELTS (init) - 1));
+  bool length_check = (init  TREE_CODE (init) == CONSTRUCTOR
+		CONSTRUCTOR_NELTS (init)  0
+		!TREE_CONSTANT (maxindex));
 
   if (init
TREE_CODE (atype) == ARRAY_TYPE
@@ -3468,10 +3451,6 @@ build_vec_init (tree base, tree maxindex, tree init,
   if (BRACE_ENCLOSED_INITIALIZER_P (init))
 	init = digest_init (atype, init, complain);
   stmt_expr = build2 (INIT_EXPR, atype, base, init);
-  if (length_check)
-	stmt_expr = build3 (COND_EXPR, atype, length_check,
-			throw_bad_array_length (),
-			stmt_expr);
   return stmt_expr;
 }
 
@@ -3582,11 +3561,30 @@ build_vec_init (tree base, tree maxindex, tree init,
 
   if (length_check)
 	{
-	  tree throw_call;
-	  throw_call = throw_bad_array_new_length ();
-	  length_check = build3 (COND_EXPR, void_type_node, length_check,
- throw_call, void_node);
-	  finish_expr_stmt (length_check);
+	  tree nelts = size_int (CONSTRUCTOR_NELTS (init) - 1);
+	  if (TREE_CODE (atype) != ARRAY_TYPE)
+	{
+	  if (flag_exceptions)
+		{
+		  tree c = fold_build2 (LT_EXPR, boolean_type_node, iterator,
+	nelts);
+		  c = build3 (COND_EXPR, void_type_node, c,
+			  throw_bad_array_new_length (), void_node);
+		  finish_expr_stmt (c);
+		}
+	  /* Don't check an array new when -fno-exceptions.  */
+	}
+	  else if (flag_sanitize  (SANITIZE_VLA | SANITIZE_BOUNDS)
+		current_function_decl
+		!lookup_attribute (no_sanitize_undefined,
+	 DECL_ATTRIBUTES
+	 (current_function_decl)))
+	{
+	  /* Make sure the last element of the initializer is in bounds. */
+	  finish_expr_stmt
+		(ubsan_instrument_bounds
+		 (input_location, obase, nelts, /*ignore_off_by_one*/false));
+	}
 	}
 
   if (try_const)
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index c30efe3..1141c5b 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -5628,9 +5628,7 @@ call into a diagnostics message call instead.  When reaching the
 

[patch] Fix warning during libstdc++ build

2015-01-07 Thread Jonathan Wakely

This fixes a -Wc++14-compat warning in the new libsupc++/del_ops.cc
file that defines the C++14 sized deallocation function.

Tested x86_64-linux, committed to trunk.

commit 9236910f087450f43ce80d696737e9ecd96bb1ef
Author: Jonathan Wakely jwak...@redhat.com
Date:   Tue Jan 6 17:30:21 2015 +

	* libsupc++/Makefile.am: Compile del_ops.cc as C++14.
	* libsupc++/Makefile.in: Regenerate.

diff --git a/libstdc++-v3/libsupc++/Makefile.am b/libstdc++-v3/libsupc++/Makefile.am
index 06e56b6..aace1a6 100644
--- a/libstdc++-v3/libsupc++/Makefile.am
+++ b/libstdc++-v3/libsupc++/Makefile.am
@@ -177,6 +177,12 @@ new_opnt.lo: new_opnt.cc
 new_opnt.o: new_opnt.cc
 	$(CXXCOMPILE) -std=gnu++11 -c $
 
+# Use special rules for the C++14 sources so that the proper flags are passed.
+del_ops.lo: del_ops.cc
+	$(LTCXXCOMPILE) -std=gnu++14 -Wno-sized-deallocation -c $
+del_ops.o: del_ops.cc
+	$(CXXCOMPILE) -std=gnu++14 -Wno-sized-deallocation -c $
+
 # AM_CXXFLAGS needs to be in each subdirectory so that it can be
 # modified in a per-library or per-sub-library way.  Need to manually
 # set this option because CONFIG_CXXFLAGS has to be after
diff --git a/libstdc++-v3/libsupc++/Makefile.in b/libstdc++-v3/libsupc++/Makefile.in
index 9a1d725..50fee54 100644
--- a/libstdc++-v3/libsupc++/Makefile.in
+++ b/libstdc++-v3/libsupc++/Makefile.in
@@ -870,6 +870,12 @@ new_opnt.lo: new_opnt.cc
 new_opnt.o: new_opnt.cc
 	$(CXXCOMPILE) -std=gnu++11 -c $
 
+# Use special rules for the C++14 sources so that the proper flags are passed.
+del_ops.lo: del_ops.cc
+	$(LTCXXCOMPILE) -std=gnu++14 -Wno-sized-deallocation -c $
+del_ops.o: del_ops.cc
+	$(CXXCOMPILE) -std=gnu++14 -Wno-sized-deallocation -c $
+
 install-stdHEADERS: $(std_HEADERS)
 	@$(NORMAL_INSTALL)
 	$(mkinstalldirs) $(DESTDIR)$(stddir)


RE: [PATCH] Fix sporadic failure in g++.dg/tsan/aligned_vs_unaligned_race.C

2015-01-07 Thread Bernd Edlinger

On Wed, 7 Jan 2015 19:32:16, Jakub Jelinek wrote:
 I am however not sure if I can always use -ldl or have to use some 
 target-dependencies here.

 libsanitizer always puts
 -lpthread -ldl -lm
 into libsanitizer.spec, so I'd say it should be safe and you shouldn't even
 need -ldl in dg-additional-options, as merely linking with -fsanitize=thread
 should link -ldl in.


I need -ldl otherwise this happens:

FAIL: g++.dg/tsan/aligned_vs_unaligned_race.C   -O0  (test for excess errors)
Excess errors:
/home/ed/gnu/install/x86_64-unknown-linux-gnu/bin/ld: /tmp/ccW6IHbj.o: 
undefined reference to symbol 'dlsym@@GLIBC_2.2.5'
/lib/x86_64-linux-gnu/libdl.so.2: error adding symbols: DSO missing from 
command line


 --- barrier.h(revision 0)
 +++ barrier.h(working copy)

 I think better to name it tsan_barrier.h or otherwise make it
 clear what this is for.


Yes. I'll call it tsan_barrier.h and add a comment.

 @@ -0,0 +1,12 @@
 +#include dlfcn.h
 +
 +static __typeof(pthread_barrier_wait) *barrier_wait;
 +
 +static
 +void barrier_init (pthread_barrier_t *barrier)

 And, I'd add unsigned count argument here, and pass it through
 pthread_barrier_init, just in case you need more than 2 threads
 in some test.


done.

 Also, what do you need sched.h for?


Oops ... Thanks for your help.

Here is a new patch, that uses this method on all tsan tests,
which seem to depend on sleep(1), and which have unstable results
because of that.

Successfully tested multiple times with:

make check-gcc-c check-gcc-c++ RUNTESTFLAGS=tsan.exp=*


OK for trunk?


Thanks
Bernd.

  testsuite/ChangeLog:
2015-01-07  Bernd Edlinger  bernd.edlin...@hotmail.de

* c-c++-common/tsan/tsan_barrier.h: New.
* c-c++-common/tsan/atomic_stack.c: Reworked to not depend on sleep.
* c-c++-common/tsan/bitfield_race.c: Likewise.
* c-c++-common/tsan/fd_pipe_race.c: Likewise.
* c-c++-common/tsan/mutexset1.c: Likewise.
* c-c++-common/tsan/race_on_barrier.c: Likewise.
* c-c++-common/tsan/race_on_mutex.c: Likewise.
* c-c++-common/tsan/race_on_mutex2.c: Likewise.
* c-c++-common/tsan/simple_race.c: Likewise.
* c-c++-common/tsan/simple_stack.c: Likewise.
* c-c++-common/tsan/sleep_sync.c: Likewise.
* c-c++-common/tsan/tiny_race.c: Likewise.
* c-c++-common/tsan/tls_race.c: Likewise.
* c-c++-common/tsan/write_in_reader_lock.c: Likewise.
* g++.dg/tsan/aligned_vs_unaligned_race.C: Likewise.
* g++.dg/tsan/atomic_free.C: Likewise.
* g++.dg/tsan/atomic_free2.C: Likewise.
* g++.dg/tsan/cond_race.C: Likewise.
* g++.dg/tsan/tsan_barrier.h: Copied from c-c++-common/tsan. 



patch-tsan-tests.diff
Description: Binary data


Re: [gofrontend-dev] [PATCH 1/2, libgo] Add reflection support to gccgo for ppc64, ppc64le in gcc 4.9

2015-01-07 Thread Michael Hudson-Doyle
Ian Lance Taylor i...@golang.org writes:

 On Wed, Jan 7, 2015 at 9:26 AM, Lynn A. Boger
 labo...@linux.vnet.ibm.com wrote:

 In libgo/go/reflect/makefunc.go, calls to MakeFunc, makeMethodValue and
 makeValueMethod will panic if called when GOARCH is ppc64 or ppc64le.

 Right, I'm just saying that almost no code actually does that.  I just
 tried a web search and found no uses other than examples of how to use
 it.  I'm sure there are a few, but not many.

There is a somewhat hidden one in Docker:

https://github.com/docker/docker/blob/master/api/client/cli.go#L64

(it is also possible to patch docker to do this differently, of course).

Cheers,
mwh


pgpdSphHFvTaL.pgp
Description: PGP signature


[PATCH, committed] jit: Add checking for dereference of void *

2015-01-07 Thread David Malcolm
Reject attempts to dereference a void *, otherwise we get an ICE
 deep inside gimplification.

Committed to trunk as r219333.

FWIW, I ran into this as part of experiments at writing a libgccjit
backend for PyPy; see
  https://bitbucket.org/pypy/pypy/branch/libgccjit-backend

In particular, the testcase is a simplified version of a buggy
version of what became:
  
https://bitbucket.org/pypy/pypy/commits/72cda48c154f1bcefec8b5db7c7a84d542c52938

gcc/jit/ChangeLog:
* jit-recording.h (gcc::jit::recording::type::is_void): New
virtual function.
(gcc::jit::recording::memento_of_get_type::is_void): New
function, overriding default implementation.
* libgccjit.c (gcc_jit_rvalue_dereference): Verify that
the underlying type is not void.

gcc/testsuite/ChangeLog:
* jit.dg/test-error-dereferencing-void-ptr.c: New test case.
---
 gcc/jit/jit-recording.h|  2 +
 gcc/jit/libgccjit.c|  7 ++
 .../jit.dg/test-error-dereferencing-void-ptr.c | 96 ++
 3 files changed, 105 insertions(+)
 create mode 100644 gcc/testsuite/jit.dg/test-error-dereferencing-void-ptr.c

diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h
index 3734e9a..9034e11 100644
--- a/gcc/jit/jit-recording.h
+++ b/gcc/jit/jit-recording.h
@@ -443,6 +443,7 @@ public:
   virtual bool is_bool () const = 0;
   virtual type *is_pointer () = 0;
   virtual type *is_array () = 0;
+  virtual bool is_void () const { return false; }
 
   bool is_numeric () const
   {
@@ -494,6 +495,7 @@ public:
   bool is_bool () const;
   type *is_pointer () { return dereference (); }
   type *is_array () { return NULL; }
+  bool is_void () const { return m_kind == GCC_JIT_TYPE_VOID; }
 
 public:
   void replay_into (replayer *r);
diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
index 6853bb0..99b2d56 100644
--- a/gcc/jit/libgccjit.c
+++ b/gcc/jit/libgccjit.c
@@ -1664,6 +1664,13 @@ gcc_jit_rvalue_dereference (gcc_jit_rvalue *rvalue,
 rvalue-get_debug_string (),
 rvalue-get_type ()-get_debug_string ());
 
+  RETURN_NULL_IF_FAIL_PRINTF2 (
+!underlying_type-is_void (),
+rvalue-m_ctxt, loc,
+dereference of void pointer %s (type: %s),
+rvalue-get_debug_string (),
+rvalue-get_type ()-get_debug_string ());
+
   return (gcc_jit_lvalue *)rvalue-dereference (loc);
 }
 
diff --git a/gcc/testsuite/jit.dg/test-error-dereferencing-void-ptr.c 
b/gcc/testsuite/jit.dg/test-error-dereferencing-void-ptr.c
new file mode 100644
index 000..a813f67
--- /dev/null
+++ b/gcc/testsuite/jit.dg/test-error-dereferencing-void-ptr.c
@@ -0,0 +1,96 @@
+#include libgccjit.h
+#include harness.h
+
+void
+create_code (gcc_jit_context *ctxt, void *user_data)
+{
+  /* Replay of API calls for ctxt.  */
+  gcc_jit_type *type_long_long =
+gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_LONG_LONG);
+  gcc_jit_type *type_void =
+gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID);
+  gcc_jit_type *type_void_ptr =
+gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID_PTR);
+  gcc_jit_field *field_u_signed =
+gcc_jit_context_new_field (ctxt,
+  NULL, /* gcc_jit_location *loc */
+  type_long_long, /* gcc_jit_type *type, */
+  u_signed); /* const char *name */
+  gcc_jit_field *field_u_ptr =
+gcc_jit_context_new_field (ctxt,
+  NULL, /* gcc_jit_location *loc */
+  type_void_ptr, /* gcc_jit_type *type, */
+  u_ptr); /* const char *name */
+  gcc_jit_field *fields_for_union_any[2] = {
+field_u_signed,
+field_u_ptr,
+  };
+  gcc_jit_type *union_any =
+gcc_jit_context_new_union_type (ctxt,
+   NULL, /* gcc_jit_location *loc */
+   any, /* const char *name */
+   2, /* int num_fields */
+   fields_for_union_any);
+  gcc_jit_function *func =
+gcc_jit_context_new_function (ctxt, /* gcc_jit_context *ctxt */
+ NULL, /* gcc_jit_location *loc */
+ GCC_JIT_FUNCTION_EXPORTED,
+ type_void, /* gcc_jit_type *return_type */
+ anonloop_0, /* const char *name */
+ 0, /* int num_params */
+ NULL, /* gcc_jit_param **params */
+ 0); /* int is_variadic */
+  gcc_jit_block *block_initial =
+gcc_jit_function_new_block (func, initial);
+
+  gcc_jit_lvalue *local_tmp =
+gcc_jit_function_new_local (func, /* gcc_jit_function *func */
+   NULL, /* gcc_jit_location *loc */
+   union_any, /* gcc_jit_type *type */
+   tmp); /* const char *name */
+
+  /* 

Re: [gofrontend-dev] [PATCH 1/2, libgo] Add reflection support to gccgo for ppc64, ppc64le in gcc 4.9

2015-01-07 Thread Ian Lance Taylor
On Wed, Jan 7, 2015 at 4:39 PM, Michael Hudson-Doyle
michael.hud...@canonical.com wrote:
 Ian Lance Taylor i...@golang.org writes:

 On Wed, Jan 7, 2015 at 9:26 AM, Lynn A. Boger
 labo...@linux.vnet.ibm.com wrote:

 In libgo/go/reflect/makefunc.go, calls to MakeFunc, makeMethodValue and
 makeValueMethod will panic if called when GOARCH is ppc64 or ppc64le.

 Right, I'm just saying that almost no code actually does that.  I just
 tried a web search and found no uses other than examples of how to use
 it.  I'm sure there are a few, but not many.

 There is a somewhat hidden one in Docker:

 https://github.com/docker/docker/blob/master/api/client/cli.go#L64

 (it is also possible to patch docker to do this differently, of course).

Ah, so that is why it matters.

Perhaps you could talk Docker into replace the return statement with

return func(a ...string) error {
return 
method.CallSlice([]reflect.Value{reflect.ValueOf(a)})[0].Interface().(error)
}, true

It would probably be just as efficient.

Ian


[PATCH, committed] API extension: add GCC_JIT_UNARY_OP_ABS to enum gcc_jit_unary_op

2015-01-07 Thread David Malcolm
This adds GCC_JIT_UNARY_OP_ABS to the end of enum gcc_jit_unary_op,
and so should not change ABI.

Takes jit.sum from:
  # of expected passes   6121
to:
  # of expected passes   6196

Committed to trunk as r219321.

gcc/jit/ChangeLog:
* docs/topics/expressions.rst (Unary Operations): Add
GCC_JIT_UNARY_OP_ABS.
* jit-playback.c (gcc::jit::playback::context::new_unary_op):
Likewise.
* jit-recording.c (unary_op_strings): Likewise.
* libgccjit.c (gcc_jit_context_new_unary_op): Update checking
of op to reflect addition of GCC_JIT_UNARY_OP_ABS.
* libgccjit.h (enum gcc_jit_unary_op): Add GCC_JIT_UNARY_OP_ABS.
* docs/_build/texinfo/libgccjit.texi: Regenerate.

gcc/testsuite/ChangeLog:
* jit.dg/test-expressions.c (make_tests_of_unary_ops): Add test of
GCC_JIT_UNARY_OP_ABS.
(verify_unary_ops): Likewise.
---
 gcc/jit/docs/topics/expressions.rst | 11 +++
 gcc/jit/jit-playback.c  |  4 
 gcc/jit/jit-recording.c |  1 +
 gcc/jit/libgccjit.c |  2 +-
 gcc/jit/libgccjit.h |  8 +++-
 gcc/testsuite/jit.dg/test-expressions.c | 13 +
 6 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/gcc/jit/docs/topics/expressions.rst 
b/gcc/jit/docs/topics/expressions.rst
index 1cf9641..72a1085 100644
--- a/gcc/jit/docs/topics/expressions.rst
+++ b/gcc/jit/docs/topics/expressions.rst
@@ -137,6 +137,7 @@ Unary Operation C equivalent
 :c:macro:`GCC_JIT_UNARY_OP_MINUS`   `-(EXPR)`
 :c:macro:`GCC_JIT_UNARY_OP_BITWISE_NEGATE`  `~(EXPR)`
 :c:macro:`GCC_JIT_UNARY_OP_LOGICAL_NEGATE`  `!(EXPR)`
+:c:macro:`GCC_JIT_UNARY_OP_ABS` `abs (EXPR)`
 ==  
 
 .. c:macro:: GCC_JIT_UNARY_OP_MINUS
@@ -170,6 +171,16 @@ Unary Operation C equivalent
 
 in C.
 
+.. c:macro:: GCC_JIT_UNARY_OP_ABS
+
+Absolute value of an arithmetic expression; analogous to:
+
+.. code-block:: c
+
+abs (EXPR)
+
+in C.
+
 Binary Operations
 *
 
diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
index cf42e5a..013ee0f 100644
--- a/gcc/jit/jit-playback.c
+++ b/gcc/jit/jit-playback.c
@@ -615,6 +615,10 @@ new_unary_op (location *loc,
   if (loc)
set_tree_location (inner_result, loc);
   return new rvalue (this, inner_result);
+
+case GCC_JIT_UNARY_OP_ABS:
+  inner_op = ABS_EXPR;
+  break;
 }
 
   inner_result = build1 (inner_op,
diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
index d228274..dc7a7fb 100644
--- a/gcc/jit/jit-recording.c
+++ b/gcc/jit/jit-recording.c
@@ -2797,6 +2797,7 @@ static const char * const unary_op_strings[] = {
   -, /* GCC_JIT_UNARY_OP_MINUS */
   ~, /* GCC_JIT_UNARY_OP_BITWISE_NEGATE */
   !, /* GCC_JIT_UNARY_OP_LOGICAL_NEGATE */
+  abs , /* GCC_JIT_UNARY_OP_ABS */
 };
 
 recording::string *
diff --git a/gcc/jit/libgccjit.c b/gcc/jit/libgccjit.c
index bd0ae91..6853bb0 100644
--- a/gcc/jit/libgccjit.c
+++ b/gcc/jit/libgccjit.c
@@ -1180,7 +1180,7 @@ gcc_jit_context_new_unary_op (gcc_jit_context *ctxt,
   /* LOC can be NULL.  */
   RETURN_NULL_IF_FAIL_PRINTF1 (
 (op = GCC_JIT_UNARY_OP_MINUS
-  op = GCC_JIT_UNARY_OP_LOGICAL_NEGATE),
+  op = GCC_JIT_UNARY_OP_ABS),
 ctxt, loc,
 unrecognized value for enum gcc_jit_unary_op: %i,
 op);
diff --git a/gcc/jit/libgccjit.h b/gcc/jit/libgccjit.h
index e89635c..2049795 100644
--- a/gcc/jit/libgccjit.h
+++ b/gcc/jit/libgccjit.h
@@ -649,7 +649,13 @@ enum gcc_jit_unary_op
   /* Logical negation of an arithmetic or pointer value; analogous to:
!(EXPR)
  in C.  */
-  GCC_JIT_UNARY_OP_LOGICAL_NEGATE
+  GCC_JIT_UNARY_OP_LOGICAL_NEGATE,
+
+  /* Absolute value of an arithmetic expression; analogous to:
+   abs (EXPR)
+ in C.  */
+  GCC_JIT_UNARY_OP_ABS
+
 };
 
 extern gcc_jit_rvalue *
diff --git a/gcc/testsuite/jit.dg/test-expressions.c 
b/gcc/testsuite/jit.dg/test-expressions.c
index 87abb76..7e33b56 100644
--- a/gcc/testsuite/jit.dg/test-expressions.c
+++ b/gcc/testsuite/jit.dg/test-expressions.c
@@ -73,6 +73,12 @@ make_tests_of_unary_ops (gcc_jit_context *ctxt)
   GCC_JIT_UNARY_OP_LOGICAL_NEGATE,
   test_UNARY_OP_LOGICAL_NEGATE_on_int),
 !(a));
+  CHECK_STRING_VALUE (
+make_test_of_unary_op (ctxt,
+  int_type,
+  GCC_JIT_UNARY_OP_ABS,
+  test_UNARY_OP_ABS_on_int),
+abs (a));
 }
 
 static void
@@ -104,6 +110,13 @@ verify_unary_ops (gcc_jit_result *result)
   CHECK_VALUE (test_UNARY_OP_LOGICAL_NEGATE_on_int (42), 0);
   CHECK_VALUE (test_UNARY_OP_LOGICAL_NEGATE_on_int (-5), 0);
 
+  test_fn test_UNARY_OP_ABS_on_int =
+(test_fn)gcc_jit_result_get_code (result,
+ test_UNARY_OP_ABS_on_int);
+  

[C++ Patch] PR 60753

2015-01-07 Thread Paolo Carlini

Hi,

this is an accepts-invalid issue about an explicit specialization 
redeclared deleted. AFAICS, the problem is that start_decl sets 
DECL_DELETED_FN on the fndecl too late, that is, *after* calling 
grokdeclarator, whereas we want to have it set by the time the latter 
calls grokfndecl, because then the problem can be diagnosed by 
duplicate_decls (called by register_specialization via 
check_explicit_specialization). The below solves the issue by passing 
down the information about SD_DELETED from grokdeclator to grokfndecl.


Tested x86_64-linux.

Thanks,
Paolo.

///
/cp
2015-01-07  Paolo Carlini  paolo.carl...@oracle.com

PR c++/60753
* decl.c (grokfndecl): Add bool parameter.
(grokdeclarator): Adjust calls.
(start_decl): Don't set DECL_DELETED_FN here.

/testsuite
2015-01-07  Paolo Carlini  paolo.carl...@oracle.com

PR c++/60753
* g++.dg/cpp0x/deleted10.C: New.
Index: cp/decl.c
===
--- cp/decl.c   (revision 219318)
+++ cp/decl.c   (working copy)
@@ -4631,27 +4631,16 @@ start_decl (const cp_declarator *declarator,
   if (context != global_namespace)
 *pushed_scope_p = push_scope (context);
 
-  if (initialized)
-/* Is it valid for this decl to have an initializer at all?
-   If not, set INITIALIZED to zero, which will indirectly
-   tell `cp_finish_decl' to ignore the initializer once it is parsed.  */
-switch (TREE_CODE (decl))
-  {
-  case TYPE_DECL:
-   error (typedef %qD is initialized (use decltype instead), decl);
-   return error_mark_node;
+  /* Is it valid for this decl to have an initializer at all?
+ If not, set INITIALIZED to zero, which will indirectly
+ tell `cp_finish_decl' to ignore the initializer once it is parsed.  */
+  if (initialized
+   TREE_CODE (decl) == TYPE_DECL)
+{
+  error (typedef %qD is initialized (use decltype instead), decl);
+  return error_mark_node;
+}
 
-  case FUNCTION_DECL:
-   if (initialized == SD_DELETED)
- /* We'll handle the rest of the semantics later, but we need to
-set this now so it's visible to duplicate_decls.  */
- DECL_DELETED_FN (decl) = 1;
-   break;
-
-  default:
-   break;
-  }
-
   if (initialized)
 {
   if (! toplevel_bindings_p ()
@@ -7630,6 +7619,7 @@ grokfndecl (tree ctype,
int friendp,
int publicp,
int inlinep,
+   bool deletedp,
special_function_kind sfk,
bool funcdef_flag,
int template_count,
@@ -7768,6 +7758,9 @@ grokfndecl (tree ctype,
   DECL_CONTEXT (decl) = ctype;
 }
 
+  if (deletedp)
+DECL_DELETED_FN (decl) = 1;
+
   if (ctype)
 {
   DECL_CONTEXT (decl) = ctype;
@@ -10756,7 +10749,7 @@ grokdeclarator (const cp_declarator *declarator,
   virtualp, flags, memfn_quals, rqual, raises,
   friendp ? -1 : 0, friendp, publicp,
inlinep | (2 * constexpr_p),
-  sfk,
+  initialized == SD_DELETED, sfk,
   funcdef_flag, template_count, in_namespace,
   attrlist, declarator-id_loc);
 decl = set_virt_specifiers (decl, virt_specifiers);
@@ -10978,7 +10971,8 @@ grokdeclarator (const cp_declarator *declarator,
decl = grokfndecl (ctype, type, original_name, parms, unqualified_id,
   virtualp, flags, memfn_quals, rqual, raises,
   1, friendp,
-  publicp, inlinep | (2 * constexpr_p), sfk,
+  publicp, inlinep | (2 * constexpr_p),
+  initialized == SD_DELETED, sfk,
funcdef_flag,
   template_count, in_namespace, attrlist,
   declarator-id_loc);
Index: testsuite/g++.dg/cpp0x/deleted10.C
===
--- testsuite/g++.dg/cpp0x/deleted10.C  (revision 0)
+++ testsuite/g++.dg/cpp0x/deleted10.C  (working copy)
@@ -0,0 +1,15 @@
+// PR c++/60753
+// { dg-do compile { target c++11 } }
+
+templateclass T void foo (T);
+
+template void fooint (int);
+template void fooint (int) = delete; // { dg-error deleted }
+
+struct S
+{
+  templateclass T void bar (T);
+};
+
+template void S::barint (int);
+template void S::barint (int) = delete;  // { dg-error deleted }


[PATCH, committed] Add test of handling arithmetic-overflow from JIT

2015-01-07 Thread David Malcolm
New testcase to verify that libgccjit client code can handle arithmeti
overflow.

This testcase brings jit.sum from:
  # of expected passes5158
to:
  # of expected passes6121

Committed to trunk as r219320.

FWIW my motivation for this testcase was due to implementing
INT_*_OVF operations within an experimental backend for PyPy I'm
hacking on:
  https://bitbucket.org/pypy/pypy/branch/libgccjit-backend
where I hope to use libgccjit within PyPy's JIT for turning traced
loops into machine code; the commit in question there was:
 
https://bitbucket.org/pypy/pypy/commits/dfab06318973a8b8a5393708519269280dab395e

gcc/testsuite/ChangeLog:
* jit.dg/test-arith-overflow.c: New test case.
* jit.dg/all-non-failing-tests.h: Add test-arith-overflow.c.
* jit.dg/test-combination.c (create_code): Likewise.
(verify_code): Likewise.
* jit.dg/test-threads.c (testcases): Likewise.
---
 gcc/testsuite/jit.dg/all-non-failing-tests.h |   7 +
 gcc/testsuite/jit.dg/test-arith-overflow.c   | 223 +++
 gcc/testsuite/jit.dg/test-combination.c  |   2 +
 gcc/testsuite/jit.dg/test-threads.c  |   3 +
 4 files changed, 235 insertions(+)
 create mode 100644 gcc/testsuite/jit.dg/test-arith-overflow.c

diff --git a/gcc/testsuite/jit.dg/all-non-failing-tests.h 
b/gcc/testsuite/jit.dg/all-non-failing-tests.h
index 10d7199..beb3d13 100644
--- a/gcc/testsuite/jit.dg/all-non-failing-tests.h
+++ b/gcc/testsuite/jit.dg/all-non-failing-tests.h
@@ -22,6 +22,13 @@
 #undef create_code
 #undef verify_code
 
+/* test-arith-overflow.c */
+#define create_code create_code_arith_overflow
+#define verify_code verify_code_arith_overflow
+#include test-arith-overflow.c
+#undef create_code
+#undef verify_code
+
 /* test-array-as-pointer.c */
 #define create_code create_code_array_as_pointer
 #define verify_code verify_code_array_as_pointer
diff --git a/gcc/testsuite/jit.dg/test-arith-overflow.c 
b/gcc/testsuite/jit.dg/test-arith-overflow.c
new file mode 100644
index 000..8d130b2
--- /dev/null
+++ b/gcc/testsuite/jit.dg/test-arith-overflow.c
@@ -0,0 +1,223 @@
+#include stdlib.h
+#include stdio.h
+#include string.h
+#include limits.h
+
+#include libgccjit.h
+
+#include harness.h
+
+static void
+create_overflow_fn (gcc_jit_context *ctxt,
+   gcc_jit_type *type,
+   const char *funcname,
+   const char *builtin_name)
+{
+  /* Create the equivalent of this C:
+
+   int
+   test_overflow_T_OP (T x, T y, int *ovf)
+   {
+T result;
+result = x OP y;
+*ovf = ...; // did overflow happen?
+return result;
+   }
+
+  */
+  gcc_jit_type *t_bool =
+gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_BOOL);
+  gcc_jit_type *t_bool_star =
+gcc_jit_type_get_pointer (t_bool);
+
+  gcc_jit_param *x =
+gcc_jit_context_new_param (
+  ctxt,
+  NULL,
+  type, x);
+  gcc_jit_param *y =
+gcc_jit_context_new_param (
+  ctxt,
+  NULL,
+  type, y);
+  gcc_jit_param *ovf =
+gcc_jit_context_new_param (
+  ctxt,
+  NULL,
+  t_bool_star, ovf);
+  gcc_jit_param *params[3] = {x, y, ovf};
+
+  gcc_jit_function *func =
+gcc_jit_context_new_function (ctxt,
+ NULL,
+ GCC_JIT_FUNCTION_EXPORTED,
+ type,
+ funcname,
+ 3, params, 0);
+
+  gcc_jit_lvalue *result =
+gcc_jit_function_new_local (func, NULL, type, result);
+
+  gcc_jit_block *b_initial =
+gcc_jit_function_new_block (func, initial);
+
+  /* The builtins are listed in builtins.def as being variadic, but
+ the have these signatures:
+   bool __builtin_add_overflow (type1 a, type2 b, type3 *res);
+   bool __builtin_sub_overflow (type1 a, type2 b, type3 *res);
+   bool __builtin_mul_overflow (type1 a, type2 b, type3 *res);  */
+
+  gcc_jit_function *builtin_fn =
+gcc_jit_context_get_builtin_function (ctxt, builtin_name);
+
+  /* Construct a call of the form:
+   (returns bool) __builtin_add_overflow (x, y, result).  */
+  gcc_jit_rvalue *args[3] = {gcc_jit_param_as_rvalue (x),
+gcc_jit_param_as_rvalue (y),
+gcc_jit_lvalue_get_address (result, NULL)};
+  gcc_jit_rvalue *call =
+gcc_jit_context_new_call (ctxt,
+ NULL,
+ builtin_fn,
+ 3, args);
+
+  /* *ovf = BUILTIN_CALL (); */
+  gcc_jit_block_add_assignment (
+b_initial, NULL,
+gcc_jit_rvalue_dereference (gcc_jit_param_as_rvalue (ovf),
+   NULL),
+call);
+
+  /* return result; */
+  gcc_jit_block_end_with_return (
+b_initial, NULL,
+gcc_jit_lvalue_as_rvalue (result));
+}
+
+void
+create_code (gcc_jit_context *ctxt, void *user_data)
+{
+  /* int */
+  gcc_jit_type *int_type =
+

[doc, committed] fix incorrect @samp markup in invoke.texi

2015-01-07 Thread Sandra Loosemore
I've checked in this further patch to clean up incorrect uses of @samp 
markup in invoke.texi.  Per the Texinfo manual, @code should be used 
instead for things that consist of entire syntactic tokens (symbol names 
and language keywords, in particular, as well as larger code fragments 
like expressions).  I also found a few places where @command markup 
should be used instead.


-Sandra

2015-01-07  Sandra Loosemore  san...@codesourcery.com

gcc/
* doc/invoke.texi: Fix incorrect uses of @samp markup throughout
the file where @code, @command, etc is more appropriate.

Index: gcc/doc/invoke.texi
===
--- gcc/doc/invoke.texi	(revision 219316)
+++ gcc/doc/invoke.texi	(working copy)
@@ -41,7 +41,7 @@ gcc [@option{-c}|@option{-S}|@option{-E}
 [@option{-o} @var{outfile}] [@@@var{file}] @var{infile}@dots{}
 
 Only the most useful options are listed here; see below for the
-remainder.  @samp{g++} accepts mostly the same options as @samp{gcc}.
+remainder.  @command{g++} accepts mostly the same options as @command{gcc}.
 @c man end
 @c man begin SEEALSO
 gpl(7), gfdl(7), fsf-funding(7),
@@ -2112,7 +2112,7 @@ Check that the pointer returned by @code
 before attempting to modify the storage allocated.  This check is
 normally unnecessary because the C++ standard specifies that
 @code{operator new} only returns @code{0} if it is declared
-@samp{throw()}, in which case the compiler always checks the
+@code{throw()}, in which case the compiler always checks the
 return value even without this option.  In all other cases, when
 @code{operator new} has a non-empty exception specification, memory
 exhaustion is signalled by throwing @code{std::bad_alloc}.  See also
@@ -2173,7 +2173,7 @@ call the copy constructor in all cases.
 Don't generate code to check for violation of exception specifications
 at run time.  This option violates the C++ standard, but may be useful
 for reducing code size in production builds, much like defining
-@samp{NDEBUG}.  This does not give user code permission to throw
+@code{NDEBUG}.  This does not give user code permission to throw
 exceptions in violation of the exception specifications; the compiler
 still optimizes based on the specifications, so throwing an
 unexpected exception results in undefined behavior at run time.
@@ -2182,8 +2182,8 @@ unexpected exception results in undefine
 @itemx -fno-extern-tls-init
 @opindex fextern-tls-init
 @opindex fno-extern-tls-init
-The C++11 and OpenMP standards allow @samp{thread_local} and
-@samp{threadprivate} variables to have dynamic (runtime)
+The C++11 and OpenMP standards allow @code{thread_local} and
+@code{threadprivate} variables to have dynamic (runtime)
 initialization.  To support this, any use of such a variable goes
 through a wrapper function that performs any necessary initialization.
 When the use and definition of the variable are in the same
@@ -2206,7 +2206,7 @@ aliases, the default is @option{-fno-ext
 @opindex ffor-scope
 @opindex fno-for-scope
 If @option{-ffor-scope} is specified, the scope of variables declared in
-a @i{for-init-statement} is limited to the @samp{for} loop itself,
+a @i{for-init-statement} is limited to the @code{for} loop itself,
 as specified by the C++ standard.
 If @option{-fno-for-scope} is specified, the scope of variables declared in
 a @i{for-init-statement} extends to the end of the enclosing scope,
@@ -2238,7 +2238,7 @@ without optimization need the same set o
 @item -fno-implement-inlines
 @opindex fno-implement-inlines
 To save space, do not emit out-of-line copies of inline functions
-controlled by @samp{#pragma implementation}.  This causes linker
+controlled by @code{#pragma implementation}.  This causes linker
 errors if these functions are not inlined everywhere they are called.
 
 @item -fms-extensions
@@ -2305,10 +2305,10 @@ Instantiation}, for more information.
 @opindex fno-rtti
 Disable generation of information about every class with virtual
 functions for use by the C++ run-time type identification features
-(@samp{dynamic_cast} and @samp{typeid}).  If you don't use those parts
+(@code{dynamic_cast} and @code{typeid}).  If you don't use those parts
 of the language, you can save some space by using this flag.  Note that
 exception handling uses the same information, but G++ generates it as
-needed. The @samp{dynamic_cast} operator can still be used for casts that
+needed. The @code{dynamic_cast} operator can still be used for casts that
 do not require run-time type information, i.e.@: casts to @code{void *} or to
 unambiguous base classes.
 
@@ -2563,9 +2563,9 @@ These mangling issues were fixed in @opt
 
 @item
 Scoped enumerators passed as arguments to a variadic function are
-promoted like unscoped enumerators, causing @samp{va_arg} to complain.
+promoted like unscoped enumerators, causing @code{va_arg} to complain.
 On most targets this does not actually affect the parameter passing
-ABI, as 

[PATCH, committed] Fix typo in jit-recording.h

2015-01-07 Thread David Malcolm
Committed as r219319.

gcc/jit/ChangeLog:
* jit-recording.h (gcc::jit::recording::memento_of_get_type): Fix
typo in comment.
---
 gcc/jit/jit-recording.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h
index 17a1ca4..3734e9a 100644
--- a/gcc/jit/jit-recording.h
+++ b/gcc/jit/jit-recording.h
@@ -465,7 +465,7 @@ private:
   type *m_pointer_to_this_type;
 };
 
-/* Result of gcc_jit_type_get_type.  */
+/* Result of gcc_jit_context_get_type.  */
 class memento_of_get_type : public type
 {
 public:
-- 
1.8.5.3



Re: [PATCH] Fix sporadic failure in g++.dg/tsan/aligned_vs_unaligned_race.C

2015-01-07 Thread Jakub Jelinek
On Wed, Jan 07, 2015 at 03:55:11PM +0100, Bernd Edlinger wrote:
 cat barrier.h
 #include dlfcn.h
 
 static pthread_barrier_t barrier;
 
 static int (*barrier_wait)(pthread_barrier_t *);

Better
static __typeof (pthread_barrier_wait) *barrier_wait;
?
 
 __attribute__((constructor(101)))

I wouldn't use a constructor for it, instead simply call it from the
testcase at the start of main.

 void barrier_init()
 {
   pthread_barrier_init (barrier, NULL, 2);
   barrier_wait = (int (*)(pthread_barrier_t *))
  dlsym (dlopen (pthread.so.0, RTLD_NOW), 
 pthread_barrier_wait);

libpthread.so.0 instead.

I'd use:
#ifdef RTLD_NOLOAD
  void *h = dlopen (libpthread.so.0, RTLD_NOLOAD);
#else
  void *h = dlopen (libpthread.so.0, RTLD_NOW);
#endif
  barrier_wait = (__typeof (pthread_barrier_wait) *) dlsym (h, 
pthread_barrier_wait);

Jakub


[PATCH, committed] jit.exp: add __func__ to help test-{combination|threads}.c

2015-01-07 Thread David Malcolm
Within the jit testsuite, test-combination.c and test-threads.c rerun
other tests - the former all within one context, the latter in multiple
contexts, each on a different thread.

When reading the results of these combined tests it can be difficult to
figure out where each PASS/FAIL line actually comes from.

Address this by adding __func__ to the output.

jit.sum remains:
  # of expected passes5008

Committed to trunk as r219314.

gcc/testsuite/ChangeLog:
* jit.dg/harness.h (CHECK_NON_NULL): Add __func__ to output, to
make it easier to figure out the origin of each test result when
running test-combination.c and test-threads.c.
(CHECK_VALUE): Likewise.
(CHECK_DOUBLE_VALUE): Likewise.
(CHECK_STRING_VALUE): Likewise.
(CHECK_STRING_STARTS_WITH): Likewise.
(CHECK_STRING_CONTAINS): Likewise.
(CHECK): Likewise.
(check_string_value): Likewise, add funcname param.
(check_string_starts_with): Likewise.
(check_string_contains): Likewise.
---
 gcc/testsuite/jit.dg/harness.h | 78 +-
 1 file changed, 47 insertions(+), 31 deletions(-)

diff --git a/gcc/testsuite/jit.dg/harness.h b/gcc/testsuite/jit.dg/harness.h
index 19dabb5..fda797c 100644
--- a/gcc/testsuite/jit.dg/harness.h
+++ b/gcc/testsuite/jit.dg/harness.h
@@ -39,11 +39,13 @@ static char test[1024];
   do {   \
 if ((PTR) != NULL)   \
   {  \
-   pass (%s: %s is non-null, test, #PTR); \
+   pass (%s: %s: %s is non-null,  \
+ test, __func__, #PTR); \
   }  \
 else \
   {  \
-   fail (%s: %s is NULL, test, #PTR); \
+   fail (%s: %s: %s is NULL,  \
+ test, __func__, #PTR); \
abort ();\
 }\
   } while (0)
@@ -52,11 +54,13 @@ static char test[1024];
   do {   \
 if ((ACTUAL) == (EXPECTED))  \
   {  \
-   pass (%s: actual: %s == expected: %s, test, #ACTUAL, #EXPECTED); \
+   pass (%s: %s: actual: %s == expected: %s, \
+ test, __func__, #ACTUAL, #EXPECTED);  \
   }  \
 else \
   {\
-   fail (%s: actual: %s != expected: %s, test, #ACTUAL, #EXPECTED); \
+   fail (%s: %s: actual: %s != expected: %s, \
+ test, __func__, #ACTUAL, #EXPECTED);  \
fprintf (stderr, incorrect value\n); \
abort ();  \
 }\
@@ -68,34 +72,36 @@ static char test[1024];
 double actual = (ACTUAL);   \
 if (abs (actual - expected)  0.1)   \
   {  \
-   pass (%s: actual: %s == expected: %s, test, #ACTUAL, #EXPECTED); \
+   pass (%s: %s: actual: %s == expected: %s, \
+ __func__, test, #ACTUAL, #EXPECTED);  \
   }  \
 else \
   {  \
-   fail (%s: actual: %s != expected: %s, test, #ACTUAL, #EXPECTED); \
+   fail (%s: %s: actual: %s != expected: %s, \
+ __func__, test, #ACTUAL, #EXPECTED); \
fprintf (stderr, incorrect value: %f\n, actual); \
abort ();\
 }\
   } while (0)
 
 #define CHECK_STRING_VALUE(ACTUAL, EXPECTED) \
-  check_string_value ((ACTUAL), (EXPECTED));
+  check_string_value (__func__, (ACTUAL), (EXPECTED));
 
 #define CHECK_STRING_STARTS_WITH(ACTUAL, EXPECTED_PREFIX) \
-  check_string_starts_with ((ACTUAL), (EXPECTED_PREFIX));
+  check_string_starts_with (__func__, (ACTUAL), (EXPECTED_PREFIX));
 
 #define CHECK_STRING_CONTAINS(ACTUAL, EXPECTED_SUBSTRING) \
-  check_string_contains (#ACTUAL, (ACTUAL), (EXPECTED_SUBSTRING));
+  check_string_contains (__func__, #ACTUAL, (ACTUAL), (EXPECTED_SUBSTRING));
 
 #define CHECK(COND) \
   do { \
 if (COND)  \
   {\
-   pass (%s: %s, test, #COND);   \
+   pass (%s: %s: %s, test, __func__, #COND); \
   }\
 else   \
   {\
-   fail (%s: %s, test, #COND);   \
+   fail (%s: %s: %s, test, __func__, #COND); \
abort ();   \
   }\
   } while (0)
@@ -107,14 +113,17 @@ create_code (gcc_jit_context *ctxt, void * user_data);
 

Go patch committed: Don't assign to embedded builtin types in composite literals

2015-01-07 Thread Ian Lance Taylor
This patch by Chris Manghane fixes the Go frontend to not permit
assigning to embedded builtin types in a composite literal for an
imported struct.  The builtin types are not exported names, but they
are represented as simple names rather than as hidden names (with a
leading dot).  This is http://golang.org/issue/6832 .  Bootstrapped
and ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to
mainline.

Ian
diff -r e027abc3dc5b go/expressions.cc
--- a/go/expressions.cc Tue Jan 06 16:14:01 2015 -0800
+++ b/go/expressions.cc Wed Jan 07 07:34:24 2015 -0800
@@ -12937,7 +12937,8 @@
   pf != st-fields()-end();
   ++pf)
{
- if (Gogo::is_hidden_name(pf-field_name()))
+ if (Gogo::is_hidden_name(pf-field_name())
+ || pf-is_embedded_builtin(gogo))
error_at(this-location(),
 assignment of unexported field %qs in %qs literal,
 Gogo::message_name(pf-field_name()).c_str(),
@@ -13114,7 +13115,8 @@
 
   if (type-named_type() != NULL
   type-named_type()-named_object()-package() != NULL
-  Gogo::is_hidden_name(sf-field_name()))
+  (Gogo::is_hidden_name(sf-field_name())
+ || sf-is_embedded_builtin(gogo)))
error_at(name_expr-location(),
 assignment of unexported field %qs in %qs literal,
 Gogo::message_name(sf-field_name()).c_str(),


Re: [RFA] Add --with-libz-prefix option in config/zlib.m4

2015-01-07 Thread Tristan Gingold

 On 07 Jan 2015, at 15:45, Joel Brobecker brobec...@adacore.com wrote:
 
 Hello,
 
 This patch enhances config/zlib.m4 to introduce an extra option
 --with-libz-prefix which allows us to provide the location of
 the zlib library we want to use during the build.

I prefer the gcc way to provide external library:

--with-zlib - system zlib used
--with-zlib=pathname - zlib from pathname is used

I have never needed different include and lib paths, but
this is supported by gcc.

(Furthermore, I think that --with-zlib vs --with-libz-prefix is confusing).

Cf:

--with-gmp=pathname
--with-gmp-include=pathname
--with-gmp-lib=pathname
--with-mpfr=pathname
--with-mpfr-include=pathname
--with-mpfr-lib=pathname
--with-mpc=pathname
--with-mpc-include=pathname
--with-mpc-lib=pathname
If you want to build GCC but do not have the GMP library, the MPFR library 
and/or the MPC library installed in a standard location and do not have their 
sources present in the GCC source tree then you can explicitly specify the 
directory where they are installed (‘--with-gmp=gmpinstalldir’, 
‘--with-mpfr=mpfrinstalldir’, ‘--with-mpc=mpcinstalldir’). The 
--with-gmp=gmpinstalldir option is shorthand for 
--with-gmp-lib=gmpinstalldir/lib and --with-gmp-include=gmpinstalldir/include. 
Likewise the --with-mpfr=mpfrinstalldir option is shorthand for 
--with-mpfr-lib=mpfrinstalldir/lib and 
--with-mpfr-include=mpfrinstalldir/include, also the --with-mpc=mpcinstalldir 
option is shorthand for --with-mpc-lib=mpcinstalldir/lib and 
--with-mpc-include=mpcinstalldir/include. If these shorthand assumptions are 
not correct, you can use the explicit include and lib options directly. You 
might also need to ensure the shared libraries can be found by the dynamic 
linker when building and using GCC, for example by setting the runtime shared 
library path variable (LD_LIBRARY_PATH on GNU/Linux and Solaris systems).
These flags are applicable to the host platform only. When building a cross 
compiler, they will not be used to configure target libraries. 




Re: [Patch, Fortran] Fix previous patch

2015-01-07 Thread Tobias Burnus

Early PING: https://gcc.gnu.org/ml/gcc-patches/2015-01/msg00090.html

Tobias Burnus wrote:
Attached is a regtested patch, which fixes the issue. Additionally, 
the variable visibility (TREE_PUBLIC) is now depending on the private 
attribute (copied from the module var generation) and I mark the tree 
as DECL_NONALIASED. The former I also did for proc-pointers, which is 
an unrelated patch.


Build and regtested on x86-64-gnu-linux.
OK for the trunk?


Dominique d'Humières wrote:

Compilation with the new patch fails with
../../work/gcc/fortran/trans-decl.c: In function 'void 
gfc_build_qualified_array(tree, gfc_symbol*)':
../../work/gcc/fortran/trans-decl.c:855:25: error: 'cur_module' was 
not declared in this scope

 gfc_module_add_decl (cur_module, token);


Which shows that w/o compiling and testing, one (usually) cannot write 
patches. Solution is to move the declaration up in the file. However, 
it turned out that that's not sufficient: the pushdecl is required.


Tobias


Le 3 janv. 2015 à 23:30, Tobias Burnus bur...@net-b.de a écrit :

Dominique d'Humières wrote:

 From a quick test, with the patch I still see the error with -m32
It helps if one actually adds the decl. The following (still 
untested) should help. I also marked the token as nonaliasing (it 
really should!) and added for proc pointers the tree-public 
optimization.


Tobias
foo.diff








[PATCH] rs6000: Add eqsi/nesi storing to a 64-bit reg (PR36557)

2015-01-07 Thread Segher Boessenkool
The compiler cannot assume that the eqsi etc. patterns write a properly
extended result to a DI reg.  The current way to tell it is to add an
extra pattern with an extend.  This patch does that.  A less cumbersome
method of specifying this would be nice -- maybe one where we say in
the SI pattern that the result is already extended correctly as DI (both
sign- and zero-extended, in this case).

This partially fixes PR36557 (and is the best we can do for the test
case there, we cannot assume function args are correctly extended for
their type).

Tested as usual; okay for mainline?


Segher


2015-01-07  Segher Boessenkool  seg...@kernel.crashing.org

gcc/
PR target/36557
* config/rs6000/rs6000.md (*eqsi3_extmode, *nesi3_extmode): New.

---
 gcc/config/rs6000/rs6000.md | 60 +
 1 file changed, 60 insertions(+)

diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 3da529c..6da1a6a 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -12588,6 +12588,66 @@ (define_insn_and_split *minus_ne_mode
(if_then_else (match_test operands[2] == const0_rtx)
  (const_string 8)
  (const_string 12)))])
+
+(define_insn_and_split *eqsi3_extmode
+  [(set (match_operand:EXTSI 0 gpc_reg_operand =r)
+   (eq:EXTSI (match_operand:SI 1 gpc_reg_operand r)
+ (match_operand:SI 2 scc_eq_operand rKLI)))
+   (clobber (match_scratch:SI 3 =r))
+   (clobber (match_scratch:SI 4 =r))]
+  
+  #
+  
+  [(set (match_dup 4)
+   (clz:SI (match_dup 3)))
+   (set (match_dup 0)
+   (zero_extend:EXTSI
+ (lshiftrt:SI (match_dup 4)
+  (const_int 5]
+{
+  operands[3] = rs6000_emit_eqne (SImode,
+ operands[1], operands[2], operands[3]);
+
+  if (GET_CODE (operands[4]) == SCRATCH)
+operands[4] = gen_reg_rtx (SImode);
+}
+  [(set (attr length)
+   (if_then_else (match_test operands[2] == const0_rtx)
+ (const_string 8)
+ (const_string 12)))])
+
+(define_insn_and_split *nesi3_extmode
+  [(set (match_operand:EXTSI 0 gpc_reg_operand =r)
+   (ne:EXTSI (match_operand:SI 1 gpc_reg_operand r)
+ (match_operand:SI 2 scc_eq_operand rKLI)))
+   (clobber (match_scratch:SI 3 =r))
+   (clobber (match_scratch:SI 4 =r))
+   (clobber (match_scratch:EXTSI 5 =r))]
+  
+  #
+  
+  [(set (match_dup 4)
+   (clz:SI (match_dup 3)))
+   (set (match_dup 5)
+   (zero_extend:EXTSI
+ (lshiftrt:SI (match_dup 4)
+  (const_int 5
+   (set (match_dup 0)
+   (xor:EXTSI (match_dup 5)
+  (const_int 1)))]
+{
+  operands[3] = rs6000_emit_eqne (SImode,
+ operands[1], operands[2], operands[3]);
+
+  if (GET_CODE (operands[4]) == SCRATCH)
+operands[4] = gen_reg_rtx (SImode);
+  if (GET_CODE (operands[5]) == SCRATCH)
+operands[5] = gen_reg_rtx (MODEmode);
+}
+  [(set (attr length)
+   (if_then_else (match_test operands[2] == const0_rtx)
+ (const_string 12)
+ (const_string 16)))])
 
 ;; Define both directions of branch and return.  If we need a reload
 ;; register, we'd rather use CR0 since it is much easier to copy a
-- 
1.8.1.4



Re: [PATCH] LRA: Fix caller-save store/restore instruction for large mode

2015-01-07 Thread Bin.Cheng
On Wed, Jan 7, 2015 at 8:28 PM, Kito Cheng kito.ch...@gmail.com wrote:
 Hi Bin:

 It's 2 more line than gcc.c-torture/execute/scal-to-vec1.c since it's
 need specific compilation
 flag and specific target to reproduce this issue,
 and it's can't reproduce by normal testing flow with
 arm-*-linux-gnueabi (due to lack -fPIC flag),
 so I prefer duplicate this case into gcc.target/arm/ :)

 /* { dg-do compile } */
 /* { dg-options -O3 -fPIC -marm -mcpu=cortex-a8 } */
Not really, we generally want to avoid cpu related options in testcase
since it introduces conflict option failures when testing against
specific processor, e.g. testing against Cortex-M profile processors.

Thanks,
bin


 On Wed, Jan 7, 2015 at 4:50 PM, Bin.Cheng amker.ch...@gmail.com wrote:
 On Wed, Jan 7, 2015 at 4:03 PM, Kito Cheng kito.ch...@gmail.com wrote:
 Hi Jeff:

 It's updated patch,bootstrapped and run regression tested on arm-eabi,
 arm-none-linux-uclibcgnueabi, x86_64-unknown-linux-gnu and nds32le-elf
 without introducing regression.

 Thanks for your review :)

 2015-01-07  Kito Cheng  k...@0xlab.org

 PR target/64348
 * lra-constraints.c (split_reg): Fix caller-save store/restore
 instruction generation.

 Thanks for fixing the issue.
 The PR is against existing testcase failure
 gcc.c-torture/execute/scal-to-vec1.c.  Unless we can create a new
 case, there is no need to include same case twice I think?  Or we can
 mention the PR number in the original test case?

 Thanks,
 bin


[PING] Flatten tree.h and tree-core.h (Version 2)

2015-01-07 Thread Michael Collison


Ping. Any update on this patch?

https://gcc.gnu.org/ml/gcc-patches/2014-12/msg01848.html


--
Michael Collison
Linaro Toolchain Working Group
michael.colli...@linaro.org



Re: [PATCH] rs6000: Add eqsi/nesi storing to a 64-bit reg (PR36557)

2015-01-07 Thread David Edelsohn
On Wed, Jan 7, 2015 at 8:28 PM, Segher Boessenkool
seg...@kernel.crashing.org wrote:
 The compiler cannot assume that the eqsi etc. patterns write a properly
 extended result to a DI reg.  The current way to tell it is to add an
 extra pattern with an extend.  This patch does that.  A less cumbersome
 method of specifying this would be nice -- maybe one where we say in
 the SI pattern that the result is already extended correctly as DI (both
 sign- and zero-extended, in this case).

 This partially fixes PR36557 (and is the best we can do for the test
 case there, we cannot assume function args are correctly extended for
 their type).

 Tested as usual; okay for mainline?


 Segher


 2015-01-07  Segher Boessenkool  seg...@kernel.crashing.org

 gcc/
 PR target/36557
 * config/rs6000/rs6000.md (*eqsi3_extmode, *nesi3_extmode): New.

Okay.

Thanks, David


[doc, committed] fix @var markup on option keyword choices

2015-01-07 Thread Sandra Loosemore
The documented syntax for most GCC options that take magic keywords is 
of the form @option{-ffoo=@var{magic}}, with the various literal values 
for @var{magic} listed in the option description.  There are a number, 
though, that list the keyword choices in the syntax, but with two 
different markup conventions.  This patch changes the ones that wrap the 
whole keyword list in @var, like -fvtable-verify, to use the same markup 
convention as the others, like -Wsuggest-attribute, which use the 
regular option/code font for the keywords but set off the syntactic 
delimiters [, |, and ] in Roman font..  @var is supposed to be for 
metasyntactic variables and seems inappropriate for literal keywords, so 
I think it's less correct than the other convention.  Of course a third 
possibility would be to rewrite all the option descriptions in this 
class to use a metasyntactic variable instead of putting the keywords 
inline, but that's more work and more prone to possible unintended changes.


I've checked this in under the obvious fix rule.

-Sandra

2015-01-07  Sandra Loosemore  san...@codesourcery.com

gcc/
* doc/invoke.texi ([-fvtable-verify]): Fix markup on option
keywords.
([-fivar-visibility], [-fvisibility]): Likewise.
Index: gcc/doc/invoke.texi
===
--- gcc/doc/invoke.texi	(revision 219322)
+++ gcc/doc/invoke.texi	(working copy)
@@ -193,7 +193,7 @@ in the following sections.
 -fno-threadsafe-statics  -fuse-cxa-atexit @gol
 -fno-weak  -nostdinc++ @gol
 -fvisibility-inlines-hidden @gol
--fvtable-verify=@var{std|preinit|none} @gol
+-fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]} @gol
 -fvtv-counts -fvtv-debug @gol
 -fvisibility-ms-compat @gol
 -fext-numeric-literals @gol
@@ -219,7 +219,7 @@ Objective-C and Objective-C++ Dialects}.
 -fobjc-nilcheck @gol
 -fobjc-std=objc1 @gol
 -fno-local-ivars @gol
--fivar-visibility=@var{public|protected|private|package} @gol
+-fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]} @gol
 -freplace-objc-classes @gol
 -fzero-link @gol
 -gen-decls @gol
@@ -1116,7 +1116,8 @@ See S/390 and zSeries Options.
 -fleading-underscore  -ftls-model=@var{model} @gol
 -fstack-reuse=@var{reuse_level} @gol
 -ftrapv  -fwrapv  -fbounds-check @gol
--fvisibility -fstrict-volatile-bitfields -fsync-libcalls}
+-fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]} @gol
+-fstrict-volatile-bitfields -fsync-libcalls}
 @end table
 
 
@@ -2436,7 +2437,7 @@ and that pointers to function members de
 objects may not compare equal.  When this flag is given, it is a
 violation of the ODR to define types with the same name differently.
 
-@item -fvtable-verify=@var{std|preinit|none}
+@item -fvtable-verify=@r{[}std@r{|}preinit@r{|}none@r{]}
 @opindex fvtable-verify
 Turn on (or off, if using @option{-fvtable-verify=none}) the security
 feature that verifies at runtime, for every virtual call that is made, that
@@ -3013,7 +3014,7 @@ and other variables declared either loca
 globally with the same name.  Specifying the @option{-fno-local-ivars}
 flag disables this behavior thus avoiding variable shadowing issues.
 
-@item -fivar-visibility=@var{public|protected|private|package}
+@item -fivar-visibility=@r{[}public@r{|}protected@r{|}private@r{|}package@r{]}
 @opindex fivar-visibility
 Set the default instance variable visibility to the specified option
 so that instance variables declared outside the scope of any access
@@ -23492,7 +23493,7 @@ unit, or if @option{-fpic} is not given 
 The default without @option{-fpic} is @samp{initial-exec}; with
 @option{-fpic} the default is @samp{global-dynamic}.
 
-@item -fvisibility=@var{default|internal|hidden|protected}
+@item -fvisibility=@r{[}default@r{|}internal@r{|}hidden@r{|}protected@r{]}
 @opindex fvisibility
 Set the default ELF image symbol visibility to the specified option---all
 symbols are marked with this unless overridden within the code.


[RFA:] Fix test-suite regressions from PR62250 due to -latomic always added

2015-01-07 Thread Hans-Peter Nilsson
PR62250 (r219171) was about some fortran tests that used atomic
operations but failing on systems where -latomic is required.
The fix was to always add -latomic.  That caused test-suite
regressions for targets that don't have libatomic, but where the
required operations are built-in (no separate PR entered, the
fix below seemed simple enough).

Here's a fix to that issue, adding a target matcher usable for
individual tests (gfortran.dg/coarray_lib_comm_1.f90) as well as
the grouped tests in gfortran.dg/coarray/caf.exp.  If you
consider using this elsewhere (other languages), there's a
prerequisite that paths have been added to default linker
options to find libatomic; already covered by r219171.  I
considered tweaking that path-adding to instead make use of
lib/atomic-dg.exp, but stopped when noticing that atomic_init
would be required to be called in lib/gfortran.exp and would
always add -latomic and would split up the path-tweaking, doing
differently than the existing tweaking in lib/gfortran.exp.
Other issues likely.  (If there's instead a preference to
strongly depend on libatomic for fortran and forcing targets to
port it, there's some required top-level dependency configury
changes and/or needing to add -latomic to the defaults when
linking with gfortran and also I don't want that, seeing this
as the simpler, better fix.  Of course, that also means that the
user has to know to manually add -latomic for *some* fortran
codes for *some* systems.)

Tested to fix the issues for cris-elf (no libatomic, operations
built-in), not having any effect on native
x86_64-unknown-linux-gnu (has libatomic but operations also
built-in) and David says test is in progress for hppa*-*-hpux*
(the cause for PR62250; has libatomic, not all required built-in
operations).

Ok to commit?

(PR marking just to make this show up in the log trail of that
PR as a follow-up to the fix.)

gcc/testsuite:
PR testsuite/62250
* lib/target-supports.exp (check_effective_target_libatomic_available):
New.
* gfortran.dg/coarray/caf.exp: Only add -latomic for
targets that match effective-target libatomic_available.
* gfortran.dg/coarray_lib_comm_1.f90: Similar.

Index: lib/target-supports.exp
===
--- lib/target-supports.exp (revision 219277)
+++ lib/target-supports.exp (working copy)
@@ -1128,6 +1128,13 @@ proc check_libcilkrts_available { } {
} -fcilkplus -lcilkrts ]
 }
 
+# Return true if the atomic library is supported on the target.
+proc check_effective_target_libatomic_available { } {
+return [check_no_compiler_messages libatomic_available executable {
+   int main (void) { return 0; }
+} -latomic]
+}
+
 # Return 1 if an ASCII locale is supported on this host, 0 otherwise.
 
 proc check_ascii_locale_available { } {
Index: gfortran.dg/coarray/caf.exp
===
--- gfortran.dg/coarray/caf.exp (revision 219277)
+++ gfortran.dg/coarray/caf.exp (working copy)
@@ -58,6 +58,12 @@ proc dg-compile-aux-modules { args } {
 # cleanup-modules isn't intentionally invoked here.
 }
 
+# Add -latomic only where supported.  Assume built-in support elsewhere.
+set maybe_atomic_lib 
+if [check_effective_target_libatomic_available] {
+set maybe_atomic_lib -latomic
+}
+
 # Main loop.
 foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} 
]] {
 # If we're only testing specific files and this isn't one of them, skip it.
@@ -81,14 +87,14 @@ foreach test [lsort [glob -nocomplain $s
 foreach flags $option_list {
verbose Testing $nshort (single), $flags 1
 set gfortran_aux_module_flags -fcoarray=single $flags
-   dg-test $test -fcoarray=single $flags -latomic  
+   dg-test $test -fcoarray=single $flags $maybe_atomic_lib  
cleanup-modules 
 }
 
 foreach flags $option_list {
verbose Testing $nshort (libcaf_single), $flags 1
 set gfortran_aux_module_flags -fcoarray=lib $flags -lcaf_single
-   dg-test $test -fcoarray=lib $flags -lcaf_single -latomic 
+   dg-test $test -fcoarray=lib $flags -lcaf_single $maybe_atomic_lib 
cleanup-modules 
 }
 }
Index: gfortran.dg/coarray_lib_comm_1.f90
===
--- gfortran.dg/coarray_lib_comm_1.f90  (revision 219277)
+++ gfortran.dg/coarray_lib_comm_1.f90  (working copy)
@@ -1,5 +1,6 @@
 ! { dg-do run }
-! { dg-options -fdump-tree-original -fcoarray=lib -lcaf_single -latomic }
+! { dg-options -fdump-tree-original -fcoarray=lib -lcaf_single -latomic { 
target libatomic_available } }
+! { dg-options -fdump-tree-original -fcoarray=lib -lcaf_single { target { ! 
libatomic_available } } }
 !
 ! Some dependency-analysis check for coarray communication
 !

brgds, H-P


Re: [PATCHv3][PING] New check and updates in check_GNU_style script

2015-01-07 Thread Trevor Saunders
On Wed, Jan 07, 2015 at 12:41:57PM +, Mantas Mikaitis wrote:
 On 26/12/14 06:46, Yury Gribov wrote:
 On 12/19/2014 11:14 AM, Yury Gribov wrote:
 Hi all,
 
 Attached patch adds new check (all blocks of 8 spaces are replaced with
 tabs) to contrib/check_GNU_style.sh. It also changes the script to allow
 reading patches from stdin and strengthens the Dot, space, space, new
 sentence. check.
 
 Is this ok to commit?
 Ping.
 
 Hi,
 
 I for one find this patch very useful in the automated code review
 application I have made.
 
 Seeing that this was pinged 2 times and that I see this patch as adding 
 useful functionality I would like to
 promote reviewing this.

 fwiw you can also check this by enabling git's default pre-committ hook
 and setting core.whitespace to indent-with-non-tab

Trev

 
 Thank you,
 Mantas M.
 
 
 
 
 
 


signature.asc
Description: Digital signature


Re: [gofrontend-dev] [PATCH 1/2, libgo] Add reflection support to gccgo for ppc64, ppc64le in gcc 4.9

2015-01-07 Thread Ian Lance Taylor
On Wed, Jan 7, 2015 at 8:43 AM, Lynn A. Boger
labo...@linux.vnet.ibm.com wrote:

 I thought that since this only affects ppc64 and ppc64le, and provides
 reflection support that doesnt exist in gcc 4.9 for Power (you get a panic
 if you try to use reflection on ppc64, ppc64le), it would be OK.

I understand that the code doesn't work today in 4.9, but a release
branch is for releases and backports of bug fixes, not for any sort of
new development.

(As far as I knoew reflection works in general for PPC in 4.9, it's
just reflect.MakeFunc, a rarely used feature, that is broken.)

Ian


Re: [PATCH] Fix sporadic failure in g++.dg/tsan/aligned_vs_unaligned_race.C

2015-01-07 Thread Mike Stump
On Jan 7, 2015, at 12:23 AM, Jakub Jelinek ja...@redhat.com wrote:
 But I really don't like the busy waiting.

We’ve already determined that sched_sleep isn’t intercepted and can be used to 
non-busy wait.  Any reason not to use it?

 As tsan is only supported on x86_64-linux

So, I hate hardening the code to be overly non-portable when it doesn’t have to 
be that.  There is something enticing to me about the simplicity of sched_sleep.

Re: [PATCH] Fix sporadic failure in g++.dg/tsan/aligned_vs_unaligned_race.C

2015-01-07 Thread Jakub Jelinek
On Wed, Jan 07, 2015 at 08:58:04AM -0800, Mike Stump wrote:
 On Jan 7, 2015, at 12:23 AM, Jakub Jelinek ja...@redhat.com wrote:
  But I really don't like the busy waiting.
 
 We’ve already determined that sched_sleep isn’t intercepted and can be used 
 to non-busy wait.  Any reason not to use it?
 
  As tsan is only supported on x86_64-linux
 
 So, I hate hardening the code to be overly non-portable when it doesn’t have 
 to be that.  There is something enticing to me about the simplicity of 
 sched_sleep.

Well, pthread_barrier_wait and dlopen/dlsym are already used by libtsan and
therefore have to be supported on all the architectures that support tsan.
So that method is as portable as libtsan itself.

Jakub


Re: [RFA] Add --with-libz-prefix option in config/zlib.m4

2015-01-07 Thread Joel Brobecker
  This patch enhances config/zlib.m4 to introduce an extra option
  --with-libz-prefix which allows us to provide the location of
  the zlib library we want to use during the build.
 
 I prefer the gcc way to provide external library:
 
 --with-zlib - system zlib used
 --with-zlib=pathname - zlib from pathname is used

Unfortunately, we took a different route with GDB (with-...-prefix).
For instance:

  --with-libiconv-prefix
  --with-liblzma-prefix
  --with-libbabeltrace-prefix

We already have a really nice macro that takes care of a lot of
configury for us with respect to lib depenencies, which I see
in gcc's root configure.ac that gmp/mpfr/mpc options is done
via specific code.

What I'm getting at is that, to achieve your prefered option
(which I agree is more elegant), it would take a significant
effort.

-- 
Joel


Go patch committed: Don't initialize zero-sized temporaries

2015-01-07 Thread Ian Lance Taylor
This patch by Chris Manghane fixes the Go frontend to avoid crashes
when initializing zero-sized temporary values.  This is GCC PR 61204.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

2015-01-07  Chris Manghane  cm...@google.com

PR go/61204
* go-gcc.cc (Gcc_backend::temporary_variable): Don't initialize
zero-sized variable.
Index: go-gcc.cc
===
--- go-gcc.cc   (revision 219262)
+++ go-gcc.cc   (working copy)
@@ -2536,7 +2536,7 @@ Gcc_backend::temporary_variable(Bfunctio
   BIND_EXPR_VARS(bind_tree) = BLOCK_VARS(block_tree);
 }
 
-  if (init_tree != NULL_TREE)
+  if (this-type_size(btype) != 0  init_tree != NULL_TREE)
 DECL_INITIAL(var) = fold_convert_loc(location.gcc_location(), type_tree,
  init_tree);
 
@@ -2546,6 +2546,13 @@ Gcc_backend::temporary_variable(Bfunctio
   *pstatement = this-make_statement(build1_loc(location.gcc_location(),
 DECL_EXPR,
void_type_node, var));
+
+  // Don't initialize VAR with BINIT, but still evaluate BINIT for
+  // its side effects.
+  if (this-type_size(btype) == 0  init_tree != NULL_TREE)
+*pstatement = this-compound_statement(this-expression_statement(binit),
+  *pstatement);
+
   return new Bvariable(var);
 }
 


Re: [gofrontend-dev] [PATCH 1/2, libgo] Add reflection support to gccgo for ppc64, ppc64le in gcc 4.9

2015-01-07 Thread Ian Lance Taylor
On Tue, Jan 6, 2015 at 7:37 AM, Lynn A. Boger
labo...@linux.vnet.ibm.com wrote:
 Add support for reflection for gccgo in gcc 4.9.  This is not a backport
 because reflection support in gcc trunk is done using FFI. Bootstrap built
 and tested on ppc64, ppc64le.

Sorry, I didn't see at first that this is not a backport.  This is a
complex patch that has never been tested on trunk.  We don't this kind
of change on release branches.  For this kind of work you'll need to
maintain your own branch.  Sorry.

Ian


Re: [PATCH] Fix sporadic failure in g++.dg/tsan/aligned_vs_unaligned_race.C

2015-01-07 Thread Mike Stump
On Jan 6, 2015, at 11:17 PM, Bernd Edlinger bernd.edlin...@hotmail.de wrote:
 
 On Tue, 6 Jan 2015 16:32:35, Mike Stump wrote:
 
 On Jan 6, 2015, at 3:22 PM, Bernd Edlinger bernd.edlin...@hotmail.de wrote:
 Yes, I think too that it can't fail under these conditions.
 
 If you mean your version… A lot has been written on how to to make racy code 
 non-racy… I’d refer you to the literature on all the various solutions 
 people have found to date. I don’t think I’ve ever seen anyone claim that 
 affinity can be used to solve race conditions like this. Do you have a 
 pointer?
 
 
 no, I agree, the affinity would just lower the likelihood, as sleep does.
 The version with affinity is just disgusting, sorry to have posted it ;-).
 
 I meant your version, with step(1)/step(2) between the race. It is probably 
 bullet-proof.
 But the version with sleep is more realistic.

 sleep_sync.c can use step but needs still to call sleep because it triggers 
 on the
 As if synchronized via sleep diagnostic.

Ah, thanks for the pointer.  Yeah, it is important to not remove that sleep, 
though, if the test case itself is racy, we can use step to ensure the elements 
of it happen in a deterministic order.

 I don't know what to make of simple_race.c, which uses usleep, but uses
 a loop to repeat the race often. Maybe leave that one as a realistic test.

I looked at that test case to see if it is flaky (llvm term) and found:

http://reviews.llvm.org/D3913

 The tests test that ThreadSanitizer finds the data race in particular 
 conditions. However, ThreadSanitizer core algorithm can miss a data race when 
 the racy memory access attempts happen very close to each other (literally 
 simultaneously). This was done intentionally, fixing this would impose 
 significant slowdown and this is not a problem for programs other than unit 
 tests.

So, clearly your presentation of the base problem is accurate.  I still doubt 
the costs of a good solution are all that expensive.

Anyway, 
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20140526/219172.html
 makes it clear that this test case is flakey (and should be fixed).

I’d fix it by removing all looping and making it deterministic (with step).  We 
can leave the usleep in there, it doesn’t hurt; though, not sure it adds 
anything.

Re: [gofrontend-dev] [PATCH 1/2, libgo] Add reflection support to gccgo for ppc64, ppc64le in gcc 4.9

2015-01-07 Thread Lynn A. Boger
I thought that since this only affects ppc64 and ppc64le, and provides 
reflection support that doesnt exist in gcc 4.9 for Power (you get a 
panic if you try to use reflection on ppc64, ppc64le), it would be OK.


We'll look at putting it in our own branch.

On 01/07/2015 10:06 AM, Ian Lance Taylor wrote:

On Tue, Jan 6, 2015 at 7:37 AM, Lynn A. Boger
labo...@linux.vnet.ibm.com wrote:

Add support for reflection for gccgo in gcc 4.9.  This is not a backport
because reflection support in gcc trunk is done using FFI. Bootstrap built
and tested on ppc64, ppc64le.

Sorry, I didn't see at first that this is not a backport.  This is a
complex patch that has never been tested on trunk.  We don't this kind
of change on release branches.  For this kind of work you'll need to
maintain your own branch.  Sorry.

Ian







Re: [PATCH] Fix sporadic failure in g++.dg/tsan/aligned_vs_unaligned_race.C

2015-01-07 Thread Jakub Jelinek
On Wed, Jan 07, 2015 at 07:21:40PM +0100, Bernd Edlinger wrote:
 Ok, just for completeness, I've got the dlopen finally working:
 RTLD_NOLOAD is not working, but RTLD_LAZY or RTLD_NOW does.

No big deal I guess.

 I am however not sure if I can always use -ldl or have to use some 
 target-dependencies here.

libsanitizer always puts
-lpthread -ldl -lm
into libsanitizer.spec, so I'd say it should be safe and you shouldn't even
need -ldl in dg-additional-options, as merely linking with -fsanitize=thread
should link -ldl in.

 --- barrier.h    (revision 0)
 +++ barrier.h    (working copy)

I think better to name it tsan_barrier.h or otherwise make it
clear what this is for.

 @@ -0,0 +1,12 @@
 +#include dlfcn.h
 +
 +static __typeof(pthread_barrier_wait) *barrier_wait;
 +
 +static
 +void barrier_init (pthread_barrier_t *barrier)

And, I'd add unsigned count argument here, and pass it through
pthread_barrier_init, just in case you need more than 2 threads
in some test.

Also, what do you need sched.h for?

Jakub


RE: [PATCH] Fix sporadic failure in g++.dg/tsan/aligned_vs_unaligned_race.C

2015-01-07 Thread Bernd Edlinger

On Wed, 7 Jan 2015 18:00:27, Jakub Jelinek wrote:

 On Wed, Jan 07, 2015 at 08:58:04AM -0800, Mike Stump wrote:
 On Jan 7, 2015, at 12:23 AM, Jakub Jelinek ja...@redhat.com wrote:
 But I really don't like the busy waiting.

 We’ve already determined that sched_sleep isn’t intercepted and can be used 
 to non-busy wait. Any reason not to use it?

 As tsan is only supported on x86_64-linux

 So, I hate hardening the code to be overly non-portable when it doesn’t have 
 to be that. There is something enticing to me about the simplicity of 
 sched_sleep.

 Well, pthread_barrier_wait and dlopen/dlsym are already used by libtsan and
 therefore have to be supported on all the architectures that support tsan.
 So that method is as portable as libtsan itself.

 Jakub


Ok, just for completeness, I've got the dlopen finally working:
RTLD_NOLOAD is not working, but RTLD_LAZY or RTLD_NOW does.

The test case is passing reliably with this method too.

I am however not sure if I can always use -ldl or have to use some 
target-dependencies here.



Index: aligned_vs_unaligned_race.C
===
--- aligned_vs_unaligned_race.C    (revision 219198)
+++ aligned_vs_unaligned_race.C    (working copy)
@@ -1,11 +1,17 @@
 /* { dg-shouldfail tsan } */
+/* { dg-additional-options -ldl } */
 #include pthread.h
+#include sched.h
 #include stdio.h
 #include stdint.h
+#include barrier.h
 
+static pthread_barrier_t barrier;
+
 uint64_t Global[2];
 
 void *Thread1(void *x) {
+  barrier_wait(barrier);
   Global[1]++;
   return NULL;
 }
@@ -15,10 +21,12 @@
   struct __attribute__((packed, aligned(1))) u_uint64_t { uint64_t val; };
   u_uint64_t *p4 = reinterpret_castu_uint64_t *(p1 + 1);
   (*p4).val++;
+  barrier_wait(barrier);
   return NULL;
 }
 
 int main() {
+  barrier_init(barrier);
   pthread_t t[2];
   pthread_create(t[0], NULL, Thread1, NULL);
   pthread_create(t[1], NULL, Thread2, NULL);
Index: barrier.h
===
--- barrier.h    (revision 0)
+++ barrier.h    (working copy)
@@ -0,0 +1,12 @@
+#include dlfcn.h
+
+static __typeof(pthread_barrier_wait) *barrier_wait;
+
+static
+void barrier_init (pthread_barrier_t *barrier)
+{
+  void *h = dlopen (libpthread.so.0, RTLD_LAZY);
+  barrier_wait = (__typeof (pthread_barrier_wait) *)
+      dlsym (h, pthread_barrier_wait);
+  pthread_barrier_init (barrier, NULL, 2);
+}


Thanks
Bernd.
  

Re: [gofrontend-dev] [PATCH 1/2, libgo] Add reflection support to gccgo for ppc64, ppc64le in gcc 4.9

2015-01-07 Thread Ian Lance Taylor
On Wed, Jan 7, 2015 at 9:26 AM, Lynn A. Boger
labo...@linux.vnet.ibm.com wrote:

 In libgo/go/reflect/makefunc.go, calls to MakeFunc, makeMethodValue and
 makeValueMethod will panic if called when GOARCH is ppc64 or ppc64le.

Right, I'm just saying that almost no code actually does that.  I just
tried a web search and found no uses other than examples of how to use
it.  I'm sure there are a few, but not many.

Ian


[PATCH, committed] jit.exp: support C++ testcases

2015-01-07 Thread David Malcolm
This adds at least two ugly kludges to jit.exp, but it works:
in particular: the setting of tool to g++ when loading wrapper.lib,
and the resetting of orig_environment_saved.

I also noticed that jit-dg-test wasn't returning a list of the form:
  [list $comp_output $output_file]
as dg-test assumes, so I fixed that.  I'm not sure how that aspect
ever worked before.

This takes jit.sum from
  # of expected passes5008
to:
  # of expected passes5158
and finally gives us automated test coverage of the C++ bindings to
libgccjit.

Committed to trunk as r219318.

gcc/jit/ChangeLog:
* TODO.rst (Test suite): Remove item about running C++ testcases.
* docs/internals/index.rst (Working on the JIT library): Add
c++ to the enabled languages in the suggested configure
invocation, and add a description of why this is necessary.
* docs/_build/texinfo/libgccjit.texi: Regenerate.

gcc/testsuite/ChangeLog:
* jit.dg/jit.exp: Load wrapper.exp with %{tool} set to g++
rather than jit.  Load g++.exp, and call g++_init.
Run test-*.cc files within the testsuite and *.cc files within
docs/examples.
(jit-dg-test): Drop the addition of -fgnu89-inline to
DEFAULT_CFLAGS in favor of adding it to additional_flags, only
doing it when compiling C testcases (since g++ does not handle
it).  Reset orig_environment_saved so that LD_LIBRARY_PATH
is restored to the value after g++_init ran, rather than the
value before g++_init ran.  Return a list of
$comp_output $output_file, as dg-test assumes.
---
 gcc/jit/TODO.rst |  2 --
 gcc/jit/docs/internals/index.rst | 13 +--
 gcc/testsuite/jit.dg/jit.exp | 78 ++--
 3 files changed, 79 insertions(+), 14 deletions(-)

diff --git a/gcc/jit/TODO.rst b/gcc/jit/TODO.rst
index 09c4d9d..ca0ddbb 100644
--- a/gcc/jit/TODO.rst
+++ b/gcc/jit/TODO.rst
@@ -81,8 +81,6 @@ Bugs
 
 Test suite
 ==
-* get DejaGnu to build and run C++ testcases
-
 * measure code coverage in testing of libgccjit.so
 
 Future milestones
diff --git a/gcc/jit/docs/internals/index.rst b/gcc/jit/docs/internals/index.rst
index 424c73e..694f058 100644
--- a/gcc/jit/docs/internals/index.rst
+++ b/gcc/jit/docs/internals/index.rst
@@ -31,7 +31,7 @@ the JIT library like this:
   cd build
   ../src/configure \
  --enable-host-shared \
- --enable-languages=jit \
+ --enable-languages=jit,c++ \
  --disable-bootstrap \
  --enable-checking=release \
  --prefix=$PREFIX
@@ -54,11 +54,20 @@ Here's what those configuration options mean:
   position-independent code, which incurs a slight performance hit,
   but it necessary for a shared library.
 
-.. option:: --enable-languages=jit
+.. option:: --enable-languages=jit,c++
 
   This specifies which frontends to build.  The JIT library looks like
   a frontend to the rest of the code.
 
+  The C++ portion of the JIT test suite requires the C++ frontend to be
+  enabled at configure-time, or you may see errors like this when
+  running the test suite:
+
+  .. code-block:: console
+
+xgcc: error: /home/david/jit/src/gcc/testsuite/jit.dg/test-quadratic.cc: 
C++ compiler not installed on this system
+c++: error trying to exec 'cc1plus': execvp: No such file or directory
+
 .. option:: --disable-bootstrap
 
   For hacking on the jit subdirectory, performing a full
diff --git a/gcc/testsuite/jit.dg/jit.exp b/gcc/testsuite/jit.dg/jit.exp
index 307cc04..098ce5e 100644
--- a/gcc/testsuite/jit.dg/jit.exp
+++ b/gcc/testsuite/jit.dg/jit.exp
@@ -14,6 +14,20 @@
 # up into the Tcl world, reporting a summary of all results
 # across all of the executables.
 
+# Kludge alert:
+# We need g++_init so that it can find the stdlib include path.
+#
+# g++_init (in lib/g++.exp) uses g++_maybe_build_wrapper,
+# which normally comes from the definition of
+# ${tool}_maybe_build_wrapper within lib/wrapper.exp.
+#
+# However, for us, ${tool} is jit.
+# Hence we load wrapper.exp with tool == g++, so that
+# g++_maybe_build_wrapper is defined.
+set tool g++
+load_lib wrapper.exp
+set tool jit
+
 load_lib dg.exp
 load_lib prune.exp
 load_lib target-supports.exp
@@ -21,6 +35,7 @@ load_lib gcc-defs.exp
 load_lib timeout.exp
 load_lib target-libpath.exp
 load_lib gcc.exp
+load_lib g++.exp
 load_lib dejagnu.exp
 
 # Look for lines of the form:
@@ -264,17 +279,25 @@ if ![info exists GCC_UNDER_TEST] {
 set GCC_UNDER_TEST [find_gcc]
 }
 
+g++_init
+
 # Initialize dg.
 dg-init
 
 # Gather a list of all tests.
 
-# Tests within the testsuite: gcc/testsuite/jit.dg/test-*.c
-set tests [lsort [find $srcdir/$subdir test-*.c]]
+# C tests within the testsuite: gcc/testsuite/jit.dg/test-*.c
+set tests [find $srcdir/$subdir test-*.c]
+
+# C++ tests within the testsuite: gcc/testsuite/jit.dg/test-*.cc
+set tests [concat $tests [find $srcdir/$subdir test-*.cc]]
 
 # We also test the examples within the 

[PATCH, committed] jit.exp: Don't drop the extension from the testcase when naming executable

2015-01-07 Thread David Malcolm
Previously, test-foo.c would be built by jit.exp as test-foo.exe.

However, we have various test-foo.c vs test-foo.cc testcases.  We don't
want them to clobber each other's executables (especially if we're going
to parallelize the jit testsuite).

Hence retain the extension, so they are built to test-foo.c.exe and
test-foo.cc.exe.

Doing so also ensures that the source name makes it into the pass/fail
output, so that we can distinguish e.g. which test-foo is failing.

jit.sum remains:
   # of expected passes 5008
(we don't yet actually run the .cc testcases due to another issue, but
this patch ought to help with debugging that)
 
Committed to trunk as r219312.

gcc/jit/ChangeLog:
* docs/internals/index.rst: Update to reflect that built
testcases are now test-foo.c.exe, rather than test-foo.exe.
* docs/_build/texinfo/libgccjit.texi: Regenerate.

gcc/testsuite/ChangeLog:
* jit.dg/jit.exp (jit-dg-test): Remove rootname call when
generating name of built executable.
---
 gcc/jit/docs/internals/index.rst |  8 
 gcc/testsuite/jit.dg/jit.exp | 14 +-
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/gcc/jit/docs/internals/index.rst b/gcc/jit/docs/internals/index.rst
index 50c55b0..694f058 100644
--- a/gcc/jit/docs/internals/index.rst
+++ b/gcc/jit/docs/internals/index.rst
@@ -125,7 +125,7 @@ and once a test has been compiled, you can debug it 
directly:
LD_LIBRARY_PATH=. \
LIBRARY_PATH=. \
  gdb --args \
-   testsuite/jit/test-factorial.exe
+   testsuite/jit/test-factorial.c.exe
 
 Running under valgrind
 **
@@ -161,11 +161,11 @@ For example, the following invocation verbosely runs the 
testcase
 
   $ less testsuite/jit/jit.sum
   (...other results...)
-  XFAIL: jit.dg/test-sum-of-squares.c: test-sum-of-squares.exe.valgrind.txt: 
definitely lost: 8 bytes in 1 blocks
-  XFAIL: jit.dg/test-sum-of-squares.c: test-sum-of-squares.exe.valgrind.txt: 
unsuppressed errors: 1
+  XFAIL: jit.dg/test-sum-of-squares.c: test-sum-of-squares.c.exe.valgrind.txt: 
definitely lost: 8 bytes in 1 blocks
+  XFAIL: jit.dg/test-sum-of-squares.c: test-sum-of-squares.c.exe.valgrind.txt: 
unsuppressed errors: 1
   (...other results...)
 
-  $ less testsuite/jit/test-sum-of-squares.exe.valgrind.txt
+  $ less testsuite/jit/test-sum-of-squares.c.exe.valgrind.txt
   (...shows full valgrind report for this test case...)
 
 When running under valgrind, it's best to have configured gcc with
diff --git a/gcc/testsuite/jit.dg/jit.exp b/gcc/testsuite/jit.dg/jit.exp
index 454e656..474d6f8 100644
--- a/gcc/testsuite/jit.dg/jit.exp
+++ b/gcc/testsuite/jit.dg/jit.exp
@@ -325,7 +325,19 @@ proc jit-dg-test { prog do_what extra_tool_flags } {
 }
 
 # Determine what to name the built executable.
-set output_file [file rootname [file tail $prog]].exe
+#
+# We simply append .exe to the filename, e.g.
+#  test-foo.c.exe
+# since some testcases exist in both
+#  test-foo.c and
+#  test-foo.cc
+# variants, and we don't want them to clobber each other's
+# executables.
+#
+# This also ensures that the source name makes it into the
+# pass/fail output, so that we can distinguish e.g. which test-foo
+# is failing.
+set output_file [file tail $prog].exe
 verbose output_file: $output_file
 
 # Create the test executable:
-- 
1.8.5.3



Re: [PATCH 1/2, libgo] Add reflection support to gccgo for ppc64, ppc64le in gcc 4.9

2015-01-07 Thread Lynn A. Boger
Would it be possible to add this patch to the gcc 4.9 branch as is? It 
provides most of the basic support for reflection on ppc64 and ppc64le, 
which does not work at all currently.  Once I get the 
libgo/go/reflect/all_test.go working I can add the patch for the fixes 
and enable the testcase for these goarch values in a later submission.


Thanks.

On 01/06/2015 12:38 PM, Lynn A. Boger wrote:
Sorry, hold off on this one for now.  I missed the update to 
libgo/go/reflect/all_test.go for ppc64 and ppc64le in this patch and 
when changed to actually test these goarch values it is failing.


On 01/06/2015 09:37 AM, Lynn A. Boger wrote:
Add support for reflection for gccgo in gcc 4.9.  This is not a 
backport because reflection support in gcc trunk is done using FFI. 
Bootstrap built and tested on ppc64, ppc64le.


2015-01-06Lynn Boger labo...@linux.vnet.ibm.com

* libgo/Makefile.am:  Build the new files for libgo reflection 
support on ppc64, ppc64le

* libgo/Makefile.in:  same
* libgo/go/reflect/makefunc.go:  Invoke reflection functions for 
ppc64, ppc64le

* libgo/go/reflect/makefunc_ppc.c:  makeFuncStub for ppc64, ppc64le
* libgo/go/reflect/makefuncgo_ppc.go:  MakeFuncStubGo and 
argument handling for ppc64, ppc64le











[PATCH] IPA ICF: add comparison for target and optimization nodes

2015-01-07 Thread Martin Liška

Hello.

Following patch adds support for target and optimization nodes comparison, 
which is
based on Honza's newly added infrastructure.

Apart from that, there's a small hunk that corrects formatting and removes 
unnecessary
call to a comparison function.

Hope it can be applied as one patch.

Tested on x86_64-linux-pc without any new regression introduction.

Ready for trunk?

Thank you,
Martin
From 393eaa47c8aef9a91a1c635016f23ca2f5aa25e4 Mon Sep 17 00:00:00 2001
From: mliska mli...@suse.cz
Date: Tue, 6 Jan 2015 15:06:18 +0100
Subject: [PATCH] IPA ICF: target and optimization flags comparison.

gcc/ChangeLog:

2015-01-06  Martin Liska  mli...@suse.cz

	* cgraphunit.c (cgraph_node::create_wrapper): Fix level of indentation.
	* ipa-icf.c (sem_function::equals_private): Add support for target and
	(sem_item_optimizer::merge_classes): Remove redundant function
	comparison.
	optimization flags comparison.
	* tree.h (target_opts_for_fn): New function.
---
 gcc/cgraphunit.c | 52 ++--
 gcc/ipa-icf.c| 44 +++-
 gcc/tree.h   | 10 ++
 3 files changed, 79 insertions(+), 27 deletions(-)

diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index c8c8562..81246e2 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -2385,40 +2385,40 @@ cgraphunit_c_finalize (void)
 void
 cgraph_node::create_wrapper (cgraph_node *target)
 {
-/* Preserve DECL_RESULT so we get right by reference flag.  */
-tree decl_result = DECL_RESULT (decl);
+  /* Preserve DECL_RESULT so we get right by reference flag.  */
+  tree decl_result = DECL_RESULT (decl);
 
-/* Remove the function's body but keep arguments to be reused
-   for thunk.  */
-release_body (true);
-reset ();
+  /* Remove the function's body but keep arguments to be reused
+ for thunk.  */
+  release_body (true);
+  reset ();
 
-DECL_RESULT (decl) = decl_result;
-DECL_INITIAL (decl) = NULL;
-allocate_struct_function (decl, false);
-set_cfun (NULL);
+  DECL_RESULT (decl) = decl_result;
+  DECL_INITIAL (decl) = NULL;
+  allocate_struct_function (decl, false);
+  set_cfun (NULL);
 
-/* Turn alias into thunk and expand it into GIMPLE representation.  */
-definition = true;
-thunk.thunk_p = true;
-thunk.this_adjusting = false;
+  /* Turn alias into thunk and expand it into GIMPLE representation.  */
+  definition = true;
+  thunk.thunk_p = true;
+  thunk.this_adjusting = false;
 
-cgraph_edge *e = create_edge (target, NULL, 0, CGRAPH_FREQ_BASE);
+  cgraph_edge *e = create_edge (target, NULL, 0, CGRAPH_FREQ_BASE);
 
-tree arguments = DECL_ARGUMENTS (decl);
+  tree arguments = DECL_ARGUMENTS (decl);
 
-while (arguments)
-  {
-	TREE_ADDRESSABLE (arguments) = false;
-	arguments = TREE_CHAIN (arguments);
-  }
+  while (arguments)
+{
+  TREE_ADDRESSABLE (arguments) = false;
+  arguments = TREE_CHAIN (arguments);
+}
 
-expand_thunk (false, true);
-e-call_stmt_cannot_inline_p = true;
+  expand_thunk (false, true);
+  e-call_stmt_cannot_inline_p = true;
 
-/* Inline summary set-up.  */
-analyze ();
-inline_analyze_function (this);
+  /* Inline summary set-up.  */
+  analyze ();
+  inline_analyze_function (this);
 }
 
 #include gt-cgraphunit.h
diff --git a/gcc/ipa-icf.c b/gcc/ipa-icf.c
index c7ba75a..28158b3 100644
--- a/gcc/ipa-icf.c
+++ b/gcc/ipa-icf.c
@@ -427,6 +427,49 @@ sem_function::equals_private (sem_item *item,
   if (!equals_wpa (item, ignored_nodes))
 return false;
 
+  /* Checking function TARGET and OPTIMIZATION flags.  */
+  cl_target_option *tar1 = target_opts_for_fn (decl);
+  cl_target_option *tar2 = target_opts_for_fn (m_compared_func-decl);
+
+  if (tar1 != NULL || tar2 != NULL)
+{
+  if (!cl_target_option_eq (tar1, tar2))
+	{
+	  if (dump_file  (dump_flags  TDF_DETAILS))
+	{
+	  fprintf (dump_file, Source target flags\n);
+	  cl_target_option_print (dump_file, 2, tar1);
+	  fprintf (dump_file, Target target flags\n);
+	  cl_target_option_print (dump_file, 2, tar2);
+	}
+
+	  return return_false_with_msg (Target flags are different);
+	}
+}
+  else if (tar1 != NULL || tar2 != NULL)
+return return_false_with_msg (Target flags are different);
+
+  cl_optimization *opt1 = opts_for_fn (decl);
+  cl_optimization *opt2 = opts_for_fn (m_compared_func-decl);
+
+  if (opt1 != NULL  opt2 != NULL)
+{
+  if (memcmp (opt1, opt2, sizeof(cl_optimization)))
+	{
+	  if (dump_file  (dump_flags  TDF_DETAILS))
+	{
+	  fprintf (dump_file, Source optimization flags\n);
+	  cl_optimization_print (dump_file, 2, opt1);
+	  fprintf (dump_file, Target optimization flags\n);
+	  cl_optimization_print (dump_file, 2, opt2);
+	}
+
+	  return return_false_with_msg (optimization flags are different);
+	}
+}
+  else if (opt1 != NULL || opt2 != NULL)
+return return_false_with_msg (optimization flags are 

Re: [PATCH] LRA: Fix caller-save store/restore instruction for large mode

2015-01-07 Thread Kito Cheng
Hi Bin:

It's 2 more line than gcc.c-torture/execute/scal-to-vec1.c since it's
need specific compilation
flag and specific target to reproduce this issue,
and it's can't reproduce by normal testing flow with
arm-*-linux-gnueabi (due to lack -fPIC flag),
so I prefer duplicate this case into gcc.target/arm/ :)

/* { dg-do compile } */
/* { dg-options -O3 -fPIC -marm -mcpu=cortex-a8 } */

On Wed, Jan 7, 2015 at 4:50 PM, Bin.Cheng amker.ch...@gmail.com wrote:
 On Wed, Jan 7, 2015 at 4:03 PM, Kito Cheng kito.ch...@gmail.com wrote:
 Hi Jeff:

 It's updated patch,bootstrapped and run regression tested on arm-eabi,
 arm-none-linux-uclibcgnueabi, x86_64-unknown-linux-gnu and nds32le-elf
 without introducing regression.

 Thanks for your review :)

 2015-01-07  Kito Cheng  k...@0xlab.org

 PR target/64348
 * lra-constraints.c (split_reg): Fix caller-save store/restore
 instruction generation.

 Thanks for fixing the issue.
 The PR is against existing testcase failure
 gcc.c-torture/execute/scal-to-vec1.c.  Unless we can create a new
 case, there is no need to include same case twice I think?  Or we can
 mention the PR number in the original test case?

 Thanks,
 bin


Re: [Patch, libstdc++/64239] Use std::swap instead of swap in regex

2015-01-07 Thread Jonathan Wakely

On 06/01/15 21:03 -0800, Tim Shen wrote:

Bootstrapped and tested. It could be also patched to 4.9 branch.

Thanks!


--
Regards,
Tim Shen



commit dfe3a26759893849020a659b14fafe8b27e90dae
Author: timshen tims...@google.com
Date:   Tue Jan 6 19:30:27 2015 -0800

PR libstdc++/64239



No blank line here in the ChangeLog.


* include/bits/regex.h (match_results::swap): Use std::swap
instead of swap.
* include/bits/regex_compiler.tcc (_Compiler::_M_quantifier):
Likewise.

diff --git a/libstdc++-v3/include/bits/regex.h 
b/libstdc++-v3/include/bits/regex.h
index 9b7ed8c..b520039 100644
--- a/libstdc++-v3/include/bits/regex.h
+++ b/libstdc++-v3/include/bits/regex.h
@@ -1864,7 +1864,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
  swap(match_results __that)
  {
_Base_type::swap(__that);
-   swap(_M_begin, __that._M_begin);
+   std::swap(_M_begin, __that._M_begin);


This is swapping iterators, which can be user-defined types, so it
should support finding a swap function by ADL, i.e.

   using std::swap;
   swap(_M_begin, __that._M_begin);


  }
  //@}


Also, there should be a new test, since apparently we don't have any
test that tries to call match_results::swap(match_results).



[AARCH64][PR63424][4.9]Backport Fix PR63424 by adding sumaxminv2di3 pattern

2015-01-07 Thread Renlin Li

Hi all,

This is a backport patch to fix PR63424. The previous change in trunk is 
here: https://gcc.gnu.org/ml/gcc-patches/2014-10/msg03306.html
and commit log is here: 
https://gcc.gnu.org/viewcvs/gcc?view=revisionrevision=217786


aarch64-none-elf toolchain has been tested on the model, no regressions.

Is it Okay for branch 4.9?

gcc/ChangeLog:

2014-11-19 Renlin Li renlin...@arm.com
PR target/63424
* config/aarch64/aarch64-simd.md (sumaxminv2di3): New.

gcc/testsuite/ChangeLog:

2014-11-19 Renlin Li renlin...@arm.com
PR target/63424
* gcc.target/aarch64/pr63424.c: New Test.

diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md
index cab26a3..41ddbb4 100644
--- a/gcc/config/aarch64/aarch64-simd.md
+++ b/gcc/config/aarch64/aarch64-simd.md
@@ -951,6 +951,41 @@
   [(set_attr type neon_minmaxq)]
 )
 
+(define_expand sumaxminv2di3
+  [(parallel [
+(set (match_operand:V2DI 0 register_operand )
+	 (MAXMIN:V2DI (match_operand:V2DI 1 register_operand )
+		  (match_operand:V2DI 2 register_operand )))
+(clobber (reg:CC CC_REGNUM))])]
+  TARGET_SIMD
+{
+  enum rtx_code cmp_operator;
+  rtx cmp_fmt;
+
+  switch (CODE)
+{
+case UMIN:
+  cmp_operator = LTU;
+  break;
+case SMIN:
+  cmp_operator = LT;
+  break;
+case UMAX:
+  cmp_operator = GTU;
+  break;
+case SMAX:
+  cmp_operator = GT;
+  break;
+default:
+  gcc_unreachable ();
+}
+
+  cmp_fmt = gen_rtx_fmt_ee (cmp_operator, V2DImode, operands[1], operands[2]);
+  emit_insn (gen_aarch64_vcond_internalv2div2di (operands[0], operands[1],
+  operands[2], cmp_fmt, operands[1], operands[2]));
+  DONE;
+})
+
 ;; vec_concat gives a new vector with the low elements from operand 1, and
 ;; the high elements from operand 2.  That is to say, given op1 = { a, b }
 ;; op2 = { c, d }, vec_concat (op1, op2) = { a, b, c, d }.
diff --git a/gcc/testsuite/gcc.target/aarch64/pr63424.c b/gcc/testsuite/gcc.target/aarch64/pr63424.c
new file mode 100644
index 000..c6bd762
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr63424.c
@@ -0,0 +1,39 @@
+/* { dg-do compile } */
+/* { dg-options -O3 } */
+
+#include stdint.h
+
+uint32_t
+truncate_int (const unsigned long long value)
+{
+  if ( value  0 )
+{
+  return 0;
+}
+  else if ( value  UINT32_MAX )
+{
+  return UINT32_MAX;
+}
+  else
+return (uint32_t)value;
+}
+
+uint32_t
+mul (const unsigned long long x, const unsigned long long y)
+{
+  uint32_t value = truncate_int (x * y);
+  return value;
+}
+
+uint32_t *
+test(unsigned size, uint32_t *a, uint32_t s)
+{
+  unsigned i;
+
+  for (i = 0; i  size; i++)
+{
+  a[i] = mul (a[i], s);
+}
+
+  return a;
+}

Re: [gofrontend-dev] [PATCH 1/2, libgo] Add reflection support to gccgo for ppc64, ppc64le in gcc 4.9

2015-01-07 Thread Lynn A. Boger
In libgo/go/reflect/makefunc.go, calls to MakeFunc, makeMethodValue and 
makeValueMethod will panic if called when GOARCH is ppc64 or ppc64le.


I understand your point about what you allow into a release branch and 
since it has known bugs with an existing testcase then I agree it 
shouldn't be accepted the way it is.  I will work on fixing that and 
then figure out what branch is best to include it in.


On 01/07/2015 10:54 AM, Ian Lance Taylor wrote:

On Wed, Jan 7, 2015 at 8:43 AM, Lynn A. Boger
labo...@linux.vnet.ibm.com wrote:

I thought that since this only affects ppc64 and ppc64le, and provides
reflection support that doesnt exist in gcc 4.9 for Power (you get a panic
if you try to use reflection on ppc64, ppc64le), it would be OK.

I understand that the code doesn't work today in 4.9, but a release
branch is for releases and backports of bug fixes, not for any sort of
new development.

(As far as I knoew reflection works in general for PPC in 4.9, it's
just reflect.MakeFunc, a rarely used feature, that is broken.)

Ian