Re: [PATCH] Add missing explicit instantiation for std::lower_bound template

2013-02-06 Thread Dodji Seketeli
Paolo Carlini paolo.carl...@oracle.com writes:

 Since commit r195676[1], it looks like
 libstdc++-v3/src/c++11/hashtable_c++0x.cc is missing an explicit
 instantiation for std::lower_bound.  This leads to libstdc++.so having
 the symbol for that (missing) instantiation be undefined, thus
 preventing executables from being linked with libstdc++.
 Note that I can confirm this only if I build with less optimization
 than the default -O2, say -O. That may explain why nobody noticed
 earlier.

Ah, right.  It's true that I build on my machine without optimization so
that I can debug problems that show up on my local machine.  And I
always forget that I do that.

 The patchlet below seems to fixed the issue for me.

 Indeed, I think we want something like that. Thanks. In terms of nits,
 formatting and types (who knows, maybe on some systems a std::size_t
 is an unsigned long long), I would write something like the
 attached. Please double check that it works for you and go ahead.

Great!  Your amendments work well for me.  I committed it to trunk.

Thank you.

-- 
Dodji


Re: [PATCH 1/2] PowerPC testsuite clean up

2013-02-06 Thread Sebastian Huber

Would someone mind having a look at this.

On 01/29/2013 03:38 PM, Sebastian Huber wrote:

2013-01-18  Sebastian Huber  sebastian.hu...@embedded-brains.de

* lib/target-supports.exp
(check_effective_target_powerpc_eabi_ok): New.
* gcc.target/powerpc/ppc-eabi.c: Use require effective target
powerpc_eabi_ok.
* gcc.target/powerpc/ppc-sdata-1.c: Likewise.
* gcc.target/powerpc/spe-small-data-2.c: Likewise.
* gcc.target/powerpc/ppc-sdata-2.c: Add powerpc-*-rtems*.
* gcc.target/powerpc/pr51623.c: Likewise.
* gcc.target/powerpc/ppc-stackalign-1.c: Likewise.
* gcc.target/powerpc/ppc-ldstruct.c: Likewise.
* gcc.target/powerpc/spe-small-data-2.c: Do not run, compile
only.


--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.


Re: [PATCH][ARM][1/3] Add vectorization support for rounding functions

2013-02-06 Thread Ramana Radhakrishnan

On 12/18/12 13:33, Kyrylo Tkachov wrote:

Hi all,

This patch does some refactoring by moving the definitions of the NEON
builtins to a separate file (arm_neon_builtins.def) and includes that when
initialising the neon_builtin_data array and also during
the definition of enum arm_builtins (with appropriate redefinitions of the
VAR* macros). This allows us to have symbolic names for the neon builtins
that allows us to look up their declaration in
arm_builtin_decls. This is needed for vectorisation support in the next
patch. The ARM_BUILTIN_NEON_BASE constant which was defined as part of the
arm_builtins enum is now defined as a macro, since
various functions that deal with the initialisation and expansion of
builtins use it.

No regressions on arm-none-eabi with model.

Ok for trunk?

Thanks,
Kyrill


gcc/ChangeLog

2012-12-18  Kyrylo Tkachov  kyrylo.tkachov at arm.com

* config/arm/arm_neon_builtins.def: New file.
* config/arm/arm.c (neon_builtin_data): Move contents to
  arm_neon_builtins.def.
  (enum arm_builtins): Include neon builtin definitions.
  (ARM_BUILTIN_NEON_BASE): Move from enum to macro.




arm.o in t-arm needs to depend on this new file. Otherwise OK for stage1 .


regards,
Ramana




Re: [PATCH][ARM][2/3] Add vectorization support for rounding functions

2013-02-06 Thread Ramana Radhakrishnan

On 12/18/12 13:33, Kyrylo Tkachov wrote:

Hi all,

This patch adds support for the vectorisation of the rounding functions:
floorf, ceilf, truncf, roundf. These can be implemented using the ARMv8 NEON
instructions: vrintm, vrintp, vrintz, vrinta.
This is done by defining the TARGET_VECTORIZE_BUILTINS and
TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION macros and the function
arm_builtin_vectorized_function that returns the decl of the vector form
of a builtin function, or NULL_TREE if no vector variant exists.

No regressions on arm-none-eabi with AEM.

Ok for trunk?

gcc/ChangeLog

2012-12-18  Kyrylo Tkachov  kyrylo.tkachov at arm.com

* config/arm/arm-protos.h (arm_builtin_vectorized_function):
  New function prototype.
* config/arm/arm.c (TARGET_VECTORIZE_BUILTINS): Define.
  (TARGET_VECTORIZE_BUILTIN_VECTORIZED_FUNCTION): Likewise.
  (arm_builtin_vectorized_function): New function.




Ok for stage1.

regards
Ramana



[Ada] Preliminary work to coordinate Pragma Warnings and middle-end warnings

2013-02-06 Thread Arnaud Charlet
This couple of adjustments paves the way for the full coordination of Pragma
Warnings with the warnings issued by the diagnostic engine of the middle-end.

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

2013-02-06  Eric Botcazou  ebotca...@adacore.com

* erroutc.adb (Validate_Specific_Warning): Do not issue the
warning about an ineffective Pragma Warnings for -Wxxx warnings.
* sem_prag.adb (Analyze_Pragma) Warnings: Accept -Wxxx warnings.
* gnat_rm.texi (Pragma Warnings): Document coordination with
warnings of the GCC back-end.

