[v3] Fix libstdc++/56282

2013-02-11 Thread Paolo Carlini

Hi,

no real reason to add this tiny bit of C++11, and the related export 
ungliness, at this late stage in the 4.8 release process. I would say, 
let's just do it in the next ABI.


Committed.

Thanks,
Paolo.

/
2013-02-11  Paolo Carlini  paolo.carl...@oracle.com

PR libstdc++/56282
Revert:
2013-02-06  Edward Smith-Rowland  3dw...@verizon.net

PR libstdc++/56193
* include/bits/basic_ios.h: Replace operator void*() const
with explicit operator bool() const in C++11 and greater.
* testsuite/27_io/basic_ios/pr56193.cc: New file.
Index: include/bits/basic_ios.h
===
--- include/bits/basic_ios.h(revision 195938)
+++ include/bits/basic_ios.h(working copy)
@@ -112,13 +112,8 @@
*  This allows you to write constructs such as
*  codeif (!a_stream) .../code and codewhile (a_stream) .../code
   */
-#if __cplusplus = 201103L
-  explicit operator bool() const
-  { return !this-fail(); }
-#else
   operator void*() const
   { return this-fail() ? 0 : const_castbasic_ios*(this); }
-#endif
 
   bool
   operator!() const
Index: testsuite/27_io/basic_ios/pr56193.cc
===
--- testsuite/27_io/basic_ios/pr56193.cc(revision 195938)
+++ testsuite/27_io/basic_ios/pr56193.cc(working copy)
@@ -1,31 +0,0 @@
-// { dg-do compile }
-// { dg-options -std=gnu++11 }
-
-// 2013-02-06  Edward Smith-Rowland 3dw...@verizon.net
-//
-// Copyright (C) 2013 Free Software Foundation, Inc.
-//
-// This file is part of the GNU ISO C++ Library.  This library is free
-// software; you can redistribute it and/or modify it under the
-// terms of the GNU General Public License as published by the
-// Free Software Foundation; either version 3, or (at your option)
-// any later version.
-//
-// This library is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this library; see the file COPYING3.  If not see
-// http://www.gnu.org/licenses/.
-
-#include iostream
-
-// PR libstdc++/56193
-void
-test01()
-{
-  std::cout  std::cout; // { dg-error cannot bind }
-}
-// { dg-error initializing argument  { target *-*-* } 602 }


Re: [PATCH][ARM] Implement vectorizer cost hooks

2013-02-11 Thread Richard Earnshaw

On 05/02/13 18:18, Christophe Lyon wrote:

Hi,

Following the discussion about disable peeling [1] a few weeks ago,
it turned out that the vectorizer cost model needed some
implementation for ARM.

The attached patch implements arm_builtin_vectorization_cost and
arm_add_stmt_cost, providing default costs when aligned and unaligned
loads/stores have the same cost (=1). init_cost and finish_cost still
use the default implementation (I noticed that x86 has chosen to
duplicate the default implementation without changing it, why?)

Benchmarking shows very little variation, expect a noticeable +1.6% on coremark.

If this is OK, we can then discuss how to disable peeling completely
when aligned and unaligned accesses have the same cost (and thus where
peeling is a loss of performance). I think adding a new hook is
necessary, since target descriptions may use different models for
these costs (eg x86 makes no difference between unaligned loads and
unaligned stores).

Thanks,

Christophe.

[1] http://gcc.gnu.org/ml/gcc/2012-12/msg00036.html

2013-02-05  Christophe Lyon christophe.l...@linaro.org

 * config/arm/arm.c (arm_builtin_vectorization_cost)
 (arm_add_stmt_cost): New functions.
 (TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST)
 (TARGET_VECTORIZE_ADD_STMT_COST): Define.
 (struct processor_costs): New struct type.
 (default_arm_cost): New struct of type processor_costs.=



Christophe,

Thanks for the patch.  This is mostly OK, but please can you make the 
following changes.


+struct processor_costs {

Please name this something like cpu_vec_costs.  It's not the only cost 
table in the back-end.


+struct processor_costs default_arm_cost = {/* arm generic costs.  */

Similarly, use something like default_arm_vec_cost.

+const struct processor_costs *arm_cost = default_arm_cost;

And here.  But better still, link this through the current_tune table 
rather than introducing a new global.


Finally,

@@ -27256,4 +27272,130 @@ arm_validize_comparison (rtx *comparison, rtx 
* op1, rtx * op2)


 }

+/* Vectorizer cost model implementation.  */


Please put the patch in a more suitable location rather than just 
dumping it at the end of the file.  There are already numerous functions 
related to costs that are mostly grouped together.  I suggest this goes 
near the rtx_costs code.


R.




Re: libsanitizer merge from upstream r173241

2013-02-11 Thread Jakub Jelinek
On Wed, Jan 23, 2013 at 04:24:01PM +0400, Evgeniy Stepanov wrote:
   What if glibc adds a scanf hook (like it has already printf hooks), apps
   could then register their own stuff and the above would then break.  It
   really should be very conservative, and should be checked e.g. with all
   glibc's *scanf tests (e.g. stdio-common/scanf[0-9]*.c,
   stdio-common/tst-sscanf.c).
 
 I'll add support for the missing %specs. About the testing, these
 files seem like GPL, so I'd prefer not to look at them at all. We've
 got a smallish test for the scanf implementation in sanitizer_common,
 but it would be really great to run it on full glibc scanf tests.
 Would you be willing to setup such testing gnu-side?

Seems the code in llvm repo looks much better now to me than it used to,
still it breaks on:

#define _GNU_SOURCE 1
#include stdio.h
#include string.h

int
main ()
{
  char *p;
  long double q;
  if (sscanf (abcdefghijklmno 1.0, %ms %Lf, p, q) != 2
  || strcmp (p, abcdefghijklmno) != 0
  || q != 1.0L)
return 1;
  return 0;
}

because it mishandles %ms.

Attached patch fixes that and also handles %a when possible.
There are cases where it is unambiguous, e.g.
s%Las is s %La s, reading long double, or %ar is %a r, reading
float, other cases where we can check at least something and keep checking
the rest of the format string, e.g. for:
%as
we know it will either store float, or char * pointer, so just assume
conservatively the smaller size, and other cases where we have to punt,
%a[a%d]
(where % appears in the [...] list).

I've tested various glibc *scanf testcases with the GCC libsanitizer
+ enabling of # define SANITIZER_INTERCEPT_SCANF SI_NOT_WINDOWS
+ llvm svn diff between last merge point to GCC and current llvm trunk
+ this patch, and it looked good.

There is one further issue, I'd say you need to pass down to scanf_common
the result from the intercepted call, and use it to see if it is valid
to call strlen on the ptr, or if just 1 should be assumed for SSS_STRLEN.
Note 'n' doesn't count towards that.  Because, it is unsafe to call strlen
on arguments that haven't been assigned yet.  Testcase that still fails:

#define _GNU_SOURCE 1
#include stdio.h
#include string.h

int
main ()
{
  int a, b, c, d;
  char e[3], f[10];
  memset (e, ' ', sizeof e);
  memset (f, ' ', sizeof f);
  if (sscanf (1 2 a, %d%n%n%d %s %s, a, b, c, d, e, f) != 3
  || a != 1
  || b != 1
  || c != 1
  || d != 2
  || strcmp (e, a) != 0)
return 1;
  return 0;
}

