PATCH: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *)

2011-03-06 Thread H.J. Lu
Hi,

We shouldn't save call frame hard registers as "void *".  This patch
changes the unwind library to save call frame hard registers as
_Unwind_Word.  OK for 4.7?

Thanks.


H.J.

commit 4163355471bfb192fdacc5da1ceb9aec5569ff94
Author: H.J. Lu 
Date:   Sun Mar 6 08:19:25 2011 -0800

Save call frame hard registers as _Unwind_Word.

diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
index 5389f19..022767b 100644
--- a/gcc/ChangeLog.x32
+++ b/gcc/ChangeLog.x32
@@ -1,3 +1,15 @@
+2011-03-06  H.J. Lu  
+
+   PR other/48007
+   * unwind-dw2.c (_Unwind_Context): Save call frame hard registers
+   as _Unwind_Word.
+   (_Unwind_GetGR): Get GR value as _Unwind_Word.
+   (_Unwind_SetGR): Set GR value as _Unwind_Word.
+   (_Unwind_SetGRValue): Likewise.
+   (_Unwind_GetGRPtr): Cast return to "void *".
+   (_Unwind_SetGRPtr): Cast pointer to _Unwind_Word.
+   (uw_install_context_1): Cast pointer to "void *".
+
 2011-03-05  H.J. Lu  
 
* config/i386/linux-unwind.h (x86_64_fallback_frame_state):
diff --git a/gcc/unwind-dw2.c b/gcc/unwind-dw2.c
index 2ea9adb..229c373 100644
--- a/gcc/unwind-dw2.c
+++ b/gcc/unwind-dw2.c
@@ -60,7 +60,7 @@
to its caller.  */
 struct _Unwind_Context
 {
-  void *reg[DWARF_FRAME_REGISTERS+1];
+  _Unwind_Word reg[DWARF_FRAME_REGISTERS+1];
   void *cfa;
   void *ra;
   void *lsda;
@@ -152,7 +152,7 @@ inline _Unwind_Word
 _Unwind_GetGR (struct _Unwind_Context *context, int index)
 {
   int size;
-  void *ptr;
+  _Unwind_Word val;
 
 #ifdef DWARF_ZERO_REG
   if (index == DWARF_ZERO_REG)
@@ -162,18 +162,18 @@ _Unwind_GetGR (struct _Unwind_Context *context, int index)
   index = DWARF_REG_TO_UNWIND_COLUMN (index);
   gcc_assert (index < (int) sizeof(dwarf_reg_size_table));
   size = dwarf_reg_size_table[index];
-  ptr = context->reg[index];
+  val = context->reg[index];
 
   if (_Unwind_IsExtendedContext (context) && context->by_value[index])
-return (_Unwind_Word) (_Unwind_Internal_Ptr) ptr;
+return val;
 
   /* This will segfault if the register hasn't been saved.  */
   if (size == sizeof(_Unwind_Ptr))
-return * (_Unwind_Ptr *) ptr;
+return * (_Unwind_Ptr *) (intptr_t) val;
   else
 {
   gcc_assert (size == sizeof(_Unwind_Word));
-  return * (_Unwind_Word *) ptr;
+  return * (_Unwind_Word *) (intptr_t) val;
 }
 }
 
@@ -205,11 +205,11 @@ _Unwind_SetGR (struct _Unwind_Context *context, int 
index, _Unwind_Word val)
 
   if (_Unwind_IsExtendedContext (context) && context->by_value[index])
 {
-  context->reg[index] = (void *) (_Unwind_Internal_Ptr) val;
+  context->reg[index] = val;
   return;
 }
 
-  ptr = context->reg[index];
+  ptr = (void *) (intptr_t) context->reg[index];
 
   if (size == sizeof(_Unwind_Ptr))
 * (_Unwind_Ptr *) ptr = val;
@@ -227,8 +227,8 @@ _Unwind_GetGRPtr (struct _Unwind_Context *context, int 
index)
 {
   index = DWARF_REG_TO_UNWIND_COLUMN (index);
   if (_Unwind_IsExtendedContext (context) && context->by_value[index])
-return &context->reg[index];
-  return context->reg[index];
+return (void *) (intptr_t) &context->reg[index];
+  return (void *) (intptr_t) context->reg[index];
 }
 
 /* Set the pointer to a register INDEX as saved in CONTEXT.  */
@@ -239,7 +239,7 @@ _Unwind_SetGRPtr (struct _Unwind_Context *context, int 
index, void *p)
   index = DWARF_REG_TO_UNWIND_COLUMN (index);
   if (_Unwind_IsExtendedContext (context))
 context->by_value[index] = 0;
-  context->reg[index] = p;
+  context->reg[index] = (_Unwind_Word) (intptr_t) p;
 }
 
 /* Overwrite the saved value for register INDEX in CONTEXT with VAL.  */
