Re: [4.7][google] Adding a new option -fstack-protector-strong. (issue5461043)

2011-12-08 Thread Richard Guenther
On Thu, Dec 8, 2011 at 2:19 AM, Andrew Pinski  wrote:
> On Wed, Dec 7, 2011 at 5:07 PM, Han Shen  wrote:
>> +  /* Examine each basic block for address taking of local variables. */
>
> I don't think you need to look at the basic blocks to figure out if a
> local variable has its address taken.  You can look through referenced
> variables and see if it is a local variable and TREE_ADDRESSABLE is
> set.  This should speed up the code a lot.  Though that might has some
> false positives with arrays but that is ok because you are checking if
> there are any arrays already anyways.

Indeed.

Also your patch does not adhere to the GCC coding standards.
For example all functions need toplevel comments documenting
their purpose and their parameters.

Richard.

> Thanks,
> Andrew Pinski


Re: [PATCH][LTO] Fix PR48437

2011-12-08 Thread Richard Guenther
On Wed, 7 Dec 2011, Diego Novillo wrote:

> On Wed, Dec 7, 2011 at 11:16, Richard Guenther  wrote:
> 
> > I'm going to apply it tomorrow, when full testing hopefully finished
> 
> Sure.  But remember the zombie kitties!

I have applied the fix for PR48437, the fix for PR49945 required
adjustment as otherwise we'd ICE gcc.dg/lto/20090706-1_0.c in
the type checker.  We also have to localize FIELD_DECLs of variable
size types.

Thus I'm re-testing the following and will commit that variant if it
succeeds.

I suppose at some point we need to look at the efficiency of
the variably_modified_type_p call, as tree_is_indexable is
called for each component type and variably_modified_type_p
recurses itself (thus, overall this is quadratic, but with
cheap constant factor as we are calling it with a NULL function arg).

Richard.

2011-12-08  Richard Guenther  

PR lto/49945
* lto-streamer-out.c (tree_is_indexable): Localize variably
modified types and their FIELD_DECLs.

Index: gcc/lto-streamer-out.c
===
--- gcc/lto-streamer-out.c  (revision 182101)
+++ gcc/lto-streamer-out.c  (working copy)
@@ -139,6 +139,16 @@ tree_is_indexable (tree t)
   && DECL_CONTEXT (t)
   && TREE_CODE (DECL_CONTEXT (t)) == FUNCTION_DECL)
 return false;
+  /* Variably modified types need to be streamed alongside function
+ bodies because they can refer to local entities.  Together with
+ them we have to localize their members as well.
+ ???  In theory that includes non-FIELD_DECLs as well.  */
+  else if (TYPE_P (t)
+  && variably_modified_type_p (t, NULL_TREE))
+return false;
+  else if (TREE_CODE (t) == FIELD_DECL
+  && variably_modified_type_p (DECL_CONTEXT (t), NULL_TREE))
+return false;
   else
 return (TYPE_P (t) || DECL_P (t) || TREE_CODE (t) == SSA_NAME);
 }



Re: [v3] RFC: rename __calculate_memory_order

2011-12-08 Thread Jonathan Wakely
On 7 December 2011 23:58, Benjamin Kosnik wrote:
>
>>         * include/bits/atomic_base.h (__calculate_memory_order):
>> Rename to... (__cmpexch_failure_order): This, and rewrite as
>> constexpr function. (compare_exchange_strong, compare_exchange_weak):
>> Use it.
>>         * include/std/atomic (compare_exchange_strong,
>> compare_exchange_weak): Likewise.
>>
>> Tested x86_64-linux.
>
> looks great to me. More constexpr, what's not to like?

OK, thanks - I checked it in.


[C++ Patch] PR 51464

2011-12-08 Thread Paolo Carlini

Hi,

here I'm just handling error_mark_nodes after the error messages: I 
think the robustification is sensible because begin_class_definition can 
certainly return error_mark_node in general and sooner or later Volker 
will find testcases producing more ;)


However, from the user point of view, it could be argued that typing the 
below isn't *really* normal when coding with lambdas, in principle the 
error messages preceding the ICE could be completely different and still 
make sense...


Tested x86_64-linux.

Thanks,
Paolo.

/
/cp
2011-12-08  Paolo Carlini  

PR c++/51464
* semantics.c (begin_lambda_type): Check begin_class_definition return
value for error_mark_node.
* parser.c (cp_parser_lambda_expression): Check begin_lambda_type
return value for error_mark_node.

/testsuite
2011-12-08  Paolo Carlini  

PR c++/51464
* g++.dg/cpp0x/lambda/lambda-ice6.C: New.
Index: testsuite/g++.dg/cpp0x/lambda/lambda-ice6.C
===
--- testsuite/g++.dg/cpp0x/lambda/lambda-ice6.C (revision 0)
+++ testsuite/g++.dg/cpp0x/lambda/lambda-ice6.C (revision 0)
@@ -0,0 +1,4 @@
+// PR c++/51464
+// { dg-options "-std=c++0x" }
+
+template struct A {}; // { dg-error "lambda" } 
Index: cp/semantics.c
===
--- cp/semantics.c  (revision 182106)
+++ cp/semantics.c  (working copy)
@@ -8603,6 +8603,8 @@ begin_lambda_type (tree lambda)
 
   /* Start the class.  */
   type = begin_class_definition (type, /*attributes=*/NULL_TREE);
+  if (type == error_mark_node)
+return error_mark_node;
 
   /* Cross-reference the expression and the type.  */
   LAMBDA_EXPR_CLOSURE (lambda) = type;
Index: cp/parser.c
===
--- cp/parser.c (revision 182106)
+++ cp/parser.c (working copy)
@@ -8033,6 +8033,8 @@ cp_parser_lambda_expression (cp_parser* parser)
   cp_parser_lambda_introducer (parser, lambda_expr);
 
   type = begin_lambda_type (lambda_expr);
+  if (type == error_mark_node)
+return error_mark_node;
 
   record_lambda_scope (lambda_expr);
 


[PATCH] Fix PR50747

2011-12-08 Thread Richard Guenther

The asserts added in rev. 179429 are too strict as shown by the testcases
in PR50747 (triggering both asserts individually).  The following
patch simply removes them instead of trying to massage it.

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

Richard.

2011-12-08  Richard Guenther  

PR lto/50747
* lto-streamer-out.c (produce_symtab): Remove asserts.

* g++.dg/opt/pr50747-1_0.C: New testcase.
* g++.dg/opt/pr50747-2_0.C: Likewise.