Oh, one more thing, on Linux for recent enough glibc's it would be
desirable to also intercept:
__isoc99_sscanf, __isoc99_scanf, __isoc99_vsscanf, __isoc99_fscanf,
__isoc99_vfscanf, __isoc99_vscanf
functions (guard the interception with
#if defined __GLIBC_PREREQ  __GLIBC_PREREQ (2, 7)
).  All these work exactly like the corresponding non-__isoc99_
functions, just %a followed by s, S or [ always writes float, thus
there is no ambiguity.

Jakub
--- sanitizer_common_interceptors_scanf.inc.jj  2013-02-08 13:21:51.0 
+0100
+++ sanitizer_common_interceptors_scanf.inc 2013-02-11 12:15:27.575871424 
+0100
@@ -18,11 +18,12 @@
 
 struct ScanfDirective {
   int argIdx;  // argument index, or -1 of not specified (%n$)
-  bool suppressed; // suppress assignment (*)
   int fieldWidth;
+  bool suppressed; // suppress assignment (*)
   bool allocate; // allocate space (m)
   char lengthModifier[2];
   char convSpecifier;
+  bool maybeGnuMalloc;
 };
 
 static const char *parse_number(const char *p, int *out) {
@@ -119,6 +120,31 @@ static const char *scanf_parse_next(cons
   // Consume the closing ']'.
   ++p;
 }
+// This is unfortunately ambiguous between old GNU extension
+// of %as, %aS and %a[...] and newer POSIX %a followed by
+// letters s, S or [.
+if (dir-convSpecifier == 'a'  !dir-lengthModifier[0]) {
+  if (*p == 's' || *p == 'S') {
+   dir-maybeGnuMalloc = true;
+   ++p;
+  } else if (*p == '[') {
+   // Watch for %a[h-j%d], if % appears in the
+   // [...] range, then we need to give up, we don't know
+   // if scanf will parse it as POSIX %a [h-j %d ] or
+   // GNU allocation of string with range dh-j plus %.
+   const char *q = p + 1;
+   if (*q == '^')
+ ++q;
+   if (*q == ']')
+ ++q;
+   while (*q  *q != ']'  *q != '%')
+ ++q;
+   if (*q == 0 || *q == '%')
+ return 0;
+   p = q + 1; // Consume the closing ']'.
+   dir-maybeGnuMalloc = true;
+  }
+}
 break;
   }
   return p;
@@ -131,9 +157,7 @@ static bool scanf_is_integer_conv(char c
 
 // Returns true if the character is an floating point conversion specifier.
 static bool scanf_is_float_conv(char c) {
-  return char_is_one_of(c, AeEfFgG);
-  // NOTE: c == 'a' is ambiguous between POSIX and GNU and, therefore,
-  // unsupported.
+  return char_is_one_of(c, aAeEfFgG);
 }
 
 // Returns string output character size for 

Re: libsanitizer merge from upstream r173241

2013-02-11 Thread Evgeniy Stepanov
On Mon, Feb 11, 2013 at 3:38 PM, Jakub Jelinek ja...@redhat.com wrote:
 On Wed, Jan 23, 2013 at 04:24:01PM +0400, Evgeniy Stepanov wrote:
   What if glibc adds a scanf hook (like it has already printf hooks), apps
   could then register their own stuff and the above would then break.  It
   really should be very conservative, and should be checked e.g. with all
   glibc's *scanf tests (e.g. stdio-common/scanf[0-9]*.c,
   stdio-common/tst-sscanf.c).

 I'll add support for the missing %specs. About the testing, these
 files seem like GPL, so I'd prefer not to look at them at all. We've
 got a smallish test for the scanf implementation in sanitizer_common,
 but it would be really great to run it on full glibc scanf tests.
 Would you be willing to setup such testing gnu-side?

 Seems the code in llvm repo looks much better now to me than it used to,
 still it breaks on:

 #define _GNU_SOURCE 1
 #include stdio.h
 #include string.h

 int
 main ()
 {
   char *p;
   long double q;
   if (sscanf (abcdefghijklmno 1.0, %ms %Lf, p, q) != 2
   || strcmp (p, abcdefghijklmno) != 0
   || q != 1.0L)
 return 1;
   return 0;
 }

 because it mishandles %ms.

 Attached patch fixes that and also handles %a when possible.
 There are cases where it is unambiguous, e.g.
 s%Las is s %La s, reading long double, or %ar is %a r, reading
 float, other cases where we can check at least something and keep checking
 the rest of the format string, e.g. for:
 %as
 we know it will either store float, or char * pointer, so just assume
 conservatively the smaller size, and other cases where we have to punt,
 %a[a%d]
 (where % appears in the [...] list).

 I've tested various glibc *scanf testcases with the GCC libsanitizer
 + enabling of # define SANITIZER_INTERCEPT_SCANF SI_NOT_WINDOWS
 + llvm svn diff between last merge point to GCC and current llvm trunk
 + this patch, and it looked good.

Sounds great. I'll commit the patch to compiler-rt if you are ok with that.

 There is one further issue, I'd say you need to pass down to scanf_common
 the result from the intercepted call, and use it to see if it is valid
 to call strlen on the ptr, or if just 1 should be assumed for SSS_STRLEN.
 Note 'n' doesn't count towards that.  Because, it is unsafe to call strlen
 on arguments that haven't been assigned yet.  Testcase that still fails:

Definitely. Also, I'm undecided on this, but we probably don't want to
report access ranges for the arguments that were not written to. On
the other hand, those are potential writes that did not happen due to,
in most cases, user input - we might want to report them anyway.


 #define _GNU_SOURCE 1
 #include stdio.h
 #include string.h

 int
 main ()
 {
   int a, b, c, d;
   char e[3], f[10];
   memset (e, ' ', sizeof e);
   memset (f, ' ', sizeof f);
   if (sscanf (1 2 a, %d%n%n%d %s %s, a, b, c, d, e, f) != 3
   || a != 1
   || b != 1
   || c != 1
   || d != 2
   || strcmp (e, a) != 0)
 return 1;
   return 0;
 }

 Oh, one more thing, on Linux for recent enough glibc's it would be
 desirable to also intercept:
 __isoc99_sscanf, __isoc99_scanf, __isoc99_vsscanf, __isoc99_fscanf,
 __isoc99_vfscanf, __isoc99_vscanf
 functions (guard the interception with
 #if defined __GLIBC_PREREQ  __GLIBC_PREREQ (2, 7)
 ).  All these work exactly like the corresponding non-__isoc99_
 functions, just %a followed by s, S or [ always writes float, thus
 there is no ambiguity.

 Jakub


[PATCH] Fix PR56273

2013-02-11 Thread Richard Biener

This is another -Warray-bounds false-positive triggered by more
aggressive loop unrolling.  Fortunately VRP has everything available
to compute correct bounds - if it were not for VRP itself pessimizing
itself (it runs twice after all) by folding predicates from
a  C to a != C (and similar transforms).  While the folded variant
is better for code-gen it's worse for analysis.  Thus the following
patch defers that to the 2nd run of VRP.

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

Richard.

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

PR tree-optimization/56273
* tree-vrp.c (simplify_cond_using_ranges): Disable for the
first VRP run.
(check_array_ref): Fix missing newline in dumps.
(search_for_addr_array): Likewise.

* g++.dg/warn/Warray-bounds-6.C: New testcase.
* gcc.dg/tree-ssa/pr21559.c: Adjust.
* gcc.dg/tree-ssa/vrp17.c: Likewise.
* gcc.dg/tree-ssa/vrp18.c: Likewise.
* gcc.dg/tree-ssa/vrp23.c: Likewise.
* gcc.dg/tree-ssa/vrp24.c: Likewise.

Index: gcc/tree-vrp.c
===
*** gcc/tree-vrp.c  (revision 195938)
--- gcc/tree-vrp.c  (working copy)
*** check_array_ref (location_t location, tr
*** 6027,6032 
--- 6022,6028 
{
  fprintf (dump_file, Array bound warning for );
  dump_generic_expr (MSG_NOTE, TDF_SLIM, ref);
+ fprintf (dump_file, \n);
}
warning_at (location, OPT_Warray_bounds,
  array subscript is above array bounds);
*** check_array_ref (location_t location, tr
*** 6039,6044 
--- 6035,6041 
{
  fprintf (dump_file, Array bound warning for );
  dump_generic_expr (MSG_NOTE, TDF_SLIM, ref);
+ fprintf (dump_file, \n);
}
warning_at (location, OPT_Warray_bounds,
  array subscript is below array bounds);
*** search_for_addr_array (tree t, location_
*** 6112,6117 
--- 6109,6115 
{
  fprintf (dump_file, Array bound warning for );
  dump_generic_expr (MSG_NOTE, TDF_SLIM, t);
+ fprintf (dump_file, \n);
}
  warning_at (location, OPT_Warray_bounds,
  array subscript is below array bounds);
*** search_for_addr_array (tree t, location_
*** 6125,6130 
--- 6123,6129 
{
  fprintf (dump_file, Array bound warning for );
  dump_generic_expr (MSG_NOTE, TDF_SLIM, t);
+ fprintf (dump_file, \n);
}
  warning_at (location, OPT_Warray_bounds,
  array subscript is above array bounds);
*** test_for_singularity (enum tree_code con
*** 8499,8507 
return NULL;
  }
  
! /* Simplify a conditional using a relational operator to an equality
!test if the range information indicates only one value can satisfy
!the original conditional.  */
  
  static bool
  simplify_cond_using_ranges (gimple stmt)
--- 8498,8505 
return NULL;
  }
  
! /* Simplify the conditional stmt STMT using final range information.
!Return true if we simplified the statement.  */
  
  static bool
  simplify_cond_using_ranges (gimple stmt)
*** simplify_cond_using_ranges (gimple stmt)
*** 8510,8516 
tree op1 = gimple_cond_rhs (stmt);
enum tree_code cond_code = gimple_cond_code (stmt);
  
!   if (cond_code != NE_EXPR
 cond_code != EQ_EXPR
 TREE_CODE (op0) == SSA_NAME
 INTEGRAL_TYPE_P (TREE_TYPE (op0))
--- 8508,8520 
tree op1 = gimple_cond_rhs (stmt);
enum tree_code cond_code = gimple_cond_code (stmt);
  
!   /* Simplify a conditional using a relational operator to an equality
!  test if the range information indicates only one value can satisfy
!  the original conditional.
!  Do that only in the second VRP pass as otherwise assertions derived
!  from this predicate are weakened.  */
!   if (!first_pass_instance
!cond_code != NE_EXPR
 cond_code != EQ_EXPR
 TREE_CODE (op0) == SSA_NAME
 INTEGRAL_TYPE_P (TREE_TYPE (op0))
Index: gcc/testsuite/g++.dg/warn/Warray-bounds-6.C
===
*** gcc/testsuite/g++.dg/warn/Warray-bounds-6.C (revision 0)
--- gcc/testsuite/g++.dg/warn/Warray-bounds-6.C (working copy)
***
*** 0 
--- 1,30 
+ // { dg-do compile }
+ // { dg-options -O3 -Warray-bounds }
+ 
+ struct type {
+ bool a, b;
+ bool get_b() { return b; }
+ };
+ 
+ type stuff[9u];
+ 
+ void bar();
+ 
+ void foo() {
+ 
+ for(unsigned i = 0u; i  9u; i++) {
+ 
+   if(!stuff[i].a) {
+   continue;
+   }
+ 
+   bar();
+ 
+   for(unsigned j = i + 1u; j  9u; j++) {
+   if(stuff[j].a  stuff[j].get_b()) { // { dg-bogus array bounds }
+   return;
+  

[PATCH] Fix PR56264

2013-02-11 Thread Richard Biener

This fixes PR56264 - the machinery to communicate changed-blocks from
fix_loop_structure to cfgcleanups call to rewrite_into_loop_closed_ssa
doesn't work (at least) in the face of newly discovered loops as that
exposes new definition sites and not only new use sites (as the code
assumes).

Fixed by completely re-scanning the whole function if we discover
new loops (in this case unswitching makes one subloop no longer
irreducible).

Bootstrapped and tested on x86_64-unknown-linux-gnu, need to retest
because I combined it with removing the find_uses_to_rename ??? and
that exposes PR56286.

Richard.

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

PR tree-optimization/56264
* cfgloop.h (fix_loop_structure): Adjust prototype.
* loop-init.c (fix_loop_structure): Return the number of
newly discovered loops.
* tree-cfgcleanup.c (repair_loop_structures): When new loops
are discovered, do a full loop-closed SSA rewrite.

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

Index: gcc/cfgloop.h
===
*** gcc/cfgloop.h   (revision 195938)
--- gcc/cfgloop.h   (working copy)
*** extern void flow_loop_dump (const struct
*** 216,222 
  struct loop *alloc_loop (void);
  extern void flow_loop_free (struct loop *);
  int flow_loop_nodes_find (basic_block, struct loop *);
! void fix_loop_structure (bitmap changed_bbs);
  bool mark_irreducible_loops (void);
  void release_recorded_exits (void);
  void record_loop_exits (void);
--- 216,222 
  struct loop *alloc_loop (void);
  extern void flow_loop_free (struct loop *);
  int flow_loop_nodes_find (basic_block, struct loop *);
! unsigned fix_loop_structure (bitmap changed_bbs);
  bool mark_irreducible_loops (void);
  void release_recorded_exits (void);
  void record_loop_exits (void);
Index: gcc/loop-init.c
===
*** gcc/loop-init.c (revision 195938)
--- gcc/loop-init.c (working copy)
*** loop_fini_done:
*** 171,186 
 the latch, and loops did not get new subloops (new loops might possibly
 get created, but we are not interested in them).  Fix up the mess.
  
!If CHANGED_BBS is not NULL, basic blocks whose loop has changed are
!marked in it.  */
  
! void
  fix_loop_structure (bitmap changed_bbs)
  {
basic_block bb;
int record_exits = 0;
loop_iterator li;
struct loop *loop;
  
timevar_push (TV_LOOP_INIT);
  
--- 171,189 
 the latch, and loops did not get new subloops (new loops might possibly
 get created, but we are not interested in them).  Fix up the mess.
  
!If CHANGED_BBS is not NULL, basic blocks whose loop depth has changed are
!marked in it.
  
!Returns the number of new discovered loops.  */
! 
! unsigned
  fix_loop_structure (bitmap changed_bbs)
  {
basic_block bb;
int record_exits = 0;
loop_iterator li;
struct loop *loop;
+   unsigned old_nloops;
  
timevar_push (TV_LOOP_INIT);
  
*** fix_loop_structure (bitmap changed_bbs)
*** 228,233 
--- 231,240 
delete_loop (loop);
  }
  
+   /* Remember the number of loops so we can return how many new loops
+  flow_loops_find discovered.  */
+   old_nloops = number_of_loops ();
+ 
/* Re-compute loop structure in-place.  */
flow_loops_find (current_loops);
  
*** fix_loop_structure (bitmap changed_bbs)
*** 253,258 
--- 260,267 
  #endif
  
timevar_pop (TV_LOOP_INIT);
+ 
+   return number_of_loops () - old_nloops;
  }
  
  /* Gate for the RTL loop superpass.  The actual passes are subpasses.
Index: gcc/tree-cfgcleanup.c
===
*** gcc/tree-cfgcleanup.c   (revision 195938)
--- gcc/tree-cfgcleanup.c   (working copy)
*** static void
*** 707,724 
  repair_loop_structures (void)
  {
bitmap changed_bbs;
  
calculate_dominance_info (CDI_DOMINATORS);
  
timevar_push (TV_REPAIR_LOOPS);
changed_bbs = BITMAP_ALLOC (NULL);
!   fix_loop_structure (changed_bbs);
  
/* This usually does nothing.  But sometimes parts of cfg that originally
   were inside a loop get out of it due to edge removal (since they
!  become unreachable by back edges from latch).  */
if (loops_state_satisfies_p (LOOP_CLOSED_SSA))
! rewrite_into_loop_closed_ssa (changed_bbs, TODO_update_ssa);
  
BITMAP_FREE (changed_bbs);
  
--- 707,728 
  repair_loop_structures (void)
  {
bitmap changed_bbs;
+   unsigned n_new_loops;
  
calculate_dominance_info (CDI_DOMINATORS);
  
timevar_push (TV_REPAIR_LOOPS);
changed_bbs = BITMAP_ALLOC (NULL);
!   n_new_loops = fix_loop_structure (changed_bbs);
  
/* This usually does nothing.  But sometimes parts of cfg that originally
   were inside a loop get out of it due to edge removal (since they
!  become unreachable by back 

Re: [PATCH, rtl-optimization]: Fix PR56275, ICE in simplify_subreg, at simplify-rtx.c:5261 with vector code.

2013-02-11 Thread Jeff Law

On 02/10/13 09:32, Uros Bizjak wrote:

Hello!

Attached patch prevents out-of-bounds offset in the call to
simplify_subreg, where the subreg offset is taken from the offset of a
memory access. The problem triggers on 4.6 branch and is latent on 4.7
and mainline.

2013-02-10  Uros Bizjak  ubiz...@gmail.com

PR rtl-optimization/56275
* simplify-rtx.c (avoid_constant_pool_reference): Check that
offset is non-negative and less than cmode size before
calling simplify_subreg.

testsuite/ChangeLog:

2013-02-10  Uros Bizjak  ubiz...@gmail.com

PR rtl-optimization/56275
* gcc.dg/pr56275.c: New test.

Tested on x86_64-pc-linux-gnu {,-m32}.

OK for mainline and release branches?
OK for mainline.  Please check with the appropriate release manager for 
the release branches.


Thanks,
Jeff



Re: libsanitizer merge from upstream r173241

2013-02-11 Thread Jack Howarth
On Mon, Feb 11, 2013 at 12:38:00PM +0100, Jakub Jelinek wrote:
 On Wed, Jan 23, 2013 at 04:24:01PM +0400, Evgeniy Stepanov wrote:
What if glibc adds a scanf hook (like it has already printf hooks), apps
could then register their own stuff and the above would then break.  It
really should be very conservative, and should be checked e.g. with all
glibc's *scanf tests (e.g. stdio-common/scanf[0-9]*.c,
stdio-common/tst-sscanf.c).
  
  I'll add support for the missing %specs. About the testing, these
  files seem like GPL, so I'd prefer not to look at them at all. We've
  got a smallish test for the scanf implementation in sanitizer_common,
  but it would be really great to run it on full glibc scanf tests.
  Would you be willing to setup such testing gnu-side?
 
 Seems the code in llvm repo looks much better now to me than it used to,
 still it breaks on:

Jakub,
  So there is likely to be at least one more remerge in libsanitizer for the
gcc 4.8 release? I saw that Richard felt that PR56128 justified one. FYI,
I'm interested because it would get us the new allocator support on darwin.
   Jack

 
 #define _GNU_SOURCE 1
 #include stdio.h
 #include string.h
 
 int
 main ()
 {
   char *p;
   long double q;
   if (sscanf (abcdefghijklmno 1.0, %ms %Lf, p, q) != 2
   || strcmp (p, abcdefghijklmno) != 0
   || q != 1.0L)
 return 1;
   return 0;
 }
 
 because it mishandles %ms.
 
 Attached patch fixes that and also handles %a when possible.
 There are cases where it is unambiguous, e.g.
 s%Las is s %La s, reading long double, or %ar is %a r, reading
 float, other cases where we can check at least something and keep checking
 the rest of the format string, e.g. for:
 %as
 we know it will either store float, or char * pointer, so just assume
 conservatively the smaller size, and other cases where we have to punt,
 %a[a%d]
 (where % appears in the [...] list).
 
 I've tested various glibc *scanf testcases with the GCC libsanitizer
 + enabling of # define SANITIZER_INTERCEPT_SCANF SI_NOT_WINDOWS
 + llvm svn diff between last merge point to GCC and current llvm trunk
 + this patch, and it looked good.
 
 There is one further issue, I'd say you need to pass down to scanf_common
 the result from the intercepted call, and use it to see if it is valid
 to call strlen on the ptr, or if just 1 should be assumed for SSS_STRLEN.
 Note 'n' doesn't count towards that.  Because, it is unsafe to call strlen
 on arguments that haven't been assigned yet.  Testcase that still fails:
 
 #define _GNU_SOURCE 1
 #include stdio.h
 #include string.h
 
 int
 main ()
 {
   int a, b, c, d;
   char e[3], f[10];
   memset (e, ' ', sizeof e);
   memset (f, ' ', sizeof f);
   if (sscanf (1 2 a, %d%n%n%d %s %s, a, b, c, d, e, f) != 3
   || a != 1
   || b != 1
   || c != 1
   || d != 2
   || strcmp (e, a) != 0)
 return 1;
   return 0;
 }
 
 Oh, one more thing, on Linux for recent enough glibc's it would be
 desirable to also intercept:
 __isoc99_sscanf, __isoc99_scanf, __isoc99_vsscanf, __isoc99_fscanf,
 __isoc99_vfscanf, __isoc99_vscanf
 functions (guard the interception with
 #if defined __GLIBC_PREREQ  __GLIBC_PREREQ (2, 7)
 ).  All these work exactly like the corresponding non-__isoc99_
 functions, just %a followed by s, S or [ always writes float, thus
 there is no ambiguity.
 
   Jakub

 --- sanitizer_common_interceptors_scanf.inc.jj2013-02-08 
 13:21:51.0 +0100
 +++ sanitizer_common_interceptors_scanf.inc   2013-02-11 12:15:27.575871424 
 +0100
 @@ -18,11 +18,12 @@
  
  struct ScanfDirective {
int argIdx;  // argument index, or -1 of not specified (%n$)
 -  bool suppressed; // suppress assignment (*)
int fieldWidth;
 +  bool suppressed; // suppress assignment (*)
bool allocate; // allocate space (m)
char lengthModifier[2];
char convSpecifier;
 +  bool maybeGnuMalloc;
  };
  
  static const char *parse_number(const char *p, int *out) {
 @@ -119,6 +120,31 @@ static const char *scanf_parse_next(cons
// Consume the closing ']'.
++p;
  }
 +// This is unfortunately ambiguous between old GNU extension
 +// of %as, %aS and %a[...] and newer POSIX %a followed by
 +// letters s, S or [.
 +if (dir-convSpecifier == 'a'  !dir-lengthModifier[0]) {
 +  if (*p == 's' || *p == 'S') {
 + dir-maybeGnuMalloc = true;
 + ++p;
 +  } else if (*p == '[') {
 + // Watch for %a[h-j%d], if % appears in the
 + // [...] range, then we need to give up, we don't know
 + // if scanf will parse it as POSIX %a [h-j %d ] or
 + // GNU allocation of string with range dh-j plus %.
 + const char *q = p + 1;
 + if (*q == '^')
 +   ++q;
 + if (*q == ']')
 +   ++q;
 + while (*q  *q != ']'  *q != '%')
 +   ++q;
 + if (*q == 0 || *q == '%')
 +   return 0;
 + p = q + 1; // Consume the closing ']'.
 + dir-maybeGnuMalloc = true;
 +  }
 +}
  break;
}

[PATCH] Fix vrp17.c FAIL

2013-02-11 Thread Richard Biener

We now optimize it better via tail-merging  reassoc before VRP2
can transform the 2nd test to !=.  The following restores the
input to VRP to match the original testcase expectations.

Committed.

Richard.

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

* gcc.dg/tree-ssa/vrp17.c: Disable tail-merging.

Index: gcc/testsuite/gcc.dg/tree-ssa/vrp17.c
===
--- gcc/testsuite/gcc.dg/tree-ssa/vrp17.c   (revision 195940)
+++ gcc/testsuite/gcc.dg/tree-ssa/vrp17.c   (working copy)
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options -O2 -fdump-tree-vrp2 } */
+/* { dg-options -O2 -fno-tree-tail-merge -fdump-tree-vrp2 } */
 
 extern void abort (void) __attribute__ ((__noreturn__));
 union tree_node;


Re: [Patch, Fortran, OOP] PR 46952: [OOP] Spurious recursive call error with type bound procedure

2013-02-11 Thread Janus Weil
Ping! (From the silence I infer that this is rather 4.9 material?)


2013/1/19 Janus Weil ja...@gcc.gnu.org:
 Hi all,

 here is a simple patch for a rejects-valid problem with deferred
 type-bound procedures. This is the patch from comment 5 in the PR. A
 simpler (but equivalent) patch can be found in comment 4. Both fix the
 problem and are free of testsuite regressions.

 Is any of the two versions still ok for 4.8? Or should it wait for 4.9?

 Cheers,
 Janus


 2013-01-18  Janus Weil  ja...@gcc.gnu.org

 PR fortran/46952
 * resolve.c (resolve_call): Do not check deferred procedures for
 recursiveness.


 2013-01-18  Janus Weil  ja...@gcc.gnu.org

 PR fortran/46952
 * gfortran.dg/typebound_deferred_1.f90: New.


[PATCH, libstdc++] Fix 22_locale/time_get/get_weekday/char/38081-[12].cc tests for glibc 2.17

2013-02-11 Thread Julian Brown
Hi,

It seems that glibc 2.17 changes the abbreviated names of weekdays for
ru_RU locales by removing an extraneous ., as described in:

http://sourceware.org/bugzilla/show_bug.cgi?id=10873

An earlier patch (circa glibc 2.14) changed (IIUC!) archaic/unusual
three-letter abbreviations to more-common two-letter abbreviations, but
included dots after each weekday name, which was apparently still wrong.
But, the two tests of this feature in the libstdc++ testsuite expect
those dots to be present, so they fail.

So, the attached patch simply removes the expectation that dots are
present in the abbreviated names from the libstdc++ tests in question,
if the glibc version in use is recent enough.

The tests pass (with a current gcc, trunk eglibc) with the attached
patch, and fail (for me) without it (cross-testing to ARM Linux, for
no particular reason). OK to apply?

Thanks,

Julian

ChangeLog

libstdc++/
* testsuite/22_locale/time_get/get_weekday/char/38081-1.cc (test01):
Don't expect dots after abbreviated weekday names for ru_RU for
glibc versions = 2.17.
* testsuite/22_locale/time_get/get_weekday/char/38081-2.cc (test01):
Likewise.
Index: libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/38081-1.cc
===
--- libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/38081-1.cc	(revision 195939)
+++ libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/38081-1.cc	(working copy)
@@ -50,7 +50,11 @@ void test01()
   // ios_base::iostate, tm*) const
 
 #if __GLIBC__  2 || (__GLIBC__ == 2  __GLIBC_MINOR__ = 14)
+# if __GLIBC__  2 || __GLIBC_MINOR__ = 17
+  iss.str(\xbf\xdd);
+# else
   iss.str(\xbf\xdd\x2e);
+# endif
 #else
   iss.str(\xbf\xdd\xd4);
 #endif
@@ -72,7 +76,11 @@ void test01()
   VERIFY( errorstate == ios_base::eofbit );
 
 #if __GLIBC__  2 || (__GLIBC__ == 2  __GLIBC_MINOR__ = 14)
+# if __GLIBC__  2 || __GLIBC_MINOR__ = 17
+  iss.str(\xbf\xdd\xd5\xd4\xd5\xdb\xec\xdd\xd8\xda);
+# else
   iss.str(\xbf\xdd\x2e\xd5\xd4\xd5\xdb\xec\xdd\xd8\xda);
+# endif
 #else
   iss.str(\xbf\xdd\xd4\xd5\xd4\xd5\xdb\xec\xdd\xd8\xda);
 #endif
Index: libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/38081-2.cc
===
--- libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/38081-2.cc	(revision 195939)
+++ libstdc++-v3/testsuite/22_locale/time_get/get_weekday/char/38081-2.cc	(working copy)
@@ -51,6 +51,15 @@ void test01()
   // ios_base::iostate, tm*) const
 
 #if __GLIBC__  2 || (__GLIBC__ == 2  __GLIBC_MINOR__ = 14)
+# if __GLIBC__  2 || __GLIBC_MINOR__ = 17
+  const char* awdays[7] = { \u0412\u0441,
+			\u041F\u043D,
+			\u0412\u0442,
+			\u0421\u0440,
+			\u0427\u0442,
+			\u041F\u0442,
+			\u0421\u0431 };
+# else
   const char* awdays[7] = { \u0412\u0441\u002E,
 			\u041F\u043D\u002E,
 			\u0412\u0442\u002E,
@@ -58,6 +67,7 @@ void test01()
 			\u0427\u0442\u002E,
 			\u041F\u0442\u002E,
 			\u0421\u0431\u002E };
+#endif
 #else
   const char* awdays[7] = { \u0412\u0441\u043A,
 			\u041F\u043D\u0434,


Re: [PATCH][ARM] Implement vectorizer cost hooks

2013-02-11 Thread Christophe Lyon
Richard,

Thanks for your comments.

Here a new version with the changes you suggested.

Christophe


On 11 February 2013 11:57, Richard Earnshaw rearn...@arm.com wrote:
 On 05/02/13 18:18, Christophe Lyon wrote:

 Hi,

 Following the discussion about disable peeling [1] a few weeks ago,
 it turned out that the vectorizer cost model needed some
 implementation for ARM.

 The attached patch implements arm_builtin_vectorization_cost and
 arm_add_stmt_cost, providing default costs when aligned and unaligned
 loads/stores have the same cost (=1). init_cost and finish_cost still
 use the default implementation (I noticed that x86 has chosen to
 duplicate the default implementation without changing it, why?)

 Benchmarking shows very little variation, expect a noticeable +1.6% on
 coremark.

 If this is OK, we can then discuss how to disable peeling completely
 when aligned and unaligned accesses have the same cost (and thus where
 peeling is a loss of performance). I think adding a new hook is
 necessary, since target descriptions may use different models for
 these costs (eg x86 makes no difference between unaligned loads and
 unaligned stores).

 Thanks,

 Christophe.

 [1] http://gcc.gnu.org/ml/gcc/2012-12/msg00036.html

 2013-02-05  Christophe Lyon christophe.l...@linaro.org

  * config/arm/arm.c (arm_builtin_vectorization_cost)
  (arm_add_stmt_cost): New functions.
  (TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST)
  (TARGET_VECTORIZE_ADD_STMT_COST): Define.
  (struct processor_costs): New struct type.
  (default_arm_cost): New struct of type processor_costs.=


 Christophe,

 Thanks for the patch.  This is mostly OK, but please can you make the
 following changes.

 +struct processor_costs {

 Please name this something like cpu_vec_costs.  It's not the only cost table
 in the back-end.

 +struct processor_costs default_arm_cost = {/* arm generic costs.  */

 Similarly, use something like default_arm_vec_cost.

 +const struct processor_costs *arm_cost = default_arm_cost;

 And here.  But better still, link this through the current_tune table rather
 than introducing a new global.

 Finally,

 @@ -27256,4 +27272,130 @@ arm_validize_comparison (rtx *comparison, rtx *
 op1, rtx * op2)

  }

 +/* Vectorizer cost model implementation.  */


 Please put the patch in a more suitable location rather than just dumping it
 at the end of the file.  There are already numerous functions related to
 costs that are mostly grouped together.  I suggest this goes near the
 rtx_costs code.

 R.


diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bfb857d..56fde74 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,17 @@
+2013-02-05  Christophe Lyon christophe.l...@linaro.org
+
+   * config/arm/arm-protos.h (struct cpu_vec_costs): New struct type.
+   (struct tune_params): Add vec_costs field.
+   * config/arm/arm.c (arm_builtin_vectorization_cost)
+   (arm_add_stmt_cost): New functions.
+   (TARGET_VECTORIZE_BUILTIN_VECTORIZATION_COST)
+   (TARGET_VECTORIZE_ADD_STMT_COST): Define.
+   (arm_default_vec_cost): New struct of type cpu_vec_costs.
+   (arm_slowmul_tune, arm_fastmul_tune, arm_strongarm_tune)
+   (arm_xscale_tune, arm_9e_tune, arm_v6t2_tune, arm_cortex_tune)
+   (arm_cortex_a15_tune, arm_cortex_a5_tune, arm_cortex_a9_tune)
+   (arm_v6m_tune, arm_fa726te_tune): Define new vec_costs field.
+
 2013-02-04  Alexander Potapenko gli...@google.com
 Jack Howarth  howa...@bromo.med.uc.edu
Jakub Jelinek  ja...@redhat.com


vect-cost-model2.patch
Description: Binary data


[PATCH] Fix ???s in find_uses_to_rename and vect_transform_loop

2013-02-11 Thread Richard Biener

This fixes the compile-time sink in find_uses_to_rename, that we
scan the whole function when nothing is to do (well, appearantly).

-O3 bootstrap and regtest on x86_64-unknown-linux-gnu in progress,
scheduled for stage1.

Richard.

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

* tree-ssa-loop-manip.c (find_uses_to_rename): Do not scan the
whole function when there is nothing to do.
* tree-ssa-loop.c (pass_vectorize): Remove TODO_update_ssa.
* tree-vectorizer.c (vectorize_loops): Update virtual and
loop-closed SSA once.
* tree-vect-loop.c (vect_transform_loop): Do not update SSA here.

Index: gcc/tree-ssa-loop-manip.c
===
*** gcc/tree-ssa-loop-manip.c   (revision 195940)
--- gcc/tree-ssa-loop-manip.c   (working copy)
*** find_uses_to_rename (bitmap changed_bbs,
*** 443,463 
unsigned index;
bitmap_iterator bi;
  
!   /* ??? If CHANGED_BBS is empty we rewrite the whole function -- why?  */
!   if (changed_bbs  !bitmap_empty_p (changed_bbs))
! {
!   EXECUTE_IF_SET_IN_BITMAP (changed_bbs, 0, index, bi)
!   {
! find_uses_to_rename_bb (BASIC_BLOCK (index), use_blocks, need_phis);
!   }
! }
else
! {
!   FOR_EACH_BB (bb)
!   {
! find_uses_to_rename_bb (bb, use_blocks, need_phis);
!   }
! }
  }
  
  /* Rewrites the program into a loop closed ssa form -- i.e. inserts extra
--- 443,454 
unsigned index;
bitmap_iterator bi;
  
!   if (changed_bbs)
! EXECUTE_IF_SET_IN_BITMAP (changed_bbs, 0, index, bi)
!   find_uses_to_rename_bb (BASIC_BLOCK (index), use_blocks, need_phis);
else
! FOR_EACH_BB (bb)
!   find_uses_to_rename_bb (bb, use_blocks, need_phis);
  }
  
  /* Rewrites the program into a loop closed ssa form -- i.e. inserts extra
Index: gcc/tree-ssa-loop.c
===
*** gcc/tree-ssa-loop.c (revision 195940)
--- gcc/tree-ssa-loop.c (working copy)
*** struct gimple_opt_pass pass_vectorize =
*** 242,249 
0,/* properties_provided */
0,/* properties_destroyed */
0,  /* todo_flags_start */
!   TODO_update_ssa
! | TODO_ggc_collect/* todo_flags_finish */
   }
  };
  
--- 242,248 
0,/* properties_provided */
0,/* properties_destroyed */
0,  /* todo_flags_start */
!   TODO_ggc_collect/* todo_flags_finish */
   }
  };
  
Index: gcc/tree-vectorizer.c
===
*** gcc/tree-vectorizer.c   (revision 195940)
--- gcc/tree-vectorizer.c   (working copy)
*** vectorize_loops (void)
*** 149,155 
  
free_stmt_vec_info_vec ();
  
!   return num_vectorized_loops  0 ? TODO_cleanup_cfg : 0;
  }
  
  
--- 149,164 
  
free_stmt_vec_info_vec ();
  
!   if (num_vectorized_loops  0)
! {
!   /* If we vectorized any loop only virtual SSA form needs to be updated.
!???  Also while we try hard to update loop-closed SSA form we fail
!to properly do this in some corner-cases (see PR56286).  */
!   rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa_only_virtuals);
!   return TODO_cleanup_cfg;
! }
! 
!   return 0;
  }
  
  
Index: gcc/tree-vect-loop.c
===
*** gcc/tree-vect-loop.c(revision 195940)
--- gcc/tree-vect-loop.c(working copy)
*** vect_transform_loop (loop_vec_info loop_
*** 5763,5773 
 loop-nb_iterations_estimate = loop-nb_iterations_estimate - 
double_int_one;
  }
  
-   /* The memory tags and pointers in vectorized statements need to
-  have their SSA forms updated.  FIXME, why can't this be delayed
-  until all the loops have been transformed?  */
-   update_ssa (TODO_update_ssa);
- 
if (dump_enabled_p ())
  dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, vect_location, LOOP 
VECTORIZED.);
if (loop-inner  dump_enabled_p ())
--- 5763,5768 


C++ PATCH for c++/56268 (ICE with __has_nothrow_copy)

2013-02-11 Thread Jason Merrill

Another missing maybe_instantiate_noexcept.

Tested x86_64-pc-linux-gnu, applying to trunk and 4.7.
commit 1a9ad88eb3e501aed25ca6542776aacf431c7adc
Author: Jason Merrill ja...@redhat.com
Date:   Sat Feb 9 15:58:29 2013 -0500

	PR c++/56268
	* semantics.c (classtype_has_nothrow_assign_or_copy_p): Call
	maybe_instantiate_noexcept.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index f8b37c1..e3dea09 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -5413,6 +5413,7 @@ classtype_has_nothrow_assign_or_copy_p (tree type, bool assign_p)
   else if (copy_fn_p (fn) = 0)
 	continue;
 
+  maybe_instantiate_noexcept (fn);
   if (!TYPE_NOTHROW_P (TREE_TYPE (fn)))
 	return false;
 }
diff --git a/gcc/testsuite/g++.dg/ext/has_nothrow_copy-8.C b/gcc/testsuite/g++.dg/ext/has_nothrow_copy-8.C
new file mode 100644
index 000..e1be1a0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/has_nothrow_copy-8.C
@@ -0,0 +1,19 @@
+// PR c++/56268
+// { dg-options -std=c++11 }
+
+template class T
+struct A {
+  A(const A) noexcept (T::value);
+};
+
+struct B {
+  static const bool value = true;
+};
+
+template class T
+struct C {
+  static const bool value = __has_nothrow_copy (T);
+};
+
+#define SA(X) static_assert((X),#X)
+SA(CAB::value);


[PATCH] Disable libsanitizer before darwin10

2013-02-11 Thread Jack Howarth
  Iain Sandoe discovered that on intel darwin9, the asan testsuite suffers 
hundreds of 
failures due to the absence of dispatch calls (Grand Central Dispatch) prior to 
darwin10.
The attached patch disables building libsanitizer on darwin8 and darwin9 until 
upstream
decides to support the earlier darwin releases. Bootstrap and regression tested 
on
x86_64-apple-darwin12. Okay for gcc trunk?
 Jack
2013-02-11  Jack Howarth  howa...@bromo.med.uc.edu

* configure.tgt: Disable build on darwin9 and earlier.

/libsanitizer

Index: libsanitizer/configure.tgt
===
--- libsanitizer/configure.tgt  (revision 195940)
+++ libsanitizer/configure.tgt  (working copy)
@@ -29,7 +29,7 @@ case ${target} in
;;
   sparc*-*-linux*)
;;
-  x86_64-*-darwin* | i?86-*-darwin*)
+  x86_64-*-darwin[1]* | i?86-*-darwin[1]*)
TSAN_SUPPORTED=no
;;
   *)


Re: [PATCH] Disable libsanitizer before darwin10

2013-02-11 Thread Iain Sandoe

On 11 Feb 2013, at 15:55, Jack Howarth wrote:

  Iain Sandoe discovered that on intel darwin9, the asan testsuite suffers 
 hundreds of 
 failures due to the absence of dispatch calls (Grand Central Dispatch) prior 
 to darwin10.
 The attached patch disables building libsanitizer on darwin8 and darwin9 
 until upstream
 decides to support the earlier darwin releases. Bootstrap and regression 
 tested on
 x86_64-apple-darwin12. Okay for gcc trunk?

note that making Darwin9 work is not that difficult - simply avoid the GCD 
calls (example hack attached).

However, the question is open as to whether upstream is willing to include code 
to cater for older Darwin (TBD).  
If such a change would be OK there, then the attached could be cleaned 
up/amended.

(it reduces the fails on i686-Darwin9 from 'all' asan to ~10 each for C on 
x86/x86_64 and similar for C++)

Iain


Index: libsanitizer/asan/dynamic/asan_interceptors_dynamic.cc
===
--- libsanitizer/asan/dynamic/asan_interceptors_dynamic.cc  (revision 
195915)
+++ libsanitizer/asan/dynamic/asan_interceptors_dynamic.cc  (working copy)
@@ -84,6 +84,10 @@
   INTERPOSE_FUNCTION(mlockall),
   INTERPOSE_FUNCTION(munlockall),
 #endif
+
+#if defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)  \
+__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ = 1060
+
   INTERPOSE_FUNCTION(dispatch_async_f),
   INTERPOSE_FUNCTION(dispatch_sync_f),
   INTERPOSE_FUNCTION(dispatch_after_f),
@@ -96,14 +100,19 @@
   INTERPOSE_FUNCTION(dispatch_source_set_event_handler),
   INTERPOSE_FUNCTION(dispatch_source_set_cancel_handler),
 #endif
+#endif
   INTERPOSE_FUNCTION(signal),
   INTERPOSE_FUNCTION(sigaction),
 
   INTERPOSE_FUNCTION(malloc_create_zone),
   INTERPOSE_FUNCTION(malloc_default_zone),
+
+#if defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)  \
+__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ = 1060
   INTERPOSE_FUNCTION(malloc_default_purgeable_zone),
   INTERPOSE_FUNCTION(malloc_make_purgeable),
   INTERPOSE_FUNCTION(malloc_make_nonpurgeable),
+#endif
   INTERPOSE_FUNCTION(malloc_set_zone_name),
   INTERPOSE_FUNCTION(malloc),
   INTERPOSE_FUNCTION(free),
@@ -111,7 +120,10 @@
   INTERPOSE_FUNCTION(calloc),
   INTERPOSE_FUNCTION(valloc),
   INTERPOSE_FUNCTION(malloc_good_size),
+#if defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)  \
+__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ = 1060
   INTERPOSE_FUNCTION(posix_memalign),
+#endif
 };
 
 }  // namespace __asan