@@ -250,10 +250,10 @@ _Unwind_SetGRValue (struct _Unwind_Context *context, int 
index,
 {
   index = DWARF_REG_TO_UNWIND_COLUMN (index);
   gcc_assert (index < (int) sizeof(dwarf_reg_size_table));
-  gcc_assert (dwarf_reg_size_table[index] == sizeof (_Unwind_Ptr));
+  gcc_assert (dwarf_reg_size_table[index] == sizeof (_Unwind_Word));
 
   context->by_value[index] = 1;
-  context->reg[index] = (void *) (_Unwind_Internal_Ptr) val;
+  context->reg[index] = val;
 }
 
 /* Return nonzero if register INDEX is stored by value rather than
@@ -1524,8 +1524,8 @@ uw_install_context_1 (struct _Unwind_Context *current,
 
   for (i = 0; i < DWARF_FRAME_REGISTERS; ++i)
 {
-  void *c = current->reg[i];
-  void *t = target->reg[i];
+  void *c = (void *) (intptr_t) current->reg[i];
+  void *t = (void *) (intptr_t) target->reg[i];
 
   gcc_assert (current->by_value[i] == 0);
   if (target->by_value[i] && c)


[x32] PATCH: Add initialize x32 support to GCC testsuite

2011-03-06 Thread H.J. Lu
Hi,

I checked in this patch to add initialize x32 support to GCC testsuite.


H.J.

commit 8df1dc7ee66e767006353d5358be926261080c1a
Author: H.J. Lu 
Date:   Sun Mar 6 09:53:16 2011 -0800

Add initialize x32 support to GCC testsuite.

diff --git a/gcc/testsuite/ChangeLog.x32 b/gcc/testsuite/ChangeLog.x32
index 22345df..e5c6bfd 100644
--- a/gcc/testsuite/ChangeLog.x32
+++ b/gcc/testsuite/ChangeLog.x32
@@ -1,3 +1,9 @@
+2011-03-06  H.J. Lu  
+
+   * go.test/go-test.exp (go-set-goarch): Check x32.
+
+   * lib/target-supports.exp (check_effective_target_x32): New.
+
 2011-03-02  H.J. Lu  
 
PR rtl-optimization/47958
diff --git a/gcc/testsuite/go.test/go-test.exp 
b/gcc/testsuite/go.test/go-test.exp
index 8945b05..9202eca 100644
--- a/gcc/testsuite/go.test/go-test.exp
+++ b/gcc/testsuite/go.test/go-test.exp
@@ -119,7 +119,8 @@ proc go-set-goarch { } {
}
"i?86-*-*" -
"x86_64-*-*" {
-   if [check_effective_target_ilp32] {
+   if { [check_effective_target_ilp32]
+&& ![check_effective_target_x32] } {
set goarch "386"
} else {
set goarch "amd64"
diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index 36cab54..2e75e5b 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -1492,6 +1492,17 @@ proc check_effective_target_ilp32 { } {
 }]
 }
 
+# Return 1 if we're generating x32 code using default options, 0
+# otherwise.
+
+proc check_effective_target_x32 { } {
+return [check_no_compiler_messages x32 object {
+   int dummy[sizeof (int) == 4
+ && sizeof (void *) == 4
+ && sizeof (long) == 4 ? 1 : -1] = { __x86_64__ };
+}]
+}
+
 # Return 1 if we're generating 32-bit or larger integers using default
 # options, 0 otherwise.
 
diff --git a/libgomp/ChangeLog.x32 b/libgomp/ChangeLog.x32
index f0d2b59..eedac54 100644
--- a/libgomp/ChangeLog.x32
+++ b/libgomp/ChangeLog.x32
@@ -1,3 +1,7 @@
+2011-03-06  H.J. Lu  
+
+   * lib/libgomp.exp (libgomp_init): Don't add -march=i486 for x32.
+
 2011-02-17  H.J. Lu  
 
* config/linux/x86/futex.h: Check __x86_64__ instead of
diff --git a/libgomp/testsuite/lib/libgomp.exp 
b/libgomp/testsuite/lib/libgomp.exp
index 0b0b608..8b6b9f3 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -141,7 +141,8 @@ proc libgomp_init { args } {
 
 # We use atomic operations in the testcases to validate results.
 if { ([istarget i?86-*-*] || [istarget x86_64-*-*])
-&& [check_effective_target_ilp32] } {
+&& [check_effective_target_ilp32]
+&& ![check_effective_target_x32] } {
lappend ALWAYS_CFLAGS "additional_flags=-march=i486"
 }
 


[x32] PATCH: Convert function address to Pmode if needed

2011-03-06 Thread H.J. Lu
Hi,

I checked in this patch to convert function address to Pmode if needed.

H.J.
---
commit b2f3e23711761c7ae4c8378ba63525dfd4030a7a
Author: H.J. Lu 
Date:   Sun Mar 6 10:52:38 2011 -0800

Convert function address to Pmode if needed.

diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
index 022767b..0fae773 100644
--- a/gcc/ChangeLog.x32
+++ b/gcc/ChangeLog.x32
@@ -1,5 +1,10 @@
 2011-03-06  H.J. Lu  
 
+   * config/i386/i386.c (ix86_expand_call): Convert function address
+   to Pmode if needed.
+
+2011-03-06  H.J. Lu  
+
PR other/48007
* unwind-dw2.c (_Unwind_Context): Save call frame hard registers
as _Unwind_Word.
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index b2eae67..c034257 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -22041,7 +22041,10 @@ ix86_expand_call (rtx retval, rtx fnaddr, rtx callarg1,
   ? !sibcall_insn_operand (XEXP (fnaddr, 0), Pmode)
   : !call_insn_operand (XEXP (fnaddr, 0), Pmode))
 {
-  fnaddr = copy_to_mode_reg (Pmode, XEXP (fnaddr, 0));
+  fnaddr = XEXP (fnaddr, 0);
+  if (GET_MODE (fnaddr) != Pmode)
+   fnaddr = convert_to_mode (Pmode, fnaddr, 1);
+  fnaddr = copy_to_mode_reg (Pmode, fnaddr);
   fnaddr = gen_rtx_MEM (QImode, fnaddr);
 }
 


[Patch, fortran] PR47850 - [4.6 Regression] ICE in gfc_conv_array_initializer

2011-03-06 Thread Paul Richard Thomas
This one was exceedingly difficult to diagnose.  The workings of
array.c are opaque to say the least of it!  However, the fix is
relatively clear.  The testcase in the PR failed because the argument
of ANY is not a gfc_constant_ac.  However, iterating through the
constructor and testing the expressions for constantness yields the
correct result.

Bootstraps and regtests on FC9/x86_64 - OK for trunk?

Cheers

Paul and Jerry

2011-03-06  Paul Thomas  
Jerry DeLisle  

PR fortran/47850
* expr.c (gfc_is_constant_expr): Only use gfc_constant_ac if
the expression has an iterator.  Otherwise, iterate through the
array, checking for constant expressions for each element.

2011-03-06  Paul Thomas  
Jerry DeLisle  

PR fortran/47850
* gfortran.dg/array_constructor_37.f90 : New test.
Index: gcc/fortran/expr.c
===
*** gcc/fortran/expr.c	(revision 170715)
--- gcc/fortran/expr.c	(working copy)
*** gfc_is_constant_expr (gfc_expr *e)
*** 937,952 
return e->ref == NULL || (gfc_is_constant_expr (e->ref->u.ss.start)
  && gfc_is_constant_expr (e->ref->u.ss.end));
  
  case EXPR_STRUCTURE:
!   for (c = gfc_constructor_first (e->value.constructor);
! 	   c; c = gfc_constructor_next (c))
  	if (!gfc_is_constant_expr (c->expr))
  	  return 0;
  
return 1;
  
- case EXPR_ARRAY:
-   return gfc_constant_ac (e);
  
  default:
gfc_internal_error ("gfc_is_constant_expr(): Unknown expression type");
--- 937,954 
return e->ref == NULL || (gfc_is_constant_expr (e->ref->u.ss.start)
  && gfc_is_constant_expr (e->ref->u.ss.end));
  
+ case EXPR_ARRAY:
  case EXPR_STRUCTURE:
!   c = gfc_constructor_first (e->value.constructor);
!   if ((e->expr_type == EXPR_ARRAY) && c && c->iterator)
! return gfc_constant_ac (e);
! 
!   for (; c; c = gfc_constructor_next (c))
  	if (!gfc_is_constant_expr (c->expr))
  	  return 0;
  
return 1;
  
  
  default:
gfc_internal_error ("gfc_is_constant_expr(): Unknown expression type");
Index: gcc/testsuite/gfortran.dg/array_constructor_37.f90
===
*** gcc/testsuite/gfortran.dg/array_constructor_37.f90	(revision 0)
--- gcc/testsuite/gfortran.dg/array_constructor_37.f90	(revision 0)
***
*** 0 
--- 1,32 
+ ! { dg-do compile }
+ ! Check the fix for PR47850, in which the argument of ANY, below, was not
+ ! simplified, thereby causing an ICE.
+ !
+ ! Contributed by Tobias Burnus   but based on James van Buskirk's program in
+ ! http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/625faf82578e9af8
+ !
+ !
+ program Cindex
+implicit none
+integer,parameter :: SENSOR_CHANNEL(8) = &
+   [10,12,17,20,22,30,33,34]
+integer,parameter :: NLTE_CHANNEL(3) = [20,22,34]
+integer,parameter :: N_NLTE_CHANNELS = size(NLTE_CHANNEL)
+integer,parameter :: N_CHANNELS = size(SENSOR_CHANNEL)
+integer i
+integer,parameter :: C_INDEX(8) = unpack( &
+   vector = [(i,i=1,size(SENSOR_CHANNEL))], &
+   mask = [(any(SENSOR_CHANNEL(i) == NLTE_CHANNEL), &
+  i=lbound(SENSOR_CHANNEL,1),ubound(SENSOR_CHANNEL,1))], &
+   field = 0)
+character(20) fmt
+ 
+write(fmt,'(a,i0,a)') '(a,t19,',size(SENSOR_CHANNEL),'(i3:","))'
+write(*,fmt) 'SENSOR_CHANNEL = ',SENSOR_CHANNEL
+write(fmt,'(a,i0,a)') '(a,t19,',size(NLTE_CHANNEL),'(i3:","))'
+write(*,fmt) 'NLTE_CHANNEL = ',NLTE_CHANNEL
+write(*,'(a,t19,i3)') 'N_NLTE_CHANNELS = ',N_NLTE_CHANNELS
+write(*,'(a,t19,i3)') 'N_CHANNELS = ',N_CHANNELS
+write(fmt,'(a,i0,a)') '(a,t19,',size(C_INDEX),'(i3:","))'
+write(*,fmt) 'C_INDEX = ',C_INDEX
+ end program Cindex


[x32] PATCH: Check SUBREG_REG for parts.index and parts.base

2011-03-06 Thread H.J. Lu
Hi,

X32 may use SUBREG_REG in parts.index and parts.base.  I checked
this patch into x32 branch.


H.J.
---
commit e2f00cf7ffb008eb4710221853d82fa1b81433e0
Author: H.J. Lu 
Date:   Sun Mar 6 11:14:50 2011 -0800

Check SUBREG_REG for parts.index and parts.base.

diff --git a/gcc/ChangeLog.x32 b/gcc/ChangeLog.x32
index 0fae773..f39563b 100644
--- a/gcc/ChangeLog.x32
+++ b/gcc/ChangeLog.x32
@@ -1,5 +1,10 @@
 2011-03-06  H.J. Lu  
 
+   * config/i386/predicates.md (aligned_operand): Check SUBREG_REG
+   for parts.index and parts.base.
+
+2011-03-06  H.J. Lu  
+
* config/i386/i386.c (ix86_expand_call): Convert function address
to Pmode if needed.
 
diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
index 55a04e3..4bd5688 100644
--- a/gcc/config/i386/predicates.md
+++ b/gcc/config/i386/predicates.md
@@ -853,11 +853,15 @@
   /* Look for some component that isn't known to be aligned.  */
   if (parts.index)
 {
+  if (GET_CODE (parts.index) == SUBREG)
+   parts.index = SUBREG_REG (parts.index);
   if (REGNO_POINTER_ALIGN (REGNO (parts.index)) * parts.scale < 32)
return false;
 }
   if (parts.base)
 {
+  if (GET_CODE (parts.base) == SUBREG)
+   parts.base = SUBREG_REG (parts.base);
   if (REGNO_POINTER_ALIGN (REGNO (parts.base)) < 32)
return false;
 }


Re: [Patch, fortran] PR47850 - [4.6 Regression] ICE in gfc_conv_array_initializer

2011-03-06 Thread Jerry DeLisle

On 03/06/2011 10:57 AM, Paul Richard Thomas wrote:

This one was exceedingly difficult to diagnose.  The workings of
array.c are opaque to say the least of it!  However, the fix is
relatively clear.  The testcase in the PR failed because the argument
of ANY is not a gfc_constant_ac.  However, iterating through the
constructor and testing the expressions for constantness yields the
correct result.

Bootstraps and regtests on FC9/x86_64 - OK for trunk?



AOK, what a bugger. I spent several hours trying to isolate where one could 
effect a change.


Thanks Paul for "seeing" it.

Jerry


Re: [Patch, fortran] PR47850 - [4.6 Regression] ICE in gfc_conv_array_initializer

2011-03-06 Thread Paul Richard Thomas
Dear Jerry,

I am not sure about one of the submitters reviewing the patch :-)
Fortunately, Dominique d'Humieres ran it by his own tests and found
that it did not break anything.

