Re: [Patch, fortran] PR51870 - [OOP] ICE with ALLOCATE and SOURCE-expr function returning BT_CLASS

2012-01-23 Thread Paul Richard Thomas
Dear Tobias,



 I believe that you mean source-expr (i.e. SOURCE= and MOLD=) and not STATUS.

It was late when I wrote the mail :-)


 I somehow liked your draft patch more:

It caused regressions, though!


 * The big program which I reduced to the test case in PR 51870 fails with
 the current patch - only the reduced test case of the PR works. The failure
 of the bigger program is - at runt time - a SIGABRT at
 #6  0x409175 in __show_class_MOD___copy_show_class_Show

 * It also fixed PR 48705. Your current patch fixes the reduced test case
 (comment 1) of that PR, but no longer the original version, which fails at
 the end of the program (end program line) at run time (SIGABRT). Valgrind
 shows:
  Invalid write of size 8
    at 0x4009B3: __generic_deferred_MOD___copy_generic_deferred_Vec (in
 /dev/shm/a.out)

 (I assume both programs have the same issue.)

 Thus, I would prefer if you could have a look at the latter PR.

Hah! OK



  2012-01-22  Paul Thomaspa...@gcc.gnu.org
        PR fortran/51870


 Could you also add PR fortran/51943 and PR 51946? (I think those are
 effectively the same examples. Also the full example
 ssdSource/chapter08/puppeteer_f2003 works for me.)

I am happy to comply with that one !



 +         /* This is the safest way of converting to a compatible
 +            type for use in the allocation.  */
 +         tmp = TYPE_SIZE_UNIT (TREE_TYPE (gfc_index_zero_node));
 +         memsz = fold_convert (TREE_TYPE (tmp), memsz);

 How about:
 +         memsz = fold_convert (size_type_node, memsz);