Index: libsanitizer/asan/asan_mac.cc
===
--- libsanitizer/asan/asan_mac.cc   (revision 195915)
+++ libsanitizer/asan/asan_mac.cc   (working copy)
@@ -197,6 +197,8 @@
   return err_none;
 }
 
+#if defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)  \
+__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ = 1060
 // Support for the following functions from libdispatch on Mac OS:
 //   dispatch_async_f()
 //   dispatch_async()
@@ -285,10 +287,12 @@
   context-func(context-block);
   asan_free(context, stack, FROM_MALLOC);
 }
-
+#endif
 }  // namespace __asan
 
 using namespace __asan;  // NOLINT
+#if defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)  \
+__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ = 1060
 
 // Wrap |ctxt| and |func| into an asan_block_context_t.
 // The caller retains control of the allocated context.
@@ -319,6 +323,7 @@
asan_dispatch_call_block_and_release); \
   }
 
+
 INTERCEPT_DISPATCH_X_F_3(dispatch_async_f)
 INTERCEPT_DISPATCH_X_F_3(dispatch_sync_f)
 INTERCEPT_DISPATCH_X_F_3(dispatch_barrier_async_f)
@@ -421,5 +426,6 @@
 }
 
 }  // namespace __asan
+#endif
 
 #endif  // __APPLE__
