[PATCH] fix PR sanitizer/55617

2013-02-02 Thread Jack Howarth
   Currently darwin is unable to utilize libasan with constructors due to the 
lack of
constructor priority support on that target. The asan_finish_file routine 
inserts an
essential __asan_init into the array of constructors (via the __mod_init_func 
section).
However the insertion occurs at the end, and due to the lack of priority 
support for
constructors, these are executed from the start of the array of constructors on 
program
startup. This causes code any instrumented code that executes before the 
__asan_init
call to crash. 
   Since darwin sets...

#undef SUPPORTS_INIT_PRIORITY
#define SUPPORTS_INIT_PRIORITY 0

in gcc/config/darwin.h, all constructors are automatically set to 

#define DEFAULT_INIT_PRIORITY 65535

in gcc/collect2.c. Any code that attempts to set the constructor/destructor 
priority
on darwin results in a compile time error of "constructor priorities are not 
supported".
So asan alone should be unique in emitting priorities different from 65535 on 
darwin.
The attached patch uses a va_gc vector of constructor symbol/priority records 
to queue
this data as it is generated in calls to machopic_asm_out_constructor. Any 
instances of
the static constructor with priority 99 emitted by asan are inserted safely in 
the front
of the vector queue which retains the original order of the remaining 
constructors in
the queue. The contents of the vector queue are later processed in a new 
finalize_ctors
routine called from darwin_file_end if necessary. The patch also adds a 
g++.dg/asan/pr55617.C
test case which is targeted to i?86-*-darwin* and x86_64-*-darwin*.
The patch reduces the failures observed when running

make -k check-g++ RUNTESTFLAGS="--target_board=unix'{-fsanitize=address}'"

from 323 to only 85 on darwin (similar to the results on linux). The cov.C 
testcase also
fails on gcc trunk with -fsanitize=address when recrafted into a dynamic shared 
library
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55617#c28. This patch eliminates 
those
crashes. This problem doesn't extend to when the shared library or module is 
dlopen'd
(which works in stock gcc trunk and with this patch as well).
The patch has been bootstrap and regression tested on x86_64-apple-darwin12.
Okay for gcc trunk?
 Jack
ps Unfortunately the flag_sort variable is unavailable inside of 
machopic_asm_out_constructor 
so we have to unconditionally test for priority == 99.

/gcc

2013-02-03  Alexander Potapenko 
Jack Howarth  

PR sanitizer/55617
* config/darwin.c (machopic_asm_out_constructor): Use vector to
queue constructors while inserting asan static constructors at front.
(finalize_ctors): New routine to output queued constructors.
(darwin_file_end): Use finalize_ctors.

/gcc/testsuite

2013-02-03  Alexander Potapenko 
Jack Howarth  

PR sanitizer/55617
* g++.dg/asan/pr55617.C: New test.


Index: gcc/config/darwin.c
===
--- gcc/config/darwin.c (revision 195686)
+++ gcc/config/darwin.c (working copy)
@@ -83,6 +83,13 @@ along with GCC; see the file COPYING3.  
kernel) the stubs might still be required, and this will be set true.  */
 int darwin_emit_branch_islands = false;
 