Index: gcc/lto-streamer-out.c
===
--- gcc/lto-streamer-out.c  (revision 182107)
+++ gcc/lto-streamer-out.c  (working copy)
@@ -1450,11 +1450,7 @@ produce_symtab (struct output_block *ob,
 them indirectly or via vtables.  Do not output them to symbol
 table: they end up being undefined and just consume space.  */
   if (!node->address_taken && !node->callers)
-   {
- gcc_assert (node->analyzed);
- gcc_assert (DECL_DECLARED_INLINE_P (node->decl));
- continue;
-   }
+   continue;
   if (DECL_COMDAT (node->decl)
  && cgraph_comdat_can_be_unshared_p (node))
continue;
Index: gcc/testsuite/g++.dg/opt/pr50747-1_0.C
===
--- gcc/testsuite/g++.dg/opt/pr50747-1_0.C  (revision 0)
+++ gcc/testsuite/g++.dg/opt/pr50747-1_0.C  (revision 0)
@@ -0,0 +1,18 @@
+// { dg-do compile }
+// { dg-require-effective-target lto }
+// { dg-options "-flto" }
+
+void foo();
+
+static void bar() __attribute__((weakref("foo")));
+
+struct A
+{
+A();
+};
+
+int i;
+
+template  struct B : T {};
+
+B b;
Index: gcc/testsuite/g++.dg/opt/pr50747-2_0.C
===
--- gcc/testsuite/g++.dg/opt/pr50747-2_0.C  (revision 0)
+++ gcc/testsuite/g++.dg/opt/pr50747-2_0.C  (revision 0)
@@ -0,0 +1,112 @@
+// { dg-do compile }
+// { dg-require-effective-target lto }
+// { dg-options "-w -fpermissive -fno-implicit-templates -flto" }
+
+namespace std {
+typedef long unsigned int size_t;
+template class allocator;
+template struct char_traits;
+template > 
class basic_ostream;
+template, 
typename _Alloc = allocator<_CharT> > class basic_ostringstream;
+}
+extern "C++" {
+namespace std {
+   class exception   {
+   };
+};
+}
+namespace __gnu_cxx __attribute__ ((__visibility__ ("default"))) {
+template class new_allocator {
+};
+}
+namespace std __attribute__ ((__visibility__ ("default"))) {
+template class allocator: public 
__gnu_cxx::new_allocator<_Tp> {
+public:   typedef size_t size_type;
+ template struct rebind {
+ typedef allocator<_Tp1> other;
+ };
+};
+template class 
basic_string {
+   typedef typename _Alloc::template rebind<_CharT>::other 
_CharT_alloc_type;
+   typedef typename _CharT_alloc_type::size_type size_type;
+private:   struct _Rep_base   {
+  };
+  struct _Rep : _Rep_base   {
+  _CharT*  _M_refdata() throw()  {
+  }
+  };
+  struct _Alloc_hider : _Alloc   {
+  _Alloc_hider(_CharT* __dat, const _Alloc& __a)  : 
_Alloc(__a), _M_p(__dat) {
+  }
+  _CharT* _M_p;
+  };
+private:   mutable _Alloc_hider _M_dataplus;
+  static _Rep&   _S_empty_rep()   {
+  }
+public:   basic_string()   : 
_M_dataplus(_S_empty_rep()._M_refdata(), _Alloc()) {
+ }
+ template 
basic_string(_InputIterator __beg, _InputIterator __end,const _Alloc& 
__a = _Alloc());
+ static _CharT*   _S_construct(size_type __req, _CharT 
__c, const _Alloc& __a);
+};
+template inline 
basic_ostream<_CharT, _Traits>& operator<<(basic_ostream<_CharT, _Traits>& 
__os, const basic_string<_CharT, _Traits, _Alloc>& __str) {
+}
+template 
template basic_string<_CharT, _Traits, _Alloc>::   
  basic_string(_InputIterator __beg, _InputIterator __end, const _Alloc& __a)   
  : _M_dataplus(_S_construct(__beg, __end, __a), __a) {
+};
+enum _Ios_Openmode {
+   _S_app = 1L << 0,   _S_ate = 1L << 1,   _S_bin = 1L << 2,   
_S_in = 1L << 3,   _S_out = 1L << 4,   _S_trunc = 1L << 5,   
_S_ios_openmode_end = 1L << 16 };
+class ios_base   {
+public: class failure : public exception {
+   };
+   typedef _Ios_Openmode openmode;
+   static const openmode in = _S_in;
+   static const openmode out = _S_out;
+};
+template class basic_streambuf {
+public:   typedef _CharT cha

[PATCH] Do not stop inlining when seen_errors ()

2011-12-08 Thread Richard Guenther

When we stop inlining in the middle of applying inline transform
we can end up with a bogus callgraph (some inline clones not
inlined) which confuses later simple IPA passes.  Don't to that - IPA
passes should only guard themselves against errors at the IPA level
(so either apply to all or to no functions).  We do that already
when deciding whether to run IPA passes at all, so this particular
check is no longer needed.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2011-12-08  Richard Guenther  

PR tree-optimization/49772
* tree-inline.c (optimize_inline_calls): Remove bail out
on errors.

Index: gcc/tree-inline.c
===
--- gcc/tree-inline.c   (revision 182107)
+++ gcc/tree-inline.c   (working copy)
@@ -4216,12 +4216,6 @@ optimize_inline_calls (tree fn)
   struct gimplify_ctx gctx;
   bool inlined_p = false;
 
-  /* There is no point in performing inlining if errors have already
- occurred -- and we might crash if we try to inline invalid
- code.  */
-  if (seen_error ())
-return 0;
-
   /* Clear out ID.  */
   memset (&id, 0, sizeof (id));
 


[testsuite,committed]: Fix wrong sizeof(int)==4 assumption (yet another time)

2011-12-08 Thread Georg-Johann Lay
I allowed me to apply the following change:

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

Assumptions like sizeof(int)==4 or sizeof(void*)==4 are the most frequent cause
for annoying false FAILing C test cases.

Besides that: Why are there new test cases in gcc.c-torture?

As far as I remember that place is deprecated and the preferred place for new C
tests like this is gcc.dg?

Johann


Index: gcc.c-torture/execute/20111208-1.c
===
--- gcc.c-torture/execute/20111208-1.c  (revision 182106)
+++ gcc.c-torture/execute/20111208-1.c  (working copy)
@@ -10,8 +10,26 @@ extern void *memcpy (void *__restrict __
 extern size_t strlen (__const char *__s)
  __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__
((__nonnull__ (1)));

+#if __SIZEOF_SHORT__ == 2
 typedef short int int16_t;
+#elif __SIZEOF_INT__ == 2
+typedef int int16_t;
+#elif __SIZEOF_LONG__ == 2
+typedef long int16_t;
+#else
+#error Fix this
+#endif
+
+
+#if __SIZEOF_INT__ == 4
 typedef int int32_t;
+#elif __SIZEOF_LONG__ == 4
+typedef long int32_t;
+#elif __SIZEOF_SHORT__ == 4
+typedef short int32_t;
+#else
+#error Fix this
+#endif

 extern void abort (void);


[patch] Fix cygwin ada install [was Re: Yet another issue with gcc current trunk with ada on cygwin]

2011-12-08 Thread Dave Korn

Hi again guys,

  After the previous patch, there's still another bug remaining in the Ada
makefile, relating to how it builds and installs the gnat/gnarl shared 
libraries.

  Windows doesn't have any concept of an rpath in executables, nor of
LD_LIBRARY_PATH; all required DLLs must be found on the PATH when an exe is
invoked.  The Ada shared libraries are currently installed into adaobj/ in the
gcc private dir, which is not (and should not be) on users' PATHs, so the
result is that executables compiled with the -shared binder option don't work.

  The attached patch fixes Windows DLLs to be installed into $bindir, and
while it does that it also generates import libraries, which live in the
private adaobj/ directory and serve for linking executables to the DLLs (it's
actually preferred to link against an import library than directly against the
DLL itself).  Finally it adjusts the name of the DLLs on Cygwin to match the
cyg*.dll naming scheme used there to avoid clashes with MinGW DLLs.

libada/ChangeLog:

* Makefile.in (bindir): Import from autoconf and pass down to submake.

gcc/ada/ChangeLog:

* gcc-interface/Makefile.in (WIN_SO_PREFIX [windows targets]): New
Windows-specific make variable.
(WIN_SO_INSTALL_DIR [windows targets]): Likewise.
(install-gnatlib): Respect the above during installation when set,
and also install any windows import library that has been built.
(gnatlib-shared-win32): Use WIN_SO_PREFIX to name output DLL and also
build a corresponding import library.

  Built, tested, installed on i686-pc-cygwin and x86_64-unknown-linux-gnu, no
regressions anywhere, verified that DLL install locations are corrected on
windows and the .so install locations unchanged on Linux.  Ok?

cheers,
  DaveK


Index: libada/Makefile.in
===
--- libada/Makefile.in	(revision 182075)
+++ libada/Makefile.in	(working copy)
@@ -33,6 +33,7 @@ MULTICLEAN = true
 SHELL = @SHELL@
 srcdir = @srcdir@
 libdir = @libdir@
+bindir = @bindir@
 build = @build@
 target = @target@
 prefix = @prefix@
@@ -83,6 +84,7 @@ LIBADA_FLAGS_TO_PASS = \
 "TRACE=$(TRACE)" \
 "MULTISUBDIR=$(MULTISUBDIR)" \
 "libsubdir=$(libsubdir)" \
+"bindir=$(bindir)" \
 "objext=$(objext)" \
 "prefix=$(prefix)" \
 "exeext=.exeext.should.not.be.used " \
Index: gcc/ada/gcc-interface/Makefile.in
===
--- gcc/ada/gcc-interface/Makefile.in	(revision 182075)
+++ gcc/ada/gcc-interface/Makefile.in	(working copy)
@@ -1588,16 +1588,19 @@ ifeq ($(strip $(filter-out cygwin% mingw32% pe,$(o
   # the Cygwin port has always been a CygMing frankenhybrid and it is
   # a long-term project to disentangle them.
   ifeq ($(strip $(filter-out cygwin%,$(osys))),)
+WIN_SO_PREFIX=cyg
 LIBGNAT_TARGET_PAIRS = \
 s-memory.adb

Re: [testsuite,committed]: Fix wrong sizeof(int)==4 assumption (yet another time)

2011-12-08 Thread Jakub Jelinek
On Thu, Dec 08, 2011 at 01:54:17PM +0100, Georg-Johann Lay wrote:
The test should be using
typedef __INT16_TYPE__ int16_t;
typedef __INT32_TYPE__ int32_t;
instead of what you are proposing.

> Index: gcc.c-torture/execute/20111208-1.c
> ===
> --- gcc.c-torture/execute/20111208-1.c  (revision 182106)
> +++ gcc.c-torture/execute/20111208-1.c  (working copy)
> @@ -10,8 +10,26 @@ extern void *memcpy (void *__restrict __
>  extern size_t strlen (__const char *__s)
>   __attribute__ ((__nothrow__)) __attribute__ ((__pure__)) __attribute__
> ((__nonnull__ (1)));
> 
> +#if __SIZEOF_SHORT__ == 2
>  typedef short int int16_t;
> +#elif __SIZEOF_INT__ == 2
> +typedef int int16_t;
> +#elif __SIZEOF_LONG__ == 2
> +typedef long int16_t;
> +#else
> +#error Fix this
> +#endif
> +
> +
> +#if __SIZEOF_INT__ == 4
>  typedef int int32_t;
> +#elif __SIZEOF_LONG__ == 4
> +typedef long int32_t;
> +#elif __SIZEOF_SHORT__ == 4
> +typedef short int32_t;
> +#else
> +#error Fix this
> +#endif
> 
>  extern void abort (void);

Jakub


Re: [4.7][google] Adding a new option -fstack-protector-strong. (issue5461043)

2011-12-08 Thread Diego Novillo
On Wed, Dec 7, 2011 at 20:07, Han Shen  wrote:

> Status - implemented internally, to be up-streamed or merged to google branch 
> only.

Why would you not consider sending this for trunk at the next stage 1?

(patch review in progress)

Diego.


[PATCH] Do not mark address-taking stmts of volatile objects as volatile

2011-12-08 Thread Richard Guenther

During an IRC discussion I noticed that we mark p = &a[i] as volatile

  p_2 ={v} &a[i_1(D)];

in the operand scanner even though that is not necessary.  The following
patch properly guards setting the volatile flag on that we are not
processing the operands of an ADDR_EXPR currently.

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

Richard.

2011-12-08  Richard Guenther  

* tree-ssa-operands.c (add_stmt_operand): Do not mark stmts
volatile when processing operands of an ADDR_EXPR.
(get_indirect_ref_operands): Likewise.
(get_tmr_operands): Likewise.
(get_expr_operands): Likewise.

* gcc.dg/volatile3.c: New testcase.

Index: gcc/tree-ssa-operands.c
===
--- gcc/tree-ssa-operands.c (revision 182107)
+++ gcc/tree-ssa-operands.c (working copy)
@@ -668,7 +668,8 @@ add_stmt_operand (tree *var_p, gimple st
   sym = (TREE_CODE (var) == SSA_NAME ? SSA_NAME_VAR (var) : var);
 
   /* Mark statements with volatile operands.  */
-  if (TREE_THIS_VOLATILE (sym))
+  if (!(flags & opf_no_vops)
+  && TREE_THIS_VOLATILE (sym))
 gimple_set_has_volatile_ops (stmt, true);
 
   if (is_gimple_reg (sym))
@@ -728,7 +729,8 @@ get_indirect_ref_operands (gimple stmt,
 {
   tree *pptr = &TREE_OPERAND (expr, 0);
 
-  if (TREE_THIS_VOLATILE (expr))
+  if (!(flags & opf_no_vops)
+  && TREE_THIS_VOLATILE (expr))
 gimple_set_has_volatile_ops (stmt, true);
 
   /* Add the VOP.  */
@@ -747,7 +749,8 @@ get_indirect_ref_operands (gimple stmt,
 static void
 get_tmr_operands (gimple stmt, tree expr, int flags)
 {
-  if (TREE_THIS_VOLATILE (expr))
+  if (!(flags & opf_no_vops)
+  && TREE_THIS_VOLATILE (expr))
 gimple_set_has_volatile_ops (stmt, true);
 
   /* First record the real operands.  */
@@ -914,14 +917,16 @@ get_expr_operands (gimple stmt, tree *ex
 case REALPART_EXPR:
 case IMAGPART_EXPR:
   {
-   if (TREE_THIS_VOLATILE (expr))
+   if (!(flags & opf_no_vops)
+   && TREE_THIS_VOLATILE (expr))
  gimple_set_has_volatile_ops (stmt, true);
 
get_expr_operands (stmt, &TREE_OPERAND (expr, 0), flags);
 
if (code == COMPONENT_REF)
  {
-   if (TREE_THIS_VOLATILE (TREE_OPERAND (expr, 1)))
+   if (!(flags & opf_no_vops)
+   && TREE_THIS_VOLATILE (TREE_OPERAND (expr, 1)))
  gimple_set_has_volatile_ops (stmt, true);
get_expr_operands (stmt, &TREE_OPERAND (expr, 2), uflags);
  }
@@ -960,7 +965,8 @@ get_expr_operands (gimple stmt, tree *ex
/* A volatile constructor is actually TREE_CLOBBER_P, transfer
   the volatility to the statement, don't use TREE_CLOBBER_P for
   mirroring the other uses of THIS_VOLATILE in this file.  */
-   if (TREE_THIS_VOLATILE (expr))
+   if (!(flags & opf_no_vops)
+   && TREE_THIS_VOLATILE (expr))
  gimple_set_has_volatile_ops (stmt, true);
 
for (idx = 0;
@@ -972,7 +978,8 @@ get_expr_operands (gimple stmt, tree *ex
   }
 
 case BIT_FIELD_REF:
-  if (TREE_THIS_VOLATILE (expr))
+  if (!(flags & opf_no_vops)
+ && TREE_THIS_VOLATILE (expr))
gimple_set_has_volatile_ops (stmt, true);
   /* FALLTHRU */
 
Index: gcc/testsuite/gcc.dg/volatile3.c
===
--- gcc/testsuite/gcc.dg/volatile3.c(revision 0)
+++ gcc/testsuite/gcc.dg/volatile3.c(revision 0)
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-ssa" } */
+
+volatile int *q;
+void foo(int i)
+{
+  volatile int a[2];
+  volatile int *p = &a[i];
+  q = p;
+}
+
+/* { dg-final { scan-tree-dump-not "{v}" "ssa" } } */
+/* { dg-final { cleanup-tree-dump "ssa" } } */


[committed] 4 backports from trunk to 4.6 branch

2011-12-08 Thread Jakub Jelinek
Hi!

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to 4.6
branch:

Jakub
2011-12-08  Jakub Jelinek  

Backport from mainline
2011-11-30  Jakub Jelinek  

PR rtl-optimization/48721
* sched-deps.c (sched_analyze_insn): For SIBLING_CALL_P set
reg_pending_barrier to TRUE_BARRIER.

* gcc.target/i386/pr48721.c: New test.

--- gcc/sched-deps.c(revision 181855)
+++ gcc/sched-deps.c(revision 181856)
@@ -2873,7 +2873,11 @@ sched_analyze_insn (struct deps_desc *de
  else
sched_analyze_2 (deps, XEXP (link, 0), insn);
}
-  if (find_reg_note (insn, REG_SETJMP, NULL))
+  /* Don't schedule anything after a tail call, tail call needs
+to use at least all call-saved registers.  */
+  if (SIBLING_CALL_P (insn))
+   reg_pending_barrier = TRUE_BARRIER;
+  else if (find_reg_note (insn, REG_SETJMP, NULL))
reg_pending_barrier = MOVE_BARRIER;
 }
 
--- gcc/testsuite/gcc.target/i386/pr48721.c (revision 0)
+++ gcc/testsuite/gcc.target/i386/pr48721.c (revision 181856)
@@ -0,0 +1,51 @@
+/* PR rtl-optimization/48721 */
+/* { dg-do compile } */
+/* { dg-options "-O -foptimize-sibling-calls -fsched2-use-superblocks 
-fschedule-insns2 -mtune=core2" } */
+
+extern unsigned char a[];
+extern int b[], d[], e[], f[], g[], *h[], m[], *n[], o[];
+extern char c[];
+
+struct S
+{
+  unsigned char s1;
+  int s2, s3, s4, s5, s6, s7, s8;
+};
+
+__attribute__((noinline, noclone)) int
+foo (int x)
+{
+  return 0;
+}
+
+int
+bar (int x, struct S *y)
+{
+  int z;
+  switch (x)
+{
+case 1:
+case 2:
+  {
+   int t2, t4, t5, t6, t7, t8;
+   z = o[y->s8 * 6];
+   t8 = *n[m[x] * 5];
+   t4 = *h[y->s7];
+   t7 = z;
+   z = g[f[x] + y->s6];
+   t6 = e[y->s5];
+   t5 = d[c[x] + y->s3 * 17];
+   if (z)
+ t2 = b[z];
+   if (a[z] != y->s1)
+ return foo (x);
+   y->s8 = t8;
+   y->s4 = t4;
+   y->s7 = t7;
+   y->s6 = t6;
+   y->s5 = t5;
+   y->s2 = t2;
+  }
+}
+  return 0;
+}
2011-12-08  Jakub Jelinek  

Backport from mainline
2011-12-05  Jakub Jelinek  
Eric Botcazou  

PR middle-end/51323
PR middle-end/50074
* calls.c (internal_arg_pointer_exp_state): New variable.
(internal_arg_pointer_based_exp_1,
internal_arg_pointer_exp_scan): New functions.
(internal_arg_pointer_based_exp): New function.
(mem_overlaps_already_clobbered_arg_p): Use it.
(expand_call): Free internal_arg_pointer_exp_state.cache vector
and clear internal_arg_pointer_exp_state.scan_start.

2011-11-26  Joern Rennecke  

PR middle-end/50074
* calls.c (mem_overlaps_already_clobbered_arg_p):
Return false if no outgoing arguments have been stored so far.

2011-12-05  Jakub Jelinek  
Eric Botcazou  

PR middle-end/51323
PR middle-end/50074
* gcc.c-torture/execute/pr51323.c: New test.

--- gcc/calls.c (revision 181999)
+++ gcc/calls.c (revision 182000)
@@ -1548,6 +1548,129 @@ rtx_for_function_call (tree fndecl, tree
   return funexp;
 }
 
+/* Internal state for internal_arg_pointer_based_exp and its helpers.  */
+static struct
+{
+  /* Last insn that has been scanned by internal_arg_pointer_based_exp_scan,
+ or NULL_RTX if none has been scanned yet.  */
+  rtx scan_start;
+  /* Vector indexed by REGNO - FIRST_PSEUDO_REGISTER, recording if a pseudo is
+ based on crtl->args.internal_arg_pointer.  The element is NULL_RTX if the
+ pseudo isn't based on it, a CONST_INT offset if the pseudo is based on it
+ with fixed offset, or PC if this is with variable or unknown offset.  */
+  VEC(rtx, heap) *cache;
+} internal_arg_pointer_exp_state;
+
+static rtx internal_arg_pointer_based_exp (rtx, bool);
+
+/* Helper function for internal_arg_pointer_based_exp.  Scan insns in
+   the tail call sequence, starting with first insn that hasn't been
+   scanned yet, and note for each pseudo on the LHS whether it is based
+   on crtl->args.internal_arg_pointer or not, and what offset from that
+   that pointer it has.  */
+
+static void
+internal_arg_pointer_based_exp_scan (void)
+{
+  rtx insn, scan_start = internal_arg_pointer_exp_state.scan_start;
+
+  if (scan_start == NULL_RTX)
+insn = get_insns ();
+  else
+insn = NEXT_INSN (scan_start);
+
+  while (insn)
+{
+  rtx set = single_set (insn);
+  if (set && REG_P (SET_DEST (set)) && !HARD_REGISTER_P (SET_DEST (set)))
+   {
+ rtx val = NULL_RTX;
+ unsigned int idx = REGNO (SET_DEST (set)) - FIRST_PSEUDO_REGISTER;
+ /* Punt on pseudos set multiple times.  */
+ if (idx < VEC_length (rtx, internal_arg_pointer_exp_state.cache)
+ && (VEC_index (rtx, internal_arg_pointer_exp_state.cache, idx)
+ != NULL_RTX))
+   val = pc_rtx;
+ 

Re: [testsuite,committed]: Fix wrong sizeof(int)==4 assumption (yet another time)

2011-12-08 Thread Georg-Johann Lay
Jakub Jelinek wrote:
> On Thu, Dec 08, 2011 at 01:54:17PM +0100, Georg-Johann Lay wrote:
> The test should be using
> typedef __INT16_TYPE__ int16_t;
> typedef __INT32_TYPE__ int32_t;
> instead of what you are proposing.

Ah, thanks for the hint! Looks way better now.

Johann


Re: [PATCH] Fix PR middle-end/39976, 200.sixtrack degradation

2011-12-08 Thread Richard Guenther
On Mon, Dec 5, 2011 at 3:52 PM, William J. Schmidt
 wrote:
>
>
> On Mon, 2011-12-05 at 08:36 -0600, William J. Schmidt wrote:
>>
>> On Mon, 2011-12-05 at 14:59 +0100, Michael Matz wrote:
>> > Hi,
>> >
>> > On Fri, 2 Dec 2011, William J. Schmidt wrote:
>> >
>> > > > on top of your current version.  That ought to remove the added PHI
>> > > > expressions (and only them) from the hash table but retain the
>> > > > information of equality in the const_or_copies_stack.  Checking the BB
>> > > > wouldn't be required then.
>> > >
>> > > Bootstrapped and regression tested on powerpc64-linux.
>> >
>> > Another nit (sorry I didn't see this before :-/) :
>> >
>> > > +      expr->ops.phi.args = (tree *) xcalloc (nargs, sizeof (tree));
>> >
>> > This leaks, because you missed to add freeing to free_expr_hash_elt.
>> > Apart from that looks good to me, but I can't approve.
>> >
>>
>> /facered :(
>>
>> Thanks.  Will fix...
>>
>> Bill
>
> Richard -- OK with this change?

Yes.

Thanks,
Richard.

>>
>> >
>> > Ciao,
>> > Michael.
>> >
>


Re: [PATCH] Fix PR middle-end/39976, 200.sixtrack degradation

2011-12-08 Thread Jakub Jelinek
On Thu, Dec 08, 2011 at 03:11:44PM +0100, Richard Guenther wrote:
> >> > Another nit (sorry I didn't see this before :-/) :
> >> >
> >> > > +      expr->ops.phi.args = (tree *) xcalloc (nargs, sizeof (tree));
> >> >
> >> > This leaks, because you missed to add freeing to free_expr_hash_elt.
> >> > Apart from that looks good to me, but I can't approve.
> >> >
> >>
> >> /facered :(
> >>
> >> Thanks.  Will fix...
> >>
> >> Bill
> >
> > Richard -- OK with this change?
> 
> Yes.

But please use:
  expr->ops.phi.args = XCNEWVEC (tree, nargs);
instead of the above.

Jakub


Re: [Patch, i386] [4.6] Backport movd*_internal_rex64 fix from trunk and [4.6/4.7] add testcase

2011-12-08 Thread Teresa Johnson
Sounds good. I will fix the 4.7 version to use the fpie target
selector. The other thing I noticed is that you had removed the
-Wwrite-strings option, but I needed to keep that as it was the
combination of -fPIE and -Wwrite-strings that triggered the bug.

Thanks,
Teresa

On Wed, Dec 7, 2011 at 10:55 PM, Uros Bizjak  wrote:
> On Wed, Dec 7, 2011 at 11:32 PM, Teresa Johnson  wrote:
>
 An issue turned up in our internal 4.6 based testing that has been
 fixed on trunk. This patch backports the fix to 4.6. I also have a
 small test case that I will add to both 4.6 and 4.7.

 Bootstrapped and checked with x86_64-unknown-linux-gnu.

 2011-12-07  Teresa Johnson  

       Backport from mainline:

       2011-08-05  Uros Bizjak  

       * config/i386/i386.md (*movdi_internal_rex64): Use "!o" constraint
       instead of "!m" for operand 0, alternative 4.
       (*movdf_internal_rex64): Ditto for operand 0, alernative 6.

 2011-12-07  Teresa Johnson  

       * gcc.target/i386/movdi-rex64.c: New.
>>>
>>> Index: testsuite/gcc.target/i386/movdi-rex64.c
>>> ===
>>> --- testsuite/gcc.target/i386/movdi-rex64.c     (revision 0)
>>> +++ testsuite/gcc.target/i386/movdi-rex64.c     (revision 0)
>>> @@ -0,0 +1,11 @@
>>> +/* { dg-do compile { target *-*-linux* } } */
>>> +/* { dg-options "-fPIE -Wwrite-strings" } */
>>> +
>>> +#include 
>>> +static __thread char buffer[25];
>>> +const char * error_message (void)
>>> +{
>>> +oops:
>>> +    strcpy (buffer, "Unknown code ");
>>> +    return 0;
>>> +}
>>>
>>> You don't need #include for compile tests, just use:
>>>
>>> --cut here--
>>> /* { dg-do compile } */
>>> /* { dg-options "-fPIE" } */
>>>
>>> char *strcpy (char *dest, const char *src);
>>>
>>> static __thread char buffer[25];
>>>
>>> const char
>>> * error_message (void)
>>> {
>>>  strcpy (buffer, "Unknown code ");
>>>  return 0;
>>> }
>>> --cut here--
>>>
>>> Also this can be compiled everywhere, not just linux.
>>
>> Ok, I will change the testcase to replace the include and retest.
>>
>> Regarding the linux target restriction, though, I was concerned about
>> the -fPIE option used for the test case. I noticed that in 4.7 there
>> is a "pie" effective target keyword (check_effective_target_pie in
>> testsuite/lib/target-supports.exp). However, that does not yet exist
>> in 4.6, so rather than backport that as well I added the linux
>> restriction. I see the same restriction in the other tests that use
>> -fpie in gcc.target/i386 (pr39013-[12].c). What do you think?
>
> Ah, I see. Then pleasee add back linux target selctor for 4.6 and add
> fpie effective target check for 4.7.
>
> Thanks,
> Uros.



-- 
Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413


[Committed] PR50395 S/390: Emit jump over literal pool as jump_insn

2011-12-08 Thread Andreas Krebbel
Hi,

so far we emitted the jump over the literal pool as normal insn:

(insn 8094 5448 8483 (parallel [
(set (reg:SI 13 %r13)
(unspec [
(label_ref 8095)
] UNSPEC_MAIN_BASE))
(set (pc)
(label_ref 8097))
]) /build/gcc-ok/libjava/gnu/gcj/tools/gcj_dbtool/
Main.java:26 610 {main_base_31_large}
 (nil))

When dwarf2cfi tries to build its own cfg it does not recognize the
insn as control flow change.  With the attached patch the back-end
properly emits the insn as jump_insn.

This fixes java bootstrap on s390 and s390x.

Committed to mainline.

Bye,

-Andreas-


2011-12-08  Andreas Krebbel  

PR target/50395
* config/s390/s390.c (s390_mainpool_finish): Emit the jump over
the literal pool as jump insn.


Index: gcc/config/s390/s390.c
===
*** gcc/config/s390/s390.c.orig
--- gcc/config/s390/s390.c
*** s390_mainpool_finish (struct constant_po
*** 6476,6482 
rtx pool_end = gen_label_rtx ();
  
insn = gen_main_base_31_large (base_reg, pool->label, pool_end);
!   insn = emit_insn_after (insn, pool->pool_insn);
INSN_ADDRESSES_NEW (insn, -1);
remove_insn (pool->pool_insn);
  
--- 6476,6483 
rtx pool_end = gen_label_rtx ();
  
insn = gen_main_base_31_large (base_reg, pool->label, pool_end);
!   insn = emit_jump_insn_after (insn, pool->pool_insn);
!   JUMP_LABEL (insn) = pool_end;
INSN_ADDRESSES_NEW (insn, -1);
remove_insn (pool->pool_insn);
  



Re: [PATCH] Fix PR middle-end/39976, 200.sixtrack degradation

2011-12-08 Thread William J. Schmidt


On Thu, 2011-12-08 at 15:18 +0100, Jakub Jelinek wrote:
> On Thu, Dec 08, 2011 at 03:11:44PM +0100, Richard Guenther wrote:
> > >> > Another nit (sorry I didn't see this before :-/) :
> > >> >
> > >> > > +  expr->ops.phi.args = (tree *) xcalloc (nargs, sizeof (tree));
> > >> >
> > >> > This leaks, because you missed to add freeing to free_expr_hash_elt.
> > >> > Apart from that looks good to me, but I can't approve.
> > >> >
> > >>
> > >> /facered :(
> > >>
> > >> Thanks.  Will fix...
> > >>
> > >> Bill
> > >
> > > Richard -- OK with this change?
> > 
> > Yes.
> 
> But please use:
>   expr->ops.phi.args = XCNEWVEC (tree, nargs);
> instead of the above.

Good call.  This was copied from another xcalloc call nearby, so I will
plan to correct that one as well, as long as I'm in there.

Bill

> 
>   Jakub
> 



Re: [PATCH, PR43814] Assume function arguments of pointer type are aligned.

2011-12-08 Thread Tom de Vries
On 26/10/11 12:19, Richard Guenther wrote:
> On Tue, Oct 25, 2011 at 2:22 PM, Tom de Vries  wrote:
>> On 09/24/2011 01:42 PM, Richard Guenther wrote:
>>> On Sat, Sep 24, 2011 at 11:40 AM, Jakub Jelinek  wrote:
 On Sat, Sep 24, 2011 at 11:31:25AM +0200, Richard Guenther wrote:
> In the end I'd probably say the patch is ok without the option (thus
> turned on by default), but if LC_GLOBAL_LOCALE is part of the
> glibc ABI then we clearly can't do this.

 Yes, LC_GLOBAL_LOCALE is part of glibc ABI.  I guess we could only assume
 the alignment if the pointer is actually dereferenced on the statement
 that checks the ABI or in some stmt that dominates the spot where you want
 to check the alignment.  It is IMHO quite common to pass arbitrary values
 in pointer types, then cast them back or just compare.
>>>
>>> Yeah (even if technically invoking undefined behavior in C).  Checking if
>>> there is a dereference post-dominating function entry with sth like
>>>
>>>   FOR_EACH_IMM_USE_STMT (... ptr ...)
>>>  if (stmt_post_dominates_entry && contains derefrence of ptr)
>>>alignment = TYPE_ALIGN (...);
>>>
>>> and otherwise not assuming anything about parameter alignment might work.
>>> Be careful to check the alignment of the dereference though,
>>>
>>> typedef int int_unaligned __attribute__((aligned(1)));
>>> int foo (int *p)
>>> {
>>>   int_unaligned *q = p;
>>>   return *q;
>>> }
>>>
>>> will be MEM[p] but with (well, hopefully ;)) TYPE_ALIGN of TREE_TYPE 
>>> (MEM[p])
>>> being 1.  And yes, you'd have to look into handled-components as well.  I 
>>> guess
>>> you'll face similar problems as we do with tree-sra.c
>>> tree_non_mode_aligned_mem_p
>>> (you need to assume eventually misaligned accesses the same way expansion
>>> does for the dereference, otherwise you'll run into issues on
>>> strict-align targets).
>>>
>>> As that de-refrence thing doesn't really fit the CCP propagation you
>>> won't be able
>>> to handle
>>>
>>> int foo (int *p)
>>> {
>>>   int *q = (char *)p + 3;
>>>   return *q;
>>> }
>>>
>>> and assume q is aligned (and p is misaligned by 1).
>>>
>>> That is, if the definition of a pointer is post-dominated by a derefrence
>>> we could assume proper alignment for that pointer (as opposed to just
>>> special-casing its default definition).  Would be certainly interesting to
>>> see what kind of fallout we would get from that ;)
>>>
>>
>> I gave this a try in deduce_alignment_from_dereferences.
>>
>> The fall-out I got from this were unaligned dereferenced pointers in
>> gcc.c-torture/unsorted/*{cmp,set}.c.
>>
>> Bootstrapped and reg-tested on x86_64. Build and reg-tested on MIPS and ARM.
>>
>> Ok for trunk?
> 
> Can you not do the get_value_from_alignment split (it doesn't look
> necessary to me) and drop the
> 
> @@ -541,10 +550,18 @@ get_value_for_expr (tree expr, bool for_
>if (TREE_CODE (expr) == SSA_NAME)
>  {
>val = *get_value (expr);
> -  if (for_bits_p
> - && val.lattice_val == CONSTANT
> +  if (!for_bits_p)
> +   return val;
> +
> +  if (val.lattice_val == CONSTANT
>   && TREE_CODE (val.value) == ADDR_EXPR)
> val = get_value_from_alignment (val.value);
> +  else if (val.lattice_val == VARYING
> +  && SSA_NAME_PTR_INFO (expr) != NULL
> +  && SSA_NAME_PTR_INFO (expr)->align > 1
> +  && SSA_NAME_PTR_INFO (expr)->misalign == 0)
> +   val = get_align_value (SSA_NAME_PTR_INFO (expr)->align * 
> BITS_PER_UNIT,
> +  TREE_TYPE (expr), 0);
>  }
> 
> hunk?  I'm not sure why it is necessary at all - CCP is the only pass
> computing alignment, so it should simply re-compute the info?
> 
> Anyway, it looks unrelated to the purpose of the patch in general.
> 

I dropped the code in get_value_for_expr, but kept the factoring of
get_align_value out of get_value_from_alignment . This remains necessary in the
new patch since get_align_value is still called from 2 sites:
get_value_from_alignment and deduce_alignment_from_dereference.

> The error reporting in deduce_alignment_from_dereferences is bogus,
> the programs are undefined only at runtime, so you can at most
> issue a warning.
> 

Introduced -Wunaligned-pointer-deref.

> +  /* Needs to be the successor of entry, for CDI_POST_DOMINATORS.  */
> +  entry = single_succ (ENTRY_BLOCK_PTR);
> +
> +  FOR_EACH_BB (bb)
> +{
> +  gimple_stmt_iterator i;
> +
> +  if (!dominated_by_p (CDI_POST_DOMINATORS, entry, bb))
> +   continue;
> 
> if you only consider post-dominators of the entry block then just walk
> them directly (first_dom_son / next_dom_son).
> 
> + align = TYPE_ALIGN (TREE_TYPE (memref)) / BITS_PER_UNIT;
> + if (align == 1)
> +   continue;
> 

I integrated the walking of post-dominators into the bb walk in ccp_initialize.

> I think you want to match what expand thinks of the alignment of this
> memory reference, no

[PATCH] use -fno-pie on darwin in boehm-gc.exp

2011-12-08 Thread Jack Howarth
Currently the boehm-gc testsuite fails...

FAIL: boehm-gc.c/gctest.c -O2 execution test
FAIL: boehm-gc.c/leak_test.c -O2 execution test
FAIL: boehm-gc.c/thread_leak_test.c -O2 execution test
FAIL: boehm-gc.lib/staticrootstest.c -O2 execution test

on x86_64-apple-darwin11 due to the -pie linker default. The attached patch
uses -fno-pie on darwin to insure that -no_pie is passed to the linker when
targeting darwin11 or later. This approach is used because istarget doesn't
support complex regex to allow -Wl,-no_pie to be passed for darwin11 and later
only (since only recent Xcode releases understand the -no_pie linker option).
Also, -fno_pie has the advantage of supporting -mmacosx-version-min usage.
Regression tested on x86_64-apple-darwin11...

http://gcc.gnu.org/ml/gcc-testresults/2011-12/msg00856.html

Okay for gcc trunk?
 Jack


boehm-gc/

2011-12-08  Jack Howarth 

* testsuite/lib/boehm-gc.exp: Use -fno-pie on darwin.

Index: boehm-gc/testsuite/lib/boehm-gc.exp
===
--- boehm-gc/testsuite/lib/boehm-gc.exp (revision 182117)
+++ boehm-gc/testsuite/lib/boehm-gc.exp (working copy)
@@ -214,6 +214,11 @@ proc boehm-gc_target_compile { source de
 lappend options "additional_flags=-I${gc_include} -I${srcdir}/../include"
 lappend options "additional_flags=${threadcflags}"
 
+# Disable -pie linker default for darwin11 and later using -fno-pie.
+if { [istarget *-*-darwin*] } {
+   lappend options "additional_flags=-fno-pie"
+}
+
 lappend options "libs=-Wc,-shared-libgcc"
 
 if { [file extension $dest] == ".la" } {


[Path,AVR]: Implement __muldi3 in asm

2011-12-08 Thread Georg-Johann Lay
This are assembler implementations for Dimode multiplication.

Tested without regressions, the only change in the test suite I get is for

gcc.c-torture/execute/arith-rand-ll.c execution,  -O0

UNTESTED -> PASS

because the former vanilla C implementation ran into timeout.

Ok for trunk?

Johann

* config/avr/t-avr (LIB1ASMFUNCS): Add _muldi3.
* config/avr/lib1funcs.S (__muldi3): New function.

Index: libgcc/config/avr/lib1funcs.S
===
--- libgcc/config/avr/lib1funcs.S	(revision 182106)
+++ libgcc/config/avr/lib1funcs.S	(working copy)
@@ -464,6 +464,249 @@ ENDF __mulsi3
 #undef C3
 
 #endif /* __AVR_HAVE_MUL__ */
+
+/***
+   Multiplication 64 x 64
+***/
+
+#if defined (L_muldi3)
+
+;; A[] = A[] * B[]
+
+;; A[0..7]: In: Multiplicand
+;; Out: Product
+#define A0  18
+#define A1  A0+1
+#define A2  A0+2
+#define A3  A0+3
+#define A4  A0+4
+#define A5  A0+5
+#define A6  A0+6
+#define A7  A0+7
+
+;; B[0..7]: In: Multiplier
+#define B0  10
+#define B1  B0+1
+#define B2  B0+2
+#define B3  B0+3
+#define B4  B0+4
+#define B5  B0+5
+#define B6  B0+6
+#define B7  B0+7
+
+#if defined (__AVR_HAVE_MUL__)
+
+;; Define C[] for convenience
+;; Notice that parts of C[] overlap A[] respective B[]
+#define C0  16
+#define C1  C0+1
+#define C2  20
+#define C3  C2+1
+#define C4  28
+#define C5  C4+1
+#define C6  C4+2
+#define C7  C4+3
+
+;; A[] *= B[]
+;; R25:R18 *= R17:R10
+;; Ordinary ABI-Function
+
+DEFUN __muldi3
+pushr29
+pushr28
+pushr17
+pushr16
+
+;; Counting in Words, we have to perform a 4 * 4 Multiplication
+
+;; 3 * 0  +  0 * 3
+mul  A7,B0  $ $  mov C7,r0
+mul  A0,B7  $ $  add C7,r0
+mul  A6,B1  $ $  add C7,r0
+mul  A6,B0  $  mov C6,r0  $  add C7,r1
+mul  B6,A1  $ $  add C7,r0
+mul  B6,A0  $  add C6,r0  $  adc C7,r1
+
+;; 1 * 2
+mul  A2,B4  $  add C6,r0  $  adc C7,r1
+mul  A3,B4  $ $  add C7,r0
+mul  A2,B5  $ $  add C7,r0
+
+pushA5
+pushA4
+pushB1
+pushB0
+pushA3
+pushA2
+
+;; 0 * 0
+wmov26, B0
+XCALL   __umulhisi3
+wmovC0, 22
+wmovC2, 24
+
+;; 0 * 2
+wmov26, B4
+XCALL   __umulhisi3  $  wmov C4,22$ add C6,24 $ adc C7,25
+
+wmov26, B2
+;; 0 * 1
+rcall   __muldi3_6
+
+pop A0
+pop A1
+;; 1 * 1
+wmov26, B2
+XCALL   __umulhisi3  $  add C4,22 $ adc C5,23 $ adc C6,24 $ adc C7,25
+
+pop r26
+pop r27
+;; 1 * 0
+rcall   __muldi3_6
+
+pop A0
+pop A1
+;; 2 * 0
+XCALL   __umulhisi3  $  add C4,22 $ adc C5,23 $ adc C6,24 $ adc C7,25
+
+;; 2 * 1
+wmov26, B2
+XCALL   __umulhisi3  $$   $ add C6,22 $ adc C7,23
+
+;; A[] = C[]
+wmovA0, C0
+;; A2 = C2 already
+wmovA4, C4
+wmovA6, C6
+
+clr __zero_reg__
+pop r16
+pop r17
+pop r28
+pop r29
+ret
+
+__muldi3_6:
+XCALL   __umulhisi3
+add C2, 22
+adc C3, 23
+adc C4, 24
+adc C5, 25
+brcc0f
+adiwC6, 1
+0:  ret
+ENDF __muldi3
+
+#undef C7
+#undef C6
+#undef C5
+#undef C4
+#undef C3
+#undef C2
+#undef C1
+#undef C0
+
+#else /* !HAVE_MUL */
+
+#define C0  26
+#define C1  C0+1
+#define C2  C0+2
+#define C3  C0+3
+#define C4  C0+4
+#define C5  C0+5
+#define C6  0
+#define C7  C6+1
+
+#define Loop 9
+
+;; A[] *= B[]
+;; R25:R18 *= R17:R10
+;; Ordinary ABI-Function
+
+DEFUN __muldi3
+pushr29
+pushr28
+pushLoop
+
+ldi C0, 64
+mov Loop, C0
+
+;; C[] = 0
+clr __tmp_reg__
+wmovC0, 0
+wmovC2, 0
+wmovC4, 0
+
+0:  ;; Rotate B[] right by 1 and set Carry to the N-th Bit of B[]
+;; where N = 64 - Loop.
+;; Notice that B[] = B[] >>> 64 so after this Routine has finished,
+;; B[] will have its initial Value again.
+LSR  B7 $  ror  B6 $  ror  B5 $  ror  B4
+ror  B3 $  ror  B2 $  ror  B1 $  ror  B0
+
+;; If the N-th Bit of B[] was set then...
+brcc1f
+;; ...finish Rotation...
+ori B7, 1 << 7
+
+;; ...and add A[] * 2^N to the Result C[]
+ADD  C0,A0  $  adc  C1,A1  $  adc  C2,A2  $  adc  C3,A3
+adc  C4,A4  $  adc  C5,A5  $  adc  C6,A6  $  adc  C7,A7
+
+1:  ;; Multiply A[] by 2
+LSL  A0 $  rol  A1 $  rol  A2 $  rol  A3
+rol  A4 $  rol  A5 $  rol  A6 $  rol  A7
+
+dec Loop
+brne0b
+
+;; We expanded the Result in C[]
+;; Copy Result to the Return Register A[]
+wmovA0, C0
+wmovA2, C2
+wmovA4, C4
+wmovA6, C6
+
+clr __zero_reg__
+pop Loop
+pop r28
+pop

Re: [PATCH] use -fno-pie on darwin in boehm-gc.exp

2011-12-08 Thread Iain Sandoe


On 8 Dec 2011, at 15:38, Jack Howarth wrote:


Currently the boehm-gc testsuite fails...

FAIL: boehm-gc.c/gctest.c -O2 execution test
FAIL: boehm-gc.c/leak_test.c -O2 execution test
FAIL: boehm-gc.c/thread_leak_test.c -O2 execution test
FAIL: boehm-gc.lib/staticrootstest.c -O2 execution test


you have not answered these questions:

a) "what is anything being built in these tests which is not PIC"?
b) and why is it being built that way?

ISTM the fix below should not be required
- and the problem lies in something being built with -mdynamic-no-pic  
or similar


- that is what we should fix.
cheers
Iain



on x86_64-apple-darwin11 due to the -pie linker default. The  
attached patch
uses -fno-pie on darwin to insure that -no_pie is passed to the  
linker when
targeting darwin11 or later. This approach is used because istarget  
doesn't
support complex regex to allow -Wl,-no_pie to be passed for darwin11  
and later
only (since only recent Xcode releases understand the -no_pie linker  
option).
Also, -fno_pie has the advantage of supporting -mmacosx-version-min  
usage.

Regression tested on x86_64-apple-darwin11...

http://gcc.gnu.org/ml/gcc-testresults/2011-12/msg00856.html

Okay for gcc trunk?
Jack


boehm-gc/

2011-12-08  Jack Howarth 

   * testsuite/lib/boehm-gc.exp: Use -fno-pie on darwin.

Index: boehm-gc/testsuite/lib/boehm-gc.exp
===
--- boehm-gc/testsuite/lib/boehm-gc.exp (revision 182117)
+++ boehm-gc/testsuite/lib/boehm-gc.exp (working copy)
@@ -214,6 +214,11 @@ proc boehm-gc_target_compile { source de
lappend options "additional_flags=-I${gc_include} -I${srcdir}/../ 
include"

lappend options "additional_flags=${threadcflags}"

+# Disable -pie linker default for darwin11 and later using -fno- 
pie.

+if { [istarget *-*-darwin*] } {
+   lappend options "additional_flags=-fno-pie"
+}
+
lappend options "libs=-Wc,-shared-libgcc"

if { [file extension $dest] == ".la" } {




Re: [Patch, i386] [4.6] Backport movd*_internal_rex64 fix from trunk and [4.6/4.7] add testcase

2011-12-08 Thread Uros Bizjak
On Thu, Dec 8, 2011 at 3:23 PM, Teresa Johnson  wrote:
> Sounds good. I will fix the 4.7 version to use the fpie target
> selector. The other thing I noticed is that you had removed the
> -Wwrite-strings option, but I needed to keep that as it was the
> combination of -fPIE and -Wwrite-strings that triggered the bug.

No, the testacase ICEes also without -Wwrite-strings on unpatched gcc.
It is a warning option.

Uros.


Re: [PATCH] use -fno-pie on darwin in boehm-gc.exp

2011-12-08 Thread Mike Stump
On Dec 8, 2011, at 7:38 AM, Jack Howarth  wrote:
> Currently the boehm-gc testsuite fails...
> 
> FAIL: boehm-gc.c/gctest.c -O2 execution test
> FAIL: boehm-gc.c/leak_test.c -O2 execution test
> FAIL: boehm-gc.c/thread_leak_test.c -O2 execution test
> FAIL: boehm-gc.lib/staticrootstest.c -O2 execution test

> Okay for gcc trunk?

Ok.


Re: [PATCH] use -fno-pie on darwin in boehm-gc.exp

2011-12-08 Thread Rainer Orth
Iain Sandoe  writes:

> On 8 Dec 2011, at 15:38, Jack Howarth wrote:
>
>> Currently the boehm-gc testsuite fails...
>>
>> FAIL: boehm-gc.c/gctest.c -O2 execution test
>> FAIL: boehm-gc.c/leak_test.c -O2 execution test
>> FAIL: boehm-gc.c/thread_leak_test.c -O2 execution test
>> FAIL: boehm-gc.lib/staticrootstest.c -O2 execution test
>
> you have not answered these questions:
>
> a) "what is anything being built in these tests which is not PIC"?
> b) and why is it being built that way?
>
> ISTM the fix below should not be required
> - and the problem lies in something being built with -mdynamic-no-pic or
> similar
>
> - that is what we should fix.

Agreed.  We shouldn't spread target-specific code like this all over the
testsuite.

Rainer

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


Re: [Patch, i386] [4.6] Backport movd*_internal_rex64 fix from trunk and [4.6/4.7] add testcase

2011-12-08 Thread Teresa Johnson
Interesting - with our internal compiler version it only triggered
with the 2 options combined, not sure why. But I just verified that on
the gcc 4.6 branch it only needed the -fPIE option. Sorry about that,
I will remove the -W option from the test case.

Teresa

On Thu, Dec 8, 2011 at 8:23 AM, Uros Bizjak  wrote:
> On Thu, Dec 8, 2011 at 3:23 PM, Teresa Johnson  wrote:
>> Sounds good. I will fix the 4.7 version to use the fpie target
>> selector. The other thing I noticed is that you had removed the
>> -Wwrite-strings option, but I needed to keep that as it was the
>> combination of -fPIE and -Wwrite-strings that triggered the bug.
>
> No, the testacase ICEes also without -Wwrite-strings on unpatched gcc.
> It is a warning option.
>
> Uros.



-- 
Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413


[PATCH v2] _GCC_PICFLAG: use -fPIC for s390x targets

2011-12-08 Thread Mike Frysinger
Building newer libiberty for s390x targets fails with relocation errors:
libiberty/pic/libiberty.a(hashtab.o): In function 'htab_create':
libiberty/hashtab.c:408:(.text+0x5e4): relocation truncated to fit:
R_390_GOT12 against symbol 'xcalloc' defined in .text section in
libiberty/pic/libiberty.a(xmalloc.o)
libiberty/pic/libiberty.a(hashtab.o): In function 'htab_try_create':
libiberty/hashtab.c:414:(.text+0x61c): relocation truncated to fit:
R_390_GOT12 against symbol 'calloc@@GLIBC_2.2' defined in .text
section in /lib/libc.so.6
collect2: ld returned 1 exit status

Building with larger GOT (-fPIC rather than -fpic) fixes this.

CC: Aurelien Jarno 
CC: Martin Schwidefsky 
Signed-off-by: Mike Frysinger 

config/:
2011-12-06  Mike Frysinger  

* picflag.m4 (_GCC_PICFLAG): Set $1 to -fPIC for s390x*-*-*.

gcc/:
libada/:
libgcc/:
libiberty/:
2011-12-06  Mike Frysinger  

* configure: Regenerate.
---
v2
- fix typo when porting patch from older binutils

 config/picflag.m4 |3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/config/picflag.m4 b/config/picflag.m4
index f6f1b44..b871d99 100644
--- a/config/picflag.m4
+++ b/config/picflag.m4
@@ -51,6 +51,9 @@ case "${$2}" in
 m68k-*-*)
$1=-fpic
;;
+s390x*-*-*)
+   $1=-fPIC
+   ;;
 s390*-*-*)
$1=-fpic
;;
-- 
1.7.6.1



Re: [Patch, i386] [4.6] Backport movd*_internal_rex64 fix from trunk and [4.6/4.7] add testcase

2011-12-08 Thread Uros Bizjak
On Thu, Dec 8, 2011 at 5:30 PM, Teresa Johnson  wrote:
> Interesting - with our internal compiler version it only triggered
> with the 2 options combined, not sure why. But I just verified that on
> the gcc 4.6 branch it only needed the -fPIE option. Sorry about that,
> I will remove the -W option from the test case.

Please also remove unused label, gcc ICEs without it.

Uros.


Re: [PATCH v2] _GCC_PICFLAG: use -fPIC for s390x targets

2011-12-08 Thread Rainer Orth
Mike Frysinger  writes:

> Building newer libiberty for s390x targets fails with relocation errors:
>   libiberty/pic/libiberty.a(hashtab.o): In function 'htab_create':
>   libiberty/hashtab.c:408:(.text+0x5e4): relocation truncated to fit:
>   R_390_GOT12 against symbol 'xcalloc' defined in .text section in
>   libiberty/pic/libiberty.a(xmalloc.o)
>   libiberty/pic/libiberty.a(hashtab.o): In function 'htab_try_create':
>   libiberty/hashtab.c:414:(.text+0x61c): relocation truncated to fit:
>   R_390_GOT12 against symbol 'calloc@@GLIBC_2.2' defined in .text
>   section in /lib/libc.so.6
>   collect2: ld returned 1 exit status
>
> Building with larger GOT (-fPIC rather than -fpic) fixes this.

Unfortunately, you mostly ignored my review comments on the previous
version.

Rainer

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


Re: [PATCH] use -fno-pie on darwin in boehm-gc.exp

2011-12-08 Thread Jack Howarth
On Thu, Dec 08, 2011 at 03:54:35PM +, Iain Sandoe wrote:
>
> On 8 Dec 2011, at 15:38, Jack Howarth wrote:
>
>> Currently the boehm-gc testsuite fails...
>>
>> FAIL: boehm-gc.c/gctest.c -O2 execution test
>> FAIL: boehm-gc.c/leak_test.c -O2 execution test
>> FAIL: boehm-gc.c/thread_leak_test.c -O2 execution test
>> FAIL: boehm-gc.lib/staticrootstest.c -O2 execution test
>
> you have not answered these questions:
>
> a) "what is anything being built in these tests which is not PIC"?
> b) and why is it being built that way?
>
> ISTM the fix below should not be required
> - and the problem lies in something being built with -mdynamic-no-pic or 
> similar

Nothing in boehm-gc is built non-PIC (see the attached log for boehm-gc).
Likewise nothing in the testsuite is built non-PIC. For example, gctest.c
at -O2 is built, according to -v, as...

 /sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/cc1 -quiet -v -I 
/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64-apple-darwin11.2.0/./boehm-gc/include
 -I 
/sw/src/fink.build/gcc47-4.7.0-1/gcc-4.7-20111207/boehm-gc/testsuite/../include 
-iprefix 
/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/../lib/gcc/x86_64-apple-darwin11.2.0/4.7.0/
 -isystem /sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/include -isystem 
/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/include-fixed -D__DYNAMIC__ 
/sw/src/fink.build/gcc47-4.7.0-1/gcc-4.7-20111207/boehm-gc/testsuite/boehm-gc.c/gctest.c
 -fPIC -quiet -dumpbase gctest.c -mmacosx-version-min=10.7.2 -mtune=core2 
-auxbase gctest -O2 -version -o /var/tmp//ccgHCNRC.s

The test is also just linked to the the libgcjgcj built in boehm-gc...

/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/collect-ld -dynamic -arch 
x86_64 -macosx_version_min 10.7.2 -weak_reference_mismatches non-weak -o 
./.libs/gctest -lcrt1.10.6.o 
-L/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc /var/tmp//ccb3OaQl.o 
/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64-apple-darwin11.2.0/./boehm-gc/.libs/libgcjgc.dylib
 -no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v

so the build in boehm-gc appears to be self-contained.

>
> - that is what we should fix.
> cheers
> Iain
>
>>
>> on x86_64-apple-darwin11 due to the -pie linker default. The attached 
>> patch
>> uses -fno-pie on darwin to insure that -no_pie is passed to the linker 
>> when
>> targeting darwin11 or later. This approach is used because istarget  
>> doesn't
>> support complex regex to allow -Wl,-no_pie to be passed for darwin11  
>> and later
>> only (since only recent Xcode releases understand the -no_pie linker  
>> option).
>> Also, -fno_pie has the advantage of supporting -mmacosx-version-min  
>> usage.
>> Regression tested on x86_64-apple-darwin11...
>>
>> http://gcc.gnu.org/ml/gcc-testresults/2011-12/msg00856.html
>>
>> Okay for gcc trunk?
>> Jack
>>
>>
>> boehm-gc/
>>
>> 2011-12-08  Jack Howarth 
>>
>>* testsuite/lib/boehm-gc.exp: Use -fno-pie on darwin.
>>
>> Index: boehm-gc/testsuite/lib/boehm-gc.exp
>> ===
>> --- boehm-gc/testsuite/lib/boehm-gc.exp  (revision 182117)
>> +++ boehm-gc/testsuite/lib/boehm-gc.exp  (working copy)
>> @@ -214,6 +214,11 @@ proc boehm-gc_target_compile { source de
>> lappend options "additional_flags=-I${gc_include} -I${srcdir}/../ 
>> include"
>> lappend options "additional_flags=${threadcflags}"
>>
>> +# Disable -pie linker default for darwin11 and later using -fno- 
>> pie.
>> +if { [istarget *-*-darwin*] } {
>> +lappend options "additional_flags=-fno-pie"
>> +}
>> +
>> lappend options "libs=-Wc,-shared-libgcc"
>>
>> if { [file extension $dest] == ".la" } {


boehm-gc.log.bz2
Description: BZip2 compressed data


Re: [Patch, i386] [4.6] Backport movd*_internal_rex64 fix from trunk and [4.6/4.7] add testcase

2011-12-08 Thread Teresa Johnson
Verified and changed.

Thanks!
Teresa

On Thu, Dec 8, 2011 at 8:43 AM, Uros Bizjak  wrote:
> On Thu, Dec 8, 2011 at 5:30 PM, Teresa Johnson  wrote:
>> Interesting - with our internal compiler version it only triggered
>> with the 2 options combined, not sure why. But I just verified that on
>> the gcc 4.6 branch it only needed the -fPIE option. Sorry about that,
>> I will remove the -W option from the test case.
>
> Please also remove unused label, gcc ICEs without it.
>
> Uros.



-- 
Teresa Johnson | Software Engineer | tejohn...@google.com | 408-460-2413


Re: [PATCH] use -fno-pie on darwin in boehm-gc.exp

2011-12-08 Thread Iain Sandoe


On 8 Dec 2011, at 16:58, Jack Howarth wrote:


On Thu, Dec 08, 2011 at 03:54:35PM +, Iain Sandoe wrote:


On 8 Dec 2011, at 15:38, Jack Howarth wrote:


Currently the boehm-gc testsuite fails...

FAIL: boehm-gc.c/gctest.c -O2 execution test
FAIL: boehm-gc.c/leak_test.c -O2 execution test
FAIL: boehm-gc.c/thread_leak_test.c -O2 execution test
FAIL: boehm-gc.lib/staticrootstest.c -O2 execution test


you have not answered these questions:

a) "what is anything being built in these tests which is not PIC"?
b) and why is it being built that way?

ISTM the fix below should not be required
- and the problem lies in something being built with -mdynamic-no- 
pic or

similar


Nothing in boehm-gc is built non-PIC (see the attached log for boehm- 
gc).
Likewise nothing in the testsuite is built non-PIC. For example,  
gctest.c

at -O2 is built, according to -v, as...

/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/cc1 -quiet -v -I / 
sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64-apple- 
darwin11.2.0/./boehm-gc/include -I /sw/src/fink.build/gcc47-4.7.0-1/ 
gcc-4.7-20111207/boehm-gc/testsuite/../include -iprefix /sw/src/ 
fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/../lib/gcc/x86_64-apple- 
darwin11.2.0/4.7.0/ -isystem /sw/src/fink.build/gcc47-4.7.0-1/ 
darwin_objdir/gcc/include -isystem /sw/src/fink.build/gcc47-4.7.0-1/ 
darwin_objdir/gcc/include-fixed -D__DYNAMIC__ /sw/src/fink.build/ 
gcc47-4.7.0-1/gcc-4.7-20111207/boehm-gc/testsuite/boehm-gc.c/ 
gctest.c -fPIC -quiet -dumpbase gctest.c -mmacosx-version-min=10.7.2  
-mtune=core2 -auxbase gctest -O2 -version -o /var/tmp//ccgHCNRC.s


The test is also just linked to the the libgcjgcj built in boehm-gc...

/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/collect-ld - 
dynamic -arch x86_64 -macosx_version_min 10.7.2 - 
weak_reference_mismatches non-weak -o ./.libs/gctest -lcrt1.10.6.o - 
L/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc /var/tmp// 
ccb3OaQl.o /sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64- 
apple-darwin11.2.0/./boehm-gc/.libs/libgcjgc.dylib - 
no_compact_unwind -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v


so the build in boehm-gc appears to be self-contained.


OK- so it appears ...
... so why is ld complaining that there's non-PIC code present?

if it's a tool bug, then we should XFAIL the tests ...

cheers
Iain


- that is what we should fix.
cheers
Iain



on x86_64-apple-darwin11 due to the -pie linker default. The  
attached

patch
uses -fno-pie on darwin to insure that -no_pie is passed to the  
linker

when
targeting darwin11 or later. This approach is used because istarget
doesn't
support complex regex to allow -Wl,-no_pie to be passed for darwin11
and later
only (since only recent Xcode releases understand the -no_pie linker
option).
Also, -fno_pie has the advantage of supporting -mmacosx-version-min
usage.
Regression tested on x86_64-apple-darwin11...

http://gcc.gnu.org/ml/gcc-testresults/2011-12/msg00856.html

Okay for gcc trunk?
   Jack


boehm-gc/

2011-12-08  Jack Howarth 

  * testsuite/lib/boehm-gc.exp: Use -fno-pie on darwin.

Index: boehm-gc/testsuite/lib/boehm-gc.exp
===
--- boehm-gc/testsuite/lib/boehm-gc.exp (revision 182117)
+++ boehm-gc/testsuite/lib/boehm-gc.exp (working copy)
@@ -214,6 +214,11 @@ proc boehm-gc_target_compile { source de
   lappend options "additional_flags=-I${gc_include} -I${srcdir}/../
include"
   lappend options "additional_flags=${threadcflags}"

+# Disable -pie linker default for darwin11 and later using - 
fno-

pie.
+if { [istarget *-*-darwin*] } {
+   lappend options "additional_flags=-fno-pie"
+}
+
   lappend options "libs=-Wc,-shared-libgcc"

   if { [file extension $dest] == ".la" } {






Re: Add __stpncpy_chk builtin support

2011-12-08 Thread Romain Geissler
Le 28 nov. 2011 à 12:16, Romain Geissler a écrit :

> Hi,
> 
> The current trunk have no support for the __stpncpy_chk function. As the 
> latest
> OS X (10.7 aka Lion) now defines stpncpy as a call to builtin__stpncpy_chk for
> GNUC compliant compiler, the following code won't link:
> 
> #include 
> 
> int main(){
>   char string[10];
>   stpncpy(string,"abcd",8);
> 
>   return 0;
> }
> 
> Undefined symbols for architecture x86_64:
>  "___builtin___stpncpy_chk", referenced from:
>  _main in ccGFZoZV.o
> ld: symbol(s) not found for architecture x86_64
> collect2: error: ld returned 1 exit status
> 
> 
> This patch add support for this builtin.
> Bootstrapped and tested without regression on darwin x86_64.
> 
> Romain Geissler
> 
> gcc/
> 
> 2011-11-28  Romain Geissler  
> 
>   * builtins.def (BUILT_IN_STPNCPY_CHK): New definition.
>   * builtins.c (expand_builtin, fold_builtin_4, maybe_emit_chk_warning):
>   Add BUILT_IN_STPNCPY_CHK case.
>   * gimple-fold.c (gimple_fold_builtin): Likewise.
>   * tree-object-size.c (pass_through_call): Likewise.
>   * tree-ssa-alias.c (ref_maybe_used_by_call_p_1,
>   call_may_clobber_ref_p_1): Likewise.
>   * tree-ssa-structalias.c (find_func_aliases_for_builtin_call,
>   find_func_clobbers): Likewise.
>   * tree.h (fold_builtin_strncpy_chk): Rename to fold_builtin_stxncpy_chk
>   * builtins.c (fold_builtin_strncpy_chk): Likewise.
>   Rewrite stpncpy_chk calls to strncpy_chk calls if returned value is
>   ignored.
> 
> gcc/testsuite/
> 
> 2011-11-28  Romain Geissler  
> 
>   * gcc.c-torture/execute/builtins/chk.h (stpncpy, stpncpy_disallowed):
>   New definitions.
>   * gcc.c-torture/execute/builtins/lib/chk.c (stpncpy_disallowed):
>   Likewise.
>   (stpncpy, __stpncpy_chk): New functions.
>   * gcc.c-torture/execute/builtins/stpncpy-chk-lib.c: New file.
>   * gcc.c-torture/execute/builtins/stpncpy-chk.c: Likewise.
> 
> 

Ping


Re: [PATCH] use -fno-pie on darwin in boehm-gc.exp

2011-12-08 Thread Jack Howarth
On Thu, Dec 08, 2011 at 05:05:12PM +, Iain Sandoe wrote:
>
> On 8 Dec 2011, at 16:58, Jack Howarth wrote:
>
>> On Thu, Dec 08, 2011 at 03:54:35PM +, Iain Sandoe wrote:
>>>
>>> On 8 Dec 2011, at 15:38, Jack Howarth wrote:
>>>
 Currently the boehm-gc testsuite fails...

 FAIL: boehm-gc.c/gctest.c -O2 execution test
 FAIL: boehm-gc.c/leak_test.c -O2 execution test
 FAIL: boehm-gc.c/thread_leak_test.c -O2 execution test
 FAIL: boehm-gc.lib/staticrootstest.c -O2 execution test
>>>
>>> you have not answered these questions:
>>>
>>> a) "what is anything being built in these tests which is not PIC"?
>>> b) and why is it being built that way?
>>>
>>> ISTM the fix below should not be required
>>> - and the problem lies in something being built with -mdynamic-no- 
>>> pic or
>>> similar
>>
>> Nothing in boehm-gc is built non-PIC (see the attached log for boehm- 
>> gc).
>> Likewise nothing in the testsuite is built non-PIC. For example,  
>> gctest.c
>> at -O2 is built, according to -v, as...
>>
>> /sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/cc1 -quiet -v -I / 
>> sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64-apple- 
>> darwin11.2.0/./boehm-gc/include -I /sw/src/fink.build/gcc47-4.7.0-1/ 
>> gcc-4.7-20111207/boehm-gc/testsuite/../include -iprefix /sw/src/ 
>> fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/../lib/gcc/x86_64-apple- 
>> darwin11.2.0/4.7.0/ -isystem /sw/src/fink.build/gcc47-4.7.0-1/ 
>> darwin_objdir/gcc/include -isystem /sw/src/fink.build/gcc47-4.7.0-1/ 
>> darwin_objdir/gcc/include-fixed -D__DYNAMIC__ /sw/src/fink.build/ 
>> gcc47-4.7.0-1/gcc-4.7-20111207/boehm-gc/testsuite/boehm-gc.c/gctest.c 
>> -fPIC -quiet -dumpbase gctest.c -mmacosx-version-min=10.7.2  
>> -mtune=core2 -auxbase gctest -O2 -version -o /var/tmp//ccgHCNRC.s
>>
>> The test is also just linked to the the libgcjgcj built in boehm-gc...
>>
>> /sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/collect-ld -dynamic 
>> -arch x86_64 -macosx_version_min 10.7.2 -weak_reference_mismatches 
>> non-weak -o ./.libs/gctest -lcrt1.10.6.o - 
>> L/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc /var/tmp// 
>> ccb3OaQl.o /sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64- 
>> apple-darwin11.2.0/./boehm-gc/.libs/libgcjgc.dylib -no_compact_unwind 
>> -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v
>>
>> so the build in boehm-gc appears to be self-contained.
>
> OK- so it appears ...
> ... so why is ld complaining that there's non-PIC code present?

Where do you see ld complaining of non-PIC code?

Running target unix
Using /sw/share/dejagnu/baseboards/unix.exp as board description file for 
target.
Using /sw/share/dejagnu/config/unix.exp as generic interface file for target.
Using 
/sw/src/fink.build/gcc47-4.7.0-1/gcc-4.7-20111207/boehm-gc/testsuite/config/default.exp
 as tool-and-target-specific interface file.
Running 
/sw/src/fink.build/gcc47-4.7.0-1/gcc-4.7-20111207/boehm-gc/testsuite/boehm-gc.c/c.exp
 ...
set_ld_library_path_env_vars: 
ld_library_path=.:/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc:/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64-apple-darwin11.2.0/./boehm-gc/.libs:.libs
Executing on host: ../libtool --silent --tag=CC --mode=link  
/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/xgcc 
-B/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/ 
/sw/src/fink.build/gcc47-4.7.0-1/gcc-4.7-20111207/boehm-gc/testsuite/boehm-gc.c/gctest.c
 
/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64-apple-darwin11.2.0/./boehm-gc/libgcjgc.la
  -O2  
-I/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64-apple-darwin11.2.0/./boehm-gc/include
 
-I/sw/src/fink.build/gcc47-4.7.0-1/gcc-4.7-20111207/boehm-gc/testsuite/../include
   -Wc,-shared-libgcc -lpthread -lm   -o ./gctest(timeout = 300)
PASS: boehm-gc.c/gctest.c -O2 (test for excess errors)
Setting LD_LIBRARY_PATH to 
.:/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc:/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64-apple-darwin11.2.0/./boehm-gc/.libs:.libs:.:/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc:/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64-apple-darwin11.2.0/./boehm-gc/.libs:.libs
FAIL: boehm-gc.c/gctest.c -O2 execution test

which shows no warnings...

../libtool --silent --tag=CC --mode=link  
/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/xgcc 
-B/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/ 
/sw/src/fink.build/gcc47-4.7.0-1/gcc-4.7-20111207/boehm-gc/testsuite/boehm-gc.c/gctest.c
 
/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64-apple-darwin11.2.0/./boehm-gc/libgcjgc.la
  -O2  
-I/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64-apple-darwin11.2.0/./boehm-gc/include
 
-I/sw/src/fink.build/gcc47-4.7.0-1/gcc-4.7-20111207/boehm-gc/testsuite/../include
   -Wc,-shared-libgcc -lpthread -lm  -v  -o ./gctest
Reading specs from /sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/specs
COLLECT_GCC=/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/xgcc
COLLECT_LTO_WRAPPER=/sw/src/fink.build/gcc47-4.7.0-

Re: [PATCH] use -fno-pie on darwin in boehm-gc.exp

2011-12-08 Thread Iain Sandoe


On 8 Dec 2011, at 17:24, Jack Howarth wrote:


On Thu, Dec 08, 2011 at 05:05:12PM +, Iain Sandoe wrote:


On 8 Dec 2011, at 16:58, Jack Howarth wrote:


On Thu, Dec 08, 2011 at 03:54:35PM +, Iain Sandoe wrote:


On 8 Dec 2011, at 15:38, Jack Howarth wrote:


Currently the boehm-gc testsuite fails...

FAIL: boehm-gc.c/gctest.c -O2 execution test
FAIL: boehm-gc.c/leak_test.c -O2 execution test
FAIL: boehm-gc.c/thread_leak_test.c -O2 execution test
FAIL: boehm-gc.lib/staticrootstest.c -O2 execution test


you have not answered these questions:

a) "what is anything being built in these tests which is not PIC"?
b) and why is it being built that way?

ISTM the fix below should not be required
- and the problem lies in something being built with -mdynamic-no-
pic or
similar


Nothing in boehm-gc is built non-PIC (see the attached log for  
boehm-

gc).
Likewise nothing in the testsuite is built non-PIC. For example,
gctest.c
at -O2 is built, according to -v, as...

/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/cc1 -quiet -v - 
I /

sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64-apple-
darwin11.2.0/./boehm-gc/include -I /sw/src/fink.build/gcc47-4.7.0-1/
gcc-4.7-20111207/boehm-gc/testsuite/../include -iprefix /sw/src/
fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/../lib/gcc/x86_64-apple-
darwin11.2.0/4.7.0/ -isystem /sw/src/fink.build/gcc47-4.7.0-1/
darwin_objdir/gcc/include -isystem /sw/src/fink.build/gcc47-4.7.0-1/
darwin_objdir/gcc/include-fixed -D__DYNAMIC__ /sw/src/fink.build/
gcc47-4.7.0-1/gcc-4.7-20111207/boehm-gc/testsuite/boehm-gc.c/ 
gctest.c

-fPIC -quiet -dumpbase gctest.c -mmacosx-version-min=10.7.2
-mtune=core2 -auxbase gctest -O2 -version -o /var/tmp//ccgHCNRC.s

The test is also just linked to the the libgcjgcj built in boehm- 
gc...


/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/collect-ld - 
dynamic

-arch x86_64 -macosx_version_min 10.7.2 -weak_reference_mismatches
non-weak -o ./.libs/gctest -lcrt1.10.6.o -
L/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc /var/tmp//
ccb3OaQl.o /sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64-
apple-darwin11.2.0/./boehm-gc/.libs/libgcjgc.dylib - 
no_compact_unwind

-lSystem -lgcc_ext.10.5 -lgcc -lSystem -v

so the build in boehm-gc appears to be self-contained.


OK- so it appears ...
... so why is ld complaining that there's non-PIC code present?


Where do you see ld complaining of non-PIC code?


OK.  Different problem - I recalled that there were [PIE] issues with  
ld complaining.


.. if  PIE is fundamentally incompatible with boehm-gc (is it??) -  
then, right, we need to make sure it's off -


-  presumably it's not affecting any other target - because they don't  
do PIE unless told to ...


Perhaps it would be better to adjust the spec that you made (and has  
been applied) to ensure that -no_pie is passed to the linker  *unless*  
pie is explicitly given on the c/l?


At present, you pass it when "no-pic, no-pie" etc. are - perhaps it  
should just be the default and *only* switched on for -pie something  
like


 %{!fpie: %{!PIE: %:version-compare(>= 10.7 mmacosx-version-min= - 
no_pie) } }


Otherwise, D11 is behaving differently from other targets for the  
whole test-suite - not just boehm-gc.


cheers
Iain




Re: Add __stpncpy_chk builtin support

2011-12-08 Thread Jakub Jelinek
On Mon, Nov 28, 2011 at 12:16:52PM +0100, Romain Geissler wrote:
> 2011-11-28  Romain Geissler  
> 
>   * builtins.def (BUILT_IN_STPNCPY_CHK): New definition.
>   * builtins.c (expand_builtin, fold_builtin_4, maybe_emit_chk_warning):
>   Add BUILT_IN_STPNCPY_CHK case.
>   * gimple-fold.c (gimple_fold_builtin): Likewise.
>   * tree-object-size.c (pass_through_call): Likewise.
>   * tree-ssa-alias.c (ref_maybe_used_by_call_p_1,
>   call_may_clobber_ref_p_1): Likewise.
>   * tree-ssa-structalias.c (find_func_aliases_for_builtin_call,
>   find_func_clobbers): Likewise.
>   * tree.h (fold_builtin_strncpy_chk): Rename to fold_builtin_stxncpy_chk
>   * builtins.c (fold_builtin_strncpy_chk): Likewise.
>   Rewrite stpncpy_chk calls to strncpy_chk calls if returned value is
>   ignored.
> 
> gcc/testsuite/
> 
> 2011-11-28  Romain Geissler  
> 
>   * gcc.c-torture/execute/builtins/chk.h (stpncpy, stpncpy_disallowed):
>   New definitions.
>   * gcc.c-torture/execute/builtins/lib/chk.c (stpncpy_disallowed):
>   Likewise.
>   (stpncpy, __stpncpy_chk): New functions.
>   * gcc.c-torture/execute/builtins/stpncpy-chk-lib.c: New file.
>   * gcc.c-torture/execute/builtins/stpncpy-chk.c: Likewise.
> 

This is ok for trunk, if you fix formatting nits mentioned below:

@@ -10910,7 +10911,8 @@ fold_builtin_4 (location_t loc, tree fndecl,
  DECL_FUNCTION_CODE (fndecl));
 
 case BUILT_IN_STRNCPY_CHK:
-  return fold_builtin_strncpy_chk (loc, arg0, arg1, arg2, arg3, NULL_TREE);
+case BUILT_IN_STPNCPY_CHK:
+  return fold_builtin_stxncpy_chk (loc, arg0, arg1, arg2, arg3, NULL_TREE, 
ignore, fcode);

Please watch formatting, this line is too long.
 
 case BUILT_IN_STRNCAT_CHK:
   return fold_builtin_strncat_chk (loc, fndecl, arg0, arg1, arg2, arg3);
@@ -12863,8 +12877,9 @@ fold_builtin_strncpy_chk (location_t loc, tree dest, 
tree src,
return NULL_TREE;
 }
 
-  /* If __builtin_strncpy_chk is used, assume strncpy is available.  */
-  fn = builtin_decl_explicit (BUILT_IN_STRNCPY);
+  /* If __builtin_st{r,p}ncpy_chk is used, assume st{r,p}ncpy is available.  */
+  fn = builtin_decl_explicit (fcode == BUILT_IN_STPNCPY_CHK
+ ? BUILT_IN_STPNCPY : BUILT_IN_STRNCPY);

"? BUILT_IN_STPNCPY" needs to be below "fcode == " on the previous line.

+   result = fold_builtin_stxncpy_chk (loc, gimple_call_arg (stmt, 0),
gimple_call_arg (stmt, 1),
gimple_call_arg (stmt, 2),
gimple_call_arg (stmt, 3),
-  val[2]);
+  val[2],
+  ignore,
+ DECL_FUNCTION_CODE (callee));

Please put ignore, on the same line as val[2], and align DECL_FUNCTION_CODE
properly below val[2].

--- gcc/tree.h
+++ gcc/tree.h
@@ -5444,7 +5444,8 @@ extern tree fold_builtin_memory_chk (location_t, tree, 
tree, tree, tree, tree, t
 enum built_in_function);
 extern tree fold_builtin_stxcpy_chk (location_t, tree, tree, tree, tree, tree, 
bool,
 enum built_in_function);
-extern tree fold_builtin_strncpy_chk (location_t, tree, tree, tree, tree, 
tree);
+extern tree fold_builtin_stxncpy_chk (location_t, tree, tree, tree, tree, 
tree, bool,
+enum built_in_function);

"enum " should be aligned below "location_t,".

Jakub


[Patch,AVR]: Fix PR51425

2011-12-08 Thread Georg-Johann Lay
This is obvious patch for PR51425: SBIC/SBRC instructions are generated by insn
combine, but insn combine tries zero_extract:QI not zero_extract:HI as  in good
old times.

Thus, use QIHI iterator.

Besides fixing this optimization flaw, it enables other developers to reproduce
PR51374:  If the pattern is question don't match, PR51374 won't show up in 4.7.

Ok for trunk?

Johann

PR target/51425
* config/avr/avr.md (config/avr/avr.md, *sbix_branch_tmp): Use
zero_extract:QIHI instead of zero_extract:HI.
Index: config/avr/avr.md
===
--- config/avr/avr.md	(revision 182106)
+++ config/avr/avr.md	(working copy)
@@ -4699,7 +4699,7 @@ (define_insn "*sbix_branch"
   [(set (pc)
 	(if_then_else
 	 (match_operator 0 "eqne_operator"
-			 [(zero_extract:HI
+			 [(zero_extract:QIHI
 			   (mem:QI (match_operand 1 "low_io_address_operand" "n"))
 			   (const_int 1)
 			   (match_operand 2 "const_int_operand" "n"))
@@ -4746,7 +4746,7 @@ (define_insn "*sbix_branch_tmp"
   [(set (pc)
 	(if_then_else
 	 (match_operator 0 "eqne_operator"
-			 [(zero_extract:HI
+			 [(zero_extract:QIHI
 			   (mem:QI (match_operand 1 "high_io_address_operand" "n"))
 			   (const_int 1)
 			   (match_operand 2 "const_int_operand" "n"))


Re: [PATCH] Implement stap probe on ARM's unwinder

2011-12-08 Thread Sergio Durigan Junior
Sergio Durigan Junior  writes:

> Bernd Schmidt  writes:
>
>> On 12/01/11 13:01, Ramana Radhakrishnan wrote:
>>> Sergio: Other than a few minor tweaks to the Changelog it largely
>>> looks obvious to me.
>>> 
>>> Bernd, could you take another look at this since this is now shared
>>> with the c6x backend ?
>>
>> Doesn't look like it would cause problems. I have no idea what
>> builtin_frob_return_addr does but it appears to exist everywhere.
>
> Thanks for the reviews.  I guess I'll leave the call to
> builtin_frob_return_addr there.  So, after addressing Ramana's
> suggestions to ChangeLog, is this patch OK to go in?

Ping.


Re: [4.7][google] Adding a new option -fstack-protector-strong. (issue5461043)

2011-12-08 Thread 沈涵
Hi, Andrew and Richard, check via referenced vars is much easier, thanks!

Updated patches attached at EOM, also uploaded to
http://codereview.appspot.com/5461043

Hi, Diego, that's good suggestion. I'm glad to send this for trunk at
the next stage 1.

-Han

Updated patches 
diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 8684721..ae76441 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -1507,15 +1507,34 @@ estimated_stack_frame_size (struct cgraph_node *node)
   return size;
 }

+/* Helper routine to check if a record or union contains an array field. */
+
+static int record_or_union_type_has_array(tree tree_type) {
+  tree fields = TYPE_FIELDS(tree_type);
+  tree f;
+  for (f = fields; f; f = DECL_CHAIN (f)) {
+if (TREE_CODE(f) == FIELD_DECL) {
+  tree field_type = TREE_TYPE(f);
+  if (RECORD_OR_UNION_TYPE_P(field_type))
+return record_or_union_type_has_array(field_type);
+  if (TREE_CODE(field_type) == ARRAY_TYPE)
+return 1;
+}
+  }
+  return 0;
+}
+
 /* Expand all variables used in the function.  */

 static void
 expand_used_vars (void)
 {
   tree var, outer_block = DECL_INITIAL (current_function_decl);
+  referenced_var_iterator rvi;
   VEC(tree,heap) *maybe_local_decls = NULL;
   unsigned i;
   unsigned len;
+  int gen_stack_protect_signal = 0;

   /* Compute the phase of the stack frame for this function.  */
   {
@@ -1548,6 +1567,20 @@ expand_used_vars (void)
}
 }

+  FOR_EACH_REFERENCED_VAR(DECL_STRUCT_FUNCTION(current_function_decl),
var, rvi)
+if (!is_global_var(var) && TREE_ADDRESSABLE(var))
+  ++gen_stack_protect_signal;
+
+  /* Examine local variable declaration. */
+  if (!gen_stack_protect_signal)
+FOR_EACH_LOCAL_DECL (cfun, i, var)
+  if (TREE_CODE(var) == VAR_DECL && !is_global_var(var)) {
+tree var_type = TREE_TYPE(var);
+gen_stack_protect_signal += (TREE_CODE(var_type) == ARRAY_TYPE) ||
+  (RECORD_OR_UNION_TYPE_P(var_type) &&
+   record_or_union_type_has_array(var_type));
+  }
+
   /* At this point all variables on the local_decls with TREE_USED
  set are not associated with any block scope.  Lay them out.  */

@@ -1640,9 +1673,13 @@ expand_used_vars (void)

   /* There are several conditions under which we should create a
  stack guard: protect-all, alloca used, protected decls present.  */
-  if (flag_stack_protect == 2
-  || (flag_stack_protect
- && (cfun->calls_alloca || has_protected_decls)))
+  if (flag_stack_protect == 2 /* -fstack-protector-all */
+  || (flag_stack_protect == 1 /* -fstack-protector */
+ && (cfun->calls_alloca || has_protected_decls))) {
+create_stack_guard ();
+  } else if (flag_stack_protect == 3 && /* -fstack-protector-strong */
+ (gen_stack_protect_signal ||
+  cfun->calls_alloca || has_protected_decls))
 create_stack_guard ();

   /* Assign rtl to each variable based on these partitions.  */
diff --git a/gcc/common.opt b/gcc/common.opt
index 55d3f2d..1ad9717 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1848,6 +1848,10 @@ fstack-protector-all
 Common Report RejectNegative Var(flag_stack_protect, 2)
 Use a stack protection method for every function

+fstack-protector-strong
+Common Report RejectNegative Var(flag_stack_protect, 3)
+Use a smart stack protection method for certain functions
+
 fstack-usage
 Common RejectNegative Var(flag_stack_usage)
 Output stack usage information on a per-function basis
diff --git a/gcc/testsuite/gcc.dg/fstack-protector-strong.c
b/gcc/testsuite/gcc.dg/fstack-protector-strong.c
new file mode 100644
index 000..44225f5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fstack-protector-strong.c
@@ -0,0 +1,110 @@
+/* Test that stack protection is done on chosen functions. */
+
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O2 -fstack-protector-strong" } */
+
+#include
+#include
+
+extern int g0;
+extern int *pg0;
+int goo(int *);
+int hoo(int);
+
+/* Function frame address escaped function call. */
+int foo1()
+{
+  int i;
+  return goo(&i);
+}
+
+struct ArrayStruct {
+  int a;
+  int array[10];
+};
+
+struct AA {
+  int b;
+  struct ArrayStruct as;
+};
+
+/* Function frame contains array. */
+int foo2() {
+  struct AA aa;
+  int i;
+  for (i = 0; i < 10; ++i) {
+aa.as.array[i] = i * (i-1) + i / 2;
+  }
+  return aa.as.array[5];
+}
+
+/* Address computation based on a function frame address. */
+int foo3() {
+  int a;
+  int *p;
+  p = &a + 5;
+  return goo(p);
+}
+
+/* Address cast based on a function frame address. */
+int foo4() {
+  int a;
+  return goo(g0 << 2 ? (int *)(3 * (long)(void *)(&a)) : 0);
+
+}
+
+/* Address cast based on a local array. */
+int foo5() {
+  short array[10];
+  return goo((int *)(array + 5));
+}
+
+struct BB {
+  int one;
+  int two;
+  int three;
+};
+
+/* Address computaton based on a function frame address.*/
+int foo6() {
+  struct BB bb;
+  return goo(&bb.one + sizeof(int));
+

Re: [4.7][google] Adding a new option -fstack-protector-strong. (issue5461043)

2011-12-08 Thread Jakub Jelinek
On Thu, Dec 08, 2011 at 11:05:42AM -0800, Han Shen(沈涵) wrote:
> --- a/gcc/cfgexpand.c
> +++ b/gcc/cfgexpand.c
> @@ -1507,15 +1507,34 @@ estimated_stack_frame_size (struct cgraph_node *node)
>return size;
>  }
> 
> +/* Helper routine to check if a record or union contains an array field. */
> +
> +static int record_or_union_type_has_array(tree tree_type) {
> +  tree fields = TYPE_FIELDS(tree_type);
> +  tree f;

The formatting is wrong in the whole patch, please read the guidelines and
fix it up.

> +  FOR_EACH_REFERENCED_VAR(DECL_STRUCT_FUNCTION(current_function_decl),
> var, rvi)

Use cfun instead of DECL_STRUCT_FUNCTION (current_function_decl) here.

Jakub


[patch PR libstdc++/51135]: Fix [4.7 Regression] SIGSEGV during exception cleanup on win32

2011-12-08 Thread Kai Tietz
Hi,

this bug was caused by change of default-calling-convention of
__thiscall for class-member-functions on 32-bit IA windows target.
Issue is that that destructor pointer used default __cdecl
calling-convention instead.  This patch fix that.
As currently trunk is still broken for all SjLj targets (this clobber
patch really clobbered things ...) and so for 32-bit Windows native
too, it is necessary to disable - until this bug is fixed in compiler
(PR/51117)- for the unwind-sjlj.c file in libgcc the option
-fexceptions.

ChangeLog

2011-12-08  Kai Tietz  

PR libstdc++/511135
* libsupc++/cxxabi.h (_GLIBCXX_DESTRUCTOR_CALLCONVENTION): New
macro.
(__cxa_throw): Use it for destructor-argument.
* eh_throw.cc (__cxa_throw): Likewise.
* unwind-cxx.h (__cxa_exception): Use for member
exceptionDestructor the _GLIBCXX_DESTRUCTOR_CALLCONVENTION macro.

Patch tested for i686-w64-mingw32, i686-pc-cygwin, x86_64-w64-mingw32,
and x86_64-unknown-linux-gnu.  Ok for apply?

Regards,
Kai

Index: gcc/libstdc++-v3/libsupc++/cxxabi.h
===
--- gcc.orig/libstdc++-v3/libsupc++/cxxabi.h
+++ gcc/libstdc++-v3/libsupc++/cxxabi.h
@@ -51,6 +51,16 @@
 #include 
 #include 

+// On 32-bit IA native windows target is the used calling-convention
+// for class-member-functions of kind __thiscall.  As destructor is
+// also of kind class-member-function, we need to specify for this
+// target proper calling-convention on destructor-function-pointer.
+#if defined (__MINGW32__) && defined (__i386__)
+#define _GLIBCXX_DESTRUCTOR_CALLCONVENTION __thiscall
+#else
+#define _GLIBCXX_DESTRUCTOR_CALLCONVENTION
+#endif
+
 #ifdef __cplusplus
 namespace __cxxabiv1
 {
@@ -596,7 +606,8 @@ namespace __cxxabiv1

   // Throw the exception.
   void
-  __cxa_throw(void*, std::type_info*, void (*) (void *))
+  __cxa_throw(void*, std::type_info*,
+ void (_GLIBCXX_DESTRUCTOR_CALLCONVENTION *) (void *))
   __attribute__((__noreturn__));

   // Used to implement exception handlers.
Index: gcc/libstdc++-v3/libsupc++/eh_throw.cc
===
--- gcc.orig/libstdc++-v3/libsupc++/eh_throw.cc
+++ gcc/libstdc++-v3/libsupc++/eh_throw.cc
@@ -59,7 +59,8 @@ __gxx_exception_cleanup (_Unwind_Reason_

 extern "C" void
 __cxxabiv1::__cxa_throw (void *obj, std::type_info *tinfo,
-void (*dest) (void *))
+void (_GLIBCXX_DESTRUCTOR_CALLCONVENTION *dest)
+ (void *))
 {
   // Definitely a primary.
   __cxa_refcounted_exception *header
Index: gcc/libstdc++-v3/libsupc++/unwind-cxx.h
===
--- gcc.orig/libstdc++-v3/libsupc++/unwind-cxx.h
+++ gcc/libstdc++-v3/libsupc++/unwind-cxx.h
@@ -51,7 +51,7 @@ struct __cxa_exception
 {
   // Manage the exception object itself.
   std::type_info *exceptionType;
-  void (*exceptionDestructor)(void *);
+  void (_GLIBCXX_DESTRUCTOR_CALLCONVENTION *exceptionDestructor)(void *);

   // The C++ standard has entertaining rules wrt calling set_terminate
   // and set_unexpected in the middle of the exception cleanup process.


[patch, fortran] Fix PR 50690

2011-12-08 Thread Thomas Koenig

Hello world,

this is what I hope is the final round of the OMP front-end optimization
patch.  This one ignores outer workshares when doing function
elimination within omp do and similar blocks.

Regression-tested.  OK for trunk?

Thomas


2011-12-02  Thomas Koenig  

PR fortran/50690
* frontend-passes.c (omp_level):  New variable.
(omp_size):  New variable.
(omp_block):  New variable.
(gfc_run_passes):  Allocate and deallocate omp_block, set
omp_size.
(cfe_expr_0):  Don't eliminiate common function if it would put
the variable immediately into a WORKSHARE construct.
(optimize_namespace):  Set omp_level.
(gfc_code_walker):  Keep track of OMP PARALLEL and OMP WORKSHARE
constructs.

2011-12-02  Thomas Koenig  

PR fortran/50690
* gfortran.dg/gomp/workshare2.f90:  New test.
* gfortran.dg/gomp/workshare3.f90:  New test.
Index: frontend-passes.c
===
--- frontend-passes.c	(Revision 181809)
+++ frontend-passes.c	(Arbeitskopie)
@@ -66,6 +66,13 @@ static gfc_namespace *current_ns;
 
 static int forall_level;
 
+/* Keep track of the OMP blocks, so we can mark variables introduced
+   by optimizations as private.  */
+
+static int omp_level;
+static int omp_size;
+static gfc_code **omp_block;
+
 /* Entry point - run all passes for a namespace.  So far, only an
optimization pass is run.  */
 
@@ -76,12 +83,15 @@ gfc_run_passes (gfc_namespace *ns)
 {
   expr_size = 20;
   expr_array = XNEWVEC(gfc_expr **, expr_size);
+  omp_size = 20;
+  omp_block = XCNEWVEC(gfc_code *, omp_size);
 
   optimize_namespace (ns);
   if (gfc_option.dump_fortran_optimized)
 	gfc_dump_parse_tree (ns, stdout);
 
   XDELETEVEC (expr_array);
+  XDELETEVEC (omp_block);
 }
 }
 
@@ -367,6 +377,23 @@ cfe_expr_0 (gfc_expr **e, int *walk_subtrees,
   int i,j;
   gfc_expr *newvar;
 
+  /* If we are within an OMP WORKSHARE or OMP PARALLEL WORKSHARE
+ construct, don't do this optimization.  Only look at the
+ innermost level because an EXEC_OMP_PARALLEL{,_DO,_SECTIONS}
+ nested in an EXEC_OMP_WORKSHARE/EXEC_OMP_PARALLEL_WORKSHARE
+ is OK.  */
+  if (omp_level > 0)
+{
+  gfc_exec_op op;
+  op = omp_block[omp_level - 1]->op;
+
+  if (op == EXEC_OMP_WORKSHARE || op == EXEC_OMP_PARALLEL_WORKSHARE)
+	{
+	  *walk_subtrees = 0;
+	  return 0;
+	}
+}
+
   expr_count = 0;
 
   gfc_expr_walker (e, cfe_register_funcs, NULL);
@@ -505,6 +532,7 @@ optimize_namespace (gfc_namespace *ns)
 
   current_ns = ns;
   forall_level = 0;
+  omp_level = 0;
 
   gfc_code_walker (&ns->code, convert_do_while, dummy_expr_callback, NULL);
   gfc_code_walker (&ns->code, cfe_code, cfe_expr_0, NULL);
@@ -1150,11 +1178,13 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t code
 	  gfc_actual_arglist *a;
 	  gfc_code *co;
 	  gfc_association_list *alist;
+	  bool in_omp;
 
 	  /* There might be statement insertions before the current code,
 	 which must not affect the expression walker.  */
 
 	  co = *c;
+	  in_omp = false;
 
 	  switch (co->op)
 	{
@@ -1330,14 +1360,32 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t code
 	  WALK_SUBEXPR (co->ext.dt->extra_comma);
 	  break;
 
-	case EXEC_OMP_DO:
 	case EXEC_OMP_PARALLEL:
 	case EXEC_OMP_PARALLEL_DO:
 	case EXEC_OMP_PARALLEL_SECTIONS:
 	case EXEC_OMP_PARALLEL_WORKSHARE:
+	case EXEC_OMP_WORKSHARE:
+
+	  /* Register all OMP PARALLEL and WORKSHARE constructs
+		 on a stack so they can be handled separately for
+		 common function elimination.  */
+
+	  in_omp = 1;
+
+	  if (omp_level >= omp_size)
+		{
+		  omp_size += omp_size;
+		  omp_block = XRESIZEVEC(gfc_code *, omp_block, omp_size);
+		}
+
+	  omp_block[omp_level] = co;
+	  omp_level ++;
+
+	  /* Fall through. */
+
 	case EXEC_OMP_SECTIONS:
+	case EXEC_OMP_DO:
 	case EXEC_OMP_SINGLE:
-	case EXEC_OMP_WORKSHARE:
 	case EXEC_OMP_END_SINGLE:
 	case EXEC_OMP_TASK:
 	  if (co->ext.omp_clauses)
@@ -1366,6 +1414,9 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t code
 	  if (co->op == EXEC_FORALL)
 	forall_level --;
 
+	  if (in_omp)
+	omp_level --;
+
 	}
 }
   return 0;
! { dg-do compile }
! { dg-options "-ffrontend-optimize -fdump-tree-original" }
! Test that common function elimination is done within the OMP parallel
! blocks even if there is a workshare around it.
program foo
  implicit none
  integer, parameter :: n = 1
  real, parameter :: eps = 3e-7
  integer :: i,j
  real :: A(n), B(5), C(n)
  real :: tmp
  B(1) = 3.344
  tmp = B(1)
  do i=1,10
 call random_number(a)
 c = a
 !$omp parallel workshare
 !$omp parallel default(shared)
 !$omp do
 do j=1,n
   A(j) = A(j)*cos(B(1))+A(j)*cos(B(1))
 end do
 !$omp end do
 !$omp end parallel
 !$omp end parallel workshare
  end do

 

[committed] Copy TREE_SIDE_EFFECTS alongside with TREE_THIS_VOLATILE in forwprop (PR tree-optimization/51466)

2011-12-08 Thread Jakub Jelinek
Hi!

As documented in tree.h for TREE_THIS_VOLATILE:
If this bit is set in an expression, so is TREE_SIDE_EFFECTS.
so copying just TREE_THIS_VOLATILE is not sufficient.
On 4.6 branch this resulted in ICEs in gimple_rhs_has_side_effects.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed after
IRC discussion with richi.

2011-12-08  Jakub Jelinek  

PR tree-optimization/51466
* tree-ssa-forwprop.c (forward_propagate_addr_expr_1): Also copy
TREE_SIDE_EFFECTS.

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

--- gcc/tree-ssa-forwprop.c.jj  2011-11-29 08:58:52.0 +0100
+++ gcc/tree-ssa-forwprop.c 2011-12-08 15:17:01.474873355 +0100
@@ -929,10 +929,12 @@ forward_propagate_addr_expr_1 (tree name
  *def_rhs_basep = build2 (MEM_REF, TREE_TYPE (*def_rhs_basep),
   new_base, new_offset);
  TREE_THIS_VOLATILE (*def_rhs_basep) = TREE_THIS_VOLATILE (lhs);
+ TREE_SIDE_EFFECTS (*def_rhs_basep) = TREE_SIDE_EFFECTS (lhs);
  TREE_THIS_NOTRAP (*def_rhs_basep) = TREE_THIS_NOTRAP (lhs);
  new_lhs = unshare_expr (TREE_OPERAND (def_rhs, 0));
  gimple_assign_set_lhs (use_stmt, new_lhs);
  TREE_THIS_VOLATILE (new_lhs) = TREE_THIS_VOLATILE (lhs);
+ TREE_SIDE_EFFECTS (new_lhs) = TREE_SIDE_EFFECTS (lhs);
  *def_rhs_basep = saved;
  tidy_after_forward_propagate_addr (use_stmt);
  /* Continue propagating into the RHS if this was not the
@@ -1011,10 +1013,12 @@ forward_propagate_addr_expr_1 (tree name
  *def_rhs_basep = build2 (MEM_REF, TREE_TYPE (*def_rhs_basep),
   new_base, new_offset);
  TREE_THIS_VOLATILE (*def_rhs_basep) = TREE_THIS_VOLATILE (rhs);
+ TREE_SIDE_EFFECTS (*def_rhs_basep) = TREE_SIDE_EFFECTS (rhs);
  TREE_THIS_NOTRAP (*def_rhs_basep) = TREE_THIS_NOTRAP (rhs);
  new_rhs = unshare_expr (TREE_OPERAND (def_rhs, 0));
  gimple_assign_set_rhs1 (use_stmt, new_rhs);
  TREE_THIS_VOLATILE (new_rhs) = TREE_THIS_VOLATILE (rhs);
+ TREE_SIDE_EFFECTS (new_rhs) = TREE_SIDE_EFFECTS (rhs);
  *def_rhs_basep = saved;
  fold_stmt_inplace (use_stmt_gsi);
  tidy_after_forward_propagate_addr (use_stmt);
--- gcc/testsuite/gcc.c-torture/execute/pr51466.c.jj2011-12-08 
15:25:42.084966108 +0100
+++ gcc/testsuite/gcc.c-torture/execute/pr51466.c   2011-12-08 
15:25:18.0 +0100
@@ -0,0 +1,43 @@
+/* PR tree-optimization/51466 */
+
+extern void abort (void);
+
+__attribute__((noinline, noclone)) int
+foo (int i)
+{
+  volatile int v[4];
+  int *p;
+  v[i] = 6;
+  p = (int *) &v[i];
+  return *p;
+}
+
+__attribute__((noinline, noclone)) int
+bar (int i)
+{
+  volatile int v[4];
+  int *p;
+  v[i] = 6;
+  p = (int *) &v[i];
+  *p = 8;
+  return v[i];
+}
+
+__attribute__((noinline, noclone)) int
+baz (int i)
+{
+  volatile int v[4];
+  int *p;
+  v[i] = 6;
+  p = (int *) &v[0];
+  *p = 8;
+  return v[i];
+}
+
+int
+main ()
+{
+  if (foo (3) != 6 || bar (2) != 8 || baz (0) != 8 || baz (1) != 6)
+abort ();
+  return 0;
+}

Jakub


[PATCH] Optimize away unnecessary clobbers (PR tree-optimization/51117)

2011-12-08 Thread Jakub Jelinek
Hi!

This patch optimizes away clobber stmts that immediately precede 
GIMPLE_RETURN or GIMPLE_RESX that throws externally, which allows
doing EH cleanups.  For both libstdc++.so.6 and go1 this
results in slight reduction of .gcc_except_table size:
$ readelf -WS obj96[24]/x86*/libstdc*/src/.libs/libstdc++.so.6 | grep 
gcc_except_table
  [16] .gcc_except_table PROGBITS000e4714 0e4714 004d1c 00   A  
0   0  4
  [16] .gcc_except_table PROGBITS000e425c 0e425c 004964 00   A  
0   0  4
$ readelf -WS obj96[24]/gcc/go1 | grep gcc_except_table
  [17] .gcc_except_table PROGBITS0160c7fc 120c7fc 003d75 00   A 
 0   0  4
  [17] .gcc_except_table PROGBITS0160c914 120c914 0039be 00   A 
 0   0  4

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

2011-12-08  Jakub Jelinek  
Andrew Pinski  

PR tree-optimization/51117
* tree-eh.c (optimize_clobbers): New function.
(execute_lower_eh_dispatch): Call it.

--- gcc/tree-eh.c.jj2011-12-01 11:45:06.0 +0100
+++ gcc/tree-eh.c   2011-12-08 17:48:58.009908793 +0100
@@ -3173,6 +3173,30 @@ struct gimple_opt_pass pass_lower_resx =
  }
 };
 
+/* Try to optimize var = {v} {CLOBBER} stmts followed just by return
+   or external throw.  */
+
+static void
+optimize_clobbers (basic_block bb)
+{
+  gimple_stmt_iterator gsi = gsi_last_bb (bb);
+  for (gsi_prev (&gsi); !gsi_end_p (gsi);)
+{
+  gimple stmt = gsi_stmt (gsi);
+  if (is_gimple_debug (stmt))
+   {
+ gsi_prev (&gsi);
+ continue;
+   }
+  if (!gimple_assign_single_p (stmt)
+ || TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME
+ || !TREE_CLOBBER_P (gimple_assign_rhs1 (stmt)))
+   return;
+  unlink_stmt_vdef (stmt);
+  gsi_remove (&gsi, true);
+  release_defs (stmt);
+}
+}
 
 /* At the end of inlining, we can lower EH_DISPATCH.  Return true when 
we have found some duplicate labels and removed some edges.  */
@@ -3337,11 +3361,17 @@ execute_lower_eh_dispatch (void)
   FOR_EACH_BB (bb)
 {
   gimple last = last_stmt (bb);
-  if (last && gimple_code (last) == GIMPLE_EH_DISPATCH)
+  if (last == NULL)
+   continue;
+  if (gimple_code (last) == GIMPLE_EH_DISPATCH)
{
  redirected |= lower_eh_dispatch (bb, last);
  any_rewritten = true;
}
+  else if (gimple_code (last) == GIMPLE_RETURN
+  || (gimple_code (last) == GIMPLE_RESX
+  && stmt_can_throw_external (last)))
+   optimize_clobbers (bb);
 }
 
   if (redirected)

Jakub


Re: [patch, fortran] Fix PR 50690

2011-12-08 Thread Jakub Jelinek
On Thu, Dec 08, 2011 at 08:48:31PM +0100, Thomas Koenig wrote:
>  /* Entry point - run all passes for a namespace.  So far, only an
> optimization pass is run.  */
>  
> @@ -76,12 +83,15 @@ gfc_run_passes (gfc_namespace *ns)
>  {
>expr_size = 20;
>expr_array = XNEWVEC(gfc_expr **, expr_size);
> +  omp_size = 20;
> +  omp_block = XCNEWVEC(gfc_code *, omp_size);

Both of these arrays should be really vec.h vectors, it doesn't
make any sense to handcode the same thing everywhere.
You can then start with NULL vectors and push something using VEC_safe_push
only when needed and let it handle reallocation etc.

Jakub


Re: [PATCH] use -fno-pie on darwin in boehm-gc.exp

2011-12-08 Thread Jack Howarth
On Thu, Dec 08, 2011 at 05:55:37PM +, Iain Sandoe wrote:
>
> On 8 Dec 2011, at 17:24, Jack Howarth wrote:
>
>> On Thu, Dec 08, 2011 at 05:05:12PM +, Iain Sandoe wrote:
>>>
>>> On 8 Dec 2011, at 16:58, Jack Howarth wrote:
>>>
 On Thu, Dec 08, 2011 at 03:54:35PM +, Iain Sandoe wrote:
>
> On 8 Dec 2011, at 15:38, Jack Howarth wrote:
>
>> Currently the boehm-gc testsuite fails...
>>
>> FAIL: boehm-gc.c/gctest.c -O2 execution test
>> FAIL: boehm-gc.c/leak_test.c -O2 execution test
>> FAIL: boehm-gc.c/thread_leak_test.c -O2 execution test
>> FAIL: boehm-gc.lib/staticrootstest.c -O2 execution test
>
> you have not answered these questions:
>
> a) "what is anything being built in these tests which is not PIC"?
> b) and why is it being built that way?
>
> ISTM the fix below should not be required
> - and the problem lies in something being built with -mdynamic-no-
> pic or
> similar

 Nothing in boehm-gc is built non-PIC (see the attached log for  
 boehm-
 gc).
 Likewise nothing in the testsuite is built non-PIC. For example,
 gctest.c
 at -O2 is built, according to -v, as...

 /sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/cc1 -quiet -v - 
 I /
 sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64-apple-
 darwin11.2.0/./boehm-gc/include -I /sw/src/fink.build/gcc47-4.7.0-1/
 gcc-4.7-20111207/boehm-gc/testsuite/../include -iprefix /sw/src/
 fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/../lib/gcc/x86_64-apple-
 darwin11.2.0/4.7.0/ -isystem /sw/src/fink.build/gcc47-4.7.0-1/
 darwin_objdir/gcc/include -isystem /sw/src/fink.build/gcc47-4.7.0-1/
 darwin_objdir/gcc/include-fixed -D__DYNAMIC__ /sw/src/fink.build/
 gcc47-4.7.0-1/gcc-4.7-20111207/boehm-gc/testsuite/boehm-gc.c/ 
 gctest.c
 -fPIC -quiet -dumpbase gctest.c -mmacosx-version-min=10.7.2
 -mtune=core2 -auxbase gctest -O2 -version -o /var/tmp//ccgHCNRC.s

 The test is also just linked to the the libgcjgcj built in boehm- 
 gc...

 /sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/collect-ld - 
 dynamic
 -arch x86_64 -macosx_version_min 10.7.2 -weak_reference_mismatches
 non-weak -o ./.libs/gctest -lcrt1.10.6.o -
 L/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc /var/tmp//
 ccb3OaQl.o /sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64-
 apple-darwin11.2.0/./boehm-gc/.libs/libgcjgc.dylib - 
 no_compact_unwind
 -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v

 so the build in boehm-gc appears to be self-contained.
>>>
>>> OK- so it appears ...
>>> ... so why is ld complaining that there's non-PIC code present?
>>
>> Where do you see ld complaining of non-PIC code?
>
> OK.  Different problem - I recalled that there were [PIE] issues with ld 
> complaining.
>
> .. if  PIE is fundamentally incompatible with boehm-gc (is it??) - then, 
> right, we need to make sure it's off -
>
> -  presumably it's not affecting any other target - because they don't  
> do PIE unless told to ...
>
> Perhaps it would be better to adjust the spec that you made (and has  
> been applied) to ensure that -no_pie is passed to the linker  *unless*  
> pie is explicitly given on the c/l?
>

Iain,
   Isn't exactly opposite of your original preference for handling darwin11
(that we shouldn't degrade darwin11 by disabling its automatic use of PIE)?
Your suggestion would seem to do exactly that.
Jack

> At present, you pass it when "no-pic, no-pie" etc. are - perhaps it  
> should just be the default and *only* switched on for -pie something  
> like
>
>  %{!fpie: %{!PIE: %:version-compare(>= 10.7 mmacosx-version-min= - 
> no_pie) } }
>
> Otherwise, D11 is behaving differently from other targets for the whole 
> test-suite - not just boehm-gc.
>
> cheers
> Iain
>


Re: [PATCH] use -fno-pie on darwin in boehm-gc.exp

2011-12-08 Thread Jack Howarth
On Thu, Dec 08, 2011 at 05:55:37PM +, Iain Sandoe wrote:
>
> On 8 Dec 2011, at 17:24, Jack Howarth wrote:
>
>> On Thu, Dec 08, 2011 at 05:05:12PM +, Iain Sandoe wrote:
>>>
>>> On 8 Dec 2011, at 16:58, Jack Howarth wrote:
>>>
 On Thu, Dec 08, 2011 at 03:54:35PM +, Iain Sandoe wrote:
>
> On 8 Dec 2011, at 15:38, Jack Howarth wrote:
>
>> Currently the boehm-gc testsuite fails...
>>
>> FAIL: boehm-gc.c/gctest.c -O2 execution test
>> FAIL: boehm-gc.c/leak_test.c -O2 execution test
>> FAIL: boehm-gc.c/thread_leak_test.c -O2 execution test
>> FAIL: boehm-gc.lib/staticrootstest.c -O2 execution test
>
> you have not answered these questions:
>
> a) "what is anything being built in these tests which is not PIC"?
> b) and why is it being built that way?
>
> ISTM the fix below should not be required
> - and the problem lies in something being built with -mdynamic-no-
> pic or
> similar

 Nothing in boehm-gc is built non-PIC (see the attached log for  
 boehm-
 gc).
 Likewise nothing in the testsuite is built non-PIC. For example,
 gctest.c
 at -O2 is built, according to -v, as...

 /sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/cc1 -quiet -v - 
 I /
 sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64-apple-
 darwin11.2.0/./boehm-gc/include -I /sw/src/fink.build/gcc47-4.7.0-1/
 gcc-4.7-20111207/boehm-gc/testsuite/../include -iprefix /sw/src/
 fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/../lib/gcc/x86_64-apple-
 darwin11.2.0/4.7.0/ -isystem /sw/src/fink.build/gcc47-4.7.0-1/
 darwin_objdir/gcc/include -isystem /sw/src/fink.build/gcc47-4.7.0-1/
 darwin_objdir/gcc/include-fixed -D__DYNAMIC__ /sw/src/fink.build/
 gcc47-4.7.0-1/gcc-4.7-20111207/boehm-gc/testsuite/boehm-gc.c/ 
 gctest.c
 -fPIC -quiet -dumpbase gctest.c -mmacosx-version-min=10.7.2
 -mtune=core2 -auxbase gctest -O2 -version -o /var/tmp//ccgHCNRC.s

 The test is also just linked to the the libgcjgcj built in boehm- 
 gc...

 /sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc/collect-ld - 
 dynamic
 -arch x86_64 -macosx_version_min 10.7.2 -weak_reference_mismatches
 non-weak -o ./.libs/gctest -lcrt1.10.6.o -
 L/sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/gcc /var/tmp//
 ccb3OaQl.o /sw/src/fink.build/gcc47-4.7.0-1/darwin_objdir/x86_64-
 apple-darwin11.2.0/./boehm-gc/.libs/libgcjgc.dylib - 
 no_compact_unwind
 -lSystem -lgcc_ext.10.5 -lgcc -lSystem -v

 so the build in boehm-gc appears to be self-contained.
>>>
>>> OK- so it appears ...
>>> ... so why is ld complaining that there's non-PIC code present?
>>
>> Where do you see ld complaining of non-PIC code?
>
> OK.  Different problem - I recalled that there were [PIE] issues with ld 
> complaining.
>
> .. if  PIE is fundamentally incompatible with boehm-gc (is it??) - then, 
> right, we need to make sure it's off -
>
> -  presumably it's not affecting any other target - because they don't  
> do PIE unless told to ...
>
> Perhaps it would be better to adjust the spec that you made (and has  
> been applied) to ensure that -no_pie is passed to the linker  *unless*  
> pie is explicitly given on the c/l?
>
> At present, you pass it when "no-pic, no-pie" etc. are - perhaps it  
> should just be the default and *only* switched on for -pie something  
> like
>
>  %{!fpie: %{!PIE: %:version-compare(>= 10.7 mmacosx-version-min= - 
> no_pie) } }
>
> Otherwise, D11 is behaving differently from other targets for the whole 
> test-suite - not just boehm-gc.

Iain,
   One could make the alternative argument that the testing on linux is
currently incomplete because it is not done on any of the hardened linux
distros which utilize PIE such as...

http://www.gentoo.org/proj/en/hardened/

I find it very stange that there seems to be so little communication between
such projects and FSF gcc.
  Jack
>
> cheers
> Iain
>


[PATCH] Fix dg-function-on-line for MIPS64-linux-gnu

2011-12-08 Thread Andrew Pinski
Hi,
  The problem here is mips64-linux-gnu produces similar output like
IRIX does except there might be some .cfi_startproc there.  This patch
fixes it by allow an optional .cfi_startproc and by always using that
format for mips*-*-* .

OK?  Tested on mips64-linux-gnu.

Thanks,
Andrew Pinski

testsuite/ChangeLog:
* lib/scanasm.exp (dg-function-on-line): Always use a special format
for all mips targets.  Also allow an optional .cfi_startproc .
Index: scanasm.exp
===
--- scanasm.exp (revision 182096)
+++ scanasm.exp (working copy)
@@ -474,8 +474,8 @@
 if { [istarget hppa*-*-*] } {
set pattern [format {\t;[^:]+:%d\n(\t[^\t]+\n)+%s:\n\t.PROC} \
  $line $symbol]
-} elseif { [istarget mips-sgi-irix*] } {
-   set pattern [format {\t\.loc [0-9]+ %d 0( 
[^\n]*)?\n\t\.set\t(no)?mips16\n\t\.ent\t%s\n\t\.type\t%s, @function\n%s:\n} \
+} elseif { [istarget mips*-*-*] } {
+   set pattern [format {\t\.loc [0-9]+ %d 0( 
[^\n]*)?\n(\t.cfi_startproc[^\t]*\n)*\t\.set\t(no)?mips16\n\t\.ent\t%s\n\t\.type\t%s,
 @function\n%s:\n} \
 $line $symbol $symbol $symbol]
 } else {
set pattern [format 
{%s:[^\t]*(\t.(fnstart|frame|mask|file)[^\t]*)*\t[^:]+:%d\n} \


Re: [patch PR libstdc++/51135]: Fix [4.7 Regression] SIGSEGV during exception cleanup on win32

2011-12-08 Thread Jonathan Wakely
On Dec 8, 2011 7:16 PM, "Kai Tietz" wrote:
>
>        * unwind-cxx.h (__cxa_exception): Use for member
>        exceptionDestructor the _GLIBCXX_DESTRUCTOR_CALLCONVENTION macro.

I think "Use the _GLIBCXX_DESTRUCTOR_CALLCONVENTION macro for the
exceptionDestructor member" would make more sense.

However ...

> Index: gcc/libstdc++-v3/libsupc++/cxxabi.h
> ===
> --- gcc.orig/libstdc++-v3/libsupc++/cxxabi.h
> +++ gcc/libstdc++-v3/libsupc++/cxxabi.h
> @@ -51,6 +51,16 @@
>  #include 
>  #include 
>
> +// On 32-bit IA native windows target is the used calling-convention
> +// for class-member-functions of kind __thiscall.  As destructor is
> +// also of kind class-member-function, we need to specify for this
> +// target proper calling-convention on destructor-function-pointer.
> +#if defined (__MINGW32__) && defined (__i386__)
> +#define _GLIBCXX_DESTRUCTOR_CALLCONVENTION __thiscall
> +#else
> +#define _GLIBCXX_DESTRUCTOR_CALLCONVENTION
> +#endif

Could you define a typedef for void(*)(void*) and adapt that for
mingw32 instead of using the macro everywhere?

#if defined (__MINGW32__) && defined (__i386__)
typedef void (__thiscall *__cxxabi_dtor_type)(void*);
#else
typedef void (*__cxxabi_dtor_type)(void*);
#endif

(That would be my preference, but the maintainers of that code might disagree.)


Re: [patch, fortran] Fix PR 50690

2011-12-08 Thread Thomas Koenig

Hi Jakub,


Both of these arrays should be really vec.h vectors, it doesn't
make any sense to handcode the same thing everywhere.
You can then start with NULL vectors and push something using VEC_safe_push
only when needed and let it handle reallocation etc.


I tried that originally, but could not get it to work; getting the
macros right just didn't happen.

A cleanup patch would be OK, though.

Thomas


Re: [patch PR libstdc++/51135]: Fix [4.7 Regression] SIGSEGV during exception cleanup on win32

2011-12-08 Thread Kai Tietz
2011/12/8 Jonathan Wakely :
> On Dec 8, 2011 7:16 PM, "Kai Tietz" wrote:
>>
>>        * unwind-cxx.h (__cxa_exception): Use for member
>>        exceptionDestructor the _GLIBCXX_DESTRUCTOR_CALLCONVENTION macro.
>
> I think "Use the _GLIBCXX_DESTRUCTOR_CALLCONVENTION macro for the
> exceptionDestructor member" would make more sense.

Thanks, I will add it to ChangeLog that way, if the macro variant is
selected by maintainer of that code.

> However ...
>
>> Index: gcc/libstdc++-v3/libsupc++/cxxabi.h
>> ===
>> --- gcc.orig/libstdc++-v3/libsupc++/cxxabi.h
>> +++ gcc/libstdc++-v3/libsupc++/cxxabi.h
>> @@ -51,6 +51,16 @@
>>  #include 
>>  #include 
>>
>> +// On 32-bit IA native windows target is the used calling-convention
>> +// for class-member-functions of kind __thiscall.  As destructor is
>> +// also of kind class-member-function, we need to specify for this
>> +// target proper calling-convention on destructor-function-pointer.
>> +#if defined (__MINGW32__) && defined (__i386__)
>> +#define _GLIBCXX_DESTRUCTOR_CALLCONVENTION __thiscall
>> +#else
>> +#define _GLIBCXX_DESTRUCTOR_CALLCONVENTION
>> +#endif
>
> Could you define a typedef for void(*)(void*) and adapt that for
> mingw32 instead of using the macro everywhere?
>
> #if defined (__MINGW32__) && defined (__i386__)
> typedef void (__thiscall *__cxxabi_dtor_type)(void*);
> #else
> typedef void (*__cxxabi_dtor_type)(void*);
> #endif
>
> (That would be my preference, but the maintainers of that code might 
> disagree.)

Well, sure.  Might be even a more clear way to have here an explicit
type-name indicating arguments kind.  But code-maintainer should tell,
what variant is preferred here.

Kai


Re: [PATCH] [MIPS] Add -march=octeon+ support for GCC

2011-12-08 Thread Richard Sandiford
Andrew Pinski  writes:
>> gcc/ChangeLog:
>> * mips/mips-cpus.def (octeon+): New CPU.

config/mips/mips-cpus.def

>> testsuite/ChangeLog:
>> * gcc.target/mips/mult-1.c: Forbit all Octeon processors.

Forbid.

> @@ -1,6 +1,6 @@
>  /* For SI->DI widening multiplication we should use DINS to combine the two
> halves.  For Octeon use DMUL with explicit widening.  */
> -/* { dg-options "-O -mgp64 isa_rev>=2 forbid_cpu=octeon" } */
> +/* { dg-options "-O -mgp64 isa_rev>=2 forbid_cpu=octeon\[\+0-9\]*" } */
>  /* { dg-final { scan-assembler "\tdins\t" } } */
>  /* { dg-final { scan-assembler-not "\tdsll\t" } } */
>  /* { dg-final { scan-assembler-not "\tdsrl\t" } } */

Here I'd either prefer "forbid_cpu=octeon.*" (a bold statement that
no Octeon processor will ever be interested in these tests) or
"forbid_cpu=octeon(|+|2)" (a much more focused statement).
Just matching + and numbers is a bit in the middle: past experience
suggests that marketing departments don't always follow such logic.

If you don't have a strong preference, let's go for (|+|2).
If you do, go with what you think's best.

OK for 4.7 with those changes, thanks.

Richard


Re: [PATCH] use -fno-pie on darwin in boehm-gc.exp

2011-12-08 Thread Iain Sandoe


On 8 Dec 2011, at 20:15, Jack Howarth wrote:


At present, you pass it when "no-pic, no-pie" etc. are - perhaps it
should just be the default and *only* switched on for -pie something
like

%{!fpie: %{!PIE: %:version-compare(>= 10.7 mmacosx-version-min= -
no_pie) } }

Otherwise, D11 is behaving differently from other targets for the  
whole

test-suite - not just boehm-gc.


Iain,
  One could make the alternative argument that the testing on linux is
currently incomplete because it is not done on any of the hardened  
linux

distros which utilize PIE such as...

http://www.gentoo.org/proj/en/hardened/

I find it very stange that there seems to be so little communication  
between

such projects and FSF gcc.



[well the best solution would be to solve whatever problem stops boehm- 
gc working with PIE on/off-- but that's not a job for this week ;-) ]


===

So to recap ---
IMO it's better if we can do the same as the vendor's tools on the  
target system, providing that's not provably buggy.

(I think that's our general policy on Darwin, right?).

So, yes, you are correct, I would prefer not to switch PIE off ...

... but then, I guess, the test-suite makes the "assumption" that PIE  
is off by default ...


... so, perhaps a solution is to run it  RUNTESTFLAGS=" \-fno- 
PIE ... " on Darwin11.


--

similarly,  the hardened linux guys could do  ... RUNTESTFLAGS="\{- 
fPIE... "  if they want to test coverage with PIE on.


--

... of course, that breaks when there are specific tests that *are*  
PIE aware ...


... so the 'easy way out' is to make D11 behave as per earlier  
versions (i.e. default PIE off);




for a small number of tests ..  { dg-additional-options ... } would be  
more transparent than modifying

lib/something.exp

... but, I'll bow out at this juncture -
- we've established the underlying issue - which isn't likely to get  
solved with specs or test-suite options.


cheers
Iain



Re: Update to Fortran "invoke" documentation about the features -finit- *really* provides.

2011-12-08 Thread Toon Moene

On 12/07/2011 07:58 PM, Toon Moene wrote:


On 12/06/2011 08:32 PM, Steve Kargl wrote:



Looks good to me. You can apply it to the 4.6 branch
if you have time.


And then  shortly before applying it, I realized that the proper
documentation of the limitations might be dependent on the
-fno-automatic, -fstack-arrays and -fmax-stack-var-size=n compiler flags
used.

So I'll come back tomorrow with version 2.0 of this patch, after
checking out all of the above (the documentation of 4.6 and 4.7 will be
different if using -fstack-arrays makes a difference, because that
option only exists in 4.7).


The flags mentioned turned out not to make a difference.  I committed 
the patch as-is to the trunk as revision 182127.  On the 4.6 branch it 
is revision 182138.


I will now change the type of the bug report to "Enhancement" - after 
all, all of these ease-debugging flags are enhancements over standard 
compiler behavior (quality-of-implementation issue, as we call it on 
http://j3-fortran.org).


Thanks for the review.

--
Toon Moene - e-mail: t...@moene.org - phone: +31 346 214290
Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
At home: http://moene.org/~toon/; weather: http://moene.org/~hirlam/
Progress of GNU Fortran: http://gcc.gnu.org/wiki/GFortran#news


Re: [patch, fortran] Fix PR 50690

2011-12-08 Thread Jakub Jelinek
On Thu, Dec 08, 2011 at 09:36:13PM +0100, Thomas Koenig wrote:
> >Both of these arrays should be really vec.h vectors, it doesn't
> >make any sense to handcode the same thing everywhere.
> >You can then start with NULL vectors and push something using VEC_safe_push
> >only when needed and let it handle reallocation etc.
>
> I tried that originally, but could not get it to work; getting the
> macros right just didn't happen.

Untested:

#include "vec.h"
...
/* static int omp_level;
   static int omp_size;
   static gfc_code **omp_block; */
typedef gfc_code *gfc_codep;
DEF_VEC_P(gfc_codep);
DEF_VEC_ALLOC_P(gfc_codep,heap);
static VEC(gfc_codep, heap) *omp_block;
...
/* omp_size = 20;
   omp_block = XCNEWVEC(gfc_code *, omp_size); - Just remove these, 
VEC_free clears omp_block.  */
...
/* XDELETEVEC (omp_block); */
VEC_free (gfc_codep, heap, omp_block);
...
  /* if (omp_level > 0)
   {
 gfc_exec_op op;
 op = omp_block[omp_level - 1]->op; */
  if (!VEC_empty (gfc_codep, omp_block))
{
  gfc_exec_op op;
  op = VEC_last (gfc_codep, omp_block)->op;
...
  /* omp_level = 0; */
  VEC_truncate (gfc_codep, omp_block, 0);
...
   /* if (omp_level >= omp_size)
{
  omp_size += omp_size;
  omp_block = XRESIZEVEC(gfc_code *, omp_block, omp_size);
}

  omp_block[omp_level] = co;
  omp_level ++; */
VEC_safe_push (gfc_codep, heap, omp_block, op);
...
  /* if (in_omp)
  omp_level --; */
  if (in_omp)
VEC_pop (gfc_codep, omp_block);

Jakub


[PATCH 0/6] Implement vec_perm_const consistently

2011-12-08 Thread Richard Henderson
We've previously discussed eliminating VEC_INTERLEAVE_*_EXPR, and
VEC_EXTRACT_{EVEN,ODD}_EXPR, as both have different semantics 
depending on target endianness.  The replacement, VEC_PERM_EXPR,
does not have this ambiguity.

In order for this to not introduce regressions in the various
targets that have previously implmented vec_interleave patterns,
we have to recognize the various vec_perm_const patterns.
To a greater or lesser degree, all of these backend patches
mirror the way that i386 approaches this problem.

Not all of the variations are completely tested; e.g. mips loongson
or powerpc paired-single.  The arm patches have had some amount of
cross-testing, and are currently bootstrapping on hardware.  The
ia64 patches need testing on big-endian hpux.


r~


Richard Henderson (5):
  rs6000: Implement vec_perm_constv16qi for altivec.
  ia64: Implement vec_perm_const.
  rs6000: Cleanup interleave/even_odd/vec_perm.
  mips: Implement vec_perm_const.
  arm: Implement vec_perm and vec_perm_const for NEON.

jakub (1):
  Delete VEC_INTERLEAVE_*_EXPR.

 gcc/cfgexpand.c   |2 -
 gcc/config/arm/arm-protos.h   |3 +
 gcc/config/arm/arm.c  |  527 -
 gcc/config/arm/neon.md|   59 +++
 gcc/config/arm/vec-common.md  |   26 +
 gcc/config/i386/i386.c|   26 +-
 gcc/config/ia64/ia64-protos.h |4 +
 gcc/config/ia64/ia64.c|  424 -
 gcc/config/ia64/vect.md   |  183 ++--
 gcc/config/mips/loongson.md   |   24 +-
 gcc/config/mips/mips-modes.def|1 +
 gcc/config/mips/mips-protos.h |1 +
 gcc/config/mips/mips-ps-3d.md |  145 --
 gcc/config/mips/mips.c|  266 ++-
 gcc/config/mips/predicates.md |7 +-
 gcc/config/rs6000/altivec.md  |  381 
 gcc/config/rs6000/paired.md   |  116 ++---
 gcc/config/rs6000/predicates.md   |   10 +
 gcc/config/rs6000/rs6000-builtin.def  |8 +-
 gcc/config/rs6000/rs6000-modes.def|   10 +-
 gcc/config/rs6000/rs6000-protos.h |4 +
 gcc/config/rs6000/rs6000.c|  335 +-
 gcc/config/rs6000/spe.md  |   58 ++-
 gcc/config/rs6000/vector.md   |   74 +---
 gcc/config/rs6000/vsx.md  |  151 ---
 gcc/doc/generic.texi  |   13 -
 gcc/doc/md.texi   |   14 -
 gcc/expr.c|2 -
 gcc/fold-const.c  |   10 -
 gcc/genopinit.c   |4 +-
 gcc/gimple-pretty-print.c |2 -
 gcc/optabs.c  |   28 +-
 gcc/optabs.h  |5 -
 gcc/testsuite/gcc.target/powerpc/altivec-perm-1.c |   76 +++
 gcc/testsuite/gcc.target/powerpc/altivec-perm-2.c |   19 +
 gcc/testsuite/gcc.target/powerpc/altivec-perm-4.c |   13 +
 gcc/testsuite/lib/target-supports.exp |9 +-
 gcc/tree-cfg.c|2 -
 gcc/tree-inline.c |2 -
 gcc/tree-pretty-print.c   |   16 -
 gcc/tree-vect-data-refs.c |   86 ++--
 gcc/tree-vect-generic.c   |4 +-
 gcc/tree-vect-stmts.c |   14 +-
 gcc/tree-vectorizer.h |1 +
 gcc/tree.def  |4 -
 45 files changed, 2242 insertions(+), 927 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/altivec-perm-1.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/altivec-perm-2.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/altivec-perm-4.c

-- 
1.7.7.3



[PATCH 2/6] rs6000: Implement vec_perm_constv16qi for altivec.

2011-12-08 Thread Richard Henderson
From: Richard Henderson 

---
 gcc/config/rs6000/altivec.md  |   13 ++
 gcc/config/rs6000/rs6000-protos.h |1 +
 gcc/config/rs6000/rs6000.c|  175 +
 gcc/testsuite/gcc.target/powerpc/altivec-perm-1.c |   76 +
 gcc/testsuite/gcc.target/powerpc/altivec-perm-2.c |   19 +++
 gcc/testsuite/gcc.target/powerpc/altivec-perm-4.c |   13 ++
 6 files changed, 297 insertions(+), 0 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/altivec-perm-1.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/altivec-perm-2.c
 create mode 100644 gcc/testsuite/gcc.target/powerpc/altivec-perm-4.c

diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md
index a3a8d77..7797b65 100644
--- a/gcc/config/rs6000/altivec.md
+++ b/gcc/config/rs6000/altivec.md
@@ -1366,6 +1366,19 @@
   "TARGET_ALTIVEC"
   "")
 
+(define_expand "vec_perm_constv16qi"
+  [(match_operand:V16QI 0 "register_operand" "")
+   (match_operand:V16QI 1 "register_operand" "")
+   (match_operand:V16QI 2 "register_operand" "")
+   (match_operand:V16QI 3 "" "")]
+  "TARGET_ALTIVEC"
+{
+  if (altivec_expand_vec_perm_const (operands))
+DONE;
+  else
+FAIL;
+})
+
 (define_insn "altivec_vrfip"   ; ceil
   [(set (match_operand:V4SF 0 "register_operand" "=v")
 (unspec:V4SF [(match_operand:V4SF 1 "register_operand" "v")]
diff --git a/gcc/config/rs6000/rs6000-protos.h 
b/gcc/config/rs6000/rs6000-protos.h
index 4650152..f2ed084 100644
--- a/gcc/config/rs6000/rs6000-protos.h
+++ b/gcc/config/rs6000/rs6000-protos.h
@@ -55,6 +55,7 @@ extern void rs6000_expand_vector_init (rtx, rtx);
 extern void paired_expand_vector_init (rtx, rtx);
 extern void rs6000_expand_vector_set (rtx, rtx, int);
 extern void rs6000_expand_vector_extract (rtx, rtx, int);
+extern bool altivec_expand_vec_perm_const (rtx op[4]);
 extern void build_mask64_2_operands (rtx, rtx *);
 extern int expand_block_clear (rtx[]);
 extern int expand_block_move (rtx[]);
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 46ad820..9be155d 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -26202,6 +26202,181 @@ rs6000_emit_parity (rtx dst, rtx src)
 }
 }
 
+/* Expand an Altivec constant permutation.  Return true if we match
+   an efficient implementation; false to fall back to VPERM.  */
+
+bool
+altivec_expand_vec_perm_const (rtx operands[4])
+{
+  struct altivec_perm_insn {
+enum insn_code impl;
+unsigned char perm[16];
+  };
+  static const struct altivec_perm_insn patterns[] = {
+{ CODE_FOR_altivec_vpkuhum,
+  {  1,  3,  5,  7,  9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31 } },
+{ CODE_FOR_altivec_vpkuwum,
+  {  2,  3,  6,  7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31 } },
+{ CODE_FOR_altivec_vmrghb,
+  {  0, 16,  1, 17,  2, 18,  3, 19,  4, 20,  5, 21,  6, 22,  7, 23 } },
+{ CODE_FOR_altivec_vmrghh,
+  {  0,  1, 16, 17,  2,  3, 18, 19,  4,  5, 20, 21,  6,  7, 22, 23 } },
+{ CODE_FOR_altivec_vmrghw,
+  {  0,  1,  2,  3, 16, 17, 18, 19,  4,  5,  6,  7, 20, 21, 22, 23 } },
+{ CODE_FOR_altivec_vmrglb,
+  {  8, 24,  9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31 } },
+{ CODE_FOR_altivec_vmrglh,
+  {  8,  9, 24, 25, 10, 11, 26, 27, 12, 13, 28, 29, 14, 15, 30, 31 } },
+{ CODE_FOR_altivec_vmrglw,
+  {  8,  9, 10, 11, 24, 25, 26, 27, 12, 13, 14, 15, 28, 29, 30, 31 } }
+  };
+
+  unsigned int i, j, elt, which;
+  unsigned char perm[16];
+  rtx target, op0, op1, sel, x;
+  bool one_vec;
+
+  target = operands[0];
+  op0 = operands[1];
+  op1 = operands[2];
+  sel = operands[3];
+
+  /* Unpack the constant selector.  */
+  for (i = which = 0; i < 16; ++i)
+{
+  rtx e = XVECEXP (sel, 0, i);
+  elt = INTVAL (e) & 31;
+  which |= (elt < 16 ? 1 : 2);
+  perm[i] = elt;
+}
+
+  /* Simplify the constant selector based on operands.  */
+  switch (which)
+{
+default:
+  gcc_unreachable ();
+
+case 3:
+  one_vec = false;
+  if (!rtx_equal_p (op0, op1))
+   break;
+
+  /* Fold the permutation into a single vector.  */
+  for (i = 0; i < 16; ++i)
+   if (perm[i] >= 16)
+ perm[i] -= 16;
+  /* FALLTHRU */
+
+case 1:
+  op1 = op0;
+  one_vec = true;
+  break;
+
+case 2:
+  for (i = 0; i < 16; ++i)
+   perm[i] -= 16;
+  op0 = op1;
+  one_vec = true;
+  break;
+}
+ 
+  /* Look for splat patterns.  */
+  if (one_vec)
+{
+  elt = perm[0];
+
+  for (i = 0; i < 16; ++i)
+   if (perm[i] != elt)
+ break;
+  if (i == 16)
+   {
+ emit_insn (gen_altivec_vspltb (target, op0, GEN_INT (elt)));
+ return true;
+   }
+
+  if (elt % 2 == 0)
+   {
+ for (i = 0; i < 16; i += 2)
+   if (perm[i] != elt || perm[i + 1] != elt + 1)
+ break;
+ if (i == 16)
+   {
+ x 

[PATCH 1/6] Delete VEC_INTERLEAVE_*_EXPR.

2011-12-08 Thread Richard Henderson
Slightly modified version of a patch Jakub posted earlier.


* tree.def (VEC_INTERLEAVE_HIGH_EXPR, VEC_INTERLEAVE_LOW_EXPR): Remove.
* gimple-pretty-print.c (dump_binary_rhs): Don't handle
VEC_INTERLEAVE_HIGH_EXPR and VEC_INTERLEAVE_LOW_EXPR.
* expr.c (expand_expr_real_2): Likewise.
* tree-cfg.c (verify_gimple_assign_binary): Likewise.
* cfgexpand.c (expand_debug_expr): Likewise.
* tree-inline.c (estimate_operator_cost): Likewise.
* tree-pretty-print.c (dump_generic_node): Likewise.
* tree-vect-generic.c (expand_vector_operations_1): Likewise.
* fold-const.c (fold_binary_loc): Likewise.
* doc/generic.texi (VEC_INTERLEAVE_HIGH_EXPR,
VEC_INTERLEAVE_LOW_EXPR): Remove documentation.
* optabs.c (optab_for_tree_code): Don't handle
VEC_INTERLEAVE_HIGH_EXPR and VEC_INTERLEAVE_LOW_EXPR.
(expand_binop, init_optabs): Remove vec_interleave_high_optab
and vec_interleave_low_optab.
* genopinit.c (optabs): Likewise.
* optabs.h (OTI_vec_interleave_high, OTI_vec_interleave_low): Remove.
(vec_interleave_high_optab, vec_interleave_low_optab): Remove.
* doc/md.texi (vec_interleave_high, vec_interleave_low): Remove
documentation.
* tree-vect-stmts.c (gen_perm_mask): Renamed to...
(vect_gen_perm_mask): ... this.  No longer static.
(perm_mask_for_reverse, vectorizable_load): Adjust callers.
* tree-vectorizer.h (vect_gen_perm_mask): New prototype.
* tree-vect-data-refs.c (vect_strided_store_supported): Don't try
VEC_INTERLEAVE_*_EXPR, use can_vec_perm_p instead of
can_vec_perm_for_code_p.
(vect_permute_store_chain): Generate VEC_PERM_EXPR with interleaving
masks instead of VEC_INTERLEAVE_HIGH_EXPR and VEC_INTERLEAVE_LOW_EXPR.
* config/i386/i386.c (expand_vec_perm_interleave2): If
expand_vec_perm_interleave3 would handle it, return false.
(expand_vec_perm_broadcast_1): Don't use vec_interleave_*_optab.
---
 gcc/cfgexpand.c   |2 -
 gcc/config/i386/i386.c|   26 +++--
 gcc/doc/generic.texi  |   13 ---
 gcc/doc/md.texi   |   14 ---
 gcc/expr.c|2 -
 gcc/fold-const.c  |   10 -
 gcc/genopinit.c   |4 +--
 gcc/gimple-pretty-print.c |2 -
 gcc/optabs.c  |   28 +-
 gcc/optabs.h  |5 ---
 gcc/tree-cfg.c|2 -
 gcc/tree-inline.c |2 -
 gcc/tree-pretty-print.c   |   16 
 gcc/tree-vect-data-refs.c |   86 ++--
 gcc/tree-vect-generic.c   |4 +--
 gcc/tree-vect-stmts.c |   14 
 gcc/tree-vectorizer.h |1 +
 gcc/tree.def  |4 --
 18 files changed, 77 insertions(+), 158 deletions(-)

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 8684721..8d2d34d 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -3449,8 +3449,6 @@ expand_debug_expr (tree exp)
 case VEC_COND_EXPR:
 case VEC_EXTRACT_EVEN_EXPR:
 case VEC_EXTRACT_ODD_EXPR:
-case VEC_INTERLEAVE_HIGH_EXPR:
-case VEC_INTERLEAVE_LOW_EXPR:
 case VEC_LSHIFT_EXPR:
 case VEC_PACK_FIX_TRUNC_EXPR:
 case VEC_PACK_SAT_EXPR:
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 1638799..439c55f 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -36013,6 +36013,8 @@ expand_vec_perm_palignr (struct expand_vec_perm_d *d)
   return ok;
 }
 
+static bool expand_vec_perm_interleave3 (struct expand_vec_perm_d *d);
+
 /* A subroutine of ix86_expand_vec_perm_builtin_1.  Try to simplify
a two vector permutation into a single vector permutation by using
an interleave operation to merge the vectors.  */
@@ -36039,6 +36041,17 @@ expand_vec_perm_interleave2 (struct expand_vec_perm_d 
*d)
   /* For 32-byte modes allow even d->op0 == d->op1.
 The lack of cross-lane shuffling in some instructions
 might prevent a single insn shuffle.  */
+  dfinal = *d;
+  dfinal.testing_p = true;
+  /* If expand_vec_perm_interleave3 can expand this into
+a 3 insn sequence, give up and let it be expanded as
+3 insn sequence.  While that is one insn longer,
+it doesn't need a memory operand and in the common
+case that both interleave low and high permutations
+with the same operands are adjacent needs 4 insns
+for both after CSE.  */
+  if (expand_vec_perm_interleave3 (&dfinal))
+   return false;
 }
   else
 return false;
@@ -36878,18 +36891,23 @@ expand_vec_perm_broadcast_1 (struct expand_vec_perm_d 
*d)
 stopping once we have promoted to V4SImode and then use pshufd.  */
   do
{
- optab otab = vec_interleave_low_optab;
+ rtx dest;
+ rtx (*gen) (rtx, rtx, rtx)
+   = vmode == V16QImode ? gen_vec_interleave_lowv16qi
+ 

[PATCH 3/6] ia64: Implement vec_perm_const.

2011-12-08 Thread Richard Henderson
---
 gcc/config/ia64/ia64-protos.h |4 +
 gcc/config/ia64/ia64.c|  424 +++--
 gcc/config/ia64/vect.md   |  183 +++---
 3 files changed, 441 insertions(+), 170 deletions(-)

diff --git a/gcc/config/ia64/ia64-protos.h b/gcc/config/ia64/ia64-protos.h
index a680c31..1cb46b6 100644
--- a/gcc/config/ia64/ia64-protos.h
+++ b/gcc/config/ia64/ia64-protos.h
@@ -61,6 +61,10 @@ extern int ia64_hard_regno_rename_ok (int, int);
 extern enum reg_class ia64_secondary_reload_class (enum reg_class,
   enum machine_mode, rtx);
 extern const char *get_bundle_name (int);
+
+extern void expand_vec_perm_even_odd_1 (rtx, rtx, rtx, int);
+extern bool ia64_expand_vec_perm_const (rtx op[4]);
+extern void ia64_expand_vec_setv2sf (rtx op[3]);
 #endif /* RTX_CODE */
 
 #ifdef TREE_CODE
diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c
index 64bd999..7bb9cec 100644
--- a/gcc/config/ia64/ia64.c
+++ b/gcc/config/ia64/ia64.c
@@ -329,6 +329,24 @@ static reg_class_t ia64_preferred_reload_class (rtx, 
reg_class_t);
 static enum machine_mode ia64_get_reg_raw_mode (int regno);
 static section * ia64_hpux_function_section (tree, enum node_frequency,
 bool, bool);
+
+static bool ia64_vectorize_vec_perm_const_ok (enum machine_mode vmode,
+ const unsigned char *sel);
+
+#define MAX_VECT_LEN   8
+
+struct expand_vec_perm_d
+{
+  rtx target, op0, op1;
+  unsigned char perm[MAX_VECT_LEN];
+  enum machine_mode vmode;
+  unsigned char nelt;
+  bool one_operand_p;
+  bool testing_p; 
+};
+
+static bool ia64_expand_vec_perm_const_1 (struct expand_vec_perm_d *d);
+
 
 /* Table of valid machine attributes.  */
 static const struct attribute_spec ia64_attribute_table[] =
@@ -623,6 +641,9 @@ static const struct attribute_spec ia64_attribute_table[] =
 #undef TARGET_DELAY_VARTRACK
 #define TARGET_DELAY_VARTRACK true
 
+#undef TARGET_VECTORIZE_VEC_PERM_CONST_OK
+#define TARGET_VECTORIZE_VEC_PERM_CONST_OK ia64_vectorize_vec_perm_const_ok
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 typedef enum
@@ -1962,28 +1983,28 @@ ia64_expand_vecint_minmax (enum rtx_code code, enum 
machine_mode mode,
 void
 ia64_unpack_assemble (rtx out, rtx lo, rtx hi, bool highp)
 {
-  enum machine_mode mode = GET_MODE (lo);
-  rtx (*gen) (rtx, rtx, rtx);
-  rtx x;
+  enum machine_mode vmode = GET_MODE (lo);
+  unsigned int i, high, nelt = GET_MODE_NUNITS (vmode);
+  struct expand_vec_perm_d d;
+  bool ok;
 
-  switch (mode)
+  d.target = gen_lowpart (vmode, out);
+  d.op0 = (TARGET_BIG_ENDIAN ? hi : lo);
+  d.op1 = (TARGET_BIG_ENDIAN ? lo : hi);
+  d.vmode = vmode;
+  d.nelt = nelt;
+  d.one_operand_p = false;
+  d.testing_p = false;
+
+  high = (highp ? nelt / 2 : 0);
+  for (i = 0; i < nelt / 2; ++i)
 {
-case V8QImode:
-  gen = highp ? gen_vec_interleave_highv8qi : gen_vec_interleave_lowv8qi;
-  break;
-case V4HImode:
-  gen = highp ? gen_vec_interleave_highv4hi : gen_vec_interleave_lowv4hi;
-  break;
-default:
-  gcc_unreachable ();
+  d.perm[i * 2] = i + high;
+  d.perm[i * 2 + 1] = i + high + nelt;
 }
 
-  x = gen_lowpart (mode, out);
-  if (TARGET_BIG_ENDIAN)
-x = gen (x, hi, lo);
-  else
-x = gen (x, lo, hi);
-  emit_insn (x);
+  ok = ia64_expand_vec_perm_const_1 (&d);
+  gcc_assert (ok);
 }
 
 /* Return a vector of the sign-extension of VEC.  */
@@ -10981,5 +11002,372 @@ ia64_hpux_function_section (tree decl 
ATTRIBUTE_UNUSED,
 {
   return NULL;
 }
+
+/* Construct (set target (vec_select op0 (parallel perm))) and
+   return true if that's a valid instruction in the active ISA.  */
+
+static bool
+expand_vselect (rtx target, rtx op0, const unsigned char *perm, unsigned nelt)
+{
+  rtx rperm[MAX_VECT_LEN], x;
+  unsigned i;
+
+  for (i = 0; i < nelt; ++i)
+rperm[i] = GEN_INT (perm[i]);
+
+  x = gen_rtx_PARALLEL (VOIDmode, gen_rtvec_v (nelt, rperm));
+  x = gen_rtx_VEC_SELECT (GET_MODE (target), op0, x);
+  x = gen_rtx_SET (VOIDmode, target, x);
+
+  x = emit_insn (x);
+  if (recog_memoized (x) < 0)
+{
+  remove_insn (x);
+  return false;
+}
+  return true;
+}
+
+/* Return a vector mode with twice as many elements as VMODE.  */
+/* ??? Consider moving this to a table generated by genmodes.c.  */
+
+static enum machine_mode
+doublesize_vector_mode (enum machine_mode vmode)
+{
+  switch (vmode)
+{
+case V2SFmode: return V4SFmode;
+case V2SImode: return V4SImode;
+case V4HImode: return V8HImode;
+case V8QImode: return V16QImode;
+
+default:
+  gcc_unreachable ();
+}
+}
+
+/* Similar, but generate a vec_concat from op0 and op1 as well.  */
+
+static bool
+expand_vselect_vconcat (rtx target, rtx op0, rtx op1,
+   const unsigned char *perm, unsigned nelt)
+{
+  enum machine_mode v2mode;
+  rtx x;
+
+  v2mode = doublesize_vector_m

[PATCH 6/6] arm: Implement vec_perm and vec_perm_const for NEON.

2011-12-08 Thread Richard Henderson
---
 gcc/config/arm/arm-protos.h   |3 +
 gcc/config/arm/arm.c  |  527 -
 gcc/config/arm/neon.md|   59 
 gcc/config/arm/vec-common.md  |   26 ++
 gcc/testsuite/lib/target-supports.exp |9 +-
 5 files changed, 620 insertions(+), 4 deletions(-)

diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h
index 296550a..8c3e412 100644
--- a/gcc/config/arm/arm-protos.h
+++ b/gcc/config/arm/arm-protos.h
@@ -244,4 +244,7 @@ extern const struct tune_params *current_tune;
 extern int vfp3_const_double_for_fract_bits (rtx);
 #endif /* RTX_CODE */
 
+extern void arm_expand_vec_perm (rtx target, rtx op0, rtx op1, rtx sel);
+extern bool arm_expand_vec_perm_const (rtx target, rtx op0, rtx op1, rtx sel);
+
 #endif /* ! GCC_ARM_PROTOS_H */
diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 65b4e9d..0395a41 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -267,6 +267,9 @@ static unsigned int arm_autovectorize_vector_sizes (void);
 static int arm_default_branch_cost (bool, bool);
 static int arm_cortex_a5_branch_cost (bool, bool);
 
+static bool arm_vectorize_vec_perm_const_ok (enum machine_mode vmode,
+const unsigned char *sel);
+
 
 /* Table of machine attributes.  */
 static const struct attribute_spec arm_attribute_table[] =
@@ -604,6 +607,10 @@ static const struct attribute_spec arm_attribute_table[] =
 #define TARGET_PREFERRED_RENAME_CLASS \
   arm_preferred_rename_class
 
+#undef TARGET_VECTORIZE_VEC_PERM_CONST_OK
+#define TARGET_VECTORIZE_VEC_PERM_CONST_OK \
+  arm_vectorize_vec_perm_const_ok
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 /* Obstack for minipool constant handling.  */
@@ -25064,6 +25071,524 @@ vfp3_const_double_for_fract_bits (rtx operand)
 }
   return 0;
 }
+
+#define MAX_VECT_LEN 16
 
-#include "gt-arm.h"
+struct expand_vec_perm_d
+{
+  rtx target, op0, op1;
+  unsigned char perm[MAX_VECT_LEN];
+  enum machine_mode vmode;
+  unsigned char nelt;
+  bool one_vector_p;
+  bool testing_p;
+};
+
+/* Generate a variable permutation.  */
+
+static void
+arm_expand_vec_perm_1 (rtx target, rtx op0, rtx op1, rtx sel)
+{
+  enum machine_mode vmode = GET_MODE (target);
+  bool one_vector_p = rtx_equal_p (op0, op1);
+
+  gcc_checking_assert (vmode == V8QImode || vmode == V16QImode);
+  gcc_checking_assert (GET_MODE (op0) == vmode);
+  gcc_checking_assert (GET_MODE (op1) == vmode);
+  gcc_checking_assert (GET_MODE (sel) == vmode);
+  gcc_checking_assert (TARGET_NEON);
+
+  if (one_vector_p)
+{
+  if (vmode == V8QImode)
+   emit_insn (gen_neon_vtbl1v8qi (target, op0, sel));
+  else
+   emit_insn (gen_neon_vtbl1v16qi (target, op0, sel));
+}
+  else
+{
+  enum machine_mode mode1, mode2;
+  rtx pair, part;
+
+  if (vmode == V8QImode)
+   mode1 = DImode, mode2 = TImode;
+  else
+   mode1 = TImode, mode2 = OImode;
+
+  pair = gen_reg_rtx (mode2);
+  emit_insn (gen_rtx_CLOBBER (VOIDmode, pair));
+
+  part = simplify_gen_subreg (mode1, pair, mode2,
+ subreg_lowpart_offset (mode1, mode2));
+  emit_move_insn (part, gen_lowpart (mode1, op0));
+
+  part = simplify_gen_subreg (mode1, pair, mode2,
+ subreg_highpart_offset (mode1, mode2));
+  emit_move_insn (part, gen_lowpart (mode1, op1));
+
+  if (vmode == V8QImode)
+   emit_insn (gen_neon_vtbl2v8qi (target, pair, sel));
+  else
+   emit_insn (gen_neon_vtbl2v16qi (target, pair, sel));
+}
+}
+
+void
+arm_expand_vec_perm (rtx target, rtx op0, rtx op1, rtx sel)
+{
+  enum machine_mode vmode = GET_MODE (target);
+  unsigned int i, nelt = GET_MODE_NUNITS (vmode);
+  bool one_vector_p = rtx_equal_p (op0, op1);
+  rtx rmask[MAX_VECT_LEN], mask;
+
+  /* TODO: ARM's VTBL indexing is little-endian.  In order to handle GCC's
+ numbering of elements for big-endian, we must reverse the order.  */
+  gcc_checking_assert (!BYTES_BIG_ENDIAN);
+
+  /* The VTBL instruction does not use a modulo index, so we must take care
+ of that ourselves.  */
+  mask = GEN_INT (one_vector_p ? nelt - 1 : 2 * nelt - 1);
+  for (i = 0; i < nelt; ++i)
+rmask[i] = mask;
+  mask = gen_rtx_CONST_VECTOR (vmode, gen_rtvec_v (nelt, rmask));
+  sel = expand_simple_binop (vmode, AND, sel, mask, NULL, 0, OPTAB_LIB_WIDEN);
+
+  arm_expand_vec_perm_1 (target, op0, op1, sel);
+}
+
+/* Generate or test for an insn that supports a constant permutation.  */
+
+/* Recognize patterns for the VUZP insns.  */
+
+static bool
+arm_evpc_neon_vuzp (struct expand_vec_perm_d *d)
+{
+  unsigned int i, odd, mask, nelt = d->nelt;
+  rtx out0, out1, in0, in1, x;
+  rtx (*gen)(rtx, rtx, rtx, rtx);
+
+  if (GET_MODE_UNIT_SIZE (d->vmode) >= 8)
+return false;
+
+  /* Note that these are little-endian tests.  Adjust for big-endian later.  */
+  if (d->perm[0] == 0)
+odd = 0;
+  els

[PATCH 5/6] mips: Implement vec_perm_const.

2011-12-08 Thread Richard Henderson
---
 gcc/config/mips/loongson.md|   24 +++-
 gcc/config/mips/mips-modes.def |1 +
 gcc/config/mips/mips-protos.h  |1 +
 gcc/config/mips/mips-ps-3d.md  |  145 ++
 gcc/config/mips/mips.c |  266 ++--
 gcc/config/mips/predicates.md  |7 +-
 6 files changed, 376 insertions(+), 68 deletions(-)

diff --git a/gcc/config/mips/loongson.md b/gcc/config/mips/loongson.md
index 225f4d1..23c37d7 100644
--- a/gcc/config/mips/loongson.md
+++ b/gcc/config/mips/loongson.md
@@ -403,12 +403,11 @@
 ;; Shuffle halfwords.
 (define_insn "loongson_pshufh"
   [(set (match_operand:VH 0 "register_operand" "=f")
-(unspec:VH [(match_operand:VH 1 "register_operand" "0")
-   (match_operand:VH 2 "register_operand" "f")
-   (match_operand:SI 3 "register_operand" "f")]
+(unspec:VH [(match_operand:VH 1 "register_operand" "f")
+   (match_operand:SI 2 "register_operand" "f")]
   UNSPEC_LOONGSON_PSHUFH))]
   "TARGET_HARD_FLOAT && TARGET_LOONGSON_VECTORS"
-  "pshufh\t%0,%2,%3"
+  "pshufh\t%0,%1,%2"
   [(set_attr "type" "fmul")])
 
 ;; Shift left logical.
@@ -479,7 +478,7 @@
   [(set_attr "type" "fadd")])
 
 ;; Unpack high data.
-(define_insn "vec_interleave_high"
+(define_insn "loongson_punpckh"
   [(set (match_operand:VWHB 0 "register_operand" "=f")
 (unspec:VWHB [(match_operand:VWHB 1 "register_operand" "f")
  (match_operand:VWHB 2 "register_operand" "f")]
@@ -489,7 +488,7 @@
   [(set_attr "type" "fdiv")])
 
 ;; Unpack low data.
-(define_insn "vec_interleave_low"
+(define_insn "loongson_punpckl"
   [(set (match_operand:VWHB 0 "register_operand" "=f")
 (unspec:VWHB [(match_operand:VWHB 1 "register_operand" "f")
  (match_operand:VWHB 2 "register_operand" "f")]
@@ -498,6 +497,19 @@
   "punpckl\t%0,%1,%2"
   [(set_attr "type" "fdiv")])
 
+(define_expand "vec_perm_const"
+  [(match_operand:VWHB 0 "register_operand" "")
+   (match_operand:VWHB 1 "register_operand" "")
+   (match_operand:VWHB 2 "register_operand" "")
+   (match_operand:VWHB 3 "" "")]
+  "TARGET_HARD_FLOAT && TARGET_LOONGSON_VECTORS"
+{
+  if (mips_expand_vec_perm_const (operands))
+DONE;
+  else
+FAIL;
+})
+
 ;; Integer division and modulus.  For integer multiplication, see mips.md.
 
 (define_insn "div3"
diff --git a/gcc/config/mips/mips-modes.def b/gcc/config/mips/mips-modes.def
index b9c508b..03b9632 100644
--- a/gcc/config/mips/mips-modes.def
+++ b/gcc/config/mips/mips-modes.def
@@ -29,6 +29,7 @@ FLOAT_MODE (TF, 16, mips_quad_format);
 VECTOR_MODES (INT, 8);/*   V8QI V4HI V2SI */
 VECTOR_MODES (FLOAT, 8);  /*V4HF V2SF */
 VECTOR_MODES (INT, 4);/*V4QI V2HI */
+VECTOR_MODES (FLOAT, 16);
 
 VECTOR_MODES (FRACT, 4);   /* V4QQ  V2HQ */
 VECTOR_MODES (UFRACT, 4);  /* V4UQQ V2UHQ */
diff --git a/gcc/config/mips/mips-protos.h b/gcc/config/mips/mips-protos.h
index dbabdff..37c958d 100644
--- a/gcc/config/mips/mips-protos.h
+++ b/gcc/config/mips/mips-protos.h
@@ -328,6 +328,7 @@ extern void mips_expand_atomic_qihi (union mips_gen_fn_ptrs,
 rtx, rtx, rtx, rtx);
 
 extern void mips_expand_vector_init (rtx, rtx);
+extern bool mips_expand_vec_perm_const (rtx op[4]);
 
 extern bool mips_eh_uses (unsigned int);
 extern bool mips_epilogue_uses (unsigned int);
diff --git a/gcc/config/mips/mips-ps-3d.md b/gcc/config/mips/mips-ps-3d.md
index 504f43c..d81abf8 100644
--- a/gcc/config/mips/mips-ps-3d.md
+++ b/gcc/config/mips/mips-ps-3d.md
@@ -89,61 +89,102 @@
   DONE;
 })
 
-; pul.ps - Pair Upper Lower
-(define_insn "mips_pul_ps"
+(define_insn "vec_perm_const_ps"
   [(set (match_operand:V2SF 0 "register_operand" "=f")
-   (vec_merge:V2SF
-(match_operand:V2SF 1 "register_operand" "f")
-(match_operand:V2SF 2 "register_operand" "f")
-(const_int 2)))]
+   (vec_select:V2SF
+ (vec_concat:V4SF
+   (match_operand:V2SF 1 "register_operand" "f")
+   (match_operand:V2SF 2 "register_operand" "f"))
+ (parallel [(match_operand:SI 3 "const_0_or_1_operand" "")
+(match_operand:SI 4 "const_2_or_3_operand" "")])))]
   "TARGET_HARD_FLOAT && TARGET_PAIRED_SINGLE_FLOAT"
-  "pul.ps\t%0,%1,%2"
+{
+  static const int * const mnemonics[2][4] = {
+/* LE */ { "pll.ps\t%0,%2,%1", "pul.ps\t%0,%2,%1",
+  "plu.ps\t%0,%2,%1", "puu.ps\t%0,%2,%1" },
+/* BE */ { "puu.ps\t%0,%1,%2", "plu.ps\t%0,%1,%2",
+  "pul.ps\t%0,%1,%2", "pll.ps\t%0,%1,%2" },
+  };
+
+  unsigned mask = INTVAL (operands[3]) * 2 + (INTVAL (operands[4]) - 2);
+  return mnemonics[WORDS_BIG_ENDIAN][mask];
+}
   [(set_attr "type" "fmove")
(set_attr "mode" "SF")])
 
-; puu.ps - Pair upper upper
-(define_insn "mips_puu_ps"
-  [(set (match_operand:V2SF 0 "register_operand" "=f")
-   (vec_merge:V2SF
-(match_operand:V2SF 1 "register_operand" 

[PATCH 4/6] rs6000: Cleanup interleave/even_odd/vec_perm.

2011-12-08 Thread Richard Henderson
Put merge-type insns in standard (vec_select (vec_concat)) form.
Delete vec_extract_{even,odd} patterns.
Delete or rename vec_interleave_{high,low} patterns.
Add vec_perm_const patterns for SPE, VSX, and Paired-Single.
---
 gcc/config/rs6000/altivec.md |  368 +++---
 gcc/config/rs6000/paired.md  |  116 ---
 gcc/config/rs6000/predicates.md  |   10 +
 gcc/config/rs6000/rs6000-builtin.def |8 +-
 gcc/config/rs6000/rs6000-modes.def   |   10 +-
 gcc/config/rs6000/rs6000-protos.h|3 +
 gcc/config/rs6000/rs6000.c   |  160 +++-
 gcc/config/rs6000/spe.md |   58 +++---
 gcc/config/rs6000/vector.md  |   74 +--
 gcc/config/rs6000/vsx.md |  151 +-
 10 files changed, 431 insertions(+), 527 deletions(-)

diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md
index 7797b65..54ca369 100644
--- a/gcc/config/rs6000/altivec.md
+++ b/gcc/config/rs6000/altivec.md
@@ -327,7 +327,7 @@
 (define_insn "*altivec_addv4sf3"
   [(set (match_operand:V4SF 0 "register_operand" "=v")
 (plus:V4SF (match_operand:V4SF 1 "register_operand" "v")
-  (match_operand:V4SF 2 "register_operand" "v")))]
+  (match_operand:V4SF 2 "register_operand" "v")))]
   "VECTOR_UNIT_ALTIVEC_P (V4SFmode)"
   "vaddfp %0,%1,%2"
   [(set_attr "type" "vecfloat")])
@@ -764,202 +764,112 @@
 
 (define_insn "altivec_vmrghb"
   [(set (match_operand:V16QI 0 "register_operand" "=v")
-(vec_merge:V16QI (vec_select:V16QI (match_operand:V16QI 1 
"register_operand" "v")
-  (parallel [(const_int 0)
- (const_int 8)
- (const_int 1)
- (const_int 9)
- (const_int 2)
- (const_int 10)
- (const_int 3)
- (const_int 11)
- (const_int 4)
- (const_int 12)
- (const_int 5)
- (const_int 13)
- (const_int 6)
- (const_int 14)
- (const_int 7)
- (const_int 15)]))
-(vec_select:V16QI (match_operand:V16QI 2 
"register_operand" "v")
-  (parallel [(const_int 8)
- (const_int 0)
- (const_int 9)
- (const_int 1)
- (const_int 10)
- (const_int 2)
- (const_int 11)
- (const_int 3)
- (const_int 12)
- (const_int 4)
- (const_int 13)
- (const_int 5)
- (const_int 14)
- (const_int 6)
- (const_int 15)
- (const_int 7)]))
- (const_int 21845)))]
+   (vec_select:V16QI
+ (vec_concat:V32QI
+   (match_operand:V16QI 1 "register_operand" "v")
+   (match_operand:V16QI 2 "register_operand" "v"))
+ (parallel [(const_int 0) (const_int 16)
+(const_int 1) (const_int 17)
+(const_int 2) (const_int 18)
+(const_int 3) (const_int 19)
+(const_int 4) (const_int 20)
+(const_int 5) (const_int 21)
+(const_int 6) (const_int 22)
+(const_int 7) (const_int 23)])))]
   "TARGET_ALTIVEC"
   "vmrghb %0,%1,%2"
   [(set_attr "type" "vecperm")])
 
 (define_insn "altivec_vmrghh"
   [(set (match_operand:V8HI 0 "register_operand" "=v")
-(vec_merge:V8HI (vec_select:V8HI (match_operand:V8HI 1 
"register_operand" "v")
-  (parallel [(const_int 0)
- (const_int 4)
- (const_int 1)
- 

Re: [PATCH] use -fno-pie on darwin in boehm-gc.exp

2011-12-08 Thread Jack Howarth
On Thu, Dec 08, 2011 at 08:55:17PM +, Iain Sandoe wrote:
>
> On 8 Dec 2011, at 20:15, Jack Howarth wrote:
>>>
>>> At present, you pass it when "no-pic, no-pie" etc. are - perhaps it
>>> should just be the default and *only* switched on for -pie something
>>> like
>>>
>>> %{!fpie: %{!PIE: %:version-compare(>= 10.7 mmacosx-version-min= -
>>> no_pie) } }
>>>
>>> Otherwise, D11 is behaving differently from other targets for the  
>>> whole
>>> test-suite - not just boehm-gc.
>>
>> Iain,
>>   One could make the alternative argument that the testing on linux is
>> currently incomplete because it is not done on any of the hardened  
>> linux
>> distros which utilize PIE such as...
>>
>> http://www.gentoo.org/proj/en/hardened/
>>
>> I find it very stange that there seems to be so little communication  
>> between
>> such projects and FSF gcc.
>
>
> [well the best solution would be to solve whatever problem stops boehm- 
> gc working with PIE on/off-- but that's not a job for this week ;-) ]
>
> ===
>
> So to recap ---
> IMO it's better if we can do the same as the vendor's tools on the  
> target system, providing that's not provably buggy.
> (I think that's our general policy on Darwin, right?).
>
> So, yes, you are correct, I would prefer not to switch PIE off ...
>
> ... but then, I guess, the test-suite makes the "assumption" that PIE is 
> off by default ...

Iain,
The same argument could be made for PIC itself regarding the testsuite. 
Aren't we still the only target that defaults to PIC objects? I would think that
the fact that we test against PIE on darwin11 and later would be a bonus for
FSF gcc since they don't seem to get much feedback directly from the hardened
linux projects. Better to just turn off PIE for the few problem test cases
and retain the wider testing against PIE in order to look for potential problems
(since one really doesn't want to test the compiler in mode completely alien
to how it will be used in practice... that is with PIE linkage).
  Jack

>
> ... so, perhaps a solution is to run it  RUNTESTFLAGS=" \-fno-PIE ... 
> " on Darwin11.
>
> --
>
> similarly,  the hardened linux guys could do  ... RUNTESTFLAGS="\{- 
> fPIE... "  if they want to test coverage with PIE on.
>
> --
>
> ... of course, that breaks when there are specific tests that *are* PIE 
> aware ...
>
> ... so the 'easy way out' is to make D11 behave as per earlier versions 
> (i.e. default PIE off);
>
> 
>
> for a small number of tests ..  { dg-additional-options ... } would be  
> more transparent than modifying
> lib/something.exp
>
> ... but, I'll bow out at this juncture -
> - we've established the underlying issue - which isn't likely to get  
> solved with specs or test-suite options.
>
> cheers
> Iain


[pph] Fix references to external PPH files (issue5476043)

2011-12-08 Thread Diego Novillo
This fixes a bug in the creation of external references to PPH images.

We save references to external PPH files when we save the line table for
the parent header.  Sometimes we were not saving a proper reference
because the path names of the header as found in the line map could
not be matched with the external PPH file.

This fixes the problem by encoding the path name of the original
header file into each PPH file.  This way, we do not have to play
guessing games when saving the line table.  We are still dependent on
the path names of the original headers to be in the same location that
the PPH was generated from.  If a header moves to a different
location, then we won't be able to match it to a PPH image.

The final solution will involve being cognizant of the path scheme
used by libcpp, but this will serve for the time being.

Tested on x86_64.  Committed.


Diego.

* pph-streamer.h (struct pph_stream): Add field HEADER_NAME.
* pph-in.c (pph_in_line_table_and_includes): Read it.
* pph-out.c (pph_init_write): Initialize it from input_filename.
(pph_filename_eq_ignoring_path): Remove.
(pph_out_line_table_and_includes): Write STREAM->HEADER_NAME.
Compare the file name in LM against STREAM->HEADER_NAME to
decide whether to write a reference to an external PPH.

diff --git a/gcc/cp/pph-in.c b/gcc/cp/pph-in.c
index 52a56aa..323516d 100644
--- a/gcc/cp/pph-in.c
+++ b/gcc/cp/pph-in.c
@@ -355,6 +355,10 @@ pph_in_line_table_and_includes (pph_stream *stream)
   used_before = LINEMAPS_ORDINARY_USED (line_table);
   first = true;
 
+  /* Read the path name of the original text header file that was
+ used to generate STREAM.  */
+  stream->header_name = pph_in_string (stream);
+
   /* All line map entries that have -1 as the includer, will now be
  relocated to the current last line map entry in the line table.  */
   top_includer_ix = used_before - 1;
diff --git a/gcc/cp/pph-out.c b/gcc/cp/pph-out.c
index e970f86..01c364a 100644
--- a/gcc/cp/pph-out.c
+++ b/gcc/cp/pph-out.c
@@ -65,6 +65,10 @@ pph_init_write (pph_stream *stream)
   /* Associate STREAM with stream->encoder.w.ob so we can recover it from the
  streamer hooks.  */
   stream->encoder.w.ob->sdata = (void *) stream;
+
+  /* Since we are about to generate STREAM, its header name is the
+ name of the header file that we are currently parsing.  */
+  stream->header_name = xstrdup (input_filename);
 }
 
 
@@ -280,45 +284,6 @@ pph_out_include (pph_stream *stream, pph_stream *include,
 }
 
 
-/* Compare filenames of a header and it's potentially corresponding pph file,
-   stripping the path passed in and the extension. Returns true if HEADER_PATH
-   and PPH_PATH end with the same filename. We expect HEADER_PATH to end in .h
-   and PPH_PATH to end in .pph.
-
-   FIXME pph: We should not need to do this if we handled include paths
-   correctly, but for now the linemap holds full paths and the stream's 
includes
-   list only holds the include name.  Also, the stream's includes hold pph
-   filenames where as the line_table as header filenames.  */
-
-static bool
-pph_filename_eq_ignoring_path (const char *header_path, const char *pph_path)
-{
-  const char *header_name = lbasename (header_path);
-  const char *pph_name = lbasename (pph_path);
-
-  const char *header_ext = strchr (header_name, '.');
-  const char *pph_ext = strchr (pph_name, '.');
-
-  unsigned int name_length;
-
-  if (header_ext != NULL)
-{
-  name_length = header_ext - header_name;
-  gcc_assert (strcmp (header_ext, ".h") == 0);
-}
-  else
-/* Some headers do not have a .h suffix, but will still
-   have a .pph suffix after being pph'ed.  */
-name_length = strlen (header_name);
-
-  gcc_assert (strcmp (pph_ext, ".pph") == 0);
-
-  /* Compare the filenames without their extension.  */
-  return pph_ext - pph_name == name_length
- && strncmp (header_name, pph_name, name_length) == 0;
-}
-
-
 /* Return the *NEXT_INCLUDE_IX'th pph_stream in STREAM's list of includes.
Returns NULL if we have read all includes.  Increments *NEXT_INCLUDE_IX
when sucessful.  */
@@ -351,6 +316,10 @@ pph_out_line_table_and_includes (pph_stream *stream)
   /* Any #include should have been fully parsed and exited at this point.  */
   gcc_assert (line_table->depth == 0);
 
+  /* Write the path name of the original text header file that was
+ used to generate STREAM.  */
+  pph_out_string (stream, stream->header_name);
+
   current_include = pph_get_next_include (stream, &next_incl_ix);
 
   for (ix = PPH_NUM_IGNORED_LINE_TABLE_ENTRIES;
@@ -379,8 +348,7 @@ pph_out_line_table_and_includes (pph_stream *stream)
 reference to it, so the reader can load the included image at
 this point.  */
   if (current_include != NULL
- && pph_filename_eq_ignoring_path (LINEMAP_FILE (lm),
-   current_include->name))
+ && strcmp (current_include

[PATCH] Make #pragma GCC target properly change macros and fix recip-5 failures

2011-12-08 Thread Michael Meissner
These patches add support for #pragma GCC target("...") on the powerpc to
change the default macros defined like tha x86 does (and the powerpc did for
the target attribute).  When adding support for changing macros on the target
attribute, I forgot to enable the code for #pragma as well.

Also, the recip-5.c test has been failing on systems that don't support VSX,
such as Darwin.  The test itself should not have been run on those system, as I
forgot to add the standard lines for VSX patches to the test.  In addition,
when reporting the bug, the compiler segfaulted.  This was due to the expand
builtin function returning NULL or const0_rtx (depending on the error), and the
higher level code was not expecting NULL.  For this case, I did a normal
expand_call operation.

I did make boostrap and there were no regressions.  Is it ok to install these
patches?

[gcc]
2011-12-08  Michael Meissner  

* config/rs6000/rs6000.c (altivec_expand_builtin): Call
expand_call to return a valid funciton instead of return
cosnt0_rtx/NULL_RTX if there was an error with the builtin.
(altivec_expand_ld_builtin): Ditto.
(rs6000_inner_target_options): If VSX is selected as a target
attribute or pragma, enable ALTIVEC also.
(rs6000_pragma_target_parse): Call rs6000_option_override_internal
to do all of the standard processing when switching options,
including redefining appropriate macros.

[gcc/testsuite]
2011-12-08  Michael Meissner  

* gcc.target/powerpc/recip-5.c: Disable running on any system that
does not support VSX.

-- 
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



Re: [testsuite,committed]: Fix wrong sizeof(int)==4 assumption (yet another time)

2011-12-08 Thread Eric Botcazou
> I allowed me to apply the following change:
>
> http://gcc.gnu.org/viewcvs?view=revision&revision=182109

Then you need to do the same on the 4.6 branch.

> Besides that: Why are there new test cases in gcc.c-torture?
>
> As far as I remember that place is deprecated and the preferred place for
> new C tests like this is gcc.dg?

What makes you think so?

-- 
Eric Botcazou


Re: [PATCH] Fix PR middle-end/45416, missing opt for (a&(1<

2011-12-08 Thread Richard Henderson
On 12/06/2011 08:17 PM, Andrew Pinski wrote:
> +   if (a & (long long) 0x400)
> +  return 1;
> +   return 0;
> +}
> +
> +/* { dg-final { scan-assembler "andl" { target i?86-*-linux* x86_64-*-linux* 
> } } } " */
> +/* { dg-final { scan-assembler "setne" { target i?86-*-linux* 
> x86_64-*-linux* } } }" */

Huh?  Why would we want to find setne here?


r~


Re: [PATCH, PR43814] Assume function arguments of pointer type are aligned.

2011-12-08 Thread Eric Botcazou
>   * expr.c (get_object_or_type_alignment): Remove static.
>   * expr.h (get_object_or_type_alignment): Declare.

I did that this morning (and also added an assertion in the function).

-- 
Eric Botcazou


[PATCH] Make #pragma GCC target properly change macros and fix recip-5 failures

2011-12-08 Thread Michael Meissner
On Thu, Dec 08, 2011 at 04:26:07PM -0500, Michael Meissner wrote:
> These patches add support for #pragma GCC target("...") on the powerpc to
> change the default macros defined like tha x86 does (and the powerpc did for
> the target attribute).  When adding support for changing macros on the target
> attribute, I forgot to enable the code for #pragma as well.
> 
> Also, the recip-5.c test has been failing on systems that don't support VSX,
> such as Darwin.  The test itself should not have been run on those system, as 
> I
> forgot to add the standard lines for VSX patches to the test.  In addition,
> when reporting the bug, the compiler segfaulted.  This was due to the expand
> builtin function returning NULL or const0_rtx (depending on the error), and 
> the
> higher level code was not expecting NULL.  For this case, I did a normal
> expand_call operation.
> 
> I did make boostrap and there were no regressions.  Is it ok to install these
> patches?
> 
> [gcc]
> 2011-12-08  Michael Meissner  
> 
>   * config/rs6000/rs6000.c (altivec_expand_builtin): Call
>   expand_call to return a valid funciton instead of return
>   cosnt0_rtx/NULL_RTX if there was an error with the builtin.
>   (altivec_expand_ld_builtin): Ditto.
>   (rs6000_inner_target_options): If VSX is selected as a target
>   attribute or pragma, enable ALTIVEC also.
>   (rs6000_pragma_target_parse): Call rs6000_option_override_internal
>   to do all of the standard processing when switching options,
>   including redefining appropriate macros.
> 
> [gcc/testsuite]
> 2011-12-08  Michael Meissner  
> 
>   * gcc.target/powerpc/recip-5.c: Disable running on any system that
>   does not support VSX.
> 
> -- 
> 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

Sigh.  Patch attached. 

-- 
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/testsuite/gcc.target/powerpc/recip-5.c
===
--- gcc/testsuite/gcc.target/powerpc/recip-5.c  (revision 182134)
+++ gcc/testsuite/gcc.target/powerpc/recip-5.c  (working copy)
@@ -1,5 +1,6 @@
 /* { dg-do compile { target { powerpc*-*-* } } } */
-/* { dg-require-effective-target powerpc_fprs } */
+/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
+/* { dg-require-effective-target powerpc_vsx_ok } */
 /* { dg-options "-O3 -ftree-vectorize -mrecip=all -ffast-math -mcpu=power7 
-fno-unroll-loops" } */
 /* { dg-final { scan-assembler-times "xvredp" 4 } } */
 /* { dg-final { scan-assembler-times "xvresp" 5 } } */

Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 182134)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -10578,7 +10578,9 @@ altivec_expand_builtin (tree exp, rtx ta
 {
   *expandedp = true;
   error ("unresolved overload for Altivec builtin %qF", fndecl);
-  return const0_rtx;
+
+  /* Given it is invalid, just generate a normal call.  */
+  return expand_call (exp, target, false);
 }
 
   target = altivec_expand_ld_builtin (exp, target, expandedp);
@@ -11306,7 +11308,9 @@ rs6000_expand_builtin (tree exp, rtx tar
   if (!func_valid_p)
 {
   rs6000_invalid_builtin (fcode);
-  return NULL_RTX;
+
+  /* Given it is invalid, just generate a normal call.  */
+  return expand_call (exp, target, ignore);
 }
 
   switch (fcode)
@@ -26789,6 +26793,11 @@ rs6000_inner_target_options (tree args, 
error_p = false;
target_flags_explicit |= mask;
 
+   /* VSX needs altivec, so -mvsx automagically sets
+  altivec.  */
+   if (mask == MASK_VSX && !invert)
+ mask |= MASK_ALTIVEC;
+
if (rs6000_opt_masks[i].invert)
  invert = !invert;
 
@@ -27001,7 +27010,6 @@ rs6000_pragma_target_parse (tree args, t
   struct cl_target_option *prev_opt, *cur_opt;
   unsigned prev_bumask, cur_bumask, diff_bumask;
   int prev_flags, cur_flags, diff_flags;
-  bool ret;
 
   if (TARGET_DEBUG_TARGET)
 {
@@ -27023,7 +27031,6 @@ rs6000_pragma_target_parse (tree args, t
 
   if (! args)
 {
-  ret = true;
   cur_tree = ((pop_target)
  ? pop_target
  : target_option_default_node);
@@ -27033,13 +27040,13 @@ rs6000_pragma_target_parse (tree args, t
   else
 {
   rs6000_cpu_index = rs6000_tune_index = -1;
-  ret = rs6000_inner_target_options (args, false);
-  cur_tree = build_target_option_node ();
-
-  if (!cur_tree)
+  if (!rs6000_inner_target_options (args, false)
+ || !rs6000_option_override_internal (false)
+ || (cur_tree = build_target_

Re: [patch, fortran] Fix PR 50690

2011-12-08 Thread Jakub Jelinek
On Thu, Dec 08, 2011 at 08:48:31PM +0100, Thomas Koenig wrote:
> this is what I hope is the final round of the OMP front-end optimization
> patch.  This one ignores outer workshares when doing function
> elimination within omp do and similar blocks.

Sorry, stopped reading the patch details once noticing you are
reimplementing vec.h.  Reading it again, isn't it overkill to keep the
vector?  All you need is a bool and a way to restore its previous state.

static bool in_omp_workshare;

and in gfc_code_walker:

  bool save_in_omp_workshare = in_omp_workshare;
  switch (...)
case EXEC_OMP_WORKSHARE:
case EXEC_OMP_PARALLEL_WORKSHARE:
  in_omp_workshare = true;
  ...
case EXEC_OMP_PARALLEL:
case EXEC_OMP_PARALLEL_DO:
case EXEC_OMP_PARALLEL_SECTIONS:
  in_omp_workshare = false;
  ...
  ...
  in_omp_workshare = save_in_omp_workshare;

That said, it would be nice if the other vector-ish array got vec.h-ized.

> ! { dg-do compile }
> ! { dg-options "-ffrontend-optimize -fdump-tree-original" }
> ! PR 50690 - this used to ICE because workshare could not handle
> ! BLOCKs.
> ! To test for correct execution, run this program (but don't forget
> ! to unset the stack limit).
> program foo
>   implicit none
>   integer, parameter :: n = 1

Why can't you use a reasonable size, like 10?

Jakub


Re: [4.7][google] Adding a new option -fstack-protector-strong. (issue5461043)

2011-12-08 Thread 沈涵
Hi, Jakub, thanks! Patches modified according to gnu coding standards. -Han

Patches (also on http://codereview.appspot.com/5461043)

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 8684721..e584cae 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -1507,15 +1507,37 @@ estimated_stack_frame_size (struct cgraph_node *node)
   return size;
 }

+/* Helper routine to check if a record or union contains an array field. */
+
+static int record_or_union_type_has_array(tree tree_type)
+{
+  tree fields = TYPE_FIELDS(tree_type);
+  tree f;
+  for (f = fields; f; f = DECL_CHAIN (f))
+{
+  if (TREE_CODE(f) == FIELD_DECL)
+   {
+ tree field_type = TREE_TYPE(f);
+ if (RECORD_OR_UNION_TYPE_P(field_type))
+   return record_or_union_type_has_array(field_type);
+ if (TREE_CODE(field_type) == ARRAY_TYPE)
+   return 1;
+   }
+}
+  return 0;
+}
+
 /* Expand all variables used in the function.  */

 static void
 expand_used_vars (void)
 {
   tree var, outer_block = DECL_INITIAL (current_function_decl);
+  referenced_var_iterator rvi;
   VEC(tree,heap) *maybe_local_decls = NULL;
   unsigned i;
   unsigned len;
+  int gen_stack_protect_signal = 0;

   /* Compute the phase of the stack frame for this function.  */
   {
@@ -1548,6 +1570,20 @@ expand_used_vars (void)
}
 }

+  FOR_EACH_REFERENCED_VAR(cfun, var, rvi)
+if (!is_global_var(var) && TREE_ADDRESSABLE(var))
+  ++gen_stack_protect_signal;
+
+  /* Examine local variable declaration. */
+  if (!gen_stack_protect_signal)
+FOR_EACH_LOCAL_DECL (cfun, i, var)
+  if (TREE_CODE(var) == VAR_DECL && !is_global_var(var)) {
+   tree var_type = TREE_TYPE(var);
+   gen_stack_protect_signal += (TREE_CODE(var_type) == ARRAY_TYPE) ||
+ (RECORD_OR_UNION_TYPE_P(var_type) &&
+  record_or_union_type_has_array(var_type));
+  }
+
   /* At this point all variables on the local_decls with TREE_USED
  set are not associated with any block scope.  Lay them out.  */

@@ -1638,12 +1674,17 @@ expand_used_vars (void)
dump_stack_var_partition ();
 }

-  /* There are several conditions under which we should create a
- stack guard: protect-all, alloca used, protected decls present.  */
+  /* There are several conditions under which we should create a stack guard:
+ protect-all, alloca used, protected decls present or a positive
+ gen_stack_protect_signal. */
   if (flag_stack_protect == 2
-  || (flag_stack_protect
+  || (flag_stack_protect == 1
  && (cfun->calls_alloca || has_protected_decls)))
 create_stack_guard ();
+  else if (flag_stack_protect == 3 &&
+  (gen_stack_protect_signal ||
+   cfun->calls_alloca || has_protected_decls))
+create_stack_guard ();

   /* Assign rtl to each variable based on these partitions.  */
   if (stack_vars_num > 0)
diff --git a/gcc/common.opt b/gcc/common.opt
index 55d3f2d..1ad9717 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1848,6 +1848,10 @@ fstack-protector-all
 Common Report RejectNegative Var(flag_stack_protect, 2)
 Use a stack protection method for every function

+fstack-protector-strong
+Common Report RejectNegative Var(flag_stack_protect, 3)
+Use a smart stack protection method for certain functions
+
 fstack-usage
 Common RejectNegative Var(flag_stack_usage)
 Output stack usage information on a per-function basis
diff --git a/gcc/testsuite/gcc.dg/fstack-protector-strong.c
b/gcc/testsuite/gcc.dg/fstack-protector-strong.c
new file mode 100644
index 000..3f9d3e7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fstack-protector-strong.c
@@ -0,0 +1,121 @@
+/* Test that stack protection is done on chosen functions. */
+
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O2 -fstack-protector-strong" } */
+
+#include
+#include
+
+extern int g0;
+extern int *pg0;
+int goo(int *);
+int hoo(int);
+
+/* Function frame address escaped function call. */
+int foo1()
+{
+  int i;
+  return goo(&i);
+}
+
+struct ArrayStruct
+{
+  int a;
+  int array[10];
+};
+
+struct AA
+{
+  int b;
+  struct ArrayStruct as;
+};
+
+/* Function frame contains array. */
+int foo2()
+{
+  struct AA aa;
+  int i;
+  for (i = 0; i < 10; ++i)
+{
+  aa.as.array[i] = i * (i-1) + i / 2;
+}
+  return aa.as.array[5];
+}
+
+/* Address computation based on a function frame address. */
+int foo3()
+{
+  int a;
+  int *p;
+  p = &a + 5;
+  return goo(p);
+}
+
+/* Address cast based on a function frame address. */
+int foo4()
+{
+  int a;
+  return goo(g0 << 2 ? (int *)(3 * (long)(void *)(&a)) : 0);
+}
+
+/* Address cast based on a local array. */
+int foo5()
+{
+  short array[10];
+  return goo((int *)(array + 5));
+}
+
+struct BB
+{
+  int one;
+  int two;
+  int three;
+};
+
+/* Address computaton based on a function frame address.*/
+int foo6()
+{
+  struct BB bb;
+  return goo(&bb.one + sizeof(int));
+}
+
+/* Function frame address es

Re: [PATCH] Fix PR middle-end/45416, missing opt for (a&(1<

2011-12-08 Thread Andrew Pinski
On Thu, Dec 8, 2011 at 1:32 PM, Richard Henderson  wrote:
> On 12/06/2011 08:17 PM, Andrew Pinski wrote:
>> +   if (a & (long long) 0x400)
>> +      return 1;
>> +   return 0;
>> +}
>> +
>> +/* { dg-final { scan-assembler "andl" { target i?86-*-linux* 
>> x86_64-*-linux* } } } " */
>> +/* { dg-final { scan-assembler "setne" { target i?86-*-linux* 
>> x86_64-*-linux* } } }" */
>
> Huh?  Why would we want to find setne here?

I fixed that in the patch which I committed and I forgot to mention that here.

Thanks,
Andrew Pinski


Re: [4.7][google] Adding a new option -fstack-protector-strong. (issue5461043)

2011-12-08 Thread Jakub Jelinek
On Thu, Dec 08, 2011 at 02:02:23PM -0800, Han Shen(沈涵) wrote:
> Hi, Jakub, thanks! Patches modified according to gnu coding standards. -Han

Not completely:
> +/* Helper routine to check if a record or union contains an array field. */
> +
> +static int record_or_union_type_has_array(tree tree_type)

This needs to be
static int
record_or_union_type_has_array (tree tree_type)

(function name at column 1, space before ( ).

> +{
> +  tree fields = TYPE_FIELDS(tree_type);

Space before ( (in many places through the whole patch).

> +  if (TREE_CODE(var) == VAR_DECL && !is_global_var(var)) {

  if (...)
{
  tree

> + tree var_type = TREE_TYPE(var);
> + gen_stack_protect_signal += (TREE_CODE(var_type) == ARRAY_TYPE) ||
> +   (RECORD_OR_UNION_TYPE_P(var_type) &&
> +record_or_union_type_has_array(var_type));

|| and && go on the next line, you probably want
gen_stack_protect_signal
  += (TREE_CODE (var_type) == ARRAY_TYPE
  || (RECORD_OR_UNION_TYPE_P (var_type)
  && record_or_union_type_has_array (var_type)));

> +  else if (flag_stack_protect == 3 &&
> +(gen_stack_protect_signal ||
> + cfun->calls_alloca || has_protected_decls))

Again.

Jakub


C++ PATCH for c++/51459 (wrong code with lambda in template)

2011-12-08 Thread Jason Merrill
Here the problem was that we ended up inappropriately calling 
cp_finish_decl on the capture proxies at instantiation time.  Fixed by 
handling them specially.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit ec77b5bed80dde351ee2086386f0c2282fdffa14
Author: Jason Merrill 
Date:   Thu Dec 8 14:01:45 2011 -0500

	PR c++/51459
	* pt.c (tsubst_expr) [DECL_EXPR]: Handle capture proxies properly.
	* semantics.c (insert_capture_proxy): No longer static.
	* cp-tree.h: Declare it.

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index dccf485..87cb8b6 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -5593,6 +5593,7 @@ extern void apply_lambda_return_type(tree, tree);
 extern tree add_capture (tree, tree, tree, bool, bool);
 extern tree add_default_capture (tree, tree, tree);
 extern tree build_capture_proxy			(tree);
+extern void insert_capture_proxy		(tree);
 extern void insert_pending_capture_proxies	(void);
 extern bool is_capture_proxy			(tree);
 extern bool is_normal_capture_proxy (tree);
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 7603c11..296cd54 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -12810,6 +12810,11 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
 		&& ANON_AGGR_TYPE_P (TREE_TYPE (decl)))
 		  /* Anonymous aggregates are a special case.  */
 		  finish_anon_union (decl);
+		else if (is_capture_proxy (DECL_EXPR_DECL (t)))
+		  {
+		DECL_CONTEXT (decl) = current_function_decl;
+		insert_capture_proxy (decl);
+		  }
 		else
 		  {
 		int const_init = false;
diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index 9a1043a..2dab6a7 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -8804,7 +8804,7 @@ is_normal_capture_proxy (tree decl)
 /* VAR is a capture proxy created by build_capture_proxy; add it to the
current function, which is the operator() for the appropriate lambda.  */
 
-static inline void
+void
 insert_capture_proxy (tree var)
 {
   cp_binding_level *b;
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template4.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template4.C
new file mode 100644
index 000..a65727a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-template4.C
@@ -0,0 +1,42 @@
+// PR c++/51459
+// { dg-do run { target c++11 } }
+
+struct func {
+virtual ~func() { }
+virtual void operator()() const = 0;
+virtual func* clone() const = 0;
+};
+
+template
+struct funcimpl : func {
+explicit funcimpl(T t) : t(t) { }
+void operator()() const { t(); }
+func* clone() const { return new funcimpl(*this); }
+T t;
+};
+
+struct function
+{
+func* p;
+
+template
+function(T t) : p(new funcimpl(t)) { }
+
+~function() { delete p; }
+
+function(const function& f) : p(f.p->clone()) { }
+
+function& operator=(const function& ) = delete;
+
+void operator()() const { (*p)(); }
+};
+
+template 
+function animate(F f) { return [=]{ f(); }; }
+
+int main()
+{
+  function linear1 = []{};
+  function av(animate(linear1));
+  av();
+}


C++ PATCH for c++/51318 (confusion with rvalue ?: in template)

2011-12-08 Thread Jason Merrill
This was an unfortunate interaction between the two hunks of my patch 
for 50835; lvalue_kind started assuming lvalue in C++98 templates, and 
then build_x_conditional_expr saw that and tried to play reference games 
as a result.  Fixed by only playing reference games in C++11 mode.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 5812d63f059c71b570ab840bb0381c5f45c93443
Author: Jason Merrill 
Date:   Thu Dec 8 15:46:57 2011 -0500

	PR c++/51318
	* typeck.c (build_x_conditional_expr): Restrict glvalue games to C++11.

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 9a5365c..4973d7d 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -5517,8 +5517,10 @@ build_x_conditional_expr (tree ifexp, tree op1, tree op2,
 {
   tree min = build_min_non_dep (COND_EXPR, expr,
 orig_ifexp, orig_op1, orig_op2);
-  /* Remember that the result is an lvalue or xvalue.  */
-  if (lvalue_or_rvalue_with_address_p (expr)
+  /* In C++11, remember that the result is an lvalue or xvalue.
+ In C++98, lvalue_kind can just assume lvalue in a template.  */
+  if (cxx_dialect >= cxx0x
+	  && lvalue_or_rvalue_with_address_p (expr)
 	  && !lvalue_or_rvalue_with_address_p (min))
 	TREE_TYPE (min) = cp_build_reference_type (TREE_TYPE (min),
 		   !real_lvalue_p (expr));
diff --git a/gcc/testsuite/g++.dg/template/cond8.C b/gcc/testsuite/g++.dg/template/cond8.C
new file mode 100644
index 000..a3bad7e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/cond8.C
@@ -0,0 +1,10 @@
+// PR c++/51318
+
+enum { e0, e1 };
+
+template struct A {};
+
+template struct B
+{
+  A a;
+};


[PATCH] PR 51469, Make gnu indirect functions always non-local

2011-12-08 Thread Michael Meissner
I noticed that most of the attr-ifunc tests were failing on the PowerPC.  I
tracked it down to the fact that in varasm.c the indirect function is
considered a local function.  On the powerpc in 64-bit mode or 32-bit mode
under AIX, a local function uses the same TOC value in r2 as the caller, so the
compiler can just implmenet a BL instruction.  For non-local functions, the
compiler issues BL followed by a NOP, which might be modified by the linker to
reload the TOC value into r2.  In the case of the indirect functions, the
linker needs to convert the call to always going through the PLT (procedure
linkage table), and it won't do the optimization if the BL is not followed by a
NOP.

This patch makes indirect functions always non-local, much like weak symbols
are.  Note, in the general case, the resolver function could potentially
resolve to a non-local function, so I feel this patch is correct for all ports.
I did a bootstrap and make check on the powerpc with no regressions, and the
attr-ifunc tests are fixed.  Is it ok to apply to the tree (and backport to
4.6)?

2011-12-08  Michael Meissner  

PR rtl-optimization/51469
* varasm.c (default_binds_local_p_1): If the symbol is a gnu
indirect function, mark the symbol as non-local.

Index: gcc/varasm.c
===
--- gcc/varasm.c(revision 182092)
+++ gcc/varasm.c(working copy)
@@ -6911,11 +6911,14 @@ default_binds_local_p_1 (const_tree exp,
   /* A non-decl is an entry in the constant pool.  */
   if (!DECL_P (exp))
 local_p = true;
-  /* Weakrefs may not bind locally, even though the weakref itself is
- always static and therefore local.
- FIXME: We can resolve this more curefuly by looking at the weakref
- alias.  */
-  else if (lookup_attribute ("weakref", DECL_ATTRIBUTES (exp)))
+  /* Weakrefs may not bind locally, even though the weakref itself is always
+ static and therefore local.  Similarly, the resolver for ifunc functions
+ might resolve to a non-local function.
+ FIXME: We can resolve the weakref case more curefuly by looking at the
+ weakref alias.  */
+  else if (lookup_attribute ("weakref", DECL_ATTRIBUTES (exp))
+  || (TREE_CODE (exp) == FUNCTION_DECL
+  && lookup_attribute ("ifunc", DECL_ATTRIBUTES (exp
 local_p = false;
   /* Static variables are always local.  */
   else if (! TREE_PUBLIC (exp))

-- 
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



Re: [4.7][google] Adding a new option -fstack-protector-strong. (issue5461043)

2011-12-08 Thread Andrew Pinski
On Thu, Dec 8, 2011 at 2:02 PM, Han Shen(沈涵)  wrote:
> +  FOR_EACH_REFERENCED_VAR(cfun, var, rvi)
> +    if (!is_global_var(var) && TREE_ADDRESSABLE(var))
> +      ++gen_stack_protect_signal;
> +
> +  /* Examine local variable declaration. */
> +  if (!gen_stack_protect_signal)
> +    FOR_EACH_LOCAL_DECL (cfun, i, var)
> +      if (TREE_CODE(var) == VAR_DECL && !is_global_var(var)) {
> +       tree var_type = TREE_TYPE(var);
> +       gen_stack_protect_signal += (TREE_CODE(var_type) == ARRAY_TYPE) ||
> +         (RECORD_OR_UNION_TYPE_P(var_type) &&
> +          record_or_union_type_has_array(var_type));
> +      }

How about merging the above two loops and break if you set
gen_stack_protect_signal?  Also I think it is better if you only look
at referenced variables rather than just all local decls.

Something like:
 FOR_EACH_REFERENCED_VAR(cfun, var, rvi)
  if (!is_global_var(var))
{
  tree var_type = TREE_TYPE(var);
  if (TREE_ADDRESSABLE(var))
{
  gen_stack_protect_signal = true;
  break;
}
  if (TREE_CODE (var) == VAR_DECL
 && (TREE_CODE (var_type) == ARRAY_TYPE
   || (RECORD_OR_UNION_TYPE_P (var_type)
   && record_or_union_type_has_array (var_type
{
  gen_stack_protect_signal = true;
  break;
}
}

Also I think you should use const_tree in some places like:
>static int record_or_union_type_has_array(tree tree_type)
static int
record_or_union_type_has_array (const_tree tree_type)

Thanks,
Andrew Pinski


Re: [4.7][google] Adding a new option -fstack-protector-strong. (issue5461043)

2011-12-08 Thread Andrew Pinski
On Thu, Dec 8, 2011 at 2:02 PM, Han Shen(沈涵)  wrote:
> +/* Address taken on struct. */
> +int foo10()
> +{
> +  struct BB bb;
> +  int i;
> +  memset(&bb, 5, sizeof bb);
> +  for (i = 0; i < 10; ++i)
> +    {
> +      bb.one = i;
> +      bb.two = bb.one + bb.two;
> +      bb.three = bb.one + bb.two + bb.three;
> +    }
> +  return bb.three;
> +}

The above testcase could be optimized such that it does not need bb
has its address taken.

Thanks,
Andrew Pinski


Re: [PATCH] PR 51469, Make gnu indirect functions always non-local

2011-12-08 Thread Richard Henderson
On 12/08/2011 02:29 PM, Michael Meissner wrote:
> 2011-12-08  Michael Meissner  
> 
>   PR rtl-optimization/51469
>   * varasm.c (default_binds_local_p_1): If the symbol is a gnu
>   indirect function, mark the symbol as non-local.

Ok everywhere.


r~


Go patch committed: Don't check for hidden fields on struct assignment

2011-12-08 Thread Ian Lance Taylor
The Go language has changed to permit structs with hidden fields to be
assigned.  This patch implements that in the gccgo frontend.  Because
the change is somewhat experimental, I did not remove the old code, I
merely stopped executing it.  I will remove it later if the change
sticks.  This change meant that I had to add checks for assignments to
hidden fields in struct composite literals.  Those are still forbidden,
and were previously picked up by the check on assignment.  Bootstrapped
and ran Go testsuite on x86_64-unknown-linux-gnu.  Committed to
mainline.

Ian

Index: gcc/go/gofrontend/types.cc
===
--- gcc/go/gofrontend/types.cc	(revision 181938)
+++ gcc/go/gofrontend/types.cc	(working copy)
@@ -605,7 +605,7 @@ Type::are_assignable_check_hidden(const 
 bool
 Type::are_assignable(const Type* lhs, const Type* rhs, std::string* reason)
 {
-  return Type::are_assignable_check_hidden(lhs, rhs, true, reason);
+  return Type::are_assignable_check_hidden(lhs, rhs, false, reason);
 }
 
 // Like are_assignable but don't check for hidden fields.
Index: gcc/go/gofrontend/expressions.cc
===
--- gcc/go/gofrontend/expressions.cc	(revision 181874)
+++ gcc/go/gofrontend/expressions.cc	(working copy)
@@ -12817,7 +12817,22 @@ Composite_literal_expression::lower_stru
   Location location = this->location();
   Struct_type* st = type->struct_type();
   if (this->vals_ == NULL || !this->has_keys_)
-return new Struct_construction_expression(type, this->vals_, location);
+{
+  if (this->vals_ != NULL && !this->vals_->empty())
+	{
+	  std::string reason;
+	  if (type->has_hidden_fields(NULL, &reason))
+	{
+	  if (reason.empty())
+		error_at(this->location(),
+			 "implicit assignment of hidden field");
+	  else
+		error_at(this->location(), "%s", reason.c_str());
+	}
+	}
+
+  return new Struct_construction_expression(type, this->vals_, location);
+}
 
   size_t field_count = st->field_count();
   std::vector vals(field_count);
@@ -12964,6 +12979,26 @@ Composite_literal_expression::lower_stru
 	  return Expression::make_error(location);
 	}
 
+  if (type->named_type() != NULL
+	  && type->named_type()->named_object()->package() != NULL
+	  && Gogo::is_hidden_name(sf->field_name()))
+	error_at(name_expr->location(),
+		 "assignment of unexported field %qs in %qs literal",
+		 Gogo::message_name(sf->field_name()).c_str(),
+		 type->named_type()->message_name().c_str());
+  else
+	{
+	  std::string reason;
+	  if (sf->type()->has_hidden_fields(NULL, &reason))
+	{
+	  if (reason.empty())
+		error_at(name_expr->location(),
+			 "implicit assignment of hidden field");
+	  else
+		error_at(name_expr->location(), "%s", reason.c_str());
+	}
+	}
+
   vals[index] = val;
 }
 
Index: gcc/testsuite/go.test/test/assign.go
===
--- gcc/testsuite/go.test/test/assign.go	(revision 181963)
+++ gcc/testsuite/go.test/test/assign.go	(working copy)
@@ -16,38 +16,38 @@ type T struct {
 func main() {
 	{
 		var x, y sync.Mutex
-		x = y	// ERROR "assignment.*Mutex"
+		x = y // ok
 		_ = x
 	}
 	{
 		var x, y T
-		x = y	// ERROR "assignment.*Mutex"
+		x = y // ok
 		_ = x
 	}
 	{
 		var x, y [2]sync.Mutex
-		x = y	// ERROR "assignment.*Mutex"
+		x = y // ok
 		_ = x
 	}
 	{
 		var x, y [2]T
-		x = y	// ERROR "assignment.*Mutex"
+		x = y // ok
 		_ = x
 	}
 	{
-		x := sync.Mutex{0, 0}	// ERROR "assignment.*Mutex"
+		x := sync.Mutex{0, 0} // ERROR "assignment.*Mutex"
 		_ = x
 	}
 	{
-		x := sync.Mutex{key: 0}	// ERROR "(unknown|assignment).*Mutex"
+		x := sync.Mutex{key: 0} // ERROR "(unknown|assignment).*Mutex"
 		_ = x
 	}
 	{
-		x := &sync.Mutex{}	// ok
-		var y sync.Mutex	// ok
-		y = *x	// ERROR "assignment.*Mutex"
-		*x = y	// ERROR "assignment.*Mutex"
+		x := &sync.Mutex{} // ok
+		var y sync.Mutex   // ok
+		y = *x // ok
+		*x = y // ok
 		_ = x
 		_ = y
-	}		
+	}
 }
Index: gcc/testsuite/go.test/test/fixedbugs/bug359.go
===
--- gcc/testsuite/go.test/test/fixedbugs/bug359.go	(revision 181963)
+++ gcc/testsuite/go.test/test/fixedbugs/bug359.go	(working copy)
@@ -1,26 +0,0 @@
-// errchk $G $D/$F.go
-
-// Copyright 2011 The Go Authors.  All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-// issue 1910
-// error on wrong line
-
-package main
-
-import "container/list"
-
-type Painting struct {
-	fragments list.List // private
-}
-
-func (p Painting) Foo() {
-	for e := p.fragments; e.Front() != nil; {  // ERROR "unexported field|hidden field"
-	}
-}
-
-// from comment 4 of issue 1910
-type Foo interface {
-	Run(a int) (a int)  // ERROR "a redeclared|redefinition|previous"
-}
Index: gcc/testsuite/go.test/test/fixedbugs/bug310.go

Re: [PATCH] Optimize away unnecessary clobbers (PR tree-optimization/51117)

2011-12-08 Thread Richard Henderson
On 12/08/2011 11:57 AM, Jakub Jelinek wrote:
> +  else if (gimple_code (last) == GIMPLE_RETURN
> +|| (gimple_code (last) == GIMPLE_RESX
> +&& stmt_can_throw_external (last)))
> + optimize_clobbers (bb);

If you need to do this for returns as well as resx, then
this is the wrong place, since we'll only get here if there
are exception regions in the current function.

If you don't need to do this for returns... why do them?


r~


Re: RFA: Fix PR middle-end/40154

2011-12-08 Thread Richard Henderson
On 12/07/2011 06:10 AM, Joern Rennecke wrote:
>   PR middle-end/40154
>   * emit-rtl.c (set_dst_reg_note): New function.
>   * rtl.h (set_dst_reg_note): Declare.
>   * optabs.c (expand_binop, expand_absneg_bit): Use set_dst_reg_note.
>   (emit_libcall_block, expand_fix): Likewise.
>   * function.c (assign_parm_setup_reg, expand_function_start): Likewise.
>   * expmed.c (expand_mult_const, expand_divmod): Likewise.
>   * reload1.c (gen_reload): Likewise.

Ok.



> +  GEN_INT
> +(trunc_int_for_mode

While you're at it, or as a followup, this is combination is gen_int_mode.
I mis-read the patch the first time and thought you'd done this, but it's
a pre-existing condition.


r~


Re: [PATCH] Optimize away unnecessary clobbers (PR tree-optimization/51117)

2011-12-08 Thread Jakub Jelinek
On Thu, Dec 08, 2011 at 03:53:40PM -0800, Richard Henderson wrote:
> On 12/08/2011 11:57 AM, Jakub Jelinek wrote:
> > +  else if (gimple_code (last) == GIMPLE_RETURN
> > +  || (gimple_code (last) == GIMPLE_RESX
> > +  && stmt_can_throw_external (last)))
> > +   optimize_clobbers (bb);
> 
> If you need to do this for returns as well as resx, then
> this is the wrong place, since we'll only get here if there
> are exception regions in the current function.

I don't need to do it for returns, on the other side those clobbers
before return are useless and removing them perhaps might decrease
memory consumptions (after collect).

But if you prefer to keep it just for GIMPLE_RESX, fine with me.

It can be done anywhere else after inlining and before ehcleanup2
too if you have suggestions where to do it instead.

Jakub


Go patch committed: Fix hidden field code

2011-12-08 Thread Ian Lance Taylor
Further testing revealed that I goofed on the hidden field patch I just
committed, and was too aggressive on testing for assignments to hidden
fields in composite literals.  It is OK to assign to a type which itself
contains hidden fields in a composite literal; that is just an example
of assignment, which is now permitted.  This patch fixes that.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

diff -r c5598ae02285 go/expressions.cc
--- a/go/expressions.cc	Thu Dec 08 15:25:25 2011 -0800
+++ b/go/expressions.cc	Thu Dec 08 16:06:29 2011 -0800
@@ -12986,18 +12986,6 @@
 		 "assignment of unexported field %qs in %qs literal",
 		 Gogo::message_name(sf->field_name()).c_str(),
 		 type->named_type()->message_name().c_str());
-  else
-	{
-	  std::string reason;
-	  if (sf->type()->has_hidden_fields(NULL, &reason))
-	{
-	  if (reason.empty())
-		error_at(name_expr->location(),
-			 "implicit assignment of hidden field");
-	  else
-		error_at(name_expr->location(), "%s", reason.c_str());
-	}
-	}
 
   vals[index] = val;
 }


Re: [PATCH] Optimize away unnecessary clobbers (PR tree-optimization/51117)

2011-12-08 Thread Richard Henderson
On 12/08/2011 04:00 PM, Jakub Jelinek wrote:
> On Thu, Dec 08, 2011 at 03:53:40PM -0800, Richard Henderson wrote:
>> On 12/08/2011 11:57 AM, Jakub Jelinek wrote:
>>> +  else if (gimple_code (last) == GIMPLE_RETURN
>>> +  || (gimple_code (last) == GIMPLE_RESX
>>> +  && stmt_can_throw_external (last)))
>>> +   optimize_clobbers (bb);
>>
>> If you need to do this for returns as well as resx, then
>> this is the wrong place, since we'll only get here if there
>> are exception regions in the current function.
> 
> I don't need to do it for returns, on the other side those clobbers
> before return are useless and removing them perhaps might decrease
> memory consumptions (after collect).
> 
> But if you prefer to keep it just for GIMPLE_RESX, fine with me.
> 
> It can be done anywhere else after inlining and before ehcleanup2
> too if you have suggestions where to do it instead.

*shrug* Maybe just a new pass immediately before ehcleanup2?
It's just a quick pass over the basic blocks...


r~


Re: [PATCH] Make #pragma GCC target properly change macros and fix recip-5 failures

2011-12-08 Thread David Edelsohn
On Thu, Dec 8, 2011 at 4:26 PM, Michael Meissner
 wrote:
> These patches add support for #pragma GCC target("...") on the powerpc to
> change the default macros defined like tha x86 does (and the powerpc did for
> the target attribute).  When adding support for changing macros on the target
> attribute, I forgot to enable the code for #pragma as well.
>
> Also, the recip-5.c test has been failing on systems that don't support VSX,
> such as Darwin.  The test itself should not have been run on those system, as 
> I
> forgot to add the standard lines for VSX patches to the test.  In addition,
> when reporting the bug, the compiler segfaulted.  This was due to the expand
> builtin function returning NULL or const0_rtx (depending on the error), and 
> the
> higher level code was not expecting NULL.  For this case, I did a normal
> expand_call operation.
>
> I did make boostrap and there were no regressions.  Is it ok to install these
> patches?
>
> [gcc]
> 2011-12-08  Michael Meissner  
>
>        * config/rs6000/rs6000.c (altivec_expand_builtin): Call
>        expand_call to return a valid funciton instead of return
>        cosnt0_rtx/NULL_RTX if there was an error with the builtin.
>        (altivec_expand_ld_builtin): Ditto.
>        (rs6000_inner_target_options): If VSX is selected as a target
>        attribute or pragma, enable ALTIVEC also.
>        (rs6000_pragma_target_parse): Call rs6000_option_override_internal
>        to do all of the standard processing when switching options,
>        including redefining appropriate macros.
>
> [gcc/testsuite]
> 2011-12-08  Michael Meissner  
>
>        * gcc.target/powerpc/recip-5.c: Disable running on any system that
>        does not support VSX.

Okay.

Thanks, David


Re: [4.7][google] Adding a new option -fstack-protector-strong. (issue5461043)

2011-12-08 Thread 沈涵
Hi, Jakub, thanks! Fixed!

Hi, Andrew, it's good suggestion. Done. Also modified foo10.

A small c++ test case was added also.

Patches (also on http://codereview.appspot.com/5461043)

diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c
index 8684721..0a7a9f7 100644
--- a/gcc/cfgexpand.c
+++ b/gcc/cfgexpand.c
@@ -1507,15 +1507,38 @@ estimated_stack_frame_size (struct cgraph_node *node)
   return size;
 }

+/* Helper routine to check if a record or union contains an array field. */
+
+static int
+record_or_union_type_has_array (const_tree tree_type)
+{
+  tree fields = TYPE_FIELDS (tree_type);
+  tree f;
+  for (f = fields; f; f = DECL_CHAIN (f))
+{
+  if (TREE_CODE (f) == FIELD_DECL)
+   {
+ tree field_type = TREE_TYPE (f);
+ if (RECORD_OR_UNION_TYPE_P (field_type))
+   return record_or_union_type_has_array (field_type);
+ if (TREE_CODE (field_type) == ARRAY_TYPE)
+   return 1;
+   }
+}
+  return 0;
+}
+
 /* Expand all variables used in the function.  */

 static void
 expand_used_vars (void)
 {
   tree var, outer_block = DECL_INITIAL (current_function_decl);
+  referenced_var_iterator rvi;
   VEC(tree,heap) *maybe_local_decls = NULL;
   unsigned i;
   unsigned len;
+  int gen_stack_protect_signal = 0;

   /* Compute the phase of the stack frame for this function.  */
   {
@@ -1548,6 +1571,28 @@ expand_used_vars (void)
}
 }

+  FOR_EACH_REFERENCED_VAR (cfun, var, rvi)
+if (!is_global_var (var))
+  {
+   tree var_type = TREE_TYPE (var);
+   /* Examine local variables that have been address taken. */
+   if (TREE_ADDRESSABLE (var))
+ {
+   ++gen_stack_protect_signal;
+   break;
+ }
+   /* Examine local referenced variables that contain an array or are
+  arrays. */
+   if (TREE_CODE (var) == VAR_DECL
+   && (TREE_CODE (var_type) == ARRAY_TYPE
+   || (RECORD_OR_UNION_TYPE_P (var_type)
+   && record_or_union_type_has_array (var_type
+ {
+   ++gen_stack_protect_signal;
+   break;
+ }
+  }
+
   /* At this point all variables on the local_decls with TREE_USED
  set are not associated with any block scope.  Lay them out.  */

@@ -1638,12 +1683,17 @@ expand_used_vars (void)
dump_stack_var_partition ();
 }

-  /* There are several conditions under which we should create a
- stack guard: protect-all, alloca used, protected decls present.  */
+  /* There are several conditions under which we should create a stack guard:
+ protect-all, alloca used, protected decls present or a positive
+ gen_stack_protect_signal. */
   if (flag_stack_protect == 2
-  || (flag_stack_protect
+  || (flag_stack_protect == 1
  && (cfun->calls_alloca || has_protected_decls)))
 create_stack_guard ();
+  else if (flag_stack_protect == 3
+  && (gen_stack_protect_signal
+  || cfun->calls_alloca || has_protected_decls))
+create_stack_guard ();

   /* Assign rtl to each variable based on these partitions.  */
   if (stack_vars_num > 0)
diff --git a/gcc/common.opt b/gcc/common.opt
index 55d3f2d..1ad9717 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1848,6 +1848,10 @@ fstack-protector-all
 Common Report RejectNegative Var(flag_stack_protect, 2)
 Use a stack protection method for every function

+fstack-protector-strong
+Common Report RejectNegative Var(flag_stack_protect, 3)
+Use a smart stack protection method for certain functions
+
 fstack-usage
 Common RejectNegative Var(flag_stack_usage)
 Output stack usage information on a per-function basis
diff --git a/gcc/testsuite/g++.dg/fstack-protector-strong.C
b/gcc/testsuite/g++.dg/fstack-protector-strong.C
new file mode 100644
index 000..a4f0f81
--- /dev/null
+++ b/gcc/testsuite/g++.dg/fstack-protector-strong.C
@@ -0,0 +1,35 @@
+/* Test that stack protection is done on chosen functions. */
+
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O2 -fstack-protector-strong" } */
+
+class A
+{
+public:
+  A() {}
+  ~A() {}
+  void method();
+  int state;
+};
+
+/* Frame address exposed to A::method via "this". */
+int
+foo1 ()
+{
+  A a;
+  a.method ();
+  return a.state;
+}
+
+/* Possible destroying foo2's stack via &a. */
+int
+global_func (A& a);
+
+/* Frame address exposed to global_func. */
+int foo2 ()
+{
+  A a;
+  return global_func (a);
+}
+
+/* { dg-final { scan-assembler-times "stack_chk_fail" 2 } } */
diff --git a/gcc/testsuite/gcc.dg/fstack-protector-strong.c
b/gcc/testsuite/gcc.dg/fstack-protector-strong.c
new file mode 100644
index 000..5a5cf98
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fstack-protector-strong.c
@@ -0,0 +1,135 @@
+/* Test that stack protection is done on chosen functions. */
+
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-options "-O2 -fstack-protector-strong" } */
+
+#include
+#include
+
+extern int

Re: PR libgomp/51376 fix

2011-12-08 Thread Alan Modra
On Fri, Dec 02, 2011 at 08:10:11PM +1030, Alan Modra wrote:
>   PR libgomp/51376
>   * task.c (GOMP_taskwait): Don't access task->children outside of
>   task_lock mutex region.
>   (GOMP_task): Likewise.

Committed revision 182151 on rth's irc OK.

-- 
Alan Modra
Australia Development Lab, IBM


Re: [PATCH] [MIPS] Add -march=octeon+ support for GCC

2011-12-08 Thread Andrew Pinski
On Thu, Dec 8, 2011 at 12:43 PM, Richard Sandiford
 wrote:
> Andrew Pinski  writes:
>>> gcc/ChangeLog:
>>> * mips/mips-cpus.def (octeon+): New CPU.
>
> config/mips/mips-cpus.def
>
>>> testsuite/ChangeLog:
>>> * gcc.target/mips/mult-1.c: Forbit all Octeon processors.
>
> Forbid.
>
>> @@ -1,6 +1,6 @@
>>  /* For SI->DI widening multiplication we should use DINS to combine the two
>>     halves.  For Octeon use DMUL with explicit widening.  */
>> -/* { dg-options "-O -mgp64 isa_rev>=2 forbid_cpu=octeon" } */
>> +/* { dg-options "-O -mgp64 isa_rev>=2 forbid_cpu=octeon\[\+0-9\]*" } */
>>  /* { dg-final { scan-assembler "\tdins\t" } } */
>>  /* { dg-final { scan-assembler-not "\tdsll\t" } } */
>>  /* { dg-final { scan-assembler-not "\tdsrl\t" } } */
>
> Here I'd either prefer "forbid_cpu=octeon.*" (a bold statement that
> no Octeon processor will ever be interested in these tests) or
> "forbid_cpu=octeon(|+|2)" (a much more focused statement).
> Just matching + and numbers is a bit in the middle: past experience
> suggests that marketing departments don't always follow such logic.
>
> If you don't have a strong preference, let's go for (|+|2).
> If you do, go with what you think's best.
>
> OK for 4.7 with those changes, thanks.

I went with octeon.* because newer Octeon processor will never remove
bbit or dmul instructions.

Thanks,
Andrew Pinski


Re: [patch] ARM: Fix miscompilation in arm.md:*minmax_arithsi. (PR target/51408)

2011-12-08 Thread Kazu Hirata

Hi Richard,


BTW, I would expect this to also exist in all the release branches.  Could you 
back-port it where
needed please.


I just backported to 4.4, 4.5, and 4.6 branches.

Kazu Hirata


Go patch committed: Another hidden fields correction

2011-12-08 Thread Ian Lance Taylor
This is another correction to the recent Go frontend patch for hidden
fields.  This treats both the case of a composite literal with field
names and one without the same way.  Bootstrapped and ran Go testsuite
on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

diff -r 2567b69456fe go/expressions.cc
--- a/go/expressions.cc	Thu Dec 08 16:14:53 2011 -0800
+++ b/go/expressions.cc	Thu Dec 08 21:02:14 2011 -0800
@@ -12818,16 +12818,20 @@
   Struct_type* st = type->struct_type();
   if (this->vals_ == NULL || !this->has_keys_)
 {
-  if (this->vals_ != NULL && !this->vals_->empty())
-	{
-	  std::string reason;
-	  if (type->has_hidden_fields(NULL, &reason))
+  if (this->vals_ != NULL
+	  && !this->vals_->empty()
+	  && type->named_type() != NULL
+	  && type->named_type()->named_object()->package() != NULL)
+	{
+	  for (Struct_field_list::const_iterator pf = st->fields()->begin();
+	   pf != st->fields()->end();
+	   ++pf)
 	{
-	  if (reason.empty())
+	  if (Gogo::is_hidden_name(pf->field_name()))
 		error_at(this->location(),
-			 "implicit assignment of hidden field");
-	  else
-		error_at(this->location(), "%s", reason.c_str());
+			 "assignment of unexported field %qs in %qs literal",
+			 Gogo::message_name(pf->field_name()).c_str(),
+			 type->named_type()->message_name().c_str());
 	}
 	}
 


Re: [PATCH 5/6] mips: Implement vec_perm_const.

2011-12-08 Thread Hans-Peter Nilsson
On Thu, 8 Dec 2011, Richard Henderson wrote:
> diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
> index d3fd709..f1c3665 100644
> --- a/gcc/config/mips/mips.c
> +++ b/gcc/config/mips/mips.c

> @@ -13021,8 +13015,8 @@ static const struct mips_builtin_description 
> mips_builtins[] = {
>LOONGSON_BUILTIN (pasubub, MIPS_UV8QI_FTYPE_UV8QI_UV8QI),
>LOONGSON_BUILTIN (biadd, MIPS_UV4HI_FTYPE_UV8QI),
>LOONGSON_BUILTIN (psadbh, MIPS_UV4HI_FTYPE_UV8QI_UV8QI),
> -  LOONGSON_BUILTIN_SUFFIX (pshufh, u, MIPS_UV4HI_FTYPE_UV4HI_UV4HI_UQI),
> -  LOONGSON_BUILTIN_SUFFIX (pshufh, s, MIPS_V4HI_FTYPE_V4HI_V4HI_UQI),
> +  LOONGSON_BUILTIN_SUFFIX (pshufh, u, MIPS_UV4HI_FTYPE_UV4HI_UQI),
> +  LOONGSON_BUILTIN_SUFFIX (pshufh, s, MIPS_V4HI_FTYPE_V4HI_UQI),
>LOONGSON_BUILTIN_SUFFIX (psllh, u, MIPS_UV4HI_FTYPE_UV4HI_UQI),

Looks like a brute-force (ignoring backward compatibility) fix
for PR48068 item 2.  If going that route, I'd suggest at least
increment the __mips_loongson_vector_rev.  Also, loongson.h
needs the corresponding adjustment.

(No specific interest in Loongson, FWIW.)

brgds, H-P


Re: [Path,AVR]: Implement __muldi3 in asm

2011-12-08 Thread Denis Chertykov
2011/12/8 Georg-Johann Lay :
> This are assembler implementations for Dimode multiplication.
>
> Tested without regressions, the only change in the test suite I get is for
>
> gcc.c-torture/execute/arith-rand-ll.c execution,  -O0
>
> UNTESTED -> PASS
>
> because the former vanilla C implementation ran into timeout.
>
> Ok for trunk?
>
> Johann
>
>        * config/avr/t-avr (LIB1ASMFUNCS): Add _muldi3.
>        * config/avr/lib1funcs.S (__muldi3): New function.
>

Approved.

Denis.


Re: [Patch,AVR]: Fix PR51425

2011-12-08 Thread Denis Chertykov
2011/12/8 Georg-Johann Lay :
> This is obvious patch for PR51425: SBIC/SBRC instructions are generated by 
> insn
> combine, but insn combine tries zero_extract:QI not zero_extract:HI as  in 
> good
> old times.
>
> Thus, use QIHI iterator.
>
> Besides fixing this optimization flaw, it enables other developers to 
> reproduce
> PR51374:  If the pattern is question don't match, PR51374 won't show up in 
> 4.7.
>
> Ok for trunk?
>
> Johann
>
>        PR target/51425
>        * config/avr/avr.md (config/avr/avr.md, *sbix_branch_tmp): Use
>        zero_extract:QIHI instead of zero_extract:HI.

Approved.

Denis.


Re: RFA: Avoid unnecessary clearing in union initialisers

2011-12-08 Thread Carrot Wei
Since it also affects 4.6 branch, can this and r176270 also be ported to gcc4.6?

thanks
Carrot

On Wed, Jul 13, 2011 at 12:34 AM, Richard Sandiford
 wrote:
> PR 48183 is caused by the fact that we don't really support integers
> (or least integer constants) wider than 2*HOST_BITS_PER_WIDE_INT:
>
>   http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01220.html
>
> However, such constants shouldn't be needed in normal use.
> They came from an unnecessary zero-initialisation of a union such as:
>
>   union { a f1; b f2; } u = { init_f1 };
>
> where f1 and f2 are the full width of the union.  The zero-initialisation
> gets optimised away for "real" insns, but persists in debug insns:
>
>   http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01585.html
>
> This patch takes up Richard's idea here:
>
>   http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01987.html
>
> categorize_ctor_elements currently tries to work out how many scalars a
> constructor initialises (IE) and how many of those scalars are zero (ZE).
> Callers can then call count_type_elements to find out how many scalars (TE)
> ought to be initialised if the constructor is "complete" (i.e. if it
> explicitly initialises every meaningful byte, rather than relying on
> default zero-initialisation).  The constructor is complete if TE == ZE,
> except as noted in [A] below.
>
> However, count_type_elements can't return the required TE for unions,
> because it would need to know which of the union's fields was initialised
> by the constructor (if any).  This choice of field is reflected in IE and
> ZE, so would need to be reflected in TE as well.
>
> count_type_elements therefore punts on unions.  However, the caller
> can't easily tell whether it punts because of that, because of overflow,
> of because of variable-sized types.
>
> [A] One particular case of interest is when a union constructor initialises
> a field that is shorter than the union.  In this case, the rest of the
> union must be zeroed in order to ensure that the other fields have
> predictable values.  categorize_ctor_elements has a special out-parameter
> to reccord this situation.
>
> This leads to quite a complicated interface.  The patch tries to
> simplify it by making categorize_ctor_elements keep track of whether
> a constructor is complete.  This also has the minor advantage of
> avoiding double recursion: first through the constructor,
> then through its type tree.
>
> After this change, ZE and IE are only needed when deciding how best to
> implement "complete" initialisers (such as whether to do a bulk zero
> initialisation anyway, and just write the nonzero elements individually).
> For cases where a "leaf" constructor element is itself an aggregate with
> a union, we can therefore estimate the number of scalars in the union,
> and hopefully make the heuristic a bit more accurate than the current 1:
>
>            HOST_WIDE_INT tc = count_type_elements (TREE_TYPE (value), true);
>            if (tc < 1)
>              tc = 1;
>
> cp/typeck2.c also wants to check whether the variable parts of a
> constructor are complete.  The patch uses the approach to completeness
> there.  This should make it a bit more general than the current code,
> which only deals with non-nested constructors.
>
> Tested on x86_64-linux-gnu (all languages, including Ada), and on
> arm-linux-gnueabi.  OK to install?
>
> Richard
>
>
> gcc/
>        * tree.h (categorize_ctor_elements): Remove comment.  Fix long line.
>        (count_type_elements): Delete.
>        (complete_ctor_at_level_p): Declare.
>        * expr.c (flexible_array_member_p): New function, split out from...
>        (count_type_elements): ...here.  Make static.  Replace allow_flexarr
>        parameter with for_ctor_p.  When for_ctor_p is true, return the
>        number of elements that should appear in the top-level constructor,
>        otherwise return an estimate of the number of scalars.
>        (categorize_ctor_elements): Replace p_must_clear with p_complete.
>        (categorize_ctor_elements_1): Likewise.  Use complete_ctor_at_level_p.
>        (complete_ctor_at_level_p): New function, borrowing union logic
>        from old categorize_ctor_elements_1.
>        (mostly_zeros_p): Return true if the constructor is not complete.
>        (all_zeros_p): Update call to categorize_ctor_elements.
>        * gimplify.c (gimplify_init_constructor): Update call to
>        categorize_ctor_elements.  Don't call count_type_elements.
>        Unconditionally prevent clearing for variable-sized types,
>        otherwise rely on categorize_ctor_elements to detect
>        incomplete initializers.
>
> gcc/cp/
>        * typeck2.c (split_nonconstant_init_1): Pass the initializer directly,
>        rather than a pointer to it.  Return true if the whole of the value
>        was initialized by the generated statements.  Use
>        complete_ctor_at_level_p instead of count_type_elements.
>
> gcc/testsuite/
> 2011-07-12  Chung-Lin Tang  
>
>        * gcc.target/a

PATCH: PR bootstrap/51479: Missing dependency on errors.o causes bootstrap failure

2011-12-08 Thread H.J. Lu
gcc/Makefile.in has

gengtype$(exeext) : gengtype.o gengtype-lex.o gengtype-parse.o \
  gengtype-state.o version.o errors.o $(LIBDEPS)
+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \
$(filter-out ($LIBDEPS), $^) $(LIBS)

However, there is no errors.o dependency, which leads to random
parallel build failures.  This patch adds errors.o dependency.  OK
for trunk and release branches?

Thanks.

H.J.
---
2011-12-08  H.J. Lu  

PR bootstrap/51479
* Makefile.in (errors.o): New.

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index ae4f4da..83f70fa 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -3947,6 +3947,8 @@ build/genautomata$(build_exeext) : BUILD_LIBS += -lm
 build/gengtype$(build_exeext) : build/gengtype-lex.o build/gengtype-parse.o \
   build/gengtype-state.o build/version.o build/errors.o
 
+errors.o : errors.c $(CONFIG_H) $(SYSTEM_H) errors.h
+
 gengtype$(exeext) : gengtype.o gengtype-lex.o gengtype-parse.o \
   gengtype-state.o version.o errors.o $(LIBDEPS)
+$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS) -o $@ \