Fix PR target/51921

2012-02-15 Thread Eric Botcazou
This fixes the regression in the frame unwinding support on SPARC/Solaris 11 
present on the mainline and 4.6 branch.  Tested (by me) on 6 differents OS 
versions of Solaris 8, 9 and 10 and on Solaris 11 by Ian and Rainer.

Applied on the mainline and 4.6 branch.


2012-02-15  Eric Botcazou  

PR target/51921
PR target/52205
* config/sparc/sol2-unwind.h (sparc64_is_sighandler): Add support for
Solaris 11 and slightly reformat.
(sparc_is_sighandler): Likewise.


-- 
Eric Botcazou
Index: config/sparc/sol2-unwind.h
===
--- config/sparc/sol2-unwind.h	(revision 183864)
+++ config/sparc/sol2-unwind.h	(working copy)
@@ -119,7 +119,12 @@ sparc64_is_sighandler (unsigned int *pc,
   unsigned int cuh_pattern
 	= *(unsigned int *)(*(unsigned long *)(cfa + 15*8) - 4);
 
-  if (cuh_pattern == 0xd25fa7ef)
+  if (cuh_pattern == 0x92100019)
+	/* This matches the call_user_handler pattern for Solaris 11.
+	   This is the same setup as for Solaris 9, see below.  */
+	*nframes = 3;
+
+  else if (cuh_pattern == 0xd25fa7ef)
 	{
 	  /* This matches the call_user_handler pattern for Solaris 10.
 	 There are 2 cases so we look for the return address of the
@@ -140,6 +145,7 @@ sparc64_is_sighandler (unsigned int *pc,
 	*/
 	*nframes = 2;
 	}
+
   else if (cuh_pattern == 0x9410001a || cuh_pattern == 0x94100013)
 	/* This matches the call_user_handler pattern for Solaris 9 and
 	   for Solaris 8 running inside Solaris Containers respectively
@@ -152,7 +158,8 @@ sparc64_is_sighandler (unsigned int *pc,
 		
 	*/
 	*nframes = 3;
-  else
+
+  else /* cuh_pattern == 0xe0272010 */
 	/* This is the default Solaris 8 case.
 	   We need to move up two frames:
 
@@ -162,6 +169,7 @@ sparc64_is_sighandler (unsigned int *pc,
 		
 	*/
 	*nframes = 2;
+
   return 1;
 }
 
@@ -296,7 +304,12 @@ sparc_is_sighandler (unsigned int *pc, v
   unsigned int cuh_pattern
 	= *(unsigned int *)(*(unsigned int *)(cfa + 15*4) - 4);
 
-  if (cuh_pattern == 0xd407a04c)
+  if (cuh_pattern == 0x92100019)
+	/* This matches the call_user_handler pattern for Solaris 11.
+	   This is the same setup as for Solaris 9, see below.  */
+	*nframes = 3;
+
+  else if (cuh_pattern == 0xd407a04c)
 	{
 	  /* This matches the call_user_handler pattern for Solaris 10.
 	 There are 2 cases so we look for the return address of the
@@ -317,6 +330,7 @@ sparc_is_sighandler (unsigned int *pc, v
 	*/
 	*nframes = 2;
 	}
+
   else if (cuh_pattern == 0x9410001a || cuh_pattern == 0x9410001b)
 	/* This matches the call_user_handler pattern for Solaris 9 and
 	   for Solaris 8 running inside Solaris Containers respectively.
@@ -329,7 +343,8 @@ sparc_is_sighandler (unsigned int *pc, v
 		
 	*/
 	*nframes = 3;
-  else
+
+  else /* cuh_pattern == 0x90100018 */
 	/* This is the default Solaris 8 case.
 	   We need to move up two frames:
 
@@ -339,6 +354,7 @@ sparc_is_sighandler (unsigned int *pc, v
 		
 	*/
 	*nframes = 2;
+
   return 1;
 }
 


[Ada] Fix ICE on function call returning volatile record type

2012-02-15 Thread Eric Botcazou
This is a regression present on the mainline: the compiler aborts on the access
to a component of the value returned by a function call, if the return type is 
a volatile record type that isn't controlled or tagged.

Tested on i586-suse-linux, applied on the mainline.


2012-02-15  Eric Botcazou  

* gcc-interface/trans.c (call_to_gnu): Create the temporary for the
return value in the by-reference return type case if this isn't the
expression of an object declaration.  Tidy up.


2012-02-15  Eric Botcazou  

* gnat.dg/volatile10.adb: New case.
* gnat.dg/volatile10_pkg.ads: New helper.


-- 
Eric Botcazou
Index: gcc-interface/trans.c
===
--- gcc-interface/trans.c	(revision 184256)
+++ gcc-interface/trans.c	(working copy)
@@ -3642,24 +3642,34 @@ call_to_gnu (Node_Id gnat_node, tree *gn
   went_into_elab_proc = true;
 }
 