No - it does not work.  It was the first thing that I tried. The
actual representation is character (kind=4), I think, and this cuased
fold_convert to barf.  I chose to go the route above since it is
always going to be correct for any platform.  In fact, tmp =
TYPE_SIZE_UNIT (gfc_array_index_type); would have been still neater.
If trans-types.c generates an appropriate type, I would be curious to
know which it is, since I have encountered this wrinkle before.



          /* Determine allocate size.  */
 -         if (al-expr-ts.type == BT_CLASS  code-expr3)
 +         if (al-expr-ts.type == BT_CLASS
 +  code-expr3
 +  memsz == NULL_TREE)
            {

 Indentation looks wrong.

I'll take a look.



   for (al = code-ext.alloc.list; al != NULL; al = al-next)
     {
 ...
 +         class_expr = build_fold_indirect_ref_loc (input_location,
 +                                                   se_sz.expr);
 +         class_expr = gfc_evaluate_now (class_expr, se.pre);

 I have the feeling that you evaluate the function multiple times. Actually,
 for*

Not for SOURCE= in this case, the allocate list is only allowed one member.


 allocate(kernel, kernel2, mold=executive_producer%create_show() )

 I find:

        D.1890 = create_show ();
        (struct __vtype_show_producer_class_Integrand *) kernel._vptr =
 (struct __vtype_show_producer_class_Integrand *) D.1890._vptr;
        (void) __builtin_memcpy ((void *) kernel._data, (void *) create_show
 (), 4);

        D.1892 = create_show ();
        (struct __vtype_show_producer_class_Integrand *) kernel2._vptr =
 (struct __vtype_show_producer_class_Integrand *) D.1892._vptr;
        (void) __builtin_memcpy ((void *) kernel2._data, (void *)
 create_show (), 4);

 Thus, one evaluates the function 4 times instead of only once. Additionally,
 MOLD= does not invoke the default initializer (as expected for MOLD=) but
 memcopy (as expected for SOURCE=).

I could fix MOLD but I was attempting to minimise the impact. I'll get on to it.


 The memcpy is also wrong. If CLASS(integrand) (of create_show) returned a
 derived type with allocatable components, one had to to a deep copy. As this
 is not known at compile time, a call to vtab-__copy is required.

 And a last issue: If one changes in
   type(show_producer), allocatable :: executive_producer
 the TYPE to CLASS one gets still an ICE in conv_function_val.

As above - we are entering problems that I did not attempt to address.


 Tobias

 * Ditto for SOURCE=, though there one runs into PR51953 as F2003 only
 allowed one allocate-object.

Indeed.

Thanks for the thorough review.  I'll retire to lick my wounds and fix
MOLD and PR48705.

Paul


[Ada] Aliased view of a type in various Ada dialects

2012-01-23 Thread Arnaud Charlet
This patch corrects the detection of a proper aliased view of a type in the
context of attributes Access and Unchecked_Access.

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

2012-01-23  Hristian Kirtchev  kirtc...@adacore.com

* freeze.adb (Check_Current_Instance): Issue an
error when the prefix of 'Unchecked_Access or 'Access does not
denote a legal aliased view of a type.
(Freeze_Record_Type): Do not halt the processing of record components
once the Has_Controlled_Component is set as this bypasses the remaining
checks.
(Is_Aliased_View_Of_Type): New routine.

Index: freeze.adb
===
--- freeze.adb  (revision 183406)
+++ freeze.adb  (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2011, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2012, 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- --
@@ -1592,14 +1592,93 @@
 
   procedure Check_Current_Instance (Comp_Decl : Node_Id) is
 
- Rec_Type : constant Entity_Id :=
-  Scope (Defining_Identifier (Comp_Decl));
+ function Is_Aliased_View_Of_Type (Typ : Entity_Id) return Boolean;
+ --  Determine whether Typ is compatible with the rules for aliased
+ --  views of types as defined in RM 3.10 in the various dialects.
 
- Decl : constant Node_Id := Parent (Rec_Type);
-
  function Process (N : Node_Id) return Traverse_Result;
  --  Process routine to apply check to given node
 
+ -
+ -- Is_Aliased_View_Of_Type --
+ -
+
+ function Is_Aliased_View_Of_Type (Typ : Entity_Id) return Boolean is
+Typ_Decl : constant Node_Id := Parent (Typ);
+
+ begin
+--  Common case
+
+if Nkind (Typ_Decl) = N_Full_Type_Declaration
+  and then Limited_Present (Type_Definition (Typ_Decl))
+then
+   return True;
+
+--  The following paragraphs describe what a legal aliased view of
+--  a type is in the various dialects of Ada.
+
+--  Ada 95
+
+--  The current instance of a limited type, and a formal parameter
+--  or generic formal object of a tagged type.
+
+--  Ada 95 limited type
+--* Type with reserved word limited
+--* A protected or task type
+--* A composite type with limited component
+
+elsif Ada_Version = Ada_95 then
+   return Is_Limited_Type (Typ);
+
+--  Ada 2005
+
+--  The current instance of a limited tagged type, a protected
+--  type, a task type, or a type that has the reserved word
+--  limited in its full definition ... a formal parameter or
+--  generic formal object of a tagged type.
+
+--  Ada 2005 limited type
+--* Type with reserved word limited, synchronized, task
+--  or protected
+--* A composite type with limited component
+--* A derived type whose parent is a non-interface limited type
+
+elsif Ada_Version = Ada_2005 then
+   return
+ (Is_Limited_Type (Typ) and then Is_Tagged_Type (Typ))
+   or else
+ (Is_Derived_Type (Typ)
+   and then not Is_Interface (Etype (Typ))
+   and then Is_Limited_Type (Etype (Typ)));
+
+--  Ada 2012 and beyond
+
+--  The current instance of an immutably limited type ... a formal
+--  parameter or generic formal object of a tagged type.
+
+--  Ada 2012 limited type
+--* Type with reserved word limited, synchronized, task
+--  or protected
+--* A composite type with limited component
+--* A derived type whose parent is a non-interface limited type
+--* An incomplete view
+
+--  Ada 2012 immutably limited type
+--* Explicitly limited record type
+--* Record extension with limited present
+--* Non-formal limited private type that is either tagged
+--  or has at least one access discriminant with a default
+--  expression
+--* Task type, protected type or 

[Patch testsuite] Fix vec_interleave and vec_extract_even_odd to fall back to vec_perm

2012-01-23 Thread Ramana Radhakrishnan
Hi,

Now that we have vec_perm support, vec_interleave and
vec_extract_even_odd should fall out from that rather than having to
handle an additional target in each of these. This fixes
gcc.dg/vect/slp-11a.c for ARM Neon testing with no other regressions
in gcc.dg/vect

Ok ?


cheers
Ramana


2012-01-23  Ramana Radhakrishnan  ramana.radhakrish...@linaro.org

* lib/target-supports.exp (check_effective_target_vect_interleave): Use
check_effective_target_vect_perm.
(check_effective_target_vect_extract_even_odd): Likewise.



diff --git a/gcc/testsuite/lib/target-supports.exp
b/gcc/testsuite/lib/target-supports.exp
index be33407a..1a0e41f 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -3473,45 +3473,13 @@ proc check_effective_target_vect_int_mult { } {
 # Return 1 if the target supports vector even/odd elements
extraction, 0 otherwise.

 proc check_effective_target_vect_extract_even_odd { } {
-global et_vect_extract_even_odd_saved
-
-if [info exists et_vect_extract_even_odd_saved] {
-verbose check_effective_target_vect_extract_even_odd: using
cached result 2
-} else {
-set et_vect_extract_even_odd_saved 0
-if { [istarget powerpc*-*-*]
- || [istarget i?86-*-*]
- || [istarget x86_64-*-*]
- || [istarget ia64-*-*]
- || [istarget spu-*-*] } {
-   set et_vect_extract_even_odd_saved 1
-}
-}
-
-verbose check_effective_target_vect_extract_even_odd: returning
$et_vect_extract_even_odd_saved 2
-return $et_vect_extract_even_odd_saved
+return [check_effective_target_vect_perm]
 }

 # Return 1 if the target supports vector interleaving, 0 otherwise.

 proc check_effective_target_vect_interleave { } {
-global et_vect_interleave_saved
-
-if [info exists et_vect_interleave_saved] {
-verbose check_effective_target_vect_interleave: using cached result 2
-} else {
-set et_vect_interleave_saved 0
-if { [istarget powerpc*-*-*]
- || [istarget i?86-*-*]
- || [istarget x86_64-*-*]
- || [istarget ia64-*-*]
- || [istarget spu-*-*] } {
-   set et_vect_interleave_saved 1
-}
-}
-
-verbose check_effective_target_vect_interleave: returning
$et_vect_interleave_saved 2
-return $et_vect_interleave_saved
+return [check_effective_target_vect_perm]
 }

 foreach N {2 3 4 8} {


[Ada] Redundant apostrophes in error messages

2012-01-23 Thread Arnaud Charlet
Some error messages contain the string with'ed, but actually the apostrophe
has special meaning for Errout (it means escape the next character), so it
is not displayed. In order to minimize change in compiler output, this change
removes the unnecessary, and ineffective, apostrophes.

No visible behaviour change, no test.

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

2012-01-23  Thomas Quinot  qui...@adacore.com

* sem_ch10.adb, sem_prag.adb: Remove redundant apostrophes in error
messages.

Index: sem_ch10.adb
===
--- sem_ch10.adb(revision 183406)
+++ sem_ch10.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2011, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2012, 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- --
@@ -3339,7 +3339,7 @@
   procedure License_Error is
   begin
  Error_Msg_N
-   (?license of with'ed unit  may be inconsistent,
+   (?license of withed unit  may be inconsistent,
 Name (Item));
   end License_Error;
 
Index: sem_prag.adb
===
--- sem_prag.adb(revision 183406)
+++ sem_prag.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2011, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2012, 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- --
@@ -8256,7 +8256,7 @@
 
if Citem = N then
   Error_Pragma_Arg
-(argument of pragma% is not with'ed unit, Arg);
+(argument of pragma% is not withed unit, Arg);
end if;
 
Next (Arg);
@@ -8334,7 +8334,7 @@
if Citem = N then
   Set_Error_Posted (N);
   Error_Pragma_Arg
-(argument of pragma% is not with'ed unit, Arg);
+(argument of pragma% is not withed unit, Arg);
end if;
 
Next (Arg);
@@ -14203,7 +14203,7 @@
 
   if Citem = N then
  Error_Pragma_Arg
-   (argument of pragma% is not with'ed unit, Arg_Node);
+   (argument of pragma% is not withed unit, Arg_Node);
   end if;
 
   Next (Arg_Node);


[Ada] Deal with empty input in __gnat_decode

2012-01-23 Thread Arnaud Charlet
This patch adds early processing of an empty input name
to __gnat_decode, the Ada demangler used by our traceback
symbolization engines.

Empty inputs are allowed by the spec, and are actually
issued for unresolved traceback addresses (for which we
haven't found a matching symbol name) as of today.

Prior to that change, calls with an empty input would trigger
bogus accesses (read and possibly write) to negative offsets
from the output buffer.

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

2012-01-23  Olivier Hainque  hain...@adacore.com

* adadecode.c (__gnat_decode): Deal with empty input early,
preventing potential erroneous memory access later on.

Index: adadecode.c
===
--- adadecode.c (revision 183406)
+++ adadecode.c (working copy)
@@ -6,7 +6,7 @@
  *  *
  *  C Implementation File   *
  *  *
- *   Copyright (C) 2001-2011, Free Software Foundation, Inc.*
+ *   Copyright (C) 2001-2012, 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- *
@@ -42,7 +42,7 @@
 #include stdio.h
 #include ctype.h
 
-#include adaint.h
+#include adaint.h  /* for a macro version of xstrdup.  */
 
 #ifndef ISDIGIT
 #define ISDIGIT(c) isdigit(c)
@@ -162,8 +162,20 @@
   int in_task = 0;
   int body_nested = 0;
 
+  /* Deal with empty input early.  This allows assuming non-null length
+ later on, simplifying coding.  In principle, it should be our callers
+ business not to call here for empty inputs.  It is easy enough to
+ allow it, however, and might allow simplifications upstream so is not
+ a bad thing per se.  We need a guard in any case.  */
+
+  if (*coded_name == '\0')
+{
+  *ada_name = '\0';
+  return;
+}
+
   /* Check for library level subprogram.  */
-  if (has_prefix (coded_name, _ada_))
+  else if (has_prefix (coded_name, _ada_))
 {
   strcpy (ada_name, coded_name + 5);
   lib_subprog = 1;


[Ada] Improvement to errors and warning messages for expanded names

2012-01-23 Thread Arnaud Charlet
This change modifies the way expanded_names are reported in error messages:
the full expanded name, in source form, is now quoted, rather than just
its terminal Selector_Name.

The following compilation must produce the shown warning message, including
the full name 'Ada.Calendar':

$ gcc -c trygnatwu.adb -gnatwu
trygnatwu.adb:2:09: warning: no entities of Ada.Calendar are referenced

with Ada.Text_Io; use Ada.Text_Io;
with Ada.Calendar; use Ada.Calendar;
procedure trygnatwu is
begin
   Put_Line(Hello);
end trygnatwu;

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

2012-01-23  Thomas Quinot  qui...@adacore.com

* errout.adb (Set_Msg_Node): For an N_Expanded_Name, output
the complete expanded name, rather than just its Selector_Name.

Index: errout.adb
===
--- errout.adb  (revision 183406)
+++ errout.adb  (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2011, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2012, 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- --
@@ -144,7 +144,9 @@
 
procedure Set_Msg_Node (Node : Node_Id);
--  Add the sequence of characters for the name associated with the
-   --  given node to the current message.
+   --  given node to the current message. For N_Designator, N_Defining_Program_
+   --  Unit_Name, N_Selected_Component, and N_Expanded_Name, the Prefix is
+   --  included as well.
 
procedure Set_Msg_Text (Text : String; Flag : Source_Ptr);
--  Add a sequence of characters to the current message. The characters may
@@ -2499,25 +2501,29 @@
   Nam : Name_Id;
 
begin
-  if Nkind (Node) = N_Designator then
- Set_Msg_Node (Name (Node));
- Set_Msg_Char ('.');
- Set_Msg_Node (Identifier (Node));
- return;
+  case Nkind (Node) is
+ when N_Designator =
+Set_Msg_Node (Name (Node));
+Set_Msg_Char ('.');
+Set_Msg_Node (Identifier (Node));
+return;
 
-  elsif Nkind (Node) = N_Defining_Program_Unit_Name then
- Set_Msg_Node (Name (Node));
- Set_Msg_Char ('.');
- Set_Msg_Node (Defining_Identifier (Node));
- return;
+ when N_Defining_Program_Unit_Name =
+Set_Msg_Node (Name (Node));
+Set_Msg_Char ('.');
+Set_Msg_Node (Defining_Identifier (Node));
+return;
 
-  elsif Nkind (Node) = N_Selected_Component then
- Set_Msg_Node (Prefix (Node));
- Set_Msg_Char ('.');
- Set_Msg_Node (Selector_Name (Node));
- return;
-  end if;
+ when N_Selected_Component | N_Expanded_Name =
+Set_Msg_Node (Prefix (Node));
+Set_Msg_Char ('.');
+Set_Msg_Node (Selector_Name (Node));
+return;
 
+ when others =
+null;
+  end case;
+
   --  The only remaining possibilities are identifiers, defining
   --  identifiers, pragmas, and pragma argument associations.
 


[Ada] Refactoring of Ada.Text_IO.Put

2012-01-23 Thread Arnaud Charlet
This change reorganizes code to avoid gratuitous duplication.
No behaviour change, no test.

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

2012-01-23  Thomas Quinot  qui...@adacore.com

* a-textio.adb (Put): Rewrite one-parameter Character version to
just call the two-parameter one with Current_Out.

Index: a-textio.adb
===
--- a-textio.adb(revision 183406)
+++ a-textio.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2010, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2012, 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- --
@@ -1274,30 +1274,7 @@
 
procedure Put (Item : Character) is
begin
-  FIO.Check_Write_Status (AP (Current_Out));
-
-  if Current_Out.Line_Length /= 0
-and then Current_Out.Col  Current_Out.Line_Length
-  then
- New_Line (Current_Out);
-  end if;
-
-  --  If lower half character, or brackets encoding, output directly
-
-  if Character'Pos (Item)  16#80#
-or else Default_WCEM = WCEM_Brackets
-  then
- if fputc (Character'Pos (Item), Current_Out.Stream) = EOF then
-raise Device_Error;
- end if;
-
-  --  Case of upper half character with non-brackets encoding
-
-  else
- Put_Encoded (Current_Out, Item);
-  end if;
-
-  Current_Out.Col := Current_Out.Col + 1;
+  Put (Current_Out, Item);
end Put;
 
-


[Ada] Handle compilation unit specific restrictions for subunits

2012-01-23 Thread Arnaud Charlet
This patch corrects two problems introduced by the previous patch
to handle compilation unit specific restrictions. First if a subunit
is compiled on its own, it does not pick up compilation unit specific
restrictions from a configuration pragma file.

Seccond, if such restrictions appear in the parent unit, they were
improperly applied to subunits.

The following two tests test both these cases

with the following configuration pragmas file:

 1. pragma Restrictions (No_Implementation_Attributes);
 2. pragma Restrictions (SPARK);

and the following sources:

 1. procedure P is
 2.procedure Q is separate;
 3. begin
 4.Q;
 5. end;

 1. separate (P)
 2. procedure Q is
 3.X : constant Integer := 0;
 4.S : String := X'Img;
 5. begin
 6.null;
 7. end Q;

Then if we compile p.adb we get messages for both units:

p.adb:5:04: violation of restriction SPARK at p.adc:2
 end P required
p-q.adb:4:04: violation of restriction SPARK at p.adc:2
   declaration of object of unconstrained type
  not allowed
p-q.adb:4:19: violation of restriction
  No_Implementation_Attributes at p.adc:1

If we compile the subunit on its own we get messages
only for the subunit:

p-q.adb:4:04: violation of restriction SPARK at p.adc:2
   declaration of object of unconstrained type
  not allowed
p-q.adb:4:19: violation of restriction
  No_Implementation_Attributes at p.adc:1

The second test tests the case of pragmas in the file:

 1. pragma Restrictions (No_Implementation_Attributes);
 2. pragma Restrictions (SPARK);
 3. procedure R is
 4.procedure Q is separate;
 5. begin
 6.Q;
 7. end;

 1. separate (R)
 2. procedure Q is
 3.X : constant Integer := 0;
 4.S : String := X'Img;
 5. begin
 6.null;
 7. end Q;

If we compile the parent unit, we get only messages
for the parent unit:

 1. pragma Restrictions (No_Implementation_Attributes);
 2. pragma Restrictions (SPARK);
 3. procedure R is
 4.procedure Q is separate;
 5. begin
 6.Q;
 7. end;
   |
 violation of restriction SPARK at line 2
  end R required

If we compile the subunit, we still get messages only
for the parent unit:

Compiling: r-q.adb

 1. separate (R)
 2. procedure Q is
 3.X : constant Integer := 0;
 4.S : String := X'Img;
 5. begin
 6.null;
 7. end Q;

Compiling: r.adb

 1. pragma Restrictions (No_Implementation_Attributes);
 2. pragma Restrictions (SPARK);
 3. procedure R is
 4.procedure Q is separate;
 5. begin
 6.Q;
 7. end;
   |
 violation of restriction SPARK at line 2
  end R required

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

2012-01-23  Robert Dewar  de...@adacore.com

* sem_ch10.adb (Analyze_Subunit): Properly save/restore cunit
restrictions.

Index: sem_ch10.adb
===
--- sem_ch10.adb(revision 183409)
+++ sem_ch10.adb(working copy)
@@ -1962,6 +1962,12 @@
   Enclosing_Child : Entity_Id := Empty;
   Svg : constant Suppress_Array := Scope_Suppress;
 
+  Save_Cunit_Restrictions : constant Save_Cunit_Boolean_Restrictions :=
+  Cunit_Boolean_Restrictions_Save;
+  --  Save non-partition wide restrictions before processing the subunit.
+  --  All subunits are analyzed with config restrictions reset and we need
+  --  to restore these saved values at the end.
+
   procedure Analyze_Subunit_Context;
   --  Capture names in use clauses of the subunit. This must be done before
   --  re-installing parent declarations, because items in the context must
@@ -2175,6 +2181,15 @@
--  Start of processing for Analyze_Subunit
 
begin
+  --  For subunit in main extended unit, we reset the configuration values
+  --  for the non-partition-wide restrictions. For other units reset them.
+
+  if In_Extended_Main_Source_Unit (N) then
+ Restore_Config_Cunit_Boolean_Restrictions;
+  else
+ Reset_Cunit_Boolean_Restrictions;
+  end if;
+
   if Style_Check then
  declare
 Nam : Node_Id := Name (Unit (N));
@@ -2280,6 +2295,10 @@
 end loop;
  end;
   end if;
+
+  --  Deal with restore of restrictions
+
+  Cunit_Boolean_Restrictions_Restore (Save_Cunit_Restrictions);
end Analyze_Subunit;
 



[Ada] Implementation of aspect Synchronization

2012-01-23 Thread Arnaud Charlet
Aspect Synchronization was introduced in Ada 2012 (AI05-215), to provide
an aspect specification for the previously defined pragma Implemented,
introduced in AI05-030. These two equivalent forms control requeue on a
synchronized interface. This patch implements the aspect version.

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

2012-01-23  Ed Schonberg  schonb...@adacore.com

* snames.ads-tmpl: Add Name_Synchronization.
* aspects.ads, aspects.adb: Add Aspect_Synchronization to
enumeration type and related maps.
* sem_ch13.adb (Analyze_Aspect_Specifications): Handle Aspect
Synchronization, build corresponding pragma Implemented.
* sem_util.adb (Implementation_Kind): Handle both explicit and
implicit pragma_argument association to retrieve the given
synchronization mode.

Index: aspects.adb
===
--- aspects.adb (revision 183406)
+++ aspects.adb (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 2010-2011, Free Software Foundation, Inc. --
+--  Copyright (C) 2010-2012, 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- --
@@ -305,6 +305,7 @@
 Aspect_Stream_Size  = Aspect_Stream_Size,
 Aspect_Suppress = Aspect_Suppress,
 Aspect_Suppress_Debug_Info  = Aspect_Suppress_Debug_Info,
+Aspect_Synchronization  = Aspect_Synchronization,
 Aspect_Test_Case= Aspect_Test_Case,
 Aspect_Type_Invariant   = Aspect_Invariant,
 Aspect_Unchecked_Union  = Aspect_Unchecked_Union,
Index: aspects.ads
===
--- aspects.ads (revision 183406)
+++ aspects.ads (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- S p e c  --
 --  --
--- Copyright (C) 2010-2011, Free Software Foundation, Inc.  --
+-- Copyright (C) 2010-2012, 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- --
@@ -81,6 +81,7 @@
   Aspect_Storage_Size,
   Aspect_Stream_Size,
   Aspect_Suppress,
+  Aspect_Synchronization,
   Aspect_Test_Case, -- GNAT
   Aspect_Type_Invariant,
   Aspect_Unsuppress,
@@ -281,6 +282,7 @@
 Aspect_Storage_Size= Expression,
 Aspect_Stream_Size = Expression,
 Aspect_Suppress= Name,
+Aspect_Synchronization = Name,
 Aspect_Test_Case   = Expression,
 Aspect_Type_Invariant  = Expression,
 Aspect_Unsuppress  = Name,
@@ -367,6 +369,7 @@
  Aspect_Stream_Size  = Name_Stream_Size,
  Aspect_Suppress = Name_Suppress,
  Aspect_Suppress_Debug_Info  = Name_Suppress_Debug_Info,
+ Aspect_Synchronization  = Name_Synchronization,
  Aspect_Test_Case= Name_Test_Case,
  Aspect_Type_Invariant   = Name_Type_Invariant,
  Aspect_Unchecked_Union  = Name_Unchecked_Union,
Index: sem_ch13.adb
===
--- sem_ch13.adb(revision 183406)
+++ sem_ch13.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2011, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2012, 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- --
@@ -1103,6 +1103,21 @@
 
 

Re: Bug store_bit_field_1 + patch

2012-01-23 Thread Aurelien Buhrig
Le 21/01/2012 03:37, Alan Modra a écrit :

 The problem occurs when value is a REG and bitsize  BITS_PER_WORD. This
 is because wordnum, which is used to get the subword of value, is
 incorrectly computed, in BIG_ENDIAN, wrt the number of words needed by
 bitsize instead of the number of words needed by the integer mode of the
 field, which is the mode used to compute subwords.
 
 That doesn't sound right.  wordnum is passed to operand_subword as its
 offset param, which counts in words of word_mode size.  I think you
 have a problem elsewhere.
 

The offset is wrong. I filed a bug. See
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51893



Re: [RFC combine] PR48308 - Fix issue with missing(?) LOG_LINKS

2012-01-23 Thread Ramana Radhakrishnan
On 22 January 2012 10:53, Eric Botcazou ebotca...@adacore.com wrote:
 The un-combining thing around line 2800 is somewhat of a kludge and I
 wouldn't be surprised if there were other fallouts.  But your change is
 clearly correct and looks relatively safe, so OK for trunk and 4.6 branch
 after full testing.

 I overlooked something though: it might be possible for combine_instructions 
 to
 try to combine i2 again if the previous combination fails (if it succeeds, i1
 is deleted so this is OK) so the stall LOG_LINKS could be problematic.  That's
 why LOG_LINKS (i2) needs to SUBST-ituted like the two lines just above

Do you mean something like this instead ? I'm testing this - Ok if no
regressions ?

Ramana


=== modified file 'gcc/combine.c'
--- gcc/combine.c   2012-01-11 22:59:12 +
+++ gcc/combine.c   2012-01-23 08:50:14 +
@@ -2865,6 +2865,7 @@
  SUBST (PATTERN (i2), XVECEXP (PATTERN (i2), 0, 0));
  SUBST (XEXP (SET_SRC (PATTERN (i2)), 0),
 SET_DEST (PATTERN (i1)));
+ SUBST (LOG_LINKS (i2), alloc_insn_link (i1, LOG_LINKS (i2)));
}
 }
 #endif



.

 --
 Eric Botcazou


[Ada] New line for each entry for pg/po/ps in Sprint

2012-01-23 Thread Arnaud Charlet
This patch ensures that output from the Sprint debugging routines
pg/ps/po has each element starting on a new line, for greater
convenience in debug output. This affects only internal debugging
of the compiler itself, so no test is needed.

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

2012-01-23  Robert Dewar  de...@adacore.com

* sprint.ads, sprint.adb (Sprint_Node_List): Add New_Lines parameter
(pg,po,ps): Make sure each entry starts on new line.

Index: sprint.adb
===
--- sprint.adb  (revision 183406)
+++ sprint.adb  (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 1992-2011, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2012, 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- --
@@ -420,7 +420,7 @@
   Current_Source_File := No_Source_File;
 
   if Arg in List_Range then
- Sprint_Node_List (List_Id (Arg));
+ Sprint_Node_List (List_Id (Arg), New_Lines = True);
 
   elsif Arg in Node_Range then
  Sprint_Node (Node_Id (Arg));
@@ -443,7 +443,7 @@
   Current_Source_File := No_Source_File;
 
   if Arg in List_Range then
- Sprint_Node_List (List_Id (Arg));
+ Sprint_Node_List (List_Id (Arg), New_Lines = True);
 
   elsif Arg in Node_Range then
  Sprint_Node (Node_Id (Arg));
@@ -490,7 +490,7 @@
   Current_Source_File := No_Source_File;
 
   if Arg in List_Range then
- Sprint_Node_List (List_Id (Arg));
+ Sprint_Node_List (List_Id (Arg), New_Lines = True);
 
   elsif Arg in Node_Range then
  Sprint_Node (Node_Id (Arg));
@@ -3263,7 +3263,7 @@
-- Sprint_Node_List --
--
 
-   procedure Sprint_Node_List (List : List_Id) is
+   procedure Sprint_Node_List (List : List_Id; New_Lines : Boolean := False) is
   Node : Node_Id;
 
begin
@@ -3276,6 +3276,10 @@
 exit when Node = Empty;
  end loop;
   end if;
+
+  if New_Lines and then Column /= 1 then
+ Write_Eol;
+  end if;
end Sprint_Node_List;
 
--
Index: sprint.ads
===
--- sprint.ads  (revision 183406)
+++ sprint.ads  (working copy)
@@ -6,7 +6,7 @@
 --  --
 -- S p e c  --
 --  --
---  Copyright (C) 1992-2010, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2012, 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- --
@@ -118,11 +118,13 @@
--  blank is output if List is non-empty, and nothing at all is printed it
--  the argument is No_List.
 
-   procedure Sprint_Node_List (List : List_Id);
+   procedure Sprint_Node_List (List : List_Id; New_Lines : Boolean := False);
--  Prints the nodes in a list with no separating characters. This is used
--  in the case of lists of items which are printed on separate lines using
-   --  the current indentation amount. Note that Sprint_Node_List itself
-   --  does not generate any New_Line calls.
+   --  the current indentation amount. New_Lines controls the generation of
+   --  New_Line calls. If False, no New_Line calls are generated. If True,
+   --  then New_Line calls are generated as needed to ensure that each list
+   --  item starts at the beginning of a line.
 
procedure Sprint_Opt_Node_List (List : List_Id);
--  Like Sprint_Node_List, but prints nothing if List = No_List
@@ -151,11 +153,13 @@
procedure po (Arg : Union_Id);
pragma Export (Ada, po);
--  Like pg, but prints original source for the argument (like -gnatdo
-   --  output). Intended only for use from gdb for debugging purposes.
+   --  output). Intended only for use from gdb for debugging purposes. In
+   --  the list case, an end of line is output to separate list elements.
 
procedure ps (Arg : Union_Id);
pragma Export (Ada, ps);
--  Like pg, but prints generated and original source for the argument (like
--  -gnatds output). Intended only for use from gdb for debugging purposes.
+   --  In the list 

[Ada] Performance of UTC_Time_Offset on Windows

2012-01-23 Thread Arnaud Charlet
This patch changes the behavior of Split and Time_Of with respect to historic
time zones. The two routines no longer attempt to determine the UTC offset of
the input date as it occurred at that point in time. Instead, Split and Time_Of
use the current UTC offset of the now.

The patch also modifies the language-defined routine UTC_Time_Offset and splits
it into two different routines. The parameterless version returns the UTC
offset of the now while the other version handles historic UTC offsets which
occurred at the input date.

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

2012-01-23  Hristian Kirtchev  kirtc...@adacore.com

* a-calend.ads, a-calend.adb: Define types int and int_Pointer. Update
the parameter profile of procedure localtime_tzoff and its associated
comment.
(Day_Of_Week): Do not treat the input date as historical
with respect to time zones.
(Split): Do not treat the input
date as historical with respect to time zones.  (Time_Of): Do
not treat the input constituents as forming a historical date
with respect to time zones.
(UTC_Time_Offset): Add new formal
parameter Is_Historic. Add local variable Flag. Update the call
to localtime_tzoff.
* a-catizo.ads, a-catizo.adb (UTC_Time_Offset): New routine.
(UTC_Time_Offset (Time)): Update the call to
Time_Zone_Operations.UTC_Time_Offset.
* sysdep.c (__gnat_localtime_tzoff): Update parameter
profile. Split the processing of offsets on Windows into two - one
part of historic time stamps and the other for the current time.

Index: sysdep.c
===
--- sysdep.c(revision 183406)
+++ sysdep.c(working copy)
@@ -6,7 +6,7 @@
  *  *
  *  C Implementation File   *
  *  *
- * Copyright (C) 1992-2011, Free Software Foundation, Inc.  *
+ * Copyright (C) 1992-2012, 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- *
@@ -644,72 +644,95 @@
 /* Reentrant localtime for Windows. */
 
 extern void
-__gnat_localtime_tzoff (const time_t *, long *);
+__gnat_localtime_tzoff (const time_t *, const int *, long *);
 
 static const unsigned long long w32_epoch_offset = 11644473600ULL;
 void
-__gnat_localtime_tzoff (const time_t *timer, long *off)
+__gnat_localtime_tzoff (const time_t *timer, const int *is_historic, long *off)
 {
-  union
-  {
-FILETIME ft_time;
-unsigned long long ull_time;
-  } utc_time, local_time;
-
-  SYSTEMTIME utc_sys_time, local_sys_time;
   TIME_ZONE_INFORMATION tzi;
 
-  BOOL  status = 1;
+  BOOL  rtx_active;
   DWORD tzi_status;
 
+#ifdef RTX
+  rtx_active = 1;
+#else
+  rtx_active = 0;
+#endif
+
   (*Lock_Task) ();
 
-#ifdef RTX
-
   tzi_status = GetTimeZoneInformation (tzi);
-  *off = tzi.Bias;
-  if (tzi_status == TIME_ZONE_ID_STANDARD)
- /* The system is operating in the range covered by the StandardDate
-member. */
- *off = *off + tzi.StandardBias;
-  else if (tzi_status == TIME_ZONE_ID_DAYLIGHT)
- /* The system is operating in the range covered by the DaylightDate
-member. */
- *off = *off + tzi.DaylightBias;
-  *off = *off * -60;
 
-#else
+  /* Processing for RTX targets or cases where we simply want to extract the
+ offset of the current time zone, regardless of the date. */
 
-  /* First convert unix time_t structure to windows FILETIME format.  */
-  utc_time.ull_time = ((unsigned long long) *timer + w32_epoch_offset)
-  * 1000ULL;
+  if (rtx_active || !is_historic) {
+*off = tzi.Bias;
 
-  tzi_status = GetTimeZoneInformation (tzi);
+/* The system is operating in the range covered by the StandardDate
+   member. */
+if (tzi_status == TIME_ZONE_ID_STANDARD) {
+   *off = *off + tzi.StandardBias;
+}
 
-  /* If GetTimeZoneInformation does not return a value between 0 and 2 then
- it means that we were not able to retrieve timezone informations.
- Note that we cannot use here FileTimeToLocalFileTime as Windows will use
- in always in this case the current timezone setting. As suggested on
- MSDN we use the following three system calls to get the right information.
- Note also that starting with Windows Vista new functions are provided to
- get timezone settings that depend on the year. We cannot use them as we
- still support Windows XP and Windows 2003.  */
-  status = (tzi_status = 0  tzi_status = 2)
-  FileTimeToSystemTime (utc_time.ft_time, utc_sys_time)
-  

[Ada] Ada 2012 aspect Synchronization

2012-01-23 Thread Arnaud Charlet
This patch adds some minor missing support for aspect Synchronization which is
later transformed into pragma Implemented by the expander.


-- Source --


--  checks.ads

package Checks is
   type Synch_Iface is synchronized interface;

   procedure With_Entry
 (Obj : in out Synch_Iface;
  Val : Integer) is abstract
   with Synchronization = By_Entry;
   procedure With_Procedure
 (Obj : in out Synch_Iface;
  Val : Integer) is abstract
   with Synchronization = By_Protected_Procedure;
   procedure With_Optional
 (Obj : in out Synch_Iface;
  Val : Integer) is abstract
   with Synchronization = Optional;

   protected type Prot_1 is new Synch_Iface with
  entry With_Entry (Val : Integer);
  entry With_Procedure (Val : Integer);  --  Illegal
  entry With_Optional (Val : Integer);
   end Prot_1;

   protected type Prot_2 is new Synch_Iface with
  procedure With_Entry (Val : Integer);  --  Illegal
  procedure With_Procedure (Val : Integer);
  procedure With_Optional (Val : Integer);
   end Prot_2;

   task type Task_1 is new Synch_Iface with
  entry With_Entry (Val : Integer);
  entry With_Procedure (Val : Integer);  --  Illegal
  entry With_Optional (Val : Integer);
   end Task_1;

   task type Task_2 is new Synch_Iface with
  entry Dummy;
   end Task_2;
   procedure With_Entry (Obj : in out Task_2; Val : Integer);  --  Illegal
   procedure With_Procedure (Obj : in out Task_2; Val : Integer);  --  Illegal
   procedure With_Optional (Obj : in out Task_2; Val : Integer);
end Checks;

--  checks.adb

package body Checks is
   protected body Prot_1 is
  entry With_Entry (Val : Integer) when True is
  begin
 null;
  end With_Entry;
  entry With_Procedure (Val : Integer) when True is
  begin
 null;
  end With_Procedure;
  entry With_Optional (Val : Integer) when True is
  begin
 null;
  end With_Optional;
   end Prot_1;

   protected body Prot_2 is
  procedure With_Entry (Val : Integer) is
  begin
 null;
  end With_Entry;
  procedure With_Procedure (Val : Integer) is
  begin
 null;
  end With_Procedure;
  procedure With_Optional (Val : Integer) is
  begin
 null;
  end With_Optional;
   end Prot_2;

   task body Task_1 is
   begin
  select
 accept With_Entry (Val : Integer) do
null;
 end With_Entry;
  or
 accept With_Procedure (Val : Integer) do
null;
 end With_Procedure;
  or
 accept With_Optional (Val : Integer) do
null;
 end With_Optional;
  or
 terminate;
  end select;
   end Task_1;

   task body Task_2 is
   begin
  accept Dummy;
   end Task_2;

   procedure With_Entry (Obj : in out Task_2; Val : Integer) is
   begin
  null;
   end With_Entry;
   procedure With_Procedure (Obj : in out Task_2; Val : Integer) is
   begin
  null;
   end With_Procedure;
   procedure With_Optional (Obj : in out Task_2; Val : Integer) is
   begin
  null;
   end With_Optional;
end Checks;

-
-- Compilation and expected output --
-

$ gnatmake -q -gnat12 checks.adb
$ checks.ads:19:13: type Prot_1 must implement abstract subprogram 
With_Procedure with a procedure
$ checks.ads:24:17: type Prot_2 must implement abstract subprogram 
With_Entry with an entry
$ checks.ads:31:13: interface subprogram With_Procedure cannot be implemented 
by a primitive procedure of task type Task_1
$ checks.ads:38:14: type Task_2 must implement abstract subprogram 
With_Entry with an entry
$ checks.ads:39:14: interface subprogram With_Procedure cannot be implemented 
by a primitive procedure of task type Task_2
$ gnatmake: checks.adb compilation error

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

2012-01-23  Hristian Kirtchev  kirtc...@adacore.com

* exp_ch9.adb: Update the comments involving pragma Implemented.
* sem_ch3.adb (Check_Pragma_Implemented (Entity_Id)): Add local
constant Subp_Alias and local variable Impl_Subp. Properly
handle aliases of synchronized wrappers. Code cleanup.
(Check_Pragma_Implemented (Entity_Id; Entity_Id)): Add
Name_Optional as part of the condition.
* sem_prag.adb (Analyze_Pragma): Add Optional as one of the
valid choices of implementation kind.
(Check_Arg_Is_One_Of): New routine.
* snames.ads-tmlp: Add Name_Optional.

Index: exp_ch9.adb
===
--- exp_ch9.adb (revision 183412)
+++ exp_ch9.adb (working copy)
@@ -8878,7 +8878,8 @@
--Target.Primitive (Param1, ..., ParamN);
 
--  Ada 2012 (AI05-0030): Dispatching requeue to an interface primitive
-   --  marked by pragma Implemented (XXX, By_Any) or not marked at all.
+   --  marked by pragma Implemented (XXX, By_Any | 

[PATCH] Fix up -free (PR rtl-optimization/51933)

2012-01-23 Thread Jakub Jelinek
Hi!

The following testcase as well as the PR51924 testcase show that it is a
really bad idea to rely on the UD/DU DF links in the ree pass if we keep
removing them while the pass goes on, and just assume that the insns
feeding the now removed UD links have been properly adjusted and are
suitable for the change.

In particular, this testcase (and even smaller:
unsigned long
baz (unsigned short *s, int i)
{
  unsigned short x = s[i];
  if (x  0x211)
return x;
  asm volatile ();
  return (unsigned char) x;
}
) is miscompiled because we have a HImode memory load that feeds
a HImode comparison, HI-DImode zero extension and a QI-DImode zero
extension.  Both zero extensions are processed as candidates for removal,
the HI-DImode zero extension verifies the HImode memory load has the
right mode matching the ZERO_EXTEND operand's mode, and replaces it
with a HI-DImode zero extending load and schedules the HI-DImode
zero extension non-load insn for removal.  As the load has been modified,
its links have been invalidated (during apply_changes_group df_rescan_insn).
When the QI-DImode zero extension is considered, we see that it has
no UD links and think that must mean all the definitions have been suitably
adjusted.  They have been adjusted, but not suitably (i.e. just HI-DI
instead of QI-DI) and schedule the QI-DImode zero extension for removal.

This patch fixes this by using DF_DEFER_INSN_RESCAN, so we keep the UD/DU
links for the whole duration of the pass, this pass doesn't add new
instructions, only changes them (and schedules insns for removal, but that
is done as the last step for all to be deleted insns at once).
Thus we don't need to assume missing links mean something, we can still walk
them all and verify.  There is an array recording what insns have been
changed and how (indexed by INSN_UID), so that we don't have to guess
what changes we've done in the past (we simplify_rtx the zero/sign
extensions, adjust const_ints in SET_SRC, etc.).  I'm reverting Eric's
recent changes (keeping all the cleanups), because it is no longer
necessary.  This patch fixes this testcase, Eric's PR51924
as well as x86_64 -m64 jcf-parse.c miscompilation (that has been also fixed
by Eric's patch already; found this by doing extra verification bootstraps
with earlier versions of the patch).

In addition to that change the patch decreases the amount of malloc/free
calls (with each candidate insn being checked we'd malloc 3 to 4 vectors
and freed them shortly afterwards, now we keep the vectors around for the
whole pass, and just VEC_truncate them to 0 each time, which is much
cheaper).

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

For 4.8, the pass could try harder, e.g. on:
int
foo (unsigned char *x, unsigned int y)
{
  unsigned short a = x[y];
  a = (a  8) | x[y + 1];
  return a;
}
we don't currently remove the useless movzwl %ax, %eax at the end of
the function, because it is fed by a SImode IOR and thus the ext_src_mode
check fails (well, we don't have a zero extending HImode - DImode ior
insn anyway).  But we could in that case process it similarly to conditional
moves (at least for IOR, perhaps others) - by processing both the operands of
the IOR instead, there we'd find out that one operand is QI-SImode zero
extended already (i.e. fine and adjustable to QI-DImode zero extension
at no cost) and the other is QI-SImode zero extended shifted up by 8
(again, could be adjusted on both the load and shift at no cost).

2012-01-23  Jakub Jelinek  ja...@redhat.com

PR rtl-optimization/51933
* ree.c (transform_ifelse): Return true right away if dstreg is
already wider or equal to cand-mode.
(enum ext_modified_kind, struct ext_modified, ext_state): New types.
(make_defs_and_copies_lists): Remove defs_list and copies_list
arguments, add state argument, just truncate state-work_list
instead of always allocating and freeing the vector.  Assert that
get_defs succeeds instead of returning 2.  Changed return type to
bool.
(merge_def_and_ext): Add state argument.  If SET_DEST doesn't
have ext_src_mode, see if it has been modified already with the
right kind of extension and has been extended before from the
ext_src_mode.  If SET_DEST is already wider or equal to cand-mode,
just return true.  Remember the original mode in state-modified
array.
(combine_reaching_defs): Add state argument.  Don't allocate and
free here def_list, copied_list and vec vectors, instead just
VEC_truncate the vectors in *state.  Don't handle outcome == 2
here.
(find_and_remove_re): Set DF_DEFER_INSN_RESCAN df flag.
Add state variable, clear vectors in it, initialize state.modified
if needed.  Free all the vectors at the end and state.modified too.
Don't skip a candidate if the extension expression has been modified.

* 

Re: [RFC combine] PR48308 - Fix issue with missing(?) LOG_LINKS

2012-01-23 Thread Eric Botcazou
 Do you mean something like this instead ? I'm testing this - Ok if no
 regressions ?

OK with an appropriate ChangeLog.

-- 
Eric Botcazou


Re: [Patch testsuite] Fix vec_interleave and vec_extract_even_odd to fall back to vec_perm

2012-01-23 Thread Jakub Jelinek
On Mon, Jan 23, 2012 at 08:30:46AM +, Ramana Radhakrishnan wrote:
 Now that we have vec_perm support, vec_interleave and
 vec_extract_even_odd should fall out from that rather than having to
 handle an additional target in each of these. This fixes
 gcc.dg/vect/slp-11a.c for ARM Neon testing with no other regressions
 in gcc.dg/vect
 
 Ok ?

That will disable ia64 testing of tests that need vect_extract_even_odd
and vect_interleave.  Not sure if ia64 has good enough vect_perm
support that it can be enabled there though.  Some targets might be
supporting only a couple of specific permutations like these two
and not general permutations.
So safer would be to add [is-effective-target arm_neon_ok] to these
two checks for now.

 2012-01-23  Ramana Radhakrishnan  ramana.radhakrish...@linaro.org
 
   * lib/target-supports.exp (check_effective_target_vect_interleave): Use
   check_effective_target_vect_perm.
   (check_effective_target_vect_extract_even_odd): Likewise.

Jakub


Re: [PATCH] Fix up -free (PR rtl-optimization/51933)

2012-01-23 Thread Eric Botcazou
 This patch fixes this by using DF_DEFER_INSN_RESCAN, so we keep the UD/DU
 links for the whole duration of the pass, this pass doesn't add new
 instructions, only changes them (and schedules insns for removal, but that
 is done as the last step for all to be deleted insns at once).
 Thus we don't need to assume missing links mean something, we can still
 walk them all and verify

Yes, we should have done that earlier, thanks for tackling it.

 2012-01-23  Jakub Jelinek  ja...@redhat.com

   PR rtl-optimization/51933
   * ree.c (transform_ifelse): Return true right away if dstreg is
   already wider or equal to cand-mode.
   (enum ext_modified_kind, struct ext_modified, ext_state): New types.
   (make_defs_and_copies_lists): Remove defs_list and copies_list
   arguments, add state argument, just truncate state-work_list
   instead of always allocating and freeing the vector.  Assert that
   get_defs succeeds instead of returning 2.  Changed return type to
   bool.
   (merge_def_and_ext): Add state argument.  If SET_DEST doesn't
   have ext_src_mode, see if it has been modified already with the
   right kind of extension and has been extended before from the
   ext_src_mode.  If SET_DEST is already wider or equal to cand-mode,
   just return true.  Remember the original mode in state-modified
   array.
   (combine_reaching_defs): Add state argument.  Don't allocate and
   free here def_list, copied_list and vec vectors, instead just
   VEC_truncate the vectors in *state.  Don't handle outcome == 2
   here.
   (find_and_remove_re): Set DF_DEFER_INSN_RESCAN df flag.
   Add state variable, clear vectors in it, initialize state.modified
   if needed.  Free all the vectors at the end and state.modified too.
   Don't skip a candidate if the extension expression has been modified.

   * gcc.c-torture/execute/pr51933.c: New test.

OK, modulo:

 +   are successful.  The function returns 0 upon failure, 1 upon success.  */

The function returns a boolean now.

-- 
Eric Botcazou


Re: FIX PR51926, libstdc++ iterator store bigendian bitfield related

2012-01-23 Thread Alan Modra
On Sat, Jan 21, 2012 at 11:07:10AM +1030, Alan Modra wrote:
   PR middle-end/51926
   * expmed.c (store_bit_field_1): Properly handle last word of
   BLKmode value when bigendian.

Blah, I was working on an old tree.  The bug is already fixed.

-- 
Alan Modra
Australia Development Lab, IBM


[Ada] SCOs for disabled pragmas

2012-01-23 Thread Arnaud Charlet
SCOs for disabled pragma statements (Assert or Debug) should be output with
a marker indicating that they are disabled, rather than suppresed, because
references to them can appear in dominance markers for subsequent statement
sequences.

In the following compilation, the dominance marker must designate the sloc
of an existing SCO statement entry with a code character 'p' (disabled
pragma):

$ gcc -c -gnateS dom_debug.adb
$ grep ^C dom_debug.ali
C 9 dom_debug.adb
CS o3:4-3:9 pDEBUG:4:4-4:40
CS 5:25-5:25
CS S4:4 o6:4-6:9
CS 8:4-8:4

with Ada.Text_IO;
procedure Dom_Debug is
   X0 : Integer;
   pragma Debug (Ada.Text_IO.Put_Line (hello));
   procedure P is begin null; end P;
   X1 : Integer;
begin
   null;
end Dom_Debug;

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

2012-01-23  Thomas Quinot  qui...@adacore.com

* scos.ads, put_scos.adb, get_scos.adb (Get_SCOs, Put_SCOs): Do not
omit statement SCOs for disabled pragmas.

Index: scos.ads
===
--- scos.ads(revision 183406)
+++ scos.ads(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- S p e c  --
 --  --
---  Copyright (C) 2009-2011, Free Software Foundation, Inc. --
+--  Copyright (C) 2009-2012, 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- --
@@ -157,6 +157,7 @@
--  FFOR loop (from FOR through end of iteration scheme)
--  IIF statement (from IF through end of condition)
--  P[name:] PRAGMA with the indicated name
+   --  p[name:] disabled PRAGMA with the indicated name
--  Rextended RETURN statement
--  WWHILE loop statement (from WHILE through end of condition)
 
Index: put_scos.adb
===
--- put_scos.adb(revision 183406)
+++ put_scos.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 2009-2011, Free Software Foundation, Inc. --
+--  Copyright (C) 2009-2012, 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- --
@@ -139,12 +139,6 @@
  Ctr := 0;
  Continuation := False;
  loop
-if SCO_Pragma_Disabled
- (SCO_Table.Table (Start).Pragma_Sloc)
-then
-   goto Next_Statement;
-end if;
-
 if Ctr = 0 then
Write_SCO_Initiate (U);
if not Continuation then
@@ -169,7 +163,7 @@
   Write_Info_Char (Sent.C2);
 
   if Sent.C1 = 'S'
-and then Sent.C2 = 'P'
+and then (Sent.C2 = 'P' or else Sent.C2 = 'p')
 and then Sent.Pragma_Name /= Unknown_Pragma
   then
  --  Strip leading PRAGMA_
@@ -205,7 +199,6 @@
Ctr := 0;
 end if;
 
- Next_Statement
 exit when SCO_Table.Table (Start).Last;
 Start := Start + 1;
  end loop;
Index: get_scos.adb
===
--- get_scos.adb(revision 183406)
+++ get_scos.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 2009-2011, Free Software Foundation, Inc. --
+--  Copyright (C) 2009-2012, 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 

[Ada] issue in ASIS with aspects

2012-01-23 Thread Arnaud Charlet
Generation of analysis information for precondition and postcondition
boolean expressions appearing in the spec of a generic subprogram declaration
in ASIS mode.

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

2012-01-23  Vincent Pucci  pu...@adacore.com

* sem_ch12.adb (Analyze_Generic_Subprogram_Declaration): Call
to Make_Aspect_For_PPC_In_Gen_Sub_Decl added in ASIS mode.
* sem_prag.adb, sem_prag.ads (Make_Aspect_For_PPC_In_Gen_Sub_Decl): New
routine. In ASIS mode, convert any PPC pragmas into aspects in generic
subprogram declaration in order to enable the analysis of PPC boolean
expressions.

Index: sem_prag.adb
===
--- sem_prag.adb(revision 183420)
+++ sem_prag.adb(working copy)
@@ -7991,8 +7991,9 @@
 --  Normally the analysis that follows will freeze the subprogram
 --  being called. However, if the call is to a null procedure,
 --  we want to freeze it before creating the block, because the
---  analysis that follows may be done with expansion disabled, and
---  and the body will not be generated, leading to spurious errors.
+--  analysis that follows may be done with expansion disabled, in
+--  which case the body will not be generated, leading to spurious
+--  errors.
 
 if Nkind (Call) = N_Procedure_Call_Statement
   and then Is_Entity_Name (Name (Call))
@@ -15242,6 +15243,82 @@
   end if;
end Is_Pragma_String_Literal;
 
+   -
+   -- Make_Aspect_For_PPC_In_Gen_Sub_Decl --
+   -
+
+   --  Convert any PPC and pragmas that appear within a generic subprogram
+   --  declaration into aspect.
+
+   procedure Make_Aspect_For_PPC_In_Gen_Sub_Decl (Decl : Node_Id) is
+  Aspects  : constant List_Id := New_List;
+  Loc  : constant Source_Ptr := Sloc (Decl);
+  Or_Decl  : constant Node_Id := Original_Node (Decl);
+  Aspect   : Node_Id;
+  Original_Aspects : List_Id;
+  --  To capture global references, a copy of the created aspects must be
+  --  inserted in the original tree.
+
+  Prag : Node_Id;
+  Prag_Arg_Ass : Node_Id;
+  Prag_Id  : Pragma_Id;
+
+   begin
+  Prag := Next (Decl);
+
+  --  Check for any PPC pragmas that appear within Decl
+
+  while Nkind (Prag) = N_Pragma loop
+ Prag_Id := Get_Pragma_Id (Chars (Pragma_Identifier (Prag)));
+
+ case Prag_Id is
+when Pragma_Postcondition | Pragma_Precondition =
+   Prag_Arg_Ass := First (Pragma_Argument_Associations (Prag));
+
+   --  Make an aspect from any PPC pragma
+
+   Aspect :=
+ Make_Aspect_Specification (Loc,
+   Identifier =
+ Make_Identifier (Loc, Chars (Pragma_Identifier (Prag))),
+   Expression = Expression (Prag_Arg_Ass));
+
+   Append (Aspect, Aspects);
+
+   --  Set the pragma node analyzed to avoid any further analysis
+
+   Set_Analyzed (Prag, True);
+
+when others = null;
+ end case;
+
+ Next (Prag);
+  end loop;
+
+  --  Set all new aspects into the generic declaration node
+
+  if Is_Non_Empty_List (Aspects) then
+ --  Create the list of aspects which will be inserted in the original
+ --  tree.
+
+ Original_Aspects := Copy_Separate_List (Aspects);
+
+ --  Check if Decl already has aspects
+ --  Attach the new lists of aspects to both the generic copy and the
+ --  original tree.
+
+ if Has_Aspects (Decl) then
+Append_List (Aspects, Aspect_Specifications (Decl));
+Append_List (Original_Aspects, Aspect_Specifications (Or_Decl));
+ else
+Set_Parent (Aspects, Decl);
+Set_Aspect_Specifications (Decl, Aspects);
+Set_Parent (Original_Aspects, Or_Decl);
+Set_Aspect_Specifications (Or_Decl, Original_Aspects);
+ end if;
+  end if;
+   end Make_Aspect_For_PPC_In_Gen_Sub_Decl;
+

-- Preanalyze_TC_Args --

Index: sem_prag.ads
===
--- sem_prag.ads(revision 183406)
+++ sem_prag.ads(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- S p e c  --
 --  --
---  Copyright (C) 1992-2011, Free Software Foundation, Inc. --
+--  Copyright (C) 1992-2012, Free Software Foundation, Inc. --
 --   

Re: [PING] Re: [PATCH, Ada] Illegal program not detected, self renames, PR15846

2012-01-23 Thread Arnaud Charlet
 Could you please review this patch:
 
 http://gcc.gnu.org/ml/gcc-patches/2012-01/msg00581.html
 
 This patch fixes problem when gnat is not able
 to detect illegal program with self renaming of predefined operation,
 when renaming operation is defined with selected component of the same
 package as renaming declaration.

Since you posted an updated patch, I was waiting a bit to see if you would
post an updated version again before starting the review.

I'll now put this patch on the review queue.

Arno


[PATCH] Fix IPA-SRA creating BLKmode sub-params (PR51895)

2012-01-23 Thread Richard Guenther

This fixes the IPA-SRA sub-optimality discovered in PR51895.  We
should avoid decomposing anything into BLKmode components if the
original param wasn't already BLKmode.

Bootstrap and regtest pending on x86_64-unknown-linux-gnu.

Richard.

2012-01-23  Richard Guenther  rguent...@suse.de

PR tree-optimization/51895
* tree-sra.c (decide_one_param_reduction): Avoid sub-optimal
parameter decomposition into BLKmode components.

Index: gcc/tree-sra.c
===
--- gcc/tree-sra.c  (revision 183421)
+++ gcc/tree-sra.c  (working copy)
@@ -3914,6 +3914,13 @@ decide_one_param_reduction (struct acces
   if (by_ref  repr-non_addressable)
return 0;
 
+  /* Do not decompose a non-BLKmode param in a way that would
+ create BLKmode params.  Especially for by-reference passing
+(thus, pointer-type param) this is hardly worthwhile.  */
+  if (DECL_MODE (parm) != BLKmode
+  TYPE_MODE (repr-type) == BLKmode)
+   return 0;
+
   if (!by_ref || (!repr-grp_maybe_modified
   !repr-grp_not_necessarilly_dereferenced))
total_size += repr-size;


[Ada] Use a proper assertion in Vet instead of a comment

2012-01-23 Thread Arnaud Charlet
Vet checks container invariants to determine whether a cursor is dangling. Some
program state had been described using comments at various points. The comments
have been replaced by instances of pragma Assert.

Some comments were also added to describe the purpose of Vet and how the
mechanism for detection of dangling references works.

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

2012-01-23  Matthew Heaney  hea...@adacore.com

* a-cdlili.adb, a-cidlli.adb, a-cbdlli.adb (Vet): Replaced
comment with pragma Assert.

Index: a-cdlili.adb
===
--- a-cdlili.adb(revision 183406)
+++ a-cdlili.adb(working copy)
@@ -6,7 +6,7 @@
 --  --
 -- B o d y  --
 --  --
---  Copyright (C) 2004-2011, Free Software Foundation, Inc. --
+--  Copyright (C) 2004-2012, 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- --
@@ -65,6 +65,11 @@
   New_Node  : Node_Access);
 
function Vet (Position : Cursor) return Boolean;
+   --  Checks invariants of the cursor and its designated container, as a
+   --  simple way of detecting dangling references (see operation Free for a
+   --  description of the detection mechanism), returning True if all checks
+   --  pass. Invocations of Vet are used here as the argument of pragma Assert,
+   --  so the checks are performed only when assertions are enabled.
 
-
-- = --
@@ -528,8 +533,23 @@
   procedure Deallocate is
  new Ada.Unchecked_Deallocation (Node_Type, Node_Access);
begin
+  --  While a node is in use, as an active link in a list, its Previous and
+  --  Next components must be null, or designate a different node; this is
+  --  a node invariant. Before actually deallocating the node, we set both
+  --  access value components of the node to point to the node itself, thus
+  --  falsifying the node invariant. Subprogram Vet inspects the value of
+  --  the node components when interrogating the node, in order to detect
+  --  whether the cursor's node access value is dangling.
+
+  --  Note that we have no guarantee that the storage for the node isn't
+  --  modified when it is deallocated, but there are other tests that Vet
+  --  does if node invariants appear to be satisifed. However, in practice
+  --  this simple test works well enough, detecting dangling references
+  --  immediately, without needing further interrogation.
+
   X.Prev := X;
   X.Next := X;
+
   Deallocate (X);
end Free;
 
@@ -1966,6 +1986,13 @@
  return False;
   end if;
 
+  --  An invariant of a node is that its Previous and Next components can
+  --  be null, or designate a different node. Operation Free sets the
+  --  access value components of the node to designate the node itself
+  --  before actually deallocating the node, thus deliberately violating
+  --  the node invariant. This gives us a simple way to detect a dangling
+  --  reference to a node.
+
   if Position.Node.Next = Position.Node then
  return False;
   end if;
@@ -1974,6 +2001,12 @@
  return False;
   end if;
 
+  --  In practice the tests above will detect most instances of a dangling
+  --  reference. If we get here, it means that the invariants of the
+  --  designated node are satisfied (they at least appear to be satisfied),
+  --  so we perform some more tests, to determine whether invariants of the
+  --  designated list are satisfied too.
+
   declare
  L : List renames Position.Container.all;
   begin
@@ -2003,8 +2036,8 @@
 return False;
  end if;
 
- --  If we get here, we know that this disjunction is true:
- --  Position.Node.Prev /= null or else Position.Node = L.First
+ pragma Assert (Position.Node.Prev /= null
+  or else Position.Node = L.First);
 
  if Position.Node.Next = null
and then Position.Node /= L.Last
@@ -2012,8 +2045,8 @@
 return False;
  end if;
 
- --  If we get here, we know that this disjunction is true:
- --  Position.Node.Next /= null or else Position.Node = L.Last
+ pragma Assert (Position.Node.Next /= null
+  or else Position.Node = L.Last);
 
  if L.Length = 1 then
 return L.First = L.Last;
@@ -2059,23 +2092,17 @@
 return False;
  end if;
 
- --  Eliminate 

[PATCH] Fix PR51949

2012-01-23 Thread Richard Guenther

We ICE when splitting part of a function which has the malloc attribute
and that part does not return.  While the issue is more general
(transfering attributes to a part/clone) we can address this probably
common issue with the following simple patch.

Richard.

2012-01-23  Richard Guenther  rguent...@suse.de

PR tree-optimization/51949
* ipa-split.c (execute_split_functions): Do not split malloc
functions.

* gcc.dg/torture/pr51949.c: New testcase.

Index: gcc/ipa-split.c
===
--- gcc/ipa-split.c (revision 183421)
+++ gcc/ipa-split.c (working copy)
@@ -1395,10 +1395,11 @@ execute_split_functions (void)
   int todo = 0;
   struct cgraph_node *node = cgraph_get_node (current_function_decl);
 
-  if (flags_from_decl_or_type (current_function_decl)  ECF_NORETURN)
+  if (flags_from_decl_or_type (current_function_decl)
+   (ECF_NORETURN|ECF_MALLOC))
 {
   if (dump_file)
-   fprintf (dump_file, Not splitting: noreturn function.\n);
+   fprintf (dump_file, Not splitting: noreturn/malloc function.\n);
   return 0;
 }
   if (MAIN_NAME_P (DECL_NAME (current_function_decl)))
Index: gcc/testsuite/gcc.dg/torture/pr51949.c
===
--- gcc/testsuite/gcc.dg/torture/pr51949.c  (revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr51949.c  (revision 0)
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+
+typedef long unsigned int size_t;
+extern __attribute__ ((malloc)) void *mem_alloc(size_t);
+void *mem_alloc(size_t amount)
+{
+  void *q = __builtin_malloc (amount);
+  if (!q) {
+  __builtin_printf(malloc);
+  __builtin_exit(255);
+  }
+}
+void mem_realloc()
+{
+  mem_alloc(1);
+}
+void put_env_var()
+{
+  mem_alloc(1);
+}


Re: Partial fix for LTO bootstrap with Ada

2012-01-23 Thread Richard Guenther
On Sun, Jan 22, 2012 at 3:42 PM, Eric Botcazou ebotca...@adacore.com wrote:
 The LTO bootstrap of the Ada compiler is currently plagued by at least three
 different problems.  The attached patch is for the easy one: it prevents fake
 variables whose type contains a placeholder from being created, which doesn't
 work in LTO mode because you cannot instantiate the PLACEHOLDER_EXPRs.  IIUC
 this is only a slight pessimization.

 Bootstrapped/regtested on x86_64-suse-linux, OK for mainline?

Ok.

I suppose that's different from TYPE_NEEDS_CONSTRUCTING?  So
it fails doing the build_fake_var_decl?  Or does it fail elsewhere?

Thanks,
Richard.


 2012-01-22  Eric Botcazou  ebotca...@adacore.com

        * tree-ssa-structalias.c (intra_create_variable_infos): Do not create
        fake variables for restrict-qualified pointers whose pointed-to type
        contains a placeholder.


 --
 Eric Botcazou


Re: Fix flag_trapping_math in java frontend

2012-01-23 Thread Richard Guenther
On Sun, Jan 22, 2012 at 3:52 PM, Andreas Schwab sch...@linux-m68k.org wrote:
 The java frontend wants that floating point operations are assumed to
 never trap, thus clears flag_trapping_math in java_init_options_struct.
 But this is no longer effective after revision 165823, because
 set_fast_math_flags is now always called during option processing,
 overriding anything what the frontend did to flag_trapping_math.  This
 is an amendment to revision 169930 which introduced
 frontend_set_flag_trapping_math, but didn't set it in
 java_init_options_struct.

 While this was found during examination of PR49847, this doesn't fix it,
 but only makes the bug dormant again in 4.6.

 Tested on powerpc-linux, ok for trunk and 4.6 branch?

Ok.

Thanks,
Richard.

 Andreas.

 2012-01-22  Andreas Schwab  sch...@linux-m68k.org

        * lang.c (java_init_options_struct): Set
        frontend_set_flag_trapping_math.

 diff --git a/gcc/java/lang.c b/gcc/java/lang.c
 index ccab48c..da7dd05 100644
 --- a/gcc/java/lang.c
 +++ b/gcc/java/lang.c
 @@ -1,6 +1,6 @@
  /* Java(TM) language-specific utility routines.
    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 -   2005, 2006, 2007, 2008, 2010 Free Software Foundation, Inc.
 +   2005, 2006, 2007, 2008, 2010, 2012 Free Software Foundation, Inc.

  This file is part of GCC.

 @@ -550,6 +550,7 @@ java_init_options_struct (struct gcc_options *opts)

   /* In Java floating point operations never trap.  */
   opts-x_flag_trapping_math = 0;
 +  opts-frontend_set_flag_trapping_math = true;

   /* In Java arithmetic overflow always wraps around.  */
   opts-x_flag_wrapv = 1;
 --
 1.7.8.4

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


Re: [ C frontend ] add support for builtins that take signed and unsigned md types

2012-01-23 Thread Richard Guenther
On Sun, Jan 22, 2012 at 8:04 PM, Mike Stump mikest...@comcast.net wrote:
 On Jan 22, 2012, at 4:53 AM, Richard Guenther wrote:
 Why add a new loop?  It seems to be bogus to not check signedness in
 the existing loop (mind that for fixed-point types you need to check 
 saturating/nonsaturating flag.

 We can remove the other loop, if people don't want any of the old semantics.  
 I'll just note, it can break things, though, for ports that are so broken, 
 they can introduce additional signatures to restore how they want it to work.

Well, it's clearly a bug to return sth that does not match the
requested signedness.

So, yes, please have only one loop.

Thanks,
Richard.

 You miss a testcase where this fix matters.

 I have a testcase, but it is dependent upon a port that isn't in the tree.  
 I'll plead ignorance of another port that is fixed by the patch.


Re: [patch PR 51900]: Fix PE's delegitimize_address functions

2012-01-23 Thread Richard Guenther
On Sun, Jan 22, 2012 at 8:05 PM, Kai Tietz ktiet...@googlemail.com wrote:
 Hello,

 this patch fixes reported issue in PR about common-symbols and fix
 behavior about -fcommon/-fno-common.  Additionally it adds proper
 support for weakref, local-variant of weaks, and tries to handle
 resolution-file information for PE-COFF.

 I did regression tests of all standard-languages for
 x86_64-w64-mingw32 and i686-w64-mingw32.  Dave would you mind to test
 it for cygwin, too?  I assume it will fit for cygwin, but just to make
 sure.  Also I did a regression test for x86_64-unknown-linux-gnu.

 Patch ok for apply?

As said in the PR your binds_local_p target hook should end with calling
default_binds_local_p[_1].  No need to duplicate all code in your hook
(it will quickly get out-of-date).

Richard.

 Regards,
 Kai

 PS: Sorry missed first time subject-line
 ChangeLog

 2012-01-22  Kai Tietz  kti...@redhat.com

        PR target/51900
        * dwarf2out.c (const_ok_for_output_1): Try to delegitimize
        address before checking for UNSPEC.
        * config/i386/predicates.md (symbolic_operand): Allow
        UNSPEC_PCREL as PIC expression for lea.
        * config/i386/winnt.c (i386_pe_binds_local_p): Reworked.
        * config/i386/i386.c (ix86_delegitimize_address): Handle
        UNSPEC_PCREL for none-MEM, too.

 Index: dwarf2out.c
 ===
 --- dwarf2out.c (revision 183389)
 +++ dwarf2out.c (working copy)
 @@ -10653,8 +10653,18 @@
  {
   rtx rtl = *rtlp;

 +  /* Try to delegitimize address by adding a CONST in front.
 +     This is required due pattern checked in delegitimize_address.  */
   if (GET_CODE (rtl) == UNSPEC)
     {
 +      rtx newrtl = gen_rtx_CONST (Pmode, rtl);
 +      newrtl = targetm.delegitimize_address (newrtl);
 +      if (GET_CODE (newrtl) == SYMBOL_REF)
 +        *rtlp = rtl = newrtl;
 +    }
 +
 +  if (GET_CODE (rtl) == UNSPEC)
 +    {
       /* If delegitimize_address couldn't do anything with the UNSPEC, assume
         we can't express it in the debug info.  */
  #ifdef ENABLE_CHECKING
 Index: config/i386/predicates.md
 ===
 --- config/i386/predicates.md   (revision 183389)
 +++ config/i386/predicates.md   (working copy)
 @@ -410,6 +410,7 @@
          || (GET_CODE (op) == UNSPEC
               (XINT (op, 1) == UNSPEC_GOT
                  || XINT (op, 1) == UNSPEC_GOTOFF
 +                 || XINT (op, 1) == UNSPEC_PCREL
                  || XINT (op, 1) == UNSPEC_GOTPCREL)))
        return true;
       if (GET_CODE (op) != PLUS
 Index: config/i386/winnt.c
 ===
 --- config/i386/winnt.c (revision 183389)
 +++ config/i386/winnt.c (working copy)
 @@ -350,20 +350,101 @@
   SYMBOL_REF_FLAGS (symbol) = flags;
  }

 +
  bool
  i386_pe_binds_local_p (const_tree exp)
  {
 -  /* PE does not do dynamic binding.  Indeed, the only kind of
 -     non-local reference comes from a dllimport'd symbol.  */
 -  if ((TREE_CODE (exp) == VAR_DECL || TREE_CODE (exp) == FUNCTION_DECL)
 -       DECL_DLLIMPORT_P (exp))
 -    return false;
 +  bool is_dllimported = false;
 +  bool resolved_to_local_def = false;
 +  bool resolved_locally = false;

 -  /* Or a weak one, now that they are supported.  */
 -  if ((TREE_CODE (exp) == VAR_DECL || TREE_CODE (exp) == FUNCTION_DECL)
 -       DECL_WEAK (exp))
 +  if (TREE_CODE (exp) == VAR_DECL || TREE_CODE (exp) == FUNCTION_DECL)
 +    is_dllimported = DECL_DLLIMPORT_P (exp);
 +
 +  if (TREE_CODE (exp) == VAR_DECL  TREE_PUBLIC (exp)
 +       (TREE_STATIC (exp) || DECL_EXTERNAL (exp)))
 +    {
 +      struct varpool_node *vnode = varpool_get_node (exp);
 +      if (vnode)
 +        {
 +         if (vnode-resolution == LDPR_PREVAILING_DEF
 +             || vnode-resolution == LDPR_PREVAILING_DEF_IRONLY
 +             || vnode-resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
 +             || vnode-resolution == LDPR_PREEMPTED_REG
 +             || vnode-resolution == LDPR_PREEMPTED_IR
 +             || vnode-resolution == LDPR_RESOLVED_IR
 +             || vnode-resolution == LDPR_RESOLVED_EXEC)
 +           resolved_locally = !is_dllimported;
 +         if (vnode-resolution == LDPR_PREVAILING_DEF
 +             || vnode-resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
 +             || vnode-resolution == LDPR_PREVAILING_DEF_IRONLY)
 +           resolved_to_local_def = true;
 +       }
 +    }
 +  else if (TREE_CODE (exp) == FUNCTION_DECL  TREE_PUBLIC (exp))
 +    {
 +      struct cgraph_node *node = cgraph_get_node (exp);
 +      if (node)
 +        {
 +         if (node-resolution == LDPR_PREVAILING_DEF
 +             || node-resolution == LDPR_PREVAILING_DEF_IRONLY
 +             || node-resolution == LDPR_PREVAILING_DEF_IRONLY_EXP
 +             || node-resolution == LDPR_PREEMPTED_REG
 +             || node-resolution == LDPR_PREEMPTED_IR
 +             || node-resolution == 

Re: Add -lssp_nonshared to LINK_SSP_SPEC

2012-01-23 Thread Richard Guenther
On Mon, Jan 23, 2012 at 12:23 AM, Gerald Pfeifer ger...@pfeifer.com wrote:
 On Sat, 21 Jan 2012, Tijl Coosemans wrote:
 I've been using this patch now. It's similar to the above url, but
 conditional on TARGET_LIBC_PROVIDES_SSP to support older FreeBSD
 versions.

 Gerald volunteered to commit. Gerald, just trunk for now or older
 branches too?

 If Richi agries, I'd apply this on trunk and the GCC 4.6 branch,
 since that is the stable release our users employ.

Sure, go ahead.

Richard.

 Gerald

 PS: We also need to update the copyright date at the top, and I'll
 take care of that when committing.

 2011-01-20  Tijl Coosemans  t...@coosemans.org

       * gcc/config/freebsd-spec.h [TARGET_LIBC_PROVIDES_SSP] 
 (LINK_SSP_SPEC): Define.

 --- gcc/config/freebsd-spec.h
 +++ gcc/config/freebsd-spec.h
 @@ -138,6 +138,10 @@ is built with the --enable-threads confi
  #define LINK_EH_SPEC %{!static:--eh-frame-hdr} 
  #endif

 +#ifdef TARGET_LIBC_PROVIDES_SSP
 +#define LINK_SSP_SPEC 
 %{fstack-protector|fstack-protector-all:-lssp_nonshared}
 +#endif
 +
  /* Use --as-needed -lgcc_s for eh support.  */
  #ifdef HAVE_LD_AS_NEEDED
  #define USE_LD_AS_NEEDED 1



Re: [PATCH] Fix PR 29333: Jump threading getting in the way of PHI-OPT

2012-01-23 Thread Richard Guenther
On Mon, Jan 23, 2012 at 6:33 AM, Andrew Pinski
andrew.pin...@caviumnetworks.com wrote:
 Hi,
  The problem here is not really jump threading getting in the way of
 PHI-OPT rather there is no cleanup of the IR after jump thread but
 before phi-opt.
 This patch adds a pass_phi_only_cprop right after the first vrp and
 pass_merge_phi right before the first and last phiopts.

 Since VRP does jump threading just like DOM does, we need a
 pass_phi_only_cprop right after it.  And the merge PHI pass should be
 done so that going into PHI-OPT we have a CFG which there is only one
 PHI for a case like:
 bb0:
 if (a)
  goto L1;
 bb3:
 if (b) goto L2;
 L1:
 x = PHI b(3), c(0)
 L2:
  x= PHIx(L1), d(3)

 PHI-OPT does not handle PHIs like this that well.

 OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

The testcase already works for me on trunk, without your patch.

You are adding three passes - one of it phi_only_cprop which I'd rather
remove ... I suspect VRP simply exposes copy propagation opportunities,
and that's expected.  mergephi before phiopt makes sense, but then
we should move the first mergephi instead of inserting another one.

Richard.

 Thanks,
 Andrew Pinski

 ChangeLog:
 * passes.c (init_optimization_passes): Add pass_phi_only_cprop after
 the first vpr pass.
 Add pass_merge_phi before the first and last phiopt passes.

 testsuite/ChangeLog:
 * gcc.dg/tree-ssa/phi-opt-7.c: New testcase.


Re: [patch PR 51900]: Fix PE's delegitimize_address functions

2012-01-23 Thread Kai Tietz
2012/1/23 Richard Guenther richard.guent...@gmail.com:
 On Sun, Jan 22, 2012 at 8:05 PM, Kai Tietz ktiet...@googlemail.com wrote:
 Hello,

 this patch fixes reported issue in PR about common-symbols and fix
 behavior about -fcommon/-fno-common.  Additionally it adds proper
 support for weakref, local-variant of weaks, and tries to handle
 resolution-file information for PE-COFF.

 I did regression tests of all standard-languages for
 x86_64-w64-mingw32 and i686-w64-mingw32.  Dave would you mind to test
 it for cygwin, too?  I assume it will fit for cygwin, but just to make
 sure.  Also I did a regression test for x86_64-unknown-linux-gnu.

 Patch ok for apply?

 As said in the PR your binds_local_p target hook should end with calling
 default_binds_local_p[_1].  No need to duplicate all code in your hook
 (it will quickly get out-of-date).

 Richard.

Well, issue here is the following block in default_binds_local_p_1:

...
  /* Variables defined outside this object might not be local.  */
  else if (DECL_EXTERNAL (exp)  !resolved_locally)
local_p = false;
...

This condition is only true for PE-coff, if dllimport attribute was specified.

I will try to adjust patch for this, but some redudant checkings are
necessary here for sure.

Kai


Re: [patch PR 51900]: Fix PE's delegitimize_address functions

2012-01-23 Thread Jakub Jelinek
On Sun, Jan 22, 2012 at 09:24:47PM +0100, Kai Tietz wrote:
 2012-01-22  Kai Tietz  kti...@redhat.com
 
   PR target/51900
   * dwarf2out.c (const_ok_for_output_1): Try to delegitimize
   address before checking for UNSPEC.

Why is the dwarf2out.c change needed at all?  dwarf2out.c already calls
targetm.delegitimize_address in various places.

Jakub


Re: [patch PR 51900]: Fix PE's delegitimize_address functions

2012-01-23 Thread Richard Guenther
On Mon, Jan 23, 2012 at 12:19 PM, Kai Tietz ktiet...@googlemail.com wrote:
 2012/1/23 Richard Guenther richard.guent...@gmail.com:
 On Sun, Jan 22, 2012 at 8:05 PM, Kai Tietz ktiet...@googlemail.com wrote:
 Hello,

 this patch fixes reported issue in PR about common-symbols and fix
 behavior about -fcommon/-fno-common.  Additionally it adds proper
 support for weakref, local-variant of weaks, and tries to handle
 resolution-file information for PE-COFF.

 I did regression tests of all standard-languages for
 x86_64-w64-mingw32 and i686-w64-mingw32.  Dave would you mind to test
 it for cygwin, too?  I assume it will fit for cygwin, but just to make
 sure.  Also I did a regression test for x86_64-unknown-linux-gnu.

 Patch ok for apply?

 As said in the PR your binds_local_p target hook should end with calling
 default_binds_local_p[_1].  No need to duplicate all code in your hook
 (it will quickly get out-of-date).

 Richard.

 Well, issue here is the following block in default_binds_local_p_1:

 ...
  /* Variables defined outside this object might not be local.  */
  else if (DECL_EXTERNAL (exp)  !resolved_locally)
    local_p = false;
 ...

 This condition is only true for PE-coff, if dllimport attribute was specified.

That would be a missed-optimization fix, please just fix the wrong-code
regression at this stage.

Richard.

 I will try to adjust patch for this, but some redudant checkings are
 necessary here for sure.

Thta

 Kai


Re: [patch PR 51900]: Fix PE's delegitimize_address functions

2012-01-23 Thread Kai Tietz
2012/1/23 Jakub Jelinek ja...@redhat.com:
 On Sun, Jan 22, 2012 at 09:24:47PM +0100, Kai Tietz wrote:
 2012-01-22  Kai Tietz  kti...@redhat.com

       PR target/51900
       * dwarf2out.c (const_ok_for_output_1): Try to delegitimize
       address before checking for UNSPEC.

 Why is the dwarf2out.c change needed at all?  dwarf2out.c already calls
 targetm.delegitimize_address in various places.

        Jakub

I saw by this patch many UNSPEC notes in dwarf.  As said before we
have here a field of unspecs (in as CONST { list-of-symbols }) for
which delegitimize_address isn't called.
The culprit code is in 'const_ok_for_output' the following block:

  if (GET_CODE (rtl) == CONST)
return for_each_rtx (XEXP (rtl, 0), const_ok_for_output_1, NULL) == 0;

Kai


Re: FW: patch to fix PR21617

2012-01-23 Thread Igor Zamyatin
Unfortunately patch doesn't help neither for separate EEMBC_2_0 tests
nor for the whole benchmark.

Do you want me to do some debugging here?

On Fri, Jan 20, 2012 at 10:13 PM, Vladimir Makarov vmaka...@redhat.com wrote:
 On 01/19/2012 03:52 PM, Vladimir Makarov wrote:

 On 01/18/2012 02:30 PM, Zamyatin, Igor wrote:

 Yes, we use Atom for EEMBC measurements.

 We'll be glad to help you with your findings.


 Thanks.

 Unfortunately I tried several alternative patches but I did not find a
 better solution (it is mostly code size degradation on CoreI7).  Now I am
 even thinking that the best action would have been ignoring the original PR.

 Could you try the attached patch.  It might work.

 I've tried several approach to prevent small hole creation in
 ira-color.c::assign_hard_reg but it does not work well.

 Thanks.




Re: [patch PR 51900]: Fix PE's delegitimize_address functions

2012-01-23 Thread Kai Tietz
2012/1/23 Richard Guenther richard.guent...@gmail.com:
 On Mon, Jan 23, 2012 at 12:19 PM, Kai Tietz ktiet...@googlemail.com wrote:
 2012/1/23 Richard Guenther richard.guent...@gmail.com:
 On Sun, Jan 22, 2012 at 8:05 PM, Kai Tietz ktiet...@googlemail.com wrote:
 Hello,

 this patch fixes reported issue in PR about common-symbols and fix
 behavior about -fcommon/-fno-common.  Additionally it adds proper
 support for weakref, local-variant of weaks, and tries to handle
 resolution-file information for PE-COFF.

 I did regression tests of all standard-languages for
 x86_64-w64-mingw32 and i686-w64-mingw32.  Dave would you mind to test
 it for cygwin, too?  I assume it will fit for cygwin, but just to make
 sure.  Also I did a regression test for x86_64-unknown-linux-gnu.

 Patch ok for apply?

 As said in the PR your binds_local_p target hook should end with calling
 default_binds_local_p[_1].  No need to duplicate all code in your hook
 (it will quickly get out-of-date).

 Richard.

 Well, issue here is the following block in default_binds_local_p_1:

 ...
  /* Variables defined outside this object might not be local.  */
  else if (DECL_EXTERNAL (exp)  !resolved_locally)
    local_p = false;
 ...

 This condition is only true for PE-coff, if dllimport attribute was 
 specified.

 That would be a missed-optimization fix, please just fix the wrong-code
 regression at this stage.

 Richard.

Hmm, 'missed-optimization'?  If I would call current variant directly
without checking for externals, I would introduce wrong code
generation, as it would introduce via the back-door use of GOT-tables
for x86_64 PE+, which aren't present.

 I will try to adjust patch for this, but some redudant checkings are
 necessary here for sure.

 Thta

 Kai


[PATCH][1/n] Fix PR50444, handle unaligned VIEW_CONVERT_EXPRs during expansion

2012-01-23 Thread Richard Guenther

The VIEW_CONVERT_EXPR expansion path fails to handle the case where
we promote alignment for !STRICT_ALIGNMENT targets but for modes
that are supposed to be handled by movmisalign.

This is exposed in gcc.dg/torture/pr45678-2.c on i?86 when
you apply the candidate patch for PR50444 in comment #15.

I'm now bootstrapping and regtesting this as a prerequesite.

Richard.

2012-01-23  Richard Guenther  rguent...@suse.de

PR tree-optimization/50444
* expr.c (expand_expr_real_1): Properly expand VIEW_CONVERT_EXPR
to an aligned mode from unaligned memory using movmisalign.

Index: gcc/expr.c
===
--- gcc/expr.c  (revision 183423)
+++ gcc/expr.c  (working copy)
@@ -10044,10 +10044,24 @@ expand_expr_real_1 (tree exp, rtx target
 results.  */
   if (MEM_P (op0))
{
+ enum insn_code icode;
+
  op0 = copy_rtx (op0);
 
  if (TYPE_ALIGN_OK (type))
set_mem_align (op0, MAX (MEM_ALIGN (op0), TYPE_ALIGN (type)));
+ else if (mode != BLKmode
+   MEM_ALIGN (op0)  GET_MODE_ALIGNMENT (mode)
+   ((icode = optab_handler (movmisalign_optab, mode))
+  != CODE_FOR_nothing))
+   {
+ struct expand_operand ops[2];
+ PUT_MODE (op0, mode);
+ create_output_operand (ops[0], NULL_RTX, mode);
+ create_fixed_operand (ops[1], op0);
+ expand_insn (icode, 2, ops);
+ return ops[0].value;
+   }
  else if (STRICT_ALIGNMENT
mode != BLKmode
MEM_ALIGN (op0)  GET_MODE_ALIGNMENT (mode))


Re: [patch PR 51900]: Fix PE's delegitimize_address functions

2012-01-23 Thread Richard Guenther
On Mon, Jan 23, 2012 at 2:11 PM, Kai Tietz ktiet...@googlemail.com wrote:
 So revised patch with removing dwarf2out.c changes and using
 default_binds_local_p_1 in  i386_pe_binds_local_p.  The dwarf2out
 change isn't anymore necessary.  It seems that fix of PR/45682 fixed
 this issue, too.


 ChangeLog

 2012-01-23  Kai Tietz  kti...@redhat.com

        PR target/51900
        * config/i386/predicates.md (symbolic_operand): Allow
        UNSPEC_PCREL as PIC expression for lea.
        * config/i386/winnt.c (i386_pe_binds_local_p): Reworked.
        * config/i386/i386.c (ix86_delegitimize_address): Handle
        UNSPEC_PCREL for none-MEM, too.

 Tested for x86_64-w64-mingw, i686-w64-mingw32, and
 x86_64-unknown-linux-gnu.  Ok for apply?

 Regards,
 Kai

 Index: config/i386/predicates.md
 ===
 --- config/i386/predicates.md   (revision 183389)
 +++ config/i386/predicates.md   (working copy)
 @@ -410,6 +410,7 @@
          || (GET_CODE (op) == UNSPEC
               (XINT (op, 1) == UNSPEC_GOT
                  || XINT (op, 1) == UNSPEC_GOTOFF
 +                 || XINT (op, 1) == UNSPEC_PCREL
                  || XINT (op, 1) == UNSPEC_GOTPCREL)))
        return true;
       if (GET_CODE (op) != PLUS
 Index: config/i386/winnt.c
 ===
 --- config/i386/winnt.c (revision 183389)
 +++ config/i386/winnt.c (working copy)
 @@ -350,21 +350,22 @@
   SYMBOL_REF_FLAGS (symbol) = flags;
  }

 +
  bool
  i386_pe_binds_local_p (const_tree exp)
  {
 -  /* PE does not do dynamic binding.  Indeed, the only kind of
 -     non-local reference comes from a dllimport'd symbol.  */
   if ((TREE_CODE (exp) == VAR_DECL || TREE_CODE (exp) == FUNCTION_DECL)
        DECL_DLLIMPORT_P (exp))
     return false;

 -  /* Or a weak one, now that they are supported.  */
 -  if ((TREE_CODE (exp) == VAR_DECL || TREE_CODE (exp) == FUNCTION_DECL)
 -       DECL_WEAK (exp))
 -    return false;
 -
 -  return true;
 +  /* External public symbols, which aren't weakref-s,
 +     have local-binding for PE targets.  */
 +  if (DECL_P (exp)
 +       !lookup_attribute (weakref, DECL_ATTRIBUTES (exp))
 +       TREE_PUBLIC (exp)
 +       DECL_EXTERNAL (exp))
 +    return true;
 +  return default_binds_local_p_1 (exp, 0);
  }

That looks indeed better.

  /* Also strip the fastcall prefix and stdcall suffix.  */
 Index: config/i386/i386.c
 ===
 --- config/i386/i386.c  (revision 183389)
 +++ config/i386/i386.c  (working copy)
 @@ -13231,10 +13231,10 @@
          || GET_CODE (XEXP (x, 0)) != UNSPEC
          || (XINT (XEXP (x, 0), 1) != UNSPEC_GOTPCREL
               XINT (XEXP (x, 0), 1) != UNSPEC_PCREL)
 -         || !MEM_P (orig_x))
 +         || (!MEM_P (orig_x)  XINT (XEXP (x, 0), 1) != UNSPEC_PCREL))
        return ix86_delegitimize_tls_address (orig_x);
       x = XVECEXP (XEXP (x, 0), 0, 0);
 -      if (GET_MODE (orig_x) != GET_MODE (x))
 +      if (GET_MODE (orig_x) != GET_MODE (x)  MEM_P (orig_x))
        {
          x = simplify_gen_subreg (GET_MODE (orig_x), x,
                                   GET_MODE (x), 0);


[Patch,AVR,doc]: Fix some typos, add example.

2012-01-23 Thread Georg-Johann Lay
Besides fixing some typos, this patch adds an example that shows how to access
code located with attribute progmem.

The example in AVR named address spaces is moved up and the note on offset
limitation is removed.

Ok to apply?

Johann

PR target/49868
* doc/extend.texi (AVR Named Address Spaces): Move sample code up.
Remove note on size/offset limitation.
(AVR Variable Attributes): Add example how to read data located
with progmem.  Refer to named address spaces.
Index: doc/extend.texi
===
--- doc/extend.texi	(revision 183341)
+++ doc/extend.texi	(working copy)
@@ -1237,9 +1237,10 @@ in order to put read-only data into the
 data by means of the special instructions @code{LPM} or @code{ELPM}
 needed to read from flash.
 
-Per default, any data including read-only data is located in RAM so
-that address spaces are needed to locate read-only data in flash memory
-@emph{and} to generate the right instructions to access the data
+Per default, any data including read-only data is located in RAM
+(the genric address space) so that non-generic address spaces are
+needed to locate read-only data in flash memory
+@emph{and} to generate the right instructions to access this data
 without using (inline) assembler code.
 
 @table @code
@@ -1265,9 +1266,9 @@ address space @code{__pgm@var{N}}.
 The compiler will set the @code{RAMPZ} segment register approptiately 
 before reading data by means of the @code{ELPM} instruction.
 
-On devices with less 64kiB flash segments as indicated by the address
+On devices with less 64@tie{}kiB flash segments as indicated by the address
 space, the compiler will cut down the segment number to a number the
-device actually supports. Counting starts at @code{0}
+device actually supports. Counting starts at@tie{}@code{0}
 for space @code{__pgm}. For example, if you access address space
 @code{__pgm3} on an ATmega128 device with two 64@tie{}kiB flash segments,
 the compiler will generate a read from @code{__pgm1}, i.e.@: it
@@ -1284,6 +1285,31 @@ with @code{RAMPZ} set according to the h
 Objects in this address space will be located in @code{.progmem.data}.
 @end table
 
+@b{Example}
+
+@example
+char my_read (const __pgm char ** p)
+@{
+/* p is a pointer to RAM that points to a pointer to flash.
+   The first indirection of p will read that flash pointer
+   from RAM and the second indirection reads a char from this
+   flash address.  */
+
+return **p;
+@}
+
+/* Locate array[] in flash memory */
+const __pgm int array[] = @{ 3, 5, 7, 11, 13, 17, 19 @};
+
+int i = 1;
+
+int main (void)
+@{
+   /* Return 17 by reading from flash memory */
+   return array[array[i]];
+@}
+@end example
+
 For each named address space supported by avr-gcc there is an equally
 named but uppercase built-in macro defined. 
 The purpose is to facilitate testing if respective address space
@@ -1311,8 +1337,9 @@ int read_i (void)
 
 Notice that attribute @ref{AVR Variable Attributes,@code{progmem}}
 locates data in flash but
-accesses to these data will be to generic address space, i.e.@: RAM,
-so that you need special access functions like @code{pgm_read_byte}
+accesses to these data will read from generic address space, i.e.@:
+from RAM,
+so that you need special accessors like @code{pgm_read_byte}
 from @w{@uref{http://nongnu.org/avr-libc/user-manual,avr-libc}}.
 
 @b{Limitations and caveats}
@@ -1331,10 +1358,10 @@ you will have to arrange your linker skr
 @code{.progmem@var{N}.data} sections according to your needs.
 
 @item
-Any data or pointers to the AVR address spaces spaces must
-also be qualified as @code{const}, i.e.@: as read-only data.
+Any data or pointers to the non-generic address spaces must
+be qualified as @code{const}, i.e.@: as read-only data.
 This still applies if the data in one of these address
-spaces like software version number or lookup tables are intended to
+spaces like software version number or calibration lookup table are intended to
 be changed after load time by, say, a boot loader. In this case
 the right qualification is @code{const} @code{volatile} so that the compiler
 must not optimize away known values or insert them
@@ -1349,52 +1376,12 @@ extern const __pgmx char foo;
 const __pgmx void *pfoo = foo;
 @end example
 The code will throw an assembler warning and the high byte of
-@code{pfoo} will be initialized with @code{0}, i.e.@: the
+@code{pfoo} will be initialized with@tie{}@code{0}, i.e.@: the
 initialization will be as if @code{foo} was located in the first
 64@tie{}KiB chunk of flash.
 
-@item
-Address arithmetic for the @code{__pgmx} address space is carried out
-as 16-bit signed integer arithmetic. This means that in the following
-code array positions with offsets @code{idx}@tie{}@tie{}8191 are
-inaccessible.
-
-@example
-extern const __pgmx long lookup[];
-
-long read_lookup (unsigned idx)
-@{
-return lookup[idx];
-@}
-@end example
-
 

Re: [PATCH] PR51280 LTO/trans-mem ICE with TM builtins

2012-01-23 Thread Aldy Hernandez



PR lto/51916
* lto-object.c (LTO_SEGMENT_NAME): Define segment name.
(lto_obj_file_open): Use it.


Patrick, the changelog was referring to the wrong file and the wrong 
function.  I've fixed it.  I also inlined the segment name, as Ian had 
in the PR.


Richard Guenther approved the patch on the PR, so I am committing and 
closing the PR.  The final version of the patch is attached.


Thanks for fixing this!
PR lto/51916
* lto-wrapper.c (run_gcc): Pass the LTO section name to
simple_object_start_read.

Index: lto-wrapper.c
===
--- lto-wrapper.c   (revision 183432)
+++ lto-wrapper.c   (working copy)
@@ -479,7 +479,8 @@ run_gcc (unsigned argc, char *argv[])
   fd = open (argv[i], O_RDONLY);
   if (fd == -1)
continue;
-  sobj = simple_object_start_read (fd, file_offset, NULL, errmsg, err);
+  sobj = simple_object_start_read (fd, file_offset, __GNU_LTO, 
+  errmsg, err);
   if (!sobj)
{
  close (fd);


[PATCH] PR testsuite/51941 - FAIL g++.dg/debug/dwarf2/nested-3.C on

2012-01-23 Thread Dodji Seketeli
Hello,

The test of the patch doesn't pass on x86_64-apple-dwarwin10 because
the DWARF asm output has an extra line:

  .set L$set$31,LASF0-Lsection__debug_str

before the DW_AT_name: Executor line, as in:

.byte   0x8 # uleb128 0x8; (DIE (0x92) DW_TAG_namespace)
.ascii thread\0   # DW_AT_name
.byte   0x1 # DW_AT_decl_file 
(/home/dodji/devel/git/gcc/cur/gcc/testsuite/g++.dg/debug/dwarf2/nested-3.C)
.byte   0x4 # DW_AT_decl_line
.long   0xb7# DW_AT_sibling
.byte   0x9 # uleb128 0x9; (DIE (0xa0) DW_TAG_class_type)
.set L$set$31,LASF0-Lsection__debug_str
.long L$set$31  # DW_AT_name: Executor
# DW_AT_declaration
.byte   0x5 # uleb128 0x5; (DIE (0xa5) DW_TAG_subprogram)
# DW_AT_external
.set L$set$32,LASF1-Lsection__debug_str
.long L$set$32  # DW_AT_name: CurrentExecutor
.byte   0x1 # DW_AT_decl_file 
(/home/dodji/devel/git/gcc/cur/gcc/testsuite/g++.dg/debug/dwarf2/nested-3.C)
.byte   0x8 # DW_AT_decl_line
.set L$set$33,LASF2-Lsection__debug_str
.long L$set$33  # DW_AT_linkage_name: 
_ZN6thread8Executor15CurrentExecutorEv
.long   0xb7# DW_AT_type
.byte   0x1 # DW_AT_accessibility
# DW_AT_declaration
.byte   0   # end of children of DIE 0xa0
.byte   0   # end of children of DIE 0x92

As Iain Sandoe says in the audit trail:

The reason for making the offsets absolute is limitations on what the
native tool-chain can handle in terms of generating/using relocs

Anyway, I just added a (\[\n\r\]+\[^\n\r\]*)+ to the regexp before
matching Executor to pass any extraneous line there.

Tested on x86_64-apple-dwarwin10 and x86_64-unknown-linux-gnu.

OK for trunk?

From 01c6dd2755ba6e4204dcaf13f2d34968f1769244 Mon Sep 17 00:00:00 2001
From: Dodji Seketeli do...@redhat.com
Date: Mon, 23 Jan 2012 14:53:45 +0100
Subject: [PATCH] PR testsuite/51941 - FAIL g++.dg/debug/dwarf2/nested-3.C on
 Darwin

gcc/testsuite/

PR testsuite/51941
* g++.dg/debug/dwarf2/nested-3.C:  Accept multiple lines between
the DW_TAG_class_type and DW_AT_name: Executor.
---
 gcc/testsuite/g++.dg/debug/dwarf2/nested-3.C |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/nested-3.C 
b/gcc/testsuite/g++.dg/debug/dwarf2/nested-3.C
index 707f02d..1c1be99 100644
--- a/gcc/testsuite/g++.dg/debug/dwarf2/nested-3.C
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/nested-3.C
@@ -51,4 +51,4 @@ main ()
 //
 // Hence the scary regexp:
 //
-// { dg-final { scan-assembler \[^\n\r\]*\\(DIE \\(0x(\[0-9a-f\]+)\\) 
DW_TAG_namespace\\)\[\n\r\]+\[^\n\r\]*\thread\[\^\n\r]+\[\n\r\]+(\[^\n\r\]*\[\n\r\]+)+\[^\n\r\]*\\(DIE
 \\(0x(\[0-9a-f\]+)\\) 
DW_TAG_class_type\\)\[\n\r\]+\[^\n\r\]*\Executor\[^\n\r\]+\[\n\r\]+\[^\n\r\]*DW_AT_declaration\[\n\r\]+\[^\n\r\]*\\(DIE\[^\n\r\]*DW_TAG_subprogram\\)\[\n\r\]+(\[^\n\r\]*\[\n\r\]+)+\[^\n\r\]*\CurrentExecutor\[^\n\r\]+\[\n\r\]+(\[^\n\r\]*\[\n\r\]+)+(\[^\n\r\]*\[\n\r\]+)+\[^\n\r\]*end
 of children of DIE 0x\\3\[\n\r]+\[^\n\r\]*end of children of DIE 
0x\\1\[\n\r]+ } }
+// { dg-final { scan-assembler \[^\n\r\]*\\(DIE \\(0x(\[0-9a-f\]+)\\) 
DW_TAG_namespace\\)\[\n\r\]+\[^\n\r\]*\thread\[\^\n\r]+\[\n\r\]+(\[^\n\r\]*\[\n\r\]+)+\[^\n\r\]*\\(DIE
 \\(0x(\[0-9a-f\]+)\\) 
DW_TAG_class_type\\)(\[\n\r\]+\[^\n\r\]*)+\Executor\[^\n\r\]+\[\n\r\]+\[^\n\r\]*DW_AT_declaration\[\n\r\]+\[^\n\r\]*\\(DIE\[^\n\r\]*DW_TAG_subprogram\\)\[\n\r\]+(\[^\n\r\]*\[\n\r\]+)+\[^\n\r\]*\CurrentExecutor\[^\n\r\]+\[\n\r\]+(\[^\n\r\]*\[\n\r\]+)+(\[^\n\r\]*\[\n\r\]+)+\[^\n\r\]*end
 of children of DIE 0x\\3\[\n\r]+\[^\n\r\]*end of children of DIE 
0x\\1\[\n\r]+ } }
-- 
1.7.6.5


-- 
Dodji


Re: [PATCH] PR testsuite/51941 - FAIL g++.dg/debug/dwarf2/nested-3.C on

2012-01-23 Thread Jason Merrill

OK.

Jason


[Patch, Fortran] PR 51948 - Fix variable check for MOVE_ALLOC

2012-01-23 Thread Tobias Burnus

Dear all,

the variable_check() failed when one had multiple nested blocks.

I think it worked in 4.5 because that was before PR 46484 got fixed in 
4.6. The issue that PR fixed was that the non-variableness of f in 
sub (see below) was not diagnosed. The problem is that the symbol tree 
is shared and sym == sym-result is also true in sub:

  contains
 subroutine sub
   ...= allocatable(f)
 end
 function f()

This patch simply allows for more than one level of parent namespace.

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

Tobias
2012-01-23  Tobias Burnus  bur...@net-b.de

	PR fortran/51948
	* check.c (variable_check): Fix checking for
	result variables and deeply nested BLOCKs.

2012-01-23  Tobias Burnus  bur...@net-b.de

	PR fortran/51948
	* gfortran.dg/move_alloc_12.f90: New.

diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index cb6b94f..4b72a5f 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -521,15 +521,18 @@ variable_check (gfc_expr *e, int n, bool allow_proc)
 
   if (e-expr_type == EXPR_VARIABLE
e-symtree-n.sym-attr.flavor != FL_PARAMETER
-   (allow_proc
-	  || !e-symtree-n.sym-attr.function
-	  || (e-symtree-n.sym == e-symtree-n.sym-result
-	   (e-symtree-n.sym == gfc_current_ns-proc_name
-		  || (gfc_current_ns-parent
-		   e-symtree-n.sym
-			 == gfc_current_ns-parent-proc_name)
+   (allow_proc || !e-symtree-n.sym-attr.function))
 return SUCCESS;
 
+  if (e-expr_type == EXPR_VARIABLE  e-symtree-n.sym-attr.function
+   e-symtree-n.sym == e-symtree-n.sym-result)
+{
+  gfc_namespace *ns;
+  for (ns = gfc_current_ns; ns; ns = ns-parent)
+	if (ns-proc_name == e-symtree-n.sym)
+	  return SUCCESS;
+}
+
   gfc_error ('%s' argument of '%s' intrinsic at %L must be a variable,
 	 gfc_current_intrinsic_arg[n]-name, gfc_current_intrinsic, e-where);
 
--- /dev/null	2012-01-23 08:22:38.999666895 +0100
+++ gcc/gcc/testsuite/gfortran.dg/move_alloc_12.f90	2012-01-23 14:23:37.0 +0100
@@ -0,0 +1,33 @@
+! { dg-do compile }
+!
+! PR fortran/51948
+!
+  type :: t
+  end type t
+contains
+  function func(x, y)
+class(t) :: y
+type(t), allocatable :: func
+type(t), allocatable :: x
+
+select type (y)
+  type is(t)
+call move_alloc (x, func)
+end select
+  end function
+
+  function func2(x, y)
+class(t) :: y
+class(t), allocatable :: func2
+class(t), allocatable :: x
+
+block
+block
+select type (y)
+  type is(t)
+call move_alloc (x, func2)
+end select
+end block
+end block
+  end function
+end


Re: Continue strict-volatile-bitfields fixes

2012-01-23 Thread Bernd Schmidt
On 11/29/2011 05:35 PM, Mitchell, Mark wrote:
 So, I still think this patch is the best way to go forward, and it
 does
 fix incorrect code generation. Would appreciate an OK.

 Ping.
 
 If you don't hear any objections within a week, please proceed.

That was committed a while ago. The part in stor-layout.c that stops us
from promoting bitfields to normal fields apparently caused some
testsuite regressions in sh tests, where some optimization dump scans
show that we can't perform the optimizations if there are BIT_FIELD_REFs
rather than a normal member access.

The testcases use things like
  enum something field:8;
and I think applying strict-volatile-bitfields to enums is probably
meaningless. Should we adjust semantics so that the compiler is free to
optimize enum bitfields? The patch would look something like the below.
Thomas has tested this on arm and sh with our internal tree.


Bernd


Index: gcc/stor-layout.c
===
--- gcc/stor-layout.c   (revision 355696)
+++ gcc/stor-layout.c   (working copy)
@@ -665,8 +665,7 @@
 may make a volatile object later.  */
  if (TYPE_SIZE (type) != 0
   TREE_CODE (TYPE_SIZE (type)) == INTEGER_CST
-  GET_MODE_CLASS (TYPE_MODE (type)) == MODE_INT
-  flag_strict_volatile_bitfields = 0)
+  GET_MODE_CLASS (TYPE_MODE (type)) == MODE_INT)
{
  enum machine_mode xmode
= mode_for_size_tree (DECL_SIZE (decl), MODE_INT, 1);
@@ -674,7 +673,12 @@

  if (xmode != BLKmode
   !(xalign  BITS_PER_UNIT  DECL_PACKED (decl))
-  (known_align == 0 || known_align = xalign))
+  (known_align == 0 || known_align = xalign)
+   (flag_strict_volatile_bitfields = 0
+  /* Same size makes strict volatile bitfields
meaningless.  */
+  || GET_MODE_SIZE (xmode) == GET_MODE_SIZE
(TYPE_MODE (type))
+  /* Strict volatile bitfields shouldn't apply to
enums.  */
+  || TREE_CODE (type) == ENUMERAL_TYPE))
{
  DECL_ALIGN (decl) = MAX (xalign, DECL_ALIGN (decl));
  DECL_MODE (decl) = xmode;



Re: [PATCH][1/n] Fix PR50444, handle unaligned VIEW_CONVERT_EXPRs during expansion

2012-01-23 Thread Richard Guenther
On Mon, 23 Jan 2012, Richard Guenther wrote:

 
 The VIEW_CONVERT_EXPR expansion path fails to handle the case where
 we promote alignment for !STRICT_ALIGNMENT targets but for modes
 that are supposed to be handled by movmisalign.
 
 This is exposed in gcc.dg/torture/pr45678-2.c on i?86 when
 you apply the candidate patch for PR50444 in comment #15.
 
 I'm now bootstrapping and regtesting this as a prerequesite.

Actually I discovered that Jakub fixed this on the 4.4 and 4.5
branches but left 4.6 unfixed ... thus I'm re-testing

2012-01-23  Richard Guenther  rguent...@suse.de

Forward-port to trunk
2010-09-21  Jakub Jelinek  ja...@redhat.com

PR middle-end/45678
* expr.c (expand_expr_real_1) case VIEW_CONVERT_EXPR: If
op0 isn't sufficiently aligned and there is movmisalignM
insn for mode, use it to load op0 into a temporary register.

Index: gcc/expr.c
===
*** gcc/expr.c  (revision 183423)
--- gcc/expr.c  (working copy)
*** expand_expr_real_1 (tree exp, rtx target
*** 10044,10053 
--- 10044,10075 
 results.  */
if (MEM_P (op0))
{
+ enum insn_code icode;
+ 
  op0 = copy_rtx (op0);
  
  if (TYPE_ALIGN_OK (type))
set_mem_align (op0, MAX (MEM_ALIGN (op0), TYPE_ALIGN (type)));
+ else if (mode != BLKmode
+   MEM_ALIGN (op0)  GET_MODE_ALIGNMENT (mode)
+  /* If the target does have special handling for unaligned
+ loads of mode then use them.  */
+   ((icode = optab_handler (movmisalign_optab, mode))
+  != CODE_FOR_nothing))
+   {
+ rtx reg, insn;
+ 
+ op0 = adjust_address (op0, mode, 0);
+ /* We've already validated the memory, and we're creating a
+new pseudo destination.  The predicates really can't
+fail.  */
+ reg = gen_reg_rtx (mode);
+ 
+ /* Nor can the insn generator.  */
+ insn = GEN_FCN (icode) (reg, op0);
+ emit_insn (insn);
+ return reg;
+   }
  else if (STRICT_ALIGNMENT
mode != BLKmode
MEM_ALIGN (op0)  GET_MODE_ALIGNMENT (mode))


Re: [RFC combine] PR48308 - Fix issue with missing(?) LOG_LINKS

2012-01-23 Thread Ramana Radhakrishnan
On 23 January 2012 09:02, Eric Botcazou ebotca...@adacore.com wrote:
 Do you mean something like this instead ? I'm testing this - Ok if no
 regressions ?

 OK with an appropriate ChangeLog.

Or not :( We really shouldn't use SUBST there as it only deals with
rtx *  It appeared better to invent a new SUBST for links given that
the type of this expression is struct insn_link rather than rtx * (Doh
!)  I did think about hacking up a local flag but somehow like this
version better.

It's survived a bootstrap and testrun with no regressions for
c,c++,fortran,ada on one of the power7 machines for
powerpc64-unknown-linux-gnu in the compile farm. I'll put it through
it's paces for trunk (arm-linux-gnueabi / x86_64) and 4.6 (modulo API
changes for alloc_insn_link) if you think this looks better.

cheers
Ramana



2012-01-23  Ramana Radhakrishnan  ramana.radhakrish...@linaro.org

PR rtl-optimization/48308
* combine.c (do_SUBST_LINK): Declare and define.
(SUBST_LINK): New.
(try_combine): Handle LOG_LINKS for dummy i1 case.


 --
 Eric Botcazou
Index: gcc/combine.c
===
--- gcc/combine.c   (revision 183416)
+++ gcc/combine.c   (working copy)
@@ -367,14 +367,14 @@
 /* Record one modification to rtl structure
to be undone by storing old_contents into *where.  */
 
-enum undo_kind { UNDO_RTX, UNDO_INT, UNDO_MODE };
+enum undo_kind { UNDO_RTX, UNDO_INT, UNDO_MODE, UNDO_LINKS };
 
 struct undo
 {
   struct undo *next;
   enum undo_kind kind;
-  union { rtx r; int i; enum machine_mode m; } old_contents;
-  union { rtx *r; int *i; } where;
+  union { rtx r; int i; enum machine_mode m; struct insn_link *l; } 
old_contents;
+  union { rtx *r; int *i; struct insn_link **l; } where;
 };
 
 /* Record a bunch of changes to be undone, up to MAX_UNDO of them.
@@ -698,7 +698,8 @@
  that are perfectly valid, so we'd waste too much effort for
  little gain doing the checks here.  Focus on catching invalid
  transformations involving integer constants.  */
-  if (GET_MODE_CLASS (GET_MODE (oldval)) == MODE_INT
+  if (oldval
+   GET_MODE_CLASS (GET_MODE (oldval)) == MODE_INT
CONST_INT_P (newval))
 {
   /* Sanity check that we're replacing oldval with a CONST_INT
@@ -789,6 +790,33 @@
 }
 
 #define SUBST_MODE(INTO, NEWVAL)  do_SUBST_MODE((INTO), (NEWVAL))
+
+/* Similar to SUBST, but NEWVAL is a LOG_LINKS expression.  */
+
+static void
+do_SUBST_LINK (struct insn_link **into, struct insn_link *newval)
+{
+  struct undo *buf;
+  struct insn_link * oldval = *into;
+
+  if (oldval == newval)
+return;
+
+  if (undobuf.frees)
+buf = undobuf.frees, undobuf.frees = buf-next;
+  else
+buf = XNEW (struct undo);
+
+  buf-kind = UNDO_LINKS;
+  buf-where.l = into;
+  buf-old_contents.l = oldval;
+  *into = newval;
+
+  buf-next = undobuf.undos, undobuf.undos = buf;
+}
+
+#define SUBST_LINK(oldval, newval) do_SUBST_LINK (oldval, newval)
+
 
 /* Subroutine of try_combine.  Determine whether the replacement patterns
NEWPAT, NEWI2PAT and NEWOTHERPAT are cheaper according to insn_rtx_cost
@@ -2865,6 +2893,7 @@
  SUBST (PATTERN (i2), XVECEXP (PATTERN (i2), 0, 0));
  SUBST (XEXP (SET_SRC (PATTERN (i2)), 0),
 SET_DEST (PATTERN (i1)));
+ SUBST_LINK (LOG_LINKS (i2), alloc_insn_link (i1, LOG_LINKS (i2)));
}
 }
 #endif
@@ -4494,6 +4523,9 @@
case UNDO_MODE:
  adjust_reg_mode (*undo-where.r, undo-old_contents.m);
  break;
+   case UNDO_LINKS:
+ *undo-where.l = undo-old_contents.l;
+ break;
default:
  gcc_unreachable ();
}


Re: [patch PR 51900]: Fix PE's delegitimize_address functions

2012-01-23 Thread Richard Henderson
On 01/24/2012 12:11 AM, Kai Tietz wrote:
 2012-01-23  Kai Tietz  kti...@redhat.com
 
   PR target/51900
   * config/i386/predicates.md (symbolic_operand): Allow
   UNSPEC_PCREL as PIC expression for lea.
   * config/i386/winnt.c (i386_pe_binds_local_p): Reworked.
   * config/i386/i386.c (ix86_delegitimize_address): Handle
   UNSPEC_PCREL for none-MEM, too.

Ok.


r~


Re: [Patch testsuite] Fix vec_interleave and vec_extract_even_odd to fall back to vec_perm

2012-01-23 Thread Ramana Radhakrishnan
On 23 January 2012 09:15, Jakub Jelinek ja...@redhat.com wrote:
 On Mon, Jan 23, 2012 at 08:30:46AM +, Ramana Radhakrishnan wrote:
 Now that we have vec_perm support, vec_interleave and
 vec_extract_even_odd should fall out from that rather than having to
 handle an additional target in each of these. This fixes
 gcc.dg/vect/slp-11a.c for ARM Neon testing with no other regressions
 in gcc.dg/vect

 Ok ?

 That will disable ia64 testing of tests that need vect_extract_even_odd
 and vect_interleave.  Not sure if ia64 has good enough vect_perm
 support that it can be enabled there though.  Some targets might be
 supporting only a couple of specific permutations like these two
 and not general permutations.
 So safer would be to add [is-effective-target arm_neon_ok] to these
 two checks for now.


Right ok - Sorry I missed ia64 when I looked at those routines. This
is what I committed in the end .

cheers
Ramana

2012-01-23  Ramana Radhakrishnan  ramana.radhakrish...@linaro.org

* lib/target-supports.exp
(check_effective_target_vect_extract_even_odd): Handle
ARM neon.
(check_effective_target_vect_interleave): Likewise.
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index be33407a..2747089 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -3480,6 +3480,7 @@ proc check_effective_target_vect_extract_even_odd { } {
 } else {
 set et_vect_extract_even_odd_saved 0 
 if { [istarget powerpc*-*-*] 
+|| [is-effective-target arm_neon_ok]
  || [istarget i?86-*-*]
  || [istarget x86_64-*-*]
  || [istarget ia64-*-*]
@@ -3502,6 +3503,7 @@ proc check_effective_target_vect_interleave { } {
 } else {
 set et_vect_interleave_saved 0
 if { [istarget powerpc*-*-*]
+|| [is-effective-target arm_neon_ok]
  || [istarget i?86-*-*]
  || [istarget x86_64-*-*]
  || [istarget ia64-*-*]


C++ PATCH for c++/51925 (ICE with using in template)

2012-01-23 Thread Jason Merrill
The problem in this case was that a few places in the compiler were 
assuming that when we have an OVERLOAD, all the functions within it come 
from the same context.  But that isn't the case when we have 
using-declarations involved, so we need to take them into account.


Tested x86_64-pc-linux-gnu, applied to trunk.
commit 08e12669e38d0ef41ebe051b31383906958d24c7
Author: Jason Merrill ja...@redhat.com
Date:   Sun Jan 22 16:32:53 2012 -0500

	PR c++/51925
	* class.c (add_method): Set OVL_USED for using-decls.
	* tree.c (ovl_scope): New.
	* cp-tree.h: Declare it.
	* parser.c (cp_parser_template_name): Use it.
	* semantics.c (baselink_for_fns): Likewise.
	* name-lookup.c (set_inherited_value_binding_p): Likewise.

diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index e6f33fe..d654b76 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -1118,6 +1118,8 @@ add_method (tree type, tree method, tree using_decl)
 
   /* Add the new binding.  */
   overload = build_overload (method, current_fns);
+  if (using_decl  TREE_CODE (overload) == OVERLOAD)
+OVL_USED (overload) = true;
 
   if (conv_p)
 TYPE_HAS_CONVERSION (type) = 1;
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index ccad644..f27755e 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -75,6 +75,7 @@ c-common.h, not after.
   IMPLICIT_CONV_EXPR_DIRECT_INIT (in IMPLICIT_CONV_EXPR)
   TRANSACTION_EXPR_IS_STMT (in TRANSACTION_EXPR)
   CONVERT_EXPR_VBASE_PATH (in CONVERT_EXPR)
+  OVL_ARG_DEPENDENT (in OVERLOAD)
1: IDENTIFIER_VIRTUAL_P (in IDENTIFIER_NODE)
   TI_PENDING_TEMPLATE_FLAG.
   TEMPLATE_PARMS_FOR_INLINE.
@@ -5679,6 +5680,7 @@ extern tree get_fns(tree);
 extern tree get_first_fn			(tree);
 extern tree ovl_cons(tree, tree);
 extern tree build_overload			(tree, tree);
+extern tree ovl_scope(tree);
 extern bool non_static_member_function_p(tree);
 extern const char *cxx_printable_name		(tree, int);
 extern const char *cxx_printable_name_translate	(tree, int);
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 5734055..2351342 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -2853,7 +2853,7 @@ set_inherited_value_binding_p (cxx_binding *binding, tree decl,
   tree context;
 
   if (TREE_CODE (decl) == OVERLOAD)
-	context = CP_DECL_CONTEXT (OVL_CURRENT (decl));
+	context = ovl_scope (decl);
   else
 	{
 	  gcc_assert (DECL_P (decl));
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index c4c3ef4..491f48e 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -12722,7 +12722,7 @@ cp_parser_template_name (cp_parser* parser,
  its name; we will look it up again during template instantiation.  */
   if (DECL_FUNCTION_TEMPLATE_P (decl) || !DECL_P (decl))
 {
-  tree scope = CP_DECL_CONTEXT (get_first_fn (decl));
+  tree scope = ovl_scope (decl);
   if (TYPE_P (scope)  dependent_type_p (scope))
 	return identifier;
 }
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index a5a10d0..9019962 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2807,23 +2807,20 @@ finish_base_specifier (tree base, tree access, bool virtual_p)
 tree
 baselink_for_fns (tree fns)
 {
-  tree fn;
+  tree scope;
   tree cl;
 
   if (BASELINK_P (fns) 
   || error_operand_p (fns))
 return fns;
-  
-  fn = fns;
-  if (TREE_CODE (fn) == TEMPLATE_ID_EXPR)
-fn = TREE_OPERAND (fn, 0);
-  fn = get_first_fn (fn);
-  if (!DECL_FUNCTION_MEMBER_P (fn))
+
+  scope = ovl_scope (fns);
+  if (!CLASS_TYPE_P (scope))
 return fns;
 
-  cl = currently_open_derived_class (DECL_CONTEXT (fn));
+  cl = currently_open_derived_class (scope);
   if (!cl)
-cl = DECL_CONTEXT (fn);
+cl = scope;
   cl = TYPE_BINFO (cl);
   return build_baselink (cl, cl, fns, /*optype=*/NULL_TREE);
 }
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index bf8bc05..cf39800 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1525,6 +1525,24 @@ build_overload (tree decl, tree chain)
   return ovl_cons (decl, chain);
 }
 
+/* Return the scope where the overloaded functions OVL were found.  */
+
+tree
+ovl_scope (tree ovl)
+{
+  if (TREE_CODE (ovl) == OFFSET_REF
+  || TREE_CODE (ovl) == COMPONENT_REF)
+ovl = TREE_OPERAND (ovl, 1);
+  if (TREE_CODE (ovl) == BASELINK)
+return BINFO_TYPE (BASELINK_BINFO (ovl));
+  if (TREE_CODE (ovl) == TEMPLATE_ID_EXPR)
+ovl = TREE_OPERAND (ovl, 0);
+  /* Skip using-declarations.  */
+  while (TREE_CODE (ovl) == OVERLOAD  OVL_USED (ovl)  OVL_CHAIN (ovl))
+ovl = OVL_CHAIN (ovl);
+  return CP_DECL_CONTEXT (OVL_CURRENT (ovl));
+}
+
 /* Return TRUE if FN is a non-static member function, FALSE otherwise.
This function looks into BASELINK and OVERLOAD nodes.  */
 
diff --git a/gcc/testsuite/g++.dg/template/template-id-2.C b/gcc/testsuite/g++.dg/template/template-id-2.C
index 333e33d..d214716 100644
--- a/gcc/testsuite/g++.dg/template/template-id-2.C
+++ b/gcc/testsuite/g++.dg/template/template-id-2.C
@@ -11,7 +11,7 @@ 

Re: Fix regression on PR46590 (slow compile with -O0)

2012-01-23 Thread Michael Matz
Hi,

On Sat, 21 Jan 2012, Eric Botcazou wrote:

  Trivially fixing the thinko (iterating over (work bit-and 
  old_conflict) in the first inner loop) would fix the testcase but in 
  general create too few conflicts, i.e. generate wrong code.  I need 
  some time to think about this again.
 
 OK, thanks in advance.

Sigh.  I can't come up with a way to generally speed up the conflict 
generation without sometimes adding artificial conflicts.  I.e. I'll have 
to revert r183305.  I can still fix the specific situation of PR46590 by 
making sure clobbers are added for all aggregates, not only the (at 
gimplification time) address takens.

So, this is currently in regstrapping, x86_64-linux, all langs+Ada.  Okay 
for trunk (well, the revert is obvious, but the gimplify.c hunk)?


Ciao,
Michael.

PR tree-optimization/46590
* cfgexpand.c: Revert last change (r183305).
* gimplify.c (gimplify_bind_expr): Add clobbers for all non-gimple
regs.

Index: gimplify.c
===
--- gimplify.c  (revision 183303)
+++ gimplify.c  (working copy)
@@ -1226,12 +1226,11 @@ gimplify_bind_expr (tree *expr_p, gimple
   if (TREE_CODE (t) == VAR_DECL
   !is_global_var (t)
   DECL_CONTEXT (t) == current_function_decl
-  !DECL_HARD_REGISTER (t)
-  !TREE_THIS_VOLATILE (t)
   !DECL_HAS_VALUE_EXPR_P (t)
  /* Only care for variables that have to be in memory.  Others
 will be rewritten into SSA names, hence moved to the top-level.  */
-  needs_to_live_in_memory (t))
+  !is_gimple_reg (t))
+
{
  tree clobber = build_constructor (TREE_TYPE (t), NULL);
  TREE_THIS_VOLATILE (clobber) = 1;
Index: cfgexpand.c
===
--- cfgexpand.c (revision 183305)
+++ cfgexpand.c (working copy)
@@ -441,12 +441,11 @@ visit_conflict (gimple stmt ATTRIBUTE_UN
 
 /* Helper routine for add_scope_conflicts, calculating the active partitions
at the end of BB, leaving the result in WORK.  We're called to generate
-   conflicts when OLD_CONFLICTS is non-null, otherwise we're just tracking
-   liveness.  If we generate conflicts then OLD_CONFLICTS stores the bits
-   for which we generated conflicts already.  */
+   conflicts when FOR_CONFLICT is true, otherwise we're just tracking
+   liveness.  */
 
 static void
-add_scope_conflicts_1 (basic_block bb, bitmap work, bitmap old_conflicts)
+add_scope_conflicts_1 (basic_block bb, bitmap work, bool for_conflict)
 {
   edge e;
   edge_iterator ei;
@@ -483,7 +482,7 @@ add_scope_conflicts_1 (basic_block bb, b
}
   else if (!is_gimple_debug (stmt))
{
- if (old_conflicts
+ if (for_conflict
   visit == visit_op)
{
  /* If this is the first real instruction in this BB we need
@@ -491,27 +490,16 @@ add_scope_conflicts_1 (basic_block bb, b
 Unlike classical liveness for named objects we can't
 rely on seeing a def/use of the names we're interested in.
 There might merely be indirect loads/stores.  We'd not add any
-conflicts for such partitions.  We know that we generated
-conflicts between all partitions in old_conflicts already,
-so we need to generate only the new ones, avoiding to
-repeatedly pay the O(N^2) cost for each basic block.  */
+conflicts for such partitions.  */
  bitmap_iterator bi;
  unsigned i;
-
- EXECUTE_IF_AND_COMPL_IN_BITMAP (work, old_conflicts, 0, i, bi)
+ EXECUTE_IF_SET_IN_BITMAP (work, 0, i, bi)
{
  unsigned j;
  bitmap_iterator bj;
- /* First the conflicts between new and old_conflicts.  */
- EXECUTE_IF_SET_IN_BITMAP (old_conflicts, 0, j, bj)
-   add_stack_var_conflict (i, j);
- /* Then the conflicts between only the new members.  */
- EXECUTE_IF_AND_COMPL_IN_BITMAP (work, old_conflicts, i + 1,
- j, bj)
+ EXECUTE_IF_SET_IN_BITMAP (work, i + 1, j, bj)
add_stack_var_conflict (i, j);
}
- /* And remember for the next basic block.  */
- bitmap_ior_into (old_conflicts, work);
  visit = visit_conflict;
}
  walk_stmt_load_store_addr_ops (stmt, work, visit, visit, visit);
@@ -528,7 +516,6 @@ add_scope_conflicts (void)
   basic_block bb;
   bool changed;
   bitmap work = BITMAP_ALLOC (NULL);
-  bitmap old_conflicts;
 
   /* We approximate the live range of a stack variable by taking the first
  mention of its name as starting point(s), and by the end-of-scope
@@ -550,18 +537,15 @@ add_scope_conflicts (void)
   FOR_EACH_BB (bb)
  

Re: [ C frontend ] add support for builtins that take signed and unsigned md types

2012-01-23 Thread Mike Stump
On Jan 23, 2012, at 3:00 AM, Richard Guenther wrote:
 So, yes, please have only one loop.

Updated patch included.

Ok?



gcc-1.diffs.patch
Description: Binary data


[C++ Patch] PR 51398

2012-01-23 Thread Paolo Carlini

Hi,

a small diagnostic regression. Normally, when we do 'TREE_VALUE 
(TREE_VEC_ELT (*parms' we check for error_mark_node, because that's what 
we store for erroneous parameters: doing that  here too avoids the ICE. 
Tested x86_64-linux.


Thanks,
Paolo.

/
/cp
2012-01-23  Paolo Carlini  paolo.carl...@oracle.com

PR c++/51398
* pt.c (parameter_of_template_p): Skip error_mark_node parameters.

/testsuite
2012-01-23  Paolo Carlini  paolo.carl...@oracle.com

PR c++/51398
* g++.dg/template/crash111.C: New.
Index: testsuite/g++.dg/template/crash111.C
===
--- testsuite/g++.dg/template/crash111.C(revision 0)
+++ testsuite/g++.dg/template/crash111.C(revision 0)
@@ -0,0 +1,6 @@
+// PR c++/51398
+
+templatevoid, int N struct A   // { dg-error not a valid type }
+{
+  static const int i = N;
+};
Index: cp/pt.c
===
--- cp/pt.c (revision 183438)
+++ cp/pt.c (working copy)
@@ -8157,6 +8157,9 @@ parameter_of_template_p (tree parm, tree templ)
   for (i = 0; i  TREE_VEC_LENGTH (parms); ++i)
 {
   tree p = TREE_VALUE (TREE_VEC_ELT (parms, i));
+  if (p == error_mark_node)
+   continue;
+
   if (parm == p
  || (DECL_INITIAL (parm)
   DECL_INITIAL (parm) == DECL_INITIAL (p)))


[patch] fix TM clone drops at LTO time

2012-01-23 Thread Aldy Hernandez
While working on PR51698, I've noticed the LTO/TM rabbit hole goes much 
deeper.


The compiler is dropping transactional clones with -flto because the 
externally_visible bit is unset for clones.  This is so because 
cgraph_copy_node_for_versioning unconditionally zaps it.  I have fixed 
the TM infrastructure to set the bit on the clones if the original 
version had it set.


This patch will be needed to get PR51698 and LTO working with TM.

OK?

* trans-mem.c (ipa_tm_create_version): Set externally_visible.
(ipa_tm_create_version_alias): Same.

Index: testsuite/gcc.dg/tm/lto-1.c
===
--- testsuite/gcc.dg/tm/lto-1.c (revision 0)
+++ testsuite/gcc.dg/tm/lto-1.c (revision 0)
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options -fgnu-tm -flto } */
+
+__attribute__((transaction_safe))
+void foo() 
+{
+}
+
+/* { dg-final { scan-assembler ZGTt3foo } } */
Index: trans-mem.c
===
--- trans-mem.c (revision 183244)
+++ trans-mem.c (working copy)
@@ -4221,7 +4221,7 @@ struct create_version_alias_info
   tree new_decl;
 };
 
-/* A subrontine of ipa_tm_create_version, called via
+/* A subroutine of ipa_tm_create_version, called via
cgraph_for_node_and_aliases.  Create new tm clones for each of
the existing aliases.  */
 static bool
@@ -4261,6 +4261,7 @@ ipa_tm_create_version_alias (struct cgra
 
   new_node = cgraph_same_body_alias (NULL, new_decl, info-new_decl);
   new_node-tm_clone = true;
+  new_node-local.externally_visible = 
info-old_node-local.externally_visible;
   /* ?? Do not traverse aliases here.  */
   get_cg_data (node, false)-clone = new_node;
 
@@ -4296,6 +4297,7 @@ ipa_tm_create_version (struct cgraph_nod
 DECL_COMDAT_GROUP (new_decl) = tm_mangle (DECL_COMDAT_GROUP (old_decl));
 
   new_node = cgraph_copy_node_for_versioning (old_node, new_decl, NULL, NULL);
+  new_node-local.externally_visible = old_node-local.externally_visible;
   new_node-lowered = true;
   new_node-tm_clone = 1;
   get_cg_data (old_node, true)-clone = new_node;



Re: [C++ Patch] PR 51398

2012-01-23 Thread Jason Merrill

OK.

Jason


Re: [patch] fix TM clone drops at LTO time

2012-01-23 Thread Richard Henderson
On 01/24/2012 04:16 AM, Aldy Hernandez wrote:
   * trans-mem.c (ipa_tm_create_version): Set externally_visible.
   (ipa_tm_create_version_alias): Same.

Ok.

r~


[v3] Don't XFAIL 22_locale/num_put/put/*char/14220.cc on 32-bit Solaris 10/x86

2012-01-23 Thread Rainer Orth
I'm currently seeing two XPASSes in 32-bit Solaris 10/x86 libstdc++
testresults:

XPASS: 22_locale/num_put/put/char/14220.cc execution test
XPASS: 22_locale/num_put/put/wchar_t/14220.cc execution test

It turned out that the libc bug which caused those tests to be xfailed
has been fixed in Solaris 10 Update 10, so I'm removing the xfail to
accomodate this.

Tested with the appropriate runtest invocations on i386-pc-solaris2.10
and i386-pc-solaris2.9, installed on mainline.

Rainer


2012-01-23  Rainer Orth  r...@cebitec.uni-bielefeld.de

* testsuite/22_locale/num_put/put/char/14220.cc: Don't xfail on
32-bit Solaris 10/x86.
* testsuite/22_locale/num_put/put/wchar_t/14220.cc: Likewise.

# HG changeset patch
# Parent 7c02309d42d500d0d71db21c174ca4880f38f6b8
Don't XFAIL 22_locale/num_put/put/*char/14220.cc on 32-bit Solaris 10/x86

diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/char/14220.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/char/14220.cc
--- a/libstdc++-v3/testsuite/22_locale/num_put/put/char/14220.cc
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/char/14220.cc
@@ -1,6 +1,6 @@
 // 2004-04-30  Paolo Carlini  pcarl...@suse.de
 
-// Copyright (C) 2004, 2009, 2010, 2011 Free Software Foundation
+// Copyright (C) 2004, 2009, 2010, 2011, 2012 Free Software Foundation
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -19,12 +19,11 @@
 
 // 22.2.2.2.1  num_put members
 
-// On Solaris 9/x86 and 32-bit Solaris 10/x86, this test crashes in libc.
-// Inside libstdc++, we call sprintf like so:
+// On Solaris 9/x86 and 32-bit Solaris 10/x86 before update 10, this test
+// crashes in libc.  Inside libstdc++, we call sprintf like so:
 //   sprintf (buffer, %.*f, 1000, 1.0)
 // which crashes.
 // { dg-xfail-run-if  i?86-*-solaris2.9 }
-// { dg-xfail-run-if  { i?86-*-solaris2.10  ilp32 } }
 
 #include locale
 #include sstream
diff --git a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/14220.cc b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/14220.cc
--- a/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/14220.cc
+++ b/libstdc++-v3/testsuite/22_locale/num_put/put/wchar_t/14220.cc
@@ -1,6 +1,6 @@
 // 2004-04-30  Paolo Carlini  pcarl...@suse.de
 
-// Copyright (C) 2004, 2009, 2010 Free Software Foundation
+// Copyright (C) 2004, 2009, 2010, 2012 Free Software Foundation
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
 // software; you can redistribute it and/or modify it under the
@@ -23,11 +23,11 @@
 #include sstream
 #include testsuite_hooks.h
 
-// On Solaris 9 and 32-bit Solaris 10/x86, this test crashes in libc.  Inside
-// libstdc++, we call sprintf like so:
+// On Solaris 9 and 32-bit Solaris 10/x86 before update 10, this test crashes
+// in libc.  Inside libstdc++, we call sprintf like so:
 //   sprintf (buffer, %.*f, 1000, 1.0)
 // which crashes.
-// { dg-do run { xfail { i?86-*-solaris2.9 || { i?86-*-solaris2.10  ilp32 } } } } 
+// { dg-do run { xfail { i?86-*-solaris2.9 } } } 
 
 // libstdc++/14220
 void test01()


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


[Patch ARM ] Fix testism for PR45416 on ARM.

2012-01-23 Thread Ramana Radhakrishnan
Hi,

This fixes a failure that I see while running the tests for v7a-
because we don't handle ubfx. Also, this test is valid for arm32
configurations.

Committed to trunk .

cheers
Ramana

2012-01-23  Ramana Radhakrishnan  ramana.radhakrish...@linaro.org

   PR middle-end/45416
* gcc.dg/pr45416.c: Skip if Thumb1. Handle ubfx.
diff --git a/gcc/testsuite/gcc.dg/pr45416.c b/gcc/testsuite/gcc.dg/pr45416.c
index 1e57185..b8077dd 100644
--- a/gcc/testsuite/gcc.dg/pr45416.c
+++ b/gcc/testsuite/gcc.dg/pr45416.c
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-skip-if Skip for Thumb1. { { arm*-*-* }  { arm_thumb1_ok } } { * 
} {  } } */
 /* { dg-options -O2 } */
 
 int foo(long long a)
@@ -10,5 +11,5 @@ int foo(long long a)
 
 /* { dg-final { scan-assembler andl { target i?86-*-linux* x86_64-*-linux* } 
} }  */
 /* { dg-final { scan-assembler-not setne { target i?86-*-linux* 
x86_64-*-linux* } } } */
-/* { dg-final { scan-assembler and { target arm*-*-* } } } */
+/* { dg-final { scan-assembler and|ubfx  { target arm*-*-* } } } */
 /* { dg-final { scan-assembler-not moveq { target arm*-*-* } } } */


RFA: cgraph PATCH for c++/51812 (link failure with undefined/unneeded virtual function)

2012-01-23 Thread Jason Merrill
In this testcase, main doesn't call anything, so the inline functions in 
the classes can be optimized away, and we don't need the vtables or the 
virtual functions they refer to.  But cgraph_decide_is_function_needed 
wants to write out all static functions at -O0, which in this case was 
including the local thunk alias created by use_thunk.  Clearly we don't 
want to force such an alias out when it isn't needed, so I've added 
same-body aliases to the list of things that we don't need to emit.


OK for trunk?
commit 9185aab5caf951ae4d46c8c36c33c00445ee4424
Author: Jason Merrill ja...@redhat.com
Date:   Mon Jan 23 12:55:19 2012 -0500

	PR c++/51812
	* cgraphunit.c (cgraph_decide_is_function_needed): Don't always
	output static aliases.

diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 6ea40ce..8f96d38 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -195,6 +195,7 @@ cgraph_decide_is_function_needed (struct cgraph_node *node, tree decl)
  to change the behavior here.  */
   if (((TREE_PUBLIC (decl)
 	|| (!optimize
+	 !node-same_body_alias
 	 !DECL_DISREGARD_INLINE_LIMITS (decl)
 	 !DECL_DECLARED_INLINE_P (decl)
 	 !(DECL_CONTEXT (decl)
diff --git a/gcc/testsuite/g++.dg/inherit/covariant20.C b/gcc/testsuite/g++.dg/inherit/covariant20.C
new file mode 100644
index 000..cf7e196
--- /dev/null
+++ b/gcc/testsuite/g++.dg/inherit/covariant20.C
@@ -0,0 +1,10 @@
+// PR c++/51812
+// { dg-do link }
+
+class Object {
+  virtual Object* clone() const;
+};
+class DNA: virtual public Object {
+  virtual DNA* clone() const {return new DNA(*this);}
+};
+int main() { }


[PATCH] Fix expansion of BLKmode MEM_REF with non-addressable non-BLKmode base decl (PR middle-end/51895)

2012-01-23 Thread Jakub Jelinek
Hi!

Now that Richi has fixed up SRA not to pessimize code by changing non-BLK
mode arguments into their BLKmode subparts, I think it would be nice
to fix up also the expansion of the BLKmode MEM_REFs that have non-BLKmode
non-addressable base decl.  While this doesn't happen for this testcase
anymore, it rarely still occurs and I think it is wrong to expand
a BLKmode MEM_REF into a non-BLKmode rtx.  While the callers sometimes
can cope with it, often they can't.

Bootstrapped/regtested on x86_64-linux and i686-linux, bootstrapped on
powerpc64-linux (both --with-cpu=default32 and with real 64-bit
profiledbootstrap).  Ok for trunk?

2012-01-19  Jakub Jelinek  ja...@redhat.com

PR middle-end/51895
* expr.c (expand_expr_real_1): Handle BLKmode MEM_REF of
non-addressable non-BLKmode base correctly.

* g++.dg/opt/pr51895.C: New test.

--- gcc/expr.c.jj   2012-01-13 21:47:35.0 +0100
+++ gcc/expr.c  2012-01-19 13:12:14.218760812 +0100
@@ -9328,6 +9328,16 @@ expand_expr_real_1 (tree exp, rtx target
bftype = TREE_TYPE (base);
if (TYPE_MODE (TREE_TYPE (exp)) != BLKmode)
  bftype = TREE_TYPE (exp);
+   else
+ {
+   temp = assign_stack_temp (DECL_MODE (base),
+ GET_MODE_SIZE (DECL_MODE (base)),
+ 0);
+   store_expr (base, temp, 0, false);
+   temp = adjust_address (temp, BLKmode, offset);
+   set_mem_size (temp, int_size_in_bytes (TREE_TYPE (exp)));
+   return temp;
+ }
return expand_expr (build3 (BIT_FIELD_REF, bftype,
base,
TYPE_SIZE (TREE_TYPE (exp)),
--- gcc/testsuite/g++.dg/opt/pr51895.C.jj   2012-01-19 13:20:27.808899825 
+0100
+++ gcc/testsuite/g++.dg/opt/pr51895.C  2012-01-19 13:21:10.042655293 +0100
@@ -0,0 +1,25 @@
+// PR middle-end/51895
+// { dg-do compile }
+// { dg-options -O2 }
+
+struct S
+{
+  long a;
+  char b;
+  S () : a (0), b (0) {}
+  bool baz ();
+};
+
+__attribute__((noinline)) static bool
+bar (S x, S y)
+{
+  y = x;
+  return y.baz ();
+}
+
+bool
+foo (S x)
+{
+  S y;
+  return bar (x, y);
+}

Jakub


[PATCH] Fix up ppc64-linux profiledbootstrap - .toc section references in .debug_loc (PR target/51957)

2012-01-23 Thread Jakub Jelinek
Hi!

profiledbootstrap currently fails on powerpc64-linux (64-bit).  The problem
is that the linker errors on .toc section references from within
non-allocated sections.  Alan changed the linker some months ago to
not die with assertion failure, but error out on these, and the attached
testcase reduced from cp/parser.c during bootstrap shows that we still
can hit it in some cases.  The problem here is that var-tracking.c
(adjust_insn) isn't able to delegitimize it, because the UNSPEC_TOCREL
isn't added there to r2 register, but to a debug_expr (which only afterwards
is found to contain r2 value).  So the UNSPEC_TOCREL makes it through to
mem_loc_descriptor, where it is already properly delegitimized into a
(mem (symbol_ref (.LC0)) where .LC0 is a constant pool (.toc) symbol.
We in some places try to prefer avoid_constant_pool_reference values over
the mems, in this case avoid_constant_pool returns (symbol_ref w), which
is a non-local symbol which isn't const_ok_for_output though.  So
mem_loc_descriptor on the avoid_constant_pool_reference value fails and we
try the original (mem (symbol_ref (.LC0)) - on other targets this is still
useful, if we know the right value is in say some .got entry etc. and we
can reference that location from within the .debug_info, we win.
Unfortunately the ppc64 linker doesn't like this, so we need to reject
those.  The following patch adds a target hook and rejects there from
emitting into .debug_info/.debug_loc any SYMBOL_REFs that are in the
.toc section.

Bootstrapped/regtested on x86_64-linux and i686-linux, profiledbootstrapped
on powerpc64-linux (both --with-cpu=default32 and defaulting to 64-bit,
the last one failed without this patch), powerpc64-linux regtest is in
progress (but the testcase in the patch has been tested already to
fail without the patch and succeed with the patch).
Ok for trunk?

2012-01-23  Jakub Jelinek  ja...@redhat.com

PR target/51957
* target.def (const_not_ok_for_debug_p): New hook.
* doc/tm.texi.in (TARGET_CONST_NOT_OK_FOR_DEBUG_P): New hook
documentation.
* doc/tm.texi: Regenerated.
* dwarf2out.c (const_ok_for_output_1): If
targetm.const_not_ok_for_debug_p returns true, fail.
* config/rs6000/rs6000.c (rs6000_const_not_ok_for_debug_p): New
function.
(TARGET_CONST_NOT_OK_FOR_DEBUG_P): Redefine.

* gcc.dg/pr51957-1.c: New test.
* gcc.dg/pr51957-1.h: New file.
* gcc.dg/pr51957-2.c: New test.

--- gcc/target.def.jj   2012-01-20 12:35:16.0 +0100
+++ gcc/target.def  2012-01-23 13:14:52.601638343 +0100
@@ -1382,6 +1382,14 @@ DEFHOOK
  rtx, (rtx x),
  delegitimize_mem_from_attrs)
 
+/* Given an RTX, return true if it is not ok to emit it into debug info
+   section.  */
+DEFHOOK
+(const_not_ok_for_debug_p,
+ ,
+ bool, (rtx x),
+ hook_bool_rtx_false)
+
 /* Given an address RTX, say whether it is valid.  */
 DEFHOOK
 (legitimate_address_p,
--- gcc/doc/tm.texi.in.jj   2012-01-20 12:35:10.0 +0100
+++ gcc/doc/tm.texi.in  2012-01-23 13:27:19.544241676 +0100
@@ -5567,6 +5567,11 @@ the semantics of these opaque @code{UNSP
 into their original form.
 @end deftypefn
 
+@hook TARGET_CONST_NOT_OK_FOR_DEBUG_P
+This hook should return true if @var{x} should not be emitted into
+debug sections.
+@end deftypefn
+
 @hook TARGET_CANNOT_FORCE_CONST_MEM
 This hook should return true if @var{x} is of a form that cannot (or
 should not) be spilled to the constant pool.  @var{mode} is the mode
--- gcc/doc/tm.texi.jj  2012-01-20 12:35:10.0 +0100
+++ gcc/doc/tm.texi 2012-01-23 13:27:33.0 +0100
@@ -5631,6 +5631,11 @@ the semantics of these opaque @code{UNSP
 into their original form.
 @end deftypefn
 
+@deftypefn {Target Hook} bool TARGET_CONST_NOT_OK_FOR_DEBUG_P (rtx @var{x})
+This hook should return true if @var{x} should not be emitted into
+debug sections.
+@end deftypefn
+
 @deftypefn {Target Hook} bool TARGET_CANNOT_FORCE_CONST_MEM (enum machine_mode 
@var{mode}, rtx @var{x})
 This hook should return true if @var{x} is of a form that cannot (or
 should not) be spilled to the constant pool.  @var{mode} is the mode
--- gcc/dwarf2out.c.jj  2012-01-22 16:02:10.0 +0100
+++ gcc/dwarf2out.c 2012-01-23 13:58:09.887380014 +0100
@@ -10683,6 +10683,13 @@ const_ok_for_output_1 (rtx *rtlp, void *
   return 1;
 }
 
+  if (targetm.const_not_ok_for_debug_p (rtl))
+{
+  expansion_failed (NULL_TREE, rtl,
+   Expression rejected for debug by the backend.\n);
+  return 1;
+}
+
   if (GET_CODE (rtl) != SYMBOL_REF)
 return 0;
 
--- gcc/config/rs6000/rs6000.c.jj   2012-01-22 16:02:10.0 +0100
+++ gcc/config/rs6000/rs6000.c  2012-01-23 13:25:05.092031129 +0100
@@ -1106,6 +1106,7 @@ static rtx rs6000_debug_legitimize_addre
 static rtx rs6000_legitimize_tls_address (rtx, enum tls_model);
 static void rs6000_output_dwarf_dtprel (FILE *, int, rtx) ATTRIBUTE_UNUSED;
 static rtx 

[testsuite] Avoid assuming argc != 0

2012-01-23 Thread Richard Sandiford
gcc.c-torture/execute/scal-to-vec1.c uses argc as an easy way of injecting
a runtime value into a constructor.  The test goes on to do divide by this
value, so it cannot be zero.

This causes problems on embedded targets that don't provide a command line,
and that instead set argc to 0.

One fix is attached.  Another would be to read from a volatile variable
that has been initialised to 1.  Other possibilities exist too of course.

Tested on mipsisa64-elf.  OK to install?

Richard


gcc/testsuite/
* gcc.c-torture/execute/scal-to-vec1.c (main): Allow argc to be 0.

Index: gcc/testsuite/gcc.c-torture/execute/scal-to-vec1.c
===
--- gcc/testsuite/gcc.c-torture/execute/scal-to-vec1.c  2012-01-23 
19:05:52.0 +
+++ gcc/testsuite/gcc.c-torture/execute/scal-to-vec1.c  2012-01-23 
19:05:59.0 +
@@ -30,7 +30,7 @@ #define fvec_2 (vector(4, float)){2., 2.
 #define dvec_2 (vector(2, double)){2., 2.}
 
 
-vector(8, short) v0 = {argc, 1,2,3,4,5,6,7};
+vector(8, short) v0 = {argc | 1, 1,2,3,4,5,6,7};
 vector(8, short) v1;
 
 vector(4, float) f0 = {1., 2., 3., 4.};


Re: [testsuite] Avoid assuming argc != 0

2012-01-23 Thread Mike Stump
On Jan 23, 2012, at 11:13 AM, Richard Sandiford wrote:
 One fix is attached.  Another would be to read from a volatile variable
 that has been initialised to 1.  Other possibilities exist too of course.
 
 Tested on mipsisa64-elf.  OK to install?

Ok.  I have a preference for volatile (clearer intent)...


RFA: fix PR 51649

2012-01-23 Thread Tom Tromey
This patch fixes some pretty-printer bugs pointed out in PR 51649.

The bug in the PR is that the pretty-printers don't work if you build
with --enable-symvers=gnu-versioned-namespace.

This patch adds test cases for all the changes I made.

I derived most of the information here from reading c++config, then
going through the existing printers one-by-one to see how they are
implemented in the various modes.

Still missing are tests for parallel and profile modes.

I wasn't sure whether we need a printer for the stuff in vstring.h.
Anybody know?

The old code referred to a __norm namespace.  I only found a single
instance of this in the tree, which seemed to indicate it is a
compatibility thing.  So, I ignored it.  (I think that if there is a
problem here we should start with a test that shows it...)

I built and tested this with --enable-symvers=gnu-versioned-namespace
and with the default on x86-64 Fedora 15.

I'm sufficiently out of the loop gcc-wise that I will need some advice
as to whether this can go in immediately or whether it must wait for
some other stage.

Ok?

Tom

2012-01-23  Tom Tromey  tro...@redhat.com

PR libstdc++/51649:
* testsuite/libstdc++-prettyprinters/debug.cc: New file.
* testsuite/lib/gdb-test.exp (regexp-test): New proc.
(note-test): Update.
(gdb-test): Handle regexp tests.  Add some logging.
* testsuite/libstdc++-prettyprinters/simple.cc: Compile with -O0.
(placeholder, use): Remove.
(main): Add tests for deque, list, map, and set iterators.  Add
tests for slist and slist iterator.
* testsuite/libstdc++-prettyprinters/48362.cc (main): Handle __7
namespace.
* python/libstdcxx/v6/printers.py (StdListPrinter.children): Use
the type's _Node typedef.
(StdListIteratorPrinter.to_string): Change how node type is
computed.
(StdSlistPrinter.children): Use the type's _Node typedef.
(StdSlistIteratorPrinter.to_string): Likewise.
(StdRbtreeIteratorPrinter.to_string): Use the type's _Link_type
typedef.
(StdMapPrinter.children): Change how the node's type is computed.
(StdSetPrinter.children): Likewise.
(StdForwardListPrinter.children): Use the type's _Node typedef.
(Printer.add_version): New method.
(Printer.add_container): New method.
(build_libstdcxx_dictionary): Handle __7 and __cxx1998
namespaces.
(find_type): New function.

Index: python/libstdcxx/v6/printers.py
===
--- python/libstdcxx/v6/printers.py (revision 183449)
+++ python/libstdcxx/v6/printers.py (working copy)
@@ -1,6 +1,6 @@
 # Pretty-printers for libstc++.
 
-# Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+# Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -26,6 +26,25 @@
 except ImportError:
 _use_gdb_pp = False
 
+# Starting with the type ORIG, search for the member type NAME.  This
+# handles searching upward through superclasses.  This is needed to
+# work around http://sourceware.org/bugzilla/show_bug.cgi?id=13615.
+def find_type(orig, name):
+typ = orig.strip_typedefs()
+while True:
+search = str(typ) + '::' + name
+try:
+return gdb.lookup_type(search)
+except RuntimeError:
+pass
+# The type was not found, so try the superclass.  We only need
+# to check the first superclass, so we don't bother with
+# anything fancier here.
+field = typ.fields()[0]
+if not field.is_base_class:
+raise ValueError, Cannot find type %s::%s % (str(orig), name)
+typ = field.type
+
 class StdPointerPrinter:
 Print a smart pointer of some kind
 
@@ -76,15 +95,8 @@
 self.val = val
 
 def children(self):
-itype = self.val.type.template_argument(0)
-# If the inferior program is compiled with -D_GLIBCXX_DEBUG
-# some of the internal implementation details change.
-if self.typename == std::list:
-nodetype = gdb.lookup_type('std::_List_node%s' % itype).pointer()
-elif self.typename == std::__debug::list:
-nodetype = gdb.lookup_type('std::__norm::_List_node%s' % 
itype).pointer()
-else:
-raise ValueError, Cannot cast list node for list printer.
+nodetype = find_type(self.val.type, '_Node')
+nodetype = nodetype.strip_typedefs().pointer()
 return self._iterator(nodetype, self.val['_M_impl']['_M_node'])
 
 def to_string(self):
@@ -100,15 +112,8 @@
 self.typename = typename
 
 def to_string(self):
-itype = self.val.type.template_argument(0)
-# If the inferior program is compiled with -D_GLIBCXX_DEBUG
-   

Re: [PATCH] Fix up ppc64-linux profiledbootstrap - .toc section references in .debug_loc (PR target/51957)

2012-01-23 Thread Jason Merrill

OK.

Jason


Re: Continue strict-volatile-bitfields fixes

2012-01-23 Thread DJ Delorie

 and I think applying strict-volatile-bitfields to enums is probably
 meaningless.

MCU vendors would disagree.  If a location is volatile, it's most
likely hardware, and must be accessed in the user-specified way.
Randomly accessing adjacent locations could cause system failure.


Re: [RFC combine] PR48308 - Fix issue with missing(?) LOG_LINKS

2012-01-23 Thread Eric Botcazou
 Or not :( We really shouldn't use SUBST there as it only deals with
 rtx *  It appeared better to invent a new SUBST for links given that
 the type of this expression is struct insn_link rather than rtx * (Doh
 !)  I did think about hacking up a local flag but somehow like this
 version better.

OK, I forgot that LOG_LINKS weren't RTX.

 It's survived a bootstrap and testrun with no regressions for
 c,c++,fortran,ada on one of the power7 machines for
 powerpc64-unknown-linux-gnu in the compile farm. I'll put it through
 it's paces for trunk (arm-linux-gnueabi / x86_64) and 4.6 (modulo API
 changes for alloc_insn_link) if you think this looks better.

Sure, that's clearly better.

 2012-01-23  Ramana Radhakrishnan  ramana.radhakrish...@linaro.org

 PR rtl-optimization/48308
 * combine.c (do_SUBST_LINK): Declare and define.
 (SUBST_LINK): New.
 (try_combine): Handle LOG_LINKS for dummy i1 case.

You also need to document the changes made to enum undo_kind, struct undo, 
do_SUBST and undo_all.  OK with these changes.

-- 
Eric Botcazou


[PATCH] Shrink .debug_ranges section by ~22.5% (PR debug/51902)

2012-01-23 Thread Jakub Jelinek
Hi!

This patch shrinks .debug_ranges section in cc1plus (and probably most of
other binaries) by ~ 22.5% by removing redundancies in the ranges.
If say a lexical block or inlined subroutine covers the same instruction
as its supercontext scope, they can share .debug_range offsets instead of
adding yet another set of ranges.  This patch handles also the case where
the child scope only covers the last two or more ranges of the supercontext
scope, in that case DW_AT_ranges can point somewhere into the middle of
supercontext ranges.  dwarf2out.c alone doesn't have information where
ranges start and end and if they start/end in adjacent locations, it has
has BLOCK_NUMBERs of the fragments for which labels are emitted.

So this patch introduces a new bit in BLOCK, BLOCK_SAME_RANGE, which,
after it is computed by reorder_blocks and its helpers, indicates that
the particular BLOCK covers the same ranges as its BLOCK_SUPERCONTEXT
(if the length of their BLOCK_FRAGMENT_CHAIN chain is the same) or
that all N fragments of BLOCK cover the last N fragments of
BLOCK_SUPERCONTEXT.  dwarf2out.c then just looks up the parent supercontext,
verifies that the ranges table contains the right data and adds DW_AT_ranges
with corresponding offset, without adding any new content into
.debug_ranges.

BLOCK_SAME_RANGE is first set on each individual fragment (where it
says that there were no non-note insns or other NOTE_INSN_BLOCK_{BEG,END}
in between the supercontext NOTE_INSN_BLOCK_BEG and child
NOTE_INSN_BLOCK_BEG and later in between child NOTE_INSN_BLOCK_END
and supercontext NOTE_INSN_BLOCK_END.  Later on during
blocks_nreverse_all we clear BLOCK_SAME_RANGE bit if the next fragment
exists and has that bit cleared (that way we can just check BLOCK_SAME_RANGE
on the fragment origin BLOCK).  Unfortunately testing of that revealed
that this wasn't sufficient, e.g. if supercontext range had 3 ranges
and child range was equal to the first and last fragment thereof, but not
the middle one, we'd misoptimize it.  So, in order to detect even that
the patch during reorder_blocks_1 doesn't set BLOCK_SUPERCONTEXT to
the supercontext's fragment origin for all fragments, but instead to the
corresponding supercontext fragment it is contained within.  During
blocks_nreverse_all we then additionally clear BLOCK_SAME_RANGE if the
fragment BLOCK_SUPERCONTEXT's BLOCK_FRAGMENT_ORIGIN isn't equal
to its BLOCK_FRAGMENT_ORIGIN's BLOCK_SUPERCONTEXT.  Finally
BLOCK_SUPERCONTEXT is adjusted to point to supercontext fragment origin,
so after reorder_blocks it has the all meaning for all fragments.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for stage 1?

2012-01-23  Jakub Jelinek  ja...@redhat.com

PR debug/51902
* tree.h (BLOCK_SAME_RANGE): Define.
* function.c (block_fragments_nreverse): Clear BLOCK_SAME_RANGE
if BLOCK_FRAGMENT_CHAIN is non-NULL, but has it cleared.
Also clear BLOCK_SAME_RANGE if fragment chain's supercontext fragment
isn't equal to supercontext fragment's fragment chain.
Adjust BLOCK_SUPERCONTEXT to point to supercontext fragment's
fragment origin.
(blocks_nreverse_all): Likewise.
(reorder_blocks_1): Compute BLOCK_SAME_RANGE bits.  Set
BLOCK_SUPERCONTEXT to supercontext fragment instead of
supercontext fragment's fragment origin.
* dwarf2out.c (add_high_low_attributes): If stmt has the same
range as its parent (or parents thereof etc.), use the parent's
DW_AT_ranges value instead of creating a new .debug_ranges range.

--- gcc/tree.h.jj   2012-01-22 16:01:52.549668218 +0100
+++ gcc/tree.h  2012-01-23 15:07:26.738058032 +0100
@@ -2088,6 +2088,9 @@ struct GTY(()) tree_omp_clause {
 #define BLOCK_ABSTRACT_ORIGIN(NODE) (BLOCK_CHECK (NODE)-block.abstract_origin)
 #define BLOCK_ABSTRACT(NODE) (BLOCK_CHECK (NODE)-block.abstract_flag)
 
+/* True if BLOCK has the same ranges as its BLOCK_SUPERCONTEXT.  */
+#define BLOCK_SAME_RANGE(NODE) (BLOCK_CHECK (NODE)-base.nameless_flag)
+
 /* An index number for this block.  These values are not guaranteed to
be unique across functions -- whether or not they are depends on
the debugging output format in use.  */
--- gcc/function.c.jj   2012-01-22 16:01:52.678667459 +0100
+++ gcc/function.c  2012-01-23 15:54:06.427002523 +0100
@@ -4005,18 +4005,35 @@ generate_setjmp_warnings (void)
 
 
 /* Reverse the order of elements in the fragment chain T of blocks,
-   and return the new head of the chain (old last element).  */
+   and return the new head of the chain (old last element).
+   In addition to that clear BLOCK_SAME_RANGE flags when needed
+   and adjust BLOCK_SUPERCONTEXT from the super fragment to
+   its super fragment origin.  */
 
 static tree
 block_fragments_nreverse (tree t)
 {
-  tree prev = 0, block, next;
+  tree prev = 0, block, next, prev_super = 0;
+  tree super = BLOCK_SUPERCONTEXT (t);
+  if (BLOCK_FRAGMENT_ORIGIN (super))
+super = 

Re: [PATCH, Ada] Illegal program not detected, self renames, PR15846

2012-01-23 Thread Arnaud Charlet
 ChangeLog:
 *  gcc/ada/exp_disp.adb (Make_DT):
Check if flag Is_Dispatching_Operation is True before
getting DT_Position flag ,
present in function and procedure entities which are
dispatching
 
 *  gcc/ada/sem_ch8.adb (Analyze_Subprogram_Renaming):
Added check if renaming entity package is the same as
 renaming_declaration package,
   in case if both operations has the same names.

The patch for sem_ch8 is correct although we will incorporate a variant
that has a minor change that will leave things a bit clearer, stay tuned.

Regarding the proposed patch for exp_disp, it does not add any new
useful functionality apparently.

By the way, do you have a copyright assignment in place with the FSF?

Arno


Re: [Patch, Fortran] PR 51948 - Fix variable check for MOVE_ALLOC

2012-01-23 Thread Paul Richard Thomas
Dear Tobias,


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


OK for trunk

Thanks for the patch!

Paul


C++ PATCH for c++/51930 (instantiation hidden despite visibility attribute)

2012-01-23 Thread Jason Merrill
DECL_VISIBILITY_SPECIFIED is set if the decl occurs after a #pragma 
visibility or within a namespace with explicit visibility.  In these 
cases, we want the visibility of template arguments to be able to 
further restrict the visibility of template specializations.  But if the 
specialization itself has explicitly specified visibility, we should 
respect that.


This patch will also mean that an attribute on the template will 
override argument visibility, which I could go either way on.  But if 
this is a problem for users they can use a pragma instead.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit e3f4b4e6d7c54ec96c77aa3e36fe9d38b7922391
Author: Jason Merrill ja...@redhat.com
Date:   Mon Jan 23 14:31:23 2012 -0500

	PR c++/51930
	* decl2.c (determine_visibility): Check for visibility attribute
	on template specialization.

diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index f51790c..bdc962a 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -2177,8 +2177,14 @@ determine_visibility (tree decl)
 		? TYPE_TEMPLATE_INFO (TREE_TYPE (decl))
 		: DECL_TEMPLATE_INFO (decl));
   tree args = TI_ARGS (tinfo);
+  tree attribs = (TREE_CODE (decl) == TYPE_DECL
+		  ? TYPE_ATTRIBUTES (TREE_TYPE (decl))
+		  : DECL_ATTRIBUTES (decl));
   
-  if (args != error_mark_node)
+  if (args != error_mark_node
+	  /* Template argument visibility outweighs #pragma or namespace
+	 visibility, but not an explicit attribute.  */
+	   !lookup_attribute (visibility, attribs))
 	{
 	  int depth = TMPL_ARGS_DEPTH (args);
 	  tree pattern = DECL_TEMPLATE_RESULT (TI_TEMPLATE (tinfo));
diff --git a/gcc/testsuite/g++.dg/ext/visibility/template10.C b/gcc/testsuite/g++.dg/ext/visibility/template10.C
new file mode 100644
index 000..01108aa
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/visibility/template10.C
@@ -0,0 +1,16 @@
+// PR c++/51930
+// { dg-require-visibility }
+// { dg-options -fvisibility=hidden }
+// { dg-final { scan-not-hidden _Z8testfuncI3fooEvv } }
+
+struct foo { };
+
+templatetypename T
+__attribute__ ((visibility(default)))
+void testfunc();
+
+templatetypename T void testfunc() { }
+
+template
+__attribute__ ((visibility(default)))
+void testfuncfoo();


RE: [Patch,AVR,doc]: Fix some typos, add example.

2012-01-23 Thread Weddington, Eric


 -Original Message-
 From: Georg-Johann Lay 
 Sent: Monday, January 23, 2012 5:35 AM
 To: gcc-patches@gcc.gnu.org
 Cc: Weddington, Eric; Denis Chertykov
 Subject: [Patch,AVR,doc]: Fix some typos, add example.
 
 Besides fixing some typos, this patch adds an example that shows how
to
 access
 code located with attribute progmem.
 
 The example in AVR named address spaces is moved up and the note on
 offset
 limitation is removed.
 
 Ok to apply?
 

Change attrubute to attribute, and please commit.

Thanks,
Eric Weddington


Re: Comdat-aware code coverage data

2012-01-23 Thread Nathan Sidwell

On 01/20/12 22:41, Xinliang David Li wrote:

Nathan, I just noticed this path. This is a good improvement over the
existing scheme.

I see one potential problem with the patch -- different instances of
the same comdat function can potentially have different control flows
(due to differences in early inline, early optimizations in different
module contexts)  before profile counter allocation -- which means
making the profile counters 'comdat' can later cause coverage mismatch
problems during profile-use phase.


Right, I have an new patch that reenables the comdat-awareness, however there is 
one case I theorized about but couldn't generate a testcase for.  Your email 
convinced me to try harder, and I now have such a testcase that needs 
addressing.  Anyway, the tree-based coverage counters treat the per-function 
counters as-if they are function-scope static variables.  Hence inlining Foo 
into Baz will not add new counters to Baz but increment Foo's counters.  So you 
can't distinguish between different inlinings of Foo.  Of course optimizing 
Foo's inline instance in Baz may delete various basic blocks and so lead to 
non-increments.  However, for the purposes of profiling, the average behaviour 
over all inlinings in that translation unit is used.   As I recall the rtl-based 
counters didn't do this.


Anyway, with comdat-awareness, the case I need to address is a function Foo that 
is inlined in some places but not in others.  So there's a comdat Foo instance 
emitted.  That instance may or may not be selected by the linker.  If it is not 
selected, we still want to track the counter values for its inlinings in that 
TU.  If it is selected, we don't want to double count its counter values.  I 
need to think about this a bit, but have some ideas.



In this patch, fn data buffer is introduced. What is that for and how
does it work?


The intention is that the fn_info structure is in the same comdat group as the 
comdat function to which it refers.  Therefore, if the instance of fn_info in 
the executable will match the instance of the function to which it refers. 
However, each object file needs to generate coverage information for all the 
functions in that object file and correctly mark whether a comdat function in it 
was in the final link or not.  So its array of pointers to fn_info will name the 
fn_infos of all its functions.  For a comdat function, the slot will select the 
fn_info of some other TU.  The gcov_info back-pointer in each fn_info allows the 
gcov runtime to detect this case.


Does that help?

nathan


Re: [PATCH, Ada] Illegal program not detected, self renames, PR15846

2012-01-23 Thread Alexander Basov
24.01.2012 00:11, Arnaud Charlet пишет:
 ChangeLog:
 *  gcc/ada/exp_disp.adb (Make_DT):
Check if flag Is_Dispatching_Operation is True before
getting DT_Position flag ,
present in function and procedure entities which are
dispatching

 *  gcc/ada/sem_ch8.adb (Analyze_Subprogram_Renaming):
Added check if renaming entity package is the same as
 renaming_declaration package,
   in case if both operations has the same names.
 The patch for sem_ch8 is correct although we will incorporate a variant
 that has a minor change that will leave things a bit clearer, stay tuned.
Great!

 Regarding the proposed patch for exp_disp, it does not add any new
 useful functionality apparently.
The patch for exp_disp is related to renaming of predefined =
operation for tagged type.
without this patch I've got ICE on the following testcase:

package renaming5 is

   type T1 is tagged null record;

   function = (left, right : in T1) return Boolean
 renames renaming5.=;  -- { dg-error subprogram cannot rename itself }

end renaming5;

Also this patch is partially fixes PR32164:

package Pak1 is
   type T1 is tagged null record;
   function  Eq(X, Y : T1) return Boolean renames =;
   function Neq(X, Y : T1) return Boolean renames /=; -- line 4
end Pak1;

It fixes ICE, but incorrect message still exists: prefix of
Unrestricted_Access attribute cannot be intrinsic.
I will try to solve this problem a bit later.

 By the way, do you have a copyright assignment in place with the FSF?

No, I don't have it. What should I do?

 Arno


-- 
Best regards,
Alexander Basov





[PATCH] Fix for PR51879 - Missed tail merging with non-const/pure calls

2012-01-23 Thread Tom de Vries
Richard,
Jakub,

the following patch fixes PR51879.

Consider the following test-case:
...
int bar (int);
void baz (int);

void
foo (int y)
{
  int a;
  if (y == 6)
a = bar (7);
  else
a = bar (7);
  baz (a);
}
...

after compiling at -02, the representation looks like this before tail-merging:
...
  # BLOCK 3 freq:1991
  # PRED: 2 [19.9%]  (true,exec)
  # .MEMD.1714_7 = VDEF .MEMD.1714_6(D)
  # USE = nonlocal
  # CLB = nonlocal
  aD.1709_3 = barD.1703 (7);
  goto bb 5;
  # SUCC: 5 [100.0%]  (fallthru,exec)

  # BLOCK 4 freq:8009
  # PRED: 2 [80.1%]  (false,exec)
  # .MEMD.1714_8 = VDEF .MEMD.1714_6(D)
  # USE = nonlocal
  # CLB = nonlocal
  aD.1709_4 = barD.1703 (7);
  # SUCC: 5 [100.0%]  (fallthru,exec)

  # BLOCK 5 freq:1
  # PRED: 3 [100.0%]  (fallthru,exec) 4 [100.0%]  (fallthru,exec)
  # aD.1709_1 = PHI aD.1709_3(3), aD.1709_4(4)
  # .MEMD.1714_5 = PHI .MEMD.1714_7(3), .MEMD.1714_8(4)
  # .MEMD.1714_9 = VDEF .MEMD.1714_5
  # USE = nonlocal
  # CLB = nonlocal
  bazD.1705 (aD.1709_1);
  # VUSE .MEMD.1714_9
  return;
...

the patch allows aD.1709_4 to be value numbered to aD.1709_3, and .MEMD.1714_8
to .MEMD.1714_7, which enables tail-merging of blocks 4 and 5.

The patch makes sure non-const/pure call results (gimple_vdef and
gimple_call_lhs) are properly value numbered.

Bootstrapped and reg-tested on x86_64.

ok for stage1?

Thanks,
- Tom

2012-01-23  Tom de Vries  t...@codesourcery.com

PR tree-optimization/51879
tree-ssa-sccvn.c (visit_reference_op_call): Handle gimple_vdef.
(visit_use): Handle non-pure/const calls using visit_reference_op_call.

gcc.dg/pr51879.c: New test.
gcc.dg/pr51879-2.c: Same.
gcc.dg/pr51879-3.c: Same.
gcc.dg/pr51879-4.c: Same.
Index: gcc/tree-ssa-sccvn.c
===
--- gcc/tree-ssa-sccvn.c (revision 183325)
+++ gcc/tree-ssa-sccvn.c (working copy)
@@ -2591,6 +2591,7 @@ visit_reference_op_call (tree lhs, gimpl
   struct vn_reference_s vr1;
   tree result;
   tree vuse = gimple_vuse (stmt);
+  tree vdef = gimple_vdef (stmt);
 
   vr1.vuse = vuse ? SSA_VAL (vuse) : NULL_TREE;
   vr1.operands = valueize_shared_reference_ops_from_call (stmt);
@@ -2600,7 +2601,11 @@ visit_reference_op_call (tree lhs, gimpl
   result = vn_reference_lookup_1 (vr1, NULL);
   if (result)
 {
-  changed = set_ssa_val_to (lhs, result);
+  tree result_vdef = gimple_vdef (SSA_NAME_DEF_STMT (result));
+  if (vdef)
+	changed |= set_ssa_val_to (vdef, result_vdef);
+  changed |= set_ssa_val_to (lhs, result);
+
   if (TREE_CODE (result) == SSA_NAME
 	   VN_INFO (result)-has_constants)
 	VN_INFO (lhs)-has_constants = true;
@@ -2609,7 +2614,9 @@ visit_reference_op_call (tree lhs, gimpl
 {
   void **slot;
   vn_reference_t vr2;
-  changed = set_ssa_val_to (lhs, lhs);
+  if (vdef)
+	changed |= set_ssa_val_to (vdef, vdef);
+  changed |= set_ssa_val_to (lhs, lhs);
   vr2 = (vn_reference_t) pool_alloc (current_info-references_pool);
   vr2-vuse = vr1.vuse;
   vr2-operands = valueize_refs (create_reference_ops_from_call (stmt));
@@ -3359,8 +3366,10 @@ visit_use (tree use)
 	  /* ???  We should handle stores from calls.  */
 	  else if (TREE_CODE (lhs) == SSA_NAME)
 	{
+	  tree vuse = gimple_vuse (stmt);
 	  if (!gimple_call_internal_p (stmt)
-		   gimple_call_flags (stmt)  (ECF_PURE | ECF_CONST))
+		   (gimple_call_flags (stmt)  (ECF_PURE | ECF_CONST)
+		  || (vuse  SSA_VAL (vuse) != VN_TOP)))
 		changed = visit_reference_op_call (lhs, stmt);
 	  else
 		changed = defs_to_varying (stmt);
Index: gcc/testsuite/gcc.dg/pr51879-2.c
===
--- /dev/null (new file)
+++ gcc/testsuite/gcc.dg/pr51879-2.c (revision 0)
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options -O2 -fdump-tree-pre } */
+
+int bar (int);
+void baz (int);
+
+void
+foo (int y)
+{
+  int a;
+  if (y)
+baz (bar (7) + 6);
+  else
+baz (bar (7) + 6);
+}
+
+/* { dg-final { scan-tree-dump-times bar \\( 1 pre} } */
+/* { dg-final { scan-tree-dump-times baz \\( 1 pre} } */
+/* { dg-final { cleanup-tree-dump pre } } */
Index: gcc/testsuite/gcc.dg/pr51879.c
===
--- /dev/null (new file)
+++ gcc/testsuite/gcc.dg/pr51879.c (revision 0)
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options -O2 -fdump-tree-pre } */
+
+int bar (int);
+void baz (int);
+
+void
+foo (int y)
+{
+  int a;
+  if (y == 6)
+a = bar (7);
+  else
+a = bar (7);
+  baz (a);
+}
+
+/* { dg-final { scan-tree-dump-times bar \\( 1 pre} } */
+/* { dg-final { cleanup-tree-dump pre } } */
Index: gcc/testsuite/gcc.dg/pr51879-3.c
===
--- /dev/null (new file)
+++ gcc/testsuite/gcc.dg/pr51879-3.c (revision 0)
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options -O2 -fdump-tree-pre } */
+
+int 

Re: Continue strict-volatile-bitfields fixes

2012-01-23 Thread Bernd Schmidt
On 01/23/2012 08:51 PM, DJ Delorie wrote:
 
 and I think applying strict-volatile-bitfields to enums is probably
 meaningless.
 
 MCU vendors would disagree.  If a location is volatile, it's most
 likely hardware, and must be accessed in the user-specified way.
 Randomly accessing adjacent locations could cause system failure.

This is not an issue here. The optimization in question in stor-layout
tries to find out if a bitfield (volatile or not) is laid out in a way
that's equivalent to a natural machine mode. For example, a 2-byte
aligned 16 bit value can be HImode on most targets.

The earlier patch restricts this optimization for non-volatile bitfields
as well, on the grounds that an object may later be declared as volatile
even if the bitfield isn't declared volatile in the struct definition.

Strict-volatile-bitfields is concerned with the opposite case: ensuring
that an int x:8; is accessed only with int-sized accesses. My thought
was that this is probably pointless with enums, which I think aren't
usually thought of as a specific size unlike char/short/int. So, if we
see enum something x:8; we don't want to prevent the compiler from
treating this as a plain QImode non-bitfield member.


Bernd


Re: Comdat-aware code coverage data

2012-01-23 Thread Xinliang David Li
On Mon, Jan 23, 2012 at 12:52 PM, Nathan Sidwell nat...@acm.org wrote:
 On 01/20/12 22:41, Xinliang David Li wrote:

 Nathan, I just noticed this path. This is a good improvement over the
 existing scheme.

 I see one potential problem with the patch -- different instances of
 the same comdat function can potentially have different control flows
 (due to differences in early inline, early optimizations in different
 module contexts)  before profile counter allocation -- which means
 making the profile counters 'comdat' can later cause coverage mismatch
 problems during profile-use phase.


 Right, I have an new patch that reenables the comdat-awareness, however
 there is one case I theorized about but couldn't generate a testcase for.

One possible way to generate a test case is like the following -- bar
will be inlined into the instance of fooint in foo_1.cc, but not in
the one in foo_2.cc

foo.h
-

extern int bar ();
template typename T __attribute__((noinline)) T foo (T)
{
  return bar();
}

foo_1.cc
--

#include foo.h
int g;

__attribute__((always_inline)) int bar()
{
   if (g  10)
return 1;
  else
return 0;
}

int test_1 ()
{
   return fooint();
}


foo_2.cc


#include foo.h

int test_2 ()
{
   return fooint();
}


  Your email convinced me to try harder, and I now have such a testcase that
 needs addressing.  Anyway, the tree-based coverage counters treat the
 per-function counters as-if they are function-scope static variables.

I like this part of the change (splitting the counter array in a
module into per-function arrays) by itself -- it simplifies the
implementation and is much cleaner.

Hence
 inlining Foo into Baz will not add new counters to Baz but increment Foo's
 counters.  So you can't distinguish between different inlinings of Foo.

This is not true for early inlining. If Foo is inlined into Baz in
early inline pass, Foo's inline instance will have its own 'private'
copy of the profile counters 'embedded' in the caller's counter.

For ipa inlining,  the old implementation allows all inline instances
of 'foo' in the same module to share the same counters -- but they do
not share the counters with the out of line copy of 'foo' which is
defined in another module (and picked up by the linker).

Your original comdat aware implementation forces all inline instances
of 'foo' also share counters across modules. This however may not only
cause problems in profile-use pass, but also cause runtime problems in
profile collection run such as out of bound accesses..


  Of
 course optimizing Foo's inline instance in Baz may delete various basic
 blocks and so lead to non-increments.  However, for the purposes of
 profiling, the average behaviour over all inlinings in that translation unit
 is used.   As I recall the rtl-based counters didn't do this.

 Anyway, with comdat-awareness, the case I need to address is a function Foo
 that is inlined in some places but not in others.  So there's a comdat Foo
 instance emitted.  That instance may or may not be selected by the linker.
  If it is not selected, we still want to track the counter values for its
 inlinings in that TU.  If it is selected, we don't want to double count its
 counter values.  I need to think about this a bit, but have some ideas.

See above. I think the main problems is that comdat function Foo in
different TUs may have incompatible counter variables (due to cfg
difference) -- common incompatible variables via comdat may cause
problems.



 In this patch, fn data buffer is introduced. What is that for and how
 does it work?


 The intention is that the fn_info structure is in the same comdat group as
 the comdat function to which it refers.  Therefore, if the instance of
 fn_info in the executable will match the instance of the function to which
 it refers. However, each object file needs to generate coverage information
 for all the functions in that object file and correctly mark whether a
 comdat function in it was in the final link or not.  So its array of
 pointers to fn_info will name the fn_infos of all its functions.  For a
 comdat function, the slot will select the fn_info of some other TU.  The
 gcov_info back-pointer in each fn_info allows the gcov runtime to detect
 this case.


Yes I knew the intention after reading the code. See also my follow up
email about it --- I think it is necessary to track where the counter
variable is coming from (the key), but not buffering is not needed.


thanks,

David

 Does that help?

 nathan


[trans-mem] Do not instrument thread locals

2012-01-23 Thread Patrick Marlier

Hi,

I found that all thread local variables are instrumented with _ITM_W/R* 
calls whereas they should not be shared with other threads. This patch 
takes care of thread locals into requires_barrier and also adds the 
local save/restore for them. This patch also includes a testcase.


I did not fill any PR since I have already a patch for it but tell me if 
I have to.


Tested on x86_64-unknown-linux-gnu, ok for trunk?
Thanks.
--
Patrick Marlier.

ChangeLog
2012-01-23  Patrick Marlier  patrick.marl...@gmail.com

* trans-mem.c (requires_barrier): Do not instrument thread local
variables and emit save/restore for them.

testsuite/ChangeLog
2012-01-23  Patrick Marlier  patrick.marl...@gmail.com

* gcc.dg/tm/threadlocal-1.c: New test.

Index: testsuite/gcc.dg/tm/threadlocal-1.c
===
--- testsuite/gcc.dg/tm/threadlocal-1.c	(revision 0)
+++ testsuite/gcc.dg/tm/threadlocal-1.c	(revision 0)
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options -fgnu-tm -O -fdump-tree-tmedge } */
+__thread int notshared = 0;
+int shared = 0;
+
+int main()
+{
+  __transaction_atomic
+{
+  notshared++;
+  shared++;
+}
+  return notshared + shared;
+}
+/* { dg-final { scan-tree-dump-times tm_save.\[0-9_\]+ = notshared 1 tmedge } } */
+/* { dg-final { scan-tree-dump-times notshared = tm_save 1 tmedge } } */
+/* { dg-final { cleanup-tree-dump tmedge } } */
Index: trans-mem.c
===
--- trans-mem.c	(revision 183448)
+++ trans-mem.c	(working copy)
@@ -1,5 +1,5 @@
 /* Passes for transactional memory support.
-   Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
 
This file is part of GCC.
 
@@ -1488,7 +1488,18 @@ requires_barrier (basic_block entry_block, tree x,
 	}
 
   if (is_global_var (x))
-	return !TREE_READONLY (x);
+	{
+	  if (DECL_THREAD_LOCAL_P (x))
+	goto thread_local;
+	  if (DECL_HAS_VALUE_EXPR_P (x))
+	{
+	  tree value = get_base_address (DECL_VALUE_EXPR (x));
+
+	  if (value  DECL_P (value)  DECL_THREAD_LOCAL_P (value))
+		goto thread_local;
+	}
+	  return !TREE_READONLY (x);
+	}
   if (/* FIXME: This condition should actually go below in the
 	 tm_log_add() call, however is_call_clobbered() depends on
 	 aliasing info which is not available during
@@ -1498,17 +1509,14 @@ requires_barrier (basic_block entry_block, tree x,
 	 lower_sequence_tm altogether.  */
 	  needs_to_live_in_memory (x))
 	return true;
-  else
-	{
-	  /* For local memory that doesn't escape (aka thread private
-	 memory), we can either save the value at the beginning of
-	 the transaction and restore on restart, or call a tm
-	 function to dynamically save and restore on restart
-	 (ITM_L*).  */
-	  if (stmt)
-	tm_log_add (entry_block, orig, stmt);
-	  return false;
-	}
+thread_local:
+  /* For local memory that doesn't escape (aka thread private memory), 
+	 we can either save the value at the beginning of the transaction and
+	 restore on restart, or call a tm function to dynamically save and
+	 restore on restart (ITM_L*). */
+  if (stmt)
+	tm_log_add (entry_block, orig, stmt);
+  return false;
 
 default:
   return false;


[v3] libstdc++/49829

2012-01-23 Thread Benjamin Kosnik

This modularizes the libstdc++ sources such that the resulting library
binaries are now composed of three convenience libraries. In short:

libstdc++.[a, so] == libc++98 + libc++11 + libsupc++

Arguably, this is the way it should have been done all along. And
certainly since the C++11 support hit 5 or more files

In any case, this helps resolve the knots gcc/libstdc++ config and
build get themselves into when gcc requires static libstdc++, but the
build says no-static (--disable-static). 

There are some warts that need addressing by a proper build maintainer.

1) dependency tracking for libstdc++convenience.la. Help. It's not
installed and not really used in most cases, so this isn't crucial.
But, perfection is a cruel mistress, and I'd like to get this right.

2) I suppose the docs should be updated to reflect this. To-do.

I'm trying to get over my fear of using git for check-ins that require
a bunch of renames etc etc. So, this is my first one of these. If I did
it all wrong, please let me know gently and I'll try to fix it.

This patch is huge due to all the re-names. Please check out the patch
posted in bugzilla instead.

best,
benjamin

tested x86-64/linux
tested x86-64/linux -x- arm-eabi
tested x86-64/linux -x- cris-elf


Go patch committed: Error if variable defined but not used

2012-01-23 Thread Ian Lance Taylor
In Go it is an error if a variable is defined but not used.  This patch
implements this error in gccgo.  This required some tweaks to gccgo
specific changes in libgo.  It also required updating various tests in
the testsuite.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

Index: gcc/go/gofrontend/gogo.cc
===
--- gcc/go/gofrontend/gogo.cc	(revision 183374)
+++ gcc/go/gofrontend/gogo.cc	(working copy)
@@ -1036,6 +1036,23 @@ Gogo::add_named_object(Named_object* no)
   this-current_bindings()-add_named_object(no);
 }
 
+// Mark all local variables used.  This is used when some types of
+// parse error occur.
+
+void
+Gogo::mark_locals_used()
+{
+  for (Open_functions::iterator pf = this-functions_.begin();
+   pf != this-functions_.end();
+   ++pf)
+{
+  for (std::vectorBlock*::iterator pb = pf-blocks.begin();
+	   pb != pf-blocks.end();
+	   ++pb)
+	(*pb)-bindings()-mark_locals_used();
+}
+}
+
 // Record that we've seen an interface type.
 
 void
@@ -1731,6 +1748,15 @@ Check_types_traverse::variable(Named_obj
 		 reason.c_str());
 	  var-clear_init();
 	}
+  else if (!var-is_used()
+	!var-is_global()
+	!var-is_parameter()
+	!var-is_receiver()
+	!var-type()-is_error()
+	(init == NULL || !init-is_error_expression())
+	!Lex::is_invalid_identifier(named_object-name()))
+	error_at(var-location(), %qs declared and not used,
+		 named_object-message_name().c_str());
 }
   return TRAVERSE_CONTINUE;
 }
@@ -2973,6 +2999,7 @@ Function::closure_var()
   Type* struct_type = Type::make_struct_type(sfl, loc);
   Variable* var = new Variable(Type::make_pointer_type(struct_type),
    NULL, false, true, false, loc);
+  var-set_is_used();
   this-closure_var_ = Named_object::make_variable(closure, NULL, var);
   // Note that the new variable is not in any binding contour.
 }
@@ -3693,7 +3720,7 @@ Variable::Variable(Type* type, Expressio
 		   Location location)
   : type_(type), init_(init), preinit_(NULL), location_(location),
 backend_(NULL), is_global_(is_global), is_parameter_(is_parameter),
-is_receiver_(is_receiver), is_varargs_parameter_(false),
+is_receiver_(is_receiver), is_varargs_parameter_(false), is_used_(false),
 is_address_taken_(false), is_non_escaping_address_taken_(false),
 seen_(false), init_is_lowered_(false), type_from_init_tuple_(false),
 type_from_range_index_(false), type_from_range_value_(false),
@@ -4877,6 +4904,19 @@ Bindings::define_type(Named_object* no, 
   this-named_objects_.push_back(no);
 }
 
+// Mark all local variables as used.  This is used for some types of
+// parse error.
+
+void
+Bindings::mark_locals_used()
+{
+  for (std::vectorNamed_object*::iterator p = this-named_objects_.begin();
+   p != this-named_objects_.end();
+   ++p)
+if ((*p)-is_variable())
+  (*p)-var_value()-set_is_used();
+}
+
 // Traverse bindings.
 
 int
Index: gcc/go/gofrontend/gogo.h
===
--- gcc/go/gofrontend/gogo.h	(revision 183340)
+++ gcc/go/gofrontend/gogo.h	(working copy)
@@ -344,6 +344,11 @@ class Gogo
   void
   add_named_object(Named_object*);
 
+  // Mark all local variables in current bindings as used.  This is
+  // used when there is a parse error to avoid useless errors.
+  void
+  mark_locals_used();
+
   // Return a name to use for a thunk function.  A thunk function is
   // one we create during the compilation, for a go statement or a
   // defer statement or a method expression.
@@ -1232,6 +1237,16 @@ class Variable
 this-is_varargs_parameter_ = true;
   }
 
+  // Return whether the variable has been used.
+  bool
+  is_used() const
+  { return this-is_used_; }
+
+  // Mark that the variable has been used.
+  void
+  set_is_used()
+  { this-is_used_ = true; }
+
   // Clear the initial value; used for error handling.
   void
   clear_init()
@@ -1368,6 +1383,8 @@ class Variable
   bool is_receiver_ : 1;
   // Whether this is the varargs parameter of a function.
   bool is_varargs_parameter_ : 1;
+  // Whether this variable is ever referenced.
+  bool is_used_ : 1;
   // Whether something takes the address of this variable.  For a
   // local variable this implies that the variable has to be on the
   // heap.
@@ -2124,6 +2141,11 @@ class Bindings
   void
   remove_binding(Named_object*);
 
+  // Mark all variables as used.  This is used for some types of parse
+  // error.
+  void
+  mark_locals_used();
+
   // Traverse the tree.  See the Traverse class.
   int
   traverse(Traverse*, bool is_global);
Index: gcc/go/gofrontend/parse.cc
===
--- gcc/go/gofrontend/parse.cc	(revision 183374)
+++ gcc/go/gofrontend/parse.cc	(working copy)
@@ -49,7 +49,8 @@ Parse::Parse(Lex* lex, Gogo* gogo)
 break_stack_(NULL),
 

MAINTAINERS file diff after adding myself

2012-01-23 Thread Harshit Chopra
Index: MAINTAINERS
===
--- MAINTAINERS (revision 183449)
+++ MAINTAINERS (working copy)
@@ -336,6 +336,7 @@
 Gabriel Charette                               gch...@google.com
 Chandra Chavva                                 ccha...@redhat.com
 Fabien Ch�ne                                   fab...@gcc.gnu.org
+Harshit Chopra        hars...@google.com
 William Cohen                                  wco...@redhat.com
 Josh Conner                                    jcon...@apple.com
 R. Kelley Cook                                 kc...@gcc.gnu.org


[PATCH, libitm]: Optimize x86_64 gtm_jmpbuf layout

2012-01-23 Thread Uros Bizjak
Hello!

Attached patch optimizes x86_64 gtm_jmpbuf layout to avoid copying
return address. Optimized layout uses the same trick as x86_32 - call
used registers are saved just below return address. And there is just
enough space in the call alignment hole to put all of them there.

2012-01-24  Uros Bizjak  ubiz...@gmail.com

* config/x86/target.h (gtm_jmpbuf) [__x86_64__]: Move rip to the
end of struct.
* config/x86/sjlj.S (_ITM_beginTransaction) [__x86_64__]: Update
offset values.  Do not copy return address.  Decrement stack
by 56 bytes only.
(GTM_longjump) [__x86_64__]: Update offset values.

Tested on x86_64-pc-linux-gnu.

OK for mainline?

BTW: Do we really need move at the end of GTM_longjump:

movq48(%rsi), %r15
movq56(%rsi), %rdx
  movl%edi, %eax
cfi_def_cfa(%rcx, 0)
cfi_register(%rip, %rdx)
movq%rcx, %rsp
jmp *%rdx

Uros.
Index: config/x86/sjlj.S
===
--- config/x86/sjlj.S   (revision 183449)
+++ config/x86/sjlj.S   (working copy)
@@ -61,20 +61,18 @@ SYM(_ITM_beginTransaction):
cfi_startproc
 #ifdef __x86_64__
leaq8(%rsp), %rax
-   movq(%rsp), %r8
-   subq$72, %rsp
-   cfi_def_cfa_offset(80)
+   subq$56, %rsp
+   cfi_def_cfa_offset(64)
movq%rax, (%rsp)
-   movq%r8, 8(%rsp)
-   movq%rbx, 16(%rsp)
-   movq%rbp, 24(%rsp)
-   movq%r12, 32(%rsp)
-   movq%r13, 40(%rsp)
-   movq%r14, 48(%rsp)
-   movq%r15, 56(%rsp)
+   movq%rbx, 8(%rsp)
+   movq%rbp, 16(%rsp)
+   movq%r12, 24(%rsp)
+   movq%r13, 32(%rsp)
+   movq%r14, 40(%rsp)
+   movq%r15, 48(%rsp)
movq%rsp, %rsi
callSYM(GTM_begin_transaction)
-   addq$72, %rsp
+   addq$56, %rsp
cfi_def_cfa_offset(8)
ret
 #else
@@ -115,13 +113,13 @@ SYM(GTM_longjmp):
cfi_startproc
 #ifdef __x86_64__
movq(%rsi), %rcx
-   movq8(%rsi), %rdx
-   movq16(%rsi), %rbx
-   movq24(%rsi), %rbp
-   movq32(%rsi), %r12
-   movq40(%rsi), %r13
-   movq48(%rsi), %r14
-   movq56(%rsi), %r15
+   movq8(%rsi), %rbx
+   movq16(%rsi), %rbp
+   movq24(%rsi), %r12
+   movq32(%rsi), %r13
+   movq40(%rsi), %r14
+   movq48(%rsi), %r15
+   movq56(%rsi), %rdx
movl%edi, %eax
cfi_def_cfa(%rcx, 0)
cfi_register(%rip, %rdx)
Index: config/x86/target.h
===
--- config/x86/target.h (revision 183449)
+++ config/x86/target.h (working copy)
@@ -29,13 +29,13 @@ namespace GTM HIDDEN {
 typedef struct gtm_jmpbuf
 {
   void *cfa;
-  unsigned long rip;
   unsigned long rbx;
   unsigned long rbp;
   unsigned long r12;
   unsigned long r13;
   unsigned long r14;
   unsigned long r15;
+  unsigned long rip;
 } gtm_jmpbuf;
 #else
 typedef struct gtm_jmpbuf


[C++ Patch] PR 51223

2012-01-23 Thread Paolo Carlini

Hi,

another diagnostic regression, a little subtler than the last one.

In this case, besides the final ICE (which was already there in 4.5), we 
also have a regression vs 4.6 in the error messages produced before it, 
that is, we have (see PR):


bug.cc:3:18: error: 'i' has incomplete type
bug.cc:3:19: error: invalid use of 'void'
bug.cc: In function 'void bar()':
bug.cc:8:11: error: call to 'A A::foo(type error)' uses the default argument
for parameter 1, which is not yet defined
bug.cc: At global scope:
bug.cc:11:15: error: 'i' has incomplete type
bug.cc:11:16: error: invalid use of 'void'
bug.cc: In function 'void bar()':
bug.cc:8:11: internal compiler error: tree check: expected class 'type', have
'exceptional' (error_mark) in useless_type_conversion_p, at tree-ssa.c:1460
Please submit a full bug report, [etc.]


which become, after the patch (note the confusing errors for line 8):

bug.cc:3:18: error: ‘i’ has incomplete type
bug.cc:3:18: error: invalid use of ‘void’
bug.cc:11:15: error: ‘i’ has incomplete type
bug.cc:11:16: error: invalid use of ‘void’


I checked that the error messages produced by Icc are quite similar, but 
2 single errors are produced instead of 2 pairs, saying that a parameter 
cannot have void type (if we wanted, it would be easy to do something 
similar by replacing the cxx_incomplete_type_error call in grokparms 
with just an error + couple of tweaks to the testsuite)


Tested x86_64-linux.

Paolo.

/


/cp
2012-01-23  Paolo Carlini  paolo.carl...@oracle.com

PR c++/51223
* call.c (build_over_call): Check for error_mark_node as
TREE_VALUE when default arguments are processed.

/testsuite
2012-01-23  Paolo Carlini  paolo.carl...@oracle.com

PR c++/51223
* g++.dg/parse/crash58.C: New.

Index: testsuite/g++.dg/parse/crash58.C
===
--- testsuite/g++.dg/parse/crash58.C(revision 0)
+++ testsuite/g++.dg/parse/crash58.C(revision 0)
@@ -0,0 +1,16 @@
+// PR c++/51223
+
+struct A
+{
+  A foo(void i = 0);  // { dg-error incomplete type|invalid use }
+};
+
+void bar()
+{
+  A().foo();
+}
+
+A A::foo(void i)  // { dg-error incomplete type|invalid use }
+{
+  return A();
+}
Index: cp/call.c
===
--- cp/call.c   (revision 183449)
+++ cp/call.c   (working copy)
@@ -6581,9 +6581,14 @@ build_over_call (struct z_candidate *cand, int fla
 
   /* Default arguments */
   for (; parm  parm != void_list_node; parm = TREE_CHAIN (parm), i++)
-argarray[j++] = convert_default_arg (TREE_VALUE (parm),
-TREE_PURPOSE (parm),
-fn, i - is_method);
+{
+  if (TREE_VALUE (parm) == error_mark_node)
+   return error_mark_node;
+  argarray[j++] = convert_default_arg (TREE_VALUE (parm),
+  TREE_PURPOSE (parm),
+  fn, i - is_method);
+}
+
   /* Ellipsis */
   for (; arg_index  VEC_length (tree, args); ++arg_index)
 {


Re: [PATCH, libitm]: Optimize x86_64 gtm_jmpbuf layout

2012-01-23 Thread Richard Henderson
On 01/24/2012 11:05 AM, Uros Bizjak wrote:
 Hello!
 
 Attached patch optimizes x86_64 gtm_jmpbuf layout to avoid copying
 return address. Optimized layout uses the same trick as x86_32 - call
 used registers are saved just below return address. And there is just
 enough space in the call alignment hole to put all of them there.
 
 2012-01-24  Uros Bizjak  ubiz...@gmail.com
 
   * config/x86/target.h (gtm_jmpbuf) [__x86_64__]: Move rip to the
   end of struct.
   * config/x86/sjlj.S (_ITM_beginTransaction) [__x86_64__]: Update
   offset values.  Do not copy return address.  Decrement stack
   by 56 bytes only.
   (GTM_longjump) [__x86_64__]: Update offset values.

Ok.

 BTW: Do we really need move at the end of GTM_longjump:
 
   movq48(%rsi), %r15
   movq56(%rsi), %rdx
 movl%edi, %eax

Yes, that copies the first argument to the return register.


r~


[trans-mem,c++] PR51928

2012-01-23 Thread Patrick Marlier

Hi,

In this PR51928, it tries to look_for_tm_attr_overrides on a thunk but 
there is no DECL_NAME for thunk. So it fails in 
lookup_fnfields_idx_nolazy because name is NULL.


#0  0x00764b5a in lookup_fnfields_idx_nolazy 
(type=0x769f77e0, name=0x0) at ../../trunk/gcc/cp/search.c:1384
#1  0x0076551a in lookup_fnfields_1 (type=0x769f77e0, 
name=0x0) at ../../trunk/gcc/cp/search.c:1470
#2  0x0076886e in look_for_overrides_here (type=0x769f77e0, 
fndecl=0x769f8800) at ../../trunk/gcc/cp/search.c:2026
#3  0x00635a94 in look_for_tm_attr_overrides 
(type=0x76a091f8, fndecl=0x769f8800) at 
../../trunk/gcc/cp/class.c:4337


I hope the good way to solve this is to use the THUNK_TARGET instead of 
the thunk itself. (or just ignore when it is a thunk?)


Tested on x86_64-unknown-linux-gnu.
Thanks.
--
Patrick Marlier.
Changelog

2012-01-23  Patrick Marlier  patrick.marl...@gmail.com

PR c++/51928
* cp/class.c (set_method_tm_attributes): Use TARGET_THUNK instead of
thunk for set_one_vmethod_tm_attributes.

testsuite/Changelog

2012-01-23  Patrick Marlier  patrick.marl...@gmail.com

PR c++/51928
* g++.dg/tm/pr51928.C: New test. 
Index: cp/class.c
===
--- cp/class.c	(revision 183448)
+++ cp/class.c	(working copy)
@@ -4430,7 +4430,12 @@ set_method_tm_attributes (tree t)
   tree vchain;
   for (vchain = BINFO_VIRTUALS (TYPE_BINFO (t)); vchain;
 	   vchain = TREE_CHAIN (vchain))
-	set_one_vmethod_tm_attributes (t, BV_FN (vchain));
+	{
+	  fndecl = BV_FN (vchain);
+	  if (DECL_THUNK_P (fndecl))
+	fndecl = THUNK_TARGET (fndecl);
+	  set_one_vmethod_tm_attributes (t, fndecl);
+	}
 }
 
   /* If the class doesn't have an attribute, nothing more to do.  */


Re: [C++ Patch] PR 51223

2012-01-23 Thread Jason Merrill

OK.

Jason


Re: [trans-mem,c++] PR51928

2012-01-23 Thread Jason Merrill

OK.

Jason


Re: [PATCH] Fix up ppc64-linux profiledbootstrap - .toc section references in .debug_loc (PR target/51957)

2012-01-23 Thread David Edelsohn
On Mon, Jan 23, 2012 at 1:29 PM, Jakub Jelinek ja...@redhat.com wrote:

 profiledbootstrap currently fails on powerpc64-linux (64-bit).  The problem
 is that the linker errors on .toc section references from within
 non-allocated sections.  Alan changed the linker some months ago to
 not die with assertion failure, but error out on these, and the attached
 testcase reduced from cp/parser.c during bootstrap shows that we still
 can hit it in some cases.  The problem here is that var-tracking.c
 (adjust_insn) isn't able to delegitimize it, because the UNSPEC_TOCREL
 isn't added there to r2 register, but to a debug_expr (which only afterwards
 is found to contain r2 value).  So the UNSPEC_TOCREL makes it through to
 mem_loc_descriptor, where it is already properly delegitimized into a
 (mem (symbol_ref (.LC0)) where .LC0 is a constant pool (.toc) symbol.
 We in some places try to prefer avoid_constant_pool_reference values over
 the mems, in this case avoid_constant_pool returns (symbol_ref w), which
 is a non-local symbol which isn't const_ok_for_output though.  So
 mem_loc_descriptor on the avoid_constant_pool_reference value fails and we
 try the original (mem (symbol_ref (.LC0)) - on other targets this is still
 useful, if we know the right value is in say some .got entry etc. and we
 can reference that location from within the .debug_info, we win.
 Unfortunately the ppc64 linker doesn't like this, so we need to reject
 those.  The following patch adds a target hook and rejects there from
 emitting into .debug_info/.debug_loc any SYMBOL_REFs that are in the
 .toc section.

 Bootstrapped/regtested on x86_64-linux and i686-linux, profiledbootstrapped
 on powerpc64-linux (both --with-cpu=default32 and defaulting to 64-bit,
 the last one failed without this patch), powerpc64-linux regtest is in
 progress (but the testcase in the patch has been tested already to
 fail without the patch and succeed with the patch).
 Ok for trunk?

 2012-01-23  Jakub Jelinek  ja...@redhat.com

        PR target/51957
        * target.def (const_not_ok_for_debug_p): New hook.
        * doc/tm.texi.in (TARGET_CONST_NOT_OK_FOR_DEBUG_P): New hook
        documentation.
        * doc/tm.texi: Regenerated.
        * dwarf2out.c (const_ok_for_output_1): If
        targetm.const_not_ok_for_debug_p returns true, fail.
        * config/rs6000/rs6000.c (rs6000_const_not_ok_for_debug_p): New
        function.
        (TARGET_CONST_NOT_OK_FOR_DEBUG_P): Redefine.

        * gcc.dg/pr51957-1.c: New test.
        * gcc.dg/pr51957-1.h: New file.
        * gcc.dg/pr51957-2.c: New test.

Okay.

Thanks, David


Re: [PATCH] Fix up ppc64-linux profiledbootstrap - .toc section references in .debug_loc (PR target/51957)

2012-01-23 Thread Alan Modra
On Mon, Jan 23, 2012 at 07:29:18PM +0100, Jakub Jelinek wrote:
 can hit it in some cases.  The problem here is that var-tracking.c
 (adjust_insn) isn't able to delegitimize it, because the UNSPEC_TOCREL
 isn't added there to r2 register, but to a debug_expr (which only afterwards
 is found to contain r2 value).

Why don't we relax operand checks in rs6000_delegitimize_address?
http://gcc.gnu.org/ml/gcc-patches/2011-09/msg00304.html did that as
part of changing toc references.  For mainline you'd just get rid of

-  ((GET_CODE (XEXP (x, 0)) == REG
-   (REGNO (XEXP (x, 0)) == TOC_REGISTER
-  || TARGET_MINIMAL_TOC
-  || TARGET_CMODEL != CMODEL_SMALL))
- || (TARGET_CMODEL != CMODEL_SMALL
-  GET_CODE (XEXP (x, 0)) == CONST
-  GET_CODE (XEXP (XEXP (x, 0), 0)) == PLUS
-  GET_CODE (XEXP (XEXP (XEXP (x, 0), 0), 0)) == REG
-  REGNO (XEXP (XEXP (XEXP (x, 0), 0), 0)) == TOC_REGISTER
-  GET_CODE (XEXP (XEXP (XEXP (x, 0), 0), 1)) == HIGH
-  rtx_equal_p (XEXP (x, 1),
- XEXP (XEXP (XEXP (XEXP (x, 0), 0), 1), 0)


-- 
Alan Modra
Australia Development Lab, IBM


[patch] Fix mismatched #pragma GCC visibility

2012-01-23 Thread Rafael Ávila de Espíndola
While trying to improve clang's handling of #pragma GCC visibility I
found out that libstdc++-v3/libsupc++/typeinfo looks like

#pragma GCC visibility push(default)
extern C++ {
#pragma GCC visibility pop
}

Is that supposed to work or just happens to? If desired, the attached
patch moves the pop after the closing }.

2011-01-23  Rafael Avila de Espindola  rafael.espind...@gmail.com

* libsupc++/typeinfo: Correctly match #pragma GCC visibility
pop with #pragma GCC visibility push.

Cheers,
Rafael
diff --git a/libstdc++-v3/libsupc++/typeinfo b/libstdc++-v3/libsupc++/typeinfo
index aaa756b..39146e0 100644
--- a/libstdc++-v3/libsupc++/typeinfo
+++ b/libstdc++-v3/libsupc++/typeinfo
@@ -218,7 +218,7 @@ namespace std
   };
 } // namespace std
 
-#pragma GCC visibility pop
-
 } // extern C++
+
+#pragma GCC visibility pop
 #endif


Re: [v3] libstdc++/49829

2012-01-23 Thread Benjamin Kosnik


 tested x86-64/linux
 tested x86-64/linux -x- arm-eabi
 tested x86-64/linux -x- cris-elf

Here is the missing bit, as tested above.

-benjamindiff --git a/libstdc++-v3/src/Makefile.am b/libstdc++-v3/src/Makefile.am
index aa25a7e..87b2a16 100644
--- a/libstdc++-v3/src/Makefile.am
+++ b/libstdc++-v3/src/Makefile.am
@@ -184,9 +184,9 @@ endif
 libstdc++convenience.la: $(toolexeclib_LTLIBRARIES)
 	$(CXXLINK) $(libstdc___la_LIBADD) $(LIBS); \
 	if test ! -f .libs/libstdc++.a; then \
-	  $(LN_S) .libs/libstdc++convenience.a .libs/libstdc++.a; \
-	  stamp-libstdc++convenience; \
-	fi;
+	  cp .libs/libstdc++convenience.a .libs/libstdc++.a; \
+	fi; \
+	echo `date`  stamp-libstdc++convenience;
 
 debugdir = debug
 


[PATCH] Improve PHI-OPT when there are multiple phis

2012-01-23 Thread Andrew Pinski
Hi,
  Right now PHI-OPT does try to handle the case where we have multiple
PHIs but the other PHIs have the same value for the edges we care
about.
This fixes the issue and allows PHI-OPT to handle a few more cases and
it removes the TODO in the comments.

OK For 4.8? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

Thanks,
Andrew Pinski

ChangeLog:
* tree-ssa-phiopt.c (gimple_phi_singleton_for_edges): New function.
(tree_ssa_phiopt_worker): Use gimple_phi_singleton_for_edges.
(empty_block_p): Check also if the PHIs for the block are empty.

testsuite/ChangeLog:
* gcc.dg/tree-ssa/phi-opt-7.c: New testcase.
Index: testsuite/gcc.dg/tree-ssa/phi-opt-7.c
===
--- testsuite/gcc.dg/tree-ssa/phi-opt-7.c   (revision 0)
+++ testsuite/gcc.dg/tree-ssa/phi-opt-7.c   (revision 0)
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options -O1 -fdump-tree-optimized } */
+
+int g(int,int);
+int f(int t, int c)
+{
+  int d = 0;
+  int e = 0;
+  if (t)
+{
+  d = t;
+  if (c) e = 1;
+}
+  else d = 0, e = 0;
+  return g(d,e);
+}
+
+/* There should be one ifs as one of them should be changed into
+   a conditional and the other should be there still.  */
+/* { dg-final { scan-tree-dump-times if 1 optimized }  }*/
+/* { dg-final { scan-tree-dump-times D.\[0-9\]*_\[0-9\]* = c_\[0-9\]*.D. != 
0 1 optimized  } } */
+/* { dg-final { cleanup-tree-dump optimized } } */
+
Index: tree-ssa-phiopt.c
===
--- tree-ssa-phiopt.c   (revision 183458)
+++ tree-ssa-phiopt.c   (working copy)
@@ -192,6 +192,33 @@ tree_ssa_cs_elim (void)
   return tree_ssa_phiopt_worker (true);
 }
 
+/* Return the singleton PHI in the SEQ of PHIs for edges E0 and E1. */
+
+static gimple
+gimple_phi_singleton_for_edges (gimple_seq seq, edge e0, edge e1)
+{
+  gimple_stmt_iterator i;
+  gimple phi = NULL;
+  if (gimple_seq_singleton_p (seq))
+return gsi_stmt (gsi_start (seq));
+  for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (i))
+{
+  gimple p = gsi_stmt (i);
+  /* If the PHI arguments are equal then we can skip this PHI. */
+  if (operand_equal_for_phi_arg_p (gimple_phi_arg_def (p, e0-dest_idx),
+  gimple_phi_arg_def (p, e1-dest_idx)))
+   continue;
+
+  /* If we already have a PHI that has the two edge arguments are
+different, then return it is not a singleton for these PHIs. */
+  if (phi)
+   return NULL;
+
+  phi = p;
+}
+  return phi;
+}
+
 /* For conditional store replacement we need a temporary to
put the old contents of the memory in.  */
 static tree condstoretemp;
@@ -313,23 +340,9 @@ tree_ssa_phiopt_worker (bool do_store_el
   else
{
  gimple_seq phis = phi_nodes (bb2);
- gimple_stmt_iterator gsi;
+ phi = gimple_phi_singleton_for_edges (phis, e1, e2);
 
- /* Check to make sure that there is only one non-virtual PHI node.
-TODO: we could do it with more than one iff the other PHI nodes
-have the same elements for these two edges.  */
- phi = NULL;
- for (gsi = gsi_start (phis); !gsi_end_p (gsi); gsi_next (gsi))
-   {
- if (!is_gimple_reg (gimple_phi_result (gsi_stmt (gsi
-   continue;
- if (phi)
-   {
- phi = NULL;
- break;
-   }
- phi = gsi_stmt (gsi);
-   }
+ /* Check to make sure that there is only one PHI node. */
  if (!phi)
continue;
 
@@ -431,6 +444,8 @@ empty_block_p (basic_block bb)
 {
   /* BB must have no executable statements.  */
   gimple_stmt_iterator gsi = gsi_after_labels (bb);
+  if (phi_nodes (bb))
+return false;
   if (gsi_end_p (gsi))
 return true;
   if (is_gimple_debug (gsi_stmt (gsi)))


Go patch committed: Better error for invalid use of builtin

2012-01-23 Thread Ian Lance Taylor
This patch to the Go compiler improves the error message for the invalid
use of a special builtin function like unsafe.Sizeof.  Bootstrapped and
ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

diff -r c1acc6a7e12a go/expressions.cc
--- a/go/expressions.cc	Mon Jan 23 15:53:43 2012 -0800
+++ b/go/expressions.cc	Mon Jan 23 22:58:26 2012 -0800
@@ -1328,7 +1328,8 @@
   // can't take their address.
   if (fntype-is_builtin())
 {
-  error_at(this-location(), invalid use of special builtin function %qs,
+  error_at(this-location(),
+	   invalid use of special builtin function %qs; must be called,
 	   this-function_-name().c_str());
   return error_mark_node;
 }


Re: [trans-mem] Do not instrument thread locals

2012-01-23 Thread Richard Henderson
On 01/24/2012 09:59 AM, Patrick Marlier wrote:
 2012-01-23  Patrick Marlier  patrick.marl...@gmail.com
 
   * trans-mem.c (requires_barrier): Do not instrument thread local
   variables and emit save/restore for them.
 
 testsuite/ChangeLog
 2012-01-23  Patrick Marlier  patrick.marl...@gmail.com
 
   * gcc.dg/tm/threadlocal-1.c: New test.
 

Ok.


r~


Re: [PATCH] Fix up ppc64-linux profiledbootstrap - .toc section references in .debug_loc (PR target/51957)

2012-01-23 Thread Jakub Jelinek
On Tue, Jan 24, 2012 at 01:45:40PM +1030, Alan Modra wrote:
 On Mon, Jan 23, 2012 at 07:29:18PM +0100, Jakub Jelinek wrote:
  can hit it in some cases.  The problem here is that var-tracking.c
  (adjust_insn) isn't able to delegitimize it, because the UNSPEC_TOCREL
  isn't added there to r2 register, but to a debug_expr (which only afterwards
  is found to contain r2 value).
 
 Why don't we relax operand checks in rs6000_delegitimize_address?
 http://gcc.gnu.org/ml/gcc-patches/2011-09/msg00304.html did that as
 part of changing toc references.  For mainline you'd just get rid of
 
 -((GET_CODE (XEXP (x, 0)) == REG
 - (REGNO (XEXP (x, 0)) == TOC_REGISTER
 -|| TARGET_MINIMAL_TOC
 -|| TARGET_CMODEL != CMODEL_SMALL))
 -   || (TARGET_CMODEL != CMODEL_SMALL
 -GET_CODE (XEXP (x, 0)) == CONST
 -GET_CODE (XEXP (XEXP (x, 0), 0)) == PLUS
 -GET_CODE (XEXP (XEXP (XEXP (x, 0), 0), 0)) == REG
 -REGNO (XEXP (XEXP (XEXP (x, 0), 0), 0)) == TOC_REGISTER
 -GET_CODE (XEXP (XEXP (XEXP (x, 0), 0), 1)) == HIGH
 -rtx_equal_p (XEXP (x, 1),
 -   XEXP (XEXP (XEXP (XEXP (x, 0), 0), 1), 0)

If you relax the checking too much, don't you risk that something other than
the TOC register value is being added to the UNSPEC_TOCREL?  Say, if you
have an 8byte object in .toc, and some loop body uses
((char *) object)[1 + iv];
to access it, can't you end up with (r2 + 1), or (r2 + 1 + iv) being added
to UNSPEC_TOCREL?  Certainly on i686 something like that happens and that
is why the delegitimization needs to be strict about the pic register
e.g. for UNSPEC_GOTOFF or UNSPEC_GOT.
I've checked in my patch already, I think it is desirable even if
delegitimization is somehow changed, it really models the linker
requirements that debug sections don't reference .toc section symbols
and this problem could pop up any time again with some other code.
And allows other targets to express their requirements too.

Jakub


Re: [PATCH, Ada] Illegal program not detected, self renames, PR15846

2012-01-23 Thread Arnaud Charlet
 The patch for exp_disp is related to renaming of predefined =
 operation for tagged type.
 without this patch I've got ICE on the following testcase:

OK, we have a better, simpler patch for this issue, no need for this hunk.

For the record, here is the patch we're looking at:

Modified: trunk/gnat/sem_ch8.adb
===
--- trunk/gnat/sem_ch8.adb  2012-01-23 19:56:15 UTC (rev 210768)
+++ trunk/gnat/sem_ch8.adb  2012-01-23 20:12:40 UTC (rev 210769)
@@ -2665,7 +2665,10 @@
  if not Is_Actual
and then (Old_S = New_S
   or else (Nkind (Nam) /= N_Expanded_Name
-and then  Chars (Old_S) = Chars (New_S))) 
+and then Chars (Old_S) = Chars (New_S))
+  or else (Nkind (Nam) = N_Expanded_Name
+and then Entity (Prefix (Nam)) = Current_Scope
+and then Chars (Selector_Name (Nam)) = Chars (New_S)))
  then
 Error_Msg_N (subprogram cannot rename itself, N);
  end if;


  By the way, do you have a copyright assignment in place with the FSF?
 
 No, I don't have it. What should I do?

Then we cannot accept your patch yet, and it's good that we've written a
different fix for this issue (currently under test).

You need to have a copyright assignment form in place with the FSF,
by e.g. contacting ass...@gnu.org

Arno