Submitted as revision 170720.

Thanks to you both!

Paul

2011-03-06  Paul Thomas  
Jerry DeLisle  

PR fortran/47850
* expr.c (gfc_is_constant_expr): Only use gfc_constant_ac if
the expression has an iterator.  Otherwise, iterate through the
array, checking for constant expressions for each element.

2011-03-06  Paul Thomas  
Jerry DeLisle  

PR fortran/47850
* gfortran.dg/array_constructor_37.f90 : New test.


Re: PATCH: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *)

2011-03-06 Thread Andrew Pinski
On Sun, Mar 6, 2011 at 9:18 AM, H.J. Lu  wrote:
> Hi,
>
> We shouldn't save call frame hard registers as "void *".  This patch
> changes the unwind library to save call frame hard registers as
> _Unwind_Word.  OK for 4.7?

I think this will break the ABI for the MIPS N32 ABI.  Not to mention
the MIPS N32 ABI works fine with the unwinding part this way.  Does
someone use the unwinding library to look at the registers in previous
stack frames?

-- Pinski


Re: PATCH: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *)

2011-03-06 Thread H.J. Lu
On Sun, Mar 6, 2011 at 1:15 PM, Andrew Pinski  wrote:
> On Sun, Mar 6, 2011 at 9:18 AM, H.J. Lu  wrote:
>> Hi,
>>
>> We shouldn't save call frame hard registers as "void *".  This patch
>> changes the unwind library to save call frame hard registers as
>> _Unwind_Word.  OK for 4.7?
>
> I think this will break the ABI for the MIPS N32 ABI.  Not to mention
> the MIPS N32 ABI works fine with the unwinding part this way.  Does
> someone use the unwinding library to look at the registers in previous
> stack frames?

It may be psABI/implementation specific.  X32 glibc force unwind calls
_Unwind_SetGRValue to get a 64bit register value.


-- 
H.J.


PATCH: Remove README.QMTEST

2011-03-06 Thread Mark Mitchell

It was recently pointed out to me that we still have the README.QMTEST
file in gcc/testsuite.  That file talks about how to use QMTest
instead of DejaGNU to test G++ -- but the information there is just
not accurate anymore.  Various things have bit-rotted since the point
at which that was written.  Given that nobody is actively working on
making this work, it's best just to remove the file.

Applied.

--
Mark Mitchell
CodeSourcery
m...@codesourcery.com
(650) 331-3385 x713

2011-03-06  Mark Mitchell  

* README.QMTEST: Remove.

[actual diff elided for brevity]


Re: PATCH: Remove README.QMTEST

2011-03-06 Thread FX
> It was recently pointed out to me that we still have the README.QMTEST
> file in gcc/testsuite.  That file talks about how to use QMTest
> instead of DejaGNU to test G++ -- but the information there is just
> not accurate anymore.  Various things have bit-rotted since the point
> at which that was written.  Given that nobody is actively working on
> making this work, it's best just to remove the file.