-  /* First, create the temporary for the return value if we need it: for a
- variable-sized return type if there is no target and this is not an
- object declaration, or else there is a target and it is a slice or an
- array with fixed size, as the gimplifier doesn't handle these cases;
- otherwise for a function with copy-in/copy-out parameters if there is
- no target, because we need to preserve the return value before copying
- back the parameters.  This must be done before we push a binding level
- around the call as we will pop it before copying the return value.  */
+  /* First, create the temporary for the return value when:
+
+   1. There is no target and the function has copy-in/copy-out parameters,
+	  because we need to preserve the return value before copying back the
+	  parameters.
+
+   2. There is no target and this is not an object declaration, and the
+	  return type is by-reference or has variable size, because in these
+	  cases the gimplifier cannot create the temporary.
+
+   3. There is a target and it is a slice or an array with fixed size,
+	  and the return type has variable size, because the gimplifier
+	  doesn't handle these cases.
+
+ This must be done before we push a binding level around the call, since
+ we will pop it before copying the return value.  */
   if (function_call
-  && ((TREE_CODE (TYPE_SIZE (gnu_result_type)) != INTEGER_CST
-	   && ((!gnu_target
-		&& Nkind (Parent (gnat_node)) != N_Object_Declaration)
-	   || (gnu_target
-		   && (TREE_CODE (gnu_target) == ARRAY_RANGE_REF
-		   || (TREE_CODE (TREE_TYPE (gnu_target)) == ARRAY_TYPE
-			   && TREE_CODE (TYPE_SIZE (TREE_TYPE (gnu_target)))
-			  == INTEGER_CST)
-	  || (!gnu_target && TYPE_CI_CO_LIST (gnu_subprog_type
+  && ((!gnu_target && TYPE_CI_CO_LIST (gnu_subprog_type))
+	  || (!gnu_target
+	  && Nkind (Parent (gnat_node)) != N_Object_Declaration
+	  && (TREE_ADDRESSABLE (gnu_result_type)
+		  || TREE_CODE (TYPE_SIZE (gnu_result_type)) != INTEGER_CST))
+	  || (gnu_target
+	  && (TREE_CODE (gnu_target) == ARRAY_RANGE_REF
+		  || (TREE_CODE (TREE_TYPE (gnu_target)) == ARRAY_TYPE
+		  && TREE_CODE (TYPE_SIZE (TREE_TYPE (gnu_target)))
+			 == INTEGER_CST))
+	  && TREE_CODE (TYPE_SIZE (gnu_result_type)) != INTEGER_CST)))
 gnu_retval = create_temporary ("R", gnu_result_type);
 
   /* Create the list of the actual parameters as GCC expects it, namely a
-- { dg-do compile }

with Volatile10_Pkg; use Volatile10_Pkg;

procedure Volatile10 is
   N : Num;
begin
   N := F.N1;
   N := F.N2;
end;
package Volatile10_Pkg is

   type Num is mod 2**9;

   type Rec is record
  B1  : Boolean;
  N1  : Num;
  B2  : Boolean;
  N2  : Num;
  B3  : Boolean;
  B4  : Boolean;
  B5  : Boolean;
  B6  : Boolean;
  B7  : Boolean;
  B8  : Boolean;
  B9  : Boolean;
  B10 : Boolean;
  B11 : Boolean;
  B12 : Boolean;
  B13 : Boolean;
  B14 : Boolean;
   end record;
   pragma Pack (Rec);
   for Rec'Size use 32;
   pragma Volatile(Rec);

   function F return Rec;

end Volatile10_Pkg;


Re: [PATCH, libitm]: GTM_longjmp: Jump indirect from memory address

2012-02-15 Thread Uros Bizjak
On Tue, Feb 14, 2012 at 8:52 PM, Richard Henderson  wrote:
> On 02/14/2012 10:26 AM, Uros Bizjak wrote:
>>  #ifdef __x86_64__
>> +     cfi_def_cfa(%rsi, 0)
>>       movq    (%rsi), %rcx
>>       movq    8(%rsi), %rbx
>>       movq    16(%rsi), %rbp
>> @@ -119,20 +120,21 @@
>>       movq    32(%rsi), %r13
>>       movq    40(%rsi), %r14
>>       movq    48(%rsi), %r15
>> +     cfi_offset(%rip, 56)
>>       movl    %edi, %eax
>> -     cfi_offset(%rip, 56)
>> -     cfi_def_cfa(%rcx, 0)
>>       movq    %rcx, %rsp
>> +     cfi_register(%rsp, %rcx)
>>       jmp     *56(%rsi)
>
> No, your changes are incorrect.  All three markers needed to be together
> in order to provide a consistent and coherent unwind.  What you committed
> was much worse than simply not describing anything at all.
>
> Fixed as below.  Committed.

Thanks!

Uros.


[Ada] Fix printing of class-wide tagged type variable in GDB

2012-02-15 Thread Eric Botcazou
This is a regression present on the mainline and which stems from enabling 
-feliminate-unused-debug-types by default in Ada.  We fail to emit the 
debugging information for tagged types when only the associated class-wide 
type is referenced in the source code.

Tested on i586-suse-linux, applied on the mainline.


2012-02-15  Eric Botcazou  

* gcc-interface/trans.c (gnat_to_gnu) : If the
type is tagged, mark it as used for debugging purposes.
: Likewise for a qualified expression.


-- 
Eric Botcazou
Index: gcc-interface/trans.c
===
--- gcc-interface/trans.c	(revision 184257)
+++ gcc-interface/trans.c	(working copy)
@@ -5518,6 +5518,13 @@ gnat_to_gnu (Node_Id gnat_node)
   gnu_result = gnat_to_gnu (Expression (gnat_node));
   gnu_result_type = get_unpadded_type (Etype (gnat_node));
 
+  /* If this is a qualified expression for a tagged type, we mark the type
+	 as used.  Because of polymorphism, this might be the only reference to
+	 the tagged type in the program while objects have it as dynamic type.
+	 The debugger needs to see it to display these objects properly.  */
+  if (kind == N_Qualified_Expression && Is_Tagged_Type (Etype (gnat_node)))
+	used_types_insert (gnu_result_type);
+
   gnu_result
 	= convert_with_check (Etype (gnat_node), gnu_result,
 			  Do_Overflow_Check (gnat_node),
@@ -5865,18 +5872,19 @@ gnat_to_gnu (Node_Id gnat_node)
 
 	if (Is_Elementary_Type (gnat_desig_type)
 		|| Is_Constrained (gnat_desig_type))
-	  {
-		gnu_type = gnat_to_gnu_type (gnat_desig_type);
-		gnu_init = convert (gnu_type, gnu_init);
-	  }
+	  gnu_type = gnat_to_gnu_type (gnat_desig_type);
 	else
 	  {
 		gnu_type = gnat_to_gnu_type (Etype (Expression (gnat_temp)));
 		if (TREE_CODE (gnu_type) == UNCONSTRAINED_ARRAY_TYPE)
 		  gnu_type = TREE_TYPE (gnu_init);
-
-		gnu_init = convert (gnu_type, gnu_init);
 	  }
+
+	/* See the N_Qualified_Expression case for the rationale.  */
+	if (Is_Tagged_Type (gnat_desig_type))
+	  used_types_insert (gnu_type);
+
+	gnu_init = convert (gnu_type, gnu_init);
 	  }
 	else
 	  gcc_unreachable ();


[Ada] Fix ICE on deferred constant with variant record type

2012-02-15 Thread Eric Botcazou
This is a regression present on the mainline: the compiler aborts on a deferred 
constant initialized with an aggregate and whose type is a discriminated 
record type with a variant part and which, ultimately, contains a component 
whose type is controlled or tagged.

Tested on i586-suse-linux, applied on the mainline.


2012-02-15  Eric Botcazou  

* gcc-interface/trans.c (Identifier_to_gnu): Move block retrieving the
type of the result to the end and execute it for a deferred constant of
a discriminated type whose full view can be elaborated statically.


2012-02-15  Eric Botcazou  

* gnat.dg/discr35.ad[sb]: New test.


-- 
Eric Botcazou
Index: gcc-interface/trans.c
===
--- gcc-interface/trans.c	(revision 184258)
+++ gcc-interface/trans.c	(working copy)
@@ -1077,17 +1077,6 @@ Identifier_to_gnu (Node_Id gnat_node, tr
 	}
 }
 
-  /* The GNAT tree has the type of a function as the type of its result.  Also
- use the type of the result if the Etype is a subtype which is nominally
- unconstrained.  But remove any padding from the resulting type.  */
-  if (TREE_CODE (TREE_TYPE (gnu_result)) == FUNCTION_TYPE
-  || Is_Constr_Subt_For_UN_Aliased (gnat_temp_type))
-{
-  gnu_result_type = TREE_TYPE (gnu_result);
-  if (TYPE_IS_PADDING_P (gnu_result_type))
-	gnu_result_type = TREE_TYPE (TYPE_FIELDS (gnu_result_type));
-}
-
   /* If we have a constant declaration and its initializer, try to return the
  latter to avoid the need to call fold in lots of places and the need for
  elaboration code if this identifier is used as an initializer itself.
@@ -1120,6 +1109,24 @@ Identifier_to_gnu (Node_Id gnat_node, tr
 	gnu_result = unshare_expr (DECL_INITIAL (gnu_result));
 }
 
+  /* The GNAT tree has the type of a function set to its result type, so we
+ adjust here.  Also use the type of the result if the Etype is a subtype
+ that is nominally unconstrained.  Likewise if this is a deferred constant
+ of a discriminated type whose full view can be elaborated statically, to
+ avoid problematic conversions to the nominal subtype.  But remove any
+ padding from the resulting type.  */
+  if (TREE_CODE (TREE_TYPE (gnu_result)) == FUNCTION_TYPE
+  || Is_Constr_Subt_For_UN_Aliased (gnat_temp_type)
+  || (Ekind (gnat_temp) == E_Constant
+	  && Present (Full_View (gnat_temp))
+	  && Has_Discriminants (gnat_temp_type)
+	  && TREE_CODE (gnu_result) == CONSTRUCTOR))
+{
+  gnu_result_type = TREE_TYPE (gnu_result);
+  if (TYPE_IS_PADDING_P (gnu_result_type))
+	gnu_result_type = TREE_TYPE (TYPE_FIELDS (gnu_result_type));
+}
+
   *gnu_result_type_p = gnu_result_type;
 
   return gnu_result;
-- { dg-do compile }

package body Discr35 is

   procedure Proc1 is
 R : Rec2 := Null_Rec2;
   begin
 null;
   end;

   procedure Proc2 is
 R : Rec2;
   begin
 R := Null_Rec2;
   end;

end Discr35;
package Discr35 is

  type Rec1 is tagged null record;

  type Enum is (One, Two);

  type Rec2 (D : Enum := One) is
  record
case D is
  when One => null;
  when Two => R : Rec1;
end case;
  end record;

   Null_Rec2 : Constant Rec2;

   procedure Proc1;

   procedure Proc2;

private

   Null_Rec2 : Constant Rec2 := (D => One);

end Discr35;


Re: [PATCH] Fix PR52178

2012-02-15 Thread Richard Guenther
On Wed, 15 Feb 2012, Eric Botcazou wrote:

> > This fixes PR52178, the failure to bootstrap Ada with LTO (well,
> > until you hit the next problem).  A self-referential DECL_QUALIFIER
> > makes us think that a QUAL_UNION_TYPE type is of variable-size which
> > makes us stream that type locally, wrecking type merging and later
> > ICEing in the type verifier.  While it looks that variably_modified_type_p
> > should not inspect DECL_QUALIFIER a less intrusive patch for 4.7
> > notices that DECL_QUALIFIER is unused after gimplification and thus
> > clears it and does not stream it instead.
> 
> Thanks for fixing the hard part.  Here is the easy one: the compiler aborts 
> during the CDDCE2 pass of LTRANS when it is trying to redirect an edge from a 
> dead control statement to the immediate post-dominator of the BB.
> 
> It turns out that the control statement isn't dead at all, but its two edges
> point to fallthrough (empty) basic blocks which have sticky abnormal edges
> to another block.
> 
> The blocks used to contain a call statement:
> 
> :
>   D.57021_4455 = sinfo__etype (this_formal_84(ab));
> 
> which was replaced by FRE with an assignment:
> 
> :
>   D.57021_4455 = D.57006_4425;
> 
> which was eventually eliminated by DCE1.
> 
> FRE has all the machinery to deal with this case and purge the dead abnormal
> edges.  But there is a hitch: the CFG may have changed between the time the
> need for the cleanup is detected and the time it is performed, which fools
> the logic.  The issue has been latent for years and becomes visible only now
> because we have both EH and AB edges in gnat1 (thanks to TREE_CLOBBER_P).
> 
> Bootstrapped/regtested on x86_64-suse-linux, applied on the mainline as 
> obvious 
> (together with the no-op patchlet to gimple.c we discussed in the PR).

Thanks for hunting this down!

Richard.

> 2012-02-14  Eric Botcazou  
> 
>   PR lto/52178
>   * gimple.c (iterative_hash_gimple_type): Use RECORD_OR_UNION_TYPE_P.
>   (iterative_hash_canonical_type): Likewise.
>   * tree-ssa-pre.c (fini_pre): Clean up the CFG only after purging all
>   the dead edges.


[PATCH, 4.6 regression]. New error: case label does not reduce

2012-02-15 Thread Christian Bruel
Hello,

This patch fixes a regression when folding a cast cond expression to a
constant in case label.

The problem came from the removal of the lines in
c-common.c:check_case_value

  /* ??? Can we ever get nops here for a valid case value?  We
 shouldn't for C.  */
  STRIP_TYPE_NOPS (value);

 so the check for INTEGER_CST) now fails.

The NOP is stripped after folding in 'c_fully_fold' and recreated in the
fly even if no change of type is needed (the constant's type was
converted to an integer, same than the case's type).

Removal of this NOP_EXPR if !CAN_HAVE_LOCATION_P fixes the problem.
looks safe from my testing, because the loc is inserted using
'protected_set_expr_location', whereas no loc for a constant case
doesn't seem to introduce new problems with the debugging information.
But in case I also added a few paranoid gcc_assert.

The motivating failing case is added in the attached testsuite part,

The test now compiles and generates the expected error with -pedantic or
-pedantic-error

Bootstrapped/Regression tested on x86

Thanks for any comment, and if OK to go for 4.6 and trunk

Many thanks

Christian




2010-02-15  Christian Bruel  

	* gcc.dg/case-const-1.c: Add cond expr label and cast case.
	* gcc.dg/case-const-2.c: Likewise.
	* gcc.dg/case-const-3.c: Likewise.

Index: testsuite/gcc.dg/case-const-1.c
===
--- testsuite/gcc.dg/case-const-1.c	(revision 184254)
+++ testsuite/gcc.dg/case-const-1.c	(working copy)
@@ -4,6 +4,8 @@
 /* { dg-options "" } */
 
 extern int i;
+extern unsigned int u;
+
 void
 f (int c)
 {
@@ -13,3 +15,13 @@
   ;
 }
 }
+
+void
+b (int c)
+{
+  switch (c)
+{
+case (int) (2  | ((4 < 8) ? 8 : u)):
+  ;
+}
+}
Index: testsuite/gcc.dg/case-const-2.c
===
--- testsuite/gcc.dg/case-const-2.c	(revision 184254)
+++ testsuite/gcc.dg/case-const-2.c	(working copy)
@@ -4,6 +4,8 @@
 /* { dg-options "-pedantic" } */
 
 extern int i;
+extern unsigned int u;
+
 void
 f (int c)
 {
@@ -13,3 +15,14 @@
   ;
 }
 }
+
+void
+b (int c)
+{
+  switch (c)
+{
+case (int) (2  | ((4 < 8) ? 8 : u)): /* { dg-warning "case label is not an integer constant expression" } */
+  ;
+}
+}
+
Index: testsuite/gcc.dg/case-const-3.c
===
--- testsuite/gcc.dg/case-const-3.c	(revision 184254)
+++ testsuite/gcc.dg/case-const-3.c	(working copy)
@@ -4,6 +4,8 @@
 /* { dg-options "-pedantic-errors" } */
 
 extern int i;
+extern unsigned int u;
+
 void
 f (int c)
 {
@@ -13,3 +15,13 @@
   ;
 }
 }
+
+void
+b (int c)
+{
+  switch (c)
+{
+case (int) (2  | ((4 < 8) ? 8 : u)): /* { dg-error "case label is not an integer constant expression" } */
+  ;
+}
+}
2010-02-15  Christian Bruel  

	* gcc/c-common.c (c_fully_fold_internal): Don't create a new NOP expr.
	* gcc/fold-const.c (try_move_mult_to_index): assert CAN_HAVE_LOCATION_P.
	(fold_comparison): Likewise.
	* gcc/tree.c (build_case_label): Likewise.


Index: c-family/c-common.c
===
--- c-family/c-common.c	(revision 184254)
+++ c-family/c-common.c	(working copy)
@@ -1435,12 +1435,9 @@
  have been done by this point, so remove them again.  */
   nowarning |= TREE_NO_WARNING (ret);
   STRIP_TYPE_NOPS (ret);
-  if (nowarning && !TREE_NO_WARNING (ret))
-{
-  if (!CAN_HAVE_LOCATION_P (ret))
-	ret = build1 (NOP_EXPR, TREE_TYPE (ret), ret);
-  TREE_NO_WARNING (ret) = 1;
-}
+  if (nowarning)
+TREE_NO_WARNING (ret) = 1;
+
   if (ret != expr)
 protected_set_expr_location (ret, loc);
   return ret;
Index: tree.c
===
--- tree.c	(revision 184254)
+++ tree.c	(working copy)
@@ -1678,6 +1678,7 @@
   tree t = make_node (CASE_LABEL_EXPR);
 
   TREE_TYPE (t) = void_type_node;
+  gcc_assert (CAN_HAVE_LOCATION_P (t));
   SET_EXPR_LOCATION (t, DECL_SOURCE_LOCATION (label_decl));
 
   CASE_LOW (t) = low_value;
Index: fold-const.c
===
--- fold-const.c	(revision 184254)
+++ fold-const.c	(working copy)
@@ -6972,6 +6972,7 @@
 
   pref = TREE_OPERAND (addr, 0);
   ret = copy_node (pref);
+  gcc_assert (CAN_HAVE_LOCATION_P (ret));
   SET_EXPR_LOCATION (ret, loc);
   pos = ret;
 
@@ -9427,6 +9428,7 @@
 	  if (save_p)
 		{
 		  tem = save_expr (build2 (code, type, cval1, cval2));
+		  gcc_assert (CAN_HAVE_LOCATION_P (tem));
 		  SET_EXPR_LOCATION (tem, loc);
 		  return tem;
 		}


Re: PR middle-end/52141: ICE due to asm statement

2012-02-15 Thread Richard Guenther
On Tue, Feb 14, 2012 at 6:47 PM, Richard Henderson  wrote:
> On 02/14/2012 08:46 AM, Aldy Hernandez wrote:
>> The call to ipa_tm_diagnose_tm_safe() does nothing because there are no 
>> longer any calls in the function, since the function call has been inlined:
>>
>> f ()
>> {
>> :
>>   __asm__ __volatile__("");
>>   return;
>>
>> }
>>
>> Perhaps we could issue the error when we notice the GIMPLE_ASM while 
>> scanning for irrevocable blocks earlier.  The attached patch does so, and 
>> fixes the PR.
>>
>> What am I missing, cause I *know* there's a rat's nest somewhere.
>
> Ug.
>
> Which means that the error message is all too likely simply be confusing
> rather than anything else, since the asm isn't lexically present in the
> transaction.
>
> I wonder, not for the first time, if we shouldn't simply turn off early
> inlining with TM, or at least of and into tm-related functions, such as
> this.  I assume that the IPA inlining pass would take up the slack...

Hmm.  I think you rather want to teach local_pure_const about TM
properties you want to know and have them propagated properly
(of course unless pure/const which is about optimization and has an
easy fallback default yours wouldn't have that - you'd have to assume
the callee contains an invalid asm ...)

Richard.

>
> r~


Re: [PATCH] Prefer reg as first operand in commutative operator

2012-02-15 Thread Paulo J. Matos

On 14/02/12 14:10, Jakub Jelinek wrote:

On Tue, Feb 14, 2012 at 02:05:30PM +, Paulo J. Matos wrote:

I think the register allocator will generate good code using % if you
make your predicate nonimmediate_operand in operand 1:

(define_insn "iorqi3"
[(set (match_operand:QI 0 "register_operand" "=c")
(ior:QI (match_operand:QI 1 "nonimmediate_operand" "%0")
(match_operand:QI 2 "general_operand" "cwmi")))
(clobber (reg:CC RCC))]
"register_operand(operands[1], QImode) ||
register_operand(operands[2], QImode)"
"or\\t%0,%f2")



Yes, I think in general that seems to be the right procedure. In my
case, unfortunately it does not work.
The reason is that it allows:
(set (reg:QI ...)
  (ior:QI (mem:QI (reg:QI ...))
  (mem:QI (reg:QI ...

This wouldn't in general be a problem except that my backend only
has one register that can be used for a memory dereference, which
means that BASE_REG_CLASS is a class with a single register.


It doesn't allow that, because the condition on the insn then fails,
as neither operand 1 nor operand 2 is register_operand.



It doesn't look like you can actually do that because, according to the 
internals manual:
"For a named pattern, the condition (if present) may not depend on the 
data in the insn being matched, but only the target-machine-type flags. 
The compiler needs to test these conditions during initialization in 
order to learn exactly which named instructions are available in a 
particular run."


And GCC complains with:
insn-opinit.c: In function 'init_all_optabs':
insn-opinit.c:24: error: 'operands' undeclared (first use in this function)
insn-opinit.c:24: error: (Each undeclared identifier is reported only once
insn-opinit.c:24: error: for each function it appears in.)

Did I miss something in the example?


--
PMatos



Re: Backported 6 patches to 4.6 branch

2012-02-15 Thread Richard Guenther
On Wed, Feb 15, 2012 at 4:47 AM, Kenny Simpson
 wrote:
> Are any other recent trunk fixes to be backported - like the wrong-code bugs: 
> PR tree-optimization/50444, PR tree-optimization/51528, or PR 
> tree-optimization/46886 ?

I'll backport 46886 but like to defer 50444 and 51528 to 4.6.4 - they
are possibly
risky and deserve more exposure on trunk.

Richard.

> thanks,
> -Kenny


Re: [PATCH] Prefer reg as first operand in commutative operator

2012-02-15 Thread Jakub Jelinek
On Wed, Feb 15, 2012 at 10:04:15AM +, Paulo J. Matos wrote:
> It doesn't look like you can actually do that because, according to
> the internals manual:
> "For a named pattern, the condition (if present) may not depend on
> the data in the insn being matched, but only the target-machine-type
> flags. The compiler needs to test these conditions during
> initialization in order to learn exactly which named instructions
> are available in a particular run."
> 
> And GCC complains with:
> insn-opinit.c: In function 'init_all_optabs':
> insn-opinit.c:24: error: 'operands' undeclared (first use in this function)
> insn-opinit.c:24: error: (Each undeclared identifier is reported only once
> insn-opinit.c:24: error: for each function it appears in.)
> 
> Did I miss something in the example?

In define_expand (or define_insn of a standard named pattern) you can't use
operands, those conditions are used to select whether the given insn is
available at all.  But you can use it in define_insn conditions for other
insn patterns.
So you can have
(define_expand "iorqi3"
  ...
  "")

(define_insn "*iorqi3"
  ...
  "register_operand (operands[1], QImode) || register_operand (operands[2], 
QImode)"
...
)

See config/i386/i386.md for thousands of examples.

Jakub


Re: [patch] [4.6] Backport strict-volatile-bitfields fix PR51200

2012-02-15 Thread Richard Guenther
On Wed, Feb 15, 2012 at 8:23 AM, Ye Joey  wrote:
> Ping^2

All hunks apart from the expr.c hunk from 182545 are ok (thus, all hunks
that are explicitly guarded with -fstrict-volatile-bitfields).

Please use -p for diffs, I couldn't spot the place in expr.c you patch,
the line-numbers are off and the patch isn't against the 4.6 branch.

Please state how you tested you backports.

r182649 is ok (obvious ontop of 182545), likewise r182685.

Richard.

> On Mon, Jan 16, 2012 at 11:21 AM, Ye Joey  wrote:
>> Ping
>>
>> On Tue, Dec 27, 2011 at 10:19 AM, Ye Joey  wrote:
>>> Fix PR51200. Backport trunk 182545, 182649, 182685 to 4.6.
>>>
>>> OK to 4.6?
>>>
>>> - Joey
>>>
>>>        2011-12-20  Bernd Schmidt  
>>>
>>>        PR middle-end/51200
>>>        * expr.c (store_field): Avoid a direct store if the mode is larger
>>>        than the size of the bit field.
>>>        * stor-layout.c (layout_decl): If flag_strict_volatile_bitfields,
>>>        treat non-volatile bit fields like volatile ones.
>>>        * toplev.c (process_options): Disallow combination of
>>>        -fstrict-volatile-bitfields and ABI versions less than 2.
>>>        * config/arm/arm.c (arm_option_override): Don't enable
>>>        flag_strict_volatile_bitfields if the ABI version is less than 2.
>>>        * config/h8300/h8300.c (h8300_option_override): Likewise.
>>>        * config/rx/rx.c (rx_option_override): Likewise.
>>>        * config/m32c/m32c.c (m32c_option_override): Likewise.
>>>        * config/sh/sh.c (sh_option_override): Likewise.
>>>
>>>        2011-12-22  Joey Ye  
>>>
>>>        * toplev.c (process_options): Fix typo.
>>>
>>> testsute
>>>        2011-12-20  Bernd Schmidt  
>>>
>>>        PR middle-end/51200
>>>        * gcc.target/arm/volatile-bitfields-4.c: New test.
>>>        * c-c++-common/abi-bf.c: New test.
>>>
>>>        2011-12-26  Joey Ye  
>>>
>>>        PR middle-end/51200
>>>        * gcc.dg/volatile-bitfields-2.c: New test.


[Patch Darwin] fix missing __USER_LABEL_PREFIX__ on extended identifiers.

2012-02-15 Thread Iain Sandoe
I noticed when working on GAS for darwin that we fail to prepend the  
user label prefix for extended identifiers.


fixed as below,
OK for trunk/when?
Iain

gcc:

* config/darwin.h (ASM_OUTPUT_LABELREF): Add user label prefix
for extended identifiers.

diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 2425332..3e6efd7 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -615,7 +615,7 @@ int darwin_label_is_anonymous_local_objc_name  
(const char *name);
else if (!strncmp (xname, ".objc_class_name_",  
17))  \
 fprintf (FILE, "%s",  
xname);\
else if (xname[0] != '"' && name_needs_quotes  
(xname))   \
-fprintf (FILE, "\"%s\"",  
xname);\
+asm_fprintf (FILE, "\"%U%s\"",  
xname);  \
 
else \
  asm_fprintf (FILE, "%U%s",  
xname); \

   } while (0)


Re: [PATCH][ARM] Improve use of conditional execution in thumb mode.

2012-02-15 Thread Andrew Stubbs

On 14/02/12 18:30, Richard Earnshaw wrote:

s/obsolete peepholes/obsolete flag-clobbering peepholes/

Otherwise ok for stage1


Thanks.


The 'Similarly' that you delete suggests there might still be more of
them...


You'd think, but I can't figure out what that refers to.

There are some other peepholes that might be obsolete - I've not 
checked; I only deleted the ones I recognised.


Andrew


[PATCH] Fix PR50561

2012-02-15 Thread Richard Guenther

This patch by Tobias fixes PR50561.

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

Richard.

2012-02-15  Tobias Grosser 

PR tree-optimization/50561
* graphite-flattening.c (lst_project_loop): Do not
remove old scattering dimensions after flattening.
(lst_do_flatten): Likewise.

* gcc.dg/graphite/pr50561.c: New testcase.

Index: gcc/graphite-flattening.c
===
*** gcc/graphite-flattening.c   (revision 184259)
--- gcc/graphite-flattening.c   (working copy)
*** lst_project_loop (lst_p outer, lst_p inn
*** 277,288 
ppl_delete_Linear_Expression (expr);
  
/* Remove inner loop and the static schedule of its body.  */
!   ds = XNEWVEC (ppl_dimension_type, 2);
!   ds[0] = inner_dim;
!   ds[1] = inner_dim + 1;
!   ppl_Polyhedron_remove_space_dimensions (poly, ds, 2);
!   PBB_NB_SCATTERING_TRANSFORM (pbb) -= 2;
!   free (ds);
  }
  
mpz_clear (x);
--- 277,302 
ppl_delete_Linear_Expression (expr);
  
/* Remove inner loop and the static schedule of its body.  */
!   /* FIXME: As long as we use PPL we are not able to remove the old
!scattering dimensions.  The reason is that these dimensions are not
!entirely unused.  They are not necessary as part of the scheduling
!vector, as the earlier dimensions already unambiguously define the
!execution time, however they may still be needed to carry modulo
!constraints as introduced e.g. by strip mining.  The correct solution
!would be to project these dimensions out of the scattering polyhedra.
!In case they are still required to carry modulo constraints they 
should be kept
!internally as existentially quantified dimensions.  PPL does only 
support
!  projection of rational polyhedra, however in this case we need an 
integer
!projection. With isl this will be trivial to implement.  For now we 
just
!leave the dimensions. This is a little ugly, but should be correct.  */
!   if (0) {
!   ds = XNEWVEC (ppl_dimension_type, 2);
!   ds[0] = inner_dim;
!   ds[1] = inner_dim + 1;
!   ppl_Polyhedron_remove_space_dimensions (poly, ds, 2);
!   PBB_NB_SCATTERING_TRANSFORM (pbb) -= 2;
!   free (ds);
!   }
  }
  
mpz_clear (x);
*** lst_do_flatten (lst_p lst)
*** 412,418 
  if (LST_LOOP_P (l))
{
res |= lst_flatten_loop (l, zero);
!   remove_unused_scattering_dimensions (l);
}
  
lst_update_scattering (lst);
--- 426,446 
  if (LST_LOOP_P (l))
{
res |= lst_flatten_loop (l, zero);
! 
!   /* FIXME: As long as we use PPL we are not able to remove the old
!  scattering dimensions.  The reason is that these dimensions are not
!  entirely unused.  They are not necessary as part of the scheduling
!  vector, as the earlier dimensions already unambiguously define the
!  execution time, however they may still be needed to carry modulo
!  constraints as introduced e.g. by strip mining.  The correct solution
!  would be to project these dimensions out of the scattering polyhedra.
!  In case they are still required to carry modulo constraints they 
should be kept
!  internally as existentially quantified dimensions.  PPL does only 
support
!projection of rational polyhedra, however in this case we need an 
integer
!  projection. With isl this will be trivial to implement.  For now we 
just
!  leave the dimensions. This is a little ugly, but should be correct.  
*/
!   if (0)
! remove_unused_scattering_dimensions (l);
}
  
lst_update_scattering (lst);
Index: gcc/testsuite/gcc.dg/graphite/pr50561.c
===
*** gcc/testsuite/gcc.dg/graphite/pr50561.c (revision 0)
--- gcc/testsuite/gcc.dg/graphite/pr50561.c (revision 0)
***
*** 0 
--- 1,9 
+ /* { dg-do compile } */
+ /* { dg-options "-O2 -floop-flatten -floop-strip-mine" } */
+ 
+ void f (unsigned *s)
+ {
+   int n;
+   for (n = 0; n < 256; n++)
+ s[n] = 0;
+ }


Re: [PATCH] Fix PR50561

2012-02-15 Thread Tobias Grosser

On 02/15/2012 01:14 PM, Richard Guenther wrote:


This patch by Tobias fixes PR50561.

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


Thanks Richard.

Tobi


RE: [libitm] Link with -litm and -pthread

2012-02-15 Thread Greta Yorsh
This patch causes all tm tests to fail on arm-none-eabi target that doesn't
support -pthread command line option:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52259


> -Original Message-
> From: Eric Botcazou [mailto:ebotca...@adacore.com]
> Sent: 11 February 2012 19:24
> To: Jack Howarth
> Cc: gcc-patches@gcc.gnu.org
> Subject: Re: [libitm] Link with -litm and -pthread
> 
> >I missed the regeneration of libitm/configure the first time. The
> > p2.diff with the regenerated libitm/configure passes make check in
> libitm
> > now on x86_64-apple-darwin11...
> 
> Great, thanks for the testing.
> 
> --
> Eric Botcazou






Re: PR middle-end/52141: ICE due to asm statement

2012-02-15 Thread Aldy Hernandez

On 02/15/12 03:48, Richard Guenther wrote:

On Tue, Feb 14, 2012 at 6:47 PM, Richard Henderson  wrote:

On 02/14/2012 08:46 AM, Aldy Hernandez wrote:

The call to ipa_tm_diagnose_tm_safe() does nothing because there are no longer 
any calls in the function, since the function call has been inlined:

f ()
{
:
   __asm__ __volatile__("");
   return;

}

Perhaps we could issue the error when we notice the GIMPLE_ASM while scanning 
for irrevocable blocks earlier.  The attached patch does so, and fixes the PR.

What am I missing, cause I *know* there's a rat's nest somewhere.


Ug.

Which means that the error message is all too likely simply be confusing
rather than anything else, since the asm isn't lexically present in the
transaction.


That's why I also specified the calling function in the error message. 
But I do agree that the message has the potential of confusing.




I wonder, not for the first time, if we shouldn't simply turn off early
inlining with TM, or at least of and into tm-related functions, such as
this.  I assume that the IPA inlining pass would take up the slack...


You will hear no complaints from me.  I'm tired of fixing the same bug 
over and over.



Hmm.  I think you rather want to teach local_pure_const about TM
properties you want to know and have them propagated properly
(of course unless pure/const which is about optimization and has an
easy fallback default yours wouldn't have that - you'd have to assume
the callee contains an invalid asm ...)


Richard G., can you explain the parenthesized comment.  I'm not sure I 
follow you.


Go patch committed: Avoid crashes on erroneous input

2012-02-15 Thread Ian Lance Taylor
This patch to the Go frontend avoids some compiler crashes on erroneous
inputs.  It also makes some minor fixes to some comments.  Bootstrapped
and ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to
mainline.

Ian

diff -r 4f7eddf7a851 go/backend.h
--- a/go/backend.h	Tue Feb 14 12:39:26 2012 -0800
+++ b/go/backend.h	Wed Feb 15 06:31:05 2012 -0800
@@ -126,7 +126,9 @@
 
   // Fill in a placeholder pointer type as a pointer.  This takes a
   // type returned by placeholder_pointer_type and arranges for it to
-  // point to to_type.  Returns true on success, false on failure.
+  // point to the type that TO_TYPE points to (that is, PLACEHOLDER
+  // becomes the same type as TO_TYPE).  Returns true on success,
+  // false on failure.
   virtual bool
   set_placeholder_pointer_type(Btype* placeholder, Btype* to_type) = 0;
 
diff -r 4f7eddf7a851 go/gogo.cc
--- a/go/gogo.cc	Tue Feb 14 12:39:26 2012 -0800
+++ b/go/gogo.cc	Wed Feb 15 06:31:05 2012 -0800
@@ -4180,6 +4180,11 @@
 	package != NULL,
 	Gogo::is_hidden_name(name),
 	this->location_);
+	  else if (function == NULL)
+	{
+	  go_assert(saw_errors());
+	  bvar = backend->error_variable();
+	}
 	  else
 	{
 	  tree fndecl = function->func_value()->get_decl();
diff -r 4f7eddf7a851 go/types.cc
--- a/go/types.cc	Tue Feb 14 12:39:26 2012 -0800
+++ b/go/types.cc	Wed Feb 15 06:31:05 2012 -0800
@@ -3595,7 +3595,7 @@
   return this->to_type_->hash_for_method(gogo) << 4;
 }
 
-// The tree for a pointer type.
+// Get the backend representation for a pointer type.
 
 Btype*
 Pointer_type::do_get_backend(Gogo* gogo)
@@ -5345,6 +5345,7 @@
 }
 
 // Return the backend representation of the element type.
+
 Btype*
 Array_type::get_backend_element(Gogo* gogo)
 {
@@ -7567,6 +7568,11 @@
 	  this->find_type_->add_dependency(type->named_type());
 	  break;
 
+	case Type::TYPE_NAMED:
+	case Type::TYPE_FORWARD:
+	  go_assert(saw_errors());
+	  break;
+
 	case Type::TYPE_VOID:
 	case Type::TYPE_SINK:
 	case Type::TYPE_FUNCTION:
@@ -7575,8 +7581,6 @@
 	case Type::TYPE_MAP:
 	case Type::TYPE_CHANNEL:
 	case Type::TYPE_INTERFACE:
-	case Type::TYPE_NAMED:
-	case Type::TYPE_FORWARD:
 	default:
 	  go_unreachable();
 	}


Re: Ping #1: [Committed,testsuite]: Fix testcase that bangs long and int against void*

2012-02-15 Thread Georg-Johann Lay
Georg-Johann Lay wrote:
> Jakub Jelinek wrote:
>> On Wed, Feb 01, 2012 at 02:00:53PM +0100, Georg-Johann Lay wrote:
* gcc.dg/lto/20091013-1_1.c: xfail for avr.
* gcc.dg/lto/20091013-1_2.c: xfail for avr.
>> If it is just because of the warnings, can't you
>> add
>> -Wno-int-to-pointer-cast -Wno-pointer-to-int-cast
>> to dg-options?
> 
> dg-additional-options triggers
> WARNING: lto.exp does not support dg-additional-options
> 
>> Also, not sure how effective is dg-xfail-if in the secondary
>> source files, the *_0.c is where all the dg directives are for it.
> 
> The FAILs return if dg-xfail-if is removed from 1.c/2.c and added to 0.c
> 
> dg-xfail-if only works if added in each and every individual source that
> triggers a warning.

I went ahead and installed the patch. It only disables for avr to avoid
disturbing other targets:

http://gcc.gnu.org/viewcvs?view=revision&revision=184276

Johann



Re: PR middle-end/52141: ICE due to asm statement

2012-02-15 Thread Richard Guenther
On Wed, Feb 15, 2012 at 3:30 PM, Aldy Hernandez  wrote:
> On 02/15/12 03:48, Richard Guenther wrote:
>>
>> On Tue, Feb 14, 2012 at 6:47 PM, Richard Henderson  wrote:
>>>
>>> On 02/14/2012 08:46 AM, Aldy Hernandez wrote:

 The call to ipa_tm_diagnose_tm_safe() does nothing because there are no
 longer any calls in the function, since the function call has been inlined:

 f ()
 {
 :
   __asm__ __volatile__("");
   return;

 }

 Perhaps we could issue the error when we notice the GIMPLE_ASM while
 scanning for irrevocable blocks earlier.  The attached patch does so, and
 fixes the PR.

 What am I missing, cause I *know* there's a rat's nest somewhere.
>>>
>>>
>>> Ug.
>>>
>>> Which means that the error message is all too likely simply be confusing
>>> rather than anything else, since the asm isn't lexically present in the
>>> transaction.
>
>
> That's why I also specified the calling function in the error message. But I
> do agree that the message has the potential of confusing.
>
>
>>>
>>> I wonder, not for the first time, if we shouldn't simply turn off early
>>> inlining with TM, or at least of and into tm-related functions, such as
>>> this.  I assume that the IPA inlining pass would take up the slack...
>
>
> You will hear no complaints from me.  I'm tired of fixing the same bug over
> and over.
>
>
>> Hmm.  I think you rather want to teach local_pure_const about TM
>> properties you want to know and have them propagated properly
>> (of course unless pure/const which is about optimization and has an
>> easy fallback default yours wouldn't have that - you'd have to assume
>> the callee contains an invalid asm ...)
>
>
> Richard G., can you explain the parenthesized comment.  I'm not sure I
> follow you.

Ok, I had a look at the bugreport and am curios why

__attribute__((always_inline))
static void asmfunc(void)
{
  __asm__ ("");
}

__attribute__((transaction_safe))
static void f(void)
{
  asmfunc();
}

you'd want a diagnostic when asmfunc is not inlined but OTOH do not
want to ICE when it is.  Why not diagnose GIMPLE_ASMs alongside
other 'unsafe function calls'.  Thus, why does __attribute__((transaction_safe))
not transitively cover all its callees (does it?)?

The comment of ipa_tm_diagnose_tm_safe says

/* Diagnose calls from transaction_safe functions to unmarked
   functions that are determined to not be safe.  */

and this "determined to not be safe" is what I was refering to with pointing
to how we handle pure/const "discovery".

For the asm above - how do you discover an asm is "unsafe"?  I suppose
you cannot, and you only consider asms lexically in a function marked
as transaction-safe as safe?  If so might I suggest to use a flag on the
GIMPLE_ASM stmt, set during initial tm lowering (or even during parsing maybe)?

Contrary to what rth says we _do_ have callgraph information available
during early optimization / inlining.  The callgraph is built over
GENERIC already.
So as you compute/propagate the tm_may_enter_irr flag only during
IPA TM you might do better (with deciding what to allow to inline during
early inlining, or other stuff) if you compute this function local property
(conservatively) late in the early optimization pipeline, close to
pass_local_pure_const (or simply integrated within it) - benefiting from
trivial propagation ensured by the way we walk functions in the callgraph
during early optimizations.  The IPA TM pass then simply would do the
propagation of the flag (no need to scan function bodies here, so this can
even work at LTO level!)

So, I guess the flag on the GIMPLE_ASM would be a way to fix 52141
(and probably the only sensible one?).  The hint at the local-pure-const
stuff would make IPA TM work at LTO level.

Hope that helps ;)

Richard.


[Patch,AVR]: Fix missing prototype warning for ACCUMULATE_OUTGOING_ARGS

2012-02-15 Thread Georg-Johann Lay
Some parts outside the backend use ACCUMULATE_OUTGOING_ARGS without including
tm_p.h which lead to a build warning because avr.h does

#define ACCUMULATE_OUTGOING_ARGS avr_accumulate_outgoing_args()

This patcs moved the prototype from avr-protos.h to avr.h:

* config/avr/avr-protos.h (avr_accumulate_outgoing_args): Move
prototype from here to...
* config/avr/avr.h: ...here.

Ok for trunk?

Johann


Index: config/avr/avr-protos.h
===
--- config/avr/avr-protos.h (revision 184266)
+++ config/avr/avr-protos.h (working copy)
@@ -33,7 +33,6 @@ extern int avr_simple_epilogue (void);
 extern int avr_hard_regno_rename_ok (unsigned int, unsigned int);
 extern rtx avr_return_addr_rtx (int count, rtx tem);
 extern void avr_register_target_pragmas (void);
-extern bool avr_accumulate_outgoing_args (void);
 extern void avr_init_expanders (void);

 #ifdef TREE_CODE
Index: config/avr/avr.h
===
--- config/avr/avr.h(revision 184269)
+++ config/avr/avr.h(working copy)
@@ -676,6 +676,7 @@ struct GTY(()) machine_function
required in order for pushes to be generated.  */
 #define PUSH_ROUNDING(X)   (X)

+extern bool avr_accumulate_outgoing_args (void);
 #define ACCUMULATE_OUTGOING_ARGS avr_accumulate_outgoing_args()

 #define INIT_EXPANDERS avr_init_expanders()


Re: [Patch,wwwdocs,AVR]: AVR release notes

2012-02-15 Thread Georg-Johann Lay
Gerald Pfeifer wrote:

> Looks good!  Please fix the one typo, and consider the other comments
> as well, and go ahead and commit this I'd say.  We can always make
> further changes later.

Committed with the following changes:

* Support for XMEGA cores
* Mini-example for address space code.

http://gcc.gnu.org/gcc-4.7/changes.html

But there is a problem with the link to built-ins in onlinedocs.

The HTML reads

Support for AVR-specific http://gcc.gnu.org/onlinedocs/gcc/AVR-Built_002din-Functions.html";>built-in
functions has been added.

But that is not used literally but as
"http://gcc.gnu.org/onlinedocs/gcc/AVR-Built-in-Functions.html";
instead leading to 404 "Not found" error.

It _002d link works from by local sandbox but not from the upstream version.

What is the trick?

Johann




Re: PR middle-end/52141: ICE due to asm statement

2012-02-15 Thread Aldy Hernandez
[rth, please correct me if I have misrepresented the TM semantics and 
rules].


On 02/15/12 09:04, Richard Guenther wrote:


Ok, I had a look at the bugreport and am curios why

__attribute__((always_inline))
static void asmfunc(void)
{
   __asm__ ("");
}

__attribute__((transaction_safe))
static void f(void)
{
   asmfunc();
}

you'd want a diagnostic when asmfunc is not inlined but OTOH do not
want to ICE when it is.  Why not diagnose GIMPLE_ASMs alongside
other 'unsafe function calls'.  Thus, why does __attribute__((transaction_safe))
not transitively cover all its callees (does it?)?


No, transaction_safe does not transitively cover its callees.  A 
transaction safe function cannot call unsafe functions, nor can 
GIMPLE_ASMs appear in it.


(This was confusing for me at first too, because transaction_pure OTOH, 
does allow any type of call inside, or GIMPLE_ASM.  For 
transaction_pure, no instrumentation is done, and the function is 
outputted as is.)




The comment of ipa_tm_diagnose_tm_safe says

/* Diagnose calls from transaction_safe functions to unmarked
functions that are determined to not be safe.  */

and this "determined to not be safe" is what I was refering to with pointing
to how we handle pure/const "discovery".


Interesting.  I suppose we can add a cgraph bit for "this function may 
go irrevocable" and accumulate it during pure/const discovery.



For the asm above - how do you discover an asm is "unsafe"?  I suppose
you cannot, and you only consider asms lexically in a function marked
as transaction-safe as safe?  If so might I suggest to use a flag on the
GIMPLE_ASM stmt, set during initial tm lowering (or even during parsing maybe)?


No, AFAIK, asms aren't safe even in transaction_safe functions (don't 
look at me, I didn't write the standard).  But rth can correct me if I'm 
wrong.



So as you compute/propagate the tm_may_enter_irr flag only during
IPA TM you might do better (with deciding what to allow to inline during
early inlining, or other stuff) if you compute this function local property
(conservatively) late in the early optimization pipeline, close to
pass_local_pure_const (or simply integrated within it) - benefiting from
trivial propagation ensured by the way we walk functions in the callgraph
during early optimizations.  The IPA TM pass then simply would do the
propagation of the flag (no need to scan function bodies here, so this can
even work at LTO level!)


Nice.  I like it.  I will play around with it.


Hope that helps ;)


Definitely, thanks!
Aldy


Re: [PATCH, 4.6 regression]. New error: case label does not reduce

2012-02-15 Thread Joseph S. Myers
On Wed, 15 Feb 2012, Christian Bruel wrote:

> Removal of this NOP_EXPR if !CAN_HAVE_LOCATION_P fixes the problem.
> looks safe from my testing, because the loc is inserted using
> 'protected_set_expr_location', whereas no loc for a constant case
> doesn't seem to introduce new problems with the debugging information.
> But in case I also added a few paranoid gcc_assert.

Is it safe to set TREE_NO_WARNING without that check?  I'd have thought 
the check was to avoid setting TREE_NO_WARNING on a shared node when 
warnings are to be disabled in only one context where that node is used.

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


Re: [Patch,wwwdocs,AVR]: AVR release notes

2012-02-15 Thread Georg-Johann Lay
Georg-Johann Lay wrote:

> http://gcc.gnu.org/gcc-4.7/changes.html
> 
> But there is a problem with the link to built-ins in onlinedocs.
> 
> The HTML reads
> 
> Support for AVR-specific  href="http://gcc.gnu.org/onlinedocs/gcc/AVR-Built_002din-Functions.html";>built-in
> functions has been added.
> 
> But that is not used literally but as
> "http://gcc.gnu.org/onlinedocs/gcc/AVR-Built-in-Functions.html";
> instead leading to 404 "Not found" error.
> 
> It _002d link works from by local sandbox but not from the upstream version.
> 
> What is the trick?

Hacked around it by escaping _002d as %5f002d so that _002d is not resolved to -

Johann



Re: [PATCH] Fix up --enable-initfini-array autodetection in configure (PR bootstrap/50237)

2012-02-15 Thread Rainer Orth
Paolo Bonzini  writes:

> This must be a separate macro in acinclude.m4 that is AC_REQUIREd from
> gcc_AC_INITFINI_ARRAY.

Here's an updated patch that does so.  During testing, I found one
additional complication, though.  With the Sun as/GNU ld combination on
Solaris 11/x86, after the bootstrap had completed, all programs linked
against libgcc_s.so.1 SEGVed with a stacktrace like this:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1 (LWP 1)]
0x2000 in ?? ()
(gdb) where
#0  0x2000 in ?? ()
#1  0xfefcd73f in call_array () from /usr/lib/ld.so.1
#2  0xfefcd8bd in call_init () from /usr/lib/ld.so.1
#3  0xfefcc8e1 in setup () from /usr/lib/ld.so.1
#4  0xfefdcfd8 in _setup () from /usr/lib/ld.so.1
#5  0xfefc0674 in _rt_boot () from /usr/lib/ld.so.1
#6  0x0804796c in ?? ()
#7  0x08047ab0 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

The problem turned out to be that with

.section.init_array

as generates 

Section Header[5]:  sh_name: .init_array
sh_addr:  0   sh_flags:   0
sh_size:  0x4 sh_type:[ SHT_PROGBITS ]
sh_offset:0x344   sh_entsize: 0
sh_link:  0   sh_info:0
sh_addralign: 0x4   

i.e. empty sh_flags.  gld seems to mishandle this, since the
corresponding .initarray entry is bad, as can be seen with runtime
linker debugging:

$ LD_DEBUG=init LD_PRELOAD=./libgcc_s.so.1 ls
[...]
02032: 1: calling .initarray[0]:0xfed77100: ./libgcc_s.so.1
02032: 1: calling .initarray[1]:0x2000: ./libgcc_s.so.1
Segmentation Fault

If I change the above to

.section.init_array,"aw",@progbits

everything works fine with as/gld, but breaks again with gas/gld since
gas warns about @progbits here.  It turned out that 

.section.init_array,"aw"

is fine with both assemblers, while as doesn't understand @init_array.
That's what the patch below uses.

> Can you test Linux too?  The change of -e0 looks good, but I'd rather check
> on the actual system.

This patch has been bootstrapped on i386-pc-solaris2.{8, 9, 10, 11} with
as/ld, gas/ld and gas/gld, i386-pc-solaris2.11 with as/gld, as well as
x86_64-unknown-linux-gnu, correctly detecting .init_array etc. support
on the gld configurations.  It was also included with
sparc-sun-solaris2.* bootstraps, but even with gas/gld the configure
test fails.  I've got to investigate that separately.

Ok for mainline now?

Thanks.
Rainer


2012-01-20  Rainer Orth  

PR target/50166
* acinclude.m4 (gcc_AC_INITFINI_ARRAY): Require gcc_SUN_LD_VERSION.
Define _start.
Remove -e 0 from $gcc_cv_ld invocation.
Only use __GLIBC_PREREQ if defined.
Enable on Solaris since Solaris 8 patch.
(gcc_SUN_LD_VERSION): New macro.
* configure.ac (ld_ver) <*-*-solaris2*>: Refer to
gcc_SUN_LD_VERSION for version number format.
* configure: Regenerate.
* varasm.c (get_elf_initfini_array_priority_section): Use
get_section instead of get_unnamed_section to emit
.init_array/.fini_array with default priority.

# HG changeset patch
# Parent f6f07805e84c98b61a355272d359379b57cca7d2
Enable initfini array support on Solaris

diff --git a/gcc/acinclude.m4 b/gcc/acinclude.m4
--- a/gcc/acinclude.m4
+++ b/gcc/acinclude.m4
@@ -1,4 +1,5 @@
-dnl Copyright (C) 2005, 2006, 2007, 2008, 2011 Free Software Foundation, Inc.
+dnl Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012
+dnl Free Software Foundation, Inc.
 dnl
 dnl This file is part of GCC.
 dnl
@@ -370,7 +371,8 @@ fi
 fi])
 
 AC_DEFUN([gcc_AC_INITFINI_ARRAY],
-[AC_ARG_ENABLE(initfini-array,
+[AC_REQUIRE([gcc_SUN_LD_VERSION])dnl
+AC_ARG_ENABLE(initfini-array,
 	[  --enable-initfini-array	use .init_array/.fini_array sections],
 	[], [
 AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support,
@@ -427,9 +429,11 @@ int (*fp) (void) __attribute__ ((section
 .balign 4
 .byte 'H', 'H', 'H', 'H'
 .text
+.globl _start
+_start:
 EOF
 	  if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \
-	 && $gcc_cv_ld -e 0 -o conftest conftest.o > /dev/null 2>&1 \
+	 && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1 \
 	 && $gcc_cv_objdump -s -j .init_array conftest \
 		| grep  > /dev/null 2>&1 \
 	 && $gcc_cv_objdump -s -j .fini_array conftest \
@@ -442,14 +446,38 @@ changequote([,])dnl
 	fi
 	AC_PREPROC_IFELSE([AC_LANG_SOURCE([
 #ifndef __ELF__
-#error Not an ELF OS
+# error Not an ELF OS
 #endif
 #include 
-#if defined __GLIBC_PREREQ && __GLIBC_PREREQ (2, 4)
+#if defined __GLIBC_PREREQ
+# if __GLIBC_PREREQ (2, 4)
+# else
+#  error GLIBC 2.4 required
+# endif
 #else
-#error The C library not known to support .init_array/.fini_array
+# if defined __sun__ && defined __svr4__
+   /* Solaris ld.so.1 supports .init_array/.fini_array since Solaris 8.  */
+# else
+#  error The C library not known to support .init_array/.fini_array
+# endif
 #

Re: [PATCH] Fix up --enable-initfini-array autodetection in configure (PR bootstrap/50237)

2012-02-15 Thread Paolo Bonzini
On 02/15/2012 06:09 PM, Rainer Orth wrote:
> Paolo Bonzini  writes:
> 
>> This must be a separate macro in acinclude.m4 that is AC_REQUIREd from
>> gcc_AC_INITFINI_ARRAY.
> 
> Here's an updated patch that does so.  During testing, I found one
> additional complication, though.  With the Sun as/GNU ld combination on
> Solaris 11/x86, after the bootstrap had completed, all programs linked
> against libgcc_s.so.1 SEGVed with a stacktrace like this:
> 
> Program received signal SIGSEGV, Segmentation fault.
> [Switching to Thread 1 (LWP 1)]
> 0x2000 in ?? ()
> (gdb) where
> #0  0x2000 in ?? ()
> #1  0xfefcd73f in call_array () from /usr/lib/ld.so.1
> #2  0xfefcd8bd in call_init () from /usr/lib/ld.so.1
> #3  0xfefcc8e1 in setup () from /usr/lib/ld.so.1
> #4  0xfefdcfd8 in _setup () from /usr/lib/ld.so.1
> #5  0xfefc0674 in _rt_boot () from /usr/lib/ld.so.1
> #6  0x0804796c in ?? ()
> #7  0x08047ab0 in ?? ()
> Backtrace stopped: previous frame inner to this frame (corrupt stack?)
> 
> The problem turned out to be that with
> 
>   .section.init_array
> 
> as generates 
> 
> Section Header[5]:  sh_name: .init_array
> sh_addr:  0   sh_flags:   0
> sh_size:  0x4 sh_type:[ SHT_PROGBITS ]
> sh_offset:0x344   sh_entsize: 0
> sh_link:  0   sh_info:0
> sh_addralign: 0x4   
> 
> i.e. empty sh_flags.  gld seems to mishandle this, since the
> corresponding .initarray entry is bad, as can be seen with runtime
> linker debugging:
> 
> $ LD_DEBUG=init LD_PRELOAD=./libgcc_s.so.1 ls
> [...]
> 02032: 1: calling .initarray[0]:0xfed77100: ./libgcc_s.so.1
> 02032: 1: calling .initarray[1]:0x2000: ./libgcc_s.so.1
> Segmentation Fault
> 
> If I change the above to
> 
>   .section.init_array,"aw",@progbits
> 
> everything works fine with as/gld, but breaks again with gas/gld since
> gas warns about @progbits here.  It turned out that 
> 
>   .section.init_array,"aw"
> 
> is fine with both assemblers, while as doesn't understand @init_array.
> That's what the patch below uses.
> 
>> Can you test Linux too?  The change of -e0 looks good, but I'd rather check
>> on the actual system.
> 
> This patch has been bootstrapped on i386-pc-solaris2.{8, 9, 10, 11} with
> as/ld, gas/ld and gas/gld, i386-pc-solaris2.11 with as/gld, as well as
> x86_64-unknown-linux-gnu, correctly detecting .init_array etc. support
> on the gld configurations.  It was also included with
> sparc-sun-solaris2.* bootstraps, but even with gas/gld the configure
> test fails.  I've got to investigate that separately.
> 
> Ok for mainline now?
> 
> Thanks.
>   Rainer
> 
> 
> 2012-01-20  Rainer Orth  
> 
>   PR target/50166
>   * acinclude.m4 (gcc_AC_INITFINI_ARRAY): Require gcc_SUN_LD_VERSION.
>   Define _start.
>   Remove -e 0 from $gcc_cv_ld invocation.
>   Only use __GLIBC_PREREQ if defined.
>   Enable on Solaris since Solaris 8 patch.
>   (gcc_SUN_LD_VERSION): New macro.
>   * configure.ac (ld_ver) <*-*-solaris2*>: Refer to
>   gcc_SUN_LD_VERSION for version number format.
>   * configure: Regenerate.
>   * varasm.c (get_elf_initfini_array_priority_section): Use
>   get_section instead of get_unnamed_section to emit
>   .init_array/.fini_array with default priority.

Build parts are okay.  I cannot approve the varasm.c changes.

Paolo


Re: [Patch Darwin] fix missing __USER_LABEL_PREFIX__ on extended identifiers.

2012-02-15 Thread Mike Stump
On Feb 15, 2012, at 2:21 AM, Iain Sandoe wrote:
> I noticed when working on GAS for darwin that we fail to prepend the user 
> label prefix for extended identifiers.

Does this match the native compiler on the platform?  This is abi changing, and 
we can't do it, unless it mismatches the native compiler?


Re: PR middle-end/52141: ICE due to asm statement

2012-02-15 Thread Richard Henderson
On 02/15/2012 01:48 AM, Richard Guenther wrote:
> Hmm.  I think you rather want to teach local_pure_const about TM
> properties you want to know and have them propagated properly
> (of course unless pure/const which is about optimization and has an
> easy fallback default yours wouldn't have that - you'd have to assume
> the callee contains an invalid asm ...)

That's more or less what we do ourselves during the tm ipa pass.

The trouble we have here is merely one of diagnostics.  The user
has written "transaction safe" and it's now our job to tell him
when he's done something that's not transaction safe.

The unfortunate thing of diagnostics is you'd like to be able to
tell the user what they did wrong at the source level, not after
10 levels of inlining.

And given that pass_local_pure_const still runs after pass_early_inline,
doing anything in there doesn't really help the problem at all.


r~


Re: PR middle-end/52141: ICE due to asm statement

2012-02-15 Thread Jakub Jelinek
On Wed, Feb 15, 2012 at 09:29:18AM -0800, Richard Henderson wrote:
> On 02/15/2012 01:48 AM, Richard Guenther wrote:
> > Hmm.  I think you rather want to teach local_pure_const about TM
> > properties you want to know and have them propagated properly
> > (of course unless pure/const which is about optimization and has an
> > easy fallback default yours wouldn't have that - you'd have to assume
> > the callee contains an invalid asm ...)
> 
> That's more or less what we do ourselves during the tm ipa pass.
> 
> The trouble we have here is merely one of diagnostics.  The user
> has written "transaction safe" and it's now our job to tell him
> when he's done something that's not transaction safe.
> 
> The unfortunate thing of diagnostics is you'd like to be able to
> tell the user what they did wrong at the source level, not after
> 10 levels of inlining.
> 
> And given that pass_local_pure_const still runs after pass_early_inline,
> doing anything in there doesn't really help the problem at all.

Use %K in error/warning fmt string, then the diagnostic will include the
full virtual backtrace.

Jakub


[v3, libgomp, build] Fix Solaris symbol versioning (PR libstdc++/52188)

2012-02-15 Thread Rainer Orth
Prompted by the suggestions in the PR what to do about the new exports
of 

_ZNSt19istreambuf_iteratorIcSt11char_traitsIcEEppEv
_ZNSt19istreambuf_iteratorIwSt11char_traitsIwEEppEv

at GLIBCXX_3.4.5 on Solaris, I've followed the preprocess *.ver files
route Jakub suggested to just omit those two on Solaris.

I considered several different preprocessors, but ultimately settled for
cpp/gcc -E:

* m4 is currently a developer-only requirement, and feels clumsy.

* Likewise for perl, which so far is only required for symbol versioning
  support on Solaris, but would now be required for every platform.

* Both options suffer from the requirement to provide at set of defines
  per target while some (like the current
  HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT) are already defined for
  cpp.  One should probably provide the components of the target triplet
  later, if need be.

Using cpp works fine after filtering out *.ver file comments that are
not cpp directives.  At the same time, it allowed to remove the hacky
#ifdef handling in make_sunver.pl or via sed.  The latter was handled by
the ENABLE_SYMVERS_SOL2 conditional so far, which can now go.

Since libgomp uses the same hack to handle
HAVE_SYMVER_SYMBOL_RENAMING_RUNTIME_SUPPORT, I applied the same solution
there, too.  There are two caveats:

* The preprocessed libgomp.map has to be called something else
  (libgomp.ver), otherwise make complains about a circular dependency
  between $(top_srcdir)/libgomp.map and libgomp.map.

* I need to remove the libtool-only -Wc, option from $(COMPILE),
  otherwise gcc -E complains.

Bootstrapped without regressions on {sparc-sun,i386-pc}-solaris2.{8, 9,
10, 11} with as/ld, gas/ld, gas/gld and x86_64-unknown-linux-gnu.  With
updates libstdc++ baselines, there are now errors and the undesired
symbols are gone, while on Linux/x86_64 there are no differences in the
readelf output from libstdc++-v3/scripts/extract_symvers.in without and
with the patch.

Ok for mainline?

Rainer


2012-02-12  Rainer Orth  

contrib:
PR libstdc++/52188
* make_sunver.pl: Remove #ifdef handling.

libgomp:
PR libstdc++/52188
* acinclude.m4 (LIBGOMP_ENABLE_SYMVERS): Remove symvers_renaming.
Remove ENABLE_SYMVERS_SOL2.
* configure: Regenerate.
* Makefile.am [LIBGOMP_BUILD_VERSIONED_SHLIB] (comma): New variable.
(PREPROCESS): New variable.
(libgomp.ver): New target.
[LIBGOMP_BUILD_VERSIONED_SHLIB &&
LIBGOMP_BUILD_VERSIONED_SHLIB_GNU]: Remove
LIBGOMP_BUILD_VERSIONED_SHLIB_SOL2 handling.
Use libgomp.ver.
[LIBGOMP_BUILD_VERSIONED_SHLIB_SUN]: Use libgomp.ver, libgomp.ver-sun.
* Makefile.in: Regenerate.

libstdc++-v3:
PR libstdc++/52188
* acinclude.m4 (GLIBCXX_ENABLE_SYMVERS): Remove symvers_renaming.
Remove ENABLE_SYMVERS_SOL2.
* configure: Regenerate.
* src/Makefile.am [ENABLE_SYMVERS] (libstdc++-symbols.ver):
Postprocess mapfile.
[ENABLE_SYMVERS_GNU]: Remove ENABLE_SYMVERS_SOL2 handling.
* src/Makefile.in: Regenerate.

* config/abi/pre/gnu.ver (GLIBCXX_3.4.5) [!__sun__ && !__svr4__]:
Don't export
_ZNSt19istreambuf_iteratorI[cw]St11char_traitsI[cw]EEppEv.

# HG changeset patch
# Parent a310ee31985e25bd0e53f4eaddd686e1cb21c5fd
Fix Solaris symbol versioning (PR libstdc++/52188, libstdc++/52189)

diff --git a/contrib/make_sunver.pl b/contrib/make_sunver.pl
--- a/contrib/make_sunver.pl
+++ b/contrib/make_sunver.pl
@@ -156,9 +156,6 @@ my $glob = 'glob';
 # We're currently inside `extern "C++"', which Sun ld doesn't understand.
 my $in_extern = 0;
 
-# We're currently inside a conditional section: just skip it.
-my $in_ifdef = 0;
-
 # The c++filt command to use.  This *must* be GNU c++filt; the Sun Studio
 # c++filt doesn't handle the GNU mangling style.
 my $cxxfilt = $ENV{'CXXFILT'} || "c++filt";
@@ -183,15 +180,6 @@ printf "# Omitted archives with correspo
 print "#\n\n";
 
 while () {
-# End of skipped section.
-if (/^[ \t]*\#endif/) {
-	$in_ifdef = 0;
-	next;
-}
-
-# Just skip a conditional section.
-if ($in_ifdef) { next; }
-
 # Lines of the form '};'
 if (/^([ \t]*)(\}[ \t]*;[ \t]*)$/) {
 	$glob = 'glob';
@@ -216,15 +204,6 @@ while () {
 	print; next;
 }
 
-# Special comments that look like C preprocessor conditionals.
-# Just skip the contents for now.
-# FIXME: Allow passing in conditionals from the command line to really
-# control the skipping.
-if (/^[ \t]*\#ifdef/) {
-	$in_ifdef = 1;
-	next;
-}
-
 # Comment and blank lines
 if (/^[ \t]*\#/) { print; next; }
 if (/^[ \t]*$/) { print; next; }
diff --git a/libgomp/Makefile.am b/libgomp/Makefile.am
--- a/libgomp/Makefile.am
+++ b/libgomp/Makefile.am
@@ -22,26 +22,26 @@ toolexeclib_LTLIBRARIES = libgomp.la
 nodist_toolexeclib_HEADERS = libgomp.spec
 
 if LIBGOMP_BUILD_VERSIONED_SHLIB
+# -Wc is only

[lra] patch to fix a wrong code generation for bulldozer.

2012-02-15 Thread Vladimir Makarov
The following patch fixes wrong code generation for SPEC2000 mesa when 
we use tuning for bulldozer.


The patch was successfully bootstrapped on x86/x86-64.

Committed as rev. 184278.

2012-02-15  Vladimir Makarov 

* lra-coalesce.c (lra_coalesce): Check the split pseudos too.

Index: lra-coalesce.c
===
--- lra-coalesce.c  (revision 184177)
+++ lra-coalesce.c  (working copy)
@@ -195,10 +195,12 @@ lra_coalesce (void)
 {
   basic_block bb;
   rtx mv, set, insn, next, *sorted_moves;
-  int i, n, mv_num, sregno, dregno;
+  int i, n, mv_num, sregno, dregno, restore_regno;
+  unsigned int regno;
   int coalesced_moves;
   int max_regno = max_reg_num ();
-  bitmap_head involved_insns_bitmap;
+  bitmap_head involved_insns_bitmap, split_origin_bitmap;
+  bitmap_iterator bi;
 
   if (lra_dump_file != NULL)
 fprintf (lra_dump_file,
@@ -210,6 +212,11 @@ lra_coalesce (void)
 first_coalesced_pseudo[i] = next_coalesced_pseudo[i] = i;
   sorted_moves = (rtx *) xmalloc (get_max_uid () * sizeof (rtx));
   mv_num = 0;
+  /* Collect pseudos whose live ranges were split.  */
+  bitmap_initialize (&split_origin_bitmap, ®_obstack);
+  EXECUTE_IF_SET_IN_BITMAP (&lra_split_pseudos, 0, regno, bi)
+if ((restore_regno = lra_reg_info[regno].restore_regno) >= 0)
+  bitmap_set_bit (&split_origin_bitmap, restore_regno);
   /* Collect moves.  */
   coalesced_moves = 0;
   FOR_EACH_BB (bb)
@@ -226,6 +233,12 @@ lra_coalesce (void)
   inheritance' pass.  */
&& lra_reg_info[sregno].restore_regno < 0
&& lra_reg_info[dregno].restore_regno < 0
+   /* We undo splits for spilled pseudos whose live ranges
+  were split.  So don't coalesce them, it is not
+  necessary and the undo transformations would be
+  wrong.  */
+   && ! bitmap_bit_p (&split_origin_bitmap, sregno)
+   && ! bitmap_bit_p (&split_origin_bitmap, dregno)
&& ! side_effects_p (set)
/* Don't coalesces bound pseudos.  Bound pseudos has own
   rules for finding live ranges.  It is hard to maintain
@@ -245,6 +258,7 @@ lra_coalesce (void)

lra_reg_info[dregno].live_ranges))
  sorted_moves[mv_num++] = insn;
 }
+  bitmap_clear (&removed_pseudos_bitmap);
   qsort (sorted_moves, mv_num, sizeof (rtx), move_freq_compare_func);
   /* Coalesced copies, most frequently executed first.  */
   bitmap_initialize (&coalesced_pseudos_bitmap, ®_obstack);


Re: [Patch Darwin] fix missing __USER_LABEL_PREFIX__ on extended identifiers.

2012-02-15 Thread Iain Sandoe


On 15 Feb 2012, at 17:16, Mike Stump wrote:


On Feb 15, 2012, at 2:21 AM, Iain Sandoe wrote:
I noticed when working on GAS for darwin that we fail to prepend  
the user label prefix for extended identifiers.


Does this match the native compiler on the platform?  This is abi  
changing, and we can't do it, unless it mismatches the native  
compiler?



extended identifiers are not recognized by the system gcc-4.0

for gcc-4.2.1:

$ echo " int \u00c0; " | gcc-4.2 -std=c99 -fextended-identifiers -x c  
- -S -o t.s

$ cat t.s
.section __TEXT,__text,regular,pure_instructions
.section  
__TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32

.machine ppc7400
.comm "_À",4,2
.subsections_via_symbols

---^ .. this is what prompted me to make the fix.

So, this just brings us into line with the current system compiler.

AFAICT: clang does not yet support them.

As for whether it's useful/compatible with earlier tool-chains -  
apparently usable for Darwin 9 [there can't be any instances in system  
components there, since the system compiler is 4.0].


so - apply or not?
Iain


[v3] Disable gthreads on Solaris 8/9 (PR libstdc++/52189)

2012-02-15 Thread Rainer Orth
As discussed the improved/relaxed test for gthreads support breaks
symbol versioning on Solaris 8 and 9.  The best solution seems to
disable it by default on those targets, allowing users to reenable it if
they don't care about compatibility.

The following patch does just that, disabling only if symbol versioning
is active, and warning if users choose to enable it nonetheless.

I had to move the GLIBCXX_CHECK_GTHREADS down in configure.ac, adding a
dependency in acinclude.m4 didnd't suffice.

Bootstrapped without regressions on {sparc-sun,i386-pc}-solaris2.{8, 9,
10, 11} and x86_64-unknown-linux-gnu, verifying that there's no change
on Linux/x86_64 and the gthr-related symbols are gone on Solaris 8 and 9
only.

Ok for mainline?

Btw., the ChangeLog lies at one point: I didn't include the
configure.html update since I lack the required tools.  I'd appreciate
it if some of the libstdc++ maintainers could handle this for me after
checking.

Thanks.
Rainer


2012-02-12  Rainer Orth  

PR libstdc++/52189
* acinclude.m4 (GLIBCXX_CHECK_GTHREADS): Handle --enable-gthreads.
Disable on Solaris 8/9 with symbol versioning.
* configure.ac (GLIBCXX_CHECK_GTHREADS): Move after
GLIBCXX_ENABLE_SYMVERS.
* configure: Regenerate.
* doc/xml/manual/configure.xml (--enable-gthreads): Explain.
* doc/html/manual/configure.html: Regenerate.

# HG changeset patch
# Parent c03709f1705410424658e4ee6f0f714ab4bbf69a
Disable gthreads on Solaris 8/9 (PR libstdc++/52189)

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -3325,7 +3325,13 @@ dnl Check if gthread implementation defi
 dnl required by the c++0x thread library.  Conforming gthread
 dnl implementations can define __GTHREADS_CXX0X to enable use with c++0x.
 dnl
+dnl GLIBCXX_ENABLE_SYMVERS must be done before this.
+dnl
 AC_DEFUN([GLIBCXX_CHECK_GTHREADS], [
+  GLIBCXX_ENABLE(gthreads,auto,,[enable gthreads support])
+
+  if test x$enable_gthreads = xauto || test x$enable_gthreads = xyes; then
+
   AC_LANG_SAVE
   AC_LANG_CPLUSPLUS
 
@@ -3364,7 +3370,28 @@ AC_DEFUN([GLIBCXX_CHECK_GTHREADS], [
   #ifndef __GTHREADS_CXX0X
   #error
   #endif
-], [ac_has_gthreads=yes], [ac_has_gthreads=no])
+], [case $target_os in
+	  # gthreads support breaks symbol versioning on Solaris 8/9 (PR
+	  # libstdc++/52189).
+  solaris2.[[89]]*)
+	if test x$enable_symvers = xno; then
+	  ac_has_gthreads=yes
+	elif test x$enable_gthreads = xyes; then
+	  AC_MSG_WARN([You have requested gthreads support, but])
+	  AC_MSG_WARN([this breaks symbol versioning.])
+	  ac_has_gthreads=yes
+	else
+	  ac_has_gthreads=no
+	fi
+	;;
+	  *)
+	ac_has_gthreads=yes
+	;;
+esac],
+   [ac_has_gthreads=no])
+  else
+ac_has_gthreads=no
+  fi
 
   AC_MSG_RESULT([$ac_has_gthreads])
 
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -164,9 +164,6 @@ GLIBCXX_CHECK_GETTIMEOFDAY
 # NB: The default is [no], because otherwise it requires linking.
 GLIBCXX_ENABLE_LIBSTDCXX_TIME([no])
 
-# For gthread support
-GLIBCXX_CHECK_GTHREADS
-
 AC_LC_MESSAGES
 
 # For hardware_concurrency
@@ -335,6 +332,9 @@ GLIBCXX_CONDITIONAL(GLIBCXX_LDBL_COMPAT,
 # This depends on GLIBCXX_ENABLE_SYMVERS and GLIBCXX_IS_NATIVE.
 GLIBCXX_CONFIGURE_TESTSUITE
 
+# For gthread support.  Depends on GLIBCXX_ENABLE_SYMVERS.
+GLIBCXX_CHECK_GTHREADS
+
 # Define documentation rules conditionally.
 
 # See if makeinfo has been installed and is modern enough
diff --git a/libstdc++-v3/doc/xml/manual/configure.xml b/libstdc++-v3/doc/xml/manual/configure.xml
--- a/libstdc++-v3/doc/xml/manual/configure.xml
+++ b/libstdc++-v3/doc/xml/manual/configure.xml
@@ -161,6 +161,13 @@
  
  
 
+ --enable-gthreads
+ Enable gthreads support.  If not explicitly specified, the
+	configure process enables it if possible.  It defaults to 'off' on
+	Solaris 8 and 9, where it would break symbol versioning.   This
+	option can change the library ABI.
+ 
+ 
 
  --enable-libstdcxx-time
  This is an abbreviated form of


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


Re: [PATCH?, 4.7 regression] Crash in ira-costs.c with -fschedule-insns -fsched-pressure -fdump-rtl-sched1

2012-02-15 Thread Vladimir Makarov

On 02/14/2012 12:00 PM, Ulrich Weigand wrote:

Hello,

compiling anything, even just an empty function, with
   -fschedule-insns -fsched-pressure -fdump-rtl-sched1
causes the compiler to crash:

Program received signal SIGSEGV, Segmentation fault.
0x0840d9e0 in REG_N_REFS (regno=58) at ../../gcc-head/gcc/regs.h:75
75return regstat_n_sets_and_refs[regno].refs;
(gdb) bt
#0  0x0840d9e0 in REG_N_REFS (regno=58) at ../../gcc-head/gcc/regs.h:75
#1  0x08411120 in print_pseudo_costs (f=0x8e3fad0) at 
../../gcc-head/gcc/ira-costs.c:1433
#2  0x08412046 in find_costs_and_classes (dump_file=0x8e3fad0) at 
../../gcc-head/gcc/ira-costs.c:1806
#3  0x084129f2 in ira_set_pseudo_classes (dump_file=0x8e3fad0) at 
../../gcc-head/gcc/ira-costs.c:2067
#4  0x089a9f08 in sched_init () at ../../gcc-head/gcc/haifa-sched.c:4838

This is because sched_init calls ira_set_pseudo_classes without having
called regstat_init_n_sets_and_refs first, but the latter is a prerequisite
for using REG_N_REFS.  All other callers of ira_set_pseudo_classes seem to
initialize the regstat array first.

This is fixed by the following patch.  However, I'm not quite sure if this is
the best way to fix the problem, given that the REG_N_REFS use occurs only for
debug output purposes -- should we actually do the work to compute the regstat
array just for that, or can print_pseudo_costs be changed instead?


Sorry, Ulrich.  I am afraid that you missed my message about solving 
this PR two week ago.


http://gcc.gnu.org/ml/gcc-patches/2012-02/msg00101.html


ChangeLog:

* haifa-sched.c (sched_init): Call regstat_init_n_sets_and_refs and
regstat_free_n_sets_and_refs before/after ira_set_pseudo_classes call.


=== modified file 'gcc/haifa-sched.c'
--- gcc/haifa-sched.c   2012-02-11 01:34:30 +
+++ gcc/haifa-sched.c   2012-02-14 16:41:47 +
@@ -6281,7 +6281,9 @@
  {
int i, max_regno = max_reg_num ();

+  regstat_init_n_sets_and_refs ();
ira_set_pseudo_classes (sched_verbose ? sched_dump : NULL);
+  regstat_free_n_sets_and_refs ();
sched_regno_pressure_class
= (enum reg_class *) xmalloc (max_regno * sizeof (enum reg_class));
for (i = 0; i<  max_regno; i++)






Re: [PATCH?, 4.7 regression] Crash in ira-costs.c with -fschedule-insns -fsched-pressure -fdump-rtl-sched1

2012-02-15 Thread Ulrich Weigand
Vladimir Makarov wrote:
> On 02/14/2012 12:00 PM, Ulrich Weigand wrote:
> > This is fixed by the following patch.  However, I'm not quite sure if this 
> > is
> > the best way to fix the problem, given that the REG_N_REFS use occurs only 
> > for
> > debug output purposes -- should we actually do the work to compute the 
> > regstat
> > array just for that, or can print_pseudo_costs be changed instead?
> >
> >
> Sorry, Ulrich.  I am afraid that you missed my message about solving 
> this PR two week ago.
> 
> http://gcc.gnu.org/ml/gcc-patches/2012-02/msg00101.html

Ah, indeed!  That does fix the problem, thanks!

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  ulrich.weig...@de.ibm.com



[testsuite] Directly declare sqrtf in gcc.dg/pr51867.c

2012-02-15 Thread Rainer Orth
gcc.dg/pr51867.c currently FAILs on Solaris 8 and 9:

FAIL: gcc.dg/pr51867.c (test for excess errors)
Excess errors:
/vol/gcc/src/hg/trunk/local/gcc/testsuite/gcc.dg/pr51867.c:7:12: warning: incomp
atible implicit declaration of built-in function 'sqrtf' [enabled by default]
/vol/gcc/src/hg/trunk/local/gcc/testsuite/gcc.dg/pr51867.c:11:12: warning: incom
patible implicit declaration of built-in function 'sqrtf' [enabled by default]

which is no wonder since those targets lack a C99 libm.  This can easily
be avoided by simply declaring sqrtf directly, which the following patch
does.

Tested with the appropriate runtest invocations on i386-pc-solaris2.8,
i386-pc-solaris2.11, and x86_64-unknown-linux-gnu, installed on
mainline.

Rainer


2012-02-11  Rainer Orth  

* gcc.dg/pr51867.c: Don't include .
(sqrtf): Declare.

# HG changeset patch
# Parent f4216d8e89ea5facd439f8fc1d0ff36670667b36
Directly declare sqrtf in gcc.dg/pr51867.c

diff --git a/gcc/testsuite/gcc.dg/pr51867.c b/gcc/testsuite/gcc.dg/pr51867.c
--- a/gcc/testsuite/gcc.dg/pr51867.c
+++ b/gcc/testsuite/gcc.dg/pr51867.c
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
 /* { dg-options "-O0 -fno-math-errno -fdump-rtl-expand" } */
-#include 
+
+extern float sqrtf(float);
 
 float a(float x)
 {

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


Re: PR middle-end/52141: ICE due to asm statement

2012-02-15 Thread Aldy Hernandez

On 02/15/12 11:32, Jakub Jelinek wrote:

On Wed, Feb 15, 2012 at 09:29:18AM -0800, Richard Henderson wrote:

On 02/15/2012 01:48 AM, Richard Guenther wrote:

Hmm.  I think you rather want to teach local_pure_const about TM
properties you want to know and have them propagated properly
(of course unless pure/const which is about optimization and has an
easy fallback default yours wouldn't have that - you'd have to assume
the callee contains an invalid asm ...)


That's more or less what we do ourselves during the tm ipa pass.

The trouble we have here is merely one of diagnostics.  The user
has written "transaction safe" and it's now our job to tell him
when he's done something that's not transaction safe.

The unfortunate thing of diagnostics is you'd like to be able to
tell the user what they did wrong at the source level, not after
10 levels of inlining.

And given that pass_local_pure_const still runs after pass_early_inline,
doing anything in there doesn't really help the problem at all.


Use %K in error/warning fmt string, then the diagnostic will include the
full virtual backtrace.

Jakub


Hmmm, isn't %K for trees?  We're talking gimple, and FUNCTION_DECLs, 
which don't have a TREE_BLOCK, here.


[testsuite] XFAIL objc.dg/stabs-1.m on IRIX (PR target/52152)

2012-02-15 Thread Rainer Orth
Like other MIPS ELF targets, the mips-sgi-irix6.5 configuration doesn't
include dbxelf.h, causing objc.dg/stabs-1.m to FAIL.  Same cure as in
Richard's patch.

Tested with the appropriate runtest invocations, installed on mainline.

Rainer


2012-02-11  Rainer Orth  

PR target/52152
* objc.dg/stabs-1.m: xfail on mips-sgi-irix6.5.

# HG changeset patch
# Parent 70ca6a7604410806387831ef3d83da7de7961a67
XFAIL objc.dg/stabs-1.m on IRIX (PR target/52152)

diff --git a/gcc/testsuite/objc.dg/stabs-1.m b/gcc/testsuite/objc.dg/stabs-1.m
--- a/gcc/testsuite/objc.dg/stabs-1.m
+++ b/gcc/testsuite/objc.dg/stabs-1.m
@@ -15,5 +15,5 @@
 }
 @end
 
-/* See PR 52152 for the xfail.  */
-/* { dg-final { scan-assembler "(.SUBSPA.*\[\$\]CODE\[\$\]|.text\"?)\n\t.stabs.*100,0,0,(\[\.\$\])?L?L\[\$\]?etext\[0-9\]*\n(\[\.\$\])?L?L\[\$\]?etext" { xfail mips*-*-elf* } } } */
+/* See PR target/52152 for the xfail.  */
+/* { dg-final { scan-assembler "(.SUBSPA.*\[\$\]CODE\[\$\]|.text\"?)\n\t.stabs.*100,0,0,(\[\.\$\])?L?L\[\$\]?etext\[0-9\]*\n(\[\.\$\])?L?L\[\$\]?etext" { xfail mips*-*-elf* mips-sgi-irix6.5 } } } */

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


[libgo] Detect Solaris 8/9 SPARC makecontext

2012-02-15 Thread Rainer Orth
The libgo setcontext TLS configure test was failing on Solaris 8 and
9/SPARC, breaking bootstrap due to the unhandled case in
runtime/proc.c.  This turned out to be a known issue, documented in the
makecontext(3C) manpage:

NOTES
 The semantics of  the  uc_stack  member  of  the  ucontext_t
 structure  have  changed as they apply to inputs to makecon-
 text(). Prior  to  Solaris  10,  the  ss_sp  member  of  the
 uc_stack  structure  represented  the high memory address of
 the area reserved  for  the  stack.  The  ss_sp  member  now
 represents  the  base  (low memory address), in keeping with
 other uses of ss_sp.

 This change in the meaning  of  ss_sp  is  now  the  default
 behavior.  The  -D__MAKECONTEXT_V2_SOURCE  compilation  flag
 used in Solaris 9 update releases to access this behavior is
 obsolete.

Since it didn't seem easy to autodetect the condition, and
__MAKECONTEXT_V2_SOURCE was only introduced in a Solaris 9 update
(4/03), I've chosed to just hardcode the fact that Solaris 8 and 9
differ on SPARC.

The patch allowed the bootstrap to complete successfully, but since
libgo.so now has undefined references to log2 and trunc, all Go
execution still fail.

Rainer


2012-02-13  Rainer Orth  

* configure.ac (libgo_cv_lib_makecontext_stack_top): Set on
sparc*-*-solaris2.[89]*.
(MAKECONTEXT_STACK_TOP): Define if appropriate.
(libgo_cv_lib_setcontext_clobbers_tls): Use it.
* configure: Regenerate.
* config.h.in: Regenerate.
* runtime/proc.c (__go_go) [MAKECONTEXT_STACK_TOP]: Add stack size
to ss_sp.

# HG changeset patch
# Parent bdc02d4914d89c66f92b2c0bd67547817cdfc646
Detect Solaris 8/9 SPARC makecontext

diff --git a/libgo/config.h.in b/libgo/config.h.in
--- a/libgo/config.h.in
+++ b/libgo/config.h.in
@@ -182,6 +182,9 @@
*/
 #undef LT_OBJDIR
 
+/* Define if makecontext expects top of stack in uc_stack. */
+#undef MAKECONTEXT_STACK_TOP
+
 /* Name of package */
 #undef PACKAGE
 
diff --git a/libgo/configure b/libgo/configure
--- a/libgo/configure
+++ b/libgo/configure
@@ -14871,6 +14871,20 @@ if test "$libgo_has_struct_exception" = 
 
 fi
 
+case "$target" in
+  sparc*-*-solaris2.[89]*)
+libgo_cv_lib_makecontext_stack_top=yes
+;;
+  *)
+libgo_cv_lib_makecontext_stack_top=no
+;;
+esac
+if test "$libgo_cv_lib_makecontext_stack_top" = "yes"; then
+
+$as_echo "#define MAKECONTEXT_STACK_TOP 1" >>confdefs.h
+
+fi
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether setcontext clobbers TLS variables" >&5
 $as_echo_n "checking whether setcontext clobbers TLS variables... " >&6; }
 if test "${libgo_cv_lib_setcontext_clobbers_tls+set}" = set; then :
@@ -14972,6 +14986,9 @@ main ()
 abort ();
 
   c.uc_stack.ss_sp = stack;
+#ifdef MAKECONTEXT_STACK_TOP
+  c.uc_stack.ss_sp += sizeof stack;
+#endif
   c.uc_stack.ss_flags = 0;
   c.uc_stack.ss_size = sizeof stack;
   c.uc_link = NULL;
diff --git a/libgo/configure.ac b/libgo/configure.ac
--- a/libgo/configure.ac
+++ b/libgo/configure.ac
@@ -609,6 +609,21 @@ if test "$libgo_has_struct_exception" = 
 [Define to 1 if  defines struct exception])
 fi
 
+dnl Check if makecontext expects the uc_stack member of ucontext to point
+dnl to the top of the stack.
+case "$target" in
+  sparc*-*-solaris2.[[89]]*)
+libgo_cv_lib_makecontext_stack_top=yes
+;;
+  *)
+libgo_cv_lib_makecontext_stack_top=no
+;;
+esac
+if test "$libgo_cv_lib_makecontext_stack_top" = "yes"; then
+  AC_DEFINE(MAKECONTEXT_STACK_TOP, 1,
+	[Define if makecontext expects top of stack in uc_stack.])
+fi
+
 dnl See whether setcontext changes the value of TLS variables.
 AC_CACHE_CHECK([whether setcontext clobbers TLS variables],
 [libgo_cv_lib_setcontext_clobbers_tls],
@@ -665,6 +680,9 @@ main ()
 abort ();
 
   c.uc_stack.ss_sp = stack;
+#ifdef MAKECONTEXT_STACK_TOP
+  c.uc_stack.ss_sp += sizeof stack;
+#endif
   c.uc_stack.ss_flags = 0;
   c.uc_stack.ss_size = sizeof stack;
   c.uc_link = NULL;
diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c
--- a/libgo/runtime/proc.c
+++ b/libgo/runtime/proc.c
@@ -1297,6 +1297,9 @@ __go_go(void (*fn)(void*), void* arg)
 
 	getcontext(&newg->context);
 	newg->context.uc_stack.ss_sp = sp;
+#ifdef MAKECONTEXT_STACK_TOP
+	newg->context.uc_stack.ss_sp += spsize;
+#endif
 	newg->context.uc_stack.ss_size = spsize;
 	makecontext(&newg->context, kickoff, 0);
 


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


Re: PR middle-end/52141: ICE due to asm statement

2012-02-15 Thread Jakub Jelinek
On Wed, Feb 15, 2012 at 11:59:15AM -0600, Aldy Hernandez wrote:
> Hmmm, isn't %K for trees?  We're talking gimple, and FUNCTION_DECLs,
> which don't have a TREE_BLOCK, here.

Gimple stmts have gimple_block, I guess you'd need to create some tree
and set its TREE_BLOCK and EXPR_LOCATION from gimple_block/gimple_location.
Or add something similar to %K that would take the same info from gimple
stmt and pass a stmt instead of a tree.

Jakub


Re: [PATCH] [RFC, GCC 4.8] Optimize conditional moves from adjacent memory locations

2012-02-15 Thread William J. Schmidt
On Fri, 2012-02-10 at 13:02 -0800, Andrew Pinski wrote:
> On Fri, Feb 10, 2012 at 12:46 PM, Michael Meissner
>  wrote:
> > I was looking at the routelookup EEMBC benchmark and it has code of the 
> > form:
> >
> >   while ( this_node->cmpbit > next_node->cmpbit )
> >{
> >  this_node = next_node;
> >
> >  if ( proute->dst_addr & (0x1 << this_node->cmpbit) )
> > next_node = this_node->rlink;
> >  else
> > next_node = this_node->llink;
> >}
> 
> Hmm, this looks like we could do this on the tree level better as we
> have more information about this_node there.  Like we know that we
> load from this_node->cmpbit before we do either of the branches.  So
> can move both of those loads before the branch and then we get the
> ifcvt for free.
> 
> Thanks,
> Andrew Pinski
> 

I agree that there is more information for doing the transformation at
the tree level, but I'm concerned that RTL optimization would undo the
transformation prior to RTL if-conversion.  Wouldn't fwprop just combine
the loads (rtmp, ltmp below) into their uses, re-creating the original
code?  It seems like you'd have to find a way to defeat that somehow.

Thanks,
Bill

> 
> 
> >
> > This is where you have a binary tree/trie and you are iterating going down
> > either the right link or left link until you find a stopping condition.  The
> > code in ifcvt.c does not handle optimizing these cases for conditional move
> > since the load might trap, and generates code that does if-then-else with 
> > loads
> > and jumps.
> >
> > However, since the two elements are next to each other in memory, they are
> > likely in the same cache line, particularly with aligned stacks and malloc
> > returning aligned pointers.  Except in unusual circumstances where the 
> > pointer
> > is not aligned, this means it is much faster to optimize it as:
> >
> >   while ( this_node->cmpbit > next_node->cmpbit )
> >{
> >  this_node = next_node;
> >
> >  rtmp = this_node->rlink;
> >  ltmp = this_node->llink;
> >  if ( proute->dst_addr & (0x1 << this_node->cmpbit) )
> > next_node = rtmp;
> >  else
> > next_node = ltmp;
> >}
> >
> > So I wrote some patches to do this optimization.  In ifcvt.c I added a new 
> > hook
> > that allows the backend to try and do conditional moves if the machine
> > independent code doesn't handle the special cases that the machine might 
> > have.
> >
> > Then in rs6000.c I used that hook to see if the conditional moves are 
> > adjacent,
> > and do the optimization.
> >
> > I will note that this type of code comes up quite frequently since binary 
> > trees
> > and tries are common data structure.  The file splay-tree.c in libiberty is 
> > one
> > place in the compiler tree that has conditional adjacent memory moves.
> >
> > So I would like comments on the patch before the 4.8 tree opens up.  I feel
> > even if we decide not to add the adjacent memory move patch, the hook is
> > useful, and I have some other ideas for using it for the powerpc.
> >
> > I was thinking about rewriting the rs6000 dependent parts to make it a 
> > normal
> > optimization available to all ports.  Is this something we want as a normal
> > option?  At the moment, I'm not sure it should be part of -O3 because it is
> > possible for a trap to occur if the pointer straddles a page boundary and 
> > the
> > test condition would guard against loading up the second value.  However,
> > -Ofast might be an appropriate place to do this optimization.
> >
> > At this time I don't have test cases, but I would add them for the real
> > submission.  I have bootstraped the compiler on powerpc with this option
> > enabled and it passed the bootstrap and had no regressions in make check.  I
> > will do a spec run over the weekend as well.
> >
> > In addition to libibery/splay-tree.c the following files in gcc have 
> > adjacent
> > conditional moves that this code would optimize:
> >
> >cfg.c
> >c-typeck.c
> >df-scan.c
> >fold-const.c
> >graphds.c
> >ira-emit.c
> >omp-low.c
> >rs6000.c
> >tree-cfg.c
> >tree-ssa-dom.c
> >tree-ssa-loop-ivops.c
> >tree-ssa-phiopt.c
> >tree-ssa-uncprop.c
> >
> > 2012-02-10  Michael Meissner  
> >
> >* target.def (cmove_md_extra): New hook that is called from
> >ifcvt.c to allow the backend to generate additional conditional
> >moves that aren't handled by the machine independent code.  Add
> >support to call the hook at the appropriate places.
> >* targhooks.h (default_cmove_md_extra): Likewise.
> >* targhooks.c (default_cmove_md_extra): Likewise.
> >* target.h (enum ifcvt_pass): Likewise.
> >* ifcvt.c (find_if_header): Likewise.
> >(noce_find_if_block): Likewise.
> >(struct noce_if_info): Likewise.
> >(noce_process_if_block): Likewise.
> >

[PATCH] Fix PR 52199 on power7 (VEC_DUPLICATE)

2012-02-15 Thread Michael Meissner
This patch fixes PR 52199, which shows up on power7 systems when the compiler
is vectorizing DImode operations, and the vector duplicate code was not
prepared to accept CONST and SYMBOL_REF's.

I have done a bootstrap and make compare, and there were no regressions.  Is
this ok to install?  I will also back port the change to 4.6, since the exact
same code is in that revision as well.

-- 
Michael Meissner, IBM
5 Technology Place Drive, M/S 2757, Westford, MA 01886-3141, USA
meiss...@linux.vnet.ibm.com fax +1 (978) 399-6899
Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 184276)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -4701,28 +4701,25 @@ rs6000_expand_vector_init (rtx target, r
   /* Double word values on VSX can use xxpermdi or lxvdsx.  */
   if (VECTOR_MEM_VSX_P (mode) && (mode == V2DFmode || mode == V2DImode))
 {
+  rtx op0 = XVECEXP (vals, 0, 0);
+  rtx op1 = XVECEXP (vals, 0, 1);
   if (all_same)
{
- rtx element = XVECEXP (vals, 0, 0);
+ if (!MEM_P (op0) && !REG_P (op0))
+   op0 = force_reg (inner_mode, op0);
  if (mode == V2DFmode)
-   emit_insn (gen_vsx_splat_v2df (target, element));
+   emit_insn (gen_vsx_splat_v2df (target, op0));
  else
-   emit_insn (gen_vsx_splat_v2di (target, element));
+   emit_insn (gen_vsx_splat_v2di (target, op0));
}
   else
{
+ op0 = force_reg (inner_mode, op0);
+ op1 = force_reg (inner_mode, op1);
  if (mode == V2DFmode)
-   {
- rtx op0 = copy_to_mode_reg (DFmode, XVECEXP (vals, 0, 0));
- rtx op1 = copy_to_mode_reg (DFmode, XVECEXP (vals, 0, 1));
- emit_insn (gen_vsx_concat_v2df (target, op0, op1));
-   }
+   emit_insn (gen_vsx_concat_v2df (target, op0, op1));
  else
-   {
- rtx op0 = copy_to_mode_reg (DImode, XVECEXP (vals, 0, 0));
- rtx op1 = copy_to_mode_reg (DImode, XVECEXP (vals, 0, 1));
- emit_insn (gen_vsx_concat_v2di (target, op0, op1));
-   }
+   emit_insn (gen_vsx_concat_v2di (target, op0, op1));
}
   return;
 }
@@ -4736,7 +4733,7 @@ rs6000_expand_vector_init (rtx target, r
   if (all_same)
{
  rtx freg = gen_reg_rtx (V4SFmode);
- rtx sreg = copy_to_reg (XVECEXP (vals, 0, 0));
+ rtx sreg = force_reg (SFmode, XVECEXP (vals, 0, 0));
 
  emit_insn (gen_vsx_xscvdpsp_scalar (freg, sreg));
  emit_insn (gen_vsx_xxspltw_v4sf (target, freg, const0_rtx));
@@ -4747,13 +4744,13 @@ rs6000_expand_vector_init (rtx target, r
  rtx dbl_odd  = gen_reg_rtx (V2DFmode);
  rtx flt_even = gen_reg_rtx (V4SFmode);
  rtx flt_odd  = gen_reg_rtx (V4SFmode);
+ rtx op0 = force_reg (SFmode, XVECEXP (vals, 0, 0));
+ rtx op1 = force_reg (SFmode, XVECEXP (vals, 0, 1));
+ rtx op2 = force_reg (SFmode, XVECEXP (vals, 0, 2));
+ rtx op3 = force_reg (SFmode, XVECEXP (vals, 0, 3));
 
- emit_insn (gen_vsx_concat_v2sf (dbl_even,
- copy_to_reg (XVECEXP (vals, 0, 0)),
- copy_to_reg (XVECEXP (vals, 0, 1;
- emit_insn (gen_vsx_concat_v2sf (dbl_odd,
- copy_to_reg (XVECEXP (vals, 0, 2)),
- copy_to_reg (XVECEXP (vals, 0, 3;
+ emit_insn (gen_vsx_concat_v2sf (dbl_even, op0, op1));
+ emit_insn (gen_vsx_concat_v2sf (dbl_odd, op2, op3));
  emit_insn (gen_vsx_xvcvdpsp (flt_even, dbl_even));
  emit_insn (gen_vsx_xvcvdpsp (flt_odd, dbl_odd));
  rs6000_expand_extract_even (target, flt_even, flt_odd);
Index: gcc/testsuite/gcc.target/powerpc/pr52199.c
===
--- gcc/testsuite/gcc.target/powerpc/pr52199.c  (revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr52199.c  (revision 0)
@@ -0,0 +1,24 @@
+/* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
+/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-options "-O3 -mcpu=power7 -fmerge-all-constants" } */
+
+struct locale_time_t
+{
+  const char *abday[7];
+  const unsigned int *wabday[7];
+};
+
+static const unsigned int empty_wstr[1] = { 0 };
+
+void
+time_read (struct locale_time_t *time)
+{
+  int cnt;
+
+  for (cnt=0; cnt < 7; cnt++)
+{
+  time->abday[cnt] = "";
+  time->wabday[cnt] = empty_wstr;
+}
+}


[patch] Poison SMALL_REGISTER_CLASSES

2012-02-15 Thread Steven Bosscher
Hello,

While going through some old patches of mine, I noticed this:

config/rl78/rl78.h:#define SMALL_REGISTER_CLASSES   1
config/rx/rx.h:#define SMALL_REGISTER_CLASSES   0

Can't possibly work, that target macro was replaced with a hook.

Attached patch OK for trunk?

Ciao!
Steven


* system.h: Poison SMALL_REGISTER_CLASSES

Index: system.h
===
--- system.h(revision 184217)
+++ system.h(working copy)
@@ -807,7 +807,7 @@ extern void fancy_abort (const char *, i
LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP JUMP_ALIGN_MAX_SKIP  \
CAN_DEBUG_WITHOUT_FP UNLIKELY_EXECUTED_TEXT_SECTION_NAME\
HOT_TEXT_SECTION_NAME LEGITIMATE_CONSTANT_P ALWAYS_STRIP_DOTDOT \
-   OUTPUT_ADDR_CONST_EXTRA
+   OUTPUT_ADDR_CONST_EXTRA SMALL_REGISTER_CLASSES

 /* Target macros only used for code built for the target, that have
moved to libgcc-tm.h or have never been present elsewhere.  */


Re: [patch] Poison SMALL_REGISTER_CLASSES

2012-02-15 Thread Steven Bosscher
On Wed, Feb 15, 2012 at 7:36 PM, Steven Bosscher  wrote:
> Hello,
>
> While going through some old patches of mine, I noticed this:
>
> config/rl78/rl78.h:#define SMALL_REGISTER_CLASSES               1
> config/rx/rx.h:#define SMALL_REGISTER_CLASSES           0
>
> Can't possibly work, that target macro was replaced with a hook.
>
> Attached patch OK for trunk?

And this will be needed to make those ports do what was intended:

* config/rl78/rl78.h: Replace SMALL_REGISTER_CLASSES with hook.
* config/rx/rx.h: Remove SMALL_REGISTER_CLASSES.

Index: config/rl78/rl78.h
===
--- config/rl78/rl78.h  (revision 184217)
+++ config/rl78/rl78.h  (working copy)
@@ -258,7 +258,7 @@ enum reg_class
   { 0xff7f, 0x001f }   /* All registers.  */   \
 }

-#define SMALL_REGISTER_CLASSES 1
+#define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P hook_bool_mode_true
 #define N_REG_CLASSES  (int) LIM_REG_CLASSES
 #define CLASS_MAX_NREGS(CLASS, MODE)((GET_MODE_SIZE (MODE) \
  + UNITS_PER_WORD - 1) \
Index: config/rx/rx.h
===
--- config/rx/rx.h  (revision 184217)
+++ config/rx/rx.h  (working copy)
@@ -185,7 +185,6 @@ enum reg_class
   { 0x }   /* All registers.  */   \
 }

-#define SMALL_REGISTER_CLASSES 0
 #define N_REG_CLASSES  (int) LIM_REG_CLASSES
 #define CLASS_MAX_NREGS(CLASS, MODE)((GET_MODE_SIZE (MODE) \
  + UNITS_PER_WORD - 1) \


Re: [patch] Poison SMALL_REGISTER_CLASSES

2012-02-15 Thread DJ Delorie

I would classify these as "obvious" but please make sure they go in
before the poison patch ;-)

> And this will be needed to make those ports do what was intended:
> 
>   * config/rl78/rl78.h: Replace SMALL_REGISTER_CLASSES with hook.
>   * config/rx/rx.h: Remove SMALL_REGISTER_CLASSES.
> 
> Index: config/rl78/rl78.h
> ===
> --- config/rl78/rl78.h(revision 184217)
> +++ config/rl78/rl78.h(working copy)
> @@ -258,7 +258,7 @@ enum reg_class
>{ 0xff7f, 0x001f } /* All registers.  */   \
>  }
> 
> -#define SMALL_REGISTER_CLASSES   1
> +#define TARGET_SMALL_REGISTER_CLASSES_FOR_MODE_P hook_bool_mode_true
>  #define N_REG_CLASSES(int) LIM_REG_CLASSES
>  #define CLASS_MAX_NREGS(CLASS, MODE)((GET_MODE_SIZE (MODE) \
> + UNITS_PER_WORD - 1) \


Re: [PR52001] too many cse reverse equiv exprs (take2)

2012-02-15 Thread Richard Sandiford
Alexandre Oliva  writes:
> On Feb 13, 2012, Richard Sandiford  wrote:
>> does this avoid the kind of memrefs_conflict_p cycle I was seeing in:
>
> I don't know that it does, I'd missed that bit.
>
> If you still have a preprocessed testcase, I'd be glad to give it a
> quick try.  Failing that, I can try a build on my yeeloong, but... that
> takes forever minus a few days ;-)

Unfortunately, I've not kept the preprocessed source, and I'd need to
wind back to an old compiler to get it.  If it's "in practice" rather
than "in theory" that we're talking about, then I'm fine with putting
it in and seeing what breaks.  But I'd really prefer if we knew in
theory. :-)  Like I say, my understanding before this patch series went
in was that cselib values weren't supposed to be cyclic.  Now that they are,
what should consumers like memrefs_conflict_p do to avoid getting stuck?

Thanks,
Richard


Re: [patch] Poison SMALL_REGISTER_CLASSES

2012-02-15 Thread Steven Bosscher
On Wed, Feb 15, 2012 at 7:59 PM, DJ Delorie  wrote:
>
> I would classify these as "obvious" but please make sure they go in
> before the poison patch ;-)
>
>> And this will be needed to make those ports do what was intended:
>>
>>       * config/rl78/rl78.h: Replace SMALL_REGISTER_CLASSES with hook.
>>       * config/rx/rx.h: Remove SMALL_REGISTER_CLASSES.

I wasn't sure if these are obvious, because I already removed the
definition from rx.h before, see ChangeLog-2010. Maybe someone put it
back intentionally.

Ciao!
Steven


Re: [Patch Darwin] fix missing __USER_LABEL_PREFIX__ on extended identifiers.

2012-02-15 Thread Mike Stump
On Feb 15, 2012, at 9:38 AM, Iain Sandoe wrote:
> So, this just brings us into line with the current system compiler.

Ah, the patch is ok.  Perfect, thanks.


Re: [trans-mem,darwin] PR/52042 find tm_clone_table with PIE

2012-02-15 Thread Patrick Marlier
Here the committed patch approved off-list by Mike Stump which fixed 
PR/52042.

Tested on darwin10/11 with x86_64.

PS: this is my first commit so I hope I get it right. Otherwise do not 
hesitate to yell at me.


Thanks.
--
Patrick.

2012-02-15  Iain Sandoe  
Patrick Marlier  

PR libitm/52042
* config/darwin-crt-tm.c (getTMCloneTable): New function.
(__doTMRegistrations): Call it.
(__doTMdeRegistrations): Likewise.



On 02/07/2012 10:36 PM, Patrick Marlier wrote:

Hi,

The problem in this PR is that with PIE, getsectdata does not return the
position of tm_clone_table after the relocation.
While _dyld_get_image_vmaddr_slide(0) is enough for PIE, this is not
enough for dylib.
I did not find an easy API function to get position of the
tm_clone_table for a shared library (dylib). So the only way I found is
to get the mach_header address of the current dylib (via
_dyld_get_image_header_containing_address), iterate over loaded binaries
to find the current shared library and use _dyld_get_image_vmaddr_slide
to find the position.
Any other proposal (my knowledge of darwin is really limited)?

Can someone do a bootstrap and test libitm on darwin (I have a limited
access to a darwin machine, at least libitm tests pass)? Thanks!

If tests passed, ok for 4.7?
--
Patrick Marlier.
libgcc:

PR libitm/52042
* config/darwin-crt-tm.c: Changes for PIE and shared library.



Index: config/darwin-crt-tm.c
===
--- config/darwin-crt-tm.c	(revision 184280)
+++ config/darwin-crt-tm.c	(working copy)
@@ -23,33 +23,67 @@ a copy of the GCC Runtime Library Exception along
 see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 .  */
 
+#include "tsystem.h"
+#include 
+#include 
 #include 
+#include 
 
-/* not listed in mach-o/dyld.h for some reason.  */
-extern char * getsectdata (const char*,const char*,unsigned long*); 
+#ifdef __LP64__
+#define GET_DATA_TMCT(mh,size) \
+  getsectdatafromheader_64 ((struct mach_header_64*) mh, \
+			"__DATA", "__tm_clone_table", (uint64_t *)size)
+#else
+#define GET_DATA_TMCT(mh,size) \
+  getsectdatafromheader (mh, "__DATA", "__tm_clone_table", (uint32_t *)size)
+#endif
 
 #define WEAK __attribute__((weak))
 
 extern void _ITM_registerTMCloneTable (void *, size_t) WEAK;
 extern void _ITM_deregisterTMCloneTable (void *) WEAK;
 
+#if defined(START) || defined(END)
+static inline void *getTMCloneTable (const void *f, size_t *tmct_siz)
+{
+  char *tmct_fixed, *tmct = NULL;
+  unsigned int i, img_count; 
+  struct mach_header *mh;
+  Dl_info info;
+  
+  if (! dladdr (f, &info) || info.dli_fbase == NULL)
+abort ();
+  
+  mh = (struct mach_header *) info.dli_fbase;
+  tmct_fixed = GET_DATA_TMCT (mh, tmct_siz);
+  *tmct_siz /= (sizeof (size_t) * 2);
+  /* No tm_clone_table or no clones. */
+  if (tmct_fixed == NULL || *tmct_siz == 0)
+return NULL; 
+
+  img_count = _dyld_image_count();
+  for (i = 0; i < img_count && tmct == NULL; i++)
+{
+  if (mh == _dyld_get_image_header(i))
+	tmct = tmct_fixed + (unsigned long)_dyld_get_image_vmaddr_slide(i); 
+}
+
+  return tmct;
+}
+#endif
+
 #ifdef START
 
 void __doTMRegistrations (void) __attribute__ ((constructor));
 
 void __doTMRegistrations (void)
 {
-  char * tm_clone_table_sect_data;
-  unsigned long tmct_siz;
-  
-  tm_clone_table_sect_data = getsectdata ("__DATA",
-	  "__tm_clone_table",
-	  &tmct_siz);
-  tmct_siz /= (sizeof (size_t) * 2);
-  if (_ITM_registerTMCloneTable != NULL
-  && tm_clone_table_sect_data != NULL
-  && tmct_siz > 0)
-_ITM_registerTMCloneTable (tm_clone_table_sect_data, (size_t)tmct_siz);
+  size_t tmct_siz;
+  void *tmct;
+
+  tmct = getTMCloneTable ((const void *)&__doTMRegistrations, &tmct_siz);
+  if (_ITM_registerTMCloneTable != NULL && tmct != NULL)
+_ITM_registerTMCloneTable (tmct, (size_t)tmct_siz);
 }
 
 #endif
@@ -60,18 +94,12 @@ void __doTMdeRegistrations (void) __attribute__ ((
 
 void __doTMdeRegistrations (void)
 {
-  char * tm_clone_table_sect_data;
-  unsigned long tmct_siz;
-  
-  tm_clone_table_sect_data = getsectdata ("__DATA",
-	  "__tm_clone_table",
-	  &tmct_siz);
-  
-  if (_ITM_deregisterTMCloneTable != NULL
-  && tm_clone_table_sect_data != NULL
-  && tmct_siz > 0)
-_ITM_deregisterTMCloneTable (tm_clone_table_sect_data);
+  size_t tmct_siz;
+  void *tmct;
 
+  tmct = getTMCloneTable ((const void *)&__doTMdeRegistrations, &tmct_siz);
+  if (_ITM_deregisterTMCloneTable != NULL && tmct != NULL)
+_ITM_deregisterTMCloneTable (tmct);
 }
 
 #endif


Re: [PATCH] Fix PR 52199 on power7 (VEC_DUPLICATE)

2012-02-15 Thread David Edelsohn
On Wed, Feb 15, 2012 at 1:32 PM, Michael Meissner
 wrote:
> This patch fixes PR 52199, which shows up on power7 systems when the compiler
> is vectorizing DImode operations, and the vector duplicate code was not
> prepared to accept CONST and SYMBOL_REF's.
>
> I have done a bootstrap and make compare, and there were no regressions.  Is
> this ok to install?  I will also back port the change to 4.6, since the exact
> same code is in that revision as well.

Okay.

Thanks, David


[v3] libstdc++/51368

2012-02-15 Thread Benjamin Kosnik

As per request, syncs libstdc++ with libjava for installation of python
modules using top-level --with-python-dir configure argument.

I think we are going to need GLIBCXX_ENABLE_PYTHON anyway for the other
python bug report.

-benjamin

tested x86/linux
tested x86/linux --with-python-dir=/share/pythoncommit 7087fa3c623191a70de5959ce23dbe004be61caf
Author: bkoz 
Date:   Wed Feb 15 11:33:24 2012 -0800

2012-02-15  Benjamin Kosnik  

	PR libstdc++/51368
	* acinclude.m4 (GLIBCXX_ENABLE_PYTHON): New.
	* configure.ac: Use it.
	* python/Makefile.am: Same.
	* configure: Regenerate.
	* python/Makefile.in: Regenerate.
	* Makefile.in: Same.
	* doc/Makefile.in: Same.
	* include/Makefile.in: Same.
	* po/Makefile.in: Same.
	* src/Makefile.in: Same.
	* src/c++11/Makefile.in: Same.
	* src/c++98/Makefile.in: Same.
	* testsuite/Makefile.in: Same.

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index e089b20..61fdb42 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -1737,26 +1737,26 @@ AC_DEFUN([GLIBCXX_CHECK_MATH_PROTO], [
 	 {  return __builtin_fabsf(__x); }
 	   }
 	])],
-[glibcxx_cv_abs_float=no],
-[glibcxx_cv_abs_float=yes]
+	[glibcxx_cv_abs_float=no],
+	[glibcxx_cv_abs_float=yes]
   )])
 
   # autoheader cannot handle indented templates.
   AH_VERBATIM([__CORRECT_ISO_CPP_MATH_H_PROTO1],
-[/* Define if all C++ overloads are available in .  */
+	[/* Define if all C++ overloads are available in .  */
 #if __cplusplus >= 199711L
 #undef __CORRECT_ISO_CPP_MATH_H_PROTO1
 #endif])
   AH_VERBATIM([__CORRECT_ISO_CPP_MATH_H_PROTO2],
-[/* Define if only double std::abs(double) is available in .  */
+	[/* Define if only double std::abs(double) is available in .  */
 #if __cplusplus >= 199711L
 #undef __CORRECT_ISO_CPP_MATH_H_PROTO2
 #endif])
 
   if test $glibcxx_cv_abs_float = yes; then
-AC_DEFINE(__CORRECT_ISO_CPP_MATH_H_PROTO1)
+	AC_DEFINE(__CORRECT_ISO_CPP_MATH_H_PROTO1)
   else
-AC_DEFINE(__CORRECT_ISO_CPP_MATH_H_PROTO2)
+	AC_DEFINE(__CORRECT_ISO_CPP_MATH_H_PROTO2)
   fi
   AC_MSG_RESULT($glibcxx_cv_abs_float)
   ;;
@@ -1787,19 +1787,19 @@ AC_DEFUN([GLIBCXX_CHECK_STDLIB_PROTO], [
 	 inline long
 	 abs(long __i) { return labs(__i); }
 	   }
-])],
-[glibcxx_cv_abs_long=no],
-[glibcxx_cv_abs_long=yes]
+	])],
+	[glibcxx_cv_abs_long=no],
+	[glibcxx_cv_abs_long=yes]
   )])
 
   # autoheader cannot handle indented templates.
   AH_VERBATIM([__CORRECT_ISO_CPP_STDLIB_H_PROTO],
-[/* Define if all C++ overloads are available in .  */
+	[/* Define if all C++ overloads are available in .  */
 #if __cplusplus >= 199711L
 #undef __CORRECT_ISO_CPP_STDLIB_H_PROTO
 #endif])
   if test $glibcxx_cv_abs_long = yes; then
-AC_DEFINE(__CORRECT_ISO_CPP_STDLIB_H_PROTO, 1)
+	AC_DEFINE(__CORRECT_ISO_CPP_STDLIB_H_PROTO, 1)
   fi
   AC_MSG_RESULT($glibcxx_cv_abs_long)
   ;;
@@ -2495,7 +2495,7 @@ template
 
 int main()
 {
-  typename same::type  f1;	
+  typename same::type  f1;
   typename same::type f2;
 }
 EOF
@@ -2729,7 +2729,7 @@ AC_DEFUN([GLIBCXX_ENABLE_ATOMIC_BUILTINS], [
atomic_type c3(0);
__atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
__atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
-   __ATOMIC_RELAXED);
+   __ATOMIC_RELAXED);
__atomic_test_and_set(&c1, __ATOMIC_RELAXED);
__atomic_load_n(&c1, __ATOMIC_RELAXED);
   ],
@@ -2748,7 +2748,7 @@ AC_DEFUN([GLIBCXX_ENABLE_ATOMIC_BUILTINS], [
atomic_type c3(0);
__atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
__atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
-   __ATOMIC_RELAXED);
+   __ATOMIC_RELAXED);
__atomic_test_and_set(&c1, __ATOMIC_RELAXED);
__atomic_load_n(&c1, __ATOMIC_RELAXED);
   ],
@@ -2767,7 +2767,7 @@ AC_DEFUN([GLIBCXX_ENABLE_ATOMIC_BUILTINS], [
atomic_type c3(0);
__atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
__atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
-   __ATOMIC_RELAXED);
+   __ATOMIC_RELAXED);
__atomic_test_and_set(&c1, __ATOMIC_RELAXED);
__atomic_load_n(&c1, __ATOMIC_RELAXED);
   ],
@@ -2786,7 +2786,7 @@ AC_DEFUN([GLIBCXX_ENABLE_ATOMIC_BUILTINS], [
atomic_type c3(0);
__atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
__atomic_compare_exchange_n(&c1, &c2, c3, true, __ATOMIC_ACQ_REL,
-   __ATOMIC_RELAXED);
+   __ATOMIC_RELAXED);
__atomic_test_and_set(&c1, __ATOMIC_RELAXED);
__atomic_load_n(&c1, __ATOMIC_RELAXED);
   ],
@@ -2814,10 +2814,10 @@ int main()
   atomic_type c3(0);
   __atomic_fetch_add(&c1, c2, __ATOMIC_RELAXED);
   __atomic_compare_exchan

obvious(?) typo in libstdc++-v3/src/c++98/locale.cc

2012-02-15 Thread DJ Delorie

The typo is obvious, but whether or not the wrapped code still works
isn't (to me).

* src/c++98/locale.cc (locale::facet::_S_get_c_locale): Fix typo.

Index: libstdc++-v3/src/c++98/locale.cc
===
--- libstdc++-v3/src/c++98/locale.cc(revision 183469)
+++ libstdc++-v3/src/c++98/locale.cc(working copy)
@@ -203,13 +203,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 _S_create_c_locale(_S_c_locale, _S_c_name);
   }
 
   __c_locale
   locale::facet::_S_get_c_locale()
   {
-#ifdef __GHTREADS
+#ifdef __GTHREADS
 if (__gthread_active_p())
   __gthread_once(&_S_once, _S_initialize_once);
 else
 #endif
   {
if (!_S_c_locale)


Re: obvious(?) typo in libstdc++-v3/src/c++98/locale.cc

2012-02-15 Thread Benjamin Kosnik

> The typo is obvious, but whether or not the wrapped code still works
> isn't (to me).
> 
>   * src/c++98/locale.cc (locale::facet::_S_get_c_locale): Fix
> typo.

Please check this in.

-benjamin



[Patch,AVR]: Add builtins.def and fix some ICE, add tests

2012-02-15 Thread Georg-Johann Lay
This patch introduces a new file builtins.def that is used as central registry
to hold built-ins' information.

The file is used by defining DEF_BUILTIN macre and then including the file as
described in the head comment of builtins.def.

Up to here it's all code clean-up and no functional change.

Moreover there are some minor changes and ICE fixes:

* Fold __builtin_avr_swap to rotate <<< 4
* Don't fold __builtin_avr_insert_bits if first arg is non-const (was ICE)
* Don't expand __builtin_avr_delay_cycles if arg is not-const (was ICE)

Ok for trunk?

Johann

gcc/testsuite/
* gcc.target/avr/torture/builtins-1.c: New test.
* gcc.target/avr/torture/builtins-error.c: New test.
gcc/
* config/avr/builtins.def: New file.
* config/avr/t-avr (avr.o, avr-c.o): Depend on it.
* config/avr/avr.c (enum avr_builtin_id): Use it.
(avr_init_builtins): Use it. And use avr_bdesc.
(bdesc_1arg): Remove.
(bdesc_2arg): Remove.
(bdesc_3arg): Remove.
(struct avr_builtin_description): Add field n_args.
(avr_bdesc): New static variable using builtins.def.
(avr_expand_builtin): Use it.
Don't call avr_expand_delay_cycles if op0 is not CONST_INT.
(avr_fold_builtin): Fold AVR_BUILTIN_SWAP.
Don't fold AVR_BUILTIN_INSERT_BITS if arg0 is not INTEGER_CST.
Index: config/avr/builtins.def
===
--- config/avr/builtins.def	(revision 0)
+++ config/avr/builtins.def	(revision 0)
@@ -0,0 +1,50 @@
+/* Copyright (C) 2012 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it under
+   the terms of the GNU General Public License as published by the Free
+   Software Foundation; either version 3, or (at your option) any later
+   version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+   for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING3.  If not see
+   .  */
+
+/* This file contains the definitions and documentation for the
+   builtins defined in the AVR part of the GNU compiler.
+   Befor including this file, define a macro
+
+   DEF_BUILTIN(NAME, N_ARGS, ID, TYPE, ICODE)
+
+   NAME:   The name as visible by the user as a C string.
+   ID: An integer to identify the built-in.
+   N_ARGS: Number of input arguments.  If special treatment is needed,
+   set to -1 and handle it by hand, see avr.c:avr_expand_builtin().
+   TYPE:   A tree node describing the prototype of the built-in.
+   ICODE:  Insn code number for the insn attached to the built-in.
+   If special treatment is needed to expand the built-in, set to -1.
+*/
+
+/* Mapped to respective instruction.  */
+DEF_BUILTIN ("__builtin_avr_nop",  -1, AVR_BUILTIN_NOP, void_ftype_void, -1)
+DEF_BUILTIN ("__builtin_avr_sei",   0, AVR_BUILTIN_SEI, void_ftype_void, CODE_FOR_enable_interrupt)
+DEF_BUILTIN ("__builtin_avr_cli",   0, AVR_BUILTIN_CLI, void_ftype_void, CODE_FOR_disable_interrupt)
+DEF_BUILTIN ("__builtin_avr_wdr",   0, AVR_BUILTIN_WDR,   void_ftype_void, CODE_FOR_wdr)
+DEF_BUILTIN ("__builtin_avr_sleep", 0, AVR_BUILTIN_SLEEP, void_ftype_void, CODE_FOR_sleep)
+
+/* Mapped to respective instruction but might alse be folded away
+   or emit as libgcc call if ISA does not provide the instruction.  */
+DEF_BUILTIN ("__builtin_avr_swap",   1, AVR_BUILTIN_SWAP,   uchar_ftype_uchar,  CODE_FOR_rotlqi3_4)
+DEF_BUILTIN ("__builtin_avr_fmul",   2, AVR_BUILTIN_FMUL,   uint_ftype_uchar_uchar, CODE_FOR_fmul)
+DEF_BUILTIN ("__builtin_avr_fmuls",  2, AVR_BUILTIN_FMULS,  int_ftype_char_char,CODE_FOR_fmuls)
+DEF_BUILTIN ("__builtin_avr_fmulsu", 2, AVR_BUILTIN_FMULSU, int_ftype_char_uchar,   CODE_FOR_fmulsu)
+
+/* More complex stuff that cannot be mapped 1:1 to an instruction.  */
+DEF_BUILTIN ("__builtin_avr_delay_cycles", -1, AVR_BUILTIN_DELAY_CYCLES, void_ftype_ulong, -1)
+DEF_BUILTIN ("__builtin_avr_insert_bits", 3, AVR_BUILTIN_INSERT_BITS, uchar_ftype_ulong_uchar_uchar, CODE_FOR_insert_bits)
Index: config/avr/avr.c
===
--- config/avr/avr.c	(revision 184269)
+++ config/avr/avr.c	(working copy)
@@ -10504,17 +10504,12 @@ avr_out_insert_bits (rtx *op, int *plen)
 
 enum avr_builtin_id
   {
-AVR_BUILTIN_NOP,
-AVR_BUILTIN_SEI,
-AVR_BUILTIN_CLI,
-AVR_BUILTIN_WDR,
-AVR_BUILTIN_SLEEP,
-AVR_BUILTIN_SWAP,
-AVR_BUILTIN_INSERT_BITS,
-AVR_BUILTIN_FMUL,
-AVR_BUILTIN_FMULS,
-AVR_BUILTIN_FMULSU,
-AVR_BUILTIN_DELAY_CYCLES
+
+#define DEF_BUILTIN(NAME, N_ARGS, ID, TYPE, CODE) ID,
+#include "builtins.def"  
+#undef DEF_BUILTIN
+
+AVR_BUILTIN_COUNT
   

Re: obvious(?) typo in libstdc++-v3/src/c++98/locale.cc

2012-02-15 Thread DJ Delorie

> > The typo is obvious, but whether or not the wrapped code still works
> > isn't (to me).
> > 
> > * src/c++98/locale.cc (locale::facet::_S_get_c_locale): Fix
> > typo.
> 
> Please check this in.

Done.  Thanks!


Re: [patch] Poison SMALL_REGISTER_CLASSES

2012-02-15 Thread Mike Stump
On Feb 15, 2012, at 11:09 AM, Steven Bosscher wrote:
> On Wed, Feb 15, 2012 at 7:59 PM, DJ Delorie  wrote:
>> 
>> I would classify these as "obvious" but please make sure they go in
>> before the poison patch ;-)
>> 
>>> And this will be needed to make those ports do what was intended:
>>> 
>>>   * config/rl78/rl78.h: Replace SMALL_REGISTER_CLASSES with hook.
>>>   * config/rx/rx.h: Remove SMALL_REGISTER_CLASSES.
> 
> I wasn't sure if these are obvious, because I already removed the
> definition from rx.h before, see ChangeLog-2010. Maybe someone put it
> back intentionally.

Nick did it (intentionally) with:

+2010-06-21  Nick Clifton  
+
+   * config/rx/rx.h (PTRDIFF_TYPE): Define.
+   (SMALL_REGISTER_CLASS): Define (to zero).
+   (PRINT_OPERAND): Delete.
+   (PRINT_OPERAND_ADDRESS): Delete.
+   * config/rx/rx-protos.h (rx_print_operand): Delete prototype.
+   (rx_print_operand_address): Delete prototype.
+   * config/rx/rx.c (rx_print_operand): Make static.
+   Allow %H and %L to handle CONST_DOUBLEs.
+   (rx_print_operand_address): Make static.
+   (rx_gen_move_template): Rename local variable 'template' to
+   out_template.
+   (rx_function_arg): Do not pass unknown sized objects in
+   registers.
+   (TARGET_PRINT_OPERAND): Define.
+   (TARGET_PRINT_OPERAND_ADDRESS): Define.


[PATCH][Cilkplus] Patch to fix a bug in 32 bit Metadata

2012-02-15 Thread Iyer, Balaji V
Hello Everyone,
 This patch is for the Cilkplus branch affecting the C and C++ compilers. 
This patch will fix a problem in metadata dwarf code generation part when we 
are trying to catch the register number when a spill occurs.

Thanks,

Balaji V. Iyer.

 diff --git a/gcc/ChangeLog.cilk b/gcc/ChangeLog.cilk
index d50f02c..ebabff6 100644
--- a/gcc/ChangeLog.cilk
+++ b/gcc/ChangeLog.cilk
@@ -1,3 +1,9 @@
+2012-02-15  Balaji V. Iyer  
+
+   * cilk.c (cilk_fix_stack_reg): New function.
+   (expand_buitin_cilk_metadata): Added a check for memory type rtx and do
+   a call to the cilk_fix_reg_stack function.
+   
 2012-02-14  Balaji V. Iyer  
 
* c-array-notation.c (contains_array_notation_exprs): Added a check
diff --git a/gcc/cilk.c b/gcc/cilk.c
index cc4ddcd..cd06f22 100644
--- a/gcc/cilk.c
+++ b/gcc/cilk.c
@@ -1032,6 +1032,32 @@ cilk_output_metadata (void)
   return;
 }
 
+/* This function will go through an RTL of type MEM and then check to see if
+ * the register is PSEUDO, if so then we replace it with stack_pointer_rtx.
+ * This is mainly used to find the DWARF codes for parameters that are pushed
+ * in the stack.
+ */
+static rtx
+cilk_fix_stack_reg (rtx mem_rtx)
+{
+  if (!mem_rtx || !MEM_P (mem_rtx))
+return mem_rtx;
+
+  if (REG_P (XEXP (mem_rtx, 0)))
+{
+  if (REGNO (XEXP (mem_rtx, 0)) >= FIRST_PSEUDO_REGISTER)
+   XEXP (mem_rtx, 0) = stack_pointer_rtx;
+}
+  else if (GET_CODE (XEXP (mem_rtx, 0)) == PLUS)
+{
+  rtx tmp_rtx = XEXP (mem_rtx, 0);
+  if (REG_P (XEXP (tmp_rtx, 0)))
+   if (REGNO (XEXP (tmp_rtx, 0)) >= FIRST_PSEUDO_REGISTER)
+ XEXP (XEXP (mem_rtx, 0), 0) = stack_pointer_rtx;
+}
+  return mem_rtx;
+}
+
 rtx
 expand_builtin_cilk_metadata (const char *annotation ATTRIBUTE_UNUSED,
  tree exp ATTRIBUTE_UNUSED)
@@ -1062,7 +1088,14 @@ expand_builtin_cilk_metadata (const char *annotation 
ATTRIBUTE_UNUSED,
  reg_rtx = XEXP (ii_rtx, 0);
  if (reg_rtx)
if (GET_CODE (reg_rtx) == USE)
- metadata_info.reg_rtx = XEXP (reg_rtx, 0);
+ {
+   reg_rtx = XEXP (reg_rtx, 0);
+   if (REG_P (reg_rtx))
+ metadata_info.reg_rtx = reg_rtx;
+   else if (MEM_P (reg_rtx)) /* this means we are using stack */
+ metadata_info.reg_rtx = cilk_fix_stack_reg (reg_rtx);
+ }
+ 
}
 
   loc_ref = loc_descriptor (metadata_info.reg_rtx, VOIDmode,
diff --git a/gcc/cp/cp-array-notation.c b/gcc/cp/cp-array-notation.c
old mode 100644
new mode 100755


Re: [libgo] Detect Solaris 8/9 SPARC makecontext

2012-02-15 Thread Ian Lance Taylor
Rainer Orth  writes:

> 2012-02-13  Rainer Orth  
>
>   * configure.ac (libgo_cv_lib_makecontext_stack_top): Set on
>   sparc*-*-solaris2.[89]*.
>   (MAKECONTEXT_STACK_TOP): Define if appropriate.
>   (libgo_cv_lib_setcontext_clobbers_tls): Use it.
>   * configure: Regenerate.
>   * config.h.in: Regenerate.
>   * runtime/proc.c (__go_go) [MAKECONTEXT_STACK_TOP]: Add stack size
>   to ss_sp.

Thanks.

Committed.

Ian


Re: [trans-mem,darwin] PR/52042 find tm_clone_table with PIE

2012-02-15 Thread Mike Stump
On Feb 15, 2012, at 11:18 AM, Patrick Marlier wrote:
> PS: this is my first commit so I hope I get it right. Otherwise do not 
> hesitate to yell at me.

Thanks.  I know of two people that will test and yell, if anything goes wrong.  
I'll spin up a build...


[pph] Merge inline function definitions. (issue5677058)

2012-02-15 Thread Lawrence Crowl
This patch merges inline functions where a plain declaration is
read from a pph file after an earlier pph file provides the full
definition.

Making this merge happen required refactoring the several pph
routines.  Ideally, we should have merge versions of the common tree
streamer.  However, we live saving and restoring so as minimize
disruption in the branch.

We add four new tests, x3funcinl12.cc, x3funcinl13.cc, x4funcinl21.cc,
and x4funcinl31.cc to capture the various orders of processing.  The
x3 tests were working.  The x4 tests are now fixed.

Tested on x64.


Index: gcc/testsuite/ChangeLog.pph

2012-02-15   Lawrence Crowl  

* lib/dg-pph.exp: Clarify kind of test in log file.
* g++.dg/pph/x0funcinl1.h: New.
* g++.dg/pph/x0funcinl2.h: New.
* g++.dg/pph/x0funcinl3.h: New.
* g++.dg/pph/x3funcinl12.cc: New.
* g++.dg/pph/x3funcinl13.cc: New.
* g++.dg/pph/x4funcinl21.cc: New.
* g++.dg/pph/x4funcinl31.cc: New.

Index: gcc/cp/ChangeLog.pph

2012-02-15   Lawrence Crowl  

* pph-in.c (pph_in_merge_ld_base): Merge odr_used.
(pph_in_lang_indep_tree_body): New, replacing idiom.
(pph_in_merge_lang_indep_tree_body): Decl merge corresponding to above.
(pph_reset_external): New, from refactoring.
(pph_in_tcc_declaration_tail): Moved into pph_in_tcc_declaration.
(pph_in_tcc_declaration): As above.  Factor out pph_reset_external.
(pph_in_nonnull_tree): New.
(pph_in_merge_tcc_declaration): Do serious decl merging.
(pph_in_identifier_bindings): Factor out pph_in_lang_indep_tree_body.
(pph_in_merge_tree_body): Factor out pph_in_lang_indep_tree_body.
Move pph_in_lang_indep_tree_body and TREE_CHAIN save/restore into
pph_in_merge_tcc_declaration.  Do some spacing corrections.


Index: gcc/testsuite/lib/dg-pph.exp
===
--- gcc/testsuite/lib/dg-pph.exp(revision 184170)
+++ gcc/testsuite/lib/dg-pph.exp(working copy)
@@ -34,7 +34,7 @@ proc dg-pph-hdr { subdir test options ma
 
 set nshort "$subdir/[file tail $test]"
 set bname "[file rootname [file tail $nshort]]"
-verbose -log "\nTesting $nshort, $options"
+verbose -log "\nTesting header $nshort, $options"
 
 set dg-do-what-default preparse
 dg-test -keep-output $test "-fpph-gen $options $mapflag $stable" ""
@@ -57,7 +57,7 @@ proc dg-pph-neg { subdir test options ma
 
 set nshort "$subdir/[file tail $test]"
 set bname "[file rootname [file tail $nshort]]"
-verbose -log "\nTesting $nshort, $options"
+verbose -log "\nTesting negative $nshort, $options"
 
 set dg-do-what-default compile
 dg-test -keep-output $test "$options $mapflag $stable" ""
@@ -86,7 +86,7 @@ proc dg-pph-pos { subdir test options ma
 set dg-do-what-default compile
 set nshort "$subdir/[file tail $test]"
 set bname "[file rootname [file tail $nshort]]"
-verbose -log "\nTesting $nshort, $options"
+verbose -log "\nTesting positive $nshort, $options"
 
 # Determine whether this is an assembly comparison test
 set is_exec [llength [grep $test "dg-do run"]]
Index: gcc/testsuite/g++.dg/pph/x4funcinl21.cc
===
--- gcc/testsuite/g++.dg/pph/x4funcinl21.cc (revision 0)
+++ gcc/testsuite/g++.dg/pph/x4funcinl21.cc (revision 0)
@@ -0,0 +1,7 @@
+#include "x0funcinl2.h"
+#include "x0funcinl1.h"
+
+int main()
+{
+return func() + user();
+}
Index: gcc/testsuite/g++.dg/pph/x3funcinl12.cc
===
--- gcc/testsuite/g++.dg/pph/x3funcinl12.cc (revision 0)
+++ gcc/testsuite/g++.dg/pph/x3funcinl12.cc (revision 0)
@@ -0,0 +1,7 @@
+#include "x0funcinl1.h"
+#include "x0funcinl2.h"
+
+int main()
+{
+return func() + user();
+}
Index: gcc/testsuite/g++.dg/pph/x0funcinl1.h
===
--- gcc/testsuite/g++.dg/pph/x0funcinl1.h   (revision 0)
+++ gcc/testsuite/g++.dg/pph/x0funcinl1.h   (revision 0)
@@ -0,0 +1,8 @@
+#ifndef X0FUNCINL1_H
+#define X0FUNCINL1_H
+
+inline int func();
+
+extern int user();
+
+#endif
Index: gcc/testsuite/g++.dg/pph/x4funcinl31.cc
===
--- gcc/testsuite/g++.dg/pph/x4funcinl31.cc (revision 0)
+++ gcc/testsuite/g++.dg/pph/x4funcinl31.cc (revision 0)
@@ -0,0 +1,7 @@
+#include "x0funcinl3.h"
+#include "x0funcinl1.h"
+
+int main()
+{
+return func() + user();
+}
Index: gcc/testsuite/g++.dg/pph/x0funcinl2.h
===
--- gcc/testsuite/g++.dg/pph/x0funcinl2.h   (revision 0)
+++ gcc/testsuite/g++.dg/pph/x0funcinl2.h   (revision 0)
@@ -0,0 +1,9 @@
+#ifndef X0FUNCINL2_H
+#define X0FUNCINL2_H
+
+inline int func()
+{
+return 3;
+}
+
+#endif
Index: gcc/testsuite/g++.dg/pph

[patch, committed] invoke.texi: clean up n-bit/byte/word modifiers

2012-02-15 Thread Sandra Loosemore
This patch is another installment in my endless(?) series of copy-edits 
to the GCC manual.  Here, I've fixed up a number of places to uniformly 
use e.g. "32-bit int" instead of sometimes that and sometimes "32 bit" 
and sometimes "32bit".  And, as a noun phrase, it's properly "32 bits". 
 Likewise similar issues with n-byte or n-word modifiers.


I've checked this in as obvious.

-Sandra


2012-02-15  Sandra Loosemore  

gcc/
* doc/invoke.texi: Clean up "n-bit/byte/word" modifiers.




Index: gcc/doc/invoke.texi
===
--- gcc/doc/invoke.texi	(revision 184287)
+++ gcc/doc/invoke.texi	(working copy)
@@ -10440,7 +10440,7 @@ for direct calls.  The default is @optio
 
 @item -msmall16
 @opindex msmall16
-Assume addresses can be loaded as 16 bit unsigned values.  This does not
+Assume addresses can be loaded as 16-bit unsigned values.  This does not
 apply to function addresses for which @option{-mlong-calls} semantics
 are in effect.
 
@@ -10487,8 +10487,8 @@ The default is @option{-mfp-mode=caller}
 @opindex mno-postinc
 @item -mno-postmodify
 @opindex mno-postmodify
-Code generation tweaks that disable, respectively, splitting of 32
-bit loads, generation of post-increment addresses, and generation of
+Code generation tweaks that disable, respectively, splitting of 32-bit
+loads, generation of post-increment addresses, and generation of
 post-modify addresses.  The defaults are @option{msplit-lohi},
 @option{-mpost-inc}, and @option{-mpost-modify}.
 
@@ -10903,7 +10903,7 @@ this option and always use the original 
 
 @item -mword-relocations
 @opindex mword-relocations
-Only generate absolute relocations on word sized values (i.e. R_ARM_ABS32).
+Only generate absolute relocations on word-sized values (i.e. R_ARM_ABS32).
 This is enabled by default on targets (uClinux, SymbianOS) where the runtime
 loader imposes this restriction, and when @option{-fpic} or @option{-fPIC}
 is specified.
@@ -11021,7 +11021,7 @@ subroutines.  Code size will be smaller.
 
 @item -mint8
 @opindex mint8
-Assume int to be 8 bit integer.  This affects the sizes of all types: A
+Assume int to be 8-bit integer.  This affects the sizes of all types: a
 char will be 1 byte, an int will be 1 byte, a long will be 2 bytes
 and long long will be 4 bytes.  Please note that this option does not
 comply to the C standards, but it will provide you with smaller code
@@ -11251,7 +11251,7 @@ with up to 128@tie{}KiB of program memor
 
 @item __AVR_HAVE_8BIT_SP__
 @item __AVR_HAVE_16BIT_SP__
-The stack pointer (SP) is 8@tie{}bits resp. 16@tie{}bits wide.
+The stack pointer (SP) is respectively 8 or 16 bits wide.
 The definition of these macros is affected by @code{-mtiny-stack}.
 
 @item __NO_INTERRUPTS__
@@ -11410,7 +11410,7 @@ This is the default.
 Tells the compiler to perform function calls by first loading the
 address of the function into a register and then performing a subroutine
 call on this register.  This switch is needed if the target function
-will lie outside of the 24 bit addressing range of the offset based
+lies outside of the 24-bit addressing range of the offset-based
 version of subroutine call instruction.
 
 This feature is not enabled by default.  Specifying
@@ -12312,7 +12312,7 @@ routine for the debugger.
 
 @item -mmalloc64
 @opindex mmalloc64
-Default to 64bit memory allocation routines.
+Default to 64-bit memory allocation routines.
 @end table
 
 @node FR30 Options
@@ -12730,9 +12730,9 @@ Make @code{int} data 32 bits by default.
 @item -malign-300
 @opindex malign-300
 On the H8/300H and H8S, use the same alignment rules as for the H8/300.
-The default for the H8/300H and H8S is to align longs and floats on 4
-byte boundaries.
-@option{-malign-300} causes them to be aligned on 2 byte boundaries.
+The default for the H8/300H and H8S is to align longs and floats on
+4-byte boundaries.
+@option{-malign-300} causes them to be aligned on 2-byte boundaries.
 This option has no effect on the H8/300.
 @end table
 
@@ -12869,7 +12869,7 @@ are passed to that ld.  The ld that is c
 @option{--with-ld} configure option, GCC's program search path, and
 finally by the user's @env{PATH}.  The linker used by GCC can be printed
 using @samp{which `gcc -print-prog-name=ld`}.  This option is only available
-on the 64 bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
+on the 64-bit HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
 
 @item -mhp-ld
 @opindex mhp-ld
@@ -12881,7 +12881,7 @@ which ld is called, it only changes what
 ld.  The ld that is called is determined by the @option{--with-ld}
 configure option, GCC's program search path, and finally by the user's
 @env{PATH}.  The linker used by GCC can be printed using @samp{which
-`gcc -print-prog-name=ld`}.  This option is only available on the 64 bit
+`gcc -print-prog-name=ld`}.  This option is only available on the 64-bit
 HP-UX GCC, i.e.@: configured with @samp{hppa*64*-*-hpux*}.
 
 

[libitm, darwin] PR52220 move dummy functions definition

2012-02-15 Thread Patrick Marlier

Hi,

In PR/52220, eh-1.C fails because the dummy function 
__cxa_allocate_exception is used instead of the one from libstdc++. 
Indeed, the function is defined in libitm and thus is used.

The fix consists to move the dummy function definitions to darwin-crt-tm.c.

This fix was mainly contributed by Iain Sandoe.
This was approved off-list by Mike Stump.

Committed and tested on darwin 10/11.
--
Patrick.

libitm/
2012-02-15  Iain Sandoe  
Patrick Marlier  

PR libitm/52220
* alloc_cpp.cc: No dummy definitions for darwin.
* eh_cpp.cc: Likewise.

libgcc/
2012-02-15  Iain Sandoe  
Patrick Marlier  

PR libitm/52220
* config/darwin-crt-tm.c: Generate dummy functions.
Index: libitm/alloc_cpp.cc
===
--- libitm/alloc_cpp.cc	(revision 184291)
+++ libitm/alloc_cpp.cc	(working copy)
@@ -60,7 +60,7 @@ extern void _ZdlPvRKSt9nothrow_t (void *, c_nothro
 extern void *_ZnaXRKSt9nothrow_t (size_t, c_nothrow_p) __attribute__((weak));
 extern void _ZdaPvRKSt9nothrow_t (void *, c_nothrow_p) __attribute__((weak));
 
-#if !defined (HAVE_ELF_STYLE_WEAKREF)
+#if !defined (HAVE_ELF_STYLE_WEAKREF) && !defined (__MACH__)
 void *_ZnwX (size_t) { return NULL; }
 void _ZdlPv (void *) { return; }
 void *_ZnaX (size_t) { return NULL; }
Index: libitm/eh_cpp.cc
===
--- libitm/eh_cpp.cc	(revision 184291)
+++ libitm/eh_cpp.cc	(working copy)
@@ -39,7 +39,7 @@ extern void *__cxa_begin_catch (void *) WEAK;
 extern void *__cxa_end_catch (void) WEAK;
 extern void __cxa_tm_cleanup (void *, void *, unsigned int) WEAK;
 
-#if !defined (HAVE_ELF_STYLE_WEAKREF)
+#if !defined (HAVE_ELF_STYLE_WEAKREF) && !defined (__MACH__)
 void *__cxa_allocate_exception (size_t) { return NULL; }
 void __cxa_throw (void *, void *, void *) { return; }
 void *__cxa_begin_catch (void *) { return NULL; }
Index: libgcc/config/darwin-crt-tm.c
===
--- libgcc/config/darwin-crt-tm.c	(revision 184291)
+++ libgcc/config/darwin-crt-tm.c	(working copy)
@@ -39,6 +39,7 @@ see the files COPYING3 and COPYING.RUNTIME respect
 #endif
 
 #define WEAK __attribute__((weak))
+#define UNUSED __attribute__((unused))
 
 extern void _ITM_registerTMCloneTable (void *, size_t) WEAK;
 extern void _ITM_deregisterTMCloneTable (void *) WEAK;
@@ -103,3 +104,46 @@ void __doTMdeRegistrations (void)
 }
 
 #endif
+
+/* Provide dummy functions to satisfy linkage for versions of the Darwin 
+   tool-chain that that can't handle undefined weak refs at the link stage.
+   ??? Define these dummy functions only when !HAVE_ELF_STYLE_WEAKREF. */
+
+extern void *__cxa_allocate_exception (size_t) WEAK;
+extern void __cxa_throw (void *, void *, void *) WEAK;
+extern void *__cxa_begin_catch (void *) WEAK;
+extern void *__cxa_end_catch (void) WEAK;
+extern void __cxa_tm_cleanup (void *, void *, unsigned int) WEAK;
+
+extern void *_ZnwX (size_t) WEAK;
+extern void _ZdlPv (void *) WEAK;
+extern void *_ZnaX (size_t) WEAK;
+extern void _ZdaPv (void *) WEAK;
+
+typedef const struct nothrow_t { } *c_nothrow_p;
+
+extern void *_ZnwXRKSt9nothrow_t (size_t, c_nothrow_p) WEAK;
+extern void _ZdlPvRKSt9nothrow_t (void *, c_nothrow_p) WEAK;
+extern void *_ZnaXRKSt9nothrow_t (size_t, c_nothrow_p) WEAK;
+extern void _ZdaPvRKSt9nothrow_t (void *, c_nothrow_p) WEAK;
+
+void *__cxa_allocate_exception (size_t s UNUSED) { return NULL; }
+void __cxa_throw (void * a UNUSED, void * b UNUSED, void * c UNUSED)
+  { return; }
+void *__cxa_begin_catch (void * a UNUSED) { return NULL; }
+void *__cxa_end_catch (void) { return NULL; }
+void __cxa_tm_cleanup (void * a UNUSED, void * b UNUSED, unsigned int c UNUSED)
+  { return; }
+
+void *_ZnwX (size_t s UNUSED) { return NULL; }
+void _ZdlPv (void * a UNUSED) { return; }
+void *_ZnaX (size_t s UNUSED) { return NULL; }
+void _ZdaPv (void * a UNUSED) { return; }
+
+void *_ZnwXRKSt9nothrow_t (size_t s UNUSED, c_nothrow_p b UNUSED)
+  { return NULL; }
+void _ZdlPvRKSt9nothrow_t (void * a UNUSED, c_nothrow_p b UNUSED)  { return; }
+void *_ZnaXRKSt9nothrow_t (size_t s UNUSED, c_nothrow_p b UNUSED)
+  { return NULL; }
+void _ZdaPvRKSt9nothrow_t (void * a UNUSED, c_nothrow_p b UNUSED) { return; }
+


Re: [libitm, darwin] PR52220 move dummy functions definition

2012-02-15 Thread Iain Sandoe


On 15 Feb 2012, at 23:39, Patrick Marlier wrote:


PR libitm/52220
* alloc_cpp.cc: No dummy definitions for darwin.
* eh_cpp.cc: Likewise.

libgcc/
2012-02-15  Iain Sandoe  
Patrick Marlier  

PR libitm/52220
* config/darwin-crt-tm.c: Generate dummy functions.



thanks for taking care of this.
Iain


Re: [v3] Disable gthreads on Solaris 8/9 (PR libstdc++/52189)

2012-02-15 Thread Jonathan Wakely
On 15 February 2012 17:44, Rainer Orth wrote:
>
> Ok for mainline?

Yes, although I would prefer the config option to be
--enable-libstdcxx-gthreads or --enable-libstdcxx-threads, since I
prefer it to be clear that a config option relates just to libstdc++,
and this only seems to affect libstdc++ not other libs such as libobjc
which make use of gthreads.

> Btw., the ChangeLog lies at one point: I didn't include the
> configure.html update since I lack the required tools.  I'd appreciate
> it if some of the libstdc++ maintainers could handle this for me after
> checking.

Sure, I can do that.


Re: [libitm, darwin] PR52220 move dummy functions definition

2012-02-15 Thread Jack Howarth
On Wed, Feb 15, 2012 at 11:48:29PM +, Iain Sandoe wrote:
>
> On 15 Feb 2012, at 23:39, Patrick Marlier wrote:
>
>>  PR libitm/52220
>>  * alloc_cpp.cc: No dummy definitions for darwin.
>>  * eh_cpp.cc: Likewise.
>>
>> libgcc/
>> 2012-02-15  Iain Sandoe  
>>  Patrick Marlier  
>>
>>  PR libitm/52220
>>  * config/darwin-crt-tm.c: Generate dummy functions.
>> 
>
> thanks for taking care of this.
> Iain

Iain,
   We are still failing...

FAIL: libitm.c++/eh-1.C execution test

on x86_64-apple-darwin11 as the committed patch is missing
those changes from darwin-pie4.patch which addressed PR52220.
 Jack


Re: [libitm, darwin] PR52220 move dummy functions definition

2012-02-15 Thread Patrick Marlier

On 02/15/2012 08:24 PM, Jack Howarth wrote:

On Wed, Feb 15, 2012 at 11:48:29PM +, Iain Sandoe wrote:


On 15 Feb 2012, at 23:39, Patrick Marlier wrote:


PR libitm/52220
* alloc_cpp.cc: No dummy definitions for darwin.
* eh_cpp.cc: Likewise.

libgcc/
2012-02-15  Iain Sandoe
Patrick Marlier

PR libitm/52220
* config/darwin-crt-tm.c: Generate dummy functions.



thanks for taking care of this.
Iain


Iain,
We are still failing...

FAIL: libitm.c++/eh-1.C execution test

on x86_64-apple-darwin11 as the committed patch is missing
those changes from darwin-pie4.patch which addressed PR52220.
  Jack


Iain told me that I made a mistake in the patch :(
Jack: could you just tell me if it solves the problem for you?
Sorry for that.

--
Patrick.

Index: libgcc/config/darwin-crt-tm.c
===
--- libgcc/config/darwin-crt-tm.c   (revision 184293)
+++ libgcc/config/darwin-crt-tm.c   (working copy)
@@ -103,8 +103,6 @@ void __doTMdeRegistrations (void)
 _ITM_deregisterTMCloneTable (tmct);
 }

-#endif
-
 /* Provide dummy functions to satisfy linkage for versions of the Darwin
tool-chain that that can't handle undefined weak refs at the link 
stage.

??? Define these dummy functions only when !HAVE_ELF_STYLE_WEAKREF. */
@@ -147,3 +145,5 @@ void *_ZnaXRKSt9nothrow_t (size_t s UNUSED, c_noth
   { return NULL; }
 void _ZdaPvRKSt9nothrow_t (void * a UNUSED, c_nothrow_p b UNUSED) { 
return; }


+#endif
+





[committed] Fix a typo (PR translation/52264)

2012-02-15 Thread Jakub Jelinek
Hi!

Bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk as obvious:

2012-02-16  Jakub Jelinek  

PR translation/52264
* cgraphunit.c (verify_cgraph_node): Fix a typo.

--- gcc/cgraphunit.c.jj 2012-02-12 15:46:32.0 +0100
+++ gcc/cgraphunit.c2012-02-15 21:29:25.927382754 +0100
@@ -667,7 +667,7 @@ verify_cgraph_node (struct cgraph_node *
   for (i = 0; ipa_ref_list_reference_iterate (&node->ref_list, i, ref); 
i++)
if (ref->use != IPA_REF_ALIAS)
  {
-   error ("Alias has non-alias refernece");
+   error ("Alias has non-alias reference");
error_found = true;
  }
else if (ref_found)

Jakub


Go patch committed: Fix ice-on-valid for type with unknown size

2012-02-15 Thread Ian Lance Taylor
The gccgo frontend was crashing on code like

type T1 struct { F1 *[1]T2 }
type T2 struct { X int }

It needed to know the size of T2 before it was computed.  This patch
fixes the problem.  I added a testcase as bug417.go in the master Go
testsuite, which I will merged into the gccgo testsuite later.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

diff -r e00e83337364 go/expressions.cc
--- a/go/expressions.cc	Wed Feb 15 14:29:00 2012 -0800
+++ b/go/expressions.cc	Wed Feb 15 22:31:03 2012 -0800
@@ -522,8 +522,8 @@
   // first field is just the type descriptor of the object.
   go_assert(strcmp(IDENTIFIER_POINTER(DECL_NAME(field)),
 			"__type_descriptor") == 0);
-  go_assert(TREE_TYPE(field) == TREE_TYPE(rhs_type_descriptor));
-  elt->value = rhs_type_descriptor;
+  elt->value = fold_convert_loc(location.gcc_location(),
+TREE_TYPE(field), rhs_type_descriptor);
 }
   else
 {
diff -r e00e83337364 go/gogo.cc
--- a/go/gogo.cc	Wed Feb 15 14:29:00 2012 -0800
+++ b/go/gogo.cc	Wed Feb 15 22:31:03 2012 -0800
@@ -2929,8 +2929,6 @@
 
   Runtime::convert_types(this);
 
-  Function_type::convert_types(this);
-
   this->named_types_are_converted_ = true;
 }
 
diff -r e00e83337364 go/types.cc
--- a/go/types.cc	Wed Feb 15 14:29:00 2012 -0800
+++ b/go/types.cc	Wed Feb 15 22:31:03 2012 -0800
@@ -34,10 +34,28 @@
 #include "backend.h"
 #include "types.h"
 
+// Forward declarations so that we don't have to make types.h #include
+// backend.h.
+
+static void
+get_backend_struct_fields(Gogo* gogo, const Struct_field_list* fields,
+			  bool use_placeholder,
+			  std::vector* bfields);
+
+static void
+get_backend_slice_fields(Gogo* gogo, Array_type* type, bool use_placeholder,
+			 std::vector* bfields);
+
+static void
+get_backend_interface_fields(Gogo* gogo, Interface_type* type,
+			 bool use_placeholder,
+			 std::vector* bfields);
+
 // Class Type.
 
 Type::Type(Type_classification classification)
-  : classification_(classification), btype_(NULL), type_descriptor_var_(NULL)
+  : classification_(classification), btype_is_placeholder_(false),
+btype_(NULL), type_descriptor_var_(NULL)
 {
 }
 
@@ -895,7 +913,11 @@
 Type::get_backend(Gogo* gogo)
 {
   if (this->btype_ != NULL)
-return this->btype_;
+{
+  if (this->btype_is_placeholder_ && gogo->named_types_are_converted())
+	this->finish_backend(gogo);
+  return this->btype_;
+}
 
   if (this->forward_declaration_type() != NULL
   || this->named_type() != NULL)
@@ -966,6 +988,189 @@
   return this->btype_;
 }
 
+// Get the backend representation of a type without forcing the
+// creation of the backend representation of all supporting types.
+// This will return a backend type that has the correct size but may
+// be incomplete.  E.g., a pointer will just be a placeholder pointer,
+// and will not contain the final representation of the type to which
+// it points.  This is used while converting all named types to the
+// backend representation, to avoid problems with indirect references
+// to types which are not yet complete.  When this is called, the
+// sizes of all direct references (e.g., a struct field) should be
+// known, but the sizes of indirect references (e.g., the type to
+// which a pointer points) may not.
+
+Btype*
+Type::get_backend_placeholder(Gogo* gogo)
+{
+  if (gogo->named_types_are_converted())
+return this->get_backend(gogo);
+  if (this->btype_ != NULL)
+return this->btype_;
+
+  Btype* bt;
+  switch (this->classification_)
+{
+case TYPE_ERROR:
+case TYPE_VOID:
+case TYPE_BOOLEAN:
+case TYPE_INTEGER:
+case TYPE_FLOAT:
+case TYPE_COMPLEX:
+case TYPE_STRING:
+case TYPE_NIL:
+  // These are simple types that can just be created directly.
+  return this->get_backend(gogo);
+
+case TYPE_FUNCTION:
+  {
+	Location loc = this->function_type()->location();
+	bt = gogo->backend()->placeholder_pointer_type("", loc, true);
+  }
+  break;
+
+case TYPE_POINTER:
+  {
+	Location loc = Linemap::unknown_location();
+	bt = gogo->backend()->placeholder_pointer_type("", loc, false);
+  }
+  break;
+
+case TYPE_STRUCT:
+  // We don't have to make the struct itself be a placeholder.  We
+  // are promised that we know the sizes of the struct fields.
+  // But we may have to use a placeholder for any particular
+  // struct field.
+  {
+	std::vector bfields;
+	get_backend_struct_fields(gogo, this->struct_type()->fields(),
+  true, &bfields);
+	bt = gogo->backend()->struct_type(bfields);
+  }
+  break;
+
+case TYPE_ARRAY:
+  if (this->is_slice_type())
+	{
+	  std::vector bfields;
+	  get_backend_slice_fields(gogo, this->array_type(), true, &bfields);
+	  bt = gogo->backend()->struct_type(bfields);
+	}
+  else
+	{
+	  Btype* element = this->array_type()->get_backend_element(gogo, true);
+	  Bexpression* len = this->array_type()->get_ba

[PATCH] Fix up slpeel_tree_peel_loop_to_edge (PR tree-optimization/52255)

2012-02-15 Thread Jakub Jelinek
Hi!

On this testcase we ICE, because slpeel_tree_peel_loop_to_edge is first
called with a loop that has a virtual PHI and no virtual PHI in the loop
exit bb and this function doesn't update the vop properly after inserting
second loop and adding all the conditional guards, then vect_loop_versioning
calls loop_version which deep inside of it performs
verify_loop_closed_ssa (true)
which ICEs on the invalid SSA.  If that check is commented out, we proceed
with optionally doing another slpeel_tree_peel_loop_to_edge and finally
when all loops are vectorized, mark the vop for renaming and update ssa,
which fixes it up.

Here is an attempt to ensure the vop is updated properly, because calling
update_ssa in each slpeel_tree_peel_loop_to_edge would be IMHO too
expensive.  The slpeel_tree_peel_loop_to_edge and its helpers already
DTRT for all other PHIs, the problem with virtual PHIs is that the loop
closed SSA form for other PHIs requires a dummy PHI on the exit bb if
it is used after the loop, but for virtual PHIs it doesn't have this
requirement.  The simplest patch below just adds an extra PHI even
for the vop if there isn't any and the loop has it, then the routines in
multiple places just DTRT.

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

2012-02-16  Jakub Jelinek  

PR tree-optimization/52255
* tree-vect-loop-manip.c (slpeel_tree_peel_loop_to_edge): If
loop->header has virtual PHI, but exit_e->dest doesn't, add
virtual PHI to exit_e->dest and adjust all uses after the loop.

* gcc.c-torture/compile/pr52255.c: New test.

--- gcc/tree-vect-loop-manip.c.jj   2012-01-03 16:22:48.0 +0100
+++ gcc/tree-vect-loop-manip.c  2012-02-15 20:15:27.816120830 +0100
@@ -1171,6 +1171,7 @@ slpeel_tree_peel_loop_to_edge (struct lo
   basic_block bb_before_first_loop;
   basic_block bb_between_loops;
   basic_block new_exit_bb;
+  gimple_stmt_iterator gsi;
   edge exit_e = single_exit (loop);
   LOC loop_loc;
   tree cost_pre_condition = NULL_TREE;
@@ -1184,6 +1185,43 @@ slpeel_tree_peel_loop_to_edge (struct lo
the function tree_duplicate_bb is called.  */
   gimple_register_cfg_hooks ();
 
+  /* If the loop has a virtual PHI, but exit bb doesn't, create a virtual PHI
+ in the exit bb and rename all the uses after the loop.  This simplifies
+ the *guard[12] routines, which assume loop closed SSA form for all PHIs
+ (but normally loop closed SSA form doesn't require virtual PHIs to be
+ in the same form).  Doing this early simplifies the checking what
+ uses should be renamed.  */
+  for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next (&gsi))
+if (!is_gimple_reg (gimple_phi_result (gsi_stmt (gsi
+  {
+   gimple phi = gsi_stmt (gsi);
+   for (gsi = gsi_start_phis (exit_e->dest);
+!gsi_end_p (gsi); gsi_next (&gsi))
+ if (!is_gimple_reg (gimple_phi_result (gsi_stmt (gsi
+   break;
+   if (gsi_end_p (gsi))
+ {
+   gimple new_phi = create_phi_node (SSA_NAME_VAR (PHI_RESULT (phi)),
+ exit_e->dest);
+   tree vop = PHI_ARG_DEF_FROM_EDGE (phi, EDGE_SUCC (loop->latch, 0));
+   source_location loc
+ = gimple_phi_arg_location_from_edge (phi, EDGE_SUCC (loop->latch,
+  0));
+   imm_use_iterator imm_iter;
+   gimple stmt;
+   tree new_vop = make_ssa_name (SSA_NAME_VAR (PHI_RESULT (phi)),
+ new_phi);
+   use_operand_p use_p;
+
+   add_phi_arg (new_phi, vop, exit_e, loc);
+   gimple_phi_set_result (new_phi, new_vop);
+   FOR_EACH_IMM_USE_STMT (stmt, imm_iter, vop)
+ if (stmt != new_phi && gimple_bb (stmt) != loop->header)
+   FOR_EACH_IMM_USE_ON_STMT (use_p, imm_iter)
+ SET_USE (use_p, new_vop);
+ }
+   break;
+  }
 
   /* 1. Generate a copy of LOOP and put it on E (E is the entry/exit of LOOP).
 Resulting CFG would be:
--- gcc/testsuite/gcc.c-torture/compile/pr52255.c.jj2012-02-15 
20:16:23.060799290 +0100
+++ gcc/testsuite/gcc.c-torture/compile/pr52255.c   2012-02-15 
20:16:05.0 +0100
@@ -0,0 +1,12 @@
+/* PR tree-optimization/52255 */
+
+int a, b, c[10], d[10] = { 0, 0 };
+
+void
+foo (void)
+{
+  for (a = 1; a <= 4; a += 1)
+d[a] = d[1];
+  for (; b; ++b)
+c[0] |= 1;
+}

Jakub


[PATCH] Don't decrease mem_cost for special MEMs, even with REG_EQUIV (PR rtl-optimization/52208)

2012-02-15 Thread Jakub Jelinek
Hi!

As mentioned in the PR, if SET_SRC MEM (with REG_EQUIV note) isn't a MEM
that can be used in general operations, but requires some specialized
instruction to load it, decreasing its mem_cost results sometimes in
worse code, the MEM is loaded with a specialized insn, then stored into
a stack slot because e.g. a negative memory cost has been chosen as
cheapest, then loaded back from the stack slot.

This patch gives up if the MEM isn't general_operand.

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

2012-02-16  Jakub Jelinek  

PR rtl-optimization/52208
* ira-costs.c (scan_one_insn): Don't decrease mem_cost
for MEMs with REG_EQUIV, if the MEM isn't general_operand.

--- gcc/ira-costs.c.jj  2012-02-15 07:34:54.0 +0100
+++ gcc/ira-costs.c 2012-02-15 20:57:49.239393641 +0100
@@ -1306,14 +1306,21 @@ scan_one_insn (rtx insn)
 
  Similarly if we're loading other constants from memory (constant
  pool, TOC references, small data areas, etc) and this is the only
- assignment to the destination pseudo.  */
+ assignment to the destination pseudo.
+
+ Don't do this if SET_SRC (set) isn't a general operand, if it is
+ a memory requiring special instructions to load it, decreasing
+ mem_cost might result in it being loaded using the specialized
+ instruction into a register, then stored into stack and loaded
+ again from the stack.  See PR52208.  */
   if (set != 0 && REG_P (SET_DEST (set)) && MEM_P (SET_SRC (set))
   && (note = find_reg_note (insn, REG_EQUIV, NULL_RTX)) != NULL_RTX
   && ((MEM_P (XEXP (note, 0)))
  || (CONSTANT_P (XEXP (note, 0))
  && targetm.legitimate_constant_p (GET_MODE (SET_DEST (set)),
XEXP (note, 0))
- && REG_N_SETS (REGNO (SET_DEST (set))) == 1)))
+ && REG_N_SETS (REGNO (SET_DEST (set))) == 1))
+  && general_operand (SET_SRC (set), GET_MODE (SET_SRC (set
 {
   enum reg_class cl = GENERAL_REGS;
   rtx reg = SET_DEST (set);

Jakub


[PATCH] Fix up copy_decls_walk (PR debug/52260)

2012-02-15 Thread Jakub Jelinek
Hi!

On the following testcase we ICE, because now that clone_tree_hash
inserts elements into decl_table hash table, if the hash table is expanded
during that, storing into *slot might either store it at a wrong spot, or
in completely unrelated memory.

Fixed by storing into the hash table immediately when we have the DIE's
copy, before the clone_tree_hash loop.

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

2012-02-16  Jakub Jelinek  

PR debug/52260
* dwarf2out.c (copy_decls_walk): Fill in *slot before traversing
children with clone_tree_hash, not after it.

* g++.dg/debug/dwarf2/pr52260.C: New test.

--- gcc/dwarf2out.c.jj  2012-02-15 07:35:11.0 +0100
+++ gcc/dwarf2out.c 2012-02-15 20:30:00.845071676 +0100
@@ -7471,14 +7471,6 @@ copy_decls_walk (dw_die_ref unit, dw_die
   dw_die_ref parent = unit;
  dw_die_ref copy = clone_die (targ);
 
- FOR_EACH_CHILD (targ, c,
- add_child_die (copy,
-clone_tree_hash (c, decl_table)));
-
-  /* Make sure the cloned tree is marked as part of the
- type unit.  */
-  mark_dies (copy);
-
   /* Record in DECL_TABLE that TARG has been copied.
  Need to do this now, before the recursive call,
  because DECL_TABLE may be expanded and SLOT
@@ -7488,6 +7480,14 @@ copy_decls_walk (dw_die_ref unit, dw_die
   entry->copy = copy;
   *slot = entry;
 
+ FOR_EACH_CHILD (targ, c,
+ add_child_die (copy,
+clone_tree_hash (c, decl_table)));
+
+  /* Make sure the cloned tree is marked as part of the
+ type unit.  */
+  mark_dies (copy);
+
   /* If TARG has surrounding context, copy its ancestor tree
  into the new type unit.  */
   if (targ->die_parent != NULL
--- gcc/testsuite/g++.dg/debug/dwarf2/pr52260.C.jj  2012-02-16 
00:22:11.632188858 +0100
+++ gcc/testsuite/g++.dg/debug/dwarf2/pr52260.C 2012-02-16 00:21:51.0 
+0100
@@ -0,0 +1,133 @@
+// PR debug/52260
+// { dg-do compile }
+// { dg-options "-gdwarf-4 -std=c++0x" }
+
+namespace { typedef decltype (nullptr) T1; }
+struct B {};
+namespace A
+{
+  template 
+  struct C { static constexpr T value = __v; };
+  typedef C  D;
+  template 
+  struct E : D {};
+  template 
+  struct F : C ::value)> {};
+  template 
+  struct G { typedef T t; };
+}
+template 
+struct H {};
+namespace A
+{
+  template 
+  struct I : H  {};
+  template  struct J;
+  template  struct K;
+  struct L
+  {
+template 
+struct M
+{
+  template  static bool m2 (T) { return false; }
+};
+  };
+  template  struct N;
+  template 
+  struct N  : L::M  {};
+  template 
+  struct K  :J <,>, L
+  {
+typedef T O (B4 ...);
+struct P {};
+template  K (B2, typename G ::value, P>::t = P ());
+  };
+  template 
+  template 
+  K ::K (B2 __f, typename G ::value, P>::t)
+  {
+typedef N  Q;
+Q::m2 (__f);
+  };
+}
+enum R { r1 };
+const R r2 = r1;
+namespace A
+{
+  template 
+  struct S {};
+  template >
+  struct U {};
+  template 
+  struct V { T *operator -> (); };
+  template 
+  struct W : V 
+  {
+W (const W &);
+W (T1) {}
+W & operator= (W) {}
+  };
+  template  struct Z;
+  struct AA
+  {
+struct AB
+{
+  struct AC { void operator () () {} };
+};
+template  using AD = U ;
+struct AE
+{
+  typedef AD  AZ;
+  virtual ~AE ();
+  void o3 (K , bool = false) {}
+  template  struct AY;
+  struct C1 {};
+  template  struct AY 
+  {
+   AZ operator () () { return AZ (); }
+Z  _M_Z;
+  };
+  template 
+  static AY  _s1 (B, Z  *);
+};
+  };
+  template <>
+  struct Z 
+  {
+typedef AA::AE AF;
+W  o4;
+void foo (B __p)
+{
+  auto _s1 = AF::_s1 (__p, this);
+  o4->o3 (_s1);
+}
+  };
+  template 
+  struct AG {};
+  template >
+  struct AH : AG 
+  {
+void bar (T) { baz (); }
+template 
+void baz (_Args && ...);
+  };
+  template 
+  template 
+  void AH ::baz (_Args && ...) {}
+  namespace
+  {
+typedef A::K  AI;
+struct AF
+{
+  int v2;
+  AI v1;
+  AF (int, unsigned, AI __t) : v2 (), v1 (__t) {}
+};
+struct D3 : A::AH 
+{
+  typedef AF AFT;
+  void v3 (AI __t) { bar (AFT (4, v4, __t)); }
+  int v4;
+};
+  }
+}

Jakub


Go patch committed: Drop log2 and trunk

2012-02-15 Thread Ian Lance Taylor
Rainer Orth  writes:

> The patch allowed the bootstrap to complete successfully, but since
> libgo.so now has undefined references to log2 and trunc, all Go
> execution still fail.

I went ahead and removed the uses of the libc log2 and trunc functions,
on the basis that although they are in C99 they are not in C89.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

diff -r e3822d0c556b libgo/go/math/floor.go
--- a/libgo/go/math/floor.go	Wed Feb 15 22:42:44 2012 -0800
+++ b/libgo/go/math/floor.go	Wed Feb 15 23:07:38 2012 -0800
@@ -58,11 +58,8 @@
 //	Trunc(±Inf) = ±Inf
 //	Trunc(NaN) = NaN
 
-//extern trunc
-func libc_trunc(float64) float64
-
 func Trunc(x float64) float64 {
-	return libc_trunc(x)
+	return trunc(x)
 }
 
 func trunc(x float64) float64 {
diff -r e3822d0c556b libgo/go/math/log10.go
--- a/libgo/go/math/log10.go	Wed Feb 15 22:42:44 2012 -0800
+++ b/libgo/go/math/log10.go	Wed Feb 15 23:07:38 2012 -0800
@@ -21,11 +21,8 @@
 // Log2 returns the binary logarithm of x.
 // The special cases are the same as for Log.
 
-//extern log2
-func libc_log2(float64) float64
-
 func Log2(x float64) float64 {
-	return libc_log2(x)
+	return log2(x)
 }
 
 func log2(x float64) float64 {