Index: libsanitizer/asan/asan_malloc_mac.cc
===
--- libsanitizer/asan/asan_malloc_mac.cc(revision 195915)
+++ libsanitizer/asan/asan_malloc_mac.cc(working copy)
@@ -52,6 +52,9 @@
   return asan_zone;
 }
 
+#if defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)  \
+__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ = 1060
+
 INTERCEPTOR(malloc_zone_t *, malloc_default_purgeable_zone, void) {
   // FIXME: ASan should support purgeable allocations.
   // https://code.google.com/p/address-sanitizer/issues/detail?id=139
@@ -73,6 +76,7 @@
   // malloc_make_purgeable().
   return 0;
 }
+#endif
 
 INTERCEPTOR(void, malloc_set_zone_name, malloc_zone_t *zone, const char *name) 
{
   if (!asan_inited) __asan_init();
@@ -126,6 +130,9 @@
   return asan_zone.introspect-good_size(asan_zone, size);
 }
 
+#if defined (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)  \
+__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ = 1060
+
 INTERCEPTOR(int, posix_memalign, void **memptr, size_t alignment, size_t size) 
{
   if (!asan_inited) __asan_init();
   CHECK(memptr);
@@ -137,7 +144,7 @@
   }
   return -1;
 }
-
+#endif
 namespace {
 
 // 

Re: [PATCH] Disable libsanitizer before darwin10

2013-02-11 Thread Alexander Potapenko
For the record, ASan never claimed darwin9 support and isn't going to
support darwin9 in the future, so it should be fine to disable
building ASan on this platform.

On Mon, Feb 11, 2013 at 7:55 PM, Jack Howarth howa...@bromo.med.uc.edu wrote:
   Iain Sandoe discovered that on intel darwin9, the asan testsuite suffers 
 hundreds of
 failures due to the absence of dispatch calls (Grand Central Dispatch) prior 
 to darwin10.
 The attached patch disables building libsanitizer on darwin8 and darwin9 
 until upstream
 decides to support the earlier darwin releases. Bootstrap and regression 
 tested on
 x86_64-apple-darwin12. Okay for gcc trunk?
  Jack



--
Alexander Potapenko
Software Engineer
Google Moscow


Re: libgo patch committed: If using DejaGNU, don't frob log file

2013-02-11 Thread Mike Stump
On Feb 9, 2013, at 3:19 PM, Ian Lance Taylor i...@google.com wrote:
 If the libgo testsuite is using DejaGNU, there is no need to frob the
 log file to make it look like DejaGNU output.  Bootstrapped and ran Go
 testsuite on x86_64-unknown-linux-gnu (without DejaGNU).  Committed to
 mainline.
 
 Ian

ENOPATCH


Re: [patch libada]: PR target/52122

2013-02-11 Thread NightStrike
Ping

On Wed, Feb 6, 2013 at 12:10 AM, Kai Tietz ktiet...@googlemail.com wrote:
 Hi,

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

 ChangeLog libada/

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

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

 Ok for apply?

 Regards,
 Kai


Re: [PATCH, libstdc++] Fix 22_locale/time_get/get_weekday/char/38081-[12].cc tests for glibc 2.17

2013-02-11 Thread Paolo Carlini

Hi,

On 02/11/2013 04:33 PM, Julian Brown wrote:

Hi,

It seems that glibc 2.17 changes the abbreviated names of weekdays for
ru_RU locales by removing an extraneous ., as described in:

http://sourceware.org/bugzilla/show_bug.cgi?id=10873

An earlier patch (circa glibc 2.14) changed (IIUC!) archaic/unusual
three-letter abbreviations to more-common two-letter abbreviations, but
included dots after each weekday name, which was apparently still wrong.
But, the two tests of this feature in the libstdc++ testsuite expect
those dots to be present, so they fail.

So, the attached patch simply removes the expectation that dots are
present in the abbreviated names from the libstdc++ tests in question,
if the glibc version in use is recent enough.

The tests pass (with a current gcc, trunk eglibc) with the attached
patch, and fail (for me) without it (cross-testing to ARM Linux, for
no particular reason). OK to apply?
I think it's Ok, yes. Thanks. However, I would appreciate if somebody 
with a glibc 2.17 system at hand could double check. Maybe HJ?


Thanks,
Paolo.


Re: [PATCH, libstdc++] Fix 22_locale/time_get/get_weekday/char/38081-[12].cc tests for glibc 2.17

2013-02-11 Thread H.J. Lu
On Mon, Feb 11, 2013 at 9:18 AM, Paolo Carlini paolo.carl...@oracle.com wrote:
 Hi,


 On 02/11/2013 04:33 PM, Julian Brown wrote:

 Hi,

 It seems that glibc 2.17 changes the abbreviated names of weekdays for
 ru_RU locales by removing an extraneous ., as described in:

 http://sourceware.org/bugzilla/show_bug.cgi?id=10873

 An earlier patch (circa glibc 2.14) changed (IIUC!) archaic/unusual
 three-letter abbreviations to more-common two-letter abbreviations, but
 included dots after each weekday name, which was apparently still wrong.
 But, the two tests of this feature in the libstdc++ testsuite expect
 those dots to be present, so they fail.

 So, the attached patch simply removes the expectation that dots are
 present in the abbreviated names from the libstdc++ tests in question,
 if the glibc version in use is recent enough.

 The tests pass (with a current gcc, trunk eglibc) with the attached
 patch, and fail (for me) without it (cross-testing to ARM Linux, for
 no particular reason). OK to apply?

 I think it's Ok, yes. Thanks. However, I would appreciate if somebody with a
 glibc 2.17 system at hand could double check. Maybe HJ?


I am not familiar with locale.  CC to glibc mailing list.


-- 
H.J.


Re: [patch libada]: PR target/52122

2013-02-11 Thread Geert Bosch

On Feb 6, 2013, at 05:10, Kai Tietz ktiet...@googlemail.com wrote:

 this patch fixes an issue about recursice LN_S for mingw-host.  The
 issue was already addressed by autotools, but an upgrade of version
 isn't suitable right now.
 For further information see the bug-report PR 52122.
 
 ChangeLog libada/
 
   PR target/52122
   * Makefile.in (LN_S_RECUSIVE): New.
(adainclude, adalib): Use LN_S_RECURSIVE for copy.
 
 Patch see at http://gcc.gnu.org/bugzilla/attachment.cgi?id=29176

OK.

  -Geert


RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-11 Thread Jason Merrill
While I was going over the C++11 status page, I noticed that quick_exit 
is implemented by glibc, it just needed to be added to the libstdc++ 
cstdlib header.


Does this configury/feature macro handling look right?  Is this enough 
testcase?  Is this small/safe enough to go in for 4.8?
commit 884a2a7815a95bade9d23f01b4c64a16808c7f05
Author: Jason Merrill ja...@redhat.com
Date:   Mon Feb 11 11:23:30 2013 -0500

	* linkage.m4 (GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE): New.
	(GLIBCXX_CHECK_STDLIB_SUPPORT): Check for atexit and at_quick_exit.
	* include/c_std/cstdlib: Add atexit and at_quick_exit.
	* include/c_global/cstdlib: Add atexit and at_quick_exit.
	* testsuite/18_support/quick_exit/quick_exit.cc: New.

diff --git a/libstdc++-v3/include/c_global/cstdlib b/libstdc++-v3/include/c_global/cstdlib
index c249c78..0eb0129 100644
--- a/libstdc++-v3/include/c_global/cstdlib
+++ b/libstdc++-v3/include/c_global/cstdlib
@@ -57,6 +57,8 @@ namespace std
   extern C void abort(void) throw () _GLIBCXX_NORETURN;
   extern C int atexit(void (*)()) throw ();
   extern C void exit(int) throw () _GLIBCXX_NORETURN;
+  extern C int at_quick_exit(void (*)()) throw ();
+  extern C void quick_exit(int) throw() _GLIBCXX_NORETURN;
 } // namespace std
 
 #else