There are also qmtest targets in gcc/Makefile.in. Shouldn't these be removed 
too?

FX


[RFA] libiberty/argv.c, expandargv, close memory leak

2011-03-06 Thread Michael Snyder

OK?

2011-03-06  Michael Snyder  

* argv.c (expandargv): Close memory leak.

Index: argv.c
===
RCS file: /cvs/src/src/libiberty/argv.c,v
retrieving revision 1.22
diff -u -p -r1.22 argv.c
--- argv.c  13 Aug 2010 11:36:10 -  1.22
+++ argv.c  6 Mar 2011 22:41:02 -
@@ -439,7 +439,10 @@ expandargv (int *argcp, char ***argvp)
 due to CR/LF->CR translation when reading text files.
 That does not in-and-of itself indicate failure.  */
  && ferror (f))
-   goto error;
+   {
+ xfree (buffer);
+ goto error;
+   }
   /* Add a NUL terminator.  */
   buffer[len] = '\0';
   /* If the file is empty or contains only whitespace, buildargv would


Re: PATCH: Remove README.QMTEST

2011-03-06 Thread Mike Stump
On Mar 6, 2011, at 1:39 PM, mitch...@codesourcery.com (Mark Mitchell) wrote:
> It was recently pointed out to me that we still have the README.QMTEST
> file in gcc/testsuite.  That file talks about how to use QMTest
> instead of DejaGNU to test G++

If you were to summarize the 3 most compelling features provided, I'd be 
interested.  I'm thinking it was parallel testing...


Re: PATCH: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *)

2011-03-06 Thread Richard Guenther
On Sun, Mar 6, 2011 at 10:28 PM, H.J. Lu  wrote:
> On Sun, Mar 6, 2011 at 1:15 PM, Andrew Pinski  wrote:
>> On Sun, Mar 6, 2011 at 9:18 AM, H.J. Lu  wrote:
>>> Hi,
>>>
>>> We shouldn't save call frame hard registers as "void *".  This patch
>>> changes the unwind library to save call frame hard registers as
>>> _Unwind_Word.  OK for 4.7?
>>
>> I think this will break the ABI for the MIPS N32 ABI.  Not to mention
>> the MIPS N32 ABI works fine with the unwinding part this way.  Does
>> someone use the unwinding library to look at the registers in previous
>> stack frames?
>
> It may be psABI/implementation specific.  X32 glibc force unwind calls
> _Unwind_SetGRValue to get a 64bit register value.

So fix it on that side?

Richard.


Re: PowerPC32 .gnu.attributes

2011-03-06 Thread David Edelsohn
On Thu, Mar 3, 2011 at 11:35 PM, Alan Modra  wrote:
> Re http://gcc.gnu.org/ml/gcc-patches/2011-02/msg01525.html
>
> Updated patch, using cgraph to decide whether a function is visible
> outside of the object file.  Bootstrapped and regression tested
> powerpc-linux.  OK for 4.6?
>
>        * config/rs6000/linux.h (TARGET_ASM_FILE_END): Don't define.
>        * config/rs6000/linux64.h (TARGET_ASM_FILE_END): Don't define.
>        * config/rs6000/sysv4.h (TARGET_ASM_FILE_END): Define.
>        * config/rs6000/rs6000-protos.h (init_cumulative_args): Add fndecl and
>        return_mode args.
>        * config/rs6000/rs6000.h (CUMULATIVE_ARGS): Add "escapes".
>        (INIT_CUMULATIVE_ARGS): Pass FNDECL, VOIDmode.
>        (INIT_CUMULATIVE_INCOMING_ARGS): Pass current_function_decl, VOIDmode.
>        (INIT_CUMULATIVE_LIBCALL_ARGS): Pass NULL_TREE, MODE.
>        * config/rs6000/rs6000.c
>        (rs6000_elf_end_indicate_exec_stack): Rename to..
>        (rs6000_elf_file_end): ..this.  Only call file_end_indicate_exec_stack
>        for POWERPC_LINUX.  Move code emitting .gnu_attribute to here, from..
>        (rs6000_file_start): ..here.
>        (rs6000_passes_float, rs6000_passes_vector, rs6000_returns_struct): New
>        file scope variables.
>        (call_ABI_of_interest): New function.
>        (init_cumulative_args): Set above vars when function return value
>        is a float, vector, or small struct.
>        (rs6000_function_arg_advance_1): Likewise for function args.
>        (rs6000_va_start): Set rs6000_passes_float if variable arg function
>        references float args.

Okay.

Thanks, David


[RFA] libiberty/make-relative-prefix.c, save_string, use xmalloc over malloc

2011-03-06 Thread Michael Snyder

I know the callers of save_string check its return value for null, but
by then it's too late -- we've memcpy'd over a null pointer.

OK?

2011-03-06  Michael Snyder  

* make-relative-prefix.c (save_string): Use xmalloc over malloc.

Index: make-relative-prefix.c
===
RCS file: /cvs/src/src/libiberty/make-relative-prefix.c,v
retrieving revision 1.13
diff -u -p -r1.13 make-relative-prefix.c
--- make-relative-prefix.c  3 Feb 2011 07:23:59 -   1.13
+++ make-relative-prefix.c  6 Mar 2011 23:25:35 -
@@ -103,7 +103,7 @@ static void free_split_directories (char
 static char *
 save_string (const char *s, int len)
 {
-  char *result = (char *) malloc (len + 1);
+  char *result = (char *) xmalloc (len + 1);
 
   memcpy (result, s, len);
   result[len] = 0;


Re: PATCH: Remove README.QMTEST

2011-03-06 Thread Mark Mitchell
On 3/6/2011 2:57 PM, Mike Stump wrote:

>> It was recently pointed out to me that we still have the
>> README.QMTEST file in gcc/testsuite. That file talks about how to
>> use QMTest instead of DejaGNU to test G++

> If you were to summarize the 3 most compelling features provided, I'd
> be interested.  I'm thinking it was parallel testing...

That's one.  A couple of others:

(a) QMTest is a structured system, i.e., you can enumerate all of the
tests and ask questions about them.  In contrast, with DejaGNU, you can
only figure out what tests you have by running them -- we depend on
executable .exp files to enumerate tests, not declarative information.
For example, try asking DejaGNU "how many tests do I have?", or "how
many tests do I have for Solaris targets that aren't applicable to Linux
targets?"

(b) QMTest has a facility for saving results in structured formats
(rather than text-based .log/.sum files) so that they can be processed
or queried later.  One immediate use of this is that you can compare
results today with results yesterday in ways more structured that "diff".

Thank you,

-- 
Mark Mitchell
CodeSourcery
m...@codesourcery.com
(650) 331-3385 x713


Re: PATCH: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *)

2011-03-06 Thread H.J. Lu
On Sun, Mar 6, 2011 at 3:23 PM, Richard Guenther
 wrote:
> On Sun, Mar 6, 2011 at 10:28 PM, H.J. Lu  wrote:
>> On Sun, Mar 6, 2011 at 1:15 PM, Andrew Pinski  wrote:
>>> On Sun, Mar 6, 2011 at 9:18 AM, H.J. Lu  wrote:
 Hi,

 We shouldn't save call frame hard registers as "void *".  This patch
 changes the unwind library to save call frame hard registers as
 _Unwind_Word.  OK for 4.7?
>>>
>>> I think this will break the ABI for the MIPS N32 ABI.  Not to mention
>>> the MIPS N32 ABI works fine with the unwinding part this way.  Does
>>> someone use the unwinding library to look at the registers in previous
>>> stack frames?
>>
>> It may be psABI/implementation specific.  X32 glibc force unwind calls
>> _Unwind_SetGRValue to get a 64bit register value.
>
> So fix it on that side?
>

How? One function in question is

/* Overwrite the saved value for register INDEX in CONTEXT with VAL.  */