+typedef struct GTY(()) ctor_record {
+  rtx symbol;
+  int priority;/* constructor priority */
+} ctor_record;
+
+static GTY(()) vec *ctors = NULL;
+
 /* A flag to determine whether we are running c++ or obj-c++.  This has to be
settable from non-c-family contexts too (i.e. we can't use the c_dialect_
functions).  */
@@ -1708,15 +1715,32 @@ machopic_select_rtx_section (enum machin
 void
 machopic_asm_out_constructor (rtx symbol, int priority ATTRIBUTE_UNUSED)
 {
+  ctor_record new_elt = {symbol, priority};
+  if (priority == 99)
+vec_safe_insert(ctors, 0, new_elt); 
+  else
+vec_safe_push (ctors, new_elt);
+
+  if (! MACHOPIC_INDIRECT)
+fprintf (asm_out_file, ".reference .constructors_used\n");
+}
+
+static void 
+finalize_ctors()
+{
+  unsigned int i;
+  ctor_record *elt;
+ 
   if (MACHOPIC_INDIRECT)
 switch_to_section (darwin_sections[mod_init_section]);
   else
 switch_to_section (darwin_sections[constructor_section]);
-  assemble_align (POINTER_SIZE);
-  assemble_integer (symbol, POINTER_SIZE / BITS_PER_UNIT, POINTER_SIZE, 1);
 
-  if (! MACHOPIC_INDIRECT)
-fprintf (asm_out_file, ".reference .constructors_used\n");
+  FOR_EACH_VEC_SAFE_ELT (ctors, i, elt)
+{
+  assemble_align (POINTER_SIZE);
+  assemble_integer (elt->symbol, POINTER_SIZE / BITS_PER_UNIT, 
POINTER_SIZE, 1);
+}
 }
 
 void
@@ -2762,6 +2786,8 @@ darwin_file_start (void)
 void
 darwin_file_end (void)
 {
+  if (!vec_safe_is_empty (ctors))
+finalize_ctors();
   machopic_finish (asm_out_file);
   if (strcmp (lang_hooks.name, "GNU C++") == 0)
 {
--- /dev/null   2013-02-02 10:53:51.0 -0500
+++ gcc/testsuite/g++.dg/asan/pr55617.C 2013-02-02 10:2

hasher speed traits

2013-02-02 Thread François Dumont

Hi

Here is the last patch I can think of for 4.8. Thanks to it default 
performance reported in performance/23_containers/insert/54075.cc and 
performance/23_containers/insert_erase/41975.cc are always the best:


54075.cc std::unordered_set without hash code cached 
30 insertion attempts, 30 inserted  10r8u 1s 
13761936mem0pf
54075.cc std::unordered_set without hash code cached 
10 times insertion of 30 elements  31r   31u 0s0mem0pf


54075.cc std::unordered_set with hash code cached 
30 insertion attempts, 30 inserted  10r9u 1s 
18562000mem0pf
54075.cc std::unordered_set with hash code cached 10 
times insertion of 30 elements  34r   35u 0s0mem0pf


54075.cc std::unordered_set default cache 30 
insertion attempts, 30 inserted   9r8u0s 13761936mem0pf
54075.cc std::unordered_set default cache 10 times 
insertion of 30 elements  31r   32u0s 0mem0pf



41975.cc std::unordered_set without hash 
code cached: first insert   9r9u0s 8450336mem0pf
41975.cc std::unordered_set without hash 
code cached: erase from iterator   6r5u0s -6400096mem0pf
41975.cc std::unordered_set without hash 
code cached: second insert   6r5u0s 640mem0pf
41975.cc std::unordered_set without hash 
code cached: erase from key   5r5u0s -640mem0pf


41975.cc std::unordered_set with hash code 
cached: first insert   5r5u1s  8450336mem 0pf
41975.cc std::unordered_set with hash code 
cached: erase from iterator   4r3u0s -6400096mem0pf
41975.cc std::unordered_set with hash code 
cached: second insert   3r3u0s  6400016mem 0pf
41975.cc std::unordered_set with hash code 
cached: erase from key   4r3u0s -6400016mem 0pf


41975.cc std::unordered_set default cache: 
first insert   5r5u1s  8450336mem0pf
41975.cc std::unordered_set default cache: 
erase from iterator   4r3u0s -6400096mem0pf
41975.cc std::unordered_set default cache: 
second insert   3r3u0s  640mem0pf
41975.cc std::unordered_set default cache: 
erase from key   4r3u0s -640mem 0pf


2013-02-02  François Dumont  

* include/bits/functional_hash.h (std::__is_fast_hash<>): New.
* include/bits/basic_string.h: Specialize previous to mark
std::hash for string types as slow.
* include/bits/hashtable.h (__cache_default): Replace is_integral
with __is_fast_hash.
* src/c++11/hash_c++0x.cc: Add type_traits include.

Tested under Linux x86_64.

Ok to commit ?

François
Index: include/bits/functional_hash.h
===
--- include/bits/functional_hash.h	(revision 195686)
+++ include/bits/functional_hash.h	(working copy)
@@ -195,6 +195,18 @@
 
   // @} group hashes
 
+  // Hint about performance of hash functor. If not fast the hash based
+  // containers will cache the hash code.
+  // Default behavior is to consider that hasher are fast unless specified
+  // otherwise.
+  template
+struct __is_fast_hash : public std::true_type
+{ };
+
+  template<>
+struct __is_fast_hash> : public std::false_type
+{ };
+
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace
 
Index: include/bits/basic_string.h
===
--- include/bits/basic_string.h	(revision 195686)
+++ include/bits/basic_string.h	(working copy)
@@ -3053,6 +3053,10 @@
   { return std::_Hash_impl::hash(__s.data(), __s.length()); }
 };
 
+  template<>
+struct __is_fast_hash> : std::false_type
+{ };
+
 #ifdef _GLIBCXX_USE_WCHAR_T
   /// std::hash specialization for wstring.
   template<>
@@ -3064,6 +3068,10 @@
   { return std::_Hash_impl::hash(__s.data(),
  __s.length() * sizeof(wchar_t)); }
 };
+
+  template<>
+struct __is_fast_hash> : std::false_type
+{ };
 #endif
 #endif /* _GLIBCXX_COMPATIBILITY_CXX0X */
 
@@ -3079,6 +3087,10 @@
  __s.length() * sizeof(char16_t)); }
 };
 
+  template<>
+struct __is_fast_hash> : std::false_type
+{ };
+
   /// std::hash specialization for u32string.
   template<>
 struct hash
@@ -3089,6 +3101,10 @@
   { return std::_Hash_impl::hash(__s.data(),
  __s.length() * sizeof(char32_t)); }
 };
+
+  template<>
+struct __is_fast_hash> : std::false_type
+{ };
 #endif
 
 _GLIBCXX_END_NAMESPACE_VERSION
Index: include/bits/hashtable.h

[RFA] Fix DEBUG_RELOAD support

2013-02-02 Thread Matthew Gretton-Dann
Hi,

Whilst debugging a reload issue I tried enabling DEBUG_RELOAD, only to
find that this caused GCC to fail to build.  I think this failure was
introduced during the change to vec being a C++ type, as DEBUG_RELOAD
is normally forced off.