@@ -67,6 +69,7 @@ namespace std
 #undef abort
 #undef abs
 #undef atexit
+#undef at_quick_exit
 #undef atof
 #undef atoi
 #undef atol
@@ -83,6 +86,7 @@ namespace std
 #undef mbstowcs
 #undef mbtowc
 #undef qsort
+#undef quick_exit
 #undef rand
 #undef realloc
 #undef srand
@@ -103,6 +107,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   using ::abort;
   using ::abs;
   using ::atexit;
+#ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT
+  using ::at_quick_exit;
+#endif
   using ::atof;
   using ::atoi;
   using ::atol;
@@ -121,6 +128,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   using ::mbtowc;
 #endif // _GLIBCXX_HAVE_MBSTATE_T
   using ::qsort;
+#ifdef _GLIBCXX_HAVE_QUICK_EXIT
+  using ::quick_exit;
+#endif
   using ::rand;
   using ::realloc;
   using ::srand;
diff --git a/libstdc++-v3/linkage.m4 b/libstdc++-v3/linkage.m4
index b24f455..45a09cd 100644
--- a/libstdc++-v3/linkage.m4
+++ b/libstdc++-v3/linkage.m4
@@ -239,6 +239,35 @@ dnl 2) has C linkage
 dnl
 dnl argument 1 is name of function to check
 dnl
+dnl ASSUMES argument is a stdlib function with ONE parameter
+dnl
+dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_1
+AC_DEFUN([GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_1], [
+  AC_MSG_CHECKING([for $1 declaration])
+  if test x${glibcxx_cv_func_$1_use+set} != xset; then
+AC_CACHE_VAL(glibcxx_cv_func_$1_use, [
+  AC_LANG_SAVE
+  AC_LANG_CPLUSPLUS
+  AC_TRY_COMPILE([#include stdlib.h],
+ [ $1(0);],
+ [glibcxx_cv_func_$1_use=yes], [glibcxx_cv_func_$1_use=no])
+  AC_LANG_RESTORE
+])
+  fi
+  AC_MSG_RESULT($glibcxx_cv_func_$1_use)
+  if test x$glibcxx_cv_func_$1_use = xyes; then
+AC_CHECK_FUNCS($1)
+  fi
+])
+
+
+dnl
+dnl Check to see if the (stdlib function) argument passed is
+dnl 1) declared when using the c++ compiler
+dnl 2) has C linkage
+dnl
+dnl argument 1 is name of function to check
+dnl
 dnl ASSUMES argument is a stdlib function with TWO parameters
 dnl
 dnl GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2