Index: erroutc.adb
===
--- erroutc.adb (revision 195784)
+++ erroutc.adb (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2012, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2013, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -1282,7 +1282,14 @@
   Eproc.all
 (?pragma Warnings Off with no matching Warnings On,
  SWE.Start);
-   elsif not SWE.Used then
+
+   --  Do not issue this warning for -Wxxx messages since the
+   --  back-end doesn't report the information.
+
+   elsif not SWE.Used
+ and then not (SWE.Msg'Length  2
+ and then SWE.Msg (1 .. 2) = -W)
+   then
   Eproc.all
 (?no warning suppressed by this pragma, SWE.Start);
end if;
Index: gnat_rm.texi
===
--- gnat_rm.texi(revision 195784)
+++ gnat_rm.texi(working copy)
@@ -6154,6 +6154,14 @@
 User's Guide}.
 
 @noindent
+The warnings controlled by the `-gnatw' switch are generated by the front end
+of the compiler. The `GCC' back end can provide additional warnings and they
+are controlled by the `-W' switch.
+The form with a single static_string_EXPRESSION argument also works for the
+latters, but the string must be a single full `-W' switch in this case.
+The above reference lists a few examples of these additional warnings.
+
+@noindent
 The specified warnings will be in effect until the end of the program
 or another pragma Warnings is encountered. The effect of the pragma is
 cumulative. Initially the set of warnings is the standard default set
@@ -6173,6 +6181,12 @@
 expression notations are permitted. All characters other than asterisk in
 these three specific cases are treated as literal characters in the match.
 
+@noindent
+The fourth form also works for the additional warnings of the `GCC' back end,
+but the string must again be a single full `-W' switch in this case. Note that
+the message issued for these warnings explicitly lists the full `-W' switch
+they are associated with.
+
 There are two ways to use the pragma in this form. The OFF form can be used as 
a
 configuration pragma. The effect is to suppress all warnings (if any)
 that match the pattern string throughout the compilation.
Index: sem_prag.adb
===
--- sem_prag.adb(revision 195784)
+++ sem_prag.adb(working copy)
@@ -16017,9 +16017,23 @@
if OK then
   Chr := Get_Character (C);
 
+  --  Dash case: only -Wxxx is accepted
+
+  if J = 1
+and then J  Len
+and then Chr = '-'
+  then
+ J := J + 1;
+ C := Get_String_Char (Str, J);
+ Chr := Get_Character (C);
+ if Chr = 'W' then
+exit;
+ end if;
+ OK := False;
+
   --  Dot case
 
-  if J  Len and then Chr = '.' then
+  elsif J  Len and then Chr = '.' then
  J := J + 1;
  C := Get_String_Char (Str, J);
  Chr := Get_Character (C);


[Ada] Internal clean up for N_Pragma nodes

2013-02-06 Thread Arnaud Charlet
The specification for N_Pragma nodes requires that all pragma arguments
by represented by N_Pragma_Associatin nodes, but in several cases naked
expressions appeared. This patch corrects this irregularity, and also
cleans up the format of Make_Pragma calls throughout these files. This
was noticed during some new development, but does not as far as is known
affect any current functionality. It is only a latent bug, so no test
is needed.

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

2013-02-06  Robert Dewar  de...@adacore.com

* exp_prag.adb, sem_ch3.adb, exp_attr.adb, sem_prag.adb, sem_ch6.adb,
exp_intr.adb, exp_dist.adb, sem_ch13.adb: Internal clean up for
N_Pragma nodes.

Index: exp_prag.adb
===
--- exp_prag.adb(revision 195784)
+++ exp_prag.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2012, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2013, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -513,7 +513,7 @@
 
   Insert_After_And_Analyze (N,
  Make_Pragma (Loc,
-   Chars = Name_Machine_Attribute,
+   Chars= Name_Machine_Attribute,
Pragma_Argument_Associations = New_List (
  Make_Pragma_Argument_Association (Iloc,
Expression = New_Copy_Tree (Internal)),
@@ -644,44 +644,38 @@
(UI_To_Int (Exception_Code (Id)) / 8 * 8);
 
  Excep_Alias :=
-   Make_Pragma
- (Loc,
-  Name_Linker_Alias,
-  New_List
-(Make_Pragma_Argument_Association
-   (Sloc = Loc,
-Expression =
-  New_Reference_To (Excep_Internal, Loc)),
+   Make_Pragma (Loc,
+ Chars= Name_Linker_Alias,
+ Pragma_Argument_Associations = New_List (
+   Make_Pragma_Argument_Association (Loc,
+ Expression =
+   New_Reference_To (Excep_Internal, Loc)),
 
- Make_Pragma_Argument_Association
-   (Sloc = Loc,
-Expression =
-  Make_String_Literal
-(Sloc = Loc,
- Strval = End_String;
+   Make_Pragma_Argument_Association (Loc,
+ Expression =
+   Make_String_Literal (Loc, End_String;
 
  Insert_Action (N, Excep_Alias);
  Analyze (Excep_Alias);
 
  Export_Pragma :=
-   Make_Pragma
- (Loc,
-  Name_Export,
-  New_List
-(Make_Pragma_Argument_Association (Loc,
-   Expression = Make_Identifier (Loc, Name_C)),
+   Make_Pragma (Loc,
+ Chars= Name_Export,
+ Pragma_Argument_Associations = New_List (
+   Make_Pragma_Argument_Association (Loc,
+ Expression = Make_Identifier (Loc, Name_C)),
 
- Make_Pragma_Argument_Association (Loc,
-   Expression =
- New_Reference_To (Excep_Internal, Loc)),
+   Make_Pragma_Argument_Association (Loc,
+ Expression =
+   New_Reference_To (Excep_Internal, Loc)),
 
- Make_Pragma_Argument_Association (Loc,
-   Expression =
- Make_String_Literal (Loc, Excep_Image)),
+   Make_Pragma_Argument_Association (Loc,
+ Expression =
+   Make_String_Literal (Loc, Excep_Image)),
 
- Make_Pragma_Argument_Association (Loc,
-Expression =
-  Make_String_Literal (Loc, Excep_Image;
+   

[patch libada]: PR target/52122

2013-02-06 Thread Kai Tietz
Hi,

this patch fixes an issue about recursice LN_S for mingw-host.  The
issue was already addressed by autotools, but an upgrade of version
isn't suitable right now.
For further information see the bug-report PR 52122.

ChangeLog libada/

PR target/52122
* Makefile.in (LN_S_RECUSIVE): New.
(adainclude, adalib): Use LN_S_RECURSIVE for copy.

Patch see at http://gcc.gnu.org/bugzilla/attachment.cgi?id=29176

Ok for apply?

Regards,
Kai


[Ada] Missing finalization of temporary function results in case and if

2013-02-06 Thread Arnaud Charlet
This patch adds machinery to properly finalize temporary controlled function
results that appear in N_Expression_With_Actions nodes as well as case and if
expressions. In general, such temporaries must be finalized after the related
context is elaborated/evaluated.


-- Source --


--  types.ads

with Ada.Finalization; use Ada.Finalization;
package Types is
   type Ctrl is new Controlled with record
  Data : Natural := 1234;
   end record;

   procedure Finalize (Obj : in out Ctrl);
   function Make_Ctrl (Val : Natural) return Ctrl;
end Types;

--  types.adb

with Ada.Text_IO; use Ada.Text_IO;

package body Types is
   procedure Finalize (Obj : in out Ctrl) is
   begin
  Obj.Data := 0;
  Put_Line (   fin);
   end Finalize;

   function Make_Ctrl (Val : Natural) return Ctrl is
   begin
  return (Controlled with Val);
   end Make_Ctrl;
end Types;

--  main.adb

with Ada.Text_IO; use Ada.Text_IO;
with Types;   use Types;

procedure Main is
   procedure Ensure_Value (Val : Natural; Exp : Natural; Act : Natural) is
   begin
  if Val /= Exp then
 Put_Line (ERROR: transient finalized too early);
 Put_Line (  Expected:  Exp'Img);
 Put_Line (  Got :  Act'Img);
  end if;
   end Ensure_Value;

   function Factorial (Val : Natural) return Natural is
   begin
  if Val  1 then
 return Factorial (Val - 1) * Val;
  else
 return 1;
  end if;
   end Factorial;

   Exp  : constant Natural := 9876;
   Junk : constant Natural := 5432;
   Flag : Boolean;
   Val  : Natural;

begin
   Put_Line (Case expression);
   Val := (case Factorial (3) is
  when 6  = Make_Ctrl (Exp).Data,
  when others = Junk);
   Ensure_Value (Val, Exp, Junk);

   Put_Line (If expression);
   Val := (if Factorial (3) = 6 then
  Make_Ctrl (Exp).Data
   else
  Junk);
   Ensure_Value (Val, Exp, Junk);

   Put_Line (If statement);
   if Val = Exp
 and then Make_Ctrl (Exp).Data = Exp
   then
  Put_Line (  then statements);
   end if;

   Put_Line (Assignment);
   Flag := Val = Exp and then Make_Ctrl (Exp).Data = Exp;

   Put_Line (End);
end Main;


-- Compilation and output --


$ gnatmake -q -gnat12 main.adb
$ ./main
Case expression
   fin
   fin
If expression
   fin
   fin
If statement
   fin
   fin
  then statements
Assignment
   fin
   fin
End

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

2013-02-06  Hristian Kirtchev  kirtc...@adacore.com

* exp_ch4.adb (Expand_N_Expression_With_Actions): Rewritten. This
routine should be able to properly detect controlled transient
objects in its actions and generate the appropriate finalization
actions.
* exp_ch6.adb (Enclosing_Context): Removed.
(Expand_Ctrl_Function_Call): Remove local subprogram and
constant. Use routine Within_Case_Or_If_Expression to determine
whether the lifetime of the function result must be extended to
match that of the context.
* exp_util.ads, exp_util.adb (Within_Case_Or_If_Expression): New
routine.

Index: exp_util.adb
===
--- exp_util.adb(revision 195784)
+++ exp_util.adb(working copy)
@@ -7944,6 +7944,43 @@
   end if;
end Type_May_Have_Bit_Aligned_Components;
 
+   --
+   -- Within_Case_Or_If_Expression --
+   --
+
+   function Within_Case_Or_If_Expression (N : Node_Id) return Boolean is
+  Par : Node_Id;
+
+   begin
+  --  Locate an enclosing case or if expression. Note that these constructs
+  --  appear as expression_with_actions, hence the test using the original
+  --  node.
+
+  Par := N;
+  while Present (Par) loop
+ if Nkind_In (Original_Node (Par), N_Case_Expression,
+   N_If_Expression)
+ then
+return True;
+
+ --  Prevent the search from going too far
+
+ elsif Nkind_In (Par, N_Entry_Body,
+  N_Package_Body,
+  N_Package_Declaration,
+  N_Protected_Body,
+  N_Subprogram_Body,
+  N_Task_Body)
+ then
+return False;
+ end if;
+
+ Par := Parent (Par);
+  end loop;
+
+  return False;
+   end Within_Case_Or_If_Expression;
+

-- Wrap_Cleanup_Procedure --

Index: exp_util.ads
===
--- exp_util.ads(revision 195784)
+++ exp_util.ads(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- S p e 

Re: var-tracking wrt. leaf regs on sparc

2013-02-06 Thread Eric Botcazou
 Now that I understand fully what we're trying to accomplish with the
 DT_OP_GNU_entry_value and DT_OP_GNU_call_site_parameter extensions, it
 does in fact seem like we will need to do leaf register remapping in
 var-tracking.c
 
 Here below is a patch I'm playing with.  It's a rough draft but it
 definitely fixes the pr54200.c problem completely.

Thanks for tackling this.  I cannot really comment on the patch itself (Jakub 
is the resident expert here), only on its idea.  I think that the most correct 
approach would indeed be to also do leaf register remapping in var-tracking.c,
before analyzing the RTL stream, so that everything is correctly exposed.  In 
practice, that might be a little heavy-handed though, so...

 Another way to do this would be to not translate the incoming
 parameter registers (leave them at %i*) if we don't see the window
 save.  That way we only have to play the regno remapping game for
 these specific incoming argument pieces, rather than for everything we
 look at in the RTL stream.

...yes, probably much lighter.  I think testing crtl-uses_only_leaf_regs is 
sufficient here (and while you're at it, you could also test the value of 
HAVE_window_save, which can be 0 if -mflat is passed on the SPARC), so

#ifdef HAVE_window_save
if (HAVE_window_save  !crtl-uses_only_leaf_regs)
  {

  }
#endif

-- 
Eric Botcazou


[Ada] Finalization of temporary controlled function results

2013-02-06 Thread Arnaud Charlet
Finalization of temporary controlled function results in expression with
actions nodes in the context of return statements:

This patch adds logic to recognize a simple return statement as one of the
cases that require special processing with respect to temporary controlled
function results that appear in expression_with_actions nodes.


-- Source --


--  types.ads

with Ada.Finalization; use Ada.Finalization;

package Types is
   type Ctrl is new Controlled with record
  Data : Natural := 1234;
   end record;

   function Equal_To_1 (Obj : Ctrl) return Boolean;
   procedure Finalize (Obj : in out Ctrl);
   function Make_Ctrl (Val : Natural) return Ctrl;
end Types;

--  types.adb

with Ada.Text_IO; use Ada.Text_IO;

package body Types is
   function Equal_To_1 (Obj : Ctrl) return Boolean is
   begin
  return Obj.Data = 1;
   end Equal_To_1;

   procedure Finalize (Obj : in out Ctrl) is
   begin
  Obj.Data := 0;
  Put_Line (   fin);
   end Finalize;

   function Make_Ctrl (Val : Natural) return Ctrl is
   begin
  return (Controlled with Val);
   end Make_Ctrl;
end Types;

--  main.adb

with Ada.Text_IO; use Ada.Text_IO;
with Types;   use Types;

procedure Main is
   function Must_Be_True return Boolean is
  function Factorial (Val : Natural) return Natural is
  begin
 if Val  1 then
return Val * Factorial (Val - 1);
 else
return 1;
 end if;
  end Factorial;
   begin
  return
Factorial (3) = 6
  and then Equal_To_1 (Make_Ctrl (1));
   end Must_Be_True;
begin
   if not Must_Be_True then
  Put_Line (ERROR: temporary function result finalized too early);
   end if;
end Main;


-- Compilation and output --


$ gnatmake -q main.adb
$ ./main
   fin
   fin

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

2013-02-06  Hristian Kirtchev  kirtc...@adacore.com

* exp_ch4.adb (Find_Enclosing_Context): Recognize
a simple return statement as one of the cases that require special
processing with respect to temporary controlled function results.
(Process_Transient_Object): Do attempt to finalize a temporary
controlled function result when the associated context is
a simple return statement.  Instead, leave this task to the
general finalization mechanism.

Index: exp_ch4.adb
===
--- exp_ch4.adb (revision 195790)
+++ exp_ch4.adb (working copy)
@@ -5038,7 +5038,7 @@
 --  Start of processing for Find_Enclosing_Context
 
 begin
-   --  The expression_with_action is in a case or if expression and
+   --  The expression_with_actions is in a case/if expression and
--  the lifetime of any temporary controlled object is therefore
--  extended. Find a suitable insertion node by locating the top
--  most case or if expressions.
@@ -5088,12 +5088,12 @@
 
   return Par;
 
-   --  Shor circuit operators in complex expressions are converted
+   --  Short circuit operators in complex expressions are converted
--  into expression_with_actions.
 
else
   --  Take care of the case where the expression_with_actions
-  --  is burried deep inside an if statement. The temporary
+  --  is buried deep inside an IF statement. The temporary
   --  function result must be finalized before the then, elsif
   --  or else statements are evaluated.
 
@@ -5123,7 +5123,7 @@
 
   Top := Par;
 
-  --  The expression_with_action might be located in a pragm
+  --  The expression_with_actions might be located in a pragma
   --  in which case locate the pragma itself:
 
   --pragma Precondition (... and then Ctrl_Func_Call ...);
@@ -5133,10 +5133,16 @@
 
   --Obj [: Some_Typ] := ... and then Ctrl_Func_Call ...;
 
+  --  Another case to consider is an expression_with_actions as
+  --  part of a return statement:
+
+  --return ... and then Ctrl_Func_Call ...;
+
   while Present (Par) loop
  if Nkind_In (Par, N_Assignment_Statement,
N_Object_Declaration,
-   N_Pragma)
+   N_Pragma,
+   N_Simple_Return_Statement)
  then
 return Par;
 
@@ -5238,23 +5244,32 @@
 --   Temp := null;
 --end if;
 
-Insert_Action_After (Context,
-  Make_If_Statement (Loc,
-Condition =
-   

[Ada] Read references in ali files for out-mode parameters

2013-02-06 Thread Arnaud Charlet
The frontend was unconditionally generating a read reference for OUT
parameters. After this patch the compiler generates the read reference
only for those cases specified by RM 6.4.1(12).

package Pkg is
  procedure Write (I : out Integer);
  procedure Update (I : in out Integer);
end Pkg;

package body Pkg is
   procedure Write (I : out Integer) is
  pragma Unreferenced (I);
   begin
  null;
   end Write;

   procedure Update (I : in out Integer) is
  pragma Unreferenced (I);
   begin
  null;
   end Update;
end Pkg;

with Pkg;
procedure TEST is
 J : Integer := 0;
begin
  Pkg.Write(J);  -- out
  Pkg.Update(J); -- in out
end;

Command:
  gcc -c test.adb
  grep -i ^3i2 test.ali
Output:
  3i2 J{integer} 5m13 6m14 6r14

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

2013-02-06  Javier Miranda  mira...@adacore.com

* sem_res.adb (Resolve_Actuals): Generate a read
reference for out-mode parameters in the cases specified by
RM 6.4.1(12).

Index: sem_res.adb
===
--- sem_res.adb (revision 195784)
+++ sem_res.adb (working copy)
@@ -3409,7 +3409,46 @@
   Generate_Reference (Orig_A, A, 'm');
 
elsif not Is_Overloaded (A) then
-  Generate_Reference (Orig_A, A);
+  if Ekind (F) /= E_Out_Parameter then
+ Generate_Reference (Orig_A, A);
+
+  --  RM 6.4.1(12): For an out parameter that is passed by
+  --  copy, the formal parameter object is created, and:
+
+  --  * For an access type, the formal parameter is initialized
+  --from the value of the actual, without checking that the
+  --value satisfies any constraint, any predicate, or any
+  --exclusion of the null value.
+
+  --  * For a scalar type that has the Default_Value aspect
+  --specified, the formal parameter is initialized from the
+  --value of the actual, without checking that the value
+  --satisfies any constraint or any predicate;
+
+  --  * For a composite type with discriminants or that has
+  --implicit initial values for any subcomponents, the
+  --behavior is as for an in out parameter passed by copy.
+
+  --  Hence for these cases we generate the read reference now
+  --  (the write reference will be generated later by
+  --   Note_Possible_Modification).
+
+  elsif Is_By_Copy_Type (Etype (F))
+and then
+  (Is_Access_Type (Etype (F))
+ or else
+   (Is_Scalar_Type (Etype (F))
+  and then
+Present (Default_Aspect_Value (Etype (F
+ or else
+   (Is_Composite_Type (Etype (F))
+  and then
+(Has_Discriminants (Etype (F))
+   or else
+ Is_Partially_Initialized_Type (Etype (F)
+  then
+ Generate_Reference (Orig_A, A);
+  end if;
end if;
 end if;
  end if;


[Ada] Crash when processing attribute Loop_Entry

2013-02-06 Thread Arnaud Charlet
This patch suppresses the resolution of the prefix of attribute Loop_Entry. The
resolution still takes place after Loop_Entry has been transformed into the
initialization expression of a constant. The delay ensures that any generated
checks or temporaries are inserted before the relocated prefix.

-
-- Sources --
-

--  main.adb:

with Ada.Text_IO; use Ada.Text_IO;

procedure Main is
   type Int_Array is array (Natural range ) of Natural;

   procedure Process_Array (Obj : Int_Array) is
  Var : Natural := 0;
   begin
  for Index in Natural range Obj'Range loop
 Var := Var + 1;
 pragma Loop_Invariant (Obj (Obj'First + Var)'Loop_Entry = 10);
  end loop;
  Put_Line (Integer'Image (Var));
   end Process_Array;

   X : Int_Array (1 .. 0);
begin
   Process_Array (X);
end Main;


-- Compilation and output --


$ gnatmake -q -gnat12 -gnata -gnatd.V main.adb
$ ./main
 0

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

2013-02-06  Hristian Kirtchev  kirtc...@adacore.com

* sem_attr.adb (Resolve_Attribute): Do not resolve the prefix of
Loop_Entry, instead wait until the attribute has been expanded. The
delay ensures that any generated checks or temporaries are inserted
before the relocated prefix.

Index: sem_attr.adb
===
--- sem_attr.adb(revision 195784)
+++ sem_attr.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2012, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2013, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -9821,6 +9821,18 @@
  when Attribute_Enabled =
 null;
 
+ 
+ -- Loop_Entry --
+ 
+
+ --  Do not resolve the prefix of Loop_Entry, instead wait until the
+ --  attribute has been expanded (see Expand_Loop_Entry_Attributes).
+ --  The delay ensures that any generated checks or temporaries are
+ --  inserted before the relocated prefix.
+
+ when Attribute_Loop_Entry =
+null;
+
  
  -- Mechanism_Code --
  


[Ada] Runtime check on assignment to tagged types

2013-02-06 Thread Arnaud Charlet
On assignments to tagged types the compiler unconditionally generates
the runtime check of the tag (even when compiling with -gnatp). After
this patch such extra runtime check is not generated.

package Test is
   type Tagged_Simple_Record is tagged
  record
 Field1 : Integer;
  end record;
   function F1 (This : Tagged_Simple_Record)
 return Tagged_Simple_Record;

   Global_SR : Tagged_Simple_Record;

   procedure Call_Dispatching_Ops
 (Class_Obj1 : Tagged_Simple_Record'Class;
  Class_Obj2 : out Tagged_Simple_Record'Class);
end Test;

package body Test is

   function F1 (This : Tagged_Simple_Record)
 return Tagged_Simple_Record is
   begin
  return This;
   end F1;

   procedure Call_Dispatching_Ops
 (Class_Obj1 : Tagged_Simple_Record'Class;
  Class_Obj2 : out Tagged_Simple_Record'Class) is
   begin
  Class_Obj2 := F1 (Class_Obj1);
   end Call_Dispatching_Ops;

end Test;

Command:
  gcc -c -gnatp -gnatD test.adb
  grep -i tag check test.adb.dg

Output:
  none

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

2013-02-06  Javier Miranda  mira...@adacore.com

* exp_ch5.adb (Expand_N_Assignment_Statement): Do not generate the
runtime check on assignment to tagged types if compiling with checks
suppressed.

Index: exp_ch5.adb
===
--- exp_ch5.adb (revision 195792)
+++ exp_ch5.adb (working copy)
@@ -2476,7 +2476,8 @@
   --  the assignment we generate run-time check to ensure that
   --  the tags of source and target match.
 
-  if Is_Class_Wide_Type (Typ)
+  if not Tag_Checks_Suppressed (Typ)
+and then Is_Class_Wide_Type (Typ)
 and then Is_Tagged_Type (Typ)
 and then Is_Tagged_Type (Underlying_Type (Etype (Rhs)))
   then


[Ada] Implement Rational profile to support non-standard renaming declarations

2013-02-06 Thread Arnaud Charlet
We introduce the profile Rational and the corresponding pragma to support
legacy Rational code that accepts subprogram renaming declarations that are
not conformant to the RM.
The following program, compiled with -gnatc, must generate the message:

   ren.ads:12:51: subprogram cannot rename itself

The program must compile quietly if the pragma is uncommented.

---
--  pragma Rational;
package Ren is
   package P is
  type T is null record;
  function F (Obj : T) return integer;
   end P;

   use P;
   type DT is new T;
   package RR renames Ren;

   function F (New_Parameter : DT) return Integer renames RR.F;
end;

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

2013-02-06  Ed Schonberg  schonb...@adacore.com

* snames.ads-tmpl: Add Name_Rational and pragma Rational.
* par-prag.adb: Recognize pragma Rational.
* opt.ads (Rational_Profile): flag to control compatibility mode
with Rational compiler.
* sem_ch8.adb (Analyze_Subprogram_Renaming): When Rational profile
is enable, accept renaming declarations where the new subprogram
and the renamed entity have the same name.
* sem_prag.adb (analyze_pragma): Add pragma Rational, and recognize
Rational as a profile.

Index: sem_prag.adb
===
--- sem_prag.adb(revision 195788)
+++ sem_prag.adb(working copy)
@@ -13859,7 +13859,7 @@
 
  --  pragma Profile (profile_IDENTIFIER);
 
- --  profile_IDENTIFIER = Restricted | Ravenscar
+ --  profile_IDENTIFIER = Restricted | Ravenscar | Rational
 
  when Pragma_Profile =
 Ada_2005_Pragma;
@@ -13879,6 +13879,9 @@
 (Restricted,
  N, Warn = Treat_Restrictions_As_Warnings);
 
+   elsif Chars (Argx) = Name_Rational then
+  Rational_Profile := True;
+
elsif Chars (Argx) = Name_No_Implementation_Extensions then
   Set_Profile_Restrictions
 (No_Implementation_Extensions,
@@ -14275,6 +14278,15 @@
 end if;
  end;
 
+ --
+ -- Rational --
+ --
+
+ --  pragma Rational, for compatibility with foreign compiler
+
+ when Pragma_Rational =
+Rational_Profile := True;
+
  ---
  -- Relative_Deadline --
  ---
@@ -16599,6 +16611,7 @@
   Pragma_Pure_12= -1,
   Pragma_Pure_Function  = -1,
   Pragma_Queuing_Policy = -1,
+  Pragma_Rational   = -1,
   Pragma_Ravenscar  = -1,
   Pragma_Relative_Deadline  = -1,
   Pragma_Remote_Access_Type = -1,
Index: par-prag.adb
===
--- par-prag.adb(revision 195784)
+++ par-prag.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2012, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2013, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -1245,6 +1245,7 @@
Pragma_Remote_Call_Interface  |
Pragma_Remote_Types   |
Pragma_Restricted_Run_Time|
+   Pragma_Rational   |
Pragma_Ravenscar  |
Pragma_Reviewable |
Pragma_Share_Generic  |
Index: sem_ch8.adb
===
--- sem_ch8.adb (revision 195784)
+++ sem_ch8.adb (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2012, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2013, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -2804,18 +2804,25 @@
 end if;
  end if;
 
- if not Is_Actual
-   and 

PING: Re: [PATCH] : Fix for PR 52123 gcc bootstrap with ada fails on mingw target

2013-02-06 Thread Rainer Emrich
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

I like to have this in trunk as soon as possible, because I want to backport
to 4.7.3 before the release.

Tested on x86_64-w64-mingw32 and x86_64-unknown-gnu-linux.

Cheers

Rainer

Am 03.01.2013 14:06, schrieb Rainer Emrich:
 Hello,
 
 this trivial patch fixes the bootstrap with ada on mingw targets. The right
 casts fix the invalid conversion issues. Patch is against trunk.
 
 ada/
 
 PR 52123 * adaint.c (__gnat_check_OWNER_ACL): Cast from pointer via 
 SECURITY_DESCRIPTOR * (__gnat_set_OWNER_ACL): Cast from DWORD to
 ACCESS_MODE (__gnat_portable_spawn): Fix cast to char* const* (add_handle):
 Cast from pointer via void ** (add_handle): Cast from pointer via int * 
 (__gnat_locate_exec_on_path): Cast from pointer via TCHAR * 
 (__gnat_locate_exec_on_path): Cast from pointer via char * * initialize.c
 (append_arg): Cast from pointer via LPWSTR (__gnat_initialize): Cast from
 pointer via LPWSTR * seh_init.c (__gnat_map_SEH): Cast from pointer via
 FARPROC
 
 If OK for apply, Kai please commit.
 
 Regards,
 
 Rainer
 
 
 Index: ada/adaint.c 
 === ---
 ada/adaint.c  (Revision 194638) +++ ada/adaint.c  (Arbeitskopie) @@ 
 -1982,7
 +1982,7 @@ __gnat_check_OWNER_ACL GROUP_SECURITY_INFORMATION |
 DACL_SECURITY_INFORMATION, NULL, 0, nLength);
 
 -  if ((pSD = (PSECURITY_DESCRIPTOR) HeapAlloc +  if ((pSD =
 (SECURITY_DESCRIPTOR *) HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
 nLength)) == NULL) return 0;
 
 @@ -2059,7 +2059,7 @@ __gnat_set_OWNER_ACL return;
 
 BuildExplicitAccessWithName -(ea, username, AccessPermissions,
 AccessMode, NO_INHERITANCE); +(ea, username, AccessPermissions,
 (ACCESS_MODE) AccessMode, NO_INHERITANCE);
 
 if (AccessMode == SET_ACCESS) { @@ -2384,7 +2384,7 @@ __gnat_portable_spawn
 (char *args[]) strcat (args[0], args_0); strcat (args[0], \);
 
 -  status = spawnvp (P_WAIT, args_0, (const char* const*)args); +  status =
 spawnvp (P_WAIT, args_0, (char* const*)args);
 
 /* restore previous value */ free (args[0]); @@ -2540,9 +2540,9 @@
 add_handle (HANDLE h, int pid) { plist_max_length += 1000; HANDLES_LIST = -
 xrealloc (HANDLES_LIST, sizeof (HANDLE) * plist_max_length); +(void
 **) xrealloc (HANDLES_LIST, sizeof (HANDLE) * plist_max_length); PID_LIST
 = -xrealloc (PID_LIST, sizeof (int) * plist_max_length); +
 (int *) xrealloc (PID_LIST, sizeof (int) * plist_max_length); }
 
 HANDLES_LIST[plist_length] = h; @@ -2931,7 +2931,7 @@
 __gnat_locate_exec_on_path (char *exec_n
 
 #define EXPAND_BUFFER_SIZE 32767
 
 -  wapath_val = alloca (EXPAND_BUFFER_SIZE); +  wapath_val = (TCHAR *)
 alloca (EXPAND_BUFFER_SIZE);
 
 wapath_val [0] = '.'; wapath_val [1] = ';'; @@ -2941,7 +2941,7 @@
 __gnat_locate_exec_on_path (char *exec_n
 
 if (!res) wapath_val [0] = _T('\0');
 
 -  apath_val = alloca (EXPAND_BUFFER_SIZE); +  apath_val = (char *) alloca
 (EXPAND_BUFFER_SIZE);
 
 WS2SC (apath_val, wapath_val, EXPAND_BUFFER_SIZE); return
 __gnat_locate_exec (exec_name, apath_val); Index: ada/initialize.c 
 === ---
 ada/initialize.c  (Revision 194638) +++ ada/initialize.c  (Arbeitskopie) 
 @@
 -88,14 +88,14 @@ append_arg (int *index, LPWSTR dir, LPWS { /* no dir
 prefix */ dirlen = 0; -  fullvalue = xmalloc ((vallen + 1) *
 sizeof(TCHAR)); +  fullvalue = (LPWSTR) xmalloc ((vallen + 1) *
 sizeof(TCHAR)); } else { /* Add dir first */ dirlen = _tcslen (dir);
 
 -  fullvalue = xmalloc ((dirlen + vallen + 1) * sizeof(TCHAR)); +
 fullvalue = (LPWSTR) xmalloc ((dirlen + vallen + 1) * sizeof(TCHAR)); 
 _tcscpy (fullvalue, dir); }
 
 @@ -203,7 +203,7 @@ __gnat_initialize (void *eh ATTRIBUTE_UN if (ldir !=
 NULL) { int n = ldir - wargv[k] + 1; - dir = xmalloc 
 ((n + 1) * sizeof
 (TCHAR)); +dir = (LPWSTR) xmalloc ((n + 1) * sizeof 
 (TCHAR)); _tcsncpy
 (dir, wargv[k], n); dir[n] = _T('\0'); } Index: ada/seh_init.c 
 === ---
 ada/seh_init.c(Revision 194638) +++ ada/seh_init.c(Arbeitskopie) 
 @@ -91,7
 +91,7 @@ __gnat_map_SEH (EXCEPTION_RECORD* Except */ if
 ((ExceptionRecord-ExceptionInformation[1]  3) != 0 || IsBadCodePtr -
 ((void *)(ExceptionRecord-ExceptionInformation[1] + 4096))) +
 ((FARPROC)(ExceptionRecord-ExceptionInformation[1] + 4096))) { *msg =
 EXCEPTION_ACCESS_VIOLATION; return program_error;
 

-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJREi9mAAoJEB3HOsWs+KJb0bsIAIs+KEdqYhTqyB3AJ97YqYqq
JwqIUtORJwvyEdEVE6vsCpnMv4pLn3cvkQS2VwkTkFX8NW7xxq1tbsGOoojGajVV
9fyUCwplCb+n4QhwtEQv9Jh2PNSF68w7S4MkTyhLrEdROg+u3XuRAO7QbzxWQf6A
09U4VqyUT3si0m53VypKkRWagqk2F6l09uIf7MxYl2jQe1ppdI1L3Z4fwJrV//ae
jyoIm8ufHI2n2tBfNPKIY3/nelut2DC1By7hWNIyafMql/SQ3ekZMrn/kvelSMrk

Re: PING: Re: [PATCH] : Fix for PR 52123 gcc bootstrap with ada fails on mingw target

2013-02-06 Thread Arnaud Charlet
 I like to have this in trunk as soon as possible, because I want to backport
 to 4.7.3 before the release.
 
 Tested on x86_64-w64-mingw32 and x86_64-unknown-gnu-linux.

Did you check that this patch also works fine with mingw64? This is the main
environment now used, so it's important to verify that these changes are
compatible with both mingw32 and mingw64.

Also, your mailer corrupted the formatting, so it's no longer possible to
review this patch. Probably better to post a link to the previous
submit to ease reviews.

Arno


[Ada] Storage_Error due to large object size

2013-02-06 Thread Arnaud Charlet
This patch corrects the decoration of type attribute Has_Unknown_Discriminants
when building the full view of a private subtype.


-- Source --


--  root.ads

package Root is
end Root;

--  root-scopes.ads

package Root.Scopes is
   type Scope_T is interface;
   function Scope_Of (Scope_Name : String) return Scope_T is abstract;
end Root.Scopes;

--  root-scopes-basics.ads

private package Root.Scopes.Basics is
   type Scope_T
 (Length : Natural) is abstract new Root.Scopes.Scope_T with
   record
  Name : String (1 .. Length) := (others = ' ');
   end record;
end Root.Scopes.Basics;

--  root-scopes-domains.ads

private with Root.Scopes.Basics;

generic
package Root.Scopes.Domains is
   type Scope_T () is new Root.Scopes.Scope_T with private;
   overriding function Scope_Of (Scope_Name : String) return Scope_T;

private
   subtype Parent_T is Root.Scopes.Basics.Scope_T;

   type Scope_T is new Parent_T with record
  Comp : Integer;
   end record;
end Root.Scopes.Domains;

--  root-scopes-domains.adb

package body Root.Scopes.Domains is
   function Scope_Of (Scope_Name : String) return Scope_T is
   begin
  return (Length = Scope_Name'Length,
  Name   = Scope_Name,
  Comp   = 5);
   end Scope_Of;
end Root.Scopes.Domains;

--  main.adb

with Ada.Text_IO; use Ada.Text_IO;
with Root.Scopes.Domains;

procedure Main is
   package Inst is new Root.Scopes.Domains;
   subtype Scope_T is Inst.Scope_T;

   S_1 : constant Scope_T := Inst.Scope_Of (One);
   S_2 : Scope_T renames S_1;
   S_3 : Scope_T := Inst.Scope_Of (Three);

begin
   Put_Line (OK);
end Main;


-- Compilation and output --


$ gnatmake -q -gnat05 main.adb
$ ./main
OK

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

2013-02-06  Hristian Kirtchev  kirtc...@adacore.com

* sem_ch3.adb (Complete_Private_Subtype): Inherit the
Has_Unknown_Discriminants from the full view of the base type.

Index: sem_ch3.adb
===
--- sem_ch3.adb (revision 195788)
+++ sem_ch3.adb (working copy)
@@ -10255,15 +10255,17 @@
   Protected_Kind   =
 Copy_Node (Priv, Full);
 
-Set_Has_Discriminants  (Full, Has_Discriminants (Full_Base));
-Set_First_Entity   (Full, First_Entity (Full_Base));
-Set_Last_Entity(Full, Last_Entity (Full_Base));
+Set_Has_Discriminants (Full, Has_Discriminants (Full_Base));
+Set_Has_Unknown_Discriminants
+  (Full, Has_Unknown_Discriminants (Full_Base));
+Set_First_Entity  (Full, First_Entity (Full_Base));
+Set_Last_Entity   (Full, Last_Entity (Full_Base));
 
  when others =
 Copy_Node (Full_Base, Full);
-Set_Chars  (Full, Chars (Priv));
-Conditional_Delay  (Full, Priv);
-Set_Sloc   (Full, Sloc (Priv));
+Set_Chars (Full, Chars (Priv));
+Conditional_Delay (Full, Priv);
+Set_Sloc  (Full, Sloc (Priv));
   end case;
 
   Set_Next_Entity (Full, Save_Next_Entity);
@@ -17388,7 +17390,6 @@
   if Is_Private_Type (Id_B) then
  Append_Elmt (Id, Private_Dependents (Id_B));
   end if;
-
end Prepare_Private_Subtype_Completion;
 
---


[committed] Fix OpenMP shared clause handling of DECL_BY_REFERENCE RESULT_DECLs/PARM_DECLs (PR middle-end/56217)

2013-02-06 Thread Jakub Jelinek
Hi!

use_pointer_for_field in some cases returns true to avoid copy-in/out,
which results in the address of the decl being passed around instead of
the decl itself.
But for RESULT_DECL or PARM_DECL of REFERENCE_TYPE we generate only
copy-in, not copy-out (as references can't change), so there is no point
passing it as pointer to the reference to something, the reference can't
change, only what it references.  Besides this generating better code,
making RESULT_DECL of REFERENCE_TYPE addressable and regimplifying it
can result in invalid IL.

Fixed thusly, tested on x86_64-linux, committed to trunk (4.7 backport will
follow later on).

2013-02-06  Jakub Jelinek  ja...@redhat.com

PR middle-end/56217
* omp-low.c (use_pointer_for_field): Return false if
lower_send_shared_vars doesn't generate any copy-out code.

* g++.dg/gomp/pr56217.C: New test.

* testsuite/libgomp.c++/pr56217.C: New test.

--- gcc/omp-low.c.jj2013-01-11 09:02:35.0 +0100
+++ gcc/omp-low.c   2013-02-06 10:42:19.016346866 +0100
@@ -757,12 +757,20 @@ use_pointer_for_field (tree decl, omp_co
   if (TREE_ADDRESSABLE (decl))
return true;
 
+  /* lower_send_shared_vars only uses copy-in, but not copy-out
+for these.  */
+  if (TREE_READONLY (decl)
+ || ((TREE_CODE (decl) == RESULT_DECL
+  || TREE_CODE (decl) == PARM_DECL)
+  DECL_BY_REFERENCE (decl)))
+   return false;
+
   /* Disallow copy-in/out in nested parallel if
 decl is shared in outer parallel, otherwise
 each thread could store the shared variable
 in its own copy-in location, making the
 variable no longer really shared.  */
-  if (!TREE_READONLY (decl)  shared_ctx-is_nested)
+  if (shared_ctx-is_nested)
{
  omp_context *up;
 
@@ -785,11 +793,10 @@ use_pointer_for_field (tree decl, omp_co
}
}
 
-  /* For tasks avoid using copy-in/out, unless they are readonly
-(in which case just copy-in is used).  As tasks can be
+  /* For tasks avoid using copy-in/out.  As tasks can be
 deferred or executed in different thread, when GOMP_task
 returns, the task hasn't necessarily terminated.  */
-  if (!TREE_READONLY (decl)  is_task_ctx (shared_ctx))
+  if (is_task_ctx (shared_ctx))
{
  tree outer;
maybe_mark_addressable_and_ret:
--- gcc/testsuite/g++.dg/gomp/pr56217.C.jj  2013-02-06 10:44:19.001660809 
+0100
+++ gcc/testsuite/g++.dg/gomp/pr56217.C 2013-02-06 10:45:56.991115914 +0100
@@ -0,0 +1,14 @@
+// PR middle-end/56217
+// { dg-do compile }
+// { dg-options -fopenmp }
+
+struct S { int *p; S (); S (S ); };
+
+S
+foo ()
+{
+  S s;
+  #pragma omp task shared (s)
+s.p = 0;
+  return s;
+}
--- libgomp/testsuite/libgomp.c++/pr56217.C.jj  2013-02-06 10:48:10.125404318 
+0100
+++ libgomp/testsuite/libgomp.c++/pr56217.C 2013-02-06 11:16:30.0 
+0100
@@ -0,0 +1,36 @@
+// PR middle-end/56217
+// { dg-do run }
+// { dg-options -std=c++0x }
+
+extern C void abort ();
+
+template typename T
+struct ptr {
+  T *p;
+  ptr () : p () {}
+  ptr (ptr ) = delete;
+  ptr (ptr o) : p(o) {}
+  operator T * () { return p; }
+};
+
+int a[6] = { 100, 101, 102, 103, 104, 105 };
+
+static ptrint
+f ()
+{
+  ptrint pt;
+  #pragma omp task shared (pt)
+pt.p = a + 2;
+  #pragma omp taskwait
+  return pt;
+}
+
+int
+main ()
+{
+  ptrint pt;
+  #pragma omp parallel
+  #pragma omp single
+  if (f () != a + 2 || *f () != 102)
+abort ();
+}

Jakub


[Ada] Removes workaround for an old GNU/Linker limitation on Windows

2013-02-06 Thread Arnaud Charlet
Removes the access to all variables. This was put in place to workaround
a limitation of the linker auto-import support which was not able to
handle works lager than 32 bits.

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

2013-02-06  Pascal Obry  o...@adacore.com

* s-osprim-mingw.adb: Removes workaround for an old GNU/Linker
limitation on Windows.
(DA): Removed.
(LIA): Removed.
(LLIA): Removed.
(TFA): Removed.
(BTA): Removed.
(BMTA): Removed.
(BCA): Removed.
(BMCA): Removed.
(BTiA): Removed.
(Clock): Use variable corresponding to access.
(Get_Base_Time): Likewise.
(Monotonic_Clock): Likewise.

Index: s-osprim-mingw.adb
===
--- s-osprim-mingw.adb  (revision 195784)
+++ s-osprim-mingw.adb  (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1998-2012, Free Software Foundation, Inc. --
+--  Copyright (C) 1998-2013, Free Software Foundation, Inc. --
 --  --
 -- GNARL is free software; you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -42,46 +42,23 @@
-- Data for the high resolution clock --

 
-   --  Declare some pointers to access multi-word data above. This is needed
-   --  to workaround a limitation in the GNU/Linker auto-import feature used
-   --  to build the GNAT runtime DLLs. In fact the Clock and Monotonic_Clock
-   --  routines are inlined and they are using some multi-word variables.
-   --  GNU/Linker will fail to auto-import those variables when building
-   --  libgnarl.dll. The indirection level introduced here has no measurable
-   --  penalties.
-
-   type DA is access all Duration;
-   --  Use to have indirect access to multi-word variables
-
-   type LIA is access all LARGE_INTEGER;
-   --  Use to have indirect access to multi-word variables
-
-   type LLIA is access all Long_Long_Integer;
-   --  Use to have indirect access to multi-word variables
-
Tick_Frequency : aliased LARGE_INTEGER;
-   TFA : constant LIA := Tick_Frequency'Access;
--  Holds frequency of high-performance counter used by Clock
--  Windows NT uses a 1_193_182 Hz counter on PCs.
 
-   Base_Ticks : aliased LARGE_INTEGER;
-   BTA : constant LIA := Base_Ticks'Access;
+   Base_Ticks : LARGE_INTEGER;
--  Holds the Tick count for the base time
 
-   Base_Monotonic_Ticks : aliased LARGE_INTEGER;
-   BMTA : constant LIA := Base_Monotonic_Ticks'Access;
+   Base_Monotonic_Ticks : LARGE_INTEGER;
--  Holds the Tick count for the base monotonic time
 
-   Base_Clock : aliased Duration;
-   BCA : constant DA := Base_Clock'Access;
+   Base_Clock : Duration;
--  Holds the current clock for the standard clock's base time
 
-   Base_Monotonic_Clock : aliased Duration;
-   BMCA : constant DA := Base_Monotonic_Clock'Access;
+   Base_Monotonic_Clock : Duration;
--  Holds the current clock for monotonic clock's base time
 
-   Base_Time : aliased Long_Long_Integer;
-   BTiA : constant LLIA := Base_Time'Access;
+   Base_Time : Long_Long_Integer;
--  Holds the base time used to check for system time change, used with
--  the standard clock.
 
@@ -118,12 +95,12 @@
   GetSystemTimeAsFileTime (Now'Access);
 
   Elap_Secs_Sys :=
-Duration (Long_Long_Float (abs (Now - BTiA.all)) /
+Duration (Long_Long_Float (abs (Now - Base_Time)) /
 Hundreds_Nano_In_Sec);
 
   Elap_Secs_Tick :=
-Duration (Long_Long_Float (Current_Ticks - BTA.all) /
-  Long_Long_Float (TFA.all));
+Duration (Long_Long_Float (Current_Ticks - Base_Ticks) /
+  Long_Long_Float (Tick_Frequency));
 
   --  If we have a shift of more than Max_Shift seconds we resynchronize
   --  the Clock. This is probably due to a manual Clock adjustment, a DST
@@ -134,11 +111,11 @@
  Get_Base_Time;
 
  Elap_Secs_Tick :=
-   Duration (Long_Long_Float (Current_Ticks - BTA.all) /
- Long_Long_Float (TFA.all));
+   Duration (Long_Long_Float (Current_Ticks - Base_Ticks) /
+ Long_Long_Float (Tick_Frequency));
   end if;
 
-  return BCA.all + Elap_Secs_Tick;
+  return Base_Clock + Elap_Secs_Tick;
end Clock;
 
---
@@ -243,9 +220,9 @@
 
   else
  Elap_Secs_Tick :=
-   Duration (Long_Long_Float (Current_Ticks - BMTA.all) /
-   Long_Long_Float (TFA.all));
- return BMCA.all + 

[Ada] gnatmake: do not invoke gnatbind with -I-

2013-02-06 Thread Arnaud Charlet
When gnatmake is invoked with a project file, gnatbind is no longer
invoked by gnatmake with -I-. The test is to invoke gnatmake with
a project file: gnatbind should not be invoked with -I-.

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

2013-02-06  Vincent Celier  cel...@adacore.com

* make.adb (Gnatmake): When gnatmake is called with a project
file, do not invoke gnatbind with -I-.
* makeutl.adb (Create_Binder_Mapping_File): Rewrite function. Get
the infos from all the sources.

Index: make.adb
===
--- make.adb(revision 195784)
+++ make.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2012, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2013, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -5895,7 +5895,6 @@
  --  projects.
 
  Look_In_Primary_Dir := False;
- Add_Switch (-I-, Binder, And_Save = True);
   end if;
 
   --  If the user wants a program without a main subprogram, add the
Index: makeutl.adb
===
--- makeutl.adb (revision 195784)
+++ makeutl.adb (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 2004-2012, Free Software Foundation, Inc. --
+--  Copyright (C) 2004-2013, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -369,6 +369,14 @@
   Status : Boolean;
   --  For call to Close
 
+  Iter : Source_Iterator :=
+For_Each_Source
+  (In_Tree   = Project_Tree,
+   Language  = Name_Ada,
+   Encapsulated_Libs = False,
+   Locally_Removed   = False);
+  Source : Prj.Source_Id;
+
begin
   Tempdir.Create_Temp_File (Mapping_FD, Mapping_Path);
   Record_Temp_File (Project_Tree.Shared, Mapping_Path);
@@ -376,57 +384,62 @@
   if Mapping_FD /= Invalid_FD then
  OK := True;
 
- --  Traverse all units
+ loop
+Source := Element (Iter);
+exit when Source = No_Source;
 
- Unit := Units_Htable.Get_First (Project_Tree.Units_HT);
- while Unit /= No_Unit_Index loop
-if Unit.Name /= No_Name then
+Unit := Source.Unit;
 
-   --  If there is a body, put it in the mapping
+if Unit = No_Unit_Index or else Unit.Name = No_Name then
+   ALI_Name := No_File;
 
-   if Unit.File_Names (Impl) /= No_Source
- and then Unit.File_Names (Impl).Project /= No_Project
-   then
-  Get_Name_String (Unit.Name);
-  Add_Str_To_Name_Buffer (%b);
-  ALI_Unit := Name_Find;
-  ALI_Name :=
-Lib_File_Name (Unit.File_Names (Impl).Display_File);
-  ALI_Project := Unit.File_Names (Impl).Project;
+--  If this is a body, put it in the mapping
 
-  --  Otherwise, if there is a spec, put it in the mapping
+elsif Source.Kind = Impl
+  and then Unit.File_Names (Impl) /= No_Source
+  and then Unit.File_Names (Impl).Project /= No_Project
+then
+   Get_Name_String (Unit.Name);
+   Add_Str_To_Name_Buffer (%b);
+   ALI_Unit := Name_Find;
+   ALI_Name :=
+ Lib_File_Name (Unit.File_Names (Impl).Display_File);
+   ALI_Project := Unit.File_Names (Impl).Project;
 
-   elsif Unit.File_Names (Spec) /= No_Source
- and then Unit.File_Names (Spec).Project /= No_Project
-   then
-  Get_Name_String (Unit.Name);
-  Add_Str_To_Name_Buffer (%s);
-  ALI_Unit := Name_Find;
-  ALI_Name :=
-Lib_File_Name (Unit.File_Names (Spec).Display_File);
-  ALI_Project := Unit.File_Names (Spec).Project;
+--  Otherwise, if this is a spec and there 

[Ada] Preliminary work to implement pragma Loop_Optimize

2013-02-06 Thread Arnaud Charlet
This is the front-end implementation of the new Loop_Optimize pragma, which
makes it possible for the programmer to control the optimizations applied to
loops on an individual basis.

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

2013-02-06  Eric Botcazou  ebotca...@adacore.com

* snames.ads-tmpl (Name_Loop_Optimize, Name_No_Unroll,
Name_Unroll, Name_No_Vector, Name_Vector): New pragma-related
names.
(Pragma_Id): Add Pragma_Loop_Optimize value.
* par-prag.adb (Prag): Handle Pragma_Loop_Optimize.
* sem_prag.adb (Check_Loop_Invariant_Variant_Placement): Rename to...
(Check_Loop_Pragma_Placement): ...this.
(Analyze_Pragma)
Pragma_Loop_Invariant: Adjust to above renaming.
Loop_Variant: Likewise.
 Pragma_Loop_Optimize: Implement new pragma Loop_Optimize.
(Sig_Flags): Add Pragma_Loop_Optimize.
* gnat_rm.texi (Implementation Defined Pragmas): Add Loop_Optimize.
* gnat_ugn.texi (Vectorization of loops): Mention Loop_Optimize.

Index: gnat_rm.texi
===
--- gnat_rm.texi(revision 195794)
+++ gnat_rm.texi(working copy)
@@ -176,6 +176,7 @@
 * Pragma Linker_Destructor::
 * Pragma Linker_Section::
 * Pragma Long_Float::
+* Pragma Loop_Optimize::
 * Pragma Machine_Attribute::
 * Pragma Main::
 * Pragma Main_Storage::
@@ -925,6 +926,7 @@
 * Pragma Linker_Destructor::
 * Pragma Linker_Section::
 * Pragma Long_Float::
+* Pragma Loop_Optimize::
 * Pragma Machine_Attribute::
 * Pragma Main::
 * Pragma Main_Storage::
@@ -3845,6 +3848,55 @@
 @cite{DEC Ada Language Reference Manual}, section 3.5.7b.  Note that to use
 this pragma, the standard runtime libraries must be recompiled.
 
+@node Pragma Loop_Optimize
+@unnumberedsec Pragma Loop_Optimize
+@findex Loop_Optimize
+@noindent
+Syntax:
+
+@smallexample @c ada
+pragma Loop_Optimize (OPTIMIZATION_HINT @{, OPTIMIZATION_HINT@});
+
+OPTIMIZATION_HINT ::= No_Unroll | Unroll | No_Vector | Vector
+@end smallexample
+
+@noindent
+This pragma must appear immediately within a loop statement.  It allows the
+programmer to specify optimization hints for the enclosing loop.  The hints
+are not mutually exclusive and can be freely mixed, but not all combinations
+will yield a sensible outcome.
+
+There are four supported optimization hints for a loop:
+@itemize @bullet
+@item No_Unroll
+
+The loop must not be unrolled.  This is a strong hint: the compiler will not
+unroll a loop marked with this hint.
+
+@item Unroll
+
+The loop should be unrolled.  This is a weak hint: the compiler will try to
+apply unrolling to this loop preferably to other optimizations, notably
+vectorization, but there is no guarantee that the loop will be unrolled.
+
+@item No_Vector
+
+The loop must not be vectorized.  This is a strong hint: the compiler will not
+vectorize a loop marked with this hint.
+
+@item Vector
+
+The loop should be vectorized.  This is a weak hint: the compiler will try to
+apply vectorization to this loop preferably to other optimizations, notably
+unrolling, but there is no guarantee that the loop will be vectorized.
+
+@end itemize
+
+These hints do not void the need to pass the appropriate switches to the
+compiler in order to enable the relevant optimizations, that is to say
+@option{-funroll-loops} for unrolling and @option{-ftree-vectorize} for
+vectorization.
+
 @node Pragma Machine_Attribute
 @unnumberedsec Pragma Machine_Attribute
 @findex Machine_Attribute
Index: gnat_ugn.texi
===
--- gnat_ugn.texi   (revision 195798)
+++ gnat_ugn.texi   (working copy)
@@ -10978,6 +10978,17 @@
 bounds of the array, the more fallback code it needs to generate in order to
 fix things up at run time.
 
+It is possible to specify that a given loop should be subject to vectorization
+preferably to other optimizations by means of pragma @code{Loop_Optimize}:
+
+@smallexample @c ada
+  pragma Loop_Optimize (Vector);
+@end smallexample
+
+@noindent
+placed immediately within the loop will convey the appropriate hint to the
+compiler for this loop.
+
 You can obtain information about the vectorization performed by the compiler
 by specifying @option{-ftree-vectorizer-verbose=N}.  For more details of
 this switch, see @ref{Debugging Options,,Options for Debugging Your Program
Index: par-prag.adb
===
--- par-prag.adb(revision 195798)
+++ par-prag.adb(working copy)
@@ -1203,6 +1203,7 @@
Pragma_Locking_Policy |
Pragma_Long_Float |
Pragma_Loop_Invariant |
+   Pragma_Loop_Optimize  |
Pragma_Loop_Variant   |
Pragma_Machine_Attribute  |
Pragma_Main   |
Index: sem_prag.adb

Re: PING: Re: [PATCH] : Fix for PR 52123 gcc bootstrap with ada fails on mingw target

2013-02-06 Thread Arnaud Charlet
  Did you check that this patch also works fine with mingw64? This is the
  main environment now used, so it's important to verify that these changes
  are compatible with both mingw32 and mingw64.
 I'm only able ot test for mingw64 at the moment as you see above,
 x86_64-w64-mingw32 is mingw64. If someone is able to test mingw.org for me
 would be fine. Otherwise I have to setup a mingw.org environment.

OK, thanks for the clarification.

 Here the link to the original post:
 http://gcc.gnu.org/ml/gcc-patches/2013-01/msg00114.html

Patch is OK although I'm a bit surprised we're not seeing these
errors at AdaCore where we also use mingw64. Perhaps we're using a different
version.

Anyway, go ahead.

Arno


[Ada] Missing accessibility check

2013-02-06 Thread Arnaud Charlet
This patch adds a missing case to the accessibility mechanism. The machinery
can now recognize a rewritten interface conversion and properly extract the
level of the operand.


-- Source --


--  types.ads

package Types is
   type Iface is limited interface;
   type Any_Iface_Ptr is access all Iface'Class;

   type Port_Type is tagged record
  Data : Any_Iface_Ptr;
   end record;

   procedure Connect (Port : in out Port_Type; Data : Any_Iface_Ptr);

   type Computer_Type is limited new Iface with record
  Port : Port_Type;
   end record;

   procedure Init_Ports (Comp : in out Computer_Type);
end Types;

--  types.adb

package body Types is
   procedure Connect (Port : in out Port_Type; Data : Any_Iface_Ptr) is
   begin
  Port.Data := Data;
   end Connect;

   procedure Init_Ports (Comp : in out Computer_Type) is
   begin
  Comp.Port.Connect (Iface (Comp)'Access);
   end Init_Ports;
end Types;


-- Compilation and output --


$ gcc -c -gnat05 types.adb
types.adb:9:26: non-local pointer cannot point to local object

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

2013-02-06  Hristian Kirtchev  kirtc...@adacore.com

* sem_util.adb (Is_Interface_Conversion): New routine.
(Object_Access_Level): Detect an interface conversion
that has been rewritten into a different construct. Use the
original form of the conversion to find the access level of
the operand.

Index: sem_util.adb
===
--- sem_util.adb(revision 195798)
+++ sem_util.adb(working copy)
@@ -11997,9 +11997,6 @@
-- Object_Access_Level --
-
 
-   function Object_Access_Level (Obj : Node_Id) return Uint is
-  E : Entity_Id;
-
--  Returns the static accessibility level of the view denoted by Obj. Note
--  that the value returned is the result of a call to Scope_Depth. Only
--  scope depths associated with dynamic scopes can actually be returned.
@@ -12008,6 +12005,12 @@
--  always one is immaterial (invariant: if level(E2) is deeper than
--  level(E1), then Scope_Depth(E1)  Scope_Depth(E2)).
 
+   function Object_Access_Level (Obj : Node_Id) return Uint is
+  function Is_Interface_Conversion (N : Node_Id) return Boolean;
+  --  Determine whether N is a construct of the form
+  --Some_Type (Operand._tag'Address)
+  --  This construct appears in the context of dispatching calls
+
   function Reference_To (Obj : Node_Id) return Node_Id;
   --  An explicit dereference is created when removing side-effects from
   --  expressions for constraint checking purposes. In this case a local
@@ -12016,6 +12019,18 @@
   --  prefix of the dereference is created by an object declaration whose
   --  initial expression is a reference.
 
+  -
+  -- Is_Interface_Conversion --
+  -
+
+  function Is_Interface_Conversion (N : Node_Id) return Boolean is
+  begin
+ return
+   Nkind (N) = N_Unchecked_Type_Conversion
+ and then Nkind (Expression (N)) = N_Attribute_Reference
+ and then Attribute_Name (Expression (N)) = Name_Address;
+  end Is_Interface_Conversion;
+
   --
   -- Reference_To --
   --
@@ -12034,6 +12049,10 @@
  end if;
   end Reference_To;
 
+  --  Local variables
+
+  E : Entity_Id;
+
--  Start of processing for Object_Access_Level
 
begin
@@ -12104,7 +12123,17 @@
  then
 return Object_Access_Level (Prefix (Obj));
 
- elsif not (Comes_From_Source (Obj)) then
+ --  Detect an interface conversion in the context of a dispatching
+ --  call. Use the original form of the conversion to find the access
+ --  level of the operand.
+
+ elsif Is_Interface (Etype (Obj))
+   and then Is_Interface_Conversion (Prefix (Obj))
+   and then Nkind (Original_Node (Obj)) = N_Type_Conversion
+ then
+return Object_Access_Level (Original_Node (Obj));
+
+ elsif not Comes_From_Source (Obj) then
 declare
Ref : constant Node_Id := Reference_To (Obj);
 begin
@@ -12119,9 +12148,7 @@
 return Type_Access_Level (Etype (Prefix (Obj)));
  end if;
 
-  elsif Nkind (Obj) = N_Type_Conversion
-or else Nkind (Obj) = N_Unchecked_Type_Conversion
-  then
+  elsif Nkind_In (Obj, N_Type_Conversion, N_Unchecked_Type_Conversion) then
  return Object_Access_Level (Expression (Obj));
 
   elsif Nkind (Obj) = N_Function_Call then


[Ada] Make sure the Clock is thread safe

2013-02-06 Thread Arnaud Charlet
Use a simple lock when updating the base values (ticks, time, clock).

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

2013-02-06  Pascal Obry  o...@adacore.com

* s-osprim-mingw.adb (Clock): Make sure we copy all data locally
to avoid interleaved modifications that could happen from another
task calling Get_Base_Data.
(Get_Base_Data): Make it a critical section. Avoid updating if another
task has already done it.

Index: s-osprim-mingw.adb
===
--- s-osprim-mingw.adb  (revision 195798)
+++ s-osprim-mingw.adb  (working copy)
@@ -31,10 +31,12 @@
 
 --  This is the NT version of this package
 
+with System.Task_Lock;
 with System.Win32.Ext;
 
 package body System.OS_Primitives is
 
+   use System.Task_Lock;
use System.Win32;
use System.Win32.Ext;
 
@@ -46,23 +48,49 @@
--  Holds frequency of high-performance counter used by Clock
--  Windows NT uses a 1_193_182 Hz counter on PCs.
 
-   Base_Ticks : LARGE_INTEGER;
-   --  Holds the Tick count for the base time
-
Base_Monotonic_Ticks : LARGE_INTEGER;
--  Holds the Tick count for the base monotonic time
 
-   Base_Clock : Duration;
-   --  Holds the current clock for the standard clock's base time
-
Base_Monotonic_Clock : Duration;
--  Holds the current clock for monotonic clock's base time
 
-   Base_Time : Long_Long_Integer;
-   --  Holds the base time used to check for system time change, used with
-   --  the standard clock.
+   type Clock_Data is record
+  Base_Ticks : LARGE_INTEGER;
+  --  Holds the Tick count for the base time
 
-   procedure Get_Base_Time;
+  Base_Time : Long_Long_Integer;
+  --  Holds the base time used to check for system time change, used with
+  --  the standard clock.
+
+  Base_Clock : Duration;
+  --  Holds the current clock for the standard clock's base time
+   end record;
+
+   type Clock_Data_Access is access all Clock_Data;
+
+   --  Two base clock buffers. This is used to be able to update a buffer
+   --  while the other buffer is read. The point is that we do not want to
+   --  use a lock inside the Clock routine for performance reasons. We still
+   --  use a lock in the Get_Base_Time which is called very rarely. Current
+   --  is a pointer, the pragma Atomic is there to ensure that the value can
+   --  be set or read atomically. That's it, when Get_Base_Time has updated
+   --  a buffer the switch to the new value is done by changing Current
+   --  pointer.
+
+   First, Second : aliased Clock_Data;
+   Current   : Clock_Data_Access := First'Access;
+   pragma Atomic (Current);
+
+   --  The following signature is to detect change on the base clock data
+   --  above. The signature is a modular type, it will wrap around without
+   --  raising an exception. We would need to have exactly 2**32 updates of
+   --  the base data for the changes to get undetected.
+
+   type Signature_Type is mod 2**32;
+   Signature : Signature_Type := 0;
+   pragma Atomic (Signature);
+
+   procedure Get_Base_Time (Data : out Clock_Data);
--  Retrieve the base time and base ticks. These values will be used by
--  clock to compute the current time by adding to it a fraction of the
--  performance counter. This is for the implementation of a
@@ -82,12 +110,28 @@
function Clock return Duration is
   Max_Shift: constant Duration:= 2.0;
   Hundreds_Nano_In_Sec : constant Long_Long_Float := 1.0E7;
+  Data : Clock_Data;
   Current_Ticks: aliased LARGE_INTEGER;
   Elap_Secs_Tick   : Duration;
   Elap_Secs_Sys: Duration;
   Now  : aliased Long_Long_Integer;
+  Sig1, Sig2   : Signature_Type;
 
begin
+  --  Try ten times to get a coherent set of base data. For this we just
+  --  check that the signature hasn't changed during the copy of the
+  --  current data.
+  --
+  --  This loop will always be done once if there is no interleaved call
+  --  to Get_Base_Time.
+
+  for K in 1 .. 10 loop
+ Sig1 := Signature;
+ Data := Current.all;
+ Sig2 := Signature;
+ exit when Sig1 = Sig2;
+  end loop;
+
   if QueryPerformanceCounter (Current_Ticks'Access) = Win32.FALSE then
  return 0.0;
   end if;
@@ -95,11 +139,11 @@
   GetSystemTimeAsFileTime (Now'Access);
 
   Elap_Secs_Sys :=
-Duration (Long_Long_Float (abs (Now - Base_Time)) /
+Duration (Long_Long_Float (abs (Now - Data.Base_Time)) /
 Hundreds_Nano_In_Sec);
 
   Elap_Secs_Tick :=
-Duration (Long_Long_Float (Current_Ticks - Base_Ticks) /
+Duration (Long_Long_Float (Current_Ticks - Data.Base_Ticks) /
   Long_Long_Float (Tick_Frequency));
 
   --  If we have a shift of more than Max_Shift seconds we resynchronize
@@ -108,21 +152,21 @@
   

[Ada] Implement pragma No_Inline (front-end part)

2013-02-06 Thread Arnaud Charlet
This implements the front-end part of pragma No_Inline, which makes it possible
for the programmer to suppress inlining on a finer-grained basis than
-fno-inline.  This pragma is strictly equivalent to the noinline attribute
supported by the C family of compilers.

The interaction with the other 2 pragmas controlling inlining is as follows:
  - No_Inline and Inline_Always are mutually exclusive, i.e. specifying both
for a subprogram is an error
  - No_Inline overrides Inline and a warning is issued by the front-end.

The corresponding gigi part will be committed later.

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

2013-02-06  Eric Botcazou  ebotca...@adacore.com

* einfo.ads (Has_Pragma_No_Inline): New flag using Flag201.
(Has_Pragma_No_Inline): Declare and mark as inline.
(Set_Has_Pragma_No_Inline): Likewise.
* einfo.adb (Has_Pragma_No_Inline): New function.
(Set_Has_Pragma_No_Inline): New procedure.
(Write_Entity_Flags): Handle Has_Pragma_No_Inline.
* snames.ads-tmpl (Name_No_Inline): New pragma-related name.
(Pragma_Id): Add Pragma_No_Inline value.
* par-prag.adb (Prag): Handle Pragma_Inline.
* sem_prag.adb (Inline_Status): New enumeration type.
(Process_Inline): Change Active parameter
to Inline_Status and add support for suppressed inlining.
(Analyze_Pragma) Pragma_Inline: Adjust to above change.
Pragma_Inline_Always: Likewise.
 Pragma_No_Inline: Implement new pragma No_Inline.
(Sig_Flags): Add Pragma_No_Inline.
* gnat_rm.texi (Implementation Defined Pragmas): Add No_Inline.
* gnat_ugn.texi (Switches for gcc): Mention Pragma No_Inline.

Index: gnat_rm.texi
===
--- gnat_rm.texi(revision 195800)
+++ gnat_rm.texi(working copy)
@@ -182,6 +182,7 @@
 * Pragma Main::
 * Pragma Main_Storage::
 * Pragma No_Body::
+* Pragma No_Inline::
 * Pragma No_Return::
 * Pragma No_Strict_Aliasing ::
 * Pragma Normalize_Scalars::
@@ -934,6 +935,7 @@
 * Pragma Main::
 * Pragma Main_Storage::
 * Pragma No_Body::
+* Pragma No_Inline::
 * Pragma No_Return::
 * Pragma No_Strict_Aliasing::
 * Pragma Normalize_Scalars::
@@ -3373,8 +3375,8 @@
 
 @noindent
 Similar to pragma @code{Inline} except that inlining is not subject to
-the use of option @option{-gnatn} and the inlining happens regardless of
-whether this option is used.
+the use of option @option{-gnatn} or @option{-gnatN} and the inlining
+happens regardless of whether these options are used.
 
 @node Pragma Inline_Generic
 @unnumberedsec Pragma Inline_Generic
@@ -4020,6 +4022,24 @@
 dummy body with a No_Body pragma ensures that there is no interference from
 earlier versions of the package body.
 
+@node Pragma No_Inline
+@unnumberedsec Pragma No_Inline
+@findex No_Inline
+@noindent
+Syntax:
+
+@smallexample @c ada
+pragma No_Inline (NAME [, NAME]);
+@end smallexample
+
+@noindent
+This pragma suppresses inlining for the callable entity or the instances of
+the generic subprogram designated by @var{NAME}, including inlining that
+results from the use of pragma @code{Inline}.  This pragma is always active,
+in particular it is not subject to the use of option @option{-gnatn} or
+@option{-gnatN}.  It is illegal to specify both pragma @code{No_Inline} and
+pragma @code{Inline_Always} for the same @var{NAME}.
+
 @node Pragma No_Return
 @unnumberedsec Pragma No_Return
 @findex No_Return
Index: einfo.adb
===
--- einfo.adb   (revision 195784)
+++ einfo.adb   (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2012, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2013, Free Software Foundation, Inc. --
 --  --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
@@ -483,6 +483,7 @@
--Is_Ada_2012_OnlyFlag199
 
--Has_Delayed_Aspects Flag200
+   --Has_Pragma_No_InlineFlag201
--Itype_Printed   Flag202
--Has_Pragma_Pure Flag203
--Is_Known_Null   Flag204
@@ -542,8 +543,6 @@
--Has_Anonymous_MasterFlag253
--Is_Implementation_Defined   Flag254
 
-   --(unused)Flag201
-
--(unused)Flag255
--(unused)Flag256
--(unused)Flag257
@@ -1560,6 +1559,11 @@
   

[PATCH] Avoid fix_loop_structure being called twice from tracer

2013-02-06 Thread Richard Biener

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

Richard.

2013-02-06  Richard Biener  rguent...@suse.de

* tracer.c (tracer): Mark loops with LOOPS_NEED_FIXUP
instead of calling fix_loop_structure.

Index: gcc/tracer.c
===
--- gcc/tracer.c(revision 195784)
+++ gcc/tracer.c(working copy)
@@ -380,9 +380,9 @@ tracer (void)
   if (changed)
 {
   free_dominance_info (CDI_DOMINATORS);
-  calculate_dominance_info (CDI_DOMINATORS);
+  /* If we changed the CFG schedule loops for fixup by cleanup_cfg.  */
   if (current_loops)
-   fix_loop_structure (NULL);
+   loops_state_set (LOOPS_NEED_FIXUP);
 }
 
   if (dump_file)


[RS6000] PR54009 again

2013-02-06 Thread Alan Modra
My PR54131 fix caused PR54009 to raise its ugly head again.  Allowing
all LO_SUM addresses in the 'Y' constraint (mem_operand_gpr) wasn't
quite correct.  We still need to check for wrap when offsetting for
multiple words/regs.  Fixing that means the LO_SUM addresses not
accepted by 'Y' need an address reload.

OK assuming powerpc64 and powerpc-linux regression testing passes?

PR target/54009
* config/rs6000/rs6000.c (mem_operand_gpr): Check that LO_SUM
addresses won't wrap when offsetting.
(rs6000_secondary_reload): Provide secondary reloads needed for
wrapping LO_SUM addresses.

Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 195707)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -5135,17 +5135,14 @@ mem_operand_gpr
   if (TARGET_POWERPC64  (offset  3) != 0)
 return false;
 
+  extra = GET_MODE_SIZE (mode) - UNITS_PER_WORD;
+  gcc_assert (extra = 0);
+
   if (GET_CODE (addr) == LO_SUM)
-/* We know by alignment that ABI_AIX medium/large model toc refs
-   will not cross a 32k boundary, since all entries in the
-   constant pool are naturally aligned and we check alignment for
-   other medium model toc-relative addresses.  For ABI_V4 and
-   ABI_DARWIN lo_sum addresses, we just check that 64-bit
-   offsets are 4-byte aligned.  */
-return true;
+/* For lo_sum addresses, we must allow any offset except one that
+   causes a wrap, so test only the low 16 bits.  */
+offset = ((offset  0x) ^ 0x8000) - 0x8000;
 
-  extra = GET_MODE_SIZE (mode) - UNITS_PER_WORD;
-  gcc_assert (extra = 0);
   return offset + 0x8000  0x1u - extra;
 }
 
@@ -13823,19 +13819,31 @@ rs6000_secondary_reload
MEM_P (x)
GET_MODE_SIZE (GET_MODE (x)) = UNITS_PER_WORD)
 {
-  rtx off = address_offset (XEXP (x, 0));
-  unsigned int extra = GET_MODE_SIZE (GET_MODE (x)) - UNITS_PER_WORD;
+  rtx addr = XEXP (x, 0);
+  rtx off = address_offset (addr);
 
-  if (off != NULL_RTX
-  (INTVAL (off)  3) != 0
-  (unsigned HOST_WIDE_INT) INTVAL (off) + 0x8000  0x1 - extra)
+  if (off != NULL_RTX)
{
- if (in_p)
-   sri-icode = CODE_FOR_reload_di_load;
+ unsigned int extra = GET_MODE_SIZE (GET_MODE (x)) - UNITS_PER_WORD;
+ unsigned HOST_WIDE_INT offset = INTVAL (off);
+
+ /* We need a secondary reload when our legitimate_address_p
+says the address is good (as otherwise the entire address
+will be reloaded), and the offset is not a multiple of
+four.  */
+ if ((GET_CODE (addr) == LO_SUM
+  || offset + 0x8000  0x1 - extra)
+  (offset  3) != 0)
+   {
+ if (in_p)
+   sri-icode = CODE_FOR_reload_di_load;
+ else
+   sri-icode = CODE_FOR_reload_di_store;
+ sri-extra_cost = 2;
+ ret = NO_REGS;
+   }
  else
-   sri-icode = CODE_FOR_reload_di_store;
- sri-extra_cost = 2;
- ret = NO_REGS;
+   default_p = true;
}
   else
default_p = true;
@@ -13845,25 +13853,43 @@ rs6000_secondary_reload
MEM_P (x)
GET_MODE_SIZE (GET_MODE (x))  UNITS_PER_WORD)
 {
-  rtx off = address_offset (XEXP (x, 0));
-  unsigned int extra = GET_MODE_SIZE (GET_MODE (x)) - UNITS_PER_WORD;
+  rtx addr = XEXP (x, 0);
+  rtx off = address_offset (addr);
 
-  /* We need a secondary reload only when our legitimate_address_p
-says the address is good (as otherwise the entire address
-will be reloaded).  So for mode sizes of 8 and 16 this will
-be when the offset is in the ranges [0x7ffc,0x7fff] and
-[0x7ff4,0x7ff7] respectively.  Note that the address we see
-here may have been manipulated by legitimize_reload_address.  */
-  if (off != NULL_RTX
-  ((unsigned HOST_WIDE_INT) INTVAL (off) - (0x8000 - extra)
-  UNITS_PER_WORD))
+  if (off != NULL_RTX)
{
- if (in_p)
-   sri-icode = CODE_FOR_reload_si_load;
+ unsigned int extra = GET_MODE_SIZE (GET_MODE (x)) - UNITS_PER_WORD;
+ unsigned HOST_WIDE_INT offset = INTVAL (off);
+
+ /* We need a secondary reload when our legitimate_address_p
+says the address is good (as otherwise the entire address
+will be reloaded), and we have a wrap.
+
+legitimate_lo_sum_address_p allows LO_SUM addresses to
+have any offset so test for wrap in the low 16 bits.
+
+legitimate_offset_address_p checks for the range
+[-0x8000,0x7fff] for mode size of 8 and [-0x8000,0x7ff7]
+for mode size of 16.  We wrap at [0x7ffc,0x7fff] and
+[0x7ff4,0x7fff] respectively, so test for the
+intersection of these 

Fix PR52448 (cselim with calls)

2013-02-06 Thread Michael Matz
Hi,

marking of non-trapping accesses currently has an issue when there's a 
call between the dominated and the dominating access (that makes the 
former non-trapping), namely when that call frees the accessed memory (or 
makes it unavailable via other means).

Instead of a full-blown algorithm iterating until a fixed point to exactly 
determine the killed set of accesses I simply clear the whole hash table 
of seen accesses whenever I see a call, which requires being conservative 
on backedges (or generally when there are unvisited predecessors, but the 
current domwalker ensures that domchilds are visited in topological 
order).  Quick clearing is done by using a phase counter.

This still retains the important transformation in hmmer, but fixes the 
bug.  Regstrapped on x86_64-linux, okay for trunk?


Ciao,
Michael.
-- 
PR tree-optimization/52448

* tree-ssa-phiopt.c (struct name_to_bb): Add phase member.
(nt_call_phase): New static.
(add_or_mark_expr): Only mark accesses with newer phase than any
call seen.
(nonfreeing_call_p): New.
(nt_init_block): Update nt_call_phase, mark blocks as visited.
(nt_fini_block): Keep blocks marked as visited.
(get_non_trapping): Initialize nt_call_phase, and reset aux pointer.

testsuite/
PR tree-optimization/52448
* gcc.dg/pr52448.c: New test.

Index: tree-ssa-phiopt.c
===
--- tree-ssa-phiopt.c   (revision 195753)
+++ tree-ssa-phiopt.c   (working copy)
@@ -1233,6 +1233,7 @@ abs_replacement (basic_block cond_bb, ba
 struct name_to_bb
 {
   unsigned int ssa_name_ver;
+  unsigned int phase;
   bool store;
   HOST_WIDE_INT offset, size;
   basic_block bb;
@@ -1241,6 +1242,10 @@ struct name_to_bb
 /* The hash table for remembering what we've seen.  */
 static htab_t seen_ssa_names;
 
+/* Used for quick clearing of the hash-table when we see calls.
+   Hash entries with phase  nt_call_phase are invalid.  */
+static unsigned int nt_call_phase;
+
 /* The set of MEM_REFs which can't trap.  */
 static struct pointer_set_t *nontrap_set;
 
@@ -1291,6 +1296,7 @@ add_or_mark_expr (basic_block bb, tree e
   /* Try to find the last seen MEM_REF through the same
  SSA_NAME, which can trap.  */
   map.ssa_name_ver = SSA_NAME_VERSION (name);
+  map.phase = 0;
   map.bb = 0;
   map.store = store;
   map.offset = tree_low_cst (TREE_OPERAND (exp, 1), 0);
@@ -1298,13 +1304,13 @@ add_or_mark_expr (basic_block bb, tree e
 
   slot = htab_find_slot (seen_ssa_names, map, INSERT);
   n2bb = (struct name_to_bb *) *slot;
-  if (n2bb)
+  if (n2bb  n2bb-phase = nt_call_phase)
 found_bb = n2bb-bb;
 
   /* If we've found a trapping MEM_REF, _and_ it dominates EXP
  (it's in a basic block on the path from us to the dominator root)
 then we can't trap.  */
-  if (found_bb  found_bb-aux == (void *)1)
+  if (found_bb  (((size_t)found_bb-aux)  1) == 1)
{
  pointer_set_insert (nontrap, exp);
}
@@ -1313,12 +1319,14 @@ add_or_mark_expr (basic_block bb, tree e
  /* EXP might trap, so insert it into the hash table.  */
  if (n2bb)
{
+ n2bb-phase = nt_call_phase;
  n2bb-bb = bb;
}
  else
{
  n2bb = XNEW (struct name_to_bb);
  n2bb-ssa_name_ver = SSA_NAME_VERSION (name);
+ n2bb-phase = nt_call_phase;
  n2bb-bb = bb;
  n2bb-store = store;
  n2bb-offset = map.offset;
@@ -1329,20 +1337,53 @@ add_or_mark_expr (basic_block bb, tree e
 }
 }
 
+/* Return true when CALL is a call stmt that definitely doesn't
+   free any memory or makes it unavailable otherwise.  */
+static bool
+nonfreeing_call_p (gimple call)
+{
+  tree fndecl = gimple_call_fndecl (call);
+
+  if (!fndecl || DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL)
+return false;
+
+  switch (DECL_FUNCTION_CODE (fndecl))
+{
+  case BUILT_IN_FREE:
+  case BUILT_IN_STACK_RESTORE:
+   return false;
+  default:
+   return true;
+}
+}
+
 /* Called by walk_dominator_tree, when entering the block BB.  */
 static void
 nt_init_block (struct dom_walk_data *data ATTRIBUTE_UNUSED, basic_block bb)
 {
+  edge e;
+  edge_iterator ei;
   gimple_stmt_iterator gsi;
-  /* Mark this BB as being on the path to dominator root.  */
-  bb-aux = (void*)1;
+
+  /* If we haven't seen all our predecessors, clear the hash-table.  */
+  FOR_EACH_EDGE (e, ei, bb-preds)
+if size_t)e-src-aux)  2) == 0)
+  {
+   nt_call_phase++;
+   break;
+  }
+
+  /* Mark this BB as being on the path to dominator root and as visited.  */
+  bb-aux = (void*)(1 | 2);
 
   /* And walk the statements in order.  */
   for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (gsi))
 {
   gimple stmt = gsi_stmt (gsi);
 
-  if 

Re: Fix PR52448 (cselim with calls)

2013-02-06 Thread Jakub Jelinek
On Wed, Feb 06, 2013 at 02:45:10PM +0100, Michael Matz wrote:
 @@ -1329,20 +1337,53 @@ add_or_mark_expr (basic_block bb, tree e
  }
  }
  
 +/* Return true when CALL is a call stmt that definitely doesn't
 +   free any memory or makes it unavailable otherwise.  */
 +static bool
 +nonfreeing_call_p (gimple call)
 +{
 +  tree fndecl = gimple_call_fndecl (call);
 +
 +  if (!fndecl || DECL_BUILT_IN_CLASS (fndecl) != BUILT_IN_NORMAL)
 +return false;
 +
 +  switch (DECL_FUNCTION_CODE (fndecl))
 +{
 +  case BUILT_IN_FREE:
 +  case BUILT_IN_STACK_RESTORE:
 + return false;
 +  default:
 + return true;
 +}
 +}

This doesn't look conservative enough.

First of all, I'd use gimple_call_builtin_p (call, BUILT_IN_NORMAL)
test.  And, the function should certainly conservatively return false
for all builtins that aren't (gimple_call_flags (call)  ECF_LEAF) != 0,
otherwise they might call hooks in the current CU and similar and free in
those hooks (likewise setjmp or similar, but again, that is not ECF_LEAF).

Jakub


[PATCH] Fix PR libitm/55693

2013-02-06 Thread Jack Howarth
   The attached patch eliminates the failure of the libitm.c++/eh-1.C execution 
test on darwin10
and later, PR55693. With the introduction of c++ weak-symbol coalescing in Mac 
OS X 10.6, dyld no
longer looks up weak symbols that reside in object files rather than shared 
libraries. This prevents
weak symbols for the dummy functions in libgcc/config/darwin-crt-tm.c from 
being replaced by those
in the libstdc++ shared library. The solution is not to define these dummy 
symbols when targeting
Mac OS X 10.6 or later (where the tool chain properly handles undefined weak 
refs in the linker).
Tested on x86_64-apple-darwin10 with Xcode 3.2.6, x86_64-apple-darwin11 and 
x86_64-apple-darwin12
with Xcode 4.5.2/4.6. Note that this fix requires functional dynamic lookup of 
undefined symbols
which is broken for the buggy linkers in Xcode 4.2 up to but not including 
Xcode 4.4 due to
radr://10466868. Since the Xcode 4.x was only briefly available to 10.6 users 
and the libitm.c++/eh-1.C 
execution test is already broken on 10.6, they should revert to Xcode 3.2.6 to 
achieve the fix.
Users on 10.7 and later have access to Xcode 4.4 and later without the 
undefined dynamic lookup bug.
Okay for gcc trunk?
Jack
/libgcc

2013-02-06  Iain Sandoe  i...@codesourcery.com
Jack Howarth  howa...@bromo.med.uc.edu

PR libitm/55693
* config/darwin-crt-tm.c: Provide dummy functions only prior to 10.6.

/gcc

2013-02-06  Iain Sandoe  i...@codesourcery.com
Jack Howarth  howa...@bromo.med.uc.edu

PR libitm/55693
* gcc/config/darwin.h: Replace ENDFILE_SPEC with TM_DESTRUCTOR and
define ENDFILE_SPEC as TM_DESTRUCTOR.
* config/i386/darwin.h (ENDFILE_SPEC): Use TM_DESTRUCTOR.

Index: libgcc/config/darwin-crt-tm.c
===
--- libgcc/config/darwin-crt-tm.c   (revision 195764)
+++ libgcc/config/darwin-crt-tm.c   (working copy)
@@ -103,9 +103,12 @@ void __doTMdeRegistrations (void)
 _ITM_deregisterTMCloneTable (tmct);
 }
 
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)  \
+__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__   1060
+
 /* Provide dummy functions to satisfy linkage for versions of the Darwin 
tool-chain that that can't handle undefined weak refs at the link stage.
-   ??? Define these dummy functions only when !HAVE_ELF_STYLE_WEAKREF. */
+   Don't define for 10.6 or later with faster weak-symbol coalescing. */
 
 extern void *__cxa_allocate_exception (size_t) WEAK;
 extern void __cxa_throw (void *, void *, void *) WEAK;
@@ -144,5 +147,5 @@ void _ZdlPvRKSt9nothrow_t (void * a UNUS
 void *_ZnaXRKSt9nothrow_t (size_t s UNUSED, c_nothrow_p b UNUSED)
   { return NULL; }
 void _ZdaPvRKSt9nothrow_t (void * a UNUSED, c_nothrow_p b UNUSED) { return; }
-
+#endif
 #endif
Index: gcc/config/i386/darwin.h
===
--- gcc/config/i386/darwin.h(revision 195764)
+++ gcc/config/i386/darwin.h(working copy)
@@ -131,8 +131,7 @@ extern int darwin_emit_branch_islands;
   %{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
%{mpc32:crtprec32.o%s} \
%{mpc64:crtprec64.o%s} \
-   %{mpc80:crtprec80.o%s} \
-   %{fgnu-tm: -lcrttme.o}
+   %{mpc80:crtprec80.o%s} TM_DESTRUCTOR
 
 #undef SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS   \
Index: gcc/config/darwin.h
===
--- gcc/config/darwin.h (revision 195764)
+++ gcc/config/darwin.h (working copy)
@@ -363,7 +363,8 @@ extern GTY(()) int darwin_ms_struct;
   %{shared-libgcc:%:version-compare( 10.5 mmacosx-version-min= crt3.o%s)}
 
 /* We want a destructor last in the list.  */
-#define ENDFILE_SPEC %{fgnu-tm: -lcrttme.o}
+#define TM_DESTRUCTOR %{fgnu-tm: -lcrttme.o}
+#define ENDFILE_SPEC TM_DESTRUCTOR
 
 #define DARWIN_EXTRA_SPECS \
   { darwin_crt1, DARWIN_CRT1_SPEC }, \


Re: Fix PR52448 (cselim with calls)

2013-02-06 Thread Michael Matz
Hi,

On Wed, 6 Feb 2013, Jakub Jelinek wrote:

 First of all, I'd use gimple_call_builtin_p (call, BUILT_IN_NORMAL) 
 test.  And, the function should certainly conservatively return false 
 for all builtins that aren't (gimple_call_flags (call)  ECF_LEAF) != 0, 
 otherwise they might call hooks in the current CU and similar and free 
 in those hooks (likewise setjmp or similar, but again, that is not 
 ECF_LEAF).

Sure.  Consider the patch changed to introduce this function:

static bool
nonfreeing_call_p (gimple call)
{
  if (gimple_call_builtin_p (call, BUILT_IN_NORMAL)
   gimple_call_flags (call)  ECF_LEAF)
return true;

  return false;
}

Tested on the testcases and hmmer, okay after regstrapping?


Ciao,
Michael.


Re: [PATCH] fix PR sanitizer/55617

2013-02-06 Thread Alexander Potapenko
I can't see how full init_priority support can work without proper aid
from ld and/or the dynamic linker. According to the Apple people,
those don't treat the cross-module priorities properly, so there's
little that can be done on the compiler side.

On Mon, Feb 4, 2013 at 11:39 PM, Mike Stump mikest...@comcast.net wrote:
 On Feb 4, 2013, at 1:38 AM, Jakub Jelinek ja...@redhat.com wrote:
 On Mon, Feb 04, 2013 at 10:22:48AM +0100, Richard Biener wrote:
 Okay for gcc trunk?

 But that does not work across translation units, no?  ISTR collect2 has 
 support
 to handle constructor priorities all by itself (at link time,
 considering all inputs).

 I wonder why the patch turned from initially at least supporting intra-CU
 support for ctor priorities into an ugly hack for asan.  I guess asan
 doesn't care too much about inter-CU ctor priorities, it just needs its
 ctors to run before anything in the same CU is called (mainly the
 __asan_init call), other CUs either won't be asan instrumented, then it
 doesn't matter, or will be, but they will have their own __asan_init call.

 I wonder why darwin cannot use that mechanism to support init priorities?

 But sure, if collect2 can be used for full init prio support, the better.

 It would be nice if someone contributed full init_priority support…  I'd be 
 happy to review that. A good patch for that would add it to clang for darwin, 
 and have gcc use that same mechanism so that we can interoperate nicely.  
 Absent interoperability…  I think it would be annoying, as then you have to 
 have a binary incompatibility to fix the one that is wrong.



--
Alexander Potapenko
Software Engineer
Google Moscow


Re: Fix PR52448 (cselim with calls)

2013-02-06 Thread Richard Biener
On Wed, Feb 6, 2013 at 3:20 PM, Michael Matz m...@suse.de wrote:
 Hi,

 On Wed, 6 Feb 2013, Jakub Jelinek wrote:

 First of all, I'd use gimple_call_builtin_p (call, BUILT_IN_NORMAL)
 test.  And, the function should certainly conservatively return false
 for all builtins that aren't (gimple_call_flags (call)  ECF_LEAF) != 0,
 otherwise they might call hooks in the current CU and similar and free
 in those hooks (likewise setjmp or similar, but again, that is not
 ECF_LEAF).

 Sure.  Consider the patch changed to introduce this function:

 static bool
 nonfreeing_call_p (gimple call)
 {
   if (gimple_call_builtin_p (call, BUILT_IN_NORMAL)
gimple_call_flags (call)  ECF_LEAF)
 return true;

   return false;
 }

 Tested on the testcases and hmmer, okay after regstrapping?

realloc can also effectively free memory.  But the above no longer
considers free () a freeing call as well?!  builtins.def also suggests
built_in_tm_free is to be handled as well.

That said, please enumerate freeing builtins even if they are
not ECF_LEAF at the moment - they might become such I suppose
(realloc is LEAF, free is not) - curiously there is no __builtin_in_tm_realloc.

Richard.


 Ciao,
 Michael.


Re: [PATCH] fix PR sanitizer/55617

2013-02-06 Thread Jack Howarth
On Wed, Feb 06, 2013 at 06:23:50PM +0400, Alexander Potapenko wrote:
 I can't see how full init_priority support can work without proper aid
 from ld and/or the dynamic linker. According to the Apple people,
 those don't treat the cross-module priorities properly, so there's
 little that can be done on the compiler side.
 
 On Mon, Feb 4, 2013 at 11:39 PM, Mike Stump mikest...@comcast.net wrote:
  On Feb 4, 2013, at 1:38 AM, Jakub Jelinek ja...@redhat.com wrote:
  On Mon, Feb 04, 2013 at 10:22:48AM +0100, Richard Biener wrote:
  Okay for gcc trunk?
 
  But that does not work across translation units, no?  ISTR collect2 has 
  support
  to handle constructor priorities all by itself (at link time,
  considering all inputs).
 
  I wonder why the patch turned from initially at least supporting intra-CU
  support for ctor priorities into an ugly hack for asan.  I guess asan
  doesn't care too much about inter-CU ctor priorities, it just needs its
  ctors to run before anything in the same CU is called (mainly the
  __asan_init call), other CUs either won't be asan instrumented, then it
  doesn't matter, or will be, but they will have their own __asan_init call.
 
  I wonder why darwin cannot use that mechanism to support init priorities?
 
  But sure, if collect2 can be used for full init prio support, the better.
 
  It would be nice if someone contributed full init_priority support…  I'd be 
  happy to review that. A good patch for that would add it to clang for 
  darwin, and have gcc use that same mechanism so that we can interoperate 
  nicely.  Absent interoperability…  I think it would be annoying, as then 
  you have to have a binary incompatibility to fix the one that is wrong.
 
 

Alexander,
   I never claimed full init priority support however FSF gcc on darwin 
currently
has no init priority support at all. Since Mike wanted to sort the destructors 
as
well as the constructors and this achieves usable intra-module init priority 
support
for FSF gcc darwin, I don't see why we don't take advantage of it. Especially 
considering that the constructors and destructors will now always be sorted 
anyway.
Jack
ps We will have one advantage over clang's init priority support as we can use 
-flto
to combine all of the code modules (outside of libraries) into a single one for 
the
sorting of constructors/destructors. This allows the g++.dg/special/conpr-3.C 
execution
test case to operate properly on darwin with -flto. Again, remember that clang 
currently
at least supports init priority on a intra-module level. I am just trying to 
leverage
the sorting of constructors/destructors that we added for asan to achive the 
same
level of functionality in FSF gcc on darwin.

 
 --
 Alexander Potapenko
 Software Engineer
 Google Moscow


Re: Fix PR52448 (cselim with calls)

2013-02-06 Thread Michael Matz
Hi,

On Wed, 6 Feb 2013, Richard Biener wrote:

 realloc can also effectively free memory.  But the above no longer
 considers free () a freeing call as well?!

free is not ECF_LEAF, so is handled correctly, like tm_free.  I didn't 
consider realloc, it's indeed not handled.

 That said, please enumerate freeing builtins even if they are not 
 ECF_LEAF at the moment - they might become such I suppose (realloc is 
 LEAF, free is not) - curiously there is no __builtin_in_tm_realloc.

The function now reads:

--
static bool
nonfreeing_call_p (gimple call)
{
  if (gimple_call_builtin_p (call, BUILT_IN_NORMAL)
   gimple_call_flags (call)  ECF_LEAF)
switch (DECL_FUNCTION_CODE (gimple_call_fndecl (call)))
  {
/* Just in case these become ECF_LEAF in the future.  */
case BUILT_IN_FREE:
case BUILT_IN_TM_FREE:
case BUILT_IN_REALLOC:
case BUILT_IN_STACK_RESTORE:
  return false;
default:
  return true;
  }

  return false;
}
--

Testcase and hmmer work, okay after regstrapping?


Ciao,
Michael.


Re: Fix PR52448 (cselim with calls)

2013-02-06 Thread Richard Biener
On Wed, Feb 6, 2013 at 4:07 PM, Michael Matz m...@suse.de wrote:
 Hi,

 On Wed, 6 Feb 2013, Richard Biener wrote:

 realloc can also effectively free memory.  But the above no longer
 considers free () a freeing call as well?!

 free is not ECF_LEAF, so is handled correctly, like tm_free.  I didn't
 consider realloc, it's indeed not handled.

 That said, please enumerate freeing builtins even if they are not
 ECF_LEAF at the moment - they might become such I suppose (realloc is
 LEAF, free is not) - curiously there is no __builtin_in_tm_realloc.

 The function now reads:

 --
 static bool
 nonfreeing_call_p (gimple call)
 {
   if (gimple_call_builtin_p (call, BUILT_IN_NORMAL)
gimple_call_flags (call)  ECF_LEAF)
 switch (DECL_FUNCTION_CODE (gimple_call_fndecl (call)))
   {
 /* Just in case these become ECF_LEAF in the future.  */
 case BUILT_IN_FREE:
 case BUILT_IN_TM_FREE:
 case BUILT_IN_REALLOC:
 case BUILT_IN_STACK_RESTORE:
   return false;
 default:
   return true;
   }

   return false;
 }
 --

 Testcase and hmmer work, okay after regstrapping?

Ok.

Thanks,
Richard.


 Ciao,
 Michael.


Re: [PATCH] fix PR sanitizer/55617

2013-02-06 Thread Alexander Potapenko
 Alexander,
I never claimed full init priority support however FSF gcc on darwin 
 currently
 has no init priority support at all. Since Mike wanted to sort the 
 destructors as
 well as the constructors and this achieves usable intra-module init priority 
 support
 for FSF gcc darwin, I don't see why we don't take advantage of it. Especially
 considering that the constructors and destructors will now always be sorted 
 anyway.
 Jack
 ps We will have one advantage over clang's init priority support as we can 
 use -flto
 to combine all of the code modules (outside of libraries) into a single one 
 for the
 sorting of constructors/destructors. This allows the g++.dg/special/conpr-3.C 
 execution
 test case to operate properly on darwin with -flto. Again, remember that 
 clang currently
 at least supports init priority on a intra-module level. I am just trying to 
 leverage
 the sorting of constructors/destructors that we added for asan to achive the 
 same
 level of functionality in FSF gcc on darwin.


Jack,
I understand and fully support your desire for intra-module ctor/dtor priority.
My comment was meant to reply to Mike (sorry for top-posting it,
again), who, as far as I understood him, wanted to see full
init_priority support on Darwin, which IIUC can't be implemented
without the proper linker support. LTO may help as a bandaid, but I
don't think this solution scales well enough yet.

Alex


[Patch, Fortran] PR 55978: [4.8 Regression] class_optional_2.f90 -Os fails

2013-02-06 Thread Janus Weil
Hi all,

here is a close-to-obvious patch which should fix the occasional
failures of class_optional_2.f90 in the testsuite.

The problem was that we call _gfortran_internal_pack on an array
descriptor for a non-existent array. This can happen, for example,
when passing a NULL array pointer to an optional array dummy (see
attached test case).

The first approach was to add code at translation stage, which only
calls internal_pack if the pointer is non-NULL.

On second thought, I decided to move this check inside of
internal_pack. While this can potentially decrease performance (due to
the additional function call, which I hope is negligible), it ensures
that this check is really done in all possible situations, which makes
internal_pack somewhat safer.

The patch was regtested on x86_64-unknown-linux-gnu. Ok for trunk?

Btw, should I include the additional test case when committing, or is
it sufficient to have class_optional_2.f90?

Cheers,
Janus


2013-02-06  Janus Weil  ja...@gcc.gnu.org

PR fortran/55978
* runtime/in_pack_generic.c (internal_pack): Return if base_addr is
NULL.

2013-02-06  Janus Weil  ja...@gcc.gnu.org

PR fortran/55978
* gfortran.dg/optional_absent_3.f90: New.


pr55978_v3.diff
Description: Binary data


optional_absent_3.f90
Description: Binary data


Re: [PATCH] fix PR sanitizer/55617

2013-02-06 Thread Jack Howarth
On Wed, Feb 06, 2013 at 07:14:07PM +0400, Alexander Potapenko wrote:
  Alexander,
 I never claimed full init priority support however FSF gcc on darwin 
  currently
  has no init priority support at all. Since Mike wanted to sort the 
  destructors as
  well as the constructors and this achieves usable intra-module init 
  priority support
  for FSF gcc darwin, I don't see why we don't take advantage of it. 
  Especially
  considering that the constructors and destructors will now always be sorted 
  anyway.
  Jack
  ps We will have one advantage over clang's init priority support as we can 
  use -flto
  to combine all of the code modules (outside of libraries) into a single one 
  for the
  sorting of constructors/destructors. This allows the 
  g++.dg/special/conpr-3.C execution
  test case to operate properly on darwin with -flto. Again, remember that 
  clang currently
  at least supports init priority on a intra-module level. I am just trying 
  to leverage
  the sorting of constructors/destructors that we added for asan to achive 
  the same
  level of functionality in FSF gcc on darwin.
 
 
 Jack,
 I understand and fully support your desire for intra-module ctor/dtor 
 priority.
 My comment was meant to reply to Mike (sorry for top-posting it,
 again), who, as far as I understood him, wanted to see full
 init_priority support on Darwin, which IIUC can't be implemented
 without the proper linker support. LTO may help as a bandaid, but I
 don't think this solution scales well enough yet.
 
 Alex

Alex,
   I have already opened a radr://13149612, inter module 
constructor/destructor priority
support needed on darwin, and pinged the darwin linker developer on this 
issue. 
 Jack
ps Once we have init priority enabled on darwin in gcc trunk, I plan to open a 
radar about
the absence of support collating this at -O4 on clang. That should be easier to 
address and 
might get Apple looking at the state of their init priority support again. 
IHMO, it would
be a start if they at least support inter-module priority support in clang's 
internal assembler.
I've been lobbying Apple for sometime to provide a stand-alone gas replacement 
based on
clang's internal assembler so we would eventually get such fixes through that.


Re: [PATCH] fix PR sanitizer/55617

2013-02-06 Thread Ian Lance Taylor
On Wed, Feb 6, 2013 at 7:14 AM, Alexander Potapenko gli...@google.com wrote:

 I understand and fully support your desire for intra-module ctor/dtor 
 priority.
 My comment was meant to reply to Mike (sorry for top-posting it,
 again), who, as far as I understood him, wanted to see full
 init_priority support on Darwin, which IIUC can't be implemented
 without the proper linker support. LTO may help as a bandaid, but I
 don't think this solution scales well enough yet.

It could be done using collect2.  Though it would be a bit tedious to write.

Or it could perhaps be done via a linker plugin--the Darwin linker
supports plugins.  I don't know if the Darwin linker has the required
plugin support, but the gold linker does.

Or we could just bug the Darwin guys to support it in the linker, it's
clearly a useful feature, and they do have linker support.

Ian


Re: [PATCH] fix PR sanitizer/55617

2013-02-06 Thread Jack Howarth
On Wed, Feb 06, 2013 at 07:36:06AM -0800, Ian Lance Taylor wrote:
 On Wed, Feb 6, 2013 at 7:14 AM, Alexander Potapenko gli...@google.com wrote:
 
  I understand and fully support your desire for intra-module ctor/dtor 
  priority.
  My comment was meant to reply to Mike (sorry for top-posting it,
  again), who, as far as I understood him, wanted to see full
  init_priority support on Darwin, which IIUC can't be implemented
  without the proper linker support. LTO may help as a bandaid, but I
  don't think this solution scales well enough yet.
 
 It could be done using collect2.  Though it would be a bit tedious to write.

Ian,
Don't you need assembler support for the constructor init priorities to be
called in the correct order when they reside in static or shared libraries?
I couldn't puzzle out how collect2 can help with that issue.
Jack

 
 Or it could perhaps be done via a linker plugin--the Darwin linker
 supports plugins.  I don't know if the Darwin linker has the required
 plugin support, but the gold linker does.
 
 Or we could just bug the Darwin guys to support it in the linker, it's
 clearly a useful feature, and they do have linker support.
 
 Ian


Re: [PATCH] fix PR sanitizer/55617

2013-02-06 Thread Ian Lance Taylor
On Wed, Feb 6, 2013 at 7:44 AM, Jack Howarth howa...@bromo.med.uc.edu wrote:
 On Wed, Feb 06, 2013 at 07:36:06AM -0800, Ian Lance Taylor wrote:
 On Wed, Feb 6, 2013 at 7:14 AM, Alexander Potapenko gli...@google.com 
 wrote:
 
  I understand and fully support your desire for intra-module ctor/dtor 
  priority.
  My comment was meant to reply to Mike (sorry for top-posting it,
  again), who, as far as I understood him, wanted to see full
  init_priority support on Darwin, which IIUC can't be implemented
  without the proper linker support. LTO may help as a bandaid, but I
  don't think this solution scales well enough yet.

 It could be done using collect2.  Though it would be a bit tedious to write.

 Ian,
 Don't you need assembler support for the constructor init priorities to be
 called in the correct order when they reside in static or shared libraries?
 I couldn't puzzle out how collect2 can help with that issue.

collect2 sees the whole link.  It can gather all the constructors
together and sort them.

Ian


Re: [Patch, Fortran] PR 55978: [4.8 Regression] class_optional_2.f90 -Os fails

2013-02-06 Thread Jakub Jelinek
On Wed, Feb 06, 2013 at 04:30:41PM +0100, Janus Weil wrote:
 internal_pack. While this can potentially decrease performance (due to
 the additional function call, which I hope is negligible), it ensures

You mean comparison + conditional jump (predicted unlikely to jump).

 that this check is really done in all possible situations, which makes
 internal_pack somewhat safer.
 
 The patch was regtested on x86_64-unknown-linux-gnu. Ok for trunk?

It looks good to me, but I guess I'll leave the decision to Fortran
reviewers.

Jakub


Re: [PATCH] Fix PR libitm/55693

2013-02-06 Thread Patrick Marlier
Hi Jack,

Thanks for having a look at this.

However I don't understand why you need this:

Index: gcc/config/i386/darwin.h
===
--- gcc/config/i386/darwin.h (revision 195764)
+++ gcc/config/i386/darwin.h (working copy)
@@ -131,8 +131,7 @@ extern int darwin_emit_branch_islands;
   %{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
%{mpc32:crtprec32.o%s} \
%{mpc64:crtprec64.o%s} \
-   %{mpc80:crtprec80.o%s} \
-   %{fgnu-tm: -lcrttme.o}
+   %{mpc80:crtprec80.o%s} TM_DESTRUCTOR

 #undef SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS   \
Index: gcc/config/darwin.h
===
--- gcc/config/darwin.h (revision 195764)
+++ gcc/config/darwin.h (working copy)
@@ -363,7 +363,8 @@ extern GTY(()) int darwin_ms_struct;
   %{shared-libgcc:%:version-compare( 10.5 mmacosx-version-min= crt3.o%s)}

 /* We want a destructor last in the list.  */
-#define ENDFILE_SPEC %{fgnu-tm: -lcrttme.o}
+#define TM_DESTRUCTOR %{fgnu-tm: -lcrttme.o}
+#define ENDFILE_SPEC TM_DESTRUCTOR

 #define DARWIN_EXTRA_SPECS \
   { darwin_crt1, DARWIN_CRT1_SPEC }, \


It seems you just add a macro TM_DESTRUCTOR which is the same as
ENDFILE_SPEC. Maybe I missed something (I am updating my svn)...

Also why HAVE_ELF_STYLE_WEAKREF is not defined for MacOS version where
weak ref works? It could be better to define function to dummy only if
HAVE_ELF_STYLE_WEAKREF is not set (and not testing the MacOS version).

If we want to remove support for Xcode 4.2 (buggy linker), I think you
should also have a look at the old commit to undo it (I remember a
change in libitm which add a #ifdef MACH).

Thanks.

--
Patrick


[patch][google/gcc-4_7] Ignore r194995 for gcc pr55852 (issue7304054)

2013-02-06 Thread Simon Baldwin
Ignore r194995 for gcc pr55852.

Okay for google/gcc-4_7 branch?  Thanks.


Index: contrib/testsuite-management/powerpc-grtev3-linux-gnu.xfail
===
--- contrib/testsuite-management/powerpc-grtev3-linux-gnu.xfail (revision 
195808)
+++ contrib/testsuite-management/powerpc-grtev3-linux-gnu.xfail (working copy)
@@ -1,3 +1,5 @@
+# Ignore r194995 for gcc pr55852.
+FAIL: gfortran.dg/intrinsic_size_3.f90 -O   scan-tree-dump-times original 
iszs = \\(integer\\(kind=2\\)\\) MAX_EXPR \\(D.-dim.0..ubound - 
D.-dim.0..lbound\\) \\+ 1, 0; 1
 # Ignore gcc pr54127.
 FAIL: gcc.dg/torture/pr53589.c -O3 -g  (test for excess errors)
 FAIL: gcc.dg/torture/pr53589.c  -O3 -g  (internal compiler error)

--
This patch is available for review at http://codereview.appspot.com/7304054


Re: [patch][google/gcc-4_7] Ignore r194995 for gcc pr55852 (issue7304054)

2013-02-06 Thread Diego Novillo
On Wed, Feb 6, 2013 at 11:42 AM, Simon Baldwin sim...@google.com wrote:
 Ignore r194995 for gcc pr55852.

 Okay for google/gcc-4_7 branch?  Thanks.

OK.


Diego.


Re: [PATCH] validate_failures.py: Fix performance regression

2013-02-06 Thread Bernhard Reutner-Fischer
On Fri, Dec 07, 2012 at 10:31:57AM -0500, Diego Novillo wrote:
On Thu, Dec 6, 2012 at 1:12 PM, Bernhard Reutner-Fischer
rep.dot@gmail.com wrote:

  def IsComment(line):
Return True if line is a comment.
 -  return line.startswith('#')
 +  return bool(re.matches(#, line))

startswith() is a better match here.

  def IsInclude(line):
Return True if line is an include of another file.
 -  return line.startswith(@include )
 +  return bool(re.matches(@include , line))

Likewise.

  def IsNegativeResult(line):
Return True if line should be removed from the expected results.
 -  return line.startswith(@remove )
 +  return bool(re.matches(@remove , line))

Likewise.


OK with those changes.

Applied as r195811

thanks,


Re: [PATCH] Fix PR libitm/55693

2013-02-06 Thread Jack Howarth
On Wed, Feb 06, 2013 at 05:37:12PM +0100, Patrick Marlier wrote:
 Hi Jack,
 
 Thanks for having a look at this.
 
 However I don't understand why you need this:
 
 Index: gcc/config/i386/darwin.h
 ===
 --- gcc/config/i386/darwin.h (revision 195764)
 +++ gcc/config/i386/darwin.h (working copy)
 @@ -131,8 +131,7 @@ extern int darwin_emit_branch_islands;
%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
 %{mpc32:crtprec32.o%s} \
 %{mpc64:crtprec64.o%s} \
 -   %{mpc80:crtprec80.o%s} \
 -   %{fgnu-tm: -lcrttme.o}
 +   %{mpc80:crtprec80.o%s} TM_DESTRUCTOR
 
  #undef SUBTARGET_EXTRA_SPECS
  #define SUBTARGET_EXTRA_SPECS   \
 Index: gcc/config/darwin.h
 ===
 --- gcc/config/darwin.h (revision 195764)
 +++ gcc/config/darwin.h (working copy)
 @@ -363,7 +363,8 @@ extern GTY(()) int darwin_ms_struct;
%{shared-libgcc:%:version-compare( 10.5 mmacosx-version-min= crt3.o%s)}
 
  /* We want a destructor last in the list.  */
 -#define ENDFILE_SPEC %{fgnu-tm: -lcrttme.o}
 +#define TM_DESTRUCTOR %{fgnu-tm: -lcrttme.o}
 +#define ENDFILE_SPEC TM_DESTRUCTOR
 
  #define DARWIN_EXTRA_SPECS \
{ darwin_crt1, DARWIN_CRT1_SPEC }, \
 
 
 It seems you just add a macro TM_DESTRUCTOR which is the same as
 ENDFILE_SPEC. Maybe I missed something (I am updating my svn)...

Patrick,
   This was the patch Iain proposed off-list and I just cleaned up the comments.
I believe that he added the additional definition of TM_DESTRUCTOR so that 
it could be used to replace the explicit instance of %{fgnu-tm: -lcrttme.o}
in the definition of ENDFILE_SPEC in gcc/config/i386/darwin.h.

 
 Also why HAVE_ELF_STYLE_WEAKREF is not defined for MacOS version where
 weak ref works? It could be better to define function to dummy only if
 HAVE_ELF_STYLE_WEAKREF is not set (and not testing the MacOS version).

I assume you are referring to the change...

 /* Provide dummy functions to satisfy linkage for versions of the Darwin 
tool-chain that that can't handle undefined weak refs at the link stage.
-   ??? Define these dummy functions only when !HAVE_ELF_STYLE_WEAKREF. */
+   Don't define for 10.6 or later with faster weak-symbol coalescing. */

As far as I can tell that was only a TODO type note in the comments and
was never implemented. Using !HAVE_ELF_STYLE_WEAKREF as the conditional
to avoid defining the dummy functions won't help at all. The problem here
has nothing to do with HAVE_ELF_STYLE_WEAKREF but is the fact that 
the introduction of faster c++ weak-symbol coalescing prevents dyld from
looking in libstdc++ for the __cxa* symbols if weak symbols for them
exist in linked libgcc/config/darwin-crt-tm.o. This problem also exists
for Xcode 3.2.6 which doesn't HAVE_ELF_STYLE_WEAKREF. So the correct fix
is what Iain proposed of defining the dummy functions only when the
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__  10.6.

 
 If we want to remove support for Xcode 4.2 (buggy linker), I think you
 should also have a look at the old commit to undo it (I remember a
 change in libitm which add a #ifdef MACH).

I don't see the point. The libitm.c++/eh-1.C execution test case is broken
current gcc trunk on Xcode 4.2 up to 4.4. With the patch, it remains broken (as 
you 
there are some linker bugs you just can hack around).
 Jack

 
 Thanks.
 
 --
 Patrick


Re: [PATCH] Fix PR libitm/55693

2013-02-06 Thread Iain Sandoe

On 6 Feb 2013, at 17:20, Jack Howarth wrote:

 On Wed, Feb 06, 2013 at 05:37:12PM +0100, Patrick Marlier wrote:
 Hi Jack,
 
 Thanks for having a look at this.
 
 However I don't understand why you need this:
 
 Index: gcc/config/i386/darwin.h
 ===
 --- gcc/config/i386/darwin.h (revision 195764)
 +++ gcc/config/i386/darwin.h (working copy)
 @@ -131,8 +131,7 @@ extern int darwin_emit_branch_islands;
   %{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
%{mpc32:crtprec32.o%s} \
%{mpc64:crtprec64.o%s} \
 -   %{mpc80:crtprec80.o%s} \
 -   %{fgnu-tm: -lcrttme.o}
 +   %{mpc80:crtprec80.o%s} TM_DESTRUCTOR
 
 #undef SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS   \
 Index: gcc/config/darwin.h
 ===
 --- gcc/config/darwin.h (revision 195764)
 +++ gcc/config/darwin.h (working copy)
 @@ -363,7 +363,8 @@ extern GTY(()) int darwin_ms_struct;
   %{shared-libgcc:%:version-compare( 10.5 mmacosx-version-min= crt3.o%s)}
 
 /* We want a destructor last in the list.  */
 -#define ENDFILE_SPEC %{fgnu-tm: -lcrttme.o}
 +#define TM_DESTRUCTOR %{fgnu-tm: -lcrttme.o}
 +#define ENDFILE_SPEC TM_DESTRUCTOR
 
 #define DARWIN_EXTRA_SPECS \
   { darwin_crt1, DARWIN_CRT1_SPEC }, \
 
 
 It seems you just add a macro TM_DESTRUCTOR which is the same as
 ENDFILE_SPEC. Maybe I missed something (I am updating my svn)...
 
 Patrick,
   This was the patch Iain proposed off-list and I just cleaned up the 
 comments.
 I believe that he added the additional definition of TM_DESTRUCTOR so that 
 it could be used to replace the explicit instance of %{fgnu-tm: -lcrttme.o}
 in the definition of ENDFILE_SPEC in gcc/config/i386/darwin.h.

Correct - it was non-obvious to have a second instance embedded in the sub-dir.
(but I'm not going to complain if that change is removed).

==

Apropos support.

I believe our policy is to support the latest official XCode from Apple for 
each version of Darwin.

In some cases (Darwins  9) the last issued XCode will not build GCC and it's 
neccessary to build odcctools and bootstrap via an older GCC.

but otherwise I don't see a point in trying to support anything that's an 
'unofficial developer' release of XCode.

Iain



Re: [Patch, Fortran] PR 55978: [4.8 Regression] class_optional_2.f90 -Os fails

2013-02-06 Thread Tobias Burnus

Janus Weil wrote:

here is a close-to-obvious patch which should fix the occasional
failures of class_optional_2.f90 in the testsuite.


Thanks!


On second thought, I decided to move this check inside of
internal_pack. While this can potentially decrease performance (due to
the additional function call, which I hope is negligible), it ensures
that this check is really done in all possible situations, which makes
internal_pack somewhat safer.


I think the performance degradation is low - especially as the code-gen 
version has also a performance penalty, unless the compiler is able to 
deduce at compile time that the flag can be optimized away.



The patch was regtested on x86_64-unknown-linux-gnu. Ok for trunk?


Okay.


Btw, should I include the additional test case when committing, or is
it sufficient to have class_optional_2.f90?


I haven't really followed when the failure occurs. If the new test makes 
failures more likely than with class_optional_2.f90, I'd include it. 
Otherwise, I'd guess it is not necessary. Similarly for my test case in 
PR fortran/55978 comment 19 - I don't know whether it is covered 
anywhere. If not, you could put Thomas' and my test case into one file 
and include it.


Tobias


2013-02-06  Janus Weil  ja...@gcc.gnu.org

 PR fortran/55978
 * runtime/in_pack_generic.c (internal_pack): Return if base_addr is
 NULL.

2013-02-06  Janus Weil  ja...@gcc.gnu.org

 PR fortran/55978
 * gfortran.dg/optional_absent_3.f90: New.


Re: [Patch, Fortran] PR 55978: [4.8 Regression] class_optional_2.f90 -Os fails

2013-02-06 Thread Thomas Koenig

Hi Janus,

after Tobias' approval, two remarks:

One thing that you can do is to change this to

+  if (unlikely(source-base_addr == NULL))
+return NULL;

to minimize the runtime impact.

As for a test  case, a lot of test cases in class_optional_2.f90
are commented out. Some of these could probably be uncommented
now, but it is not too urgent now.

Regards

Thomas



Re: [Patch, Fortran] PR 55978: [4.8 Regression] class_optional_2.f90 -Os fails

2013-02-06 Thread Tobias Burnus

Thomas Koenig wrote:

One thing that you can do is to change this to
+ if (unlikely(source-base_addr == NULL))
+ return NULL;
to minimize the runtime impact.


As Jakub already wrote in his reply, the middle end already assumes the 
condition as unlikely.


(The middle end always does so for == NULL – whether it should is 
another question.)



As for a test case, a lot of test cases in class_optional_2.f90
are commented out. Some of these could probably be uncommented
now, but it is not too urgent now.


Good point! I think we should do it now – otherwise, we will forget it. 
(But one should test using valgrind whether it really works or only 
accidentally.)


Tobias


Fix PR rtl-optimization/56178

2013-02-06 Thread Eric Botcazou
This is the miscompilation of the Ada front-end (ureal.adb) on x86-64/Linux 
with profiled bootstrap and another instance of the infamous webizer bug, 
whereby a REG_EQUAL note for a dead pseudo-register ends up creating an insn 
that wrongly zeroes another pseudo-register.

The origin is fwprop1: from

(insn 399 205 400 13 (set (reg:DI 282 [ ln ])
(subreg:DI (reg:TI 189) 0)) /home/eric/svn/gcc/gcc/ada/urealp.adb:622 
87 {*movdi_internal_rex64}
 (nil))

(insn 400 399 208 13 (set (reg:DI 283 [ ln+8 ])
(subreg:DI (reg:TI 189) 8)) /home/eric/svn/gcc/gcc/ada/urealp.adb:622 
87 {*movdi_internal_rex64}
 (expr_list:REG_DEAD (reg:TI 189)

the pass tries to forward-propagate (subreg:DI (reg:TI 189) 0)) into a bunch 
of insns, which almost always fails and thus generates the much dreaded 
REG_EQUAL notes:

In insn 208, replacing
 (subreg:SI (reg:DI 282 [ ln ]) 0)
 with (subreg:SI (reg:TI 189) 0)
Changes to insn 208 not profitable
 Setting REG_EQUAL note

In insn 210, replacing
 (lshiftrt:DI (reg:DI 282 [ ln ])
(const_int 32 [0x20]))
 with (lshiftrt:DI (subreg:DI (reg:TI 189) 0)
(const_int 32 [0x20]))
Changes to insn 210 not profitable
 Setting REG_EQUAL note

In insn 252, replacing
 (lshiftrt:DI (reg:DI 283 [ ln+8 ])
(const_int 32 [0x20]))
 with (lshiftrt:DI (subreg:DI (reg:TI 189) 8)
(const_int 32 [0x20]))
Changes to insn 252 not profitable
 Setting REG_EQUAL note

In insn 257, replacing
 (subreg:SI (reg:DI 282 [ ln ]) 0)
 with (subreg:SI (reg:TI 189) 0)
Changes to insn 257 not profitable
 Setting REG_EQUAL note

I think there is no point in creating a REG_EQUAL note when you're trying to 
propagate a pseudo (or a subreg of a pseudo here).  As a matter of fact, 
that's what CSE explicitly does not:

  /* If this is a single SET, we are setting a register, and we have an
 equivalent constant, we want to add a REG_NOTE.   We don't want
 to write a REG_EQUAL note for a constant pseudo since verifying that
 that pseudo hasn't been eliminated is a pain.  Such a note also
 won't help anything.

 Avoid a REG_EQUAL note for (CONST (MINUS (LABEL_REF) (LABEL_REF)))
 which can be created for a reference to a compile time computable
 entry in a jump table.  */

  if (n_sets == 1  src_const  REG_P (dest)
   !REG_P (src_const)

so we should not do it in fwprop either.  Patch attached (which adds the 
SUBREG case to cse.c as well); it introduces no changes at -O2 for the 
testcases in gcc.c-torture/compile.  Tested on x86-64/Linux.

Thoughts?


2013-02-06  Eric Botcazou  ebotca...@adacore.com

PR rtl-optimization/56178
* cse.c (cse_insn): Do not create a REG_EQUAL note if the source is a
SUBREG of a register.  Tidy up related block of code.
* fwprop.c (orward_propagate_and_simplify): Do not create a REG_EQUAL
note if the source is a register or a SUBREG of a register.


-- 
Eric BotcazouIndex: fwprop.c
===
--- fwprop.c	(revision 195803)
+++ fwprop.c	(working copy)
@@ -1316,10 +1316,16 @@ forward_propagate_and_simplify (df_ref u
 	 separately try plugging the definition in the note and simplifying.
 	 And only install a REQ_EQUAL note when the destination is a REG
 	 that isn't mentioned in USE_SET, as the note would be invalid
-	 otherwise.  */
-  set_reg_equal = (note == NULL_RTX  REG_P (SET_DEST (use_set))
-		! reg_mentioned_p (SET_DEST (use_set),
-	 SET_SRC (use_set)));
+	 otherwise.  We also don't want to install a note if we are merely
+	 propagating a pseudo since verifying that this pseudo isn't dead
+	 is a pain; moreover such a note won't help anything.  */
+  set_reg_equal = (note == NULL_RTX
+		REG_P (SET_DEST (use_set))
+		!REG_P (src)
+		!(GET_CODE (src) == SUBREG
+			 REG_P (SUBREG_REG (src)))
+		!reg_mentioned_p (SET_DEST (use_set),
+	SET_SRC (use_set)));
 }
 
   if (GET_MODE (*loc) == VOIDmode)
Index: cse.c
===
--- cse.c	(revision 195803)
+++ cse.c	(working copy)
@@ -5311,33 +5311,33 @@ cse_insn (rtx insn)
 	}
 
   /* If this is a single SET, we are setting a register, and we have an
-	 equivalent constant, we want to add a REG_NOTE.   We don't want
-	 to write a REG_EQUAL note for a constant pseudo since verifying that
-	 that pseudo hasn't been eliminated is a pain.  Such a note also
-	 won't help anything.
+	 equivalent constant, we want to add a REG_EQUAL note if the constant
+	 is different from the source.  We don't want to do it for a constant
+	 pseudo since verifying that this pseudo hasn't been eliminated is a
+	 pain; moreover such a note won't help anything.
 
 	 Avoid a REG_EQUAL note for (CONST (MINUS (LABEL_REF) (LABEL_REF)))
 	 which can be created for a reference to a compile time computable
 	 entry in a jump table.  */
-
-  

Re: [RS6000] PR54009 again

2013-02-06 Thread David Edelsohn
On Wed, Feb 6, 2013 at 8:38 AM, Alan Modra amo...@gmail.com wrote:
 My PR54131 fix caused PR54009 to raise its ugly head again.  Allowing
 all LO_SUM addresses in the 'Y' constraint (mem_operand_gpr) wasn't
 quite correct.  We still need to check for wrap when offsetting for
 multiple words/regs.  Fixing that means the LO_SUM addresses not
 accepted by 'Y' need an address reload.

 OK assuming powerpc64 and powerpc-linux regression testing passes?

 PR target/54009
 * config/rs6000/rs6000.c (mem_operand_gpr): Check that LO_SUM
 addresses won't wrap when offsetting.
 (rs6000_secondary_reload): Provide secondary reloads needed for
 wrapping LO_SUM addresses.

Okay.

We just need to tweak it until we close these corner cases.

Do you have a testcase that can be added?

Thanks, David


Re: [PATCH] Fix PR libitm/55693

2013-02-06 Thread Jack Howarth
On Wed, Feb 06, 2013 at 05:28:33PM +, Iain Sandoe wrote:
 
 On 6 Feb 2013, at 17:20, Jack Howarth wrote:
 
  On Wed, Feb 06, 2013 at 05:37:12PM +0100, Patrick Marlier wrote:
  Hi Jack,
  
  Thanks for having a look at this.
  
  However I don't understand why you need this:
  
  Index: gcc/config/i386/darwin.h
  ===
  --- gcc/config/i386/darwin.h (revision 195764)
  +++ gcc/config/i386/darwin.h (working copy)
  @@ -131,8 +131,7 @@ extern int darwin_emit_branch_islands;
%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
 %{mpc32:crtprec32.o%s} \
 %{mpc64:crtprec64.o%s} \
  -   %{mpc80:crtprec80.o%s} \
  -   %{fgnu-tm: -lcrttme.o}
  +   %{mpc80:crtprec80.o%s} TM_DESTRUCTOR
  
  #undef SUBTARGET_EXTRA_SPECS
  #define SUBTARGET_EXTRA_SPECS   \
  Index: gcc/config/darwin.h
  ===
  --- gcc/config/darwin.h (revision 195764)
  +++ gcc/config/darwin.h (working copy)
  @@ -363,7 +363,8 @@ extern GTY(()) int darwin_ms_struct;
%{shared-libgcc:%:version-compare( 10.5 mmacosx-version-min= crt3.o%s)}
  
  /* We want a destructor last in the list.  */
  -#define ENDFILE_SPEC %{fgnu-tm: -lcrttme.o}
  +#define TM_DESTRUCTOR %{fgnu-tm: -lcrttme.o}
  +#define ENDFILE_SPEC TM_DESTRUCTOR
  
  #define DARWIN_EXTRA_SPECS \
{ darwin_crt1, DARWIN_CRT1_SPEC }, \
  
  
  It seems you just add a macro TM_DESTRUCTOR which is the same as
  ENDFILE_SPEC. Maybe I missed something (I am updating my svn)...
  
  Patrick,
This was the patch Iain proposed off-list and I just cleaned up the 
  comments.
  I believe that he added the additional definition of TM_DESTRUCTOR so that 
  it could be used to replace the explicit instance of %{fgnu-tm: -lcrttme.o}
  in the definition of ENDFILE_SPEC in gcc/config/i386/darwin.h.
 
 Correct - it was non-obvious to have a second instance embedded in the 
 sub-dir.
 (but I'm not going to complain if that change is removed).
 
 ==
 
 Apropos support.
 
 I believe our policy is to support the latest official XCode from Apple for 
 each version of Darwin.

Iain,
   Do remember that Xcode 4.x on Snow Leopard is the odd duck here. Those 
releases were the
only Xcode releases that Apple required to be explicitly purchased at a cost 
from the App Store.
Also, those releases were only briefly available from the App Store (as they 
were removed as
soon as Lion was released). So it is no longer the latest official Xcode for 
Snow Leopard
(unless you have a paid developer account). I suspect this episode will never 
be repeated and had
more to do with the novelty of the App Store at the time. Apple has been very 
good with Xcode
releases under Lion (starting with 4.2 up to the current 4.6 release) all being 
free.
   Jack

 
 In some cases (Darwins  9) the last issued XCode will not build GCC and it's 
 neccessary to build odcctools and bootstrap via an older GCC.
 
 but otherwise I don't see a point in trying to support anything that's an 
 'unofficial developer' release of XCode.

It's really neither fish nor fowl as Apple did release it 'officially' but only 
for a brief period of time.

 
 Iain


[PATCH] Check headers in verify_loop_structure

2013-02-06 Thread Marek Polacek
This patch extends verify_loop_structure by checking that header's
are really its own headers (this proved as useful in PR56181).
The bulk of the code is taken from flow_loops_find.

Bootstrapped on x86_64 linux.  The only fallout now is (for C/C++):
FAIL: gcc.dg/torture/pr54458.c  -O3 -fomit-frame-pointer  (internal compiler 
error)
FAIL: gcc.dg/torture/pr54458.c  -O3 -fomit-frame-pointer  (test for excess 
errors)
FAIL: gcc.dg/torture/pr54458.c  -O3 -fomit-frame-pointer -funroll-loops  
(internal compiler error)
FAIL: gcc.dg/torture/pr54458.c  -O3 -fomit-frame-pointer -funroll-loops  (test 
for excess errors)
FAIL: gcc.dg/torture/pr54458.c  -O3 -fomit-frame-pointer -funroll-all-loops 
-finline-functions  (internal compiler error)
FAIL: gcc.dg/torture/pr54458.c  -O3 -fomit-frame-pointer -funroll-all-loops 
-finline-functions  (test for excess errors)
FAIL: gcc.dg/torture/pr54458.c  -O3 -g  (internal compiler error)   
   
FAIL: gcc.dg/torture/pr54458.c  -O3 -g  (test for excess errors)

which is only because -O3 means -funswitch-loops as well.  What happens
here is quite interesting situation, we have three analogical loops
which look like below.  BB7 is marked as IRREDUCIBLE_LOOP.

|
  +---+ |
  |   | |
  |   +---+-+-+
  |   |   6   |
  |   +---+---+
  |   |---|
  |   |  -/   |
  |   +-/-+   |
  |   |   7   |   |
  |   +---+   |
  |/  \   |
  |   /\  |
  |   +--++--+|
  |   |  9   ||   8  ||
  |   +--+---++---+--+|
  |  ||   |
  |  |+---+
  |   +---+
  |   |   10  |
  |   +---+---+
  |   |
  +---+

Thus, we basically have two headers in a loop.
So, shall I skip the BB_IRREDUCIBLE_LOOP blocks?  (Although this leads to
another crash: we get into the same situation in another pass, just
the BB isn't marked as BB_IRREDUCIBLE_LOOP, so we don't skip it.  Perhaps
this could be sorted out by just calling mark_irreducible_loops somewhere.)

Comments?

2013-02-06  Marek Polacek  pola...@redhat.com

* cfgloop.c (verify_loop_structure): Check that header
BBs are really its own headers.

--- gcc/cfgloop.c.mp2013-02-06 12:08:01.536918761 +0100
+++ gcc/cfgloop.c   2013-02-06 18:32:59.957027313 +0100
@@ -1316,6 +1316,41 @@ verify_loop_structure (void)
   else
 verify_dominators (CDI_DOMINATORS);
 
+  /* Check the loop headers.  */
+  FOR_EACH_BB (bb)
+{
+  edge_iterator ei;
+
+  /* If we have an abnormal predecessor, do not consider the
+loop (not worth the problems).  */
+  if (bb_has_abnormal_pred (bb))
+   continue;
+
+  if (bb-loop_father == current_loops-tree_root)
+continue;
+
+  FOR_EACH_EDGE (e, ei, bb-preds)
+   {
+ basic_block latch = e-src;
+
+ gcc_assert (!(e-flags  EDGE_ABNORMAL));
+
+ /* Look for back edges where a predecessor is dominated
+by this block.  A natural loop has a single entry
+node (header) that dominates all the nodes in the
+loop.  It also has single back edge to the header
+from a latch node.  */
+ if (latch != ENTRY_BLOCK_PTR
+  bb != latch
+  dominated_by_p (CDI_DOMINATORS, latch, bb))
+   if (bb-loop_father-header != bb)
+ {
+   error (header %d is not its own header, bb-index);
+   err = 1;
+ }
+   }
+}
+
   /* Check sizes.  */
   sizes = XCNEWVEC (unsigned, num);
   sizes[0] = 2;

Marek


Re: [Patch, Fortran] PR 55978: [4.8 Regression] class_optional_2.f90 -Os fails

2013-02-06 Thread Janus Weil
 As for a test case, a lot of test cases in class_optional_2.f90
 are commented out. Some of these could probably be uncommented
 now, but it is not too urgent now.

 Good point! I think we should do it now – otherwise, we will forget it. (But
 one should test using valgrind whether it really works or only
 accidentally.)

Actually I found only two Conditional jump cases which work now, see
updated patch. The rest is being tracked in PR 54618.

Will commit this later this evening. Thanks for the reviews, everyone!

Cheers,
Janus


pr55978_v4.diff
Description: Binary data


Re: Fix PR rtl-optimization/56178

2013-02-06 Thread Jeff Law

On 02/06/2013 11:11 AM, Eric Botcazou wrote:



I think there is no point in creating a REG_EQUAL note when you're trying to
propagate a pseudo (or a subreg of a pseudo here).  As a matter of fact,
that's what CSE explicitly does not:
Agreed.  I have a hard time seeing where having a REG_EQUAL note that is 
just a REG or SUBREG (REG) is actually useful -- const/copy propagation 
ought to be able to find those equivalences without the aid of the note. 
 And as we've repeatedly seen, they cause problems.


Beyond 4.8, I'd really like to see this formalized a bit with a checker 
to ensure such notes aren't created and docs for REG_EQUAL notes 
indicating such notes are invalid.





2013-02-06  Eric Botcazou  ebotca...@adacore.com

PR rtl-optimization/56178
* cse.c (cse_insn): Do not create a REG_EQUAL note if the source is a
SUBREG of a register.  Tidy up related block of code.
* fwprop.c (orward_propagate_and_simplify): Do not create a REG_EQUAL
note if the source is a register or a SUBREG of a register.
Cleanups to cse look fine, as do the real changes of avoiding creating 
notes for the SUBREG (REG) case for both cse and fwprop.  Please install.



jeff


[RFC] Modify -g1 to produce line tables

2013-02-06 Thread Cary Coutant
A long time ago, I proposed a -gmlt option to generate minimal line
tables (basically -g1 + line tables):

http://gcc.gnu.org/ml/gcc-patches/2011-04/msg02075.html

The consensus from that thread was that instead of a new option, we
should just modify -g1 to produce line tables (the documented purpose
of -g1 is to enable stack traces, and stack traces are much more
useful with line numbers). I also proposed, and got no objection, that
-g by itself should set the debugging level to 2 (i.e., -g1 -g should
behave the same as -g1 -g2).

Here, finally, is that patch again, reworked to generate line tables
at -g1. I plan to commit this when Stage 1 reopens, but I'd like to
verify that earlier consensus. I also plan to commit this to the
google/main branch, and future merges will go more smoothly if what I
put in google/main matches what eventually goes into trunk.

-cary

2013-02-06   Cary Coutant  ccout...@google.com

gcc/
* dwarf2out.c (want_pubnames): Don't do pubnames for -g1.
(add_linkage_name): Don't add linkage name for -g1.
(decls_for_scope): Process subblocks for -g1.
(dwarf2out_source_line): Output line tables for -g1.
(dwarf2out_finish): Likewise.
* tree-ssa-live.c (remove_unused_scope_block_p): Don't prune
unused scopes for -g1.
* opts.c (common_handle_option): Handle -g same as -g2.
* doc/invoke.texi: Update description for -g1.

gcc/testsuite/
* gcc.dg/debug/dwarf2/mlt1.c: New test.
* gcc.dg/debug/dwarf2/mlt2.c: New test.
2013-02-06   Cary Coutant  ccout...@google.com

gcc/
* dwarf2out.c (want_pubnames): Don't do pubnames for -g1.
(add_linkage_name): Don't add linkage name for -g1.
(decls_for_scope): Process subblocks for -g1.
(dwarf2out_source_line): Output line tables for -g1.
(dwarf2out_finish): Likewise.
* tree-ssa-live.c (remove_unused_scope_block_p): Don't prune
unused scopes for -g1.
* opts.c (common_handle_option): Handle -g same as -g2.
* doc/invoke.texi: Update description for -g1.

gcc/testsuite/
* gcc.dg/debug/dwarf2/mlt1.c: New test.
* gcc.dg/debug/dwarf2/mlt2.c: New test.


Index: dwarf2out.c
===
--- dwarf2out.c (revision 195743)
+++ dwarf2out.c (working copy)
@@ -8650,9 +8650,11 @@ output_comp_unit (dw_die_ref die, int ou
 static inline bool
 want_pubnames (void)
 {
-  return (debug_generate_pub_sections != -1
- ? debug_generate_pub_sections
- : targetm.want_debug_pub_sections);
+  if (debug_info_level = DINFO_LEVEL_TERSE)
+return false;
+  if (debug_generate_pub_sections != -1)
+return debug_generate_pub_sections;
+  return targetm.want_debug_pub_sections;
 }
 
 /* Add the DW_AT_GNU_pubnames and DW_AT_GNU_pubtypes attributes.  */
@@ -16222,11 +16224,12 @@ add_src_coords_attributes (dw_die_ref di
 static void
 add_linkage_name (dw_die_ref die, tree decl)
 {
-  if ((TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == VAR_DECL)
-TREE_PUBLIC (decl)
-!DECL_ABSTRACT (decl)
-!(TREE_CODE (decl) == VAR_DECL  DECL_REGISTER (decl))
-die-die_tag != DW_TAG_member)
+  if (debug_info_level  DINFO_LEVEL_TERSE
+   (TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == VAR_DECL)
+   TREE_PUBLIC (decl)
+   !DECL_ABSTRACT (decl)
+   !(TREE_CODE (decl) == VAR_DECL  DECL_REGISTER (decl))
+   die-die_tag != DW_TAG_member)
 {
   /* Defer until we have an assembler name set.  */
   if (!DECL_ASSEMBLER_NAME_SET_P (decl))
@@ -19609,16 +19612,19 @@ decls_for_scope (tree stmt, dw_die_ref c
   /* Output the DIEs to represent all of the data objects and typedefs
  declared directly within this block but not within any nested
  sub-blocks.  Also, nested function and tag DIEs have been
- generated with a parent of NULL; fix that up now.  */
-  for (decl = BLOCK_VARS (stmt); decl != NULL; decl = DECL_CHAIN (decl))
-process_scope_var (stmt, decl, NULL_TREE, context_die);
-  for (i = 0; i  BLOCK_NUM_NONLOCALIZED_VARS (stmt); i++)
-process_scope_var (stmt, NULL, BLOCK_NONLOCALIZED_VAR (stmt, i),
-  context_die);
+ generated with a parent of NULL; fix that up now.  We don't
+ have to do this if we're at -g1.  */
+  if (debug_info_level  DINFO_LEVEL_TERSE)
+{
+  for (decl = BLOCK_VARS (stmt); decl != NULL; decl = DECL_CHAIN (decl))
+   process_scope_var (stmt, decl, NULL_TREE, context_die);
+  for (i = 0; i  BLOCK_NUM_NONLOCALIZED_VARS (stmt); i++)
+   process_scope_var (stmt, NULL, BLOCK_NONLOCALIZED_VAR (stmt, i),
+  context_die);
+}
 
-  /* If we're at -g1, we're not interested in subblocks.  */
-  if (debug_info_level = DINFO_LEVEL_TERSE)
-return;
+  /* Even if we're at -g1, we need to process the subblocks in order to get
+ inlined call information.  */
 
   /* Output the DIEs to 

Re: [PATCH] Fix PR libitm/55693

2013-02-06 Thread Patrick Marlier
On Wed, Feb 6, 2013 at 6:28 PM, Iain Sandoe i...@codesourcery.com wrote:

 On 6 Feb 2013, at 17:20, Jack Howarth wrote:

 On Wed, Feb 06, 2013 at 05:37:12PM +0100, Patrick Marlier wrote:
 Hi Jack,

 Thanks for having a look at this.

 However I don't understand why you need this:

 Index: gcc/config/i386/darwin.h
 ===
 --- gcc/config/i386/darwin.h (revision 195764)
 +++ gcc/config/i386/darwin.h (working copy)
 @@ -131,8 +131,7 @@ extern int darwin_emit_branch_islands;
   %{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
%{mpc32:crtprec32.o%s} \
%{mpc64:crtprec64.o%s} \
 -   %{mpc80:crtprec80.o%s} \
 -   %{fgnu-tm: -lcrttme.o}
 +   %{mpc80:crtprec80.o%s} TM_DESTRUCTOR

 #undef SUBTARGET_EXTRA_SPECS
 #define SUBTARGET_EXTRA_SPECS   \
 Index: gcc/config/darwin.h
 ===
 --- gcc/config/darwin.h (revision 195764)
 +++ gcc/config/darwin.h (working copy)
 @@ -363,7 +363,8 @@ extern GTY(()) int darwin_ms_struct;
   %{shared-libgcc:%:version-compare( 10.5 mmacosx-version-min= crt3.o%s)}

 /* We want a destructor last in the list.  */
 -#define ENDFILE_SPEC %{fgnu-tm: -lcrttme.o}
 +#define TM_DESTRUCTOR %{fgnu-tm: -lcrttme.o}
 +#define ENDFILE_SPEC TM_DESTRUCTOR

 #define DARWIN_EXTRA_SPECS \
   { darwin_crt1, DARWIN_CRT1_SPEC }, \


 It seems you just add a macro TM_DESTRUCTOR which is the same as
 ENDFILE_SPEC. Maybe I missed something (I am updating my svn)...

 Patrick,
   This was the patch Iain proposed off-list and I just cleaned up the 
 comments.
 I believe that he added the additional definition of TM_DESTRUCTOR so that
 it could be used to replace the explicit instance of %{fgnu-tm: -lcrttme.o}
 in the definition of ENDFILE_SPEC in gcc/config/i386/darwin.h.

 Correct - it was non-obvious to have a second instance embedded in the 
 sub-dir.
 (but I'm not going to complain if that change is removed).

I had a look at Iain's patch from the PR but some changes are missing
in the proposed patch to give TM_DESTRUCTOR a sense.
So either you add changes for files: gcc/config/darwin10.h
libgcc/config.host libgcc/config/t-darwin to this patch or you create
another patch with changes to gcc/config/darwin10.h libgcc/config.host
libgcc/config/t-darwin gcc/config/darwin.h gcc/config/i386/darwin.h.

About this old patch
http://gcc.gnu.org/ml/gcc-patches/2012-02/msg00851.html, I though that
 !defined (__MACH__) should be changed but it seems the best
way...

Thanks for the precision about XCode.

Note that I cannot approve anything. So the patch must be approved by
a GCC master ;)
--
Patrick


Re: var-tracking wrt. leaf regs on sparc

2013-02-06 Thread David Miller
From: Eric Botcazou ebotca...@adacore.com
Date: Wed, 06 Feb 2013 11:13:30 +0100

 I think testing crtl-uses_only_leaf_regs is sufficient here (and
 while you're at it, you could also test the value of
 HAVE_window_save, which can be 0 if -mflat is passed on the SPARC),
 so
 
 #ifdef HAVE_window_save
 if (HAVE_window_save  !crtl-uses_only_leaf_regs)
   {
 
   }
 #endif

Yes, this works perfectly, Jakub any objections?

gcc/

2013-02-06  David S. Miller  da...@davemloft.net

* var-tracking.c (vt_add_function_parameter): Test the presence of
HAVE_window_save properly and do not remap argument registers when
we have a leaf function.

diff --git a/gcc/var-tracking.c b/gcc/var-tracking.c
index 714acb69..0db1562 100644
--- a/gcc/var-tracking.c
+++ b/gcc/var-tracking.c
@@ -9502,31 +9502,34 @@ vt_add_function_parameter (tree parm)
   /* DECL_INCOMING_RTL uses the INCOMING_REGNO of parameter registers.
  If the target machine has an explicit window save instruction, the
  actual entry value is the corresponding OUTGOING_REGNO instead.  */
-  if (REG_P (incoming)
-   HARD_REGISTER_P (incoming)
-   OUTGOING_REGNO (REGNO (incoming)) != REGNO (incoming))
+  if (HAVE_window_save  !crtl-uses_only_leaf_regs)
 {
-  parm_reg_t p;
-  p.incoming = incoming;
-  incoming
-   = gen_rtx_REG_offset (incoming, GET_MODE (incoming),
- OUTGOING_REGNO (REGNO (incoming)), 0);
-  p.outgoing = incoming;
-  vec_safe_push (windowed_parm_regs, p);
-}
-  else if (MEM_P (incoming)
-   REG_P (XEXP (incoming, 0))
-   HARD_REGISTER_P (XEXP (incoming, 0)))
-{
-  rtx reg = XEXP (incoming, 0);
-  if (OUTGOING_REGNO (REGNO (reg)) != REGNO (reg))
+  if (REG_P (incoming)
+  HARD_REGISTER_P (incoming)
+  OUTGOING_REGNO (REGNO (incoming)) != REGNO (incoming))
{
  parm_reg_t p;
- p.incoming = reg;
- reg = gen_raw_REG (GET_MODE (reg), OUTGOING_REGNO (REGNO (reg)));
- p.outgoing = reg;
+ p.incoming = incoming;
+ incoming
+   = gen_rtx_REG_offset (incoming, GET_MODE (incoming),
+ OUTGOING_REGNO (REGNO (incoming)), 0);
+ p.outgoing = incoming;
  vec_safe_push (windowed_parm_regs, p);
- incoming = replace_equiv_address_nv (incoming, reg);
+   }
+  else if (MEM_P (incoming)
+   REG_P (XEXP (incoming, 0))
+   HARD_REGISTER_P (XEXP (incoming, 0)))
+   {
+ rtx reg = XEXP (incoming, 0);
+ if (OUTGOING_REGNO (REGNO (reg)) != REGNO (reg))
+   {
+ parm_reg_t p;
+ p.incoming = reg;
+ reg = gen_raw_REG (GET_MODE (reg), OUTGOING_REGNO (REGNO (reg)));
+ p.outgoing = reg;
+ vec_safe_push (windowed_parm_regs, p);
+ incoming = replace_equiv_address_nv (incoming, reg);
+   }
}
 }
 #endif


[committed] Fix validate_failures.py in standalone testing

2013-02-06 Thread Diego Novillo
When using validate_failures.py with --manifest and --results, we
don't need a GCC build directory.  This is useful when using the
validator outside of the build tree.  We were insisting on finding
a valid build tree regardless of those options.

Tested on x86_64.  Committed to trunk.

* testsuite-management/validate_failures.py: Update
Copyright years.
Request contributions not to use Python features newer
than 2.4.
(GetBuildData): If this is not a build directory,
emit an error only if --results or --manifest are missing.

diff --git a/contrib/testsuite-management/validate_failures.py 
b/contrib/testsuite-management/validate_failures.py
index 5c80ca3..76f9aab 100755
--- a/contrib/testsuite-management/validate_failures.py
+++ b/contrib/testsuite-management/validate_failures.py
@@ -2,10 +2,14 @@
 
 # Script to compare testsuite failures against a list of known-to-fail
 # tests.
+#
+# NOTE: This script is used in installations that are running Python 2.4.
+#   Please stick to syntax features available in 2.4 and earlier
+#   versions.
 
 # Contributed by Diego Novillo dnovi...@google.com
 #
-# Copyright (C) 2011, 2012 Free Software Foundation, Inc.
+# Copyright (C) 2011-2013 Free Software Foundation, Inc.
 #
 # This file is part of GCC.
 #
@@ -78,7 +82,7 @@ _MANIFEST_PATH_PATTERN = '%s/%s/%s.xfail'
 _OPTIONS = None
 
 def Error(msg):
-  print sys.stderr, '\nerror: %s' % msg
+  print sys.stderr, 'error: %s' % msg
   sys.exit(1)
 
 
@@ -358,15 +362,24 @@ def GetManifestPath(srcdir, target, 
user_provided_must_exist):
   Error('Manifest does not exist: %s' % manifest_path)
 return manifest_path
   else:
+assert srdir and target
 return _MANIFEST_PATH_PATTERN % (srcdir, _MANIFEST_SUBDIR, target)
 
 
 def GetBuildData():
-  target = GetMakefileValue('%s/Makefile' % _OPTIONS.build_dir, 
'target_alias=')
   srcdir = GetMakefileValue('%s/Makefile' % _OPTIONS.build_dir, 'srcdir =')
+  target = GetMakefileValue('%s/Makefile' % _OPTIONS.build_dir, 
'target_alias=')
   if not ValidBuildDirectory(_OPTIONS.build_dir, target):
-Error('%s is not a valid GCC top level build directory.' %
-  _OPTIONS.build_dir)
+# If we have been given a set of results to use, we may
+# not be inside a valid GCC build directory.  In that case,
+# the user must provide both a manifest file and a set
+# of results to check against it.
+if not _OPTIONS.results or not _OPTIONS.manifest:
+  Error('%s is not a valid GCC top level build directory. '
+'You must use --manifest and --results to do the validation.' %
+_OPTIONS.build_dir)
+else:
+  return None, None
   print 'Source directory: %s' % srcdir
   print 'Build target: %s' % target
   return srcdir, target
@@ -410,7 +423,7 @@ def PerformComparison(expected, actual, 
ignore_missing_failures):
 
 
 def CheckExpectedResults():
-  (srcdir, target) = GetBuildData()
+  srcdir, target = GetBuildData()
   manifest_path = GetManifestPath(srcdir, target, True)
   print 'Manifest: %s' % manifest_path
   manifest = GetManifest(manifest_path)
@@ -485,7 +498,8 @@ def Main(argv):
   parser.add_option('--manifest', action='store', type='string',
 dest='manifest', default=None,
 help='Name of the manifest file to use (default = '
-'taken from 
contrib/testsuite-managment/target_alias.xfail)')
+'taken from '
+'contrib/testsuite-managment/target_alias.xfail)')
   parser.add_option('--produce_manifest', action='store_true',
 dest='produce_manifest', default=False,
 help='Produce the manifest for the current '


Re: [PATCH 1/2] PowerPC testsuite clean up

2013-02-06 Thread Mike Stump
On Feb 6, 2013, at 1:20 AM, Sebastian Huber 
sebastian.hu...@embedded-brains.de wrote:
 Would someone mind having a look at this.

GIven where we are in the release cycle, I'd prefer a ppc person to double 
check (by reviewing and approving).  I don't see reason why it cannot be 
approved...


Re: [PATCH 1/2] PowerPC testsuite clean up

2013-02-06 Thread Mike Stump
On Feb 6, 2013, at 1:20 AM, Sebastian Huber 
sebastian.hu...@embedded-brains.de wrote:
 Would someone mind having a look at this.

GIven where we are in the release cycle, I'd prefer a ppc person to double 
check (by reviewing and approving).  I don't see reason why it cannot be 
approved…


C++ PATCH for undeclared enum regression

2013-02-06 Thread Jason Merrill
Since the patch to add C++11 opaque enum declarations went in, we 
haven't been giving a diagnostic about defining a nested enum that was 
never declared.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit fc9c83ce083e197c17ad7377431ff219e43d7eff
Author: Jason Merrill ja...@redhat.com
Date:   Wed Feb 6 15:06:30 2013 -0500

	* parser.c (cp_parser_enum_specifier): Check for error_mark_node.

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 74db9ae..72da561 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -14567,7 +14567,7 @@ cp_parser_enum_specifier (cp_parser* parser)
  /*check_dependency=*/true,
  /*ambiguous_decls=*/NULL,
  input_location);
-  if (name)
+  if (name  name != error_mark_node)
 	{
 	  type = TREE_TYPE (name);
 	  if (TREE_CODE (type) == TYPENAME_TYPE)
diff --git a/gcc/testsuite/g++.dg/parse/enum10.C b/gcc/testsuite/g++.dg/parse/enum10.C
new file mode 100644
index 000..8760597
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/enum10.C
@@ -0,0 +1,2 @@
+namespace A { }
+enum A::B { };			// { dg-error  }


Re: [PATCH] Fix PR libitm/55693

2013-02-06 Thread Jack Howarth
On Wed, Feb 06, 2013 at 09:15:20PM +0100, Patrick Marlier wrote:
 On Wed, Feb 6, 2013 at 6:28 PM, Iain Sandoe i...@codesourcery.com wrote:
 
  On 6 Feb 2013, at 17:20, Jack Howarth wrote:
 
  On Wed, Feb 06, 2013 at 05:37:12PM +0100, Patrick Marlier wrote:
  Hi Jack,
 
  Thanks for having a look at this.
 
  However I don't understand why you need this:
 
  Index: gcc/config/i386/darwin.h
  ===
  --- gcc/config/i386/darwin.h (revision 195764)
  +++ gcc/config/i386/darwin.h (working copy)
  @@ -131,8 +131,7 @@ extern int darwin_emit_branch_islands;
%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
 %{mpc32:crtprec32.o%s} \
 %{mpc64:crtprec64.o%s} \
  -   %{mpc80:crtprec80.o%s} \
  -   %{fgnu-tm: -lcrttme.o}
  +   %{mpc80:crtprec80.o%s} TM_DESTRUCTOR
 
  #undef SUBTARGET_EXTRA_SPECS
  #define SUBTARGET_EXTRA_SPECS   \
  Index: gcc/config/darwin.h
  ===
  --- gcc/config/darwin.h (revision 195764)
  +++ gcc/config/darwin.h (working copy)
  @@ -363,7 +363,8 @@ extern GTY(()) int darwin_ms_struct;
%{shared-libgcc:%:version-compare( 10.5 mmacosx-version-min= 
  crt3.o%s)}
 
  /* We want a destructor last in the list.  */
  -#define ENDFILE_SPEC %{fgnu-tm: -lcrttme.o}
  +#define TM_DESTRUCTOR %{fgnu-tm: -lcrttme.o}
  +#define ENDFILE_SPEC TM_DESTRUCTOR
 
  #define DARWIN_EXTRA_SPECS \
{ darwin_crt1, DARWIN_CRT1_SPEC }, \
 
 
  It seems you just add a macro TM_DESTRUCTOR which is the same as
  ENDFILE_SPEC. Maybe I missed something (I am updating my svn)...
 
  Patrick,
This was the patch Iain proposed off-list and I just cleaned up the 
  comments.
  I believe that he added the additional definition of TM_DESTRUCTOR so that
  it could be used to replace the explicit instance of %{fgnu-tm: -lcrttme.o}
  in the definition of ENDFILE_SPEC in gcc/config/i386/darwin.h.
 
  Correct - it was non-obvious to have a second instance embedded in the 
  sub-dir.
  (but I'm not going to complain if that change is removed).
 
 I had a look at Iain's patch from the PR but some changes are missing
 in the proposed patch to give TM_DESTRUCTOR a sense.
 So either you add changes for files: gcc/config/darwin10.h
 libgcc/config.host libgcc/config/t-darwin to this patch or you create
 another patch with changes to gcc/config/darwin10.h libgcc/config.host
 libgcc/config/t-darwin gcc/config/darwin.h gcc/config/i386/darwin.h.

Patrick,
   I think you are making this much more complex than it really is.
The ENDFILE_SPEC on ppc is obtained from gcc/config/darwin.h and is
only...

#define TM_DESTRUCTOR %{fgnu-tm: -lcrttme.o}

whereas for intel darwin, it is defined in gcc/config/i386/darwin.h as

#undef ENDFILE_SPEC
#define ENDFILE_SPEC \
  %{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
   %{mpc32:crtprec32.o%s} \
   %{mpc64:crtprec64.o%s} \
   %{mpc80:crtprec80.o%s} \
   %{fgnu-tm: -lcrttme.o}

Iain only added TM_DESTRUCTOR to remove the explicit instance of
%{fgnu-tm: -lcrttme.o} in the definition of ENDFILE_SPEC in 
gcc/config/i386/darwin.h (which meant he needed a new definition, 
TM_DESTRUCTOR).
That change is non-essential to the fix and completely tangential to the
problem. The actual fix is only the change...

Index: libgcc/config/darwin-crt-tm.c
===
--- libgcc/config/darwin-crt-tm.c   (revision 195764)
+++ libgcc/config/darwin-crt-tm.c   (working copy)
@@ -103,9 +103,12 @@ void __doTMdeRegistrations (void)
 _ITM_deregisterTMCloneTable (tmct);
 }
 
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)  \
+__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__   1060
+
 /* Provide dummy functions to satisfy linkage for versions of the Darwin 
tool-chain that that can't handle undefined weak refs at the link stage.
-   ??? Define these dummy functions only when !HAVE_ELF_STYLE_WEAKREF. */
+   Don't define for 10.6 or later with faster weak-symbol coalescing. */
 
 extern void *__cxa_allocate_exception (size_t) WEAK;
 extern void __cxa_throw (void *, void *, void *) WEAK;
@@ -144,5 +147,5 @@ void _ZdlPvRKSt9nothrow_t (void * a UNUS
 void *_ZnaXRKSt9nothrow_t (size_t s UNUSED, c_nothrow_p b UNUSED)
   { return NULL; }
 void _ZdaPvRKSt9nothrow_t (void * a UNUSED, c_nothrow_p b UNUSED) { return; }
-
+#endif
 #endif

which correctly eliminates the definition of the dummy functions on darwin
when c++ fast weak-symbol coalescing is present (which was introduced in
dyld at 10.6). The problem and solution was identified by the darwin linker
developer. The fast weak-symbol coalescing now assumes that weak symbol
duplicates are rare and only looks for them if the weak symbol appears
in a shared library. In our case, the weak dummy functions are considered
to reside in an object file, libgcc/config/darwin-crt-tm.o, and this
doesn't trigger the 

[committed] Fix typo in validate_failures.py

2013-02-06 Thread Diego Novillo
I misspelled srcdir in an assertion (sorry David!).

Committed to trunk.


* testsuite-management/validate_failures.py: Fix typo.

diff --git a/contrib/testsuite-management/validate_failures.py 
b/contrib/testsuite-management/validate_failures.py
index 76f9aab..74dbcfb 100755
--- a/contrib/testsuite-management/validate_failures.py
+++ b/contrib/testsuite-management/validate_failures.py
@@ -362,7 +362,7 @@ def GetManifestPath(srcdir, target, 
user_provided_must_exist):
   Error('Manifest does not exist: %s' % manifest_path)
 return manifest_path
   else:
-assert srdir and target
+assert srcdir and target
 return _MANIFEST_PATH_PATTERN % (srcdir, _MANIFEST_SUBDIR, target)
 
 


Re: Ping: unreviewed copyright patches

2013-02-06 Thread Richard Sandiford
Ben Elliston b...@air.net.au writes:
 On Mon, Feb 04, 2013 at 12:12:14PM -0800, Bruce Korb wrote:

 If you update a chapter, the book copyright date is updated.  Makes more 
 sense
 to me.

 OK. That's fine with me, then.

Thanks, I installed the patch and added libdecnumber to the list
of default directories to update.

Richard


Re: RFA: Update copyright for libquadmath

2013-02-06 Thread Richard Sandiford
Jakub Jelinek ja...@redhat.com writes:
 On Sun, Feb 03, 2013 at 10:38:05AM +, Richard Sandiford wrote:
 Most of the files here say This file is part of the GNU C Library
 or the GNU MP Library, so maybe we don't actually want to update them.
 Please let me know if so.
 
 Tested on x86_64-linux-gnu.  OK to install?
 
 Richard
 
 
 libquadmath/
  Update copyright years for libquadmath.

 Dunno if we want this, all these files are copied over (with some minor
 adjustments) from glibc, so I wonder if they shouldn't switch to the range
 Copyrights only when the glibc origins do.

Sorry Jakub, I got carried away when applying the other patches and
forgot that you'd raised doubts about these.  I've justed reverted
the libquadmath and libssp bits.

I've installed the patch below to update the list of default directories.

Thanks,
Richard


contrib/
* update-copyright.py: Add libdecnumber to the default list.
Remove libquadmath and libssp.

Index: contrib/update-copyright.py
===
--- contrib/update-copyright.py 2013-02-06 22:04:58.0 +
+++ contrib/update-copyright.py 2013-02-06 22:05:59.362375919 +
@@ -752,14 +752,13 @@ class GCCCmdLine (CmdLine):
 'libatomic',
 'libbacktrace',
 'libcpp',
+'libdecnumber',
 'libgcc',
 'libgfortran',
 'libgomp',
 'libitm',
 'libmudflap',
 'libobjc',
-'libquadmath',
-'libssp',
 'libstdc++-v3',
 ]
 


Re: var-tracking wrt. leaf regs on sparc

2013-02-06 Thread Eric Botcazou
 Yes, this works perfectly, Jakub any objections?
 
 gcc/
 
 2013-02-06  David S. Miller  da...@davemloft.net
 
   * var-tracking.c (vt_add_function_parameter): Test the presence of
   HAVE_window_save properly and do not remap argument registers when
   we have a leaf function.

Please put it on the 4.7 branch as well if approved, this worked (by chance) 
before my change.  TIA.

-- 
Eric Botcazou


Re: [PATCH 1/2] PowerPC testsuite clean up

2013-02-06 Thread David Edelsohn
Because Peter Bergner most recently worked on embedded PPC targets, I
had asked him to double-check the patch before approving it.
Hopefully he will give me some feedback soon.

Thanks, David


[google/integration] Add -gfission and -gmlt options as synonyms

2013-02-06 Thread Cary Coutant
This patch adds -g[no-]fission as a synonym for -g[no-]split-dwarf,
and modifies the existing stub we have for -gmlt to make it a synonym
for -g1. The implementation of -gsplit-dwarf is already in trunk (and
therefore g/i), and the implementation of -g1 to produce line tables
will be submitted for google/main shortly, and for trunk when Stage 1
reopens.

Tested with crosstool-validate.

OK for google/integration?

-cary



Index: opts.c
===
--- opts.c (revision 195770)
+++ opts.c (working copy)
@@ -1720,8 +1720,9 @@ common_handle_option (struct gcc_options
   break;

 case OPT_gmlt:
-  /* [google/integration] - Empty placeholder.  Real implementation
- in google/main.  */
+  /* [google/integration] Synonym for -g1.  */
+  set_debug_level (NO_DEBUG, DEFAULT_GDB_EXTENSIONS, 1, opts, opts_set,
+   loc);
   break;

 case OPT_gvms:
Index: common.opt
===
--- common.opt (revision 195770)
+++ common.opt (working copy)
@@ -2398,6 +2398,12 @@ gsplit-dwarf
 Common Driver RejectNegative Var(dwarf_split_debug_info,1)
 Generate debug information in separate .dwo files

+gfission
+Common Driver Alias(gsplit-dwarf)
+
+gno-fission
+Common Driver Alias(gno-split-dwarf)
+
 gstabs
 Common JoinedOrMissing Negative(gstabs+)
 Generate debug information in STABS format


libgo patch committed: Fixes for select based pollster

2013-02-06 Thread Ian Lance Taylor
On Solaris the libgo networking library uses select.  This patch
implements some fixes for that code.  The Close method is changed to
actually do something; this is mainly for testing purposes.  More
importantly, when a socket is closed, the select needs to be restarted
so that the callers see the close.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

diff -r fd46f2eb83d3 libgo/go/net/fd_bsd.go
--- a/libgo/go/net/fd_bsd.go	Tue Feb 05 15:57:40 2013 -0800
+++ b/libgo/go/net/fd_bsd.go	Wed Feb 06 14:36:13 2013 -0800
@@ -64,7 +64,7 @@
 	return false, nil
 }
 
-func (p *pollster) DelFD(fd int, mode int) {
+func (p *pollster) DelFD(fd int, mode int) bool {
 	// pollServer is locked.
 
 	var kmode int
@@ -77,6 +77,7 @@
 	// EV_DELETE - delete event from kqueue list
 	syscall.SetKevent(ev, fd, kmode, syscall.EV_DELETE)
 	syscall.Kevent(p.kq, p.kbuf[:], nil, nil)
+	return false
 }
 
 func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err error) {
diff -r fd46f2eb83d3 libgo/go/net/fd_linux.go
--- a/libgo/go/net/fd_linux.go	Tue Feb 05 15:57:40 2013 -0800
+++ b/libgo/go/net/fd_linux.go	Wed Feb 06 14:36:13 2013 -0800
@@ -114,7 +114,7 @@
 	}
 }
 
-func (p *pollster) DelFD(fd int, mode int) {
+func (p *pollster) DelFD(fd int, mode int) bool {
 	// pollServer is locked.
 
 	if mode == 'r' {
@@ -133,6 +133,7 @@
 			i++
 		}
 	}
+	return false
 }
 
 func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err error) {
diff -r fd46f2eb83d3 libgo/go/net/fd_select.go
--- a/libgo/go/net/fd_select.go	Tue Feb 05 15:57:40 2013 -0800
+++ b/libgo/go/net/fd_select.go	Wed Feb 06 14:36:13 2013 -0800
@@ -7,6 +7,7 @@
 package net
 
 import (
+	errors
 	os
 	syscall
 )
@@ -17,6 +18,7 @@
 	readyReadFds, readyWriteFds  *syscall.FdSet
 	nReady   int
 	lastFd   int
+	closed   bool
 }
 
 func newpollster() (p *pollster, err error) {
@@ -35,6 +37,10 @@
 func (p *pollster) AddFD(fd int, mode int, repeat bool) (bool, error) {
 	// pollServer is locked.
 
+	if p.closed {
+		return false, errors.New(pollster closed)
+	}
+
 	if mode == 'r' {
 		syscall.FDSet(fd, p.readFds)
 	} else {
@@ -52,19 +58,23 @@
 	return true, nil
 }
 
-func (p *pollster) DelFD(fd int, mode int) {
+func (p *pollster) DelFD(fd int, mode int) bool {
 	// pollServer is locked.
 
+	if p.closed {
+		return false
+	}
+
 	if mode == 'r' {
 		if !syscall.FDIsSet(fd, p.readFds) {
 			print(Select unexpected fd=, fd,  for read\n)
-			return
+			return false
 		}
 		syscall.FDClr(fd, p.readFds)
 	} else {
 		if !syscall.FDIsSet(fd, p.writeFds) {
 			print(Select unexpected fd=, fd,  for write\n)
-			return
+			return false
 		}
 		syscall.FDClr(fd, p.writeFds)
 	}
@@ -73,6 +83,8 @@
 	syscall.FDClr(fd, p.repeatFds)
 
 	// We don't worry about maxFd here.
+
+	return true
 }
 
 func (p *pollster) WaitFD(s *pollServer, nsec int64) (fd int, mode int, err error) {
@@ -89,6 +101,10 @@
 		var e error
 		var tmpReadFds, tmpWriteFds syscall.FdSet
 		for {
+			if p.closed {
+return -1, 0, errors.New(pollster closed)
+			}
+
 			// Temporary syscall.FdSet's into which the values are copied
 			// because select mutates the values.
 			tmpReadFds = *p.readFds
@@ -161,5 +177,6 @@
 }
 
 func (p *pollster) Close() error {
+	p.closed = true
 	return nil
 }
diff -r fd46f2eb83d3 libgo/go/net/fd_unix.go
--- a/libgo/go/net/fd_unix.go	Tue Feb 05 15:57:40 2013 -0800
+++ b/libgo/go/net/fd_unix.go	Wed Feb 06 14:36:13 2013 -0800
@@ -110,16 +110,24 @@
 // any I/O running on fd.  The caller must have locked
 // pollserver.
 func (s *pollServer) Evict(fd *netFD) {
+	doWakeup := false
 	if s.pending[fd.sysfd1] == fd {
 		s.WakeFD(fd, 'r', errClosing)
-		s.poll.DelFD(fd.sysfd, 'r')
+		if s.poll.DelFD(fd.sysfd, 'r') {
+			doWakeup = true
+		}
 		delete(s.pending, fd.sysfd1)
 	}
 	if s.pending[fd.sysfd1|1] == fd {
 		s.WakeFD(fd, 'w', errClosing)
-		s.poll.DelFD(fd.sysfd, 'w')
+		if s.poll.DelFD(fd.sysfd, 'w') {
+			doWakeup = true
+		}
 		delete(s.pending, fd.sysfd1|1)
 	}
+	if doWakeup {
+		s.Wakeup()
+	}
 }
 
 var wakeupbuf [1]byte


Re: [google/integration] Add -gfission and -gmlt options as synonyms

2013-02-06 Thread Diego Novillo
On Wed, Feb 6, 2013 at 5:32 PM, Cary Coutant ccout...@google.com wrote:
 This patch adds -g[no-]fission as a synonym for -g[no-]split-dwarf,
 and modifies the existing stub we have for -gmlt to make it a synonym
 for -g1. The implementation of -gsplit-dwarf is already in trunk (and
 therefore g/i), and the implementation of -g1 to produce line tables
 will be submitted for google/main shortly, and for trunk when Stage 1
 reopens.

 Tested with crosstool-validate.

 OK for google/integration?

OK.


Diego.


Re: GCC for GNU Hurd: MACH built-in preprocessor macro (was: gdb: FTBFS on hurd-i386 (for review))

2013-02-06 Thread Thomas Schwinge
Hi!

On Mon, 05 Nov 2012 07:09:43 +0100, I wrote:
 On Fri, 28 Sep 2012 09:56:41 +0200, Samuel Thibault samuel.thiba...@gnu.org 
 wrote:
  Thomas Schwinge, le Thu 27 Sep 2012 09:15:23 +0200, a écrit :
   On Wed, 26 Sep 2012 16:02:29 +0200, Svante Signell 
   svante.sign...@telia.com wrote:
gdb does not build from source any longer since gdb-multiarch packages
was enabled in 7.4.1-1. The build problems are due to two reasons:
   
   I also once had a look and came to the same conclusion.
   
First the reserved keyword MACH is defined in include/objcode/h8300.h
causing problems since gcc defines it for GNU/Hurd. 
   
   Correct.  And I wonder if that isn't a name-space violation?  This is
   what I meant to look up when working on this two months ago, but then it
   seems I again got distracted by other issues.  Roland, do you have any
   comments regarding that?
   
   [GCC]/gcc/config/gnu.h:
   [...]
   #undef GNU_USER_TARGET_OS_CPP_BUILTINS
   #define GNU_USER_TARGET_OS_CPP_BUILTINS()   \
   do {\
   builtin_define (__gnu_hurd__);\
   builtin_define (__GNU__); \
   builtin_define_std (unix);\
   builtin_define_std (MACH);\
   builtin_assert (system=gnu);  \
   builtin_assert (system=mach); \
   builtin_assert (system=unix); \
   builtin_assert (system=posix);\
   } while (0)
   
   $ gcc -dM -E -x c -  /dev/null | grep -i mach
   #define __MACH 1
   #define __MACH__ 1
   #define MACH 1
  
  On Linux i386, both linux and i386 macros are defined, which poses
  its own problems too.
 
 (Let's pause for a moment in remembrance of the »glibc vs. i686 defined«
 issue that would nearly have seen its 10th anniversary these days.)
 
  I'd indeed tend to say that defining a non-underscored macro is only a
  way for troubles.
  
   Could we/should we remove the latter one?  Though, I have no idea how
   much user code is relying on MACH being #defined.  I had a colleague
   check, and Apple/Darwin systems do *only* #define __MACH__ (as well as
   __APPLE__).
 
 Here is the straightforward patch.  With it, only the __MACH__ built-in
 preprocessor macro remains, and we get:
 
 [...]
  Fixing headers into /home/thomas/tmp/gnu-0/obj/gcc/gcc/include-fixed for
  i686-pc-gnu target
 -Forbidden identifiers: MACH i386 unix
 +Forbidden identifiers: i386 unix
 [...]
 
 These two are to remain.
 
 diff --git gcc/config/gnu.h gcc/config/gnu.h
 index dddbcbf..4d9449e 100644
 --- gcc/config/gnu.h
 +++ gcc/config/gnu.h
 @@ -34,7 +34,7 @@ along with GCC.  If not, see http://www.gnu.org/licenses/.
   builtin_define (__gnu_hurd__);\
   builtin_define (__GNU__); \
   builtin_define_std (unix);\
 - builtin_define_std (MACH);\
 + builtin_define (__MACH__);\
   builtin_assert (system=gnu);  \
   builtin_assert (system=mach); \
   builtin_assert (system=unix); \

Committed to trunk as r195826.  Samuel, please port to active Debian GCC
branches.


Grüße,
 Thomas


pgpOO2kYtYpE2.pgp
Description: PGP signature


Re: [PATCH] Fix PR libitm/55693

2013-02-06 Thread Jack Howarth
On Wed, Feb 06, 2013 at 09:15:20PM +0100, Patrick Marlier wrote:
 About this old patch
 http://gcc.gnu.org/ml/gcc-patches/2012-02/msg00851.html, I though that
  !defined (__MACH__) should be changed but it seems the best
 way...

Actually on reflection this conditional may be why the proposed patch doesn't
work under 10.6 with Xcode 4.2. That configuration, unlike Xcode 4.5.2/4.6
on 10.7/10.8, doesn't cause HAVE_ELF_STYLE_WEAKREF to be defined and the
testcase was failing with undefined symbols for _ZdlPv. Since Xcode 4.2
has an undefined dynamic lookup bug and Iain said the patch worked with
Xcode 3.2.6 on 10.6, I didn't explore further. I can test tomorrow removing
the  !defined (__MACH__) from libitm/eh_cpp.cc and libitm/alloc_cpp.cc
to see if that fixes the Xcode 4.2/10.6 combination. However, from the
original comments added to the code, this likely will cause the problem
with undefined weak refs being improperly handled at link to time to return
for older Xcode's. Do we know exactly which Xcode releases show that issue?
Jack

 
 Thanks for the precision about XCode.
 
 Note that I cannot approve anything. So the patch must be approved by
 a GCC master ;)
 --
 Patrick


Re: [PATCH] Multiversioning fixes (PR c++/55742, take 2)

2013-02-06 Thread Sriraman Tallam
Hi,

  I have attached a patch documenting Function Multiversioning and
added a few more tests. I have also updated the wiki
http://gcc.gnu.org/wiki/FunctionMultiVersioning. Please let me know if
there are any more tests you specifically want.

  Please review.

Thanks
Sri

On Wed, Jan 30, 2013 at 5:55 AM, Jason Merrill ja...@redhat.com wrote:
 OK.  Sriraman, are you working on documentation and more tests?

 Jason
* doc/extend.texi: Document Function Multiversioning and default
parameter string to target attribute.
* g++.dg/ext/mv12.C: New test.
* g++.dg/ext/mv13.C: New test.
* g++.dg/ext/mv13.h: New file.
* g++.dg/ext/mv13-aux.C: New file.
* config/i386/i386.c (ix86_mangle_function_version_assembler_name): 
Change
comment.
Index: gcc/doc/extend.texi
===
--- gcc/doc/extend.texi (revision 195818)
+++ gcc/doc/extend.texi (working copy)
@@ -3655,6 +3655,11 @@ Enable/disable the generation of the advanced bit
 @cindex @code{target(aes)} attribute
 Enable/disable the generation of the AES instructions.
 
+@item default
+@cindex @code{target(default)} attribute
+@xref{Function Multiversioning}, where it is used to specify the
+default function version.
+
 @item mmx
 @itemx no-mmx
 @cindex @code{target(mmx)} attribute
@@ -15215,6 +15220,7 @@ Predefined Macros,cpp,The GNU C Preprocessor}).
 * Bound member functions:: You can extract a function pointer to the
 method denoted by a @samp{-*} or @samp{.*} expression.
 * C++ Attributes::  Variable, function, and type attributes for C++ only.
+* Function Multiversioning::   Declaring multiple function versions.
 * Namespace Association:: Strong using-directives for namespace association.
 * Type Traits:: Compiler support for type traits
 * Java Exceptions:: Tweaking exception handling to work with Java.
@@ -15744,6 +15750,64 @@ interface table mechanism, instead of regular virt
 
 See also @ref{Namespace Association}.
 
+@node Function Multiversioning
+@section Function Multiversioning
+@cindex function versions
+
+With the GNU C++ front end, for target i386, you may specify multiple
+versions of a function, where each function is specialized for a
+specific target feature.  At runtime, the appropriate version of the
+function is automatically executed depending on the characteristics of
+the execution platform.  Here is an example.
+
+@smallexample
+__attribute__ ((target (default)))
+int foo ()
+@{
+  // The default version of foo.
+  return 0;
+@}
+
+__attribute__ ((target (sse4.2)))
+int foo ()
+@{
+  // foo version for SSE4.2
+  return 1;
+@}
+
+__attribute__ ((target (arch=atom)))
+int foo ()
+@{
+  // foo version for the Intel ATOM processor
+  return 2;
+@}
+
+__attribute__ ((target (arch=amdfam10)))
+int foo ()
+@{
+  // foo version for the AMD Family 0x10 processors.
+  return 3;
+@}
+
+int main ()
+@{
+  int (*p)() = foo;
+  assert ((*p) () == foo ());
+  return 0;
+@}
+@end smallexample
+
+In the above example, four versions of function foo are created. The
+first version of foo with the target attribute default is the default
+version.  This version gets executed when no other target specific
+version qualifies for execution on a particular platform. A new version
+of foo is created by using the same function signature but with a
+different target string.  Function foo is called or a pointer to it is
+taken just like a regular function.  GCC takes care of doing the
+dispatching to call the right version at runtime.  Refer to the
+@uref{http://gcc.gnu.org/wiki/FunctionMultiVersioning, GCC wiki on
+Function Multiversioning} for more details.
+
 @node Namespace Association
 @section Namespace Association
 
Index: gcc/testsuite/g++.dg/ext/mv13-aux.C
===
--- gcc/testsuite/g++.dg/ext/mv13-aux.C (revision 0)
+++ gcc/testsuite/g++.dg/ext/mv13-aux.C (revision 0)
@@ -0,0 +1,11 @@
+// Test case to check if multiversioning works as expected when the versions
+// are defined in different files. Auxiliary file for mv13.C.
+// { dg-do compile }
+
+#include mv13.h
+
+__attribute__ ((target (sse4.2)))
+int foo ()
+{
+  return 1;
+}
Index: gcc/testsuite/g++.dg/ext/mv12.C
===
--- gcc/testsuite/g++.dg/ext/mv12.C (revision 0)
+++ gcc/testsuite/g++.dg/ext/mv12.C (revision 0)
@@ -0,0 +1,21 @@
+// Test to check if an error is generated when virtual functions
+// are multiversioned.  
+
+// { dg-do compile { target i?86-*-* x86_64-*-* } }
+// { dg-options  }
+class Foo
+{
+ public:
+  /* Default version of foo.  */
+  __attribute__ ((target(default)))
+  virtual int foo () // { dg-error Virtual function multiversioning not 
supported }
+  {
+return 0;
+  }
+  /* corei7 version of foo.  */
+  __attribute__ ((target(arch=corei7)))
+  virtual int foo () // { dg-error Virtual 

Re: [RS6000] PR54009 again

2013-02-06 Thread Alan Modra
On Wed, Feb 06, 2013 at 01:24:43PM -0500, David Edelsohn wrote:
 We just need to tweak it until we close these corner cases.
 
 Do you have a testcase that can be added?

David's corner case comment prompted me to look at this again, and
sure enough, there was another case that could be triggered with
-m32 -mpowerpc64.  Discussed off-list with David, final patch as
follows.  Committed revision 195835 (pr54131 test) and 195836.

gcc/
PR target/54009
* config/rs6000/rs6000.c (mem_operand_gpr): Check that LO_SUM
addresses won't wrap when offsetting.
(rs6000_secondary_reload): Provide secondary reloads needed for
wrapping LO_SUM addresses.

gcc/testsuite/
PR target/54131
* gfortran.dg/pr54131.f: New test.

PR target/54009
* gcc.target/powerpc/pr54009.c: New test.


Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 195707)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -5135,17 +5135,14 @@
   if (TARGET_POWERPC64  (offset  3) != 0)
 return false;
 
+  extra = GET_MODE_SIZE (mode) - UNITS_PER_WORD;
+  gcc_assert (extra = 0);
+
   if (GET_CODE (addr) == LO_SUM)
-/* We know by alignment that ABI_AIX medium/large model toc refs
-   will not cross a 32k boundary, since all entries in the
-   constant pool are naturally aligned and we check alignment for
-   other medium model toc-relative addresses.  For ABI_V4 and
-   ABI_DARWIN lo_sum addresses, we just check that 64-bit
-   offsets are 4-byte aligned.  */
-return true;
+/* For lo_sum addresses, we must allow any offset except one that
+   causes a wrap, so test only the low 16 bits.  */
+offset = ((offset  0x) ^ 0x8000) - 0x8000;
 
-  extra = GET_MODE_SIZE (mode) - UNITS_PER_WORD;
-  gcc_assert (extra = 0);
   return offset + 0x8000  0x1u - extra;
 }
 
@@ -13823,19 +13819,36 @@
MEM_P (x)
GET_MODE_SIZE (GET_MODE (x)) = UNITS_PER_WORD)
 {
-  rtx off = address_offset (XEXP (x, 0));
-  unsigned int extra = GET_MODE_SIZE (GET_MODE (x)) - UNITS_PER_WORD;
+  rtx addr = XEXP (x, 0);
+  rtx off = address_offset (addr);
 
-  if (off != NULL_RTX
-  (INTVAL (off)  3) != 0
-  (unsigned HOST_WIDE_INT) INTVAL (off) + 0x8000  0x1 - extra)
+  if (off != NULL_RTX)
{
- if (in_p)
-   sri-icode = CODE_FOR_reload_di_load;
+ unsigned int extra = GET_MODE_SIZE (GET_MODE (x)) - UNITS_PER_WORD;
+ unsigned HOST_WIDE_INT offset = INTVAL (off);
+
+ /* We need a secondary reload when our legitimate_address_p
+says the address is good (as otherwise the entire address
+will be reloaded), and the offset is not a multiple of
+four or we have an address wrap.  Address wrap will only
+occur for LO_SUMs since legitimate_offset_address_p
+rejects addresses for 16-byte mems that will wrap.  */
+ if (GET_CODE (addr) == LO_SUM
+ ? (1 /* legitimate_address_p allows any offset for lo_sum */
+ ((offset  3) != 0
+|| ((offset  0x) ^ 0x8000) = 0x1 - extra))
+ : (offset + 0x8000  0x1 - extra /* legitimate_address_p */
+ (offset  3) != 0))
+   {
+ if (in_p)
+   sri-icode = CODE_FOR_reload_di_load;
+ else
+   sri-icode = CODE_FOR_reload_di_store;
+ sri-extra_cost = 2;
+ ret = NO_REGS;
+   }
  else
-   sri-icode = CODE_FOR_reload_di_store;
- sri-extra_cost = 2;
- ret = NO_REGS;
+   default_p = true;
}
   else
default_p = true;
@@ -13845,25 +13858,43 @@
MEM_P (x)
GET_MODE_SIZE (GET_MODE (x))  UNITS_PER_WORD)
 {
-  rtx off = address_offset (XEXP (x, 0));
-  unsigned int extra = GET_MODE_SIZE (GET_MODE (x)) - UNITS_PER_WORD;
+  rtx addr = XEXP (x, 0);
+  rtx off = address_offset (addr);
 
-  /* We need a secondary reload only when our legitimate_address_p
-says the address is good (as otherwise the entire address
-will be reloaded).  So for mode sizes of 8 and 16 this will
-be when the offset is in the ranges [0x7ffc,0x7fff] and
-[0x7ff4,0x7ff7] respectively.  Note that the address we see
-here may have been manipulated by legitimize_reload_address.  */
-  if (off != NULL_RTX
-  ((unsigned HOST_WIDE_INT) INTVAL (off) - (0x8000 - extra)
-  UNITS_PER_WORD))
+  if (off != NULL_RTX)
{
- if (in_p)
-   sri-icode = CODE_FOR_reload_si_load;
+ unsigned int extra = GET_MODE_SIZE (GET_MODE (x)) - UNITS_PER_WORD;
+ unsigned HOST_WIDE_INT offset = INTVAL (off);
+
+ /* We need a secondary reload when our legitimate_address_p
+ 

[RFC, 4.9 patch] Reload alternative weighting vs. wrong class regs

2013-02-06 Thread Alan Modra
After fixing PR54009 (again), I thought I'd take a look at why reload
is generating the following correct but poor code

 stw 10,8(1)
 stw 11 12(1)
 ...
 lfd 0,8(1)
 stfd 0,x+32764@l(9)

rather than

 addi 9,x+32764@l(9)
 ...
 stw 10,0(9)
 stw 11 4(9)

This code sequence is from

(set (mem/c:DF (lo_sum:SI (reg/f:SI 9)
  (const:SI (plus:SI (symbol_ref:SI (x))
 (const_int 32764)
 (reg:DF 10) ...gcc.target/powerpc/pr54009.c:42 363 {*movdf_hardfloat32})

In tracing through reload, I see a score of 8 for the m-d
alternative, and 9 for Y-r.  In both cases we have one loser
operand for a score of 6 (d in the first case, Y in the second),
plus a score of 2 from

  /* We prefer to reload pseudos over reloading other things,
 since such reloads may be able to be eliminated later.
 If we are reloading a SCRATCH, we won't be generating any
 insns, just using a register, so it is also preferred.
 So bump REJECT in other cases.  Don't do this in the
 case where we are forcing a constant into memory and
 it will then win since we don't want to have a different
 alternative match then.  */
  if (! (REG_P (operand)
  REGNO (operand) = FIRST_PSEUDO_REGISTER)
   GET_CODE (operand) != SCRATCH
   ! (const_to_mem  constmemok))
reject += 2;

The Y-r alternative gets one extra from

  /* Input reloads can be inherited more often than output
 reloads can be removed, so penalize output reloads.  */
  if (operand_type[i] != RELOAD_FOR_INPUT
   GET_CODE (operand) != SCRATCH)
reject++;

The problem of course is that the input reload is quite expensive,
involving a copy to memory.  So, how about teaching reload about this
as follows?  I picked 6 for the reject value to make it equivalent to
a '?' in the constraint, but that may be too large.  Any value of 2 or
greater works for the testcase.

Bootstrapped and regression tested powerpc64-linux, but not yet spec
tested.

2013-02-07  Alan Modra  amo...@gmail.com

* reload.c (find_reloads): Disparage reg alternatives needing
secondary memory to reload.

Index: gcc/reload.c
===
--- gcc/reload.c(revision 195707)
+++ gcc/reload.c(working copy)
@@ -3633,11 +3633,21 @@
  == NO_REGS)
reject = 600;
 
- if (operand_type[i] == RELOAD_FOR_OUTPUT
-  (targetm.preferred_output_reload_class (operand,
-   this_alternative[i])
- == NO_REGS))
+ else if (operand_type[i] == RELOAD_FOR_OUTPUT
+   (targetm.preferred_output_reload_class
+  (operand, this_alternative[i])
+  == NO_REGS))
reject = 600;
+
+#ifdef SECONDARY_MEMORY_NEEDED
+ else if (REG_P (operand)
+   REGNO (operand)  FIRST_PSEUDO_REGISTER
+   (SECONDARY_MEMORY_NEEDED
+  ((enum reg_class) this_alternative[i],
+   REGNO_REG_CLASS (REGNO (operand)),
+   operand_mode[i])))
+   reject += 6;
+#endif
}
 
  /* We prefer to reload pseudos over reloading other things,

-- 
Alan Modra
Australia Development Lab, IBM


[google/main] Generate line tables at -g1 (aka -gmlt)

2013-02-06 Thread Cary Coutant
This patch is the google/main version of this pending patch for trunk:

http://gcc.gnu.org/ml/gcc-patches/2013-02/msg00260.html

I've modified GCC to generate line number tables at -g1, and we
already have the -gmlt option in google/main as a synonym for -g1. The
patch also changes -g so that it has the same behavior as -g2 -- -g1
-g is the same as -g1 -g2.

Tested with crosstool-validate.py.

OK for google/main?

-cary
Index: doc/invoke.texi
===
--- doc/invoke.texi (revision 195825)
+++ doc/invoke.texi (working copy)
@@ -5105,8 +5105,8 @@ Level 0 produces no debug information at
 
 Level 1 produces minimal information, enough for making backtraces in
 parts of the program that you don't plan to debug.  This includes
-descriptions of functions and external variables, but no information
-about local variables and no line numbers.
+descriptions of functions and external variables, and line number
+tables, but no information about local variables.
 
 Level 3 includes extra information, such as all the macro definitions
 present in the program.  Some debuggers support macro expansion when
Index: common.opt
===
--- common.opt  (revision 195825)
+++ common.opt  (working copy)
@@ -2456,6 +2456,10 @@ grecord-gcc-switches
 Common RejectNegative Var(dwarf_record_gcc_switches,1)
 Record gcc command line switches in DWARF DW_AT_producer.
 
+gmlt
+Common RejectNegative
+Generate debug information at level 1 with minimal line table
+
 gno-split-dwarf
 Common Driver RejectNegative Var(dwarf_split_debug_info,0) Init(0)
 Don't generate debug information in separate .dwo files
Index: testsuite/gcc.dg/debug/dwarf2/mlt2.c
===
--- testsuite/gcc.dg/debug/dwarf2/mlt2.c(revision 0)
+++ testsuite/gcc.dg/debug/dwarf2/mlt2.c(revision 0)
@@ -0,0 +1,31 @@
+/* Test that -g overrides -g1.  */
+/* Origin: Cary Coutant  ccout...@google.com */
+/* { dg-do compile } */
+/* { dg-options -O2 -gdwarf-2 -dA -g1 -g } */
+/* { dg-final { scan-assembler DW_AT_stmt_list } } */
+/* { dg-final { scan-assembler DW_TAG_subprogram } } */
+/* { dg-final { scan-assembler DW_TAG_inlined_subroutine } } */
+/* { dg-final { scan-assembler DW_TAG_variable } } */
+/* { dg-final { scan-assembler DW_TAG_formal_parameter } } */
+/* { dg-final { scan-assembler DW_TAG_base_type } } */
+
+static inline __attribute__((always_inline)) int
+a(int i, int j)
+{
+  return (i  5) + j;
+}
+
+int
+b(int i, int j)
+{
+  return (i  5) + (j  27);
+}
+
+int
+c(int i, int j)
+{
+  int r = a(i, j);
+  r = b(r, i);
+  r = b(r, j);
+  return r;
+}
Index: testsuite/gcc.dg/debug/dwarf2/mlt1.c
===
--- testsuite/gcc.dg/debug/dwarf2/mlt1.c(revision 0)
+++ testsuite/gcc.dg/debug/dwarf2/mlt1.c(revision 0)
@@ -0,0 +1,32 @@
+/* Test that -g1 includes line tables and inlined subroutine entries,
+   and excludes types and variables.  */
+/* Origin: Cary Coutant  ccout...@google.com */
+/* { dg-do compile } */
+/* { dg-options -O2 -gdwarf-2 -dA -g1 } */
+/* { dg-final { scan-assembler DW_AT_stmt_list } } */
+/* { dg-final { scan-assembler DW_TAG_subprogram } } */
+/* { dg-final { scan-assembler DW_TAG_inlined_subroutine } } */
+/* { dg-final { scan-assembler-not DW_TAG_variable } } */
+/* { dg-final { scan-assembler-not DW_TAG_formal_parameter } } */
+/* { dg-final { scan-assembler-not DW_TAG_base_type } } */
+
+static inline __attribute__((always_inline)) int
+a(int i, int j)
+{
+  return (i  5) + j;
+}
+
+int
+b(int i, int j)
+{
+  return (i  5) + (j  27);
+}
+
+int
+c(int i, int j)
+{
+  int r = a(i, j);
+  r = b(r, i);
+  r = b(r, j);
+  return r;
+}
Index: dwarf2out.c
===
--- dwarf2out.c (revision 195825)
+++ dwarf2out.c (working copy)
@@ -8648,9 +8648,11 @@ output_comp_unit (dw_die_ref die, int ou
 static inline bool
 want_pubnames (void)
 {
-  return (debug_generate_pub_sections != -1
- ? debug_generate_pub_sections
- : targetm.want_debug_pub_sections);
+  if (debug_info_level = DINFO_LEVEL_TERSE)
+return false;
+  if (debug_generate_pub_sections != -1)
+return debug_generate_pub_sections;
+  return targetm.want_debug_pub_sections;
 }
 
 /* Add the DW_AT_GNU_pubnames and DW_AT_GNU_pubtypes attributes.  */
@@ -16225,11 +16227,12 @@ add_src_coords_attributes (dw_die_ref di
 static void
 add_linkage_name (dw_die_ref die, tree decl)
 {
-  if ((TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == VAR_DECL)
-TREE_PUBLIC (decl)
-!DECL_ABSTRACT (decl)
-!(TREE_CODE (decl) == VAR_DECL  DECL_REGISTER (decl))
-die-die_tag != DW_TAG_member)
+  if (debug_info_level  DINFO_LEVEL_TERSE
+   (TREE_CODE (decl) == FUNCTION_DECL || TREE_CODE (decl) == VAR_DECL)
+   TREE_PUBLIC (decl)
+

Re: [PATCH] Fix PR libitm/55693

2013-02-06 Thread Patrick Marlier
Jack,

On Wed, Feb 6, 2013 at 10:27 PM, Jack Howarth howa...@bromo.med.uc.edu wrote:
I think you are making this much more complex than it really is.
 The ENDFILE_SPEC on ppc is obtained from gcc/config/darwin.h and is
 only...

 #define TM_DESTRUCTOR %{fgnu-tm: -lcrttme.o}

 whereas for intel darwin, it is defined in gcc/config/i386/darwin.h as

 #undef ENDFILE_SPEC
 #define ENDFILE_SPEC \
   %{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
%{mpc32:crtprec32.o%s} \
%{mpc64:crtprec64.o%s} \
%{mpc80:crtprec80.o%s} \
%{fgnu-tm: -lcrttme.o}

 Iain only added TM_DESTRUCTOR to remove the explicit instance of
 %{fgnu-tm: -lcrttme.o} in the definition of ENDFILE_SPEC in
 gcc/config/i386/darwin.h (which meant he needed a new definition, 
 TM_DESTRUCTOR).
 That change is non-essential to the fix and completely tangential to the
 problem. The actual fix is only the change...

Ok thanks. I am fine with this then. It was just I did not understand
the purpose of this from your first email on gcc-patches.
--
Patrick