The attached patch fixes the build issue.  Tested by building a cross
arm-none-linux-gnueabi compiler with DEBUG_RELOAD forced on.

OK for trunk?

gcc/ChangeLog:

2013-02-02  Matthew Gretton-Dann  

* gcc/reload.c (subst_reloads): Fix DEBUG_RELOAD build issue.


--
Matthew Gretton-Dann
Linaro Toolchain Working Group
matthew.gretton-d...@linaro.org
diff --git a/gcc/reload.c b/gcc/reload.c
index 889a6cc..2546c1b 100644
--- a/gcc/reload.c
+++ b/gcc/reload.c
@@ -6313,14 +6313,14 @@ subst_reloads (rtx insn)
  for (check_regno = 0; check_regno < max_regno; check_regno++)
{
 #define CHECK_MODF(ARRAY)  \
- gcc_assert (!reg_equivs[check_regno].ARRAY\
+ gcc_assert (!(*reg_equivs)[check_regno].ARRAY \
  || !loc_mentioned_in_p (r->where, \
- 
reg_equivs[check_regno).ARRAY)]
+ 
(*reg_equivs)[check_regno].ARRAY))
 
- CHECK_MODF (equiv_constant);
- CHECK_MODF (equiv_memory_loc);
- CHECK_MODF (equiv_address);
- CHECK_MODF (equiv_mem);
+ CHECK_MODF (constant);
+ CHECK_MODF (memory_loc);
+ CHECK_MODF (address);
+ CHECK_MODF (mem);
 #undef CHECK_MODF
}
 #endif /* DEBUG_RELOAD */


[patch] libffii, fix build for powerpc where DOUBLE equal LONGDOUBLE

2013-02-02 Thread Andreas Tobler
Hi,

I'm going to apply the patch below if there are no objections.

On PowerPC FreeBSD we have DOUBLE = LONGDOUBLE, so w/o the below the
compilation fails with a double 'case' entry.
Something went wrong with the latest upstream patch. And I didn't have a
chance to test earlier.

Ok?

TIA,
Andreas

2013-02-02  Andreas Tobler  

* src/powerpc/ffi.c (ffi_prep_cif_machdep): Fix case where
DOUBLE equal LONGDOUBLE.

Index: src/powerpc/ffi.c
===
--- src/powerpc/ffi.c   (revision 195611)
+++ src/powerpc/ffi.c   (working copy)
@@ -664,9 +664,11 @@
   switch (type)
 {
 #ifndef __NO_FPRS__
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
 case FFI_TYPE_LONGDOUBLE:
   flags |= FLAG_RETURNS_128BITS;
   /* Fall through.  */
+#endif
 case FFI_TYPE_DOUBLE:
   flags |= FLAG_RETURNS_64BITS;
   /* Fall through.  */


libgo patch committed: Only run syscall creds_test on GNU/Linux

2013-02-02 Thread Ian Lance Taylor
PR 56171 points out that the syscall/creds_test.go test fails on
Solaris.  In fact that test is only intended to be run on GNU/Linux
anyhow.  Solaris supports a similar mechanism, but it works differently.
This patch changes the libgo Makefile to let packages specify the list
of tests to run, and corrects the existing support in the gotest shell
script to use that list correctly.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

diff -r a20ef2465f30 libgo/Makefile.am
--- a/libgo/Makefile.am	Sat Feb 02 07:10:22 2013 -0800
+++ b/libgo/Makefile.am	Sat Feb 02 07:29:12 2013 -0800
@@ -1696,6 +1696,13 @@
 syscall_utimesnano_file = go/syscall/libcall_posix_utimesnano.go
 endif
 
+# Test files.
+if LIBGO_IS_LINUX
+syscall_creds_test_file = go/syscall/creds_test.go
+else
+syscall_creds_test_file =
+endif
+
 go_base_syscall_files = \
 	go/syscall/env_unix.go \
 	go/syscall/syscall_errno.go \
@@ -1734,6 +1741,10 @@
 	go/syscall/signame.c \
 	$(syscall_wait_c_file)
 
+go_syscall_test_files = \
+	$(syscall_creds_test_file) \
+	go/syscall/passfd_test.go
+
 libcalls.go: s-libcalls; @true
 s-libcalls: Makefile go/syscall/mksyscall.awk $(go_base_syscall_files)
 	rm -f libcalls.go.tmp
@@ -2005,9 +2016,9 @@
 	$(MKDIR_P) $(@D); \
 	rm -f $@-testsum $@-testlog; \
 	if test "$(use_dejagnu)" = "yes"; then \
-	  $(SHELL) $(srcdir)/testsuite/gotest --dejagnu=yes --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$(go_$(subst /,_,$(@D))_files)" --testname="$(@D)" --goarch="$(GOARCH)" $(GOTESTFLAGS); \
+	  $(SHELL) $(srcdir)/testsuite/gotest --dejagnu=yes --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$(go_$(subst /,_,$(@D))_files)" --testname="$(@D)" --goarch="$(GOARCH)" $(GOTESTFLAGS) $(go_$(subst /,_,$(@D))_test_files); \
 	else \
-	  if $(SHELL) $(srcdir)/testsuite/gotest --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$(go_$(subst /,_,$(@D))_files)" --goarch="$(GOARCH)" $(GOTESTFLAGS) >>$@-testlog 2>&1; then \
+	  if $(SHELL) $(srcdir)/testsuite/gotest --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$(go_$(subst /,_,$(@D))_files)" --goarch="$(GOARCH)" $(GOTESTFLAGS) $(go_$(subst /,_,$(@D))_test_files) >>$@-testlog 2>&1; then \
 	echo "PASS: $(@D)" >> $@-testlog; \
 	echo "PASS: $(@D)"; \
 	echo "PASS: $(@D)" > $@-testsum; \
diff -r a20ef2465f30 libgo/testsuite/gotest
--- a/libgo/testsuite/gotest	Sat Feb 02 07:10:22 2013 -0800
+++ b/libgo/testsuite/gotest	Sat Feb 02 07:29:12 2013 -0800
@@ -259,12 +259,20 @@
 case "x$gofiles" in
 x)
 	gofiles=`ls *_test.go 2>/dev/null`
+	;;
+*)
+	xgofiles=$gofiles
+	gofiles=
+	for f in $xgofiles; do
+	gofiles="$gofiles `basename $f`"
+	done
 esac
 
 case "x$gofiles" in
 x)
 	echo 'no test files found' 1>&2
 	exit 1
+	;;
 esac
 
 # Run any commands given in sources, like
@@ -295,6 +303,7 @@
 
 # Split $gofiles into external gofiles (those in *_test packages)
 # and internal ones (those in the main package).
+xgofiles=
 for f in $gofiles; do
 package=`grep '^package[ 	]' $f | sed 1q`
 case "$package" in


libgo patch committed: Correct runtime.Callers skip argument

2013-02-02 Thread Ian Lance Taylor
With the change to using the libbacktrace code, inlined functions now
picked up.  Previously the skip parameter to runtime.Callers was
adjusted based on inlining that was ignored.  This patch corrects it so
that the right thing happens.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

diff -r 13363f80cdf6 libgo/runtime/go-callers.c
--- a/libgo/runtime/go-callers.c	Thu Jan 31 21:48:23 2013 -0800
+++ b/libgo/runtime/go-callers.c	Sat Feb 02 07:09:40 2013 -0800
@@ -115,8 +115,9 @@
 
   /* In the Go 1 release runtime.Callers has an off-by-one error,
  which we can not correct because it would break backward
- compatibility.  Adjust SKIP here to be compatible.  */
-  ret = runtime_callers (skip - 1, locbuf, pc.__count);
+ compatibility.  Normally we would add 1 to SKIP here, but we
+ don't so that we are compatible.  */
+  ret = runtime_callers (skip, locbuf, pc.__count);
 
   for (i = 0; i < ret; i++)
 ((uintptr *) pc.__values)[i] = locbuf[i].pc;


Re: [PATCH 6/6] [AArch64-4.7] Backport: Fix warning in aarch64.md

2013-02-02 Thread Richard Earnshaw

On 01/02/13 17:42, James Greenhalgh wrote:


Hi,

This patch is a backport of one approved here:
http://gcc.gnu.org/ml/gcc-patches/2012-12/msg01135.html

The patch fixes the warning:

config/aarch64/aarch64.md:840: warning: source missing a mode?

Regression tested with no regressions on aarch64-none-elf.

OK for aarch64-4.7-branch?

Thanks,
James

---
gcc/

2013-02-01  James Greenhalgh  

Backport from mainline.
2012-12-18  James Greenhalgh  

* config/aarch64/aarch64.md (insv_imm): Add modes
for source operands.



OK.

R.




Re: [PATCH 5/6] [AArch64-4.7] Fix warning - Mixed code and declarations in aarch64_simd_const_bounds.

2013-02-02 Thread Richard Earnshaw

On 01/02/13 17:42, James Greenhalgh wrote:


Hi,

aarch64_simd_const_bounds declares `lane' after an assert. This
patch moves the declaration above the assert.

This patch fixes the warning:

config/aarch64/aarch64.c: In function ‘aarch64_simd_const_bounds’:
config/aarch64/aarch64.c:6412:3: warning: ISO C90 forbids mixed declarations 
and code [-pedantic]

Regression tested on aarch64-none-elf with no regressions.

OK for aarch64-4.7-branch?

Thanks,
James

---
gcc/

2013-02-01  James Greenhalgh  

* config/aarch64/aarch64.c
(aarch64_simd_const_bounds): Move declaration of 'lane' above code.


0005-AArch64-4.7-Fix-warning-Mixed-code-and-declarations-.patch


diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 434ccd7..a3c482b 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -6406,8 +6406,9 @@ aarch64_simd_lane_bounds (rtx operand, HOST_WIDE_INT low, 
HOST_WIDE_INT high)
  void
  aarch64_simd_const_bounds (rtx operand, HOST_WIDE_INT low, HOST_WIDE_INT high)
  {
+  HOST_WIDE_INT lane;
gcc_assert (GET_CODE (operand) == CONST_INT);


Blank line after declaration.

OK with that change.

R.




Re: [PATCH 4/6] [AArch64-4.7] Fix warning - aarch64_trampoline_init passes the wrong type to emit_library_call.

2013-02-02 Thread Richard Earnshaw

On 01/02/13 17:42, James Greenhalgh wrote:


Hi,

emit_library_call takes an `enum library_type` as its second argument.
Currently aarch64-4.7-branch passes it an int 0.

This patch fixes this, mirroring trunk, by passing LCT_NORMAL instead.

This patch fixes the warning:

config/aarch64/aarch64.c: In function ‘aarch64_trampoline_init’:
config/aarch64/aarch64.c:3893:8: warning: enum conversion when passing argument 
2 of ‘emit_library_call’ is invalid in C++ [-Wc++-compat]

Regression tested on aarch64-none-elf with no regressions.

OK for aarch64-4.7-branch?

Thanks,
James

---
gcc/

2013-02-01  James Greenhalgh  

* config/aarch64/aarch64.c
(aarch64_trampoline_init): Pass 'LCT_NORMAL' rather than '0'
to emit_library_call.



OK.

R.




Re: [PATCH 3/6] [AArch64-4.7] Fix warning - aarch64_legitimize_reload_address passes the wrong type to push_reload.

2013-02-02 Thread Richard Earnshaw

On 01/02/13 17:42, James Greenhalgh wrote:


Hi,

push_reload takes an `enum reload_type' as its final argument.

On trunk we just cast the int we have to the correct type,
so we do that here to mirror trunk and correct the warning.
We can't fix this by changing the type of the argument we take
as we would then need to forward declare the enum when giving
the prototype, which is illegal.

This fixes the warning:

config/aarch64/aarch64.c: In function ‘aarch64_legitimize_reload_address’:
config/aarch64/aarch64.c:3641:6: warning: enum conversion when passing argument 
11 of ‘push_reload’ is invalid in C++ [-Wc++-compat]

Regression tested aarch64-none-elf with no regressions.

OK for aarch64-4.7-branch?

Thanks,
James

---
gcc/

2013-02-01  James Greenhalgh  

* config/aarch64/aarch64.c
(aarch64_legitimize_reload_address): Cast 'type' before
passing to push_reload.




OK.

R.




Re: [PATCH 2/6] [AArch64-4.7] Fix warning - aarch64_add_constant mixed code and declarations.

2013-02-02 Thread Richard Earnshaw

On 01/02/13 17:42, James Greenhalgh wrote:


Hi,

In config/aarch64/aarch64.c::aarch64_add_constant `shift' was
declared after we started writing code. C90 doesn't like this,
so split the declaration and the assignment.

This fixes the warning:

config/aarch64/aarch64.c: In function ‘aarch64_add_constant’:
config/aarch64/aarch64.c:2249:4: warning: ISO C90 forbids mixed declarations 
and code [-pedantic]

Regression tested on aarch64-none-elf with no regressions.

OK for aarch64-4.7-branch?

Thanks,
James

---
gcc/

2013-02-01  James Greenhalgh  

* config/aarch64/aarch64.c
(aarch64_add_constant): Move declaration of 'shift' above code.


0002-AArch64-4.7-Fix-warning-aarch64_add_constant-mixed-c.patch


diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 59124eb..62d0a12 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -2307,8 +2307,9 @@ aarch64_add_constant (int regnum, int scratchreg, 
HOST_WIDE_INT delta)
  {
if (mdelta >= 4096)
{
+ rtx shift;
  emit_insn (gen_rtx_SET (Pmode, scratch_rtx, GEN_INT (mdelta / 4096)));


Blank line between declarations and code.

OK with that change.

R.




Re: [PATCH 1/6] [AArch64-4.7] Fix warning - Initialise generic_tunings.

2013-02-02 Thread Richard Earnshaw

On 01/02/13 17:42, James Greenhalgh wrote:


Hi,

This patch moves the various tuning parameter data structures
further up config/aarch64/aarch64.c and then uses them to
initialise the generic_tunings variable. This mirrors their
position on trunk.

This fixes the warning:

config/aarch64/aarch64.c:129:33: warning: uninitialised const ‘generic_tunings’ 
is invalid in C++ [-Wc++-compat]

Regression tested on aarch64-none-elf with no regressions.

OK for aarch64-4.7-branch?



OK.

R.




Re: [patch, fortran] Fix PR 50627

2013-02-02 Thread Thomas Koenig

Hi Paul,


OK for trunk.  The part in decl.c is exactly what I was thinking to do.

Thanks for the patch


Thanks a lot for your review!

Committed to trunk as rev. 195684, 4.7 and 4.6 to follow.

Thomas



[MIPS, committed] Include mips-sde-elf in vect_float

2013-02-02 Thread Richard Sandiford
I noticed while looking at some -mgp32 -mfp64 vect testsuite failures
on mips-sde-elf that we weren't running the more interesting tests.
Like mipsisa64-elf, hard-float mips-sde-elf ought to have full support
for paired single, and mips-sde-elf is the easiest way of testing
mismatched register sizes.

Tested on mips-sde-elf and applied.

Richard


gcc/testsuite/
* lib/target-supports.exp (check_effective_target_vect_float)
(check_effective_target_vect_no_align): Add mips-sde-elf.

Index: gcc/testsuite/lib/target-supports.exp
===
--- gcc/testsuite/lib/target-supports.exp   2013-01-23 11:56:58.0 
+
+++ gcc/testsuite/lib/target-supports.exp   2013-02-02 09:25:12.124671796 
+
@@ -2935,6 +2935,7 @@ proc check_effective_target_vect_float {
if { [istarget i?86-*-*]
  || [istarget powerpc*-*-*]
  || [istarget spu-*-*]
+ || [istarget mips-sde-elf]
  || [istarget mipsisa64*-*-*]
  || [istarget x86_64-*-*]
  || [istarget ia64-*-*]
@@ -3532,6 +3533,7 @@ proc check_effective_target_vect_no_alig
 } else {
set et_vect_no_align_saved 0
if { [istarget mipsisa64*-*-*]
+|| [istarget mips-sde-elf]
 || [istarget sparc*-*-*]
 || [istarget ia64-*-*]
 || [check_effective_target_arm_vect_no_misalign]


Re: [patch, fortran] Fix PR 50627

2013-02-02 Thread Paul Richard Thomas
Dear Thomas,

I wrote this almost immediately after you posted the patch, got
disturbed and forgot about it - my apologies.  Note Dominique's reply
after you corrected the PR number.

OK for trunk.  The part in decl.c is exactly what I was thinking to do.

Thanks for the patch

Paul


Re: [RFC patch] testsuite: Workaround issues with GCC 4.8.0pre + gdb.trace new KFAIL

2013-02-02 Thread Jan Kratochvil
Hi,

just forgot also about gdb.trace/unavailable.exp, equivalent to previous
gdb.trace/collection.exp workarounds.


Jan


gdb/testsuite/
2013-02-02  Jan Kratochvil  

Workaround GCC PR debug/55056 and GDB PR server/15081.
* gdb.base/restore.c (caller3): Protect l1 by GCC_PR_55056 #ifdef.
(caller4): Protect l1 and l2 by GCC_PR_55056 #ifdef.
(caller5): Protect l1, l2 and l3 by GCC_PR_55056 #ifdef.
* gdb.base/restore.exp: New variable opts.  Test caller3, caller4 and
caller5 for l1, l2 and l3.  New prepare_for_testing.
* gdb.base/store.c (wack_longest, wack_float, wack_double)
(wack_doublest): Protect l and r by GCC_PR_55056 #ifdef.
* gdb.base/store.exp: New variable opts.  Test longest, float, double
and doublest functions for l and r.  New prepare_for_testing.
* gdb.trace/collection.c (reglocal_test_func): Protect locf and locd by
GCC_PR_55056 #ifdef.  Protect locar by GDB_PR_15081 #ifdef.
* gdb.trace/unavailable.c: Likewise.
* gdb.trace/collection.exp: New variable opts.  Test reglocal_test_func
for locf, locd and locar.  New prepare_for_testing.
(gdb_collect_locals_test): Increase list size to 43.
* gdb.trace/unavailable.exp: Likewise.

diff --git a/gdb/testsuite/gdb.base/restore.c b/gdb/testsuite/gdb.base/restore.c
index 526be5f..a9b6d28 100644
--- a/gdb/testsuite/gdb.base/restore.c
+++ b/gdb/testsuite/gdb.base/restore.c
@@ -206,6 +206,10 @@ caller2 (void)
 int
 caller3 (void)
 {
+  /* volatile is a GCC PR debug/55056 workaround.  */
+#ifdef GCC_PR_55056
+  volatile
+#endif
   register int l1 = increment (0x7eeb);  /* caller3 prologue */
   register int l2 = increment (l1);
   register int l3 = increment (l2);
@@ -222,7 +226,15 @@ caller3 (void)
 int
 caller4 (void)
 {
+  /* volatile is a GCC PR debug/55056 workaround.  */
+#ifdef GCC_PR_55056
+  volatile
+#endif
   register int l1 = increment (0x7eeb);  /* caller4 prologue */
+  /* volatile is a GCC PR debug/55056 workaround.  */
+#ifdef GCC_PR_55056
+  volatile
+#endif
   register int l2 = increment (l1);
   register int l3 = increment (l2);
   register int l4 = increment (l3);
@@ -239,8 +251,20 @@ caller4 (void)
 int
 caller5 (void)
 {
+  /* volatile is a GCC PR debug/55056 workaround.  */
+#ifdef GCC_PR_55056
+  volatile
+#endif
   register int l1 = increment (0x7eeb);  /* caller5 prologue */
+  /* volatile is a GCC PR debug/55056 workaround.  */
+#ifdef GCC_PR_55056
+  volatile
+#endif
   register int l2 = increment (l1);
+  /* volatile is a GCC PR debug/55056 workaround.  */
+#ifdef GCC_PR_55056
+  volatile
+#endif
   register int l3 = increment (l2);
   register int l4 = increment (l3);
   register int l5 = increment (l4);
diff --git a/gdb/testsuite/gdb.base/restore.exp 
b/gdb/testsuite/gdb.base/restore.exp
index dbe01dc..a7fa91b 100644
--- a/gdb/testsuite/gdb.base/restore.exp
+++ b/gdb/testsuite/gdb.base/restore.exp
@@ -24,7 +24,37 @@
 standard_testfile
 set executable $testfile
 
-if { [prepare_for_testing $testfile.exp $executable $srcfile] } {
+set opts {debug}
+
+if { [prepare_for_testing $testfile.exp $executable $srcfile $opts] } {
+return -1
+}
+
+if {![runto_main]} {
+return -1
+}
+
+foreach caller { caller3 caller4 caller5 } { with_test_prefix $caller {
+gdb_breakpoint $caller
+gdb_continue_to_breakpoint $caller
+
+foreach l { l1 l2 l3 } { with_test_prefix $l {
+   set test "info addr $l"
+   gdb_test_multiple $test $test {
+   -re "\r\nSymbol \"$l\" is optimized out\\.\r\n$gdb_prompt $" {
+   lappend opts additional_flags=-DGCC_PR_55056
+   xfail "$test (register variable has no location)"
+   }
+   -re "\r\nSymbol \"$l\" is .*\r\n$gdb_prompt $" {
+   pass $test
+   }
+   }
+}}
+}}
+
+set executable ${testfile}opts
+
+if { [prepare_for_testing $testfile.exp $executable $srcfile $opts] } {
 return -1
 }
 
diff --git a/gdb/testsuite/gdb.base/store.c b/gdb/testsuite/gdb.base/store.c
index 545515d..3ac4a1a 100644
--- a/gdb/testsuite/gdb.base/store.c
+++ b/gdb/testsuite/gdb.base/store.c
@@ -98,6 +98,10 @@ wack_long (register long u, register long v)
 long
 wack_longest (register longest u, register longest v)
 {
+  /* volatile is a GCC PR debug/55056 workaround.  */
+#ifdef GCC_PR_55056
+  volatile
+#endif
   register longest l = u, r = v;
   l = add_longest (l, r);
   return l + r;
@@ -106,6 +110,10 @@ wack_longest (register longest u, register longest v)
 float
 wack_float (register float u, register float v)
 {
+  /* volatile is a GCC PR debug/55056 workaround.  */
+#ifdef GCC_PR_55056
+  volatile
+#endif
   register float l = u, r = v;
   l = add_float (l, r);
   return l + r;
@@ -114,6 +122,10 @@ wack_float (register float u, register float v)
 double
 wack_double (register double u, register double v)
 {
+  /* volatile is a GCC PR debug/55056 workaround.  */
+#ifdef GCC_PR_55056
+  volatile
+#e

Re: [PATCH, RFC] PR 55403 + 55391

2013-02-02 Thread Richard Sandiford
Sorry, I realised when posting the expmed patch earlier today that I hadn't
finished this off.

Richard Sandiford  writes:
> Richard Henderson  writes:
>> On 11/20/2012 11:24 AM, Richard Henderson wrote:
>>> On 11/20/2012 09:29 AM, Richard Sandiford wrote:
 Gah.  How about this patch, currently bootstrapping on x86_64-linux-gnu
 as a sanity check?  The last instance seems glaringly obvious in
 hindsight :-(

 Richard


 gcc/
* expmed.c (store_bit_field_1): Use adjust_bitfield_address_size
rather than adjust_bitfield_address to change the mode of a reference.
(extract_bit_field_1): Likewise.
>>> 
>>> That patch does fix my ICE.
>>> 
>>> It looks all good, too.  As you say, glaringly obvious even.  ;-)
>>
>> One further point -- get_best_mem_extraction_insn does not work for
>> the traditional 'extv' patterns that only accept memories.  In
>> particular, the QImode memory in the extv pattern never matches up
>> at the beginning of get_traditional_extraction_insn, so that first
>> "if (mode != struct_mode) return false;" always triggers.
>
> Sorry for all the mishaps.
>
>> I audited the existing extv patterns and the affected targets are
>> alpha, sh, and vax.  All of the others implement extv on registers,
>> which appears to work.  Test case:
>>
>> struct S { long y __attribute__((packed)); };
>> long g(struct S *s) { return s->y; }
>>
>> Before:
>>
>>  ldq_u $0,0($16)
>>  ldq_u $1,7($16)
>>  extql $0,$16,$0
>>  extqh $1,$16,$16
>>  bis $0,$16,$0
>>
>> After:
>>
>>  ldbu $5,1($16)
>>  ldbu $8,0($16)
>>  ldbu $7,2($16)
>>  ldbu $6,3($16)
>>  ldbu $4,4($16)
>>  ldbu $3,5($16)
>>  sll $5,8,$5
>>  ldbu $2,6($16)
>>  ldbu $1,7($16)
>>  sll $7,16,$7
>>  sll $6,24,$6
>>  bis $5,$8,$5
>>  sll $4,32,$4
>>  sll $3,40,$3
>>  bis $7,$5,$5
>>  sll $2,48,$2
>>  sll $1,56,$1
>>  bis $6,$5,$0
>>  bis $4,$0,$0
>>  bis $3,$0,$0
>>  bis $2,$0,$0
>>  bis $1,$0,$0
>>
>> I suppose the question is: with only 3 affected targets, is it more
>> trouble fiddling the somewhat confused "traditional" path, or to
>> just go ahead and update the backends?
>
> I suppose updating them would be the ideal eventually, but I'd still
> like to fix the bug.
>
> I belatedly did a similar audit and it looks there are no patterns that
> use a mixture of field and structure modes for register operations.
> They're either equal or not present.

I was wrong, i386.md has an extzv that allows SImode extractions of
DImode registers.  I tested the patch below at the time of the original
thread but for some reason didn't get around to posting it.

I've just rechecked that it doesn't change the output of gcc .ii
files for x86_64-linux-gnu and that it fixes your testcase for SH4A.
Retested on x86_64-linux-gnu and mips-sde-elf.  OK to install?

Richard


gcc/
* optabs.c (get_traditional_extraction_insn): Check the field mode
rather than the structure mode for memory operations.

Index: gcc/optabs.c
===
--- gcc/optabs.c2013-01-31 09:17:21.551473246 +
+++ gcc/optabs.c2013-01-31 09:27:35.535226561 +
@@ -8261,23 +8261,35 @@ get_traditional_extraction_insn (extract
 {
   const struct insn_data_d *data = &insn_data[icode];
 
-  enum machine_mode struct_mode = data->operand[struct_op].mode;
-  if (struct_mode == VOIDmode)
-struct_mode = word_mode;
-  if (mode != struct_mode)
-return false;
-
   enum machine_mode field_mode = data->operand[field_op].mode;
   if (field_mode == VOIDmode)
 field_mode = word_mode;
 
+  enum machine_mode struct_mode;
+  if (type == ET_unaligned_mem)
+{
+  /* Memory structure operands refer to the first byte of the
+bitfield and the true mode is taken from the field operand.  */
+  struct_mode = byte_mode;
+  if (mode != field_mode)
+   return false;
+}
+  else
+{
+  struct_mode = data->operand[struct_op].mode;
+  if (struct_mode == VOIDmode)
+   struct_mode = word_mode;
+  if (mode != struct_mode)
+   return false;
+}
+
   enum machine_mode pos_mode = data->operand[struct_op + 2].mode;
   if (pos_mode == VOIDmode)
 pos_mode = word_mode;
 
   insn->icode = icode;
   insn->field_mode = field_mode;
-  insn->struct_mode = (type == ET_unaligned_mem ? byte_mode : struct_mode);
+  insn->struct_mode = struct_mode;
   insn->pos_mode = pos_mode;
   return true;
 }


RFA: Fix mips-sde-elf fallout from 4.8 extv/extzv changes

2013-02-02 Thread Richard Sandiford
This patch fixes a regression caused by my ext and extzv changes.
The original idea was that the extract side could pass the number
of significant bits in the structure to get_best_reg_extraction_insn,
ignoring any bits higher than the field we're extracting:

/* Return true if an instruction exists to access a field of mode
   FIELDMODE in a register structure that has STRUCT_BITS significant bits.
   Describe the "best" such instruction in *INSN if so.  PATTERN describes
   the type of insertion or extraction we want to perform.

   For an insertion, the number of significant structure bits includes
   all bits of the target.  For an extraction, it need only include the
   most significant bit of the field.  Larger widths are acceptable
   in both cases.  */

That still seems correct in itself, but I'd fluffed the call site:

  if (!MEM_P (op0)
  && get_best_reg_extraction_insn (&extv, pattern, bitnum + bitsize,
   tmode))

in two ways: the calculation was wrong for big-endian, and
extract_bit_field wouldn't cope with cases where TRULY_NOOP_TRUNCATION
was false for the implied truncation.

The latter problem triggered an UNPREDICTABLE warning from the GDB
simulator on vshuf-v8qi.c for -mips64r2 on mips-sde-elf.  It also
shows why the truncation optimisation isn't useful for MIPS:
anything smaller than a word uses the SImode optabs anyway,
and TRULY_NOOP_TRUNCATION makes it wrong to use the SImode optabs
on DImode structures.  So for 4.8 I think the best thing is simply
to pass the full width of the structure.  We could revisit it in
later releases if another target would find it useful.

Tested on x86_64-linux-gnu and mips-sde-elf.  OK to install?

Richard


gcc/
* expmed.c (extract_bit_field_1): Pass the full width of the
structure to get_best_reg_extraction_insn.

Index: gcc/expmed.c
===
--- gcc/expmed.c2013-02-02 08:46:38.031991259 +
+++ gcc/expmed.c2013-02-02 08:57:04.726958347 +
@@ -1569,7 +1569,11 @@ extract_bit_field_1 (rtx str_rtx, unsign
   enum extraction_pattern pattern = unsignedp ? EP_extzv : EP_extv;
   extraction_insn extv;
   if (!MEM_P (op0)
-  && get_best_reg_extraction_insn (&extv, pattern, bitnum + bitsize,
+  /* ??? We could limit the structure size to the part of OP0 that
+contains the field, with appropriate checks for endianness
+and TRULY_NOOP_TRUNCATION.  */
+  && get_best_reg_extraction_insn (&extv, pattern,
+  GET_MODE_BITSIZE (GET_MODE (op0)),
   tmode))
 {
   rtx result = extract_bit_field_using_extv (&extv, op0, bitsize, bitnum,