@@ -306,6 +335,8 @@ AC_DEFUN([GLIBCXX_CHECK_STDLIB_SUPPORT], [
   ac_save_CXXFLAGS=$CXXFLAGS
   CXXFLAGS='-fno-builtin -D_GNU_SOURCE'
 
+  GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_1(at_quick_exit)
+  GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_1(quick_exit)
   GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtold)
   GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE_2(strtof)
 
diff --git a/libstdc++-v3/testsuite/18_support/quick_exit/quick_exit.cc b/libstdc++-v3/testsuite/18_support/quick_exit/quick_exit.cc
new file mode 100644
index 000..54ee41e
--- /dev/null
+++ b/libstdc++-v3/testsuite/18_support/quick_exit/quick_exit.cc
@@ -0,0 +1,39 @@
+// 2013-02-11 Jason Merrill
+
+// Copyright (C) 2013 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// http://www.gnu.org/licenses/.
+
+// 18.5 - Start and termination
+
+#include cstdlib
+
+void handler()
+{
+  std::_Exit(0);
+}
+
+void wrong_handler()
+{
+  std::abort();
+}
+
+int main()
+{
+  std::at_quick_exit (handler);
+  std::atexit (wrong_handler);
+  std::quick_exit (1);
+}
diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in

Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-11 Thread Benjamin De Kosnik

 Does this configury/feature macro handling look right? 

yes.

 Is this enough testcase? 

yes.

 Is this small/safe enough to go in for 4.8?

yes.
 
 commit 884a2a7815a95bade9d23f01b4c64a16808c7f05
 Author: Jason Merrill ja...@redhat.com
 Date:   Mon Feb 11 11:23:30 2013 -0500
 
   * linkage.m4 (GLIBCXX_CHECK_STDLIB_DECL_AND_LINKAGE): New.
   (GLIBCXX_CHECK_STDLIB_SUPPORT): Check for atexit and
 at_quick_exit.
   * include/c_std/cstdlib: Add atexit and at_quick_exit.
   * include/c_global/cstdlib: Add atexit and at_quick_exit.
   * testsuite/18_support/quick_exit/quick_exit.cc: New.


thanks Jason

-benjamin


Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-11 Thread Paolo Carlini

Hi,

On 02/11/2013 06:33 PM, Jason Merrill wrote:
While I was going over the C++11 status page, I noticed that 
quick_exit is implemented by glibc, it just needed to be added to the 
libstdc++ cstdlib header.


Does this configury/feature macro handling look right?  Is this enough 
testcase?  Is this small/safe enough to go in for 4.8?
I'm only not sure we want to add the new C++11 functions to c_std too, 
besides c_global, because normally we don't, AFAIK. But Benjamin 
invented the split c_std / c_global, I'm only raising a trivial 
consistency issue.


Thanks!
Paolo.


[GCC 4.8 changes] PATCH: Mention -maddress-mode=[short|long]

2013-02-11 Thread H.J. Lu
Hi,

This patch updates GCC 4.8 changes.html to mention
-maddress-mode=[short|long] for x32.  OK to install?


H.J.
---
Index: changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-4.8/changes.html,v
retrieving revision 1.95
diff -u -p -r1.95 changes.html
--- changes.html11 Feb 2013 15:12:58 -  1.95
+++ changes.html11 Feb 2013 18:03:31 -
@@ -460,6 +460,10 @@ B b(42); // OK
 wrong results.  You must build all
 modules with code-mpreferred-stack-boundary=3/code, including any
 libraries.  This includes the system libraries and startup modules./li
+liNew code-maddress-mode=[short|long]/code option for x32.
+code-maddress-mode=short/code overrides default 64-bit addresses to
+32-bit by emitting 0x67 size prefix. This is the default address mode for
+x32./li
 li New built-in functions to detect run-time CPU type and ISA:
 ul
   liA built-in function code__builtin_cpu_is/code has been added to


[PATCH] Cilk Plus merging to trunk (3 of n)

2013-02-11 Thread Iyer, Balaji V
Hello Everyone,
   Attached, please find a patch that implements Array Notations for C++. This 
patch affects the C++ compiler and should build (or be applied) on top of the 
Array Notation for C patch (2 of n: 
http://gcc.gnu.org/ml/gcc-patches/2013-01/msg01213.html). To my best knowledge, 
I have implemented all the applicable comments that GCC reviewers have made 
about my previous patches into this. Please let me know if it is Ok for trunk.

Here are the ChangeLog Entries:

gcc/cp/Changelog
2013-02-11  Balaji V. Iyer  balaji.v.i...@intel.com

* typeck.c (cp_build_array_ref): Added a check if array notation used
as index for an array has a rank greater than 1.  If so, then emit an
error.
(cp_build_binary_op): Find the correct type when array notation expr. is
used in op0 and op1.
(cp_build_addr_expr_1): Check if array notation is used and if so then
handle the arg and var like you handle an array.
(convert_for_assignment): If array notation is used, then just return
the rhs.
* semantics.c (finish_return_stmt): Added a check for array notations in
return statement.  If so, then issue an error.
(cxx_eval_constant_expression): Added a ARRAY_NOTATION_REF case.
(potential_constant_expression_1): Likewise.
* tree.c (lvalue_kind): Likewise.
* pt.c (tsubst_copy_and_build): Likewise.
(type_unification_real): Return 1 when array notation is used and cilk
plus is enabled.
(instantiate_decl): Check if array notation is used in (sub)tree when
Cilk plus is enabled.  If so, then expand them.
* parser.c (cp_parser_nested_name_specifier_opt): Added a check if cilk
plus is enabled.  If so, then we don't issue the error.
(cp_parser_postfix_open_square_expression): Added checks for colon(s)
after square braces when cilkplus is enabled.  if so, then do the array
notation parsing.
(cp_parser_compound_statement): Added a check to see if array notations
are used in the (sub)tree.  if so, then call function to expand them.
(cp_parser_ctor_initializer_opt_and_function_body): Likewise.
(cp_parser_function_definition_after_declarator): Likewise.
(cp_parser_selection_statement): Added a check if array notation is used
in a switch statement.  If so, then issue an error.
(cp_parser_iteration_statement): Likewise for while and do-while and for
statements.
(cp_parser_direct_declarator): Added a check for intialization near an
array notation.  If so, then issue an error.
* cp-tree.h (build_x_array_notation_expr): New function declaration.
(contains_array_notation_expr): Likewise.
(fix_array_notation_exprs): Likewise.
(is_builtin_array_notation_fn): Likewise.
(find_correct_array_notation_type): Likewise.
(cp_parser_array_notation): New function.
* cp-objcp-common.c (cp_common_init_ts): Marked ARRAY_NOTATION_REF as
typed.
* call.c (convert_like_real): Added a check for array notations when
cilkplus is enabled.
(build_over_call): Added a check if the function call is a builtin
array notation function.  If so, then no type conversion is necessary.
* cp-array-notation.c: New file.
* Make-lang.in (CXX_AND_OBJCXX_OBJS): Added cp/cp-array-notation.o

gcc/testsuite/Changelog
2013-02-11  Balaji V. Iyer  balaji.v.i...@intel.com

* g++.dg/cilk-plus/array_notation/compile/array_test1.cc: New test.
* g++.dg/cilk-plus/array_notation/compile/array_test2.cc: Likewise.
* g++.dg/cilk-plus/array_notation/compile/builtin_fn_double.cc: 
Likewise.
* g++.dg/cilk-plus/array_notation/compile/builtin_funcs.cc: Likewise.
* g++.dg/cilk-plus/array_notation/compile/gather_scatter.cc: Likewise.
* g++.dg/cilk-plus/array_notation/compile/if_test1.cc: Likewise.
* g++.dg/cilk-plus/array_notation/compile/if_test2.cc: Likewise.
* g++.dg/cilk-plus/array_notation/compile/postdecr_test.cc: Likewise.
* g++.dg/cilk-plus/array_notation/compile/postincr_test.cc: Likewise.
* g++.dg/cilk-plus/array_notation/compile/preincr_test.cc: Likewise.
* g++.dg/cilk-plus/array_notation/compile/predecr_test.cc: Likewise.
* g++.dg/cilk-plus/array_notation/compile/sec_implicit_ex.cc: Likewise.
* g++.dg/cilk-plus/array_notation/errors/decl-ptr-colon.cc: Likewise.
* g++.dg/cilk-plus/array_notation/errors/fn_ptr.cc: Likewise.
* g++.dg/cilk-plus/array_notation/errors/fp_triplet_values.cc: Likewise.
* g++.dg/cilk-plus/array_notation/errors/gather_scatter.cc: Likewise.
* g++.dg/cilk-plus/array_notation/errors/misc.cc: Likewise.
* g++.dg/cilk-plus/array_notation/errors/parser_errors.cc: Likewise.
* g++.dg/cilk-plus/array_notation/errors/parser_errors2.cc: Likewise.

Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-11 Thread Paolo Carlini
.. also, I think we should have #if __cplusplus = 201103L protecting 
these functions too, exactly like all the other C++11 bits. Eg, I don't 
think we should unconditionally, ie in C++03 mode too, declare 
at_quick_exit and quick_exit in namespace std.


I can tweak things for the two issues I noticed.

Paolo.


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

2013-02-11 Thread Sriraman Tallam
Hi,

  Is this alright to commit?

Thanks
Sri

On Thu, Feb 7, 2013 at 4:10 PM, Sriraman Tallam tmsri...@google.com wrote:
 On Thu, Feb 7, 2013 at 6:29 AM, Jason Merrill ja...@redhat.com wrote:
 On 02/06/2013 08:39 PM, Sriraman Tallam wrote:

 +// Test to check if an error is generated when virtual functions
 +// are multiversioned.


 This seems like a TODO, rather than something to test for.  I don't see any
 reason why we couldn't support multiversioned virtual functions.

  error_at (DECL_SOURCE_LOCATION (decl),
 - Virtual function versioning not supported\n);
 + Virtual function multiversioning not supported\n);


 And so this should be a sorry rather than an error.

 Attached a new patch with these changes. Also made more minor changes
 to config/i386/i386.c.

 Thanks
 Sri


 Jason



Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-11 Thread Benjamin De Kosnik

 .. also, I think we should have #if __cplusplus = 201103L protecting 
 these functions too, exactly like all the other C++11 bits. Eg, I
 don't think we should unconditionally, ie in C++03 mode too, declare 
 at_quick_exit and quick_exit in namespace std.

Yeah.
 
 I can tweak things for the two issues I noticed.

Thanks. 

It seems like this is still 4.8 material to me.

-benjamin


Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-11 Thread Paolo Carlini

On 02/11/2013 07:54 PM, Benjamin De Kosnik wrote:

I can tweak things for the two issues I noticed.

Thanks.

It seems like this is still 4.8 material to me.
Great. I'll take care of that later today. I'm also going to make sure 
the new testcase doesn't spuriously fail if the functions aren't 
actually available.


Paolo.


libgo patch committed: Solaris portability patches

2013-02-11 Thread Ian Lance Taylor
This patch from Rainer Orth in PR 56171 fixes some Solaris portability
problems in libgo.

* Check for nanosleep in -lrt.
* Pass $(LIBS) when testing so that the tests use -lrt as needed.
* Make sure that AF_LOCAL is defined.

Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

diff -r 4466c8235d4a libgo/Makefile.am
--- a/libgo/Makefile.am	Sat Feb 09 21:58:14 2013 -0800
+++ b/libgo/Makefile.am	Mon Feb 11 10:56:06 2013 -0800
@@ -1997,7 +1997,7 @@
 CHECK = \
 	GC=$(GOC) $(GOCFLAGS) $($(subst /,_,$@)_GOCFLAGS) -L `${PWD_COMMAND}` -L `${PWD_COMMAND}`/.libs; \
 	export GC; \
-	GOLIBS=$(MATH_LIBS) $(NET_LIBS); \
+	GOLIBS=$(MATH_LIBS) $(NET_LIBS) $(LIBS); \
 	export GOLIBS; \
 	RUNTESTFLAGS=$(RUNTESTFLAGS); \
 	export RUNTESTFLAGS; \
diff -r 4466c8235d4a libgo/configure.ac
--- a/libgo/configure.ac	Sat Feb 09 21:58:14 2013 -0800
+++ b/libgo/configure.ac	Mon Feb 11 10:56:06 2013 -0800
@@ -413,8 +413,9 @@
 AC_CHECK_LIB([pthread], [pthread_create], PTHREAD_LIBS=-lpthread)
 AC_SUBST(PTHREAD_LIBS)
 
-dnl Test if -lrt is required for sched_yield.
+dnl Test if -lrt is required for sched_yield and/or nanosleep.
 AC_SEARCH_LIBS([sched_yield], [rt])
+AC_SEARCH_LIBS([nanosleep], [rt])
 
 AC_C_BIGENDIAN
 
diff -r 4466c8235d4a libgo/mksysinfo.sh
--- a/libgo/mksysinfo.sh	Sat Feb 09 21:58:14 2013 -0800
+++ b/libgo/mksysinfo.sh	Mon Feb 11 10:56:06 2013 -0800
@@ -309,6 +309,13 @@
   fi
 done
 
+# The syscall package requires AF_LOCAL.
+if ! grep '^const AF_LOCAL ' ${OUT} /dev/null 21; then
+  if grep '^const AF_UNIX ' ${OUT} /dev/null 21; then
+echo const AF_LOCAL = AF_UNIX  ${OUT}
+  fi
+fi
+
 # pathconf constants.
 grep '^const __PC' gen-sysinfo.go |
   sed -e 's/^\(const \)__\(PC[^= ]*\)\(.*\)$/\1\2 = __\2/'  ${OUT}


Re: [PATCH, libstdc++] Fix 22_locale/time_get/get_weekday/char/38081-[12].cc tests for glibc 2.17

2013-02-11 Thread Carlos O'Donell
On 02/11/2013 12:28 PM, H.J. Lu wrote:
 On Mon, Feb 11, 2013 at 9:18 AM, Paolo Carlini paolo.carl...@oracle.com 
 wrote:
 On 02/11/2013 04:33 PM, Julian Brown wrote:

 Hi,

 It seems that glibc 2.17 changes the abbreviated names of weekdays for
 ru_RU locales by removing an extraneous ., as described in:

 http://sourceware.org/bugzilla/show_bug.cgi?id=10873

 An earlier patch (circa glibc 2.14) changed (IIUC!) archaic/unusual
 three-letter abbreviations to more-common two-letter abbreviations, but
 included dots after each weekday name, which was apparently still wrong.
 But, the two tests of this feature in the libstdc++ testsuite expect
 those dots to be present, so they fail.

 So, the attached patch simply removes the expectation that dots are
 present in the abbreviated names from the libstdc++ tests in question,
 if the glibc version in use is recent enough.

 The tests pass (with a current gcc, trunk eglibc) with the attached
 patch, and fail (for me) without it (cross-testing to ARM Linux, for
 no particular reason). OK to apply?

 I think it's Ok, yes. Thanks. However, I would appreciate if somebody with a
 glibc 2.17 system at hand could double check. Maybe HJ?

 
 I am not familiar with locale.  CC to glibc mailing list.

Paolo,

glibc 2.17 and eglibc 2.17 are so close that it should be fine
to test just one. I'd think the change should be fine for libstdc++.

Upstream will be working to reduce the differences between eglibc
and glibc so eventually these reports will just say glibc in
their testing notes.

Does that make sense?

Cheers,
Carlos.


Re: [PATCH, libstdc++] Fix 22_locale/time_get/get_weekday/char/38081-[12].cc tests for glibc 2.17

2013-02-11 Thread Jonathan Wakely
On 11 February 2013 17:18, Paolo Carlini wrote:

 I think it's Ok, yes. Thanks. However, I would appreciate if somebody with a
 glibc 2.17 system at hand could double check. Maybe HJ?

Although I'm sure Carlos is right that they're close enough to not
need checking, I've got a Rawhide setup with glibc 2.17 so I can test
it, just to be sure.


[Patch,avr]: ad PR54222: Add saturated multiply

2013-02-11 Thread Georg-Johann Lay
This patch adds optimized support for (short) (un)signed _Sat _Accum
multiplication (HA, UHA, SA, USA).

The 32-bit multiply uses 64 = 32 * 32 widening multiplication.  As a spin-off,
the widening mul is available as [u]mulsidi3 default pattern.


Okay for trunk?

Johann


gcc/
PR target/54222
* config/avr/avr-dimode.md (umulsidi3, mulsidi3): New expanders.
(umulsidi3_insn, mulsidi3_insn): New insns.

libgcc/
PR target/54222
* config/avr/t-avr (LIB2FUNCS_EXCLUDE): Add: _usmulUHA, _usmulUSA,
_ssmulHA, _ssmulSA.
(LIB1ASMFUNCS): Add: _muldi3_6, _mulsidi3, _umulsidi3, _usmuluha3,
_ssmulha3, _usmulusa3, _ssmulsa3.
* config/avr/lib1funcs.S (__muldi3_6): Break out of __muldi3.
(__muldi3): XCALL __muldi3_6 instead of rcall.
(__umulsidi3, __mulsidi3): New functions.
(do_prologue_saves, do_epilogue_restores): New .macros.
(__divdi3_moddi3): Use them.
* config/avr/lib1funcs-fixed.S (__usmuluha3, __ssmulha3)
(__usmulusa3, __ssmulsa3): New functions.

Index: gcc/config/avr/avr-dimode.md
===
--- gcc/config/avr/avr-dimode.md	(revision 195877)
+++ gcc/config/avr/avr-dimode.md	(working copy)
@@ -446,3 +446,34 @@ (define_insn code_stdnamemode3_insn
   %~call __code_stdnamedi3
   [(set_attr adjust_len call)
(set_attr cc clobber)])
+
+;; umulsidi3
+;; mulsidi3
+(define_expand extend_umulsidi3
+  [(parallel [(match_operand:DI 0 register_operand )
+  (match_operand:SI 1 general_operand )
+  (match_operand:SI 2 general_operand )
+  ;; Just to mention the iterator 
+  (clobber (any_extend:SI (match_dup 1)))])]
+  avr_have_dimode
+  {
+emit_move_insn (gen_rtx_REG (SImode, 22), operands[1]);
+emit_move_insn (gen_rtx_REG (SImode, 18), operands[2]);
+emit_insn (gen_extend_umulsidi3_insn());
+// Use emit_move_insn and not open-coded expand because of missing movdi
+emit_move_insn (operands[0], gen_rtx_REG (DImode, ACC_A));
+DONE;
+  })
+
+;; umulsidi3_insn
+;; mulsidi3_insn
+(define_insn extend_umulsidi3_insn
+  [(set (reg:DI ACC_A)
+(mult:DI (any_extend:DI (reg:SI 18))
+ (any_extend:DI (reg:SI 22
+   (clobber (reg:HI REG_X))
+   (clobber (reg:HI REG_Z))]
+  avr_have_dimode
+  %~call __extend_umulsidi3
+  [(set_attr adjust_len call)
+   (set_attr cc clobber)])
Index: libgcc/config/avr/lib1funcs-fixed.S
===
--- libgcc/config/avr/lib1funcs-fixed.S	(revision 195878)
+++ libgcc/config/avr/lib1funcs-fixed.S	(working copy)
@@ -669,6 +669,210 @@ ENDF __mulusa3_round
 
 #undef GUARD
 
+/***
+Fixed  unsigned saturated Multiplication  8.8 x 8.8
+***/
+
+#define C0  22
+#define C1  C0+1
+#define C2  C0+2
+#define C3  C0+3
+#define SS __tmp_reg__
+
+#if defined (L_usmuluha3)
+DEFUN __usmuluha3
+;; Widening multiply
+#ifdef __AVR_HAVE_MUL__
+;; Adjust interface
+movwR26, R22
+movwR18, R24
+#endif /* HAVE MUL */
+XCALL   __umulhisi3
+tst C3
+brne .Lmax
+;; Round, target is in C1..C2
+lsl C0
+adc C1, __zero_reg__
+adc C2, __zero_reg__
+brcs .Lmax
+;; Move result into place
+mov C3, C2
+mov C2, C1
+ret
+.Lmax:
+;; Saturate
+ldi C2, 0xff
+ldi C3, 0xff
+ret
+ENDF  __usmuluha3
+#endif /* L_usmuluha3 */
+
+/***
+Fixed signed saturated Multiplication  s8.7 x s8.7
+***/
+
+#if defined (L_ssmulha3)
+DEFUN __ssmulha3
+;; Widening multiply
+#ifdef __AVR_HAVE_MUL__
+;; Adjust interface
+movwR26, R22
+movwR18, R24
+#endif /* HAVE MUL */
+XCALL   __mulhisi3
+;; Adjust decimal point
+lsl C0
+rol C1
+rol C2
+brvs .LsatC3.3
+;; The 9 MSBs must be the same
+rol C3
+sbc SS, SS
+cp  C3, SS
+brne .LsatSS
+;; Round
+lsl C0
+adc C1, __zero_reg__
+adc C2, __zero_reg__
+brvs .Lmax
+;; Move result into place
+movC3, C2
+movC2, C1
+ret
+.Lmax:
+;; Load 0x7fff
+clr C3
+.LsatC3.3:
+;; C3   0 --  0x8000
+;; C3 = 0 --  0x7fff
+mov SS, C3
+.LsatSS:
+;; Load min / max value:
+;; SS = -1  --  0x8000
+;; SS =  0  --  0x7fff
+ldi C3, 0x7f
+ldi C2, 0xff
+sbrcSS, 7
+adiwC2, 1
+ret
+ENDF  __ssmulha3
+#endif /* L_ssmulha3 */
+
+#undef C0
+#undef C1
+#undef C2
+#undef C3
+#undef SS
+
+/***
+Fixed  unsigned saturated Multiplication  16.16 x 16.16
+***/
+
+#define 

Sync include/plugin-api.h with the copy in binutils

2013-02-11 Thread Sriraman Tallam
Hi,

   This patch was approved by Ian:
http://sourceware.org/ml/binutils/2013-02/msg00136.html

I have synced plugin-api.h

* plugin-api.h (enum ld_plugin_level): Assign integers
explicitly for all values.


Index: include/plugin-api.h
===
RCS file: /cvs/src/src/include/plugin-api.h,v
retrieving revision 1.20
diff -u -p -r1.20 plugin-api.h
--- include/plugin-api.h 24 Aug 2012 18:35:35 - 1.20
+++ include/plugin-api.h 11 Feb 2013 18:51:18 -
@@ -358,33 +358,33 @@ enum ld_plugin_level
 enum ld_plugin_tag
 {
   LDPT_NULL = 0,
-  LDPT_API_VERSION,
-  LDPT_GOLD_VERSION,
-  LDPT_LINKER_OUTPUT,
-  LDPT_OPTION,
-  LDPT_REGISTER_CLAIM_FILE_HOOK,
-  LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK,
-  LDPT_REGISTER_CLEANUP_HOOK,
-  LDPT_ADD_SYMBOLS,
-  LDPT_GET_SYMBOLS,
-  LDPT_ADD_INPUT_FILE,
-  LDPT_MESSAGE,
-  LDPT_GET_INPUT_FILE,
-  LDPT_RELEASE_INPUT_FILE,
-  LDPT_ADD_INPUT_LIBRARY,
-  LDPT_OUTPUT_NAME,
-  LDPT_SET_EXTRA_LIBRARY_PATH,
-  LDPT_GNU_LD_VERSION,
-  LDPT_GET_VIEW,
-  LDPT_GET_INPUT_SECTION_COUNT,
-  LDPT_GET_INPUT_SECTION_TYPE,
-  LDPT_GET_INPUT_SECTION_NAME,
-  LDPT_GET_INPUT_SECTION_CONTENTS,
-  LDPT_UPDATE_SECTION_ORDER,
-  LDPT_ALLOW_SECTION_ORDERING,
-  LDPT_GET_SYMBOLS_V2,
-  LDPT_ALLOW_UNIQUE_SEGMENT_FOR_SECTIONS,
-  LDPT_UNIQUE_SEGMENT_FOR_SECTIONS
+  LDPT_API_VERSION = 1,
+  LDPT_GOLD_VERSION = 2,
+  LDPT_LINKER_OUTPUT = 3,
+  LDPT_OPTION = 4,
+  LDPT_REGISTER_CLAIM_FILE_HOOK = 5,
+  LDPT_REGISTER_ALL_SYMBOLS_READ_HOOK = 6,
+  LDPT_REGISTER_CLEANUP_HOOK = 7,
+  LDPT_ADD_SYMBOLS = 8,
+  LDPT_GET_SYMBOLS = 9,
+  LDPT_ADD_INPUT_FILE = 10,
+  LDPT_MESSAGE = 11,
+  LDPT_GET_INPUT_FILE = 12,
+  LDPT_RELEASE_INPUT_FILE = 13,
+  LDPT_ADD_INPUT_LIBRARY = 14,
+  LDPT_OUTPUT_NAME = 15,
+  LDPT_SET_EXTRA_LIBRARY_PATH = 16,
+  LDPT_GNU_LD_VERSION = 17,
+  LDPT_GET_VIEW = 18,
+  LDPT_GET_INPUT_SECTION_COUNT = 19,
+  LDPT_GET_INPUT_SECTION_TYPE = 20,
+  LDPT_GET_INPUT_SECTION_NAME = 21,
+  LDPT_GET_INPUT_SECTION_CONTENTS = 22,
+  LDPT_UPDATE_SECTION_ORDER = 23,
+  LDPT_ALLOW_SECTION_ORDERING = 24,
+  LDPT_GET_SYMBOLS_V2 = 25,
+  LDPT_ALLOW_UNIQUE_SEGMENT_FOR_SECTIONS = 26,
+  LDPT_UNIQUE_SEGMENT_FOR_SECTIONS = 27
 };

 /* The plugin transfer vector.  */

Thanks
Sri


[PATCH] Don't expand MEM1 op= MEM2 as temp = MEM1; temp op= MEM2; MEM1 = temp just because we couldn't add REG_EQUIV note (PR rtl-optimization/56151)

2013-02-11 Thread Jakub Jelinek
Hi!

As discussed in this PR, MEM1 op= MEM2 is usually better expanded
as temp = MEM2; MEM1 op= temp; if target supports that, even when it
means we can't add a REG_EQUIV note in that case (it would be
self-referential).

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok
for trunk?

2013-02-11  Jakub Jelinek  ja...@redhat.com
Steven Bosscher   ste...@gcc.gnu.org

PR rtl-optimization/56151
* optabs.c (add_equal_note): Don't return 0 if target is a MEM,
equal to op0 or op1, and last_insn pattern is CODE operation
with MEM dest and one of the operands matches that MEM.

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

--- gcc/optabs.c.jj 2013-01-16 08:30:10.0 +0100
+++ gcc/optabs.c2013-02-11 15:28:16.543839881 +0100
@@ -190,17 +190,34 @@ add_equal_note (rtx insns, rtx target, e
   if (GET_CODE (target) == ZERO_EXTRACT)
 return 1;
 
-  /* If TARGET is in OP0 or OP1, punt.  We'd end up with a note referencing
- a value changing in the insn, so the note would be invalid for CSE.  */
-  if (reg_overlap_mentioned_p (target, op0)
-  || (op1  reg_overlap_mentioned_p (target, op1)))
-return 0;
-
   for (last_insn = insns;
NEXT_INSN (last_insn) != NULL_RTX;
last_insn = NEXT_INSN (last_insn))
 ;
 
+  /* If TARGET is in OP0 or OP1, punt.  We'd end up with a note referencing
+ a value changing in the insn, so the note would be invalid for CSE.  */
+  if (reg_overlap_mentioned_p (target, op0)
+  || (op1  reg_overlap_mentioned_p (target, op1)))
+{
+  if (MEM_P (target)
+  (rtx_equal_p (target, op0)
+ || (op1  rtx_equal_p (target, op1
+   {
+ /* For MEM target, with MEM = MEM op X, prefer no REG_EQUAL note
+over expanding it as temp = MEM op X, MEM = temp.  See PR56151. */
+ set = single_set (last_insn);
+ if (set
+  GET_CODE (SET_SRC (set)) == code
+  MEM_P (SET_DEST (set))
+  (rtx_equal_p (SET_DEST (set), XEXP (SET_SRC (set), 0))
+ || (op1  rtx_equal_p (SET_DEST (set),
+ XEXP (SET_SRC (set), 1)
+   return 1;
+   }
+  return 0;
+}
+
   set = single_set (last_insn);
   if (set == NULL_RTX)
 return 1;
--- gcc/testsuite/gcc.target/i386/pr56151.c.jj  2013-02-11 16:20:51.459752951 
+0100
+++ gcc/testsuite/gcc.target/i386/pr56151.c 2013-02-11 16:23:10.590964710 
+0100
@@ -0,0 +1,17 @@
+/* PR rtl-optimization/56151 */
+/* { dg-do compile } */
+/* { dg-options -O2 } */
+
+int vara, varb;
+
+void
+foo (int i, int j)
+{
+  vara = varb | vara;
+}
+
+/* Verify the above is compiled into movl varb, %reg; orl %reg, vara instead
+   of longer movl vara, %reg; orl varb, %reg; movl %reg, vara.  */
+/* { dg-final { scan-assembler-not mov\[^\n\r]*vara { target nonpic } } } */
+/* { dg-final { scan-assembler-times mov\[^\n\r]*varb 1 { target nonpic } } 
} */
+/* { dg-final { scan-assembler-times or\[^\n\r]*vara 1 { target nonpic } } } 
*/

Jakub


Re: [PATCH] Don't expand MEM1 op= MEM2 as temp = MEM1; temp op= MEM2; MEM1 = temp just because we couldn't add REG_EQUIV note (PR rtl-optimization/56151)

2013-02-11 Thread Jeff Law

On 02/11/13 12:49, Jakub Jelinek wrote:

Hi!

As discussed in this PR, MEM1 op= MEM2 is usually better expanded
as temp = MEM2; MEM1 op= temp; if target supports that, even when it
means we can't add a REG_EQUIV note in that case (it would be
self-referential).

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok
for trunk?

2013-02-11  Jakub Jelinek  ja...@redhat.com
Steven Bosscher   ste...@gcc.gnu.org

PR rtl-optimization/56151
* optabs.c (add_equal_note): Don't return 0 if target is a MEM,
equal to op0 or op1, and last_insn pattern is CODE operation
with MEM dest and one of the operands matches that MEM.

* gcc.target/i386/pr56151.c: New test.
Note that expanding as MEM op= X puts the decision about whether or not 
to use a temporary entirely into the backend, where it can be split via 
a define_insn_and_split.  I'm generally OK with that.


However, it is worth noting this can inhibit CSE if the MEM was already 
available in a pseudo.  I don't think this is serious enough to warrant 
rejecting this change.  If it turns out to be a problem we'll need to do 
more tuning.



+   {
+ /* For MEM target, with MEM = MEM op X, prefer no REG_EQUAL note
+over expanding it as temp = MEM op X, MEM = temp.  See PR56151. */
I'd suggest adding a comment here about the details of 56151 rather than 
referencing the BZ database.  Ideally we want a developer to be able to 
read the code and understand why it works the way it does.  Now the 
developer has to go find the bug in the database and read that too.


I'd also suggest a quick note that this style of code generation can 
inhibit CSE in some cases.


With those two comment changes, approved.

jeff



Re: [PATCH, libstdc++] Fix 22_locale/time_get/get_weekday/char/38081-[12].cc tests for glibc 2.17

2013-02-11 Thread Jonathan Wakely
On 11 February 2013 19:15, Jonathan Wakely wrote:
 On 11 February 2013 17:18, Paolo Carlini wrote:

 I think it's Ok, yes. Thanks. However, I would appreciate if somebody with a
 glibc 2.17 system at hand could double check. Maybe HJ?

 Although I'm sure Carlos is right that they're close enough to not
 need checking, I've got a Rawhide setup with glibc 2.17 so I can test
 it, just to be sure.

Julian's patch does indeed fix the test failures on glibc 2.17, so is
OK to commit.  Thanks!


Re: unordered containers doc

2013-02-11 Thread François Dumont
That's crystal clear. I think I can recognize one or two words from my 
original proposal like 'The' or 'in' :-)


François


On 02/11/2013 01:24 AM, Jonathan Wakely wrote:

On 7 February 2013 21:01, François Dumont wrote:

Thanks for taking care of it. Here is another version, I think clearer.
Reading the doc I also found an unfinished sentence in an other chapter, it
is in the patch.

I made quite a few changes, partly to address the is_copy_assignable
check I added for PR 56267, the change I committed is attached.
Please let me know if you think it's wrong or unclear.

2013-02-10  François Dumont  fdum...@gcc.gnu.org
 Jonathan Wakely  jwakely@gmail.com

 * doc/xml/manual/containers.xml: Add section on unordered containers.
 * doc/xml/manual/using.xml: Fix incomplete sentence.

Tested with doc-xml-validate-docbook and doc-html-docbook, committed to trunk.




Re: [PATCH] Disable libsanitizer before darwin10

2013-02-11 Thread Mike Stump
On Feb 11, 2013, at 7:55 AM, Jack Howarth howa...@bromo.med.uc.edu wrote:
  Iain Sandoe discovered that on intel darwin9, the asan testsuite suffers 
 hundreds of 
 failures due to the absence of dispatch calls (Grand Central Dispatch) prior 
 to darwin10.
 The attached patch disables building libsanitizer on darwin8 and darwin9 
 until upstream
 decides to support the earlier darwin releases. Bootstrap and regression 
 tested on
 x86_64-apple-darwin12. Okay for gcc trunk?

Ok.

Committed revision 195958.

If the patch needs to go upstream, could the asan people push it up?  Thanks.


I like fixing asan so that it works on darwin9.  If/when that is done, we can 
remove this patch; until such time, the patch is necessary.


Re: RFA: v3 PATCH to add on_quick_exit/quick_exit to std

2013-02-11 Thread Paolo Carlini

... this is what I committed.

Thanks,
Paolo.

/
2013-02-11  Paolo Carlini  paolo.carl...@oracle.com

* include/c_std/cstdlib (at_quick_exit, quick_exit): Do not declare.
* include/c_global/cstdlib (at_quick_exit, quick_exit): Declare only
in C++11 mode and if available in the underlying C library.
* testsuite/18_support/quick_exit/quick_exit.cc: Compile with
-std=gnu++11; check _GLIBCXX_HAVE_AT_QUICK_EXIT and
_GLIBCXX_HAVE_QUICK_EXIT.
Index: include/c_global/cstdlib
===
--- include/c_global/cstdlib(revision 195952)
+++ include/c_global/cstdlib(working copy)
@@ -57,8 +57,14 @@
   extern C void abort(void) throw () _GLIBCXX_NORETURN;
   extern C int atexit(void (*)()) throw ();
   extern C void exit(int) throw () _GLIBCXX_NORETURN;
+#if __cplusplus = 201103L
+# ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT
   extern C int at_quick_exit(void (*)()) throw ();
+# endif
+# ifdef _GLIBCXX_HAVE_QUICK_EXIT
   extern C void quick_exit(int) throw() _GLIBCXX_NORETURN;
+# endif
+#endif
 } // namespace std
 
 #else
@@ -69,7 +75,11 @@
 #undef abort
 #undef abs
 #undef atexit
-#undef at_quick_exit
+#if __cplusplus = 201103L
+# ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT
+#  undef at_quick_exit
+# endif
+#endif
 #undef atof
 #undef atoi
 #undef atol
@@ -86,7 +96,11 @@
 #undef mbstowcs
 #undef mbtowc
 #undef qsort
-#undef quick_exit
+#if __cplusplus = 201103L
+# ifdef _GLIBCXX_HAVE_QUICK_EXIT
+#  undef quick_exit
+# endif
+#endif
 #undef rand
 #undef realloc
 #undef srand
@@ -107,8 +121,10 @@
   using ::abort;
   using ::abs;
   using ::atexit;
-#ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT
+#if __cplusplus = 201103L
+# ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT
   using ::at_quick_exit;
+# endif
 #endif
   using ::atof;
   using ::atoi;
@@ -128,8 +144,10 @@
   using ::mbtowc;
 #endif // _GLIBCXX_HAVE_MBSTATE_T
   using ::qsort;
-#ifdef _GLIBCXX_HAVE_QUICK_EXIT
+#if __cplusplus = 201103L
+# ifdef _GLIBCXX_HAVE_QUICK_EXIT
   using ::quick_exit;
+# endif
 #endif
   using ::rand;
   using ::realloc;
Index: include/c_std/cstdlib
===
--- include/c_std/cstdlib   (revision 195952)
+++ include/c_std/cstdlib   (working copy)
@@ -57,8 +57,6 @@
   extern C void abort(void) throw () _GLIBCXX_NORETURN;
   extern C int atexit(void (*)()) throw ();
   extern C void exit(int) throw () _GLIBCXX_NORETURN;
-  extern C int at_quick_exit(void (*)()) throw ();
-  extern C void quick_exit(int) throw() _GLIBCXX_NORETURN;
 } // namespace
 
 #else
@@ -69,7 +67,6 @@
 #undef abort
 #undef abs
 #undef atexit
-#undef at_quick_exit
 #undef atof
 #undef atoi
 #undef atol
@@ -86,7 +83,6 @@
 #undef mbstowcs
 #undef mbtowc
 #undef qsort
-#undef quick_exit
 #undef rand
 #undef realloc
 #undef srand
@@ -107,9 +103,6 @@
   using ::abort;
   using ::abs;
   using ::atexit;
-#ifdef _GLIBCXX_HAVE_AT_QUICK_EXIT
-  using ::at_quick_exit;
-#endif
   using ::atof;
   using ::atoi;
   using ::atol;
@@ -128,9 +121,6 @@
   using ::mbtowc;
 #endif // _GLIBCXX_HAVE_MBSTATE_T
   using ::qsort;
-#ifdef _GLIBCXX_HAVE_QUICK_EXIT
-  using ::quick_exit;
-#endif
   using ::rand;
   using ::realloc;
   using ::srand;
Index: testsuite/18_support/quick_exit/quick_exit.cc
===
--- testsuite/18_support/quick_exit/quick_exit.cc   (revision 195952)
+++ testsuite/18_support/quick_exit/quick_exit.cc   (working copy)
@@ -1,5 +1,7 @@
-// 2013-02-11 Jason Merrill
-
+// { dg-options -std=gnu++11 }
+//
+// 2013-02-11  Jason  Merrill
+//
 // Copyright (C) 2013 Free Software Foundation, Inc.
 //
 // This file is part of the GNU ISO C++ Library.  This library is free
@@ -33,7 +35,9 @@
 
 int main()
 {
+#if defined(_GLIBCXX_HAVE_AT_QUICK_EXIT)  defined(_GLIBCXX_HAVE_QUICK_EXIT)
   std::at_quick_exit (handler);
   std::atexit (wrong_handler);
   std::quick_exit (1);
+#endif
 }


PR target/52555: attribute optimize is overriding command line options

2013-02-11 Thread Aldy Hernandez
The problem here is that -ffast-math is overridden when switching 
optimization options on a per function basis with 
__attribute__((optimize(O))).


The x86 ceilf* instructions depend on unsafe math optimizations, but the 
optabs are created at the beginning of the compilation.  When fast math 
becomes unavailable, the target can no longer find the instructions.


Fixed by recalculating the optabs when creating new optimization nodes, 
and switching to these (if appropriate) at cfun switching time.


How does this look?

Jakub, what's this you mention in the PR about caching 
__optimize__((3))?  You also mention I shouldn't compare against 
this_target_optabs, but default_target_optabs.  But what if 
this_target_optabs has changed?  (See patch).


Tested on x86-64 Linux.  It would be nice if someone with access to a 
SWITCHABLE_TARGET platform (mips) could also test this.
commit fcac0360de909e6d96fe005a3012139d487d2db8
Author: Aldy Hernandez al...@redhat.com
Date:   Mon Feb 11 15:51:24 2013 -0600

PR target/52555
* tree.h (struct tree_optimization_option): New field
target_optabs.
(TREE_OPTIMIZATION_OPTABS): New.
(save_optabs_if_changed): Protoize.
* optabs.h: Always declare this_target_optabs.
* optabs.c (save_optabs_if_changed): New.
Always declare this_target_optabs.
* function.c (invoke_set_current_function_hook): Set
this_target_optabs if there is one in the optimization node.
c-family/
* c-common.c (handle_optimize_attribute): Call
save_optabs_if_changed.

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 1e6afaa..3711e69 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -8925,6 +8925,8 @@ handle_optimize_attribute (tree *node, tree name, tree 
args,
   DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node)
= build_optimization_node ();
 
+  save_optabs_if_changed (DECL_FUNCTION_SPECIFIC_OPTIMIZATION (*node));
+
   /* Restore current options.  */
   cl_optimization_restore (global_options, cur_opts);
 }
diff --git a/gcc/function.c b/gcc/function.c
index 4ce2259..f37e91f 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -4397,6 +4397,13 @@ invoke_set_current_function_hook (tree fndecl)
{
  optimization_current_node = opts;
  cl_optimization_restore (global_options, TREE_OPTIMIZATION (opts));
+
+ /* Change optabs if needed.  */
+ if (TREE_OPTIMIZATION_OPTABS (opts))
+   this_target_optabs
+ = (struct target_optabs *) TREE_OPTIMIZATION_OPTABS (opts);
+ else
+   this_target_optabs = default_target_optabs;
}
 
   targetm.set_current_function (fndecl);
diff --git a/gcc/optabs.c b/gcc/optabs.c
index 8a3d3a9..3ce1701 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -44,8 +44,8 @@ along with GCC; see the file COPYING3.  If not see
 
 struct target_optabs default_target_optabs;
 struct target_libfuncs default_target_libfuncs;
-#if SWITCHABLE_TARGET
 struct target_optabs *this_target_optabs = default_target_optabs;
+#if SWITCHABLE_TARGET
 struct target_libfuncs *this_target_libfuncs = default_target_libfuncs;
 #endif
 
@@ -6184,6 +6184,41 @@ init_optabs (void)
   targetm.init_libfuncs ();
 }
 
+/* Recompute the optabs.  If they have changed, save the new set of
+   optabs in the optimization node OPTNODE.  */
+
+void
+save_optabs_if_changed (tree optnode)
+{
+  struct target_optabs *save_target_optabs = this_target_optabs;
+  struct target_optabs *tmp_target_optabs = XNEW (struct target_optabs);
+
+  /* Generate a new set of optabs into tmp_target_optabs.  */
+  memset (tmp_target_optabs, 0, sizeof (struct target_optabs));
+  this_target_optabs = tmp_target_optabs;
+  init_all_optabs ();
+  this_target_optabs = save_target_optabs;
+
+  /* If the optabs changed, record it in the node.  */
+  if (memcmp (tmp_target_optabs, this_target_optabs,
+ sizeof (struct target_optabs)))
+{
+  /* ?? An existing entry in TREE_OPTIMIZATION_OPTABS indicates
+multiple ((optimize)) attributes for the same function.  Is
+this even valid?  For now, just clobber the existing entry
+with the new optabs.  */
+  if (TREE_OPTIMIZATION_OPTABS (optnode))
+   free (TREE_OPTIMIZATION_OPTABS (optnode));
+
+  TREE_OPTIMIZATION_OPTABS (optnode) = tmp_target_optabs;
+}
+  else
+{
+  TREE_OPTIMIZATION_OPTABS (optnode) = NULL;
+  free (tmp_target_optabs);
+}
+}
+
 /* A helper function for init_sync_libfuncs.  Using the basename BASE,
install libfuncs into TAB for BASE_N for 1 = N = MAX.  */
 
diff --git a/gcc/optabs.h b/gcc/optabs.h
index c08adcf..2e8b6ec 100644
--- a/gcc/optabs.h
+++ b/gcc/optabs.h
@@ -76,11 +76,7 @@ struct target_optabs {
 };
 
 extern struct target_optabs default_target_optabs;
-#if SWITCHABLE_TARGET
 extern struct target_optabs *this_target_optabs;
-#else
-#define this_target_optabs 

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

2013-02-11 Thread Benjamin De Kosnik

  Since commit r195676[1], it looks like
  libstdc++-v3/src/c++11/hashtable_c++0x.cc is missing an explicit
  instantiation for std::lower_bound. 
   
it's missing an implicit instantiation of std::lower_bound.

This leads to libstdc++.so
  having the symbol for that (missing) instantiation be undefined,
  thus preventing executables from being linked with libstdc++.
  Note that I can confirm this only if I build with less optimization
  than the default -O2, say -O. That may explain why nobody noticed
  earlier.

Yes, indeed.

Certainly, the explicit instantiation is ok for this non-usual -O
compile. The full instantiation set depends on specific flag and
perhaps platform. Let's not special case all of these, and instead just
allow implicit template instantiations via -fimplicit-templates. 

Thus, what is really needed (and also in cases like PR52887)
is to just allow implicit template instantiations. Done as attached.

-benjamin

tested x86/linux
tested x86/linux -O0
tested x86/linux -O2013-02-11  Benjamin Kosnik  b...@redhat.com

	* src/c++11/Makefile.am (hashtable_c++0x.lo, hashtable_c++0x.o):
	Use -fimplicit-templates.
	* src/c++11/Makefile.in: Regenerate.
	* src/c++11/hashtable_c++0x.cc: Remove instantiation for
	std::lower_bound template.


diff --git a/libstdc++-v3/src/c++11/Makefile.am b/libstdc++-v3/src/c++11/Makefile.am
index 89ee335..e7b48ac 100644
--- a/libstdc++-v3/src/c++11/Makefile.am
+++ b/libstdc++-v3/src/c++11/Makefile.am
@@ -60,6 +60,13 @@ vpath % $(top_srcdir)/src/c++11
 
 libc__11convenience_la_SOURCES = $(sources)  $(inst_sources)
 
+# Use special rules for the hashtable.cc file so that all
+# the generated template functions are also instantiated. 
+hashtable_c++0x.lo: hashtable_c++0x.cc
+	$(LTCXXCOMPILE) -fimplicit-templates -c $
+hashtable_c++0x.o: hashtable_c++0x.cc
+	$(CXXCOMPILE) -fimplicit-templates -c $
+
 # AM_CXXFLAGS needs to be in each subdirectory so that it can be
 # modified in a per-library or per-sub-library way.  Need to manually
 # set this option because CONFIG_CXXFLAGS has to be after
diff --git a/libstdc++-v3/src/c++11/hashtable_c++0x.cc b/libstdc++-v3/src/c++11/hashtable_c++0x.cc
index b6a56bc..7617c58 100644
--- a/libstdc++-v3/src/c++11/hashtable_c++0x.cc
+++ b/libstdc++-v3/src/c++11/hashtable_c++0x.cc
@@ -94,11 +94,4 @@ namespace __detail
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace __detail
-
- // Instantiations.
- template
- const unsigned long*
- lower_boundconst unsigned long*, size_t(const unsigned long*,
-	   const unsigned long*,
-	   const size_t);
 } // namespace std


[PATCH] GCC 4.9 powerpc, fix insn type attribute for load/store insns

2013-02-11 Thread Pat Haugen
The following patch fixes the assignment of the insn type attribute 
for loads and stores. Specifically, it will now appropriately assign 
update form and update-indexed form type attributes which allows for 
better instruction scheduling by honoring group formation restrictions 
and (to a lesser extent) insn latency for the updated address reg. The 
patch is based on Mike Meissner's prior 4.9 submissions for move pattern 
combinations.


Bootstrap/regtest on powerpc64-linux with no new regressions. Ok for 4.9 
when it opens up?



2013-02-12  Pat Haugen pthau...@us.ibm.com
* config/rs6000/predicates.md (indexed_address, update_address_mem
update_indexed_address_mem): New predicates.
* config/rs6000/vsx.md (vsx_extract_mode_zero): Set correct 
type

attribute for load/store instructions.
* config/rs6000/dfp.md (movsd_store): Likewise.
(movsd_load): Likewise.
* config/rs6000/rs6000.md (zero_extendmodedi2_internal1): 
Likewise.

(unnamed HI-DI extend define_insn): Likewise.
(unnamed SI-DI extend define_insn): Likewise.
(unnamed QI-SI extend define_insn): Likewise.
(unnamed QI-HI extend define_insn): Likewise.
(unnamed HI-SI extend define_insn): Likewise.
(unnamed HI-SI extend define_insn): Likewise.
(extendsfdf2_fpr): Likewise.
(movsi_internal1): Likewise.
(movsi_internal1_single): Likewise.
(movhi_internal): Likewise.
(movqi_internal): Likewise.
(movcc_internal1): Correct mnemonic for stw insn. Set correct 
type

attribute for load/store instructions.
(movmode_hardfloat): Set correct type attribute for load/store
instructions.
(movmode_softfloat): Likewise.
(movmode_hardfloat32): Likewise.
(movmode_hardfloat64): Likewise.
(movmode_softfloat64): Likewise.
(movdi_internal32): Likewise.
(movdi_internal64): Likewise.
(probe_stack_mode): Likewise.

Index: gcc/config/rs6000/predicates.md
===
--- gcc/config/rs6000/predicates.md (revision 195896)
+++ gcc/config/rs6000/predicates.md (working copy)
@@ -557,6 +557,28 @@ (define_special_predicate indexed_or_in
 REG_P (XEXP (op, 1
(match_operand 0 address_operand)))
 
+;; Return 1 if the operand is an index-form address.
+(define_special_predicate indexed_address
+  (match_test (GET_CODE (op) == PLUS
+REG_P (XEXP (op, 0))
+REG_P (XEXP (op, 1)
+
+;; Return 1 if the operand is a MEM with an update-form address. This may
+;; also include update-indexed form.
+(define_special_predicate update_address_mem
+  (match_test (MEM_P (op)
+(GET_CODE (XEXP (op, 0)) == PRE_INC
+   || GET_CODE (XEXP (op, 0)) == PRE_DEC
+   || GET_CODE (XEXP (op, 0)) == PRE_MODIFY
+
+;; Return 1 if the operand is a MEM with an update-indexed-form address. Note
+;; that PRE_INC/PRE_DEC will always be non-indexed (i.e. non X-form) since the
+;; increment is based on the mode size and will therefor always be a const.
+(define_special_predicate update_indexed_address_mem
+  (match_test (MEM_P (op)
+GET_CODE (XEXP (op, 0)) == PRE_MODIFY
+indexed_address (XEXP (XEXP (op, 0), 1), mode
+
 ;; Used for the destination of the fix_truncdfsi2 expander.
 ;; If stfiwx will be used, the result goes to memory; otherwise,
 ;; we're going to emit a store and a load of a subreg, so the dest is a
Index: gcc/config/rs6000/vsx.md
===
--- gcc/config/rs6000/vsx.md(revision 195896)
+++ gcc/config/rs6000/vsx.md(working copy)
@@ -1217,7 +1217,11 @@ (define_insn *vsx_extract_mode_zero
 (parallel [(const_int 0)])))]
   VECTOR_MEM_VSX_P (MODEmode)  WORDS_BIG_ENDIAN
   lxsd%U1x %x0,%y1
-  [(set_attr type fpload)
+  [(set (attr type)
+  (if_then_else
+   (match_test update_indexed_address_mem (operands[1], VOIDmode))
+   (const_string fpload_ux)
+   (const_string fpload)))
(set_attr length 4)])  
 
 ;; Extract a SF element from V4SF
Index: gcc/config/rs6000/dfp.md
===
--- gcc/config/rs6000/dfp.md(revision 195896)
+++ gcc/config/rs6000/dfp.md(working copy)
@@ -37,7 +37,14 @@ (define_insn movsd_store
|| gpc_reg_operand (operands[1], SDmode))
 TARGET_HARD_FLOAT  TARGET_FPRS
   stfd%U0%X0 %1,%0
-  [(set_attr type fpstore)
+  [(set (attr type)
+  (if_then_else
+   (match_test update_indexed_address_mem (operands[0], VOIDmode))
+   (const_string fpstore_ux)
+   (if_then_else
+ (match_test update_address_mem (operands[0], VOIDmode))
+ (const_string fpstore_u)
+ (const_string fpstore
(set_attr length 4)])
 
 (define_insn movsd_load
@@ -48,7 +55,14 @@ (define_insn 

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

2013-02-11 Thread Jason Merrill

OK, thanks.

Jason


Re: [PATCH] Disable libsanitizer before darwin10

2013-02-11 Thread Dmitry Vyukov
On Tue, Feb 12, 2013 at 3:16 AM, Mike Stump mikest...@comcast.net wrote:
 On Feb 11, 2013, at 7:55 AM, Jack Howarth howa...@bromo.med.uc.edu wrote:
  Iain Sandoe discovered that on intel darwin9, the asan testsuite suffers 
 hundreds of
 failures due to the absence of dispatch calls (Grand Central Dispatch) prior 
 to darwin10.
 The attached patch disables building libsanitizer on darwin8 and darwin9 
 until upstream
 decides to support the earlier darwin releases. Bootstrap and regression 
 tested on
 x86_64-apple-darwin12. Okay for gcc trunk?

 Ok.

 Committed revision 195958.

 If the patch needs to go upstream, could the asan people push it up?  Thanks.


 I like fixing asan so that it works on darwin9.  If/when that is done, we can 
 remove this patch; until such time, the patch is necessary.

LLVM uses different build system, so this patch can't be applied
directly. But future integrations won't break gcc.
Alexander, do we want to apply something similar upstream?