static inline void
_Unwind_SetGRValue (struct _Unwind_Context *context, int index,
_Unwind_Word val)


Are you saying it shouldn't be called if UNITS_PER_WORD > sizeof (void *)?

-- 
H.J.


Re: Harden rs6000 offsettable_ok_by_alignment

2011-03-06 Thread David Edelsohn
Isn't this too conservative?  Shouldn't CONSTANT_ALIGNMENT increase
the alignment of STRING_CST to word-aligned?  The only problem is
structs?

- David

On Wed, Mar 2, 2011 at 2:34 AM, Alan Modra  wrote:
> Prior to a fix I committed recently on the gcc-4.5-ibm branch, we used
> to fail with a linker error: "relocation R_PPC64_TOC16_LO_DS not a
> multiple of 4" on code loading the "md_backup_data-1" string in the
> following testcase.
>
> typedef __signed__ char __s8;
> typedef unsigned char __u8;
> typedef __signed__ short __s16;
> typedef unsigned short __u16;
> typedef __signed__ int __s32;
> typedef unsigned int __u32;
> typedef __signed__ long __s64;
> typedef unsigned long __u64;
>
> static struct mdp_backup_super {
>  char magic[16];
>  __u8 set_uuid[16];
>  __u64 mtime;
>
>  __u64 devstart;
>  __u64 arraystart;
>  __u64 length;
>  __u32 sb_csum;
>  __u32 pad1;
>  __u64 devstart2;
>  __u64 arraystart2;
>  __u64 length2;
>  __u32 sb_csum2;
>  __u8 pad[512-68-32];
> } __attribute__((aligned(512))) bsb;
>
> void f (void)
> {
>  __builtin_memcpy (bsb.magic, "md_backup_data-1", 16);
> }
>
> The memcpy gets optimised to two ld insns followed by two std insns,
> with both the address of bsb and the string being toc-relative.
> bsb.magic is sufficiently aligned for the stores to be OK, but the
> string is not aligned at all;  The loads may well be at an address
> that is not a multiple of four.  It is also quite possible for the
> string to straddle a 32k boundary, resulting in rubbish being loaded
> in the second dword.
>
> On mainline, the situation is a little different due to changes in
> memref handling.  I seem to always get a VAR_DECL for the string,
> correctly reporting an alignment of one, so we don't use the invalid
> toc-relative address.  ie. I can't find a testcase for this potential
> problem on mainline.  What worries me is that this may simply be due
> to not trying enough compiler options.  Also, future changes in gcc
> might result in STRING_CST trees appearing as they do on 4.5.  So I'd
> like to apply the following patch.  Bootstrapped etc. powerpc64-linux.
> OK?
>
>        * config/rs6000/rs6000.c (offsettable_ok_by_alignment): Ensure
>        STRING_CST returns false.  Add assert.
>
> Index: gcc/config/rs6000/rs6000.c
> ===
> --- gcc/config/rs6000/rs6000.c  (revision 170373)
> +++ gcc/config/rs6000/rs6000.c  (working copy)
> @@ -7301,12 +7301,14 @@ offsettable_ok_by_alignment (tree decl)
>   if (!decl)
>     return true;
>
> -  if (TREE_CODE (decl) != VAR_DECL
> -      && TREE_CODE (decl) != PARM_DECL
> -      && TREE_CODE (decl) != RESULT_DECL
> -      && TREE_CODE (decl) != FIELD_DECL)
> +  if (TREE_CODE (decl) == FUNCTION_DECL)
>     return true;
>
> +  if (CONSTANT_CLASS_P (decl))
> +    return TREE_CODE (decl) != STRING_CST;
> +
> +  gcc_assert (DECL_P (decl));
> +
>   if (!DECL_SIZE_UNIT (decl))
>     return false;
>
>
> --
> Alan Modra
> Australia Development Lab, IBM
>


Re: PATCH: PR other/48007: Unwind library doesn't work with UNITS_PER_WORD > sizeof (void *)

2011-03-06 Thread H.J. Lu
On Sun, Mar 6, 2011 at 3:40 PM, H.J. Lu  wrote:
> On Sun, Mar 6, 2011 at 3:23 PM, Richard Guenther
>  wrote:
>> On Sun, Mar 6, 2011 at 10:28 PM, H.J. Lu  wrote:
>>> On Sun, Mar 6, 2011 at 1:15 PM, Andrew Pinski  wrote:
 On Sun, Mar 6, 2011 at 9:18 AM, H.J. Lu  wrote:
> Hi,
>
> We shouldn't save call frame hard registers as "void *".  This patch
> changes the unwind library to save call frame hard registers as
> _Unwind_Word.  OK for 4.7?

 I think this will break the ABI for the MIPS N32 ABI.  Not to mention
 the MIPS N32 ABI works fine with the unwinding part this way.  Does
 someone use the unwinding library to look at the registers in previous
 stack frames?
>>>
>>> It may be psABI/implementation specific.  X32 glibc force unwind calls
>>> _Unwind_SetGRValue to get a 64bit register value.
>>
>> So fix it on that side?
>>
>
> How? One function in question is
>
> /* Overwrite the saved value for register INDEX in CONTEXT with VAL.  */
>
> static inline void
> _Unwind_SetGRValue (struct _Unwind_Context *context, int index,
>                    _Unwind_Word val)
>
>
> Are you saying it shouldn't be called if UNITS_PER_WORD > sizeof (void *)?
>

FWIW, the type of GR is _Unwind_Word, not void *.  They may not
have the same size.  Why does the DWARF unwind library use
void * to store GR? Can a target have an option to save a _Unwind_Word
value in _Unwind_Word, instead of void *?

Thanks.

-- 
H.J.


Re: [RFA] libiberty/hashtab.c, higher_prime_index: avoid array overrun

2011-03-06 Thread Michael Snyder

DJ Delorie wrote:

Bizzare, the problem isn't the hash loop, it's the error handler at
the end!  It never uses [30] for the main loop, only if you give it a
number between 0xfffb and 0x - and in the case where it
would use [30], it's supposed to abort anyway.

I couldn't figure out why your patch worked until I realized that the
main loop still fails!  It works because the error handler just
doesn't abort, returning the last array entry, which happens to be the
right one.

I think a suitable comment explaining what's actually going on, and
why it still works, is warranted... but your patch is OK with me
otherwise :-)


Please give me the comment, and I'll check it in.




[4.7] Avoid global state in mn10300_handle_option

2011-03-06 Thread Joseph S. Myers
This patch, for 4.7 and relative to a tree with
 applied,
stops the MN10300 handle_option hook from using global state.  The
-mtune= option, taking a string argument and storing it in a string
variable, is made to use Var to store the string rather than ad hoc
handler code.  (This option actually takes enumerated arguments, but
they are handled in mn10300_option_override, and conversion of
TARGET_OPTION_OVERRIDE hooks will be a later patch series.  These
particular enumerated arguments, like some for MIPS and RX, are
case-insensitive, which will require a new target-independent .opt
feature to handle such enumerated arguments through .opt files.)

Tested building cc1 and xgcc for cross to mn10300-elf.  Will commit to
trunk for 4.7 in the absence of target maintainer objections.

2011-03-06  Joseph Myers  

* config/mn10300/mn10300-opts.h: New.
* config/mn10300/mn10300.c (mn10300_processor,
mn10300_tune_string): Remove.
(mn10300_handle_option): Don't assert that global structures are
in use.  Access mn10300_processor via opts pointer.  Don't handle
OPT_mtune_ here.
* config/mn10300/mn10300.h (enum processor_type): Move to
mn10300-opts.h.
(mn10300_processor): Remove.
* config/mn10300/mn10300.opt (config/mn10300/mn10300-opts.h): New
HeaderInclude entry.
(mn10300_processor): New Variable entry.
(mtune=): Use Var.

diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/mn10300/mn10300-opts.h 
gcc-mainline/gcc/config/mn10300/mn10300-opts.h
--- gcc-mainline-1/gcc/config/mn10300/mn10300-opts.h1969-12-31 
16:00:00.0 -0800
+++ gcc-mainline/gcc/config/mn10300/mn10300-opts.h  2011-03-06 
09:08:22.0 -0800
@@ -0,0 +1,32 @@
+/* Definitions for option handling for Matsushita MN10300 series.
+   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+   2007, 2008, 2009, 2010, 2011 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
+   .  */
+
+#ifndef MN10300_OPTS_H
+#define MN10300_OPTS_H
+
+enum processor_type
+{
+  PROCESSOR_MN10300,
+  PROCESSOR_AM33,
+  PROCESSOR_AM33_2,
+  PROCESSOR_AM34
+};
+
+#endif
diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/mn10300/mn10300.c 
gcc-mainline/gcc/config/mn10300/mn10300.c
--- gcc-mainline-1/gcc/config/mn10300/mn10300.c 2011-02-23 18:41:54.0 
-0800
+++ gcc-mainline/gcc/config/mn10300/mn10300.c   2011-03-06 09:09:40.0 
-0800
@@ -52,12 +52,6 @@
symbol names from register names.  */
 int mn10300_protect_label;
 
-/* The selected processor.  */
-enum processor_type mn10300_processor = PROCESSOR_DEFAULT;
-
-/* Processor type to select for tuning.  */
-static const char * mn10300_tune_string = NULL;
-
 /* Selected processor type for tuning.  */
 enum processor_type mn10300_tune_cpu = PROCESSOR_DEFAULT;
 
@@ -91,35 +85,28 @@ static int cc_flags_for_code(enum rtx_co
 /* Implement TARGET_HANDLE_OPTION.  */
 
 static bool
-mn10300_handle_option (struct gcc_options *opts, struct gcc_options *opts_set,
+mn10300_handle_option (struct gcc_options *opts,
+  struct gcc_options *opts_set ATTRIBUTE_UNUSED,
   const struct cl_decoded_option *decoded,
   location_t loc ATTRIBUTE_UNUSED)
 {
   size_t code = decoded->opt_index;
-  const char *arg = decoded->arg;
   int value = decoded->value;
 
-  gcc_assert (opts == &global_options);
-  gcc_assert (opts_set == &global_options_set);
-
   switch (code)
 {
 case OPT_mam33:
-  mn10300_processor = value ? PROCESSOR_AM33 : PROCESSOR_MN10300;
+  opts->x_mn10300_processor = value ? PROCESSOR_AM33 : PROCESSOR_MN10300;
   return true;
 
 case OPT_mam33_2:
-  mn10300_processor = (value
-  ? PROCESSOR_AM33_2
-  : MIN (PROCESSOR_AM33, PROCESSOR_DEFAULT));
+  opts->x_mn10300_processor = (value
+  ? PROCESSOR_AM33_2
+  : MIN (PROCESSOR_AM33, PROCESSOR_DEFAULT));
   return true;
 
 case OPT_mam34:
-  mn10300_processor = (value ? PROCESSOR_AM34 : PROCESSOR_DEFAULT);
-  return true;
-
-case OPT_mtune_:
-  mn10300_tune_string = arg;
+  opts->x_mn10300_processor = (value ? PROCESSOR_AM34 :

[4.7] Avoid global state in pa_handle_option

2011-03-06 Thread Joseph S. Myers
This patch, for 4.7 and relative to a tree with
 applied,
stops the PA handle_option hook from using global state.  The -munix=
options are converted to use Var in the .opt files, -mschedule= is
made to use the Enum facility, and -mfixed-range= is deferred to
pa_option_override as in the IA64 patch.

Tested building cc1 and xgcc for cross to hppa2.0w-hp-hpux11.23.  Will
commit to trunk for 4.7 in the absence of target maintainer
objections.

2011-03-06  Joseph Myers  

* config/pa/pa-hpux.opt (flag_pa_unix): New Variable entry.
(munix=93): Use Var.
* config/pa/pa-hpux1010.opt (munix=95): Use Var.
* config/pa/pa-hpux.opt (munix=98): Use Var.
* config/pa/pa-opts.h: New.
* config/pa/pa.c (pa_cpu, flag_pa_unix): Remove.
(pa_handle_option): Don't assert that global structures are in
use.  Access target_flags via opts pointer.  Don't handle
OPT_mschedule_, OPT_mfixed_range_, OPT_munix_93, OPT_munix_95 or
OPT_munix_98 here.
(pa_option_override): Handle deferred OPT_mfixed_range_.

diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/pa/pa-hpux.opt 
gcc-mainline/gcc/config/pa/pa-hpux.opt
--- gcc-mainline-1/gcc/config/pa/pa-hpux.opt2011-02-04 15:18:52.0 
-0800
+++ gcc-mainline/gcc/config/pa/pa-hpux.opt  2011-03-06 09:37:23.0 
-0800
@@ -18,12 +18,16 @@
 ; along with GCC; see the file COPYING3.  If not see
 ; .
 
+; The UNIX standard to use for predefines and linking.
+Variable
+int flag_pa_unix = TARGET_HPUX_11_11 ? 1998 : TARGET_HPUX_10_10 ? 1995 : 1993
+
 msio
 Target RejectNegative Mask(SIO) MaskExists
 Generate cpp defines for server IO
 
 munix=93
-Target RejectNegative
+Target RejectNegative Var(flag_pa_unix, 1993)
 Specify UNIX standard for predefines and linking
 
 mwsio
diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/pa/pa-hpux1010.opt 
gcc-mainline/gcc/config/pa/pa-hpux1010.opt
--- gcc-mainline-1/gcc/config/pa/pa-hpux1010.opt2009-03-28 
00:38:47.0 -0700
+++ gcc-mainline/gcc/config/pa/pa-hpux1010.opt  2011-03-06 09:38:04.0 
-0800
@@ -1,6 +1,6 @@
 ; Options for the HP PA-RISC port of the compiler.
 
-; Copyright (C) 2005, 2007 Free Software Foundation, Inc.
+; Copyright (C) 2005, 2007, 2011 Free Software Foundation, Inc.
 ;
 ; This file is part of GCC.
 ;
@@ -19,5 +19,5 @@
 ; .
 
 munix=95
-Target RejectNegative
+Target RejectNegative Var(flag_pa_unix, 1995)
 Specify UNIX standard for predefines and linking
diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/pa/pa-hpux.opt 
gcc-mainline/gcc/config/pa/pa-hpux.opt
--- gcc-mainline-1/gcc/config/pa/pa-hpux.opt2009-03-28 
00:38:47.0 -0700
+++ gcc-mainline/gcc/config/pa/pa-hpux.opt  2011-03-06 09:38:24.0 
-0800
@@ -1,6 +1,6 @@
 ; Options for the HP PA-RISC port of the compiler.
 
-; Copyright (C) 2005, 2007 Free Software Foundation, Inc.
+; Copyright (C) 2005, 2007, 2011 Free Software Foundation, Inc.
 ;
 ; This file is part of GCC.
 ;
@@ -19,5 +19,5 @@
 ; .
 
 munix=98
-Target RejectNegative
+Target RejectNegative Var(flag_pa_unix, 1998)
 Specify UNIX standard for predefines and linking
diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/pa/pa-opts.h 
gcc-mainline/gcc/config/pa/pa-opts.h
--- gcc-mainline-1/gcc/config/pa/pa-opts.h  1969-12-31 16:00:00.0 
-0800
+++ gcc-mainline/gcc/config/pa/pa-opts.h2011-03-06 10:05:13.0 
-0800
@@ -0,0 +1,37 @@
+/* Definitions for option handling for HP PA.
+   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+   2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
+   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
+.  */
+
+#ifndef PA_OPTS_H
+#define PA_OPTS_H
+
+/* Which processor to schedule for.  */
+
+enum processor_type
+{
+  PROCESSOR_700,
+  PROCESSOR_7100,
+  PROCESSOR_7100LC,
+  PROCESSOR_7200,
+  PROCESSOR_7300,
+  PROCESSOR_8000
+};
+
+#endif
diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/pa/pa.c 
gcc-mainline/gcc/config/pa/pa.c
--- gcc-mainline-1/gcc/config/pa/pa.c   2011-02-24 07:39:41.0 -0800
+++ gcc-mainline/gcc/config/pa/pa.c 2011-03-06 10:34:36.0 -0800
@@ -193,12 +193,6 @@ static GTY(()) section *som_r

[4.7] Avoid global state in sh_handle_option

2011-03-06 Thread Joseph S. Myers
This patch, for 4.7 and relative to a tree with
 applied,
stops the SH handle_option hook from using global state.

Tested building cc1 and xgcc for cross to sh-elf.  Will commit to
trunk for 4.7 in the absence of target maintainer objections.

2011-03-06  Joseph Myers  

* config/sh/sh.c (sh_handle_option): Access target_flags via opts
pointer.  Don't assert that global structures are in use.

diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/sh/sh.c 
gcc-mainline/gcc/config/sh/sh.c
--- gcc-mainline-1/gcc/config/sh/sh.c   2011-02-24 13:21:35.0 -0800
+++ gcc-mainline/gcc/config/sh/sh.c 2011-03-06 17:33:18.0 -0800
@@ -619,58 +619,59 @@ struct gcc_target targetm = TARGET_INITI
 /* Implement TARGET_HANDLE_OPTION.  */
 
 static bool
-sh_handle_option (struct gcc_options *opts, struct gcc_options *opts_set,
+sh_handle_option (struct gcc_options *opts,
+ struct gcc_options *opts_set ATTRIBUTE_UNUSED,
  const struct cl_decoded_option *decoded,
  location_t loc ATTRIBUTE_UNUSED)
 {
   size_t code = decoded->opt_index;
 
-  gcc_assert (opts == &global_options);
-  gcc_assert (opts_set == &global_options_set);
-
   switch (code)
 {
 case OPT_m1:
-  target_flags = (target_flags & ~MASK_ARCH) | SELECT_SH1;
+  opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH1;
   return true;
 
 case OPT_m2:
-  target_flags = (target_flags & ~MASK_ARCH) | SELECT_SH2;
+  opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2;
   return true;
 
 case OPT_m2a:
-  target_flags = (target_flags & ~MASK_ARCH) | SELECT_SH2A;
+  opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2A;
   return true;
 
 case OPT_m2a_nofpu:
-  target_flags = (target_flags & ~MASK_ARCH) | SELECT_SH2A_NOFPU;
+  opts->x_target_flags
+   = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2A_NOFPU;
   return true;
 
 case OPT_m2a_single:
-  target_flags = (target_flags & ~MASK_ARCH) | SELECT_SH2A_SINGLE;
+  opts->x_target_flags
+   = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2A_SINGLE;
   return true;
 
 case OPT_m2a_single_only:
-  target_flags = (target_flags & ~MASK_ARCH) | SELECT_SH2A_SINGLE_ONLY;
+  opts->x_target_flags
+   = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2A_SINGLE_ONLY;
   return true;
 
 case OPT_m2e:
-  target_flags = (target_flags & ~MASK_ARCH) | SELECT_SH2E;
+  opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH2E;
   return true;
 
 case OPT_m3:
-  target_flags = (target_flags & ~MASK_ARCH) | SELECT_SH3;
+  opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH3;
   return true;
 
 case OPT_m3e:
-  target_flags = (target_flags & ~MASK_ARCH) | SELECT_SH3E;
+  opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH3E;
   return true;
 
 case OPT_m4:
 case OPT_m4_100:
 case OPT_m4_200:
 case OPT_m4_300:
-  target_flags = (target_flags & ~MASK_ARCH) | SELECT_SH4;
+  opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4;
   return true;
 
 case OPT_m4_nofpu:
@@ -680,62 +681,74 @@ sh_handle_option (struct gcc_options *op
 case OPT_m4_340:
 case OPT_m4_400:
 case OPT_m4_500:
-  target_flags = (target_flags & ~MASK_ARCH) | SELECT_SH4_NOFPU;
+  opts->x_target_flags
+   = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4_NOFPU;
   return true;
 
 case OPT_m4_single:
 case OPT_m4_100_single:
 case OPT_m4_200_single:
 case OPT_m4_300_single:
-  target_flags = (target_flags & ~MASK_ARCH) | SELECT_SH4_SINGLE;
+  opts->x_target_flags
+   = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4_SINGLE;
   return true;
 
 case OPT_m4_single_only:
 case OPT_m4_100_single_only:
 case OPT_m4_200_single_only:
 case OPT_m4_300_single_only:
-  target_flags = (target_flags & ~MASK_ARCH) | SELECT_SH4_SINGLE_ONLY;
+  opts->x_target_flags
+   = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4_SINGLE_ONLY;
   return true;
 
 case OPT_m4a:
-  target_flags = (target_flags & ~MASK_ARCH) | SELECT_SH4A;
+  opts->x_target_flags = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4A;
   return true;
 
 case OPT_m4a_nofpu:
 case OPT_m4al:
-  target_flags = (target_flags & ~MASK_ARCH) | SELECT_SH4A_NOFPU;
+  opts->x_target_flags
+   = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4A_NOFPU;
   return true;
 
 case OPT_m4a_single:
-  target_flags = (target_flags & ~MASK_ARCH) | SELECT_SH4A_SINGLE;
+  opts->x_target_flags
+   = (opts->x_target_flags & ~MASK_ARCH) | SELECT_SH4A_SINGLE;
   return true;
 
 case OPT_m4a_single_only:
-  target_flags = (target_flags & ~MASK_ARCH) | S

[4.7] Avoid global state in pdp11_handle_option

2011-03-06 Thread Joseph S. Myers
This patch, for 4.7 and relative to a tree with
 applied,
stops the pdp11 handle_option hook from using global state.

Tested building cc1 and xgcc for cross to pdp11-none.  Will commit to
trunk for 4.7 in the absence of target maintainer objections.

2011-03-06  Joseph Myers  

* config/pdp11/pdp11.c (pdp11_handle_option): Access target_flags
via opts pointer.  Don't assert that global structures are in use.

diff -rupN --exclude=.svn gcc-mainline-1/gcc/config/pdp11/pdp11.c 
gcc-mainline/gcc/config/pdp11/pdp11.c
--- gcc-mainline-1/gcc/config/pdp11/pdp11.c 2011-02-24 08:08:11.0 
-0800
+++ gcc-mainline/gcc/config/pdp11/pdp11.c   2011-03-06 17:07:03.0 
-0800
@@ -247,19 +247,17 @@ static const struct default_options pdp1
 /* Implement TARGET_HANDLE_OPTION.  */
 
 static bool
-pdp11_handle_option (struct gcc_options *opts, struct gcc_options *opts_set,
+pdp11_handle_option (struct gcc_options *opts,
+struct gcc_options *opts_set ATTRIBUTE_UNUSED,
 const struct cl_decoded_option *decoded,
 location_t loc ATTRIBUTE_UNUSED)
 {
   size_t code = decoded->opt_index;
 
-  gcc_assert (opts == &global_options);
-  gcc_assert (opts_set == &global_options_set);
-
   switch (code)
 {
 case OPT_m10:
-  target_flags &= ~(MASK_40 | MASK_45);
+  opts->x_target_flags &= ~(MASK_40 | MASK_45);
   return true;
 
 default:

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


Re: [4.7] Avoid global state in pdp11_handle_option

2011-03-06 Thread Paul Koning

On Mar 6, 2011, at 8:59 PM, Joseph S. Myers wrote:

> This patch, for 4.7 and relative to a tree with
>  applied,
> stops the pdp11 handle_option hook from using global state.
> 
> Tested building cc1 and xgcc for cross to pdp11-none.  Will commit to
> trunk for 4.7 in the absence of target maintainer objections.
> ...

Looks good.  Thanks Joseph.

paul




Re: [4.7] Avoid global state in pa_handle_option

2011-03-06 Thread John David Anglin
> Tested building cc1 and xgcc for cross to hppa2.0w-hp-hpux11.23.  Will
> commit to trunk for 4.7 in the absence of target maintainer
> objections.
> 
> 2011-03-06  Joseph Myers  
> 
>   * config/pa/pa-hpux.opt (flag_pa_unix): New Variable entry.
>   (munix=93): Use Var.
>   * config/pa/pa-hpux1010.opt (munix=95): Use Var.
>   * config/pa/pa-hpux.opt (munix=98): Use Var.
>   * config/pa/pa-opts.h: New.
>   * config/pa/pa.c (pa_cpu, flag_pa_unix): Remove.
>   (pa_handle_option): Don't assert that global structures are in
>   use.  Access target_flags via opts pointer.  Don't handle
>   OPT_mschedule_, OPT_mfixed_range_, OPT_munix_93, OPT_munix_95 or
>   OPT_munix_98 here.
>   (pa_option_override): Handle deferred OPT_mfixed_range_.

Looks good.

Dave
-- 
J. David Anglin  dave.ang...@nrc-cnrc.gc.ca
National Research Council of Canada  (613) 990-0752 (FAX: 952-6602)


Re: [doc, PATCH] Remove redundant word "See" before @xref

2011-03-06 Thread Mingjie Xing
2011/3/4 Gerald Pfeifer :
> On Thu, 3 Mar 2011, Mingjie Xing wrote:
>> 2011-03-03  Mingjie Xing  
>>
>>         * doc/cfg.texi: Remove "See" before @ref.
>>         * doc/invoke.texi: Likewise.
>
> This is fine, thank you.  If you want to apply this to the GCC 4.5
> branch as well, that's fine, too.
>
> Gerald
>

Committed revision 170730, and 4.5 branch revision 170729.

Thanks,
Mingjie


Ping Re: [doc, PATCH] Update the description about ENTRY_BLOCK_PTR and EXIT_BLOCK_PTR

2011-03-06 Thread Mingjie Xing
2011/2/25 Mingjie Xing :
> Hi,
>
> This patch updates the description about ENTRY_BLOCK_PTR and
> EXIT_BLOCK_PTR, since their index numbers are no longer negative now.
>
> Is it OK?
>
> Thanks,
> Mingjie
>
> ChangeLog,
> 2011-02-25  Mingjie Xing  
>
>        * doc/cfg.texi (ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR): Update the
>        description about their index numbers.
>
>
> Index: doc/cfg.texi
> ===
> --- doc/cfg.texi        (revision 170165)
> +++ doc/cfg.texi        (working copy)
> @@ -67,8 +67,8 @@ blocks.  The index for any block should
>  Special basic blocks represent possible entry and exit points of a
>  function.  These blocks are called @code{ENTRY_BLOCK_PTR} and
>  @code{EXIT_BLOCK_PTR}.  These blocks do not contain any code, and are
> -not elements of the @code{BASIC_BLOCK} array.  Therefore they have
> -been assigned unique, negative index numbers.
> +always in the CFG.  They are assigned unique index numbers 0 and 1
> +respectively.  Therefore @code{NUM_FIXED_BLOCKS} are 2.
>
>  Each @code{basic_block} also contains pointers to the first
>  instruction (the @dfn{head}) and the last instruction (the @dfn{tail})
>

Ping.


Re: Harden rs6000 offsettable_ok_by_alignment

2011-03-06 Thread Alan Modra
On Sun, Mar 06, 2011 at 07:01:44PM -0500, David Edelsohn wrote:
> Isn't this too conservative?  Shouldn't CONSTANT_ALIGNMENT increase
> the alignment of STRING_CST to word-aligned?

Yes and yes.  Thanks for the correction.  I'll update the patch.

> The only problem is structs?

No, I don't think there is anything special about the struct, just
that it was aligned more that usual.

-- 
Alan Modra
Australia Development Lab, IBM