[PATCH] Windows libibery: Don't quote args unnecessarily

2014-05-06 Thread Ray Donnelly
We only quote arguments that contain spaces, \t or "
characters to prevent wasting 2 characters per
argument of the CreateProcess() 32,768 limit.
---
 libiberty/pex-win32.c | 46 +-
 1 file changed, 37 insertions(+), 9 deletions(-)

diff --git a/libiberty/pex-win32.c b/libiberty/pex-win32.c
index eae72c5..8b9d4f0 100644
--- a/libiberty/pex-win32.c
+++ b/libiberty/pex-win32.c
@@ -340,17 +340,25 @@ argv_to_cmdline (char *const *argv)
   char *p;
   size_t cmdline_len;
   int i, j, k;
+  int needs_quotes;
 
   cmdline_len = 0;
   for (i = 0; argv[i]; i++)
 {
-  /* We quote every last argument.  This simplifies the problem;
-we need only escape embedded double-quotes and immediately
+  /* We only quote arguments that contain spaces, \t or " characters to
+prevent wasting 2 chars per argument of the CreateProcess 32k char
+limit.  We need only escape embedded double-quotes and immediately
 preceeding backslash characters.  A sequence of backslach characters
 that is not follwed by a double quote character will not be
 escaped.  */
+  needs_quotes = 0;
   for (j = 0; argv[i][j]; j++)
{
+ if (argv[i][j] == ' ' || argv[i][j] == '\t' || argv[i][j] == '"')
+   {
+ needs_quotes = 1;
+   }
+
  if (argv[i][j] == '"')
{
  /* Escape preceeding backslashes.  */
@@ -362,16 +370,33 @@ argv_to_cmdline (char *const *argv)
}
   /* Trailing backslashes also need to be escaped because they will be
  followed by the terminating quote.  */
-  for (k = j - 1; k >= 0 && argv[i][k] == '\\'; k--)
-   cmdline_len++;
+  if (needs_quotes)
+{
+  for (k = j - 1; k >= 0 && argv[i][k] == '\\'; k--)
+cmdline_len++;
+}
   cmdline_len += j;
-  cmdline_len += 3;  /* for leading and trailing quotes and space */
+  /* for leading and trailing quotes and space */
+  cmdline_len += needs_quotes * 2 + 1;
 }
   cmdline = XNEWVEC (char, cmdline_len);
   p = cmdline;
   for (i = 0; argv[i]; i++)
 {
-  *p++ = '"';
+  needs_quotes = 0;
+  for (j = 0; argv[i][j]; j++)
+{
+  if (argv[i][j] == ' ' || argv[i][j] == '\t' || argv[i][j] == '"')
+{
+  needs_quotes = 1;
+  break;
+}
+}
+
+  if (needs_quotes)
+{
+  *p++ = '"';
+}
   for (j = 0; argv[i][j]; j++)
{
  if (argv[i][j] == '"')
@@ -382,9 +407,12 @@ argv_to_cmdline (char *const *argv)
}
  *p++ = argv[i][j];
}
-  for (k = j - 1; k >= 0 && argv[i][k] == '\\'; k--)
-   *p++ = '\\';
-  *p++ = '"';
+  if (needs_quotes)
+{
+  for (k = j - 1; k >= 0 && argv[i][k] == '\\'; k--)
+*p++ = '\\';
+  *p++ = '"';
+}
   *p++ = ' ';
 }
   p[-1] = '\0';
-- 
1.9.2



[PATCH] Windows libiberty: Don't quote args unnecessarily (v2)

2014-05-06 Thread Ray Donnelly
We only quote arguments that contain spaces, \t or "
characters to prevent wasting 2 characters per
argument of the CreateProcess() 32,768 limit.

libiberty/
* pex-win32.c (argv_to_cmdline): Don't quote
args unnecessarily

Ray Donnelly (1):
  Windows libibery: Don't quote args unnecessarily

 libiberty/pex-win32.c | 46 +-
 1 file changed, 37 insertions(+), 9 deletions(-)

-- 
1.9.2



Re: [RS6000] PR60737, expand_block_clear uses word stores

2014-05-06 Thread Alan Modra
On Tue, May 06, 2014 at 06:00:14PM +0930, Alan Modra wrote:
> __asm__ __volatile__ ("ld %0,0(%1)"
> : "=r" (scratch[0]) : "r" (p));

Ick, I can't write ppc asm.  That should be "b" (p).

-- 
Alan Modra
Australia Development Lab, IBM


fallout on x86-64 from the wide-int merge.

2014-05-06 Thread Kenneth Zadeck
here is a comparison.  The two areas were built using configure with no 
options at all on x86-64.  The comparison is between revision 210112 and 
210113.Tsan is very unhappy but everything else looks ok.I know 
that this worked a couple of days before the merge. I know that there 
was some tsan fiddling before the merge.


Kenny




# Comparing directories
## Dir1=gbBaseline/: 11 sum files
## Dir2=gbNew: 11 sum files

# Comparing 11 common sum files
## /bin/sh gccBaseline/contrib/compare_tests  /tmp/gxx-sum1.26585 
/tmp/gxx-sum2.26585
Tests that now fail, but worked before:

c-c++-common/tsan/thread_leak.c  -O0  execution test
c-c++-common/tsan/thread_leak.c  -O0  execution test
c-c++-common/tsan/thread_leak.c  -O2  execution test
c-c++-common/tsan/thread_leak.c  -O2  execution test
g++.dg/tsan/aligned_vs_unaligned_race.C  -O0  execution test
g++.dg/tsan/aligned_vs_unaligned_race.C  -O2  execution test
g++.dg/tsan/benign_race.C  -O0  execution test
g++.dg/tsan/benign_race.C  -O2  execution test
g++.dg/tsan/default_options.C  -O0  execution test
g++.dg/tsan/default_options.C  -O2  execution test
g++.dg/tsan/fd_close_norace.C  -O0  execution test
g++.dg/tsan/fd_close_norace.C  -O2  execution test
g++.dg/tsan/fd_close_norace2.C  -O0  execution test
g++.dg/tsan/fd_close_norace2.C  -O2  execution test

New tests that FAIL:

c-c++-common/tsan/atomic_stack.c  -O0  output pattern test, is FATAL: 
ThreadSanitizer CHECK failed: 
../../../../gccNew/libsanitizer/tsan/tsan_rtl.cc:587 "((IsShadowMem((uptr)(p + 
size * kShadowCnt / kShadowCell - 1 != (0)" (0x0, 0x0)
c-c++-common/tsan/atomic_stack.c  -O0  output pattern test, is FATAL: 
ThreadSanitizer CHECK failed: 
../../../../gccNew/libsanitizer/tsan/tsan_rtl.cc:587 "((IsShadowMem((uptr)(p + 
size * kShadowCnt / kShadowCell - 1 != (0)" (0x0, 0x0)
c-c++-common/tsan/atomic_stack.c  -O2  output pattern test, is FATAL: 
ThreadSanitizer CHECK failed: 
../../../../gccNew/libsanitizer/tsan/tsan_rtl.cc:587 "((IsShadowMem((uptr)(p + 
size * kShadowCnt / kShadowCell - 1 != (0)" (0x0, 0x0)
c-c++-common/tsan/atomic_stack.c  -O2  output pattern test, is FATAL: 
ThreadSanitizer CHECK failed: 
../../../../gccNew/libsanitizer/tsan/tsan_rtl.cc:587 "((IsShadowMem((uptr)(p + 
size * kShadowCnt / kShadowCell - 1 != (0)" (0x0, 0x0)
c-c++-common/tsan/fd_pipe_race.c  -O0  output pattern test, is FATAL: 
ThreadSanitizer CHECK failed: 
../../../../gccNew/libsanitizer/tsan/tsan_rtl.cc:587 "((IsShadowMem((uptr)(p + 
size * kShadowCnt / kShadowCell - 1 != (0)" (0x0, 0x0)
c-c++-common/tsan/fd_pipe_race.c  -O0  output pattern test, is FATAL: 
ThreadSanitizer CHECK failed: 
../../../../gccNew/libsanitizer/tsan/tsan_rtl.cc:587 "((IsShadowMem((uptr)(p + 
size * kShadowCnt / kShadowCell - 1 != (0)" (0x0, 0x0)
c-c++-common/tsan/fd_pipe_race.c  -O2  output pattern test, is FATAL: 
ThreadSanitizer CHECK failed: 
../../../../gccNew/libsanitizer/tsan/tsan_rtl.cc:587 "((IsShadowMem((uptr)(p + 
size * kShadowCnt / kShadowCell - 1 != (0)" (0x0, 0x0)
c-c++-common/tsan/fd_pipe_race.c  -O2  output pattern test, is FATAL: 
ThreadSanitizer CHECK failed: 
../../../../gccNew/libsanitizer/tsan/tsan_rtl.cc:587 "((IsShadowMem((uptr)(p + 
size * kShadowCnt / kShadowCell - 1 != (0)" (0x0, 0x0)
c-c++-common/tsan/free_race.c  -O0  output pattern test, is FATAL: 
ThreadSanitizer CHECK failed: 
../../../../gccNew/libsanitizer/tsan/tsan_rtl.cc:587 "((IsShadowMem((uptr)(p + 
size * kShadowCnt / kShadowCell - 1 != (0)" (0x0, 0x0)
c-c++-common/tsan/free_race.c  -O0  output pattern test, is FATAL: 
ThreadSanitizer CHECK failed: 
../../../../gccNew/libsanitizer/tsan/tsan_rtl.cc:587 "((IsShadowMem((uptr)(p + 
size * kShadowCnt / kShadowCell - 1 != (0)" (0x0, 0x0)
c-c++-common/tsan/free_race.c  -O2  output pattern test, is FATAL: 
ThreadSanitizer CHECK failed: 
../../../../gccNew/libsanitizer/tsan/tsan_rtl.cc:587 "((IsShadowMem((uptr)(p + 
size * kShadowCnt / kShadowCell - 1 != (0)" (0x0, 0x0)
c-c++-common/tsan/free_race.c  -O2  output pattern test, is FATAL: 
ThreadSanitizer CHECK failed: 
../../../../gccNew/libsanitizer/tsan/tsan_rtl.cc:587 "((IsShadowMem((uptr)(p + 
size * kShadowCnt / kShadowCell - 1 != (0)" (0x0, 0x0)
c-c++-common/tsan/free_race2.c  -O0  output pattern test, is FATAL: 
ThreadSanitizer CHECK failed: 
../../../../gccNew/libsanitizer/tsan/tsan_rtl.cc:587 "((IsShadowMem((uptr)(p + 
size * kShadowCnt / kShadowCell - 1 != (0)" (0x0, 0x0)
c-c++-common/tsan/free_race2.c  -O0  output pattern test, is FATAL: 
ThreadSanitizer CHECK failed: 
../../../../gccNew/libsanitizer/tsan/tsan_rtl.cc:587 "((IsShadowMem((uptr)(p + 
size * kShadowCnt / kShadowCell - 1 != (0)" (0x0, 0x0)
c-c++-common/tsan/free_race2.c  -O2  output pattern test, is FATAL: 
ThreadSanitizer CHECK failed: 
../../../../gccNew/libsanitizer/tsan/tsan_rtl.cc:587 "((IsShadowMem((uptr)(p + 
size * kShadowCnt / kShadowCell - 1 != (0)" (0x0, 0x0)
c-c++-common/tsan/free_race2.c  -O2  output pattern 

Re: debug container patch

2014-05-06 Thread Paolo Carlini

-- Francois,

remember to regenerate and commit the Makefile.in changes.

Thanks,
Paolo.


Re: we are starting the wide int merge

2014-05-06 Thread Mike Stump
On May 6, 2014, at 3:54 PM, Mike Stump  wrote:
> 
>> My build robot experiences errors like this:
>> 
>> g++ -c   -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -fno-exceptions 
>> -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing 
>> -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual 
>> -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings 
>> -fno-common  -DHAVE_CONFIG_H -I. -I. -I/home/jbglaw/repos/gcc/gcc 
>> -I/home/jbglaw/repos/gcc/gcc/. -I/home/jbglaw/repos/gcc/gcc/../include 
>> -I/home/jbglaw/repos/gcc/gcc/../libcpp/include 
>> -I/opt/cfarm/gmp-latest/include -I/opt/cfarm/mpfr-latest/include 
>> -I/opt/cfarm/mpc-latest/include  
>> -I/home/jbglaw/repos/gcc/gcc/../libdecnumber 
>> -I/home/jbglaw/repos/gcc/gcc/../libdecnumber/dpd -I../libdecnumber 
>> -I/home/jbglaw/repos/gcc/gcc/../libbacktrace-o alias.o -MT alias.o -MMD 
>> -MP -MF ./.deps/alias.TPo /home/jbglaw/repos/gcc/gcc/alias.c
>> In file included from /home/jbglaw/repos/gcc/gcc/real.h:25:0,
>>from /home/jbglaw/repos/gcc/gcc/rtl.h:27,
>>from /home/jbglaw/repos/gcc/gcc/alias.c:25:
>> /home/jbglaw/repos/gcc/gcc/wide-int.h: In instantiation of 'bool 
>> wi::ltu_p(const T1&, const T2&) [with T1 = 
>> generic_wide_int >; T2 = long int]':
>> /home/jbglaw/repos/gcc/gcc/alias.c:346:28:   required from here
>> /home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
>> 'wi::int_traits' used in nested name specifier
>>  WIDE_INT_REF_FOR (T2) yi (y, precision);
> 
> I’m pretty sure this:

I checked this in, sorry for the breakage.

* wide-int.h (wi::int_traits ): Always define.

Committed revision 210128.

Re: we are starting the wide int merge

2014-05-06 Thread Mike Stump
On May 6, 2014, at 3:54 PM, Mike Stump  wrote:
> 
> I’m pretty sure this:

> will fix it.  If someone can confirm that would be great.

I tried that on my p7 and on my x86_64 machines, they both build fine.



Re: we are starting the wide int merge

2014-05-06 Thread Jan-Benedict Glaw
On Tue, 2014-05-06 15:54:05 -0700, Mike Stump  wrote:
> On May 6, 2014, at 2:17 PM, Jan-Benedict Glaw  wrote:
> > On Tue, 2014-05-06 12:20:54 -0700, Mike Stump  wrote:
> > > On May 6, 2014, at 8:19 AM, Kenneth Zadeck  
> > > wrote:
> > > > please hold off on committing patches for the next couple of
> > > > hours as we have a very large merge to do.  thanks.
> > > All done…  It is in.
> > My build robot experiences errors like this:
[...]
> I’m pretty sure this:
[...]
> will fix it.  If someone can confirm that would be great.

I addad that patch to two (darkeye and gcc76) of the builders. Won't
probably take too long :)

MfG, JBG

-- 
  Jan-Benedict Glaw  jbg...@lug-owl.de  +49-172-7608481
Signature of:http://catb.org/~esr/faqs/smart-questions.html
the second  :


signature.asc
Description: Digital signature


Re: we are starting the wide int merge

2014-05-06 Thread Christophe Lyon
I have noticed build failures too (arm, aarch64).

It also looks like the git-svn-id property is now wrong/incomplete.
For instance, commit 9a5942c1d4d9116ab74b0741cfe3894a89fd17fb has:
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/wide-int@201706
138bc75d-0d04-0410-961f-82ee72b054a4

How does it map to the SVN commit in trunk?

Thanks,

Christophe.


On 6 May 2014 23:17, Jan-Benedict Glaw  wrote:
> On Tue, 2014-05-06 12:20:54 -0700, Mike Stump  wrote:
>> On May 6, 2014, at 8:19 AM, Kenneth Zadeck  wrote:
>> > please hold off on committing patches for the next couple of hours as we 
>> > have a very large merge to do.
>> > thanks.
>>
>> All done…  It is in.
>
> My build robot experiences errors like this:
>
>
> g++ -c   -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -fno-exceptions 
> -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing 
> -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual 
> -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings 
> -fno-common  -DHAVE_CONFIG_H -I. -I. -I/home/jbglaw/repos/gcc/gcc 
> -I/home/jbglaw/repos/gcc/gcc/. -I/home/jbglaw/repos/gcc/gcc/../include 
> -I/home/jbglaw/repos/gcc/gcc/../libcpp/include 
> -I/opt/cfarm/gmp-latest/include -I/opt/cfarm/mpfr-latest/include 
> -I/opt/cfarm/mpc-latest/include  -I/home/jbglaw/repos/gcc/gcc/../libdecnumber 
> -I/home/jbglaw/repos/gcc/gcc/../libdecnumber/dpd -I../libdecnumber 
> -I/home/jbglaw/repos/gcc/gcc/../libbacktrace-o alias.o -MT alias.o -MMD 
> -MP -MF ./.deps/alias.TPo /home/jbglaw/repos/gcc/gcc/alias.c
> In file included from /home/jbglaw/repos/gcc/gcc/real.h:25:0,
>  from /home/jbglaw/repos/gcc/gcc/rtl.h:27,
>  from /home/jbglaw/repos/gcc/gcc/alias.c:25:
> /home/jbglaw/repos/gcc/gcc/wide-int.h: In instantiation of 'bool 
> wi::ltu_p(const T1&, const T2&) [with T1 = 
> generic_wide_int >; T2 = long int]':
> /home/jbglaw/repos/gcc/gcc/alias.c:346:28:   required from here
> /home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
> 'wi::int_traits' used in nested name specifier
>WIDE_INT_REF_FOR (T2) yi (y, precision);
>  ^
> /home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
> 'wi::int_traits' used in nested name specifier
> /home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
> 'wi::int_traits' used in nested name specifier
> /home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
> 'wi::int_traits' used in nested name specifier
> /home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
> 'wi::int_traits' used in nested name specifier
> /home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
> 'wi::int_traits' used in nested name specifier
> /home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
> 'wi::int_traits' used in nested name specifier
> /home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
> 'wi::int_traits' used in nested name specifier
> /home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
> 'wi::int_traits' used in nested name specifier
> /home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
> 'wi::int_traits' used in nested name specifier
> /home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
> 'wi::int_traits' used in nested name specifier
> /home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
> 'wi::int_traits' used in nested name specifier
> /home/jbglaw/repos/gcc/gcc/wide-int.h: In instantiation of 'unsigned int 
> wi::get_binary_precision(const T1&, const T2&) [with T1 = 
> generic_wide_int >; T2 = long int]':
> /home/jbglaw/repos/gcc/gcc/wide-int.h:1785:54:   required from 'bool 
> wi::ltu_p(const T1&, const T2&) [with T1 = 
> generic_wide_int >; T2 = long int]'
> /home/jbglaw/repos/gcc/gcc/alias.c:346:28:   required from here
> /home/jbglaw/repos/gcc/gcc/wide-int.h:1638:27: error: incomplete type 
> 'wi::int_traits' used in nested name specifier
> get_binary_result (x, y));
>^
> /home/jbglaw/repos/gcc/gcc/wide-int.h: In function 'bool wi::ltu_p(const T1&, 
> const T2&) [with T1 = generic_wide_int >; T2 = long 
> int]':
> /home/jbglaw/repos/gcc/gcc/wide-int.h:1803:1: warning: control reaches end of 
> non-void function [-Wreturn-type]
>  }
>  ^
> /home/jbglaw/repos/gcc/gcc/wide-int.h: In function 'unsigned int 
> wi::get_binary_precision(const T1&, const T2&) [with T1 = 
> generic_wide_int >; T2 = long int]':
> /home/jbglaw/repos/gcc/gcc/wide-int.h:1639:1: warning: control reaches end of 
> non-void function [-Wreturn-type]
>  }
>  ^
> make[1]: *** [alias.o] Error 1
>
>
> ...at least for:
> rl78-elf 
> (http://toolchain.lug-owl.de/buildbot/show_build_details.php?id=219615)
> microblazeel-linux 
> (http://toolchain.lug-owl.de/buildbot/show_build_details.php?id=219701)
> msp430-elf 
> (http://toolchain.lug-owl.de/buildbot/show_build_details.php?id=219703)
> 

Re: we are starting the wide int merge

2014-05-06 Thread Mike Stump
On May 6, 2014, at 2:17 PM, Jan-Benedict Glaw  wrote:
> On Tue, 2014-05-06 12:20:54 -0700, Mike Stump  wrote:
>> On May 6, 2014, at 8:19 AM, Kenneth Zadeck  wrote:
>>> please hold off on committing patches for the next couple of hours as we 
>>> have a very large merge to do.
>>> thanks.
>> 
>> All done…  It is in.
> 
> My build robot experiences errors like this:
> 
> g++ -c   -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -fno-exceptions 
> -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing 
> -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual 
> -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings 
> -fno-common  -DHAVE_CONFIG_H -I. -I. -I/home/jbglaw/repos/gcc/gcc 
> -I/home/jbglaw/repos/gcc/gcc/. -I/home/jbglaw/repos/gcc/gcc/../include 
> -I/home/jbglaw/repos/gcc/gcc/../libcpp/include 
> -I/opt/cfarm/gmp-latest/include -I/opt/cfarm/mpfr-latest/include 
> -I/opt/cfarm/mpc-latest/include  -I/home/jbglaw/repos/gcc/gcc/../libdecnumber 
> -I/home/jbglaw/repos/gcc/gcc/../libdecnumber/dpd -I../libdecnumber 
> -I/home/jbglaw/repos/gcc/gcc/../libbacktrace-o alias.o -MT alias.o -MMD 
> -MP -MF ./.deps/alias.TPo /home/jbglaw/repos/gcc/gcc/alias.c
> In file included from /home/jbglaw/repos/gcc/gcc/real.h:25:0,
> from /home/jbglaw/repos/gcc/gcc/rtl.h:27,
> from /home/jbglaw/repos/gcc/gcc/alias.c:25:
> /home/jbglaw/repos/gcc/gcc/wide-int.h: In instantiation of 'bool 
> wi::ltu_p(const T1&, const T2&) [with T1 = 
> generic_wide_int >; T2 = long int]':
> /home/jbglaw/repos/gcc/gcc/alias.c:346:28:   required from here
> /home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
> 'wi::int_traits' used in nested name specifier
>   WIDE_INT_REF_FOR (T2) yi (y, precision);

I’m pretty sure this:

Index: gcc/wide-int.h
===
--- gcc/wide-int.h  (revision 210113)
+++ gcc/wide-int.h  (working copy)
@@ -1442,7 +1442,6 @@ namespace wi
   struct int_traits 
 : public primitive_int_traits  {};
 
-#if HOST_BITS_PER_INT != HOST_BITS_PER_WIDE_INT
   template <>
   struct int_traits 
 : public primitive_int_traits  {};
@@ -1450,7 +1449,6 @@ namespace wi
   template <>
   struct int_traits 
 : public primitive_int_traits  {};
-#endif
 }
 
 namespace wi

will fix it.  If someone can confirm that would be great.



Re: Fix PR ipa/60965 (placement new wrt ipa-devirt)

2014-05-06 Thread Paolo Carlini

Hi Honza,

On 05/05/2014 09:44 PM, Jan Hubicka wrote:

Hi,
this patch fixes unfortunate thinko in get_class_context that invalidates
transitions from non-POD type to a polymorphic type that may happen by virtue
of placement new and apparently breaks openJDK and Qt. I really tried to keep
placement new in mind when implementing ipa-devirt, so hope there are no
similar negaitve surprises.

The patch disables about 200 out of 3 devirtualizations happening in
Firefox.

I have commited it to 4.9 and will commit to mainline once testing finishes.

Honza

PR ipa/60965
* g++.dg/ipa/devirt-31.C: New testcase.
* g++.dg/ipa/devirt-11.C: Adjust testcase.
Does devirt-11.C require further adjustment in the branch? Apparently it 
is failing, eg:


http://gcc.gnu.org/ml/gcc-testresults/2014-05/msg00383.html

and for me too ;)

Thanks,
Paolo.


Re: we are starting the wide int merge

2014-05-06 Thread Jan-Benedict Glaw
On Tue, 2014-05-06 12:20:54 -0700, Mike Stump  wrote:
> On May 6, 2014, at 8:19 AM, Kenneth Zadeck  wrote:
> > please hold off on committing patches for the next couple of hours as we 
> > have a very large merge to do.
> > thanks.
> 
> All done…  It is in.

My build robot experiences errors like this:


g++ -c   -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -fno-exceptions 
-fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings 
-Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic 
-Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common  
-DHAVE_CONFIG_H -I. -I. -I/home/jbglaw/repos/gcc/gcc 
-I/home/jbglaw/repos/gcc/gcc/. -I/home/jbglaw/repos/gcc/gcc/../include 
-I/home/jbglaw/repos/gcc/gcc/../libcpp/include -I/opt/cfarm/gmp-latest/include 
-I/opt/cfarm/mpfr-latest/include -I/opt/cfarm/mpc-latest/include  
-I/home/jbglaw/repos/gcc/gcc/../libdecnumber 
-I/home/jbglaw/repos/gcc/gcc/../libdecnumber/dpd -I../libdecnumber 
-I/home/jbglaw/repos/gcc/gcc/../libbacktrace-o alias.o -MT alias.o -MMD -MP 
-MF ./.deps/alias.TPo /home/jbglaw/repos/gcc/gcc/alias.c
In file included from /home/jbglaw/repos/gcc/gcc/real.h:25:0,
 from /home/jbglaw/repos/gcc/gcc/rtl.h:27,
 from /home/jbglaw/repos/gcc/gcc/alias.c:25:
/home/jbglaw/repos/gcc/gcc/wide-int.h: In instantiation of 'bool 
wi::ltu_p(const T1&, const T2&) [with T1 = 
generic_wide_int >; T2 = long int]':
/home/jbglaw/repos/gcc/gcc/alias.c:346:28:   required from here
/home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
'wi::int_traits' used in nested name specifier
   WIDE_INT_REF_FOR (T2) yi (y, precision);
 ^
/home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
'wi::int_traits' used in nested name specifier
/home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
'wi::int_traits' used in nested name specifier
/home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
'wi::int_traits' used in nested name specifier
/home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
'wi::int_traits' used in nested name specifier
/home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
'wi::int_traits' used in nested name specifier
/home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
'wi::int_traits' used in nested name specifier
/home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
'wi::int_traits' used in nested name specifier
/home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
'wi::int_traits' used in nested name specifier
/home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
'wi::int_traits' used in nested name specifier
/home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
'wi::int_traits' used in nested name specifier
/home/jbglaw/repos/gcc/gcc/wide-int.h:1787:25: error: incomplete type 
'wi::int_traits' used in nested name specifier
/home/jbglaw/repos/gcc/gcc/wide-int.h: In instantiation of 'unsigned int 
wi::get_binary_precision(const T1&, const T2&) [with T1 = 
generic_wide_int >; T2 = long int]':
/home/jbglaw/repos/gcc/gcc/wide-int.h:1785:54:   required from 'bool 
wi::ltu_p(const T1&, const T2&) [with T1 = 
generic_wide_int >; T2 = long int]'
/home/jbglaw/repos/gcc/gcc/alias.c:346:28:   required from here
/home/jbglaw/repos/gcc/gcc/wide-int.h:1638:27: error: incomplete type 
'wi::int_traits' used in nested name specifier
get_binary_result (x, y));
   ^
/home/jbglaw/repos/gcc/gcc/wide-int.h: In function 'bool wi::ltu_p(const T1&, 
const T2&) [with T1 = generic_wide_int >; T2 = long int]':
/home/jbglaw/repos/gcc/gcc/wide-int.h:1803:1: warning: control reaches end of 
non-void function [-Wreturn-type]
 }
 ^
/home/jbglaw/repos/gcc/gcc/wide-int.h: In function 'unsigned int 
wi::get_binary_precision(const T1&, const T2&) [with T1 = 
generic_wide_int >; T2 = long int]':
/home/jbglaw/repos/gcc/gcc/wide-int.h:1639:1: warning: control reaches end of 
non-void function [-Wreturn-type]
 }
 ^
make[1]: *** [alias.o] Error 1


...at least for:
rl78-elf (http://toolchain.lug-owl.de/buildbot/show_build_details.php?id=219615)
microblazeel-linux 
(http://toolchain.lug-owl.de/buildbot/show_build_details.php?id=219701)
msp430-elf 
(http://toolchain.lug-owl.de/buildbot/show_build_details.php?id=219703)
arc-elf (http://toolchain.lug-owl.de/buildbot/show_build_details.php?id=219789)
...but not for:
arm-eabi (http://toolchain.lug-owl.de/buildbot/show_build_details.php?id=219709)
bfin-elf (http://toolchain.lug-owl.de/buildbot/show_build_details.php?id=219778)
(and several others.)

MfG, JBG

-- 
  Jan-Benedict Glaw  jbg...@lug-owl.de  +49-172-7608481
Signature of:  Alles sollte so einfach wie möglich gemacht sein.
the second  :  Aber nicht einfacher.  (Einstein)


signature.asc
Description: Digital signature


Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-06 Thread Mike Stump
On May 6, 2014, at 8:07 AM, Nicholas Clifton  wrote:
> +  tmp = size_int ((5 * MAX (POINTER_SIZE, BITS_PER_WORD)) / 
> BITS_PER_WORD - 1);

This is not right.  The denominator should either be GET_MODE_SIZE (Pmode) or 
POINTER_SIZE.  See get_nl_goto_field for additional fun.

Also, the save area for the machine is exactly 2 * GET_MODE_SIZE (Pmode) in and 
the save area is exactly GET_MODE_SIZE (STACK_SAVEAREA_MODE (SAVE_NONLOCAL)) 
bits.  builtin_setjmp_setup is the only unaccounted for component.

mips is alone in having slop not accounted for in GET_MODE_SIZE 
(STACK_SAVEAREA_MODE (SAVE_NONLOCAL)).  Personally, I’d rather make the size 
calculation exact, rather than even more sloppy and hard to comprehend.

How about GET_MODE_SIZE (STACK_SAVEAREA_MODE (SAVE_NONLOCAL)) / GET_MODE_SIZE 
(Pmode) + 2 + /* slop for mips, see builtin_setjmp_setup */ 1 - 1.  This 
retains the slop for mips, and fixes ports like ia64 and s390 (see 
STACK_SAVEAREA_MODE on those ports, it is larger one might expect)?

Last patch that `broke’ this:

  http://gcc.gnu.org/ml/gcc-patches/2004-01/msg02000.html

That entire thread is interesting.

Re: [RFC][PATCH][MIPS] Patch to enable LRA for MIPS backend

2014-05-06 Thread Richard Sandiford
Kyrill Tkachov  writes:
> On 03/05/14 20:21, Richard Sandiford wrote:
>> Vladimir Makarov  writes:
> Not sure how the constraint would/should exclude $sp-based address in
> LRA.  In this particular case, a spilled pseudo is changed to memory
> giving the following RTL form:
>
> (insn 30 29 31 4 (set (reg:SI 4 $4)
>   (and:SI (mem/c:SI (plus:SI (reg/f:SI 78 $frame)
>   (const_int 16 [0x10])) [7 %sfp+16 S4 A32])
>   (const_int 65535 [0x]))) shell.i:17 161 {*andsi3_mips16}
>(expr_list:REG_DEAD (reg:SI 194 [ D.1469 ])
>   (nil)))
>
> The operand 1 during alternative selection is not marked as a bad
> operand as it is a memory operand. $frame appears to be fine as it
> could be eliminated later to hard register. No reloads are inserted
> for the instructions concerned. Unless, $frame should be temporarily
> eliminated and then a reload would be inserted?
 Yeah, I think the lack of elimination is the problem.  process_address
 eliminates $frame temporarily before checking whether the address
 is valid, but the places that check EXTRA_CONSTRAINT_STR pass the
 original uneliminated address.  So the legitimate_address_p hook sees
 the $sp-based address but the "W" constraint only sees the $frame-based
 address (which might or might not be valid, depending on whether $frame
 is eliminated to the stack or hard frame pointer).  I think the constraints
 should see the eliminated address too.

 This patch seems to fix it for me.  Tested on x86_64-linux-gnu.
 Vlad, is this OK for trunk?

 BTW, we might want to define something like:

 #define MODE_BASE_REG_CLASS(MODE) \
 (TARGET_MIPS16 \
  ? ((MODE) == SImode || (MODE) == DImode ? M16_SP_REGS : M16_REGS) \
  : GR_REGS)

 instead of BASE_REG_CLASS.  It might lead to slightly better code
 (or not -- if it doesn't then don't bother :-)).

 If this patch is OK then I think the only thing blocking the switch
 to LRA is the asm-subreg-1.c failure.  I think it'd be fine to XFAIL
 that test on MIPS for now, until there's a consensus about what "X" means
 for asms.


 gcc/
* lra-constraints.c (valid_address_p): Move earlier in file.
Add a constraint argument to the address_info version.
(satisfies_memory_constraint_p): New function.
(satisfies_address_constraint_p): Likewise.
(process_alt_operands, curr_insn_transform): Use them.
(process_address): Pass the constraint to valid_address_p when
checking address operands.


>>> Yes, it looks ok for me, Richard.  Thanks on working on this.
>>>
>>> I am on vacation till May 4th. If the patch results in problems on other
>>> targets, I hope you revert it.  But to be honest, I believe it is very
>>> safe and don't expect any problems at all.
>> Thanks Vlad, belatedly committed on that basis.  Like you say I'll revert
>> it at the first sign of trouble (although it ended up being closer to
>> your return than originally intended. :-))
>
> Hi all,
> This caused some testsuite failures on arm:
> FAIL: gcc.target/arm/vfp-ldmdbd.c scan-assembler fldmdbd
> FAIL: gcc.target/arm/vfp-ldmdbs.c scan-assembler fldmdbs
> FAIL: gcc.target/arm/vfp-ldmiad.c scan-assembler fldmiad
> FAIL: gcc.target/arm/vfp-ldmias.c scan-assembler fldmias
>
>  From the vfp-ldmdbd.c test this patch changed the codegen from:
>  fldmdbdr5!, {d7}
>
> into
>  subr5, r5, #8
>  flddd7, [r5]
>
> Which broke the test.

Sorry for the breakage.  I've reverted the patch for now and will send a
fixed version when I have time.

Thanks,
Richard



Re: [PATCH 0/3] Compile-time gimple checking, without typedefs

2014-05-06 Thread Richard Biener
On May 6, 2014 9:15:09 PM CEST, Jeff Law  wrote:
>On 05/06/14 12:58, David Malcolm wrote:
>>> But the prefix can be as short as e.g. "g" (for gimple), so gtry,
>ggoto,
>>> gassign, gcall.
>>
>> FWIW, I like this: I think it's clear and concise, and I think it
>avoids
>> the need for namespaces. (I'd prefer not to have a namespace, due to
>> gengtype).
>Then let's go with it.  g is as reasonable as anything else we're 
>likely to come up with.

Agreed.

Richard.

>jeff




Re: we are starting the wide int merge

2014-05-06 Thread Mike Stump
On May 6, 2014, at 8:19 AM, Kenneth Zadeck  wrote:
> please hold off on committing patches for the next couple of hours as we have 
> a very large merge to do.
> thanks.

All done…  It is in.

Re: [PATCH 0/3] Compile-time gimple checking, without typedefs

2014-05-06 Thread Jeff Law

On 05/06/14 12:58, David Malcolm wrote:

But the prefix can be as short as e.g. "g" (for gimple), so gtry, ggoto,
gassign, gcall.


FWIW, I like this: I think it's clear and concise, and I think it avoids
the need for namespaces. (I'd prefer not to have a namespace, due to
gengtype).
Then let's go with it.  g is as reasonable as anything else we're 
likely to come up with.


jeff



Re: [PATCH 0/3] Compile-time gimple checking, without typedefs

2014-05-06 Thread David Malcolm
On Mon, 2014-05-05 at 21:53 +0200, Jakub Jelinek wrote:
> On Mon, May 05, 2014 at 01:44:06PM -0600, Jeff Law wrote:
> > On 05/05/14 11:37, Richard Biener wrote:
> > >
> > >Well, I hope that Andrew doesn't do without a namespace (and I still
> > >don't believe in what he tries to achieve without laying proper ground-work
> > >throughout the compiler).  With a namespace gimple we can use
> > >gimple::stmt.
> > namespaces, while nice, aren't going to solve all these issues.
> > While I think we can get a good separation between gimple and the
> > rest of the world, I suspect namespaces aren't going to help much
> > with the statement vs expression vs type issues.
> > 
> > Ultimately I suspect we're not going to have too many places where
> > we can stick a "using namespace gimple-whatever", but time will
> > tell.
> > 
> > >Agreed on that, btw.  But switch_ can't be the answer either.  Maybe
> > >swidch (similar do klass) or swjdch.  Or swtch.  I like swtch the best
> > >(similar to stmt).
> > As David pointed out there's several others that map to keywords.
> > I'd rather set a standard here across the project so that we don't
> > have folks using gto for goto, others using goto_, _goto, whatever.
> > While swtch works well, I don't think the other examples work nearly
> > as well.  Thus some kind of prefix/suffix seems better to me (though
> > I'm sure my eyes will bleed as a result of looking at those
> > objects).
> 
> But the prefix can be as short as e.g. "g" (for gimple), so gtry, ggoto,
> gassign, gcall.

FWIW, I like this: I think it's clear and concise, and I think it avoids
the need for namespaces. (I'd prefer not to have a namespace, due to
gengtype).

Given Richi's preference for the base class being "gimple", that could
give:

Existing   New
   ---
gimple gimple *


gimple gswitch *
  a GIMPLE_SWITCH


gimple gcall *
  a GIMPLE_CALL

etc

with the various
  gimple_statement_with_FOO
becoming just
  gimple_with_FOO
e.g. "gimple_with_memory_ops"

How would you want subclasses for the OpenMP statements to be named?
e.g. replace "gimple_statement_omp" with gomp_" for e.g.
"gomp_for *"

or to "gimple_omp_", giving e.g. "gimple_omp_for *"

with the former (less verbose) approach giving the following names, I
think (showing the class hierarchy):

   gimple
 |layout: GSS_BASE
 |used for 4 codes: GIMPLE_ERROR_MARK
 |  GIMPLE_NOP
 |  GIMPLE_OMP_SECTIONS_SWITCH
 |  GIMPLE_PREDICT
 |
 + gimple_with_ops_base
 |   |(no GSS layout)
 |   |
 |   + gimple_with_ops
 |   |   |layout: GSS_WITH_OPS
 |   |   |
 |   |   + gcond
 |   |   | code: GIMPLE_COND
 |   |   |
 |   |   + gdebug
 |   |   | code: GIMPLE_DEBUG
 |   |   |
 |   |   + ggoto
 |   |   | code: GIMPLE_GOTO
 |   |   |
 |   |   + glabel
 |   |   | code: GIMPLE_LABEL
 |   |   |
 |   |   + gswitch
 |   | code: GIMPLE_SWITCH
 |   |
 |   + gimple_with_memory_ops_base
 |   |layout: GSS_WITH_MEM_OPS_BASE
 |   |
 |   + gimple_with_memory_ops
 |   |   |layout: GSS_WITH_MEM_OPS
 |   |   |
 |   |   + gassign
 |   |   |code GIMPLE_ASSIGN
 |   |   |
 |   |   + greturn
 |   |code GIMPLE_RETURN
 |   |
 |   + gcall
 |   |layout: GSS_CALL, code: GIMPLE_CALL
 |   |
 |   + gasm
 |   |layout: GSS_ASM, code: GIMPLE_ASM
 |   |
 |   + gtransaction
 |layout: GSS_TRANSACTION, code: GIMPLE_TRANSACTION
 |
 + gomp
 |   |layout: GSS_OMP.  Used for code GIMPLE_OMP_SECTION
 |   |
 |   + gomp_critical
 |   |layout: GSS_OMP_CRITICAL, code: GIMPLE_OMP_CRITICAL
 |   |
 |   + gomp_for
 |   |layout: GSS_OMP_FOR, code: GIMPLE_OMP_FOR
 |   |
 |   + gomp_parallel_layout
 |   |   |layout: GSS_OMP_PARALLEL_LAYOUT
 |   |   |
 |   |   + gomp_taskreg
 |   |   |   |
 |   |   |   + gomp_parallel
 |   |   |   |code: GIMPLE_OMP_PARALLEL
 |   |   |   |
 |   |   |   + gomp_task
 |   |   |code: GIMPLE_OMP_TASK
 |   |   |
 |   |   + gomp_target
 |   |code: GIMPLE_OMP_TARGET
 |   |
 |   + gomp_sections
 |   |layout: GSS_OMP_SECTIONS, code: GIMPLE_OMP_SECTIONS
 |   |
 |   + gomp_single_layout
 |   |layout: GSS_OMP_SINGLE_LAYOUT
 |   |
 |   + gomp_single
 |   |code: GIMPLE_OMP_SINGLE
 |   |
 |   + gomp_teams
 |code: GIMPLE_OMP_TEAMS
 |
 + gbind
 |layout: GSS_BIND, code: GIMPLE_BIND
 |
 + gcatch
 |layout: GSS_CATCH, code: GIMPLE_CATCH
 |
 + geh_filter

Re: Hurd port for gcc go PATCH 7-9 (9)

2014-05-06 Thread Samuel Thibault
Svante Signell, le Tue 06 May 2014 14:13:54 +0200, a écrit :
> > > +# Special treatment of EWOULDBLOCK for GNU/Hurd
> > > +# /usr/include/bits/errno.h: #define EWOULDBLOCK EAGAIN
> > > +egrep '^const EWOULDBLOCK = Errno(_EWOULDBLOCK)' ${OUT} | \
> > > +sed -i.bak -e 's/_EWOULDBLOCK/_EAGAIN/' ${OUT}
> > > +
> 
> This applies to all systems yes, how to modify?

Well, either explicitly test for the system, or find a way to make it
actually do things only for the systems which need it. You could for
instance grep for "#define EWOULDBLOCK EAGAIN".

> > and that:
> > 
> > > +# Special treatment of SYS_FCNTL for GNU/Hurd
> > > +if ! grep '^const SYS_FCNTL' ${OUT} >/dev/null 2>&1; then
> > > +  echo "const SYS_FCNTL = 0" >> ${OUT}
> > > +fi
> 
> And this applies to systems not defining FCNTL.
> How many systems could possibly be affected?

I misread it indeed, I'm sorry about that.  So it adds SYS_FCNTL = 0 to
any system which does not have it already.  What is the consequence of
this?  Where is this used?  (I can't find any go reference to SYS_FCNTL
in the gcc source)

Samuel


Re: [C++ Patch] PR 60999

2014-05-06 Thread Jason Merrill

On 05/06/2014 04:23 AM, Paolo Carlini wrote:

On further thought (yesterday was a little tired, sorry), I think that
nsdmi-template7.C is telling us that, in fact, we *do* want something
true when we are handling an NSDMI inside a non-template class of a
template class!


Right, sorry, I was thinking we only had to look at the innermost 
parameters, but in fact we need to push all levels of parameters.


I've been resistant to your change because it wouldn't fix a 
specialization of a member template of another class template. 
Currently that is ill-formed, but there have been mumblings in Core 
about allowing it in the future.  But supporting that would probably 
involve making such a specialization a template itself, so go ahead.


But please add a comment clarifying that the test is there to avoid 
looking past an explicit specialization.


Jason



Re: [PATCH] [ARM] [RFC] Fix longstanding push_minipool_fix ICE (PR49423, lp1296601)

2014-05-06 Thread Julian Brown
On Tue, 6 May 2014 17:05:16 +0100
Charles Baylis  wrote:

> Ping?
> 
> At this stage looking for general feedback on whether the define_split
> approach in this patch is appropriate. If it is, I'll do a clean patch
> for full review.
> 
> Archive link: http://gcc.gnu.org/ml/gcc-patches/2014-04/msg00078.html

TBH, it feels like a hack to me, FWIW. It'd be better to avoid
generating the bad RTL to begin with.

Thanks,

Julian


Re: [PATCH] [ARM] [RFC] Fix longstanding push_minipool_fix ICE (PR49423, lp1296601)

2014-05-06 Thread Charles Baylis
Ping?

At this stage looking for general feedback on whether the define_split
approach in this patch is appropriate. If it is, I'll do a clean patch
for full review.

Archive link: http://gcc.gnu.org/ml/gcc-patches/2014-04/msg00078.html

On 2 April 2014 14:29, Charles Baylis  wrote:
> Hi
>
> This patch fixes the push_minipool_fix ICE, which occurs when the ARM
> backend encounters a zero/sign extending load from a constant pool.
>
> I don't have a current test case for trunk, lp1296601 has a test case
> which affects the linaro-4.8 branch. As far as I know, there has been
> no fix for this on trunk.
>
> The approach taken in this patch is to extend each pattern where this
> can occur,  so that it triggers a define_split to synthesise a
> constant move instead. Some but not all extend patterns have
> previously added pool_range attributes to work-around this problem,
> this patch removes those, and also fixes the remaining patterns. Some
> patterns have slightly more complex workarounds, which I have not yet
> analysed, but it seems worth posting the patch at this stage to get
> feedback on the general approach.
>
> Tested on arm-unknown-linux-gnueabihf (qemu), bootstrap in progress.
>
> If this looks good, I'll clean it up for a more detailed review.
>
> Thanks
> Charles


Re: [gomp4] Add tables generation

2014-05-06 Thread Ilya Verbin
On 05 Apr 17:22, Bernd Schmidt wrote:
> Things seemed to work over here, but now I'm not certain whether the
> __start_/__stop_ functionality is GNU ld specific? Maybe we should
> just go back to the previous version of this patch which didn't try
> to use this.
> 
> Bernd

This approach does not work with shared libraries.

The automatically inserted symbols have GLOBAL binding, therefore the
__start_/__stop_ from the executable overwrite the respective symbols in DSO.

Here is a simple example with 2 DSOs and one executable.  The function
GOMP_offload_register is called with the following pointers in HOST_TABLE:

1. (funcs 0x604880:0x604898, vars 0x604840:0x604880)
2. (funcs 0x604880:0x604898, vars 0x604840:0x604880)
3. (funcs 0x604880:0x604898, vars 0x604840:0x604880)

But with "manually" added start/stop and LOCAL binding everything works fine:

1. (funcs 0x7f286b425530:0x7f286b425540, vars 0x7f286b425540:0x7f286b425540)
2. (funcs 0x7f286b8624a0:0x7f286b8624b0, vars 0x7f286b8624b0:0x7f286b8624b0)
3. (funcs 0x604760:0x604778, vars 0x604780:0x6047c0)

  -- Ilya


Re: [AArch64][4.8 backport] Fix default CPU architecture flags

2014-05-06 Thread Marcus Shawcroft
On 6 May 2014 15:25, Kyrill Tkachov  wrote:

> 2014-05-06  Kyrylo Tkachov  
>
> * config.gcc (aarch64*-*-*): Use ISA flags from aarch64-arches.def.
> Do not define target_cpu_default2 to generic.

OK /Marcus


we are starting the wide int merge

2014-05-06 Thread Kenneth Zadeck
please hold off on committing patches for the next couple of hours as we 
have a very large merge to do.

thanks.

kenny


Re: [PATCH, Pointer Bounds Checker 1/x] Pointer bounds type and mode

2014-05-06 Thread Jeff Law

On 05/06/14 07:31, Richard Biener wrote:

On Tue, May 6, 2014 at 2:10 PM, Ilya Enkovich  wrote:

2014-04-16 15:00 GMT+04:00 Ilya Enkovich :

Hi,

This patch restarts the series for introducing Pointer Bounds Checker 
instrumentation and supporting Intel Memory Protection Extension (MPX) 
technology.  Detailed description is on GCC Wiki page: 
http://gcc.gnu.org/wiki/Intel%20MPX%20support%20in%20the%20GCC%20compiler.

The first patch introduces pointer bounds type and mode.  It was approved 
earlier for 4.9 and had no significant changes since then.  I'll assume patch 
is OK if no objections arise.

Patch was bootstrapped and tested for linux-x86_64.

Thanks,
Ilya
--
gcc/

2014-04-16  Ilya Enkovich  

 * mode-classes.def (MODE_POINTER_BOUNDS): New.
 * tree.def (POINTER_BOUNDS_TYPE): New.
 * genmodes.c (complete_mode): Support MODE_POINTER_BOUNDS.
 (POINTER_BOUNDS_MODE): New.
 (make_pointer_bounds_mode): New.
 * machmode.h (POINTER_BOUNDS_MODE_P): New.
 * stor-layout.c (int_mode_for_mode): Support MODE_POINTER_BOUNDS.
 (layout_type): Support POINTER_BOUNDS_TYPE.
 * tree-pretty-print.c (dump_generic_node): Support POINTER_BOUNDS_TYPE.
 * tree.c (build_int_cst_wide): Support POINTER_BOUNDS_TYPE.
 (type_contains_placeholder_1): Likewise.
 * tree.h (POINTER_BOUNDS_TYPE_P): New.
 * varasm.c (output_constant): Support POINTER_BOUNDS_TYPE.
 * doc/rtl.texi (MODE_POINTER_BOUNDS): New.


diff --git a/gcc/doc/rtl.texi b/gcc/doc/rtl.texi
index 20b7187..3a1014d 100644
--- a/gcc/doc/rtl.texi
+++ b/gcc/doc/rtl.texi
@@ -1382,6 +1382,12 @@ any @code{CC_MODE} modes listed in the 
@file{@var{machine}-modes.def}.
  @xref{Jump Patterns},
  also see @ref{Condition Code}.

+@findex MODE_POINTER_BOUNDS
+@item MODE_POINTER_BOUNDS
+Pointer bounds modes.  Used to represent values of pointer bounds type.
+Operations in these modes may be executed as NOPs depending on hardware
+features and environment setup.
+
  @findex MODE_RANDOM
  @item MODE_RANDOM
  This is a catchall mode class for modes which don't fit into the above
diff --git a/gcc/genmodes.c b/gcc/genmodes.c
index 8cc3cde..9d0b413 100644
--- a/gcc/genmodes.c
+++ b/gcc/genmodes.c
@@ -333,6 +333,7 @@ complete_mode (struct mode_data *m)
break;

  case MODE_INT:
+case MODE_POINTER_BOUNDS:
  case MODE_FLOAT:
  case MODE_DECIMAL_FLOAT:
  case MODE_FRACT:
@@ -534,6 +535,19 @@ make_special_mode (enum mode_class cl, const char *name,
new_mode (cl, name, file, line);
  }

+#define POINTER_BOUNDS_MODE(N, Y) \
+  make_pointer_bounds_mode (#N, Y, __FILE__, __LINE__)
+
+static void ATTRIBUTE_UNUSED
+make_pointer_bounds_mode (const char *name,
+ unsigned int bytesize,
+ const char *file, unsigned int line)
+{
+  struct mode_data *m = new_mode (MODE_POINTER_BOUNDS, name, file, line);
+  m->bytesize = bytesize;
+}
+
+
  #define INT_MODE(N, Y) FRACTIONAL_INT_MODE (N, -1U, Y)
  #define FRACTIONAL_INT_MODE(N, B, Y) \
make_int_mode (#N, B, Y, __FILE__, __LINE__)
diff --git a/gcc/machmode.h b/gcc/machmode.h
index bc5d901..cbe5042 100644
--- a/gcc/machmode.h
+++ b/gcc/machmode.h
@@ -174,6 +174,9 @@ extern const unsigned char mode_class[NUM_MACHINE_MODES];
 || CLASS == MODE_ACCUM  \
 || CLASS == MODE_UACCUM)

+#define POINTER_BOUNDS_MODE_P(MODE)  \
+  (GET_MODE_CLASS (MODE) == MODE_POINTER_BOUNDS)
+
  /* Get the size in bytes and bits of an object of mode MODE.  */

  extern CONST_MODE_SIZE unsigned char mode_size[NUM_MACHINE_MODES];
diff --git a/gcc/mode-classes.def b/gcc/mode-classes.def
index 9c6a8bb..b645484 100644
--- a/gcc/mode-classes.def
+++ b/gcc/mode-classes.def
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
DEF_MODE_CLASS (MODE_CC),/* condition code in a register */ \
DEF_MODE_CLASS (MODE_INT),   /* integer */  \
DEF_MODE_CLASS (MODE_PARTIAL_INT),   /* integer with padding bits */\
+  DEF_MODE_CLASS (MODE_POINTER_BOUNDS), /* bounds */   \
DEF_MODE_CLASS (MODE_FRACT), /* signed fractional number */ \
DEF_MODE_CLASS (MODE_UFRACT),/* unsigned fractional number 
*/   \
DEF_MODE_CLASS (MODE_ACCUM), /* signed accumulator */   \
diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
index 084d195..af0ab88 100644
--- a/gcc/stor-layout.c
+++ b/gcc/stor-layout.c
@@ -386,6 +386,7 @@ int_mode_for_mode (enum machine_mode mode)
  case MODE_VECTOR_ACCUM:
  case MODE_VECTOR_UFRACT:
  case MODE_VECTOR_UACCUM:
+case MODE_POINTER_BOUNDS:
mode = mode_for_size (GET_MODE_BITSIZE (mode), MODE_INT, 0);
break;

@@ -2124,6 +2125,11 @@ layout_type (tree type)
SET_TYPE_MODE (type, VOIDmode);
break;

+case POINTER_BOUNDS_TYPE:
+  TYPE_SIZE (type) = bitsize_int (GET_MODE_BITSIZE (TYPE_MODE (t

Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-06 Thread Nicholas Clifton

Hi Jakub,


But what will this do on targets where POINTER_SIZE is smaller than
BITS_PER_WORD?  E.g. I think some options on s390 or ppc.
If you want it to be always 5 pointers, then you want
   tmp = size_int (4);
and not something else, otherwise it really depends on how exactly it is
used, perhaps it can be 5 * MAX (BITS_PER_WORD / POINTER_SIZE, 1) - 1
or whatever else, but 5 * POINTER_SIZE / BITS_PER_WORD is definitely wrong.


Ah -I had not considered this.

OK - how about this revision ?  It allocates a buffer big enough to hold 
5 things, either pointers or words, whichever is bigger.  The comments 
are suitably adjusted as well.


Cheers
  Nick


Index: gcc/except.c
===
--- gcc/except.c(revision 210096)
+++ gcc/except.c(working copy)
@@ -286,8 +286,9 @@
   tmp = size_int (FIRST_PSEUDO_REGISTER + 2 - 1);
 #endif
 #else
-  /* builtin_setjmp takes a pointer to 5 words.  */
-  tmp = size_int (5 * BITS_PER_WORD / POINTER_SIZE - 1);
+  /* builtin_setjmp uses a buffer big enough to hold
+5 pointers or 5 words, whichever is bigger.  */
+  tmp = size_int ((5 * MAX (POINTER_SIZE, BITS_PER_WORD)) / 
BITS_PER_WORD - 1);

 #endif
   tmp = build_index_type (tmp);
   tmp = build_array_type (ptr_type_node, tmp);
Index: gcc/builtins.c
===
--- gcc/builtins.c  (revision 210096)
+++ gcc/builtins.c  (working copy)
@@ -977,10 +977,10 @@
   emit_insn (gen_blockage ());
 }

-/* __builtin_longjmp is passed a pointer to an array of five words (not
-   all will be used on all machines).  It operates similarly to the C
-   library function of the same name, but is more efficient.  Much of
-   the code below is copied from the handling of non-local gotos.  */
+/* __builtin_longjmp is passed a pointer to an array of five word/pointer
+   sized entries, not all will be used on all machines.  It operates 
similarly

+   to the C library function of the same name, but is more efficient.  Much
+   of the code below is copied from the handling of non-local gotos.  */

 static void
 expand_builtin_longjmp (rtx buf_addr, rtx value)
@@ -1204,10 +1204,10 @@
   return const0_rtx;
 }

-/* __builtin_update_setjmp_buf is passed a pointer to an array of five 
words
-   (not all will be used on all machines) that was passed to 
__builtin_setjmp.

-   It updates the stack pointer in that block to correspond to the current
-   stack pointer.  */
+/* __builtin_update_setjmp_buf is passed a pointer to an array of five
+   entries (not all will be used on all machines) that was passed to
+   __builtin_setjmp.  It updates the stack pointer in that block to
+   correspond to the current stack pointer.  */

 static void
 expand_builtin_update_setjmp_buf (rtx buf_addr)
@@ -6205,8 +6205,8 @@
   gcc_unreachable ();

 case BUILT_IN_SETJMP_SETUP:
-  /* __builtin_setjmp_setup is passed a pointer to an array of five 
words

-  and the receiver label.  */
+  /* __builtin_setjmp_setup is passed a pointer to an array of five
+entries and the receiver label.  */
   if (validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE))
{
  rtx buf_addr = expand_expr (CALL_EXPR_ARG (exp, 0), subtarget,
@@ -6239,9 +6239,9 @@
}
   break;

-  /* __builtin_longjmp is passed a pointer to an array of five words.
-It's similar to the C library longjmp function but works with
-__builtin_setjmp above.  */
+  /* __builtin_longjmp is passed a pointer to an array of five
+entries.  It's similar to the C library longjmp function
+but works with __builtin_setjmp above.  */
 case BUILT_IN_LONGJMP:
   if (validate_arglist (exp, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE))
{
Index: gcc/doc/md.texi
===
--- gcc/doc/md.texi (revision 210096)
+++ gcc/doc/md.texi (working copy)
@@ -6112,10 +6112,15 @@
 A typical reason why you might need this pattern is if some value, such
 as a pointer to a global table, must be restored.  Though it is
 preferred that the pointer value be recalculated if possible (given the
-address of a label for instance).  The single argument is a pointer to
-the @code{jmp_buf}.  Note that the buffer is five words long and that
-the first three are normally used by the generic mechanism.
+address of a label for instance).

+The single argument is a pointer to the @code{jmp_buf}.  This buffer
+is big enough to hold five @code{word_mode} or @code{Pmode} sized
+entries, whichever is bigger.  The generic machanism uses just the
+first three entries, (to hold the frame pointer, return address and
+stack pointer respectively), but target specific code can use all five
+of them.
+
 @cindex @code{builtin_setjmp_receiver} instruction pattern
 @item @samp{builtin_setjmp_receiver}
 This pattern, if defined, co

Re: [Patch,Microblaze]: Added Break Handler Support

2014-05-06 Thread Michael Eager

On 05/06/14 06:10, Ajit Kumar Agarwal wrote:

Hello All:

Could you please review this patch.

[PATCH] Break handler is used to support a normal hardware break.
This is similar to interrupt_handler except that RTBD should be used instead of 
RTID.

Changelog

2014-05-06 Nagaraju 

* gcc/config/microblaze/microblaze-protos.h : Declaration of 
microblaze_is_break_handler.
* gcc/config/microblaze/microblaze.c :  Add functions to support break handler
* gcc/config/microblaze/microblaze.h :  Add required defination declaration.
* gcc/config/microblaze/microblaze.md : Add pattern for generating instruction 
rtbd.


Please follow conventions for ChangeLog.  For example
  * config/microblaze/microblaze.c (microblaze_break_function_p): New.

See http://www.gnu.org/prep/standards/html_node/Change-Logs.html#Change-Logs

Add documentation for _break_handler.

Add test case(s).

Code formatting issues:
+  a = lookup_attribute("break_handler",DECL_ATTRIBUTES (func));
Space before left paren, after comma.
+  else if (break_handler && strcmp (BREAK_HANDLER_NAME, fnname))
+   fputs ("_break_handler", file);
Incorrect indent.
+if (microblaze_is_break_handler ())
+return "rtbd\tr16, 0\;%#";
Ditto.
+if (microblaze_is_break_handler ())
+return "rtbd\tr16, 0\;%#";
Ditto.


Mailing list conventions do not permit restrictive annotations.


--
Michael Eagerea...@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306  650-325-8077


Re: [PATCH, PR52252] Vectorization for load/store groups of size 3.

2014-05-06 Thread Richard Biener
On Tue, 6 May 2014, Evgeny Stupachenko wrote:

> Patch with fixes attached.

Ok if bootstrap/regtest passes.

Thanks,
Richard.

> Currently if-structure is as following:
> +  if (count == 3)
> ...
> +  else
> +   {
> + /* If length is not equal to 3 then only power of 2 is supported.  
> */
> + gcc_assert (exact_log2 (count) != -1);
> 
> For stores group I've created another mail thread.
> 
> Thanks,
> Evgeny
> 
> 
> On Tue, May 6, 2014 at 3:47 PM, Richard Biener  wrote:
> > On Tue, 6 May 2014, Evgeny Stupachenko wrote:
> >
> >> The patch on cost model was successfully committed.
> >> I've separated the rest part of the patch on loads/stores group into
> >> 2: on loads group and on stores group.
> >> Below is first part on loads group.
> >>
> >> Bootstrap and make check passed on x86.
> >>
> >> Is it ok?
> >>
> >> ChangeLog:
> >>
> >> 2014-05-06  Evgeny Stupachenko  
> >>
> >> * tree-vect-data-refs.c (vect_grouped_load_supported): New
> >> check for loads group of length 3.
> >> (vect_permute_load_chain): New permutations for loads group of
> >> length 3.
> >> * tree-vect-stmts.c (vect_model_load_cost): Change cost
> >> of vec_perm_shuffle for the new permutations.
> >>
> >> ChangeLog for testsuite:
> >>
> >> 2014-05-06  Evgeny Stupachenko  
> >>
> >>PR tree-optimization/52252
> >>* gcc.dg/vect/pr52252-ld.c: Test on loads group of size 3.
> >>
> >> diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
> >> index 274cdbd..feafb38 100644
> >> --- a/gcc/tree-vect-data-refs.c
> >> +++ b/gcc/tree-vect-data-refs.c
> >> @@ -4812,36 +4812,74 @@ vect_grouped_load_supported (tree vectype,
> >> unsigned HOST_WIDE_INT count)
> >>  {
> >>enum machine_mode mode = TYPE_MODE (vectype);
> >>
> >> -  /* vect_permute_load_chain requires the group size to be a power of 
> >> two.  */
> >> -  if (exact_log2 (count) == -1)
> >> +  /* vect_permute_load_chain requires the group size to be equal to 3 or
> >> + be a power of two.  */
> >> +  if (count != 3 && exact_log2 (count) == -1)
> >>  {
> >>if (dump_enabled_p ())
> >> dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
> >> - "the size of the group of accesses"
> >> - " is not a power of 2\n");
> >> +"the size of the group of accesses"
> >> +" is not a power of 2 or not eqaul to 3\n");
> >
> > equal
> >
> >>return false;
> >>  }
> >>
> >>/* Check that the permutation is supported.  */
> >>if (VECTOR_MODE_P (mode))
> >>  {
> >> -  unsigned int i, nelt = GET_MODE_NUNITS (mode);
> >> +  unsigned int i, j, nelt = GET_MODE_NUNITS (mode);
> >>unsigned char *sel = XALLOCAVEC (unsigned char, nelt);
> >>
> >> -  for (i = 0; i < nelt; i++)
> >> -   sel[i] = i * 2;
> >> -  if (can_vec_perm_p (mode, false, sel))
> >> +  if (exact_log2 (count) != -1)
> >> {
> >>   for (i = 0; i < nelt; i++)
> >> -   sel[i] = i * 2 + 1;
> >> +   sel[i] = i * 2;
> >>   if (can_vec_perm_p (mode, false, sel))
> >> -   return true;
> >> +   {
> >> + for (i = 0; i < nelt; i++)
> >> +   sel[i] = i * 2 + 1;
> >> + if (can_vec_perm_p (mode, false, sel))
> >> +   return true;
> >> +   }
> >> +}
> >> +  else if (count == 3)
> >
> > Please structure this if as having special cases first and then an
> > else with gcc_assert (exact_log2 (count)).
> >
> >> +   {
> >> + unsigned int k;
> >> + for (k = 0; k < 3; k++)
> >> +   {
> >> + for (i = 0; i < nelt; i++)
> >> +   if (3 * i + k < 2 * nelt)
> >> + sel[i] = 3 * i + k;
> >> +   else
> >> + sel[i] = 0;
> >> + if (!can_vec_perm_p (mode, false, sel))
> >> +   {
> >> + if (dump_enabled_p ())
> >> +   dump_printf_loc (MSG_MISSED_OPTIMIZATION, 
> >> vect_location,
> >> +"shuffle of 3 loads is not supported 
> >> by \
> >> +target\n");
> >
> > Don't use multi-line strings but do
> >
> > "shuffle of ..."
> > "target\n");
> >
> > instead.
> >
> >> +   return false;
> >> +   }
> >> + for (i = 0, j = 0; i < nelt; i++)
> >> +   if (3 * i + k < 2 * nelt)
> >> + sel[i] = i;
> >> +   else
> >> + sel[i] = nelt + ((nelt + k) % 3) + 3 * (j++);
> >> + if (!can_vec_perm_p (mode, false, sel))
> >> +   {
> >> + if (dump_enabled_p ())
> >> +   dump_printf_loc (MSG_MISSED_OPTIMIZATION, 
> >> vect_location,
> >> +"shuffle of 3 loads is 

Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-06 Thread Jakub Jelinek
On Tue, May 06, 2014 at 03:34:37PM +0100, Nicholas Clifton wrote:
> --- gcc/except.c  (revision 210096)
> +++ gcc/except.c  (working copy)
> @@ -286,8 +286,8 @@
>tmp = size_int (FIRST_PSEUDO_REGISTER + 2 - 1);
>  #endif
>  #else
> -  /* builtin_setjmp takes a pointer to 5 words.  */
> -  tmp = size_int (5 * BITS_PER_WORD / POINTER_SIZE - 1);
> +  /* builtin_setjmp uses a buffer big enough to hold 5 pointers.  */
> +  tmp = size_int (5 * POINTER_SIZE / BITS_PER_WORD - 1);

But what will this do on targets where POINTER_SIZE is smaller than
BITS_PER_WORD?  E.g. I think some options on s390 or ppc.
If you want it to be always 5 pointers, then you want
  tmp = size_int (4);
and not something else, otherwise it really depends on how exactly it is
used, perhaps it can be 5 * MAX (BITS_PER_WORD / POINTER_SIZE, 1) - 1
or whatever else, but 5 * POINTER_SIZE / BITS_PER_WORD is definitely wrong.

>  #endif
>tmp = build_index_type (tmp);
>tmp = build_array_type (ptr_type_node, tmp);

Jakub


[PATCH2/2, PR52252] Vectorization for load/store groups of size 3.

2014-05-06 Thread Evgeny Stupachenko
2nd part of patch is on stores group.
Bootstrap and make check passed on x86.

Is it ok?

2014-05-06  Evgeny Stupachenko  

* tree-vect-data-refs.c (vect_grouped_store_supported): New
check for storess group of length 3.
(vect_permute_store_chain): New permutations for storess group of
length 3.
* tree-vect-stmts.c (vect_model_store_cost): Change cost
of vec_perm_shuffle for the new permutations.

ChangeLog for testsuite:

2014-05-06  Evgeny Stupachenko  

   PR tree-optimization/52252
   * gcc.dg/vect/pr52252-st.c: Test on stores group of size 3.

diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index ef710cf..fb0e30d 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -4365,13 +4365,14 @@ vect_grouped_store_supported (tree vectype,
unsigned HOST_WIDE_INT count)
 {
   enum machine_mode mode = TYPE_MODE (vectype);

-  /* vect_permute_store_chain requires the group size to be a power of two.  */
-  if (exact_log2 (count) == -1)
+  /* vect_permute_store_chain requires the group size to be equal to 3 or
+ be a power of two.  */
+  if (count != 3 && exact_log2 (count) == -1)
 {
   if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "the size of the group of accesses"
- " is not a power of 2\n");
+"the size of the group of accesses"
+" is not a power of 2 or not eqaul to 3\n");
   return false;
 }

@@ -4380,23 +4381,76 @@ vect_grouped_store_supported (tree vectype,
unsigned HOST_WIDE_INT count)
 {
   unsigned int i, nelt = GET_MODE_NUNITS (mode);
   unsigned char *sel = XALLOCAVEC (unsigned char, nelt);
-  for (i = 0; i < nelt / 2; i++)
+
+  if (count == 3)
{
- sel[i * 2] = i;
- sel[i * 2 + 1] = i + nelt;
+ unsigned int j0 = 0, j1 = 0, j2 = 0;
+ unsigned int i, j;
+
+ for (j = 0; j < 3; j++)
+   {
+ int nelt0 = ((3 - j) * nelt) % 3;
+ int nelt1 = ((3 - j) * nelt + 1) % 3;
+ int nelt2 = ((3 - j) * nelt + 2) % 3;
+ for (i = 0; i < nelt; i++)
+   {
+ if (3 * i + nelt0 < nelt)
+   sel[3 * i + nelt0] = j0++;
+ if (3 * i + nelt1 < nelt)
+   sel[3 * i + nelt1] = nelt + j1++;
+ if (3 * i + nelt2 < nelt)
+   sel[3 * i + nelt2] = 0;
+   }
+ if (!can_vec_perm_p (mode, false, sel))
+   {
+ if (dump_enabled_p ())
+   dump_printf (MSG_MISSED_OPTIMIZATION,
+"permutaion op not supported by target.\n");
+ return false;
+   }
+
+ for (i = 0; i < nelt; i++)
+   {
+ if (3 * i + nelt0 < nelt)
+   sel[3 * i + nelt0] = 3 * i + nelt0;
+ if (3 * i + nelt1 < nelt)
+   sel[3 * i + nelt1] = 3 * i + nelt1;
+ if (3 * i + nelt2 < nelt)
+   sel[3 * i + nelt2] = nelt + j2++;
+   }
+ if (!can_vec_perm_p (mode, false, sel))
+   {
+ if (dump_enabled_p ())
+   dump_printf (MSG_MISSED_OPTIMIZATION,
+"permutaion op not supported by target.\n");
+ return false;
+   }
+   }
+ return true;
}
-  if (can_vec_perm_p (mode, false, sel))
+  else
{
- for (i = 0; i < nelt; i++)
-   sel[i] += nelt / 2;
- if (can_vec_perm_p (mode, false, sel))
-   return true;
+ /* If length is not equal to 3 then only power of 2 is supported.  */
+ gcc_assert (exact_log2 (count) != -1);
+
+ for (i = 0; i < nelt / 2; i++)
+   {
+ sel[i * 2] = i;
+ sel[i * 2 + 1] = i + nelt;
+   }
+   if (can_vec_perm_p (mode, false, sel))
+ {
+   for (i = 0; i < nelt; i++)
+ sel[i] += nelt / 2;
+   if (can_vec_perm_p (mode, false, sel))
+ return true;
+ }
}
 }

   if (dump_enabled_p ())
 dump_printf (MSG_MISSED_OPTIMIZATION,
- "interleave op not supported by target.\n");
+"permutaion op not supported by target.\n");
   return false;
 }

@@ -4416,9 +4470,9 @@ vect_store_lanes_supported (tree vectype,
unsigned HOST_WIDE_INT count)
 /* Function vect_permute_store_chain.

Given a chain of interleaved stores in DR_CHAIN of LENGTH that must be
-   a power of 2, generate interleave_high/low stmts to reorder the data
-   correctly for the stores.  Return the final references for stores in
-   RESULT_CHAIN.
+   a power of 2 or equal to 3, generate interleave_high/low stmts to reorder
+   the

Re: [PATCH, PR52252] Vectorization for load/store groups of size 3.

2014-05-06 Thread Evgeny Stupachenko
Patch with fixes attached.
Currently if-structure is as following:
+  if (count == 3)
...
+  else
+   {
+ /* If length is not equal to 3 then only power of 2 is supported.  */
+ gcc_assert (exact_log2 (count) != -1);

For stores group I've created another mail thread.

Thanks,
Evgeny


On Tue, May 6, 2014 at 3:47 PM, Richard Biener  wrote:
> On Tue, 6 May 2014, Evgeny Stupachenko wrote:
>
>> The patch on cost model was successfully committed.
>> I've separated the rest part of the patch on loads/stores group into
>> 2: on loads group and on stores group.
>> Below is first part on loads group.
>>
>> Bootstrap and make check passed on x86.
>>
>> Is it ok?
>>
>> ChangeLog:
>>
>> 2014-05-06  Evgeny Stupachenko  
>>
>> * tree-vect-data-refs.c (vect_grouped_load_supported): New
>> check for loads group of length 3.
>> (vect_permute_load_chain): New permutations for loads group of
>> length 3.
>> * tree-vect-stmts.c (vect_model_load_cost): Change cost
>> of vec_perm_shuffle for the new permutations.
>>
>> ChangeLog for testsuite:
>>
>> 2014-05-06  Evgeny Stupachenko  
>>
>>PR tree-optimization/52252
>>* gcc.dg/vect/pr52252-ld.c: Test on loads group of size 3.
>>
>> diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
>> index 274cdbd..feafb38 100644
>> --- a/gcc/tree-vect-data-refs.c
>> +++ b/gcc/tree-vect-data-refs.c
>> @@ -4812,36 +4812,74 @@ vect_grouped_load_supported (tree vectype,
>> unsigned HOST_WIDE_INT count)
>>  {
>>enum machine_mode mode = TYPE_MODE (vectype);
>>
>> -  /* vect_permute_load_chain requires the group size to be a power of two.  
>> */
>> -  if (exact_log2 (count) == -1)
>> +  /* vect_permute_load_chain requires the group size to be equal to 3 or
>> + be a power of two.  */
>> +  if (count != 3 && exact_log2 (count) == -1)
>>  {
>>if (dump_enabled_p ())
>> dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
>> - "the size of the group of accesses"
>> - " is not a power of 2\n");
>> +"the size of the group of accesses"
>> +" is not a power of 2 or not eqaul to 3\n");
>
> equal
>
>>return false;
>>  }
>>
>>/* Check that the permutation is supported.  */
>>if (VECTOR_MODE_P (mode))
>>  {
>> -  unsigned int i, nelt = GET_MODE_NUNITS (mode);
>> +  unsigned int i, j, nelt = GET_MODE_NUNITS (mode);
>>unsigned char *sel = XALLOCAVEC (unsigned char, nelt);
>>
>> -  for (i = 0; i < nelt; i++)
>> -   sel[i] = i * 2;
>> -  if (can_vec_perm_p (mode, false, sel))
>> +  if (exact_log2 (count) != -1)
>> {
>>   for (i = 0; i < nelt; i++)
>> -   sel[i] = i * 2 + 1;
>> +   sel[i] = i * 2;
>>   if (can_vec_perm_p (mode, false, sel))
>> -   return true;
>> +   {
>> + for (i = 0; i < nelt; i++)
>> +   sel[i] = i * 2 + 1;
>> + if (can_vec_perm_p (mode, false, sel))
>> +   return true;
>> +   }
>> +}
>> +  else if (count == 3)
>
> Please structure this if as having special cases first and then an
> else with gcc_assert (exact_log2 (count)).
>
>> +   {
>> + unsigned int k;
>> + for (k = 0; k < 3; k++)
>> +   {
>> + for (i = 0; i < nelt; i++)
>> +   if (3 * i + k < 2 * nelt)
>> + sel[i] = 3 * i + k;
>> +   else
>> + sel[i] = 0;
>> + if (!can_vec_perm_p (mode, false, sel))
>> +   {
>> + if (dump_enabled_p ())
>> +   dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
>> +"shuffle of 3 loads is not supported by 
>> \
>> +target\n");
>
> Don't use multi-line strings but do
>
> "shuffle of ..."
> "target\n");
>
> instead.
>
>> +   return false;
>> +   }
>> + for (i = 0, j = 0; i < nelt; i++)
>> +   if (3 * i + k < 2 * nelt)
>> + sel[i] = i;
>> +   else
>> + sel[i] = nelt + ((nelt + k) % 3) + 3 * (j++);
>> + if (!can_vec_perm_p (mode, false, sel))
>> +   {
>> + if (dump_enabled_p ())
>> +   dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
>> +"shuffle of 3 loads is not supported by 
>> \
>> +target\n");
>
> Likewise.
>
>> + return false;
>> +   }
>> +   }
>> + return true;
>> }
>>  }
>>
>>if (dump_enabled_p ())
>>  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
>> - "extract even/odd not supported by target\n");
>> +

Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-06 Thread Richard Biener
On Tue, May 6, 2014 at 4:34 PM, Nicholas Clifton  wrote:
> Hi Jakub,
>
>
>>> /* builtin_setjmp takes a pointer to 5 words.  */
>>> -  tmp = size_int (5 * BITS_PER_WORD / POINTER_SIZE - 1);
>>> +  tmp = size_int (5 * POINTER_SIZE / BITS_PER_WORD - 1);
>
>
>> That doesn't look correct to me.  If the code wants to create 5 words long
>> array, but with pointer elements (instead of word sized elements), then
>> 5 * BITS_PER_WORD is the desired size in bits of the buffer, POINTER_SIZE
>> is how many bits each void *array[...] element occupies and thus
>> 5 * BITS_PER_WORD / POINTER_SIZE - 1 is the right last element, so I'd
>> say the previous expression is the right one.  Perhaps you want to round
>> up
>> rather than down, but certainly not swap the division operands.
>>
>> Now, if the code actually expects 5 pointers, rather than 5 words, or
>> something else, then you'd at least need to also fix the comment.
>
>
> The contents of the builtin setjmp buffer do not appear to be explicitly
> documented anywhere.   The nearest that I could come was this line in the
> description of builtin_setjmp_setup in gcc/doc/md.texi:
>
>   Note that the buffer is five words long and that
>   the first three are normally used by the generic
>   mechanism.
>
> But a comment in gcc/except.c:expand_builtin_setjmp_setup() says that the
> first three entries in the buffer are for the frame pointer, the address of
> the return label and the stack pointer.  This appears to suggest that it is
> 3 pointers that are stored in the buffer not 3 words.
>
> Given that pointers can be bigger than words, and that if a pointer is 2
> words long then even a 5 word buffer will be too small, I still feel that my
> patch is correct.  So here is a revised patch which updates the comments in
> all of the places that I could find them, adds a description of
> builtin_setjmp buffer to the documentation, and includes my original, not
> quite so obvious fix.

As a pointer can also be smaller than a word maybe take the maximum of
both readings?  But Eric should know what was intended here ...

Richard.

>
> OK to apply ?
>
> Cheers
>   Nick
>
> gcc/ChangeLog
> 2014-05-06  Nick Clifton  
>
> * builtins.c: Update description of buffer used by builtin setjmp
> and longjmp.
> * doc/md.texi (builtin_setjmp_setup): Likewise.
>
> * except.c (init_eh): Fix computation of builtin setjmp buffer
> size.
>
> Index: gcc/builtins.c
> ===
> --- gcc/builtins.c  (revision 210096)
> +++ gcc/builtins.c  (working copy)
> @@ -977,10 +977,10 @@
>emit_insn (gen_blockage ());
>  }
>
> -/* __builtin_longjmp is passed a pointer to an array of five words (not
> -   all will be used on all machines).  It operates similarly to the C
> -   library function of the same name, but is more efficient.  Much of
> -   the code below is copied from the handling of non-local gotos.  */
> +/* __builtin_longjmp is passed a pointer to an array of five Pmode sized
> +   entries (not all will be used on all machines).  It operates similarly
> +   to the C library function of the same name, but is more efficient.  Much
> +   of the code below is copied from the handling of non-local gotos.  */
>
>  static void
>  expand_builtin_longjmp (rtx buf_addr, rtx value)
> @@ -1204,10 +1204,10 @@
>return const0_rtx;
>  }
>
> -/* __builtin_update_setjmp_buf is passed a pointer to an array of five
> words
> -   (not all will be used on all machines) that was passed to
> __builtin_setjmp.
> -   It updates the stack pointer in that block to correspond to the current
> -   stack pointer.  */
> +/* __builtin_update_setjmp_buf is passed a pointer to an array of five
> Pmode
> +   sized entries (not all will be used on all machines) that was passed to
> +   __builtin_setjmp.  It updates the stack pointer in that block to
> correspond
> +   to the current stack pointer.  */
>
>  static void
>  expand_builtin_update_setjmp_buf (rtx buf_addr)
> @@ -6205,8 +6205,8 @@
>gcc_unreachable ();
>
>  case BUILT_IN_SETJMP_SETUP:
> -  /* __builtin_setjmp_setup is passed a pointer to an array of five
> words
> -  and the receiver label.  */
> +  /* __builtin_setjmp_setup is passed a pointer to an array of five
> +Pmode sized entries and the receiver label.  */
>if (validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE))
> {
>   rtx buf_addr = expand_expr (CALL_EXPR_ARG (exp, 0), subtarget,
> @@ -6239,9 +6239,9 @@
> }
>break;
>
> -  /* __builtin_longjmp is passed a pointer to an array of five words.
> -It's similar to the C library longjmp function but works with
> -__builtin_setjmp above.  */
> +  /* __builtin_longjmp is passed a pointer to an array of five Pmode
> +sized entries.  It's similar to the C library longjmp function
> +but works with __builtin_setjmp above.  */
>

Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-06 Thread Nicholas Clifton

Hi Jakub,


/* builtin_setjmp takes a pointer to 5 words.  */
-  tmp = size_int (5 * BITS_PER_WORD / POINTER_SIZE - 1);
+  tmp = size_int (5 * POINTER_SIZE / BITS_PER_WORD - 1);



That doesn't look correct to me.  If the code wants to create 5 words long
array, but with pointer elements (instead of word sized elements), then
5 * BITS_PER_WORD is the desired size in bits of the buffer, POINTER_SIZE
is how many bits each void *array[...] element occupies and thus
5 * BITS_PER_WORD / POINTER_SIZE - 1 is the right last element, so I'd
say the previous expression is the right one.  Perhaps you want to round up
rather than down, but certainly not swap the division operands.

Now, if the code actually expects 5 pointers, rather than 5 words, or
something else, then you'd at least need to also fix the comment.


The contents of the builtin setjmp buffer do not appear to be explicitly 
documented anywhere.   The nearest that I could come was this line in 
the description of builtin_setjmp_setup in gcc/doc/md.texi:


  Note that the buffer is five words long and that
  the first three are normally used by the generic
  mechanism.

But a comment in gcc/except.c:expand_builtin_setjmp_setup() says that 
the first three entries in the buffer are for the frame pointer, the 
address of the return label and the stack pointer.  This appears to 
suggest that it is 3 pointers that are stored in the buffer not 3 words.


Given that pointers can be bigger than words, and that if a pointer is 2 
words long then even a 5 word buffer will be too small, I still feel 
that my patch is correct.  So here is a revised patch which updates the 
comments in all of the places that I could find them, adds a description 
of builtin_setjmp buffer to the documentation, and includes my original, 
not quite so obvious fix.


OK to apply ?

Cheers
  Nick

gcc/ChangeLog
2014-05-06  Nick Clifton  

* builtins.c: Update description of buffer used by builtin setjmp
and longjmp.
* doc/md.texi (builtin_setjmp_setup): Likewise.
* except.c (init_eh): Fix computation of builtin setjmp buffer
size.

Index: gcc/builtins.c
===
--- gcc/builtins.c  (revision 210096)
+++ gcc/builtins.c  (working copy)
@@ -977,10 +977,10 @@
   emit_insn (gen_blockage ());
 }

-/* __builtin_longjmp is passed a pointer to an array of five words (not
-   all will be used on all machines).  It operates similarly to the C
-   library function of the same name, but is more efficient.  Much of
-   the code below is copied from the handling of non-local gotos.  */
+/* __builtin_longjmp is passed a pointer to an array of five Pmode sized
+   entries (not all will be used on all machines).  It operates similarly
+   to the C library function of the same name, but is more efficient.  Much
+   of the code below is copied from the handling of non-local gotos.  */

 static void
 expand_builtin_longjmp (rtx buf_addr, rtx value)
@@ -1204,10 +1204,10 @@
   return const0_rtx;
 }

-/* __builtin_update_setjmp_buf is passed a pointer to an array of five 
words
-   (not all will be used on all machines) that was passed to 
__builtin_setjmp.

-   It updates the stack pointer in that block to correspond to the current
-   stack pointer.  */
+/* __builtin_update_setjmp_buf is passed a pointer to an array of five 
Pmode

+   sized entries (not all will be used on all machines) that was passed to
+   __builtin_setjmp.  It updates the stack pointer in that block to 
correspond

+   to the current stack pointer.  */

 static void
 expand_builtin_update_setjmp_buf (rtx buf_addr)
@@ -6205,8 +6205,8 @@
   gcc_unreachable ();

 case BUILT_IN_SETJMP_SETUP:
-  /* __builtin_setjmp_setup is passed a pointer to an array of five 
words

-  and the receiver label.  */
+  /* __builtin_setjmp_setup is passed a pointer to an array of five
+Pmode sized entries and the receiver label.  */
   if (validate_arglist (exp, POINTER_TYPE, POINTER_TYPE, VOID_TYPE))
{
  rtx buf_addr = expand_expr (CALL_EXPR_ARG (exp, 0), subtarget,
@@ -6239,9 +6239,9 @@
}
   break;

-  /* __builtin_longjmp is passed a pointer to an array of five words.
-It's similar to the C library longjmp function but works with
-__builtin_setjmp above.  */
+  /* __builtin_longjmp is passed a pointer to an array of five Pmode
+sized entries.  It's similar to the C library longjmp function
+but works with __builtin_setjmp above.  */
 case BUILT_IN_LONGJMP:
   if (validate_arglist (exp, POINTER_TYPE, INTEGER_TYPE, VOID_TYPE))
{
Index: gcc/doc/md.texi
===
--- gcc/doc/md.texi (revision 210096)
+++ gcc/doc/md.texi (working copy)
@@ -6113,8 +6113,10 @@
 as a pointer to a global table, must be restored.  Though it is
 preferred that the pointer value be 

[AArch64][4.8 backport] Fix default CPU architecture flags

2014-05-06 Thread Kyrill Tkachov

Hi all,

A latent issue was recently exposed in the 4.8 branch. Due to the recently fixed 
TARGET_FLOAT macro on that branch (r210004), we now hit the bug that the 
configure-time default architecture flags do not include FP and SIMD even though 
the default cpu target mandates them in aarch64-arches.def.
 The issue appears when trying to build gcc without any --with-cpu or 
--with-arch flags.



My patch to fix that issue for trunk (then 4.9) was posted at
http://gcc.gnu.org/ml/gcc-patches/2014-02/msg01487.html but was not backported 
to 4.8


This patch is a backport of the config.gcc change for that. This fixes the build 
by properly using the architecture flags in aarch64-arches.def when configuring gcc.


Ok to propose upstream for backport?

Tested aarch64-none-elf built with various combinations of --with-cpu and 
--with-arch.
Note, this fixes a build error when no --with-cpu or --with-arch is given on the 
configure line. That variation has been tested as well.


Ok to commit to the 4.8 branch?

Thanks,
Kyrill

2014-05-06  Kyrylo Tkachov  

* config.gcc (aarch64*-*-*): Use ISA flags from aarch64-arches.def.
Do not define target_cpu_default2 to generic.diff --git a/gcc/config.gcc b/gcc/config.gcc
index a4fb77d..2b54dd9 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -3150,6 +3150,11 @@ case "${target}" in
   ${srcdir}/config/aarch64/$def | \
   sed -e 's/^[^,]*,[ 	]*//' | \
   sed -e 's/,.*$//'`
+# Extract the architecture flags from aarch64-arches.def
+ext_mask=`grep "^$pattern(\"$base_val\"," \
+   ${srcdir}/config/aarch64/$def | \
+   sed -e 's/)$//' | \
+   sed -e 's/^.*,//'`
 			  else
 base_id=`grep "^$pattern(\"$base_val\"," \
   ${srcdir}/config/aarch64/$def | \
@@ -3699,10 +3704,8 @@ esac
 target_cpu_default2=
 case ${target} in
 	aarch64*-*-*)
-		if test x$target_cpu_cname = x
+		if test x"$target_cpu_cname" != x
 		then
-			target_cpu_default2=TARGET_CPU_generic
-		else
 			target_cpu_default2=$target_cpu_cname
 		fi
 		;;

Re: [AArch64/ARM 3/3] Add execution tests of ARM ZIP Intrinsics

2014-05-06 Thread Alan Lawrence

Right. Tests appear correct and problem is in arm_neon.h. I'll work on a fix.

Cheers, Alan

Christophe Lyon wrote:

This caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61062


On 30 April 2014 11:18, Ramana Radhakrishnan  wrote:

On Thu, Mar 27, 2014 at 10:53 AM, Alan Lawrence  wrote:

Final patch adds new tests of the ARM ZIP Intrinsics (subsuming the
autogenerated ones in testsuite/gcc.target/arm/neon/), that also check the
execution results, reusing the test bodies introduced into AArch64 in the
first patch.

All tests passing on arm-none-eabi.

This is OK - thanks,

Ramana


gcc/testsuite/ChangeLog:
2012-03-27  Alan Lawrence  

* gcc.target/arm/simd/simd.exp: New file.
* gcc.target/arm/simd/vzipqf32_1.c: New file.
* gcc.target/arm/simd/vzipqp16_1.c: New file.
* gcc.target/arm/simd/vzipqp8_1.c: New file.
* gcc.target/arm/simd/vzipqs16_1.c: New file.
* gcc.target/arm/simd/vzipqs32_1.c: New file.
* gcc.target/arm/simd/vzipqs8_1.c: New file.
* gcc.target/arm/simd/vzipqu16_1.c: New file.
* gcc.target/arm/simd/vzipqu32_1.c: New file.
* gcc.target/arm/simd/vzipqu8_1.c: New file.
* gcc.target/arm/simd/vzipf32_1.c: New file.
* gcc.target/arm/simd/vzipp16_1.c: New file.
* gcc.target/arm/simd/vzipp8_1.c: New file.
* gcc.target/arm/simd/vzips16_1.c: New file.
* gcc.target/arm/simd/vzips32_1.c: New file.
* gcc.target/arm/simd/vzips8_1.c: New file.
* gcc.target/arm/simd/vzipu16_1.c: New file.
* gcc.target/arm/simd/vzipu32_1.c: New file.
* gcc.target/arm/simd/vzipu8_1.c: New file.
diff --git a/gcc/testsuite/gcc.target/arm/simd/simd.exp
b/gcc/testsuite/gcc.target/arm/simd/simd.exp
new file mode 100644
index 000..746429d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/simd/simd.exp
@@ -0,0 +1,35 @@
+# Copyright (C) 1997-2014 Free Software Foundation, Inc.
+
+# This program 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 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# .
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Exit immediately if this isn't an ARM target.
+if ![istarget arm*-*-*] then {
+  return
+}
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]] \
+   "" ""
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/gcc.target/arm/simd/vzipf32_1.c
b/gcc/testsuite/gcc.target/arm/simd/vzipf32_1.c
new file mode 100644
index 000..efaa96e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/simd/vzipf32_1.c
@@ -0,0 +1,12 @@
+/* Test the `vzipf32' ARM Neon intrinsic.  */
+
+/* { dg-do run } */
+/* { dg-require-effective-target arm_neon_ok } */
+/* { dg-options "-save-temps -O1 -fno-inline" } */
+/* { dg-add-options arm_neon } */
+
+#include "arm_neon.h"
+#include "../../aarch64/simd/vzipf32.x"
+
+/* { dg-final { scan-assembler-times "vuzp\.32\[ \t\]+\[dD\]\[0-9\]+,
?\[dD\]\[0-9\]+!?\(?:\[ \t\]+@\[a-zA-Z0-9 \]+\)?\n" 1 } } */
+/* { dg-final { cleanup-saved-temps } } */
diff --git a/gcc/testsuite/gcc.target/arm/simd/vzipp16_1.c
b/gcc/testsuite/gcc.target/arm/simd/vzipp16_1.c
new file mode 100644
index 000..4154333
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/simd/vzipp16_1.c
@@ -0,0 +1,12 @@
+/* Test the `vzipp16' ARM Neon intrinsic.  */
+
+/* { dg-do run } */
+/* { dg-require-effective-target arm_neon_ok } */
+/* { dg-options "-save-temps -O1 -fno-inline" } */
+/* { dg-add-options arm_neon } */
+
+#include "arm_neon.h"
+#include "../../aarch64/simd/vzipp16.x"
+
+/* { dg-final { scan-assembler-times "vzip\.16\[ \t\]+\[dD\]\[0-9\]+,
?\[dD\]\[0-9\]+!?\(?:\[ \t\]+@\[a-zA-Z0-9 \]+\)?\n" 1 } } */
+/* { dg-final { cleanup-saved-temps } } */
diff --git a/gcc/testsuite/gcc.target/arm/simd/vzipp8_1.c
b/gcc/testsuite/gcc.target/arm/simd/vzipp8_1.c
new file mode 100644
index 000..9fe2384
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/simd/vzipp8_1.c
@@ -0,0 +1,12 @@
+/* Test the `vzipp8' ARM Neon intrinsic.  */
+
+/* { dg-do run } */
+/* { dg-require-effective-target arm_neon_ok } */
+/* { dg-options "-save-temps -O1 -fno-inline" } */
+/* { dg-add-options arm_neon } */
+
+#include "arm_neon.h"
+#include "../../aarch64/simd/vzipp8.x"
+
+/* { dg-final { scan-assembler-times "vzip\.8\[ \t\]+\[dD\]\[0-9\]+,
?\[dD\]\[0-9\]+!?\(?:\[ \t\]+@\[a-zA-Z0-9 \]+\)?\n" 1 } } */
+/* { dg-final { cleanup-saved-temps } } */

Re: [RFC][PATCH][MIPS] Patch to enable LRA for MIPS backend

2014-05-06 Thread Kyrill Tkachov

On 03/05/14 20:21, Richard Sandiford wrote:

Vladimir Makarov  writes:

Not sure how the constraint would/should exclude $sp-based address in
LRA.  In this particular case, a spilled pseudo is changed to memory
giving the following RTL form:

(insn 30 29 31 4 (set (reg:SI 4 $4)
  (and:SI (mem/c:SI (plus:SI (reg/f:SI 78 $frame)
  (const_int 16 [0x10])) [7 %sfp+16 S4 A32])
  (const_int 65535 [0x]))) shell.i:17 161 {*andsi3_mips16}
   (expr_list:REG_DEAD (reg:SI 194 [ D.1469 ])
  (nil)))

The operand 1 during alternative selection is not marked as a bad
operand as it is a memory operand. $frame appears to be fine as it
could be eliminated later to hard register. No reloads are inserted
for the instructions concerned. Unless, $frame should be temporarily
eliminated and then a reload would be inserted?

Yeah, I think the lack of elimination is the problem.  process_address
eliminates $frame temporarily before checking whether the address
is valid, but the places that check EXTRA_CONSTRAINT_STR pass the
original uneliminated address.  So the legitimate_address_p hook sees
the $sp-based address but the "W" constraint only sees the $frame-based
address (which might or might not be valid, depending on whether $frame
is eliminated to the stack or hard frame pointer).  I think the constraints
should see the eliminated address too.

This patch seems to fix it for me.  Tested on x86_64-linux-gnu.
Vlad, is this OK for trunk?

BTW, we might want to define something like:

#define MODE_BASE_REG_CLASS(MODE) \
(TARGET_MIPS16 \
 ? ((MODE) == SImode || (MODE) == DImode ? M16_SP_REGS : M16_REGS) \
 : GR_REGS)

instead of BASE_REG_CLASS.  It might lead to slightly better code
(or not -- if it doesn't then don't bother :-)).

If this patch is OK then I think the only thing blocking the switch
to LRA is the asm-subreg-1.c failure.  I think it'd be fine to XFAIL
that test on MIPS for now, until there's a consensus about what "X" means
for asms.


gcc/
* lra-constraints.c (valid_address_p): Move earlier in file.
Add a constraint argument to the address_info version.
(satisfies_memory_constraint_p): New function.
(satisfies_address_constraint_p): Likewise.
(process_alt_operands, curr_insn_transform): Use them.
(process_address): Pass the constraint to valid_address_p when
checking address operands.



Yes, it looks ok for me, Richard.  Thanks on working on this.

I am on vacation till May 4th. If the patch results in problems on other
targets, I hope you revert it.  But to be honest, I believe it is very
safe and don't expect any problems at all.

Thanks Vlad, belatedly committed on that basis.  Like you say I'll revert
it at the first sign of trouble (although it ended up being closer to
your return than originally intended. :-))


Hi all,
This caused some testsuite failures on arm:
FAIL: gcc.target/arm/vfp-ldmdbd.c scan-assembler fldmdbd
FAIL: gcc.target/arm/vfp-ldmdbs.c scan-assembler fldmdbs
FAIL: gcc.target/arm/vfp-ldmiad.c scan-assembler fldmiad
FAIL: gcc.target/arm/vfp-ldmias.c scan-assembler fldmias

From the vfp-ldmdbd.c test this patch changed the codegen from:
fldmdbdr5!, {d7}

into
subr5, r5, #8
flddd7, [r5]

Which broke the test.

Kyrill




Re: debug container patch

2014-05-06 Thread Jonathan Wakely

On 28/04/14 23:07 +0200, François Dumont wrote:

On 27/04/2014 15:39, Jonathan Wakely wrote:

On 17/04/14 22:43 +0200, François Dumont wrote:

Hi

  Here is a patch to globally enhance debug containers implementation.


François, sorry for the delay, this is a large patch and I wanted to
give it the time it deserves to review properly.


No problem, I see that there are a lot of proposals lately.


Yes, I need to review patches faster!


I understand why this is needed, but it changes the layout of the
classes in very significant ways, meaning the debug containers will
not be compatible across GCC releases. I'm OK with that now, but from
the next major GCC release I'd like to avoid that in future.


I remember Paolo saying that there is no abi guaranty for debug mode 
this is why I didn't hesitate in making this proposal. Will there be 
one in the future ?


Probably not. Originally the performance impact of debug mode was so
large that noone would use the containers except for special builds to
find specific problems.  With some of your performance improvements
(unwrapping safe iterators once we know they are valid etc.) I wonder
if some people would choose to use e.g. __gnu_debug::vector directly
in "release builds". If anyone is doing that they would probably want
a stable ABI, but we don't guarantee that now, and probably shouldn't
guarantee it in future.

If people want extra safety without _GLIBCXX_DEBUG we should probably
consider the lightweight checks that have been implemented on the
Google branch.

I plan also breaking changes for profile mode to 
fix its very bad performance.


I don't care about Profile mode at all! :-)

I reviewed the ChangeLog and limit modifications like in this file. 
Note however that patch have been generated with '-x -b' option to 
hide white space modifications. I clean usage of white chars in 
impacted files, replaced some white spaces with tabs and remove 
useless white spaces.


Great, thank you.


In C++03 mode the _GLIBCXX_NOEXCEPT macro expands to an empty string,
so it is useless in this chunk of code, which is only compiled for
C++03 mode. It should probably just be removed here (and in all the
other debug containers which use it in C++03-only code).


Ok, I cleaned those. Did you mean removing the whole explicit 
destructor ? Is it a coding Standard to always explicitly implement 
the destructor or just a way to have Doxygen generate ?


What you've done in your patch is fine.

We don't have any such coding standard for destructors though (AFAIK!)

To avoid losing the Doxygen comments we could put them on the
defaulted C++11 destructor. If we don't do so already we should
consider generating Doxygen docs with -std=gnu++11 (it's not the
default used by G++, but it would show more complete, and more modern,
API information).


+ * before-begin ownership.*/

+   template
+void
+_Safe_forward_list<_SafeSequence>::
+_M_swap(_Safe_sequence_base& __other) noexcept
+{
+  __gnu_cxx::__scoped_lock sentry(_M_this()._M_get_mutex());


Shouldn't we be locking both containers' mutexes here?
As we do in src/c++11/debug.cc


Good point, not a regression but nice to fix in this patch.


Looks good now, thanks.


That indeed looks scary, we replaced with:

 forward_list(forward_list&& __list, const allocator_type& __al)
   : _Safe(std::move(__list._M_safe()), __al),
 _Base(std::move(__list._M_base()), __al)
 { }

it makes clearer the fact that we move each part.


Yes, this is much less scary :-)

Thanks, the revised patch is OK for trunk.



[PATCH][buildrobot] AVR: Fix warning for unused argument

2014-05-06 Thread Jan-Benedict Glaw
Hi!

This patch fixes a warning / leftover (from Feb 22) which I oversaw
too long in buildrobot's output. Committed as obvious.

g++ -c   -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -fno-exceptions 
-fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings 
-Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic 
-Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -fno-common  
-DHAVE_CONFIG_H -I. -I. -I/home/vaxbuild/repos/gcc/gcc 
-I/home/vaxbuild/repos/gcc/gcc/. -I/home/vaxbuild/repos/gcc/gcc/../include 
-I/home/vaxbuild/repos/gcc/gcc/../libcpp/include  
-I/home/vaxbuild/repos/gcc/gcc/../libdecnumber 
-I/home/vaxbuild/repos/gcc/gcc/../libdecnumber/dpd -I../libdecnumber 
-I/home/vaxbuild/repos/gcc/gcc/../libbacktrace-o avr.o -MT avr.o -MMD -MP 
-MF ./.deps/avr.TPo /home/vaxbuild/repos/gcc/gcc/config/avr/avr.c
/home/vaxbuild/repos/gcc/gcc/config/avr/avr.c:745:1: warning: unused parameter 
‘from’ [-Wunused-parameter]
 avr_can_eliminate (const int from, const int to)
 ^


2014-05-06  Jan-Benedict Glaw  

gcc/
* config/avr/avr.c (avr_can_eliminate): Mark unused argument.

diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c
index be8c6fa..8935c15 100644
--- a/gcc/config/avr/avr.c
+++ b/gcc/config/avr/avr.c
@@ -742,7 +742,7 @@ avr_allocate_stack_slots_for_args (void)
 /* Return true if register FROM can be eliminated via register TO.  */
 
 static bool
-avr_can_eliminate (const int from, const int to)
+avr_can_eliminate (const int from ATTRIBUTE_UNUSED, const int to)
 {
   return ((frame_pointer_needed && to == FRAME_POINTER_REGNUM)
   || !frame_pointer_needed);
-- 
  Jan-Benedict Glaw  jbg...@lug-owl.de  +49-172-7608481
Signature of: "really soon now":  an unspecified period of time, 
likly to
the second  : be greater than any reasonable 
definition
  of "soon".


signature.asc
Description: Digital signature


Go patch committed: Store flags for division checks in Gogo object

2014-05-06 Thread Ian Lance Taylor
This patch by Chris Manghane stores the flags for division checks in the
Gogo object, rather than referring directly to the GCC global variables.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian


2014-05-06  Chris Manghane  

* go-c.h (go_create_gogo): Update declaration to add
check_divide_zero and check_divide_overflow parameters.
* go-lang.c (go_langhook_init): Pass new arguments to
go_create_gogo.


Index: gcc/go/go-lang.c
===
--- gcc/go/go-lang.c	(revision 209945)
+++ gcc/go/go-lang.c	(working copy)
@@ -104,7 +104,8 @@ go_langhook_init (void)
  build_common_builtin_nodes (because it calls, indirectly,
  go_type_for_size).  */
   go_create_gogo (INT_TYPE_SIZE, POINTER_SIZE, go_pkgpath, go_prefix,
-		  go_relative_import_path);
+		  go_relative_import_path, go_check_divide_zero,
+		  go_check_divide_overflow);
 
   build_common_builtin_nodes ();
 
Index: gcc/go/gofrontend/go.cc
===
--- gcc/go/gofrontend/go.cc	(revision 209941)
+++ gcc/go/gofrontend/go.cc	(working copy)
@@ -21,7 +21,8 @@ static Gogo* gogo;
 GO_EXTERN_C
 void
 go_create_gogo(int int_type_size, int pointer_size, const char *pkgpath,
-	   const char *prefix, const char *relative_import_path)
+	   const char *prefix, const char *relative_import_path,
+	   bool check_divide_by_zero, bool check_divide_overflow)
 {
   go_assert(::gogo == NULL);
   Linemap* linemap = go_get_linemap();
@@ -34,6 +35,10 @@ go_create_gogo(int int_type_size, int po
 
   if (relative_import_path != NULL)
 ::gogo->set_relative_import_path(relative_import_path);
+  if (check_divide_by_zero)
+::gogo->set_check_divide_by_zero(check_divide_by_zero);
+  if (check_divide_overflow)
+::gogo->set_check_divide_overflow(check_divide_overflow);
 }
 
 // Parse the input files.
Index: gcc/go/gofrontend/expressions.cc
===
--- gcc/go/gofrontend/expressions.cc	(revision 210088)
+++ gcc/go/gofrontend/expressions.cc	(working copy)
@@ -5432,7 +5432,7 @@ Binary_expression::lower_compare_to_memc
 }
 
 Expression*
-Binary_expression::do_flatten(Gogo*, Named_object*,
+Binary_expression::do_flatten(Gogo* gogo, Named_object*,
   Statement_inserter* inserter)
 {
   Location loc = this->location();
@@ -5462,11 +5462,9 @@ Binary_expression::do_flatten(Gogo*, Nam
   left_type->integer_type() != NULL)
  || this->op_ == OPERATOR_MOD);
 
-  // FIXME: go_check_divide_zero and go_check_divide_overflow are globals
-  // defined in gcc/go/lang.opt.  These should be defined in go_create_gogo
-  // and accessed from the Gogo* passed to do_flatten.
   if (is_shift_op
-  || (is_idiv_op && (go_check_divide_zero || go_check_divide_overflow)))
+  || (is_idiv_op
+	  && (gogo->check_divide_by_zero() || gogo->check_divide_overflow(
 {
   if (!this->left_->is_variable())
 {
@@ -6046,7 +6044,7 @@ Binary_expression::do_get_tree(Translate
   // Add checks for division by zero and division overflow as needed.
   if (is_idiv_op)
 {
-  if (go_check_divide_zero)
+  if (gogo->check_divide_by_zero())
 	{
 	  // right == 0
   Bexpression* zero_expr =
@@ -6065,7 +6063,7 @@ Binary_expression::do_get_tree(Translate
 crash_expr, ret, loc);
 	}
 
-  if (go_check_divide_overflow)
+  if (gogo->check_divide_overflow())
 	{
 	  // right == -1
 	  // FIXME: It would be nice to say that this test is expected
Index: gcc/go/gofrontend/gogo.h
===
--- gcc/go/gofrontend/gogo.h	(revision 209941)
+++ gcc/go/gofrontend/gogo.h	(working copy)
@@ -215,7 +215,27 @@ class Gogo
   // Set the relative import path from a command line option.
   void
   set_relative_import_path(const std::string& s)
-  {this->relative_import_path_ = s; }
+  { this->relative_import_path_ = s; }
+
+  // Return whether to check for division by zero in binary operations.
+  bool
+  check_divide_by_zero() const
+  { return this->check_divide_by_zero_; }
+
+  // Set the option to check division by zero from a command line option.
+  void
+  set_check_divide_by_zero(bool b)
+  { this->check_divide_by_zero_ = b; }
+
+  // Return whether to check for division overflow in binary operations.
+  bool
+  check_divide_overflow() const
+  { return this->check_divide_overflow_; }
+
+  // Set the option to check division overflow from a command line option.
+  void
+  set_check_divide_overflow(bool b)
+  { this->check_divide_overflow_ = b; }
 
   // Return the priority to use for the package we are compiling.
   // This is two more than the largest priority of any package we
@@ -716,6 +736,12 @@ class Gogo
   // The relative import path, from the -fgo-re

[PATCH][ARM] Remove unused vtrn, vzip, vuzp NEON builtins

2014-05-06 Thread Kyrill Tkachov

Hi all,

This patch removes the NEON builtin functions for vtrn, vzip, vuzp and their 
associated wiring and machine descriptions. The builtins were initially used to 
implement the corresponding intrinsics in arm_neon.h but those have since been 
reimplemented using the more generic __builtin_shuffle. This allows us to clean 
up the NEON builtin initialisation code somewhat.


Tested arm-none-eabi on qemu. Made sure that the recently added tests in 
simd.exp for vzip, vuzp etc. pass.


Ok for trunk?

Thanks,
Kyrill

2014-05-06  Kyrylo Tkachov  

* config/arm/arm.c (neon_itype): Remove NEON_RESULTPAIR.
(arm_init_neon_builtins): Remove handling of NEON_RESULTPAIR.
Remove associated type declarations and initialisations.
(arm_expand_neon_builtin): Likewise.
(neon_emit_pair_result_insn): Delete.
* config/arm/arm_neon_builtins (vtrn, vzip, vuzp): Delete.
* config/arm/neon.md (neon_vtrn): Delete.
(neon_vzip): Likewise.
(neon_vuzp): Likewise.diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c
index 4bada64..44d0bd6 100644
--- a/gcc/config/arm/arm.c
+++ b/gcc/config/arm/arm.c
@@ -23098,7 +23098,6 @@ typedef enum {
   NEON_FLOAT_NARROW,
   NEON_FIXCONV,
   NEON_SELECT,
-  NEON_RESULTPAIR,
   NEON_REINTERP,
   NEON_VTBL,
   NEON_VTBX,
@@ -23563,27 +23562,6 @@ arm_init_neon_builtins (void)
   tree intCI_type_node;
   tree intXI_type_node;
 
-  tree V8QI_pointer_node;
-  tree V4HI_pointer_node;
-  tree V2SI_pointer_node;
-  tree V2SF_pointer_node;
-  tree V16QI_pointer_node;
-  tree V8HI_pointer_node;
-  tree V4SI_pointer_node;
-  tree V4SF_pointer_node;
-  tree V2DI_pointer_node;
-
-  tree void_ftype_pv8qi_v8qi_v8qi;
-  tree void_ftype_pv4hi_v4hi_v4hi;
-  tree void_ftype_pv2si_v2si_v2si;
-  tree void_ftype_pv2sf_v2sf_v2sf;
-  tree void_ftype_pdi_di_di;
-  tree void_ftype_pv16qi_v16qi_v16qi;
-  tree void_ftype_pv8hi_v8hi_v8hi;
-  tree void_ftype_pv4si_v4si_v4si;
-  tree void_ftype_pv4sf_v4sf_v4sf;
-  tree void_ftype_pv2di_v2di_v2di;
-
   tree reinterp_ftype_dreg[NUM_DREG_TYPES][NUM_DREG_TYPES];
   tree reinterp_ftype_qreg[NUM_QREG_TYPES][NUM_QREG_TYPES];
   tree dreg_types[NUM_DREG_TYPES], qreg_types[NUM_QREG_TYPES];
@@ -23709,49 +23687,6 @@ arm_init_neon_builtins (void)
   (*lang_hooks.types.register_builtin_type) (intXI_type_node,
 	 "__builtin_neon_xi");
 
-  /* Pointers to vector types.  */
-  V8QI_pointer_node = build_pointer_type (V8QI_type_node);
-  V4HI_pointer_node = build_pointer_type (V4HI_type_node);
-  V2SI_pointer_node = build_pointer_type (V2SI_type_node);
-  V2SF_pointer_node = build_pointer_type (V2SF_type_node);
-  V16QI_pointer_node = build_pointer_type (V16QI_type_node);
-  V8HI_pointer_node = build_pointer_type (V8HI_type_node);
-  V4SI_pointer_node = build_pointer_type (V4SI_type_node);
-  V4SF_pointer_node = build_pointer_type (V4SF_type_node);
-  V2DI_pointer_node = build_pointer_type (V2DI_type_node);
-
-  /* Operations which return results as pairs.  */
-  void_ftype_pv8qi_v8qi_v8qi =
-build_function_type_list (void_type_node, V8QI_pointer_node, V8QI_type_node,
-  			  V8QI_type_node, NULL);
-  void_ftype_pv4hi_v4hi_v4hi =
-build_function_type_list (void_type_node, V4HI_pointer_node, V4HI_type_node,
-  			  V4HI_type_node, NULL);
-  void_ftype_pv2si_v2si_v2si =
-build_function_type_list (void_type_node, V2SI_pointer_node, V2SI_type_node,
-  			  V2SI_type_node, NULL);
-  void_ftype_pv2sf_v2sf_v2sf =
-build_function_type_list (void_type_node, V2SF_pointer_node, V2SF_type_node,
-  			  V2SF_type_node, NULL);
-  void_ftype_pdi_di_di =
-build_function_type_list (void_type_node, intDI_pointer_node,
-			  neon_intDI_type_node, neon_intDI_type_node, NULL);
-  void_ftype_pv16qi_v16qi_v16qi =
-build_function_type_list (void_type_node, V16QI_pointer_node,
-			  V16QI_type_node, V16QI_type_node, NULL);
-  void_ftype_pv8hi_v8hi_v8hi =
-build_function_type_list (void_type_node, V8HI_pointer_node, V8HI_type_node,
-  			  V8HI_type_node, NULL);
-  void_ftype_pv4si_v4si_v4si =
-build_function_type_list (void_type_node, V4SI_pointer_node, V4SI_type_node,
-  			  V4SI_type_node, NULL);
-  void_ftype_pv4sf_v4sf_v4sf =
-build_function_type_list (void_type_node, V4SF_pointer_node, V4SF_type_node,
-  			  V4SF_type_node, NULL);
-  void_ftype_pv2di_v2di_v2di =
-build_function_type_list (void_type_node, V2DI_pointer_node, V2DI_type_node,
-			  V2DI_type_node, NULL);
-
   if (TARGET_CRYPTO && TARGET_HARD_FLOAT)
   {
 tree V4USI_type_node =
@@ -24043,25 +23978,6 @@ arm_init_neon_builtins (void)
 	  }
 	  break;
 
-	case NEON_RESULTPAIR:
-	  {
-	switch (insn_data[d->code].operand[1].mode)
-	  {
-	  case V8QImode: ftype = void_ftype_pv8qi_v8qi_v8qi; break;
-	  case V4HImode: ftype = void_ftype_pv4hi_v4hi_v4hi; break;
-	  case V2SImode: ftype = void_ftype_pv2si_v2si_v2si; break;
-	  case V2SFmode: ftype = void_ftype_pv2sf_v2sf_v2sf; break;
-	  case DImode: ftyp

Re: [PATCH, Pointer Bounds Checker 1/x] Pointer bounds type and mode

2014-05-06 Thread Richard Biener
On Tue, May 6, 2014 at 2:10 PM, Ilya Enkovich  wrote:
> 2014-04-16 15:00 GMT+04:00 Ilya Enkovich :
>> Hi,
>>
>> This patch restarts the series for introducing Pointer Bounds Checker 
>> instrumentation and supporting Intel Memory Protection Extension (MPX) 
>> technology.  Detailed description is on GCC Wiki page: 
>> http://gcc.gnu.org/wiki/Intel%20MPX%20support%20in%20the%20GCC%20compiler.
>>
>> The first patch introduces pointer bounds type and mode.  It was approved 
>> earlier for 4.9 and had no significant changes since then.  I'll assume 
>> patch is OK if no objections arise.
>>
>> Patch was bootstrapped and tested for linux-x86_64.
>>
>> Thanks,
>> Ilya
>> --
>> gcc/
>>
>> 2014-04-16  Ilya Enkovich  
>>
>> * mode-classes.def (MODE_POINTER_BOUNDS): New.
>> * tree.def (POINTER_BOUNDS_TYPE): New.
>> * genmodes.c (complete_mode): Support MODE_POINTER_BOUNDS.
>> (POINTER_BOUNDS_MODE): New.
>> (make_pointer_bounds_mode): New.
>> * machmode.h (POINTER_BOUNDS_MODE_P): New.
>> * stor-layout.c (int_mode_for_mode): Support MODE_POINTER_BOUNDS.
>> (layout_type): Support POINTER_BOUNDS_TYPE.
>> * tree-pretty-print.c (dump_generic_node): Support 
>> POINTER_BOUNDS_TYPE.
>> * tree.c (build_int_cst_wide): Support POINTER_BOUNDS_TYPE.
>> (type_contains_placeholder_1): Likewise.
>> * tree.h (POINTER_BOUNDS_TYPE_P): New.
>> * varasm.c (output_constant): Support POINTER_BOUNDS_TYPE.
>> * doc/rtl.texi (MODE_POINTER_BOUNDS): New.
>>
>>
>> diff --git a/gcc/doc/rtl.texi b/gcc/doc/rtl.texi
>> index 20b7187..3a1014d 100644
>> --- a/gcc/doc/rtl.texi
>> +++ b/gcc/doc/rtl.texi
>> @@ -1382,6 +1382,12 @@ any @code{CC_MODE} modes listed in the 
>> @file{@var{machine}-modes.def}.
>>  @xref{Jump Patterns},
>>  also see @ref{Condition Code}.
>>
>> +@findex MODE_POINTER_BOUNDS
>> +@item MODE_POINTER_BOUNDS
>> +Pointer bounds modes.  Used to represent values of pointer bounds type.
>> +Operations in these modes may be executed as NOPs depending on hardware
>> +features and environment setup.
>> +
>>  @findex MODE_RANDOM
>>  @item MODE_RANDOM
>>  This is a catchall mode class for modes which don't fit into the above
>> diff --git a/gcc/genmodes.c b/gcc/genmodes.c
>> index 8cc3cde..9d0b413 100644
>> --- a/gcc/genmodes.c
>> +++ b/gcc/genmodes.c
>> @@ -333,6 +333,7 @@ complete_mode (struct mode_data *m)
>>break;
>>
>>  case MODE_INT:
>> +case MODE_POINTER_BOUNDS:
>>  case MODE_FLOAT:
>>  case MODE_DECIMAL_FLOAT:
>>  case MODE_FRACT:
>> @@ -534,6 +535,19 @@ make_special_mode (enum mode_class cl, const char *name,
>>new_mode (cl, name, file, line);
>>  }
>>
>> +#define POINTER_BOUNDS_MODE(N, Y) \
>> +  make_pointer_bounds_mode (#N, Y, __FILE__, __LINE__)
>> +
>> +static void ATTRIBUTE_UNUSED
>> +make_pointer_bounds_mode (const char *name,
>> + unsigned int bytesize,
>> + const char *file, unsigned int line)
>> +{
>> +  struct mode_data *m = new_mode (MODE_POINTER_BOUNDS, name, file, line);
>> +  m->bytesize = bytesize;
>> +}
>> +
>> +
>>  #define INT_MODE(N, Y) FRACTIONAL_INT_MODE (N, -1U, Y)
>>  #define FRACTIONAL_INT_MODE(N, B, Y) \
>>make_int_mode (#N, B, Y, __FILE__, __LINE__)
>> diff --git a/gcc/machmode.h b/gcc/machmode.h
>> index bc5d901..cbe5042 100644
>> --- a/gcc/machmode.h
>> +++ b/gcc/machmode.h
>> @@ -174,6 +174,9 @@ extern const unsigned char mode_class[NUM_MACHINE_MODES];
>> || CLASS == MODE_ACCUM  \
>> || CLASS == MODE_UACCUM)
>>
>> +#define POINTER_BOUNDS_MODE_P(MODE)  \
>> +  (GET_MODE_CLASS (MODE) == MODE_POINTER_BOUNDS)
>> +
>>  /* Get the size in bytes and bits of an object of mode MODE.  */
>>
>>  extern CONST_MODE_SIZE unsigned char mode_size[NUM_MACHINE_MODES];
>> diff --git a/gcc/mode-classes.def b/gcc/mode-classes.def
>> index 9c6a8bb..b645484 100644
>> --- a/gcc/mode-classes.def
>> +++ b/gcc/mode-classes.def
>> @@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
>>DEF_MODE_CLASS (MODE_CC),/* condition code in a register */ \
>>DEF_MODE_CLASS (MODE_INT),   /* integer */  \
>>DEF_MODE_CLASS (MODE_PARTIAL_INT),   /* integer with padding bits */\
>> +  DEF_MODE_CLASS (MODE_POINTER_BOUNDS), /* bounds */   \
>>DEF_MODE_CLASS (MODE_FRACT), /* signed fractional number */ \
>>DEF_MODE_CLASS (MODE_UFRACT),/* unsigned fractional 
>> number */   \
>>DEF_MODE_CLASS (MODE_ACCUM), /* signed accumulator */   \
>> diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
>> index 084d195..af0ab88 100644
>> --- a/gcc/stor-layout.c
>> +++ b/gcc/stor-layout.c
>> @@ -386,6 +386,7 @@ int_mode_for_mode (enum machine_mode mode)
>>  case MODE_VECTOR_ACCUM:
>>  case MODE_VECTOR_UFRACT:
>>  case MODE_VECTOR_UACCUM:
>> +case MODE_POINTER_BOUNDS:
>>mode =

Re: GCC's -fsplit-stack disturbing Mach's vm_allocate

2014-05-06 Thread Samuel Thibault
Svante Signell, le Tue 06 May 2014 15:25:38 +0200, a écrit :
> On Tue, 2014-05-06 at 15:07 +0200, Samuel Thibault wrote:
> > Svante Signell, le Tue 06 May 2014 15:05:20 +0200, a écrit :
> > > On Tue, 2014-05-06 at 14:51 +0200, Samuel Thibault wrote:
> > > > Just to explicitly ask for it:
> > > > 
> > > > Svante Signell, le Tue 06 May 2014 10:06:49 +0200, a écrit :
> > > > > For some (yet) unknown reason all libgo tests fails with a segfault 
> > > > > when
> > > > > run in the build tree: make, sh or something else, the test commands 
> > > > > are
> > > > > rather hard to track.
> > > > 
> > > > Doesn't that dump a core?  Do you have /servers/crash properly pointing
> > > > to /servers/crash-dump-core and ulimit -u set to unlimited?
> > > 
> > > fsysopts /servers/crash
> > > ext2fs --writable --no-inherit-dir-group --store-type=typed device:hd0s1
> > 
> > See the type of file, it's a symlink, so just ls -l it.
> 
> ls -l /servers/crash
> lrw-r--r-- 1 root root 10 May 17  2013 /servers/crash -> crash-kill
> 
> Should I just ln -sf to change?

Yes.


Re: GCC's -fsplit-stack disturbing Mach's vm_allocate

2014-05-06 Thread Svante Signell
On Tue, 2014-05-06 at 15:07 +0200, Samuel Thibault wrote:
> Svante Signell, le Tue 06 May 2014 15:05:20 +0200, a écrit :
> > On Tue, 2014-05-06 at 14:51 +0200, Samuel Thibault wrote:
> > > Just to explicitly ask for it:
> > > 
> > > Svante Signell, le Tue 06 May 2014 10:06:49 +0200, a écrit :
> > > > For some (yet) unknown reason all libgo tests fails with a segfault when
> > > > run in the build tree: make, sh or something else, the test commands are
> > > > rather hard to track.
> > > 
> > > Doesn't that dump a core?  Do you have /servers/crash properly pointing
> > > to /servers/crash-dump-core and ulimit -u set to unlimited?
> > 
> > fsysopts /servers/crash
> > ext2fs --writable --no-inherit-dir-group --store-type=typed device:hd0s1
> 
> See the type of file, it's a symlink, so just ls -l it.

ls -l /servers/crash
lrw-r--r-- 1 root root 10 May 17  2013 /servers/crash -> crash-kill

Should I just ln -sf to change?



Re: [C PATCH] Warn about variadic main (PR c/60156)

2014-05-06 Thread Marek Polacek
On Thu, May 01, 2014 at 11:37:58PM +, Joseph S. Myers wrote:
> As a matter of QoI we should also diagnose use of _Atomic in the return 
> type or argument types of main (something I deferred doing in the initial 
> _Atomic support).

Ok, I opened PR61077 and I'm taking it.  But I wonder if I should
diagnose if the second parameter is e.g.:
_Atomic char **argv;
char *_Atomic *argv;

My current patch diagnoses only
char **_Atomic argv;
since I'm not looking through the pointers.

Marek


Re: RFA: Fix calculation of size of builtin setjmp buffer

2014-05-06 Thread Jakub Jelinek
On Tue, May 06, 2014 at 01:55:18PM +0100, Nick Clifton wrote:
> 2014-05-06  Nick Clifton  
> 
>   * except.c (init_eh): Fix computation of builtin setjmp buffer
>   size.
> 
> Index: gcc/except.c
> ===
> --- gcc/except.c  (revision 210096)
> +++ gcc/except.c  (working copy)
> @@ -287,7 +287,7 @@
>  #endif
>  #else
>/* builtin_setjmp takes a pointer to 5 words.  */
> -  tmp = size_int (5 * BITS_PER_WORD / POINTER_SIZE - 1);
> +  tmp = size_int (5 * POINTER_SIZE / BITS_PER_WORD - 1);
>  #endif
>tmp = build_index_type (tmp);
>tmp = build_array_type (ptr_type_node, tmp);

That doesn't look correct to me.  If the code wants to create 5 words long
array, but with pointer elements (instead of word sized elements), then
5 * BITS_PER_WORD is the desired size in bits of the buffer, POINTER_SIZE
is how many bits each void *array[...] element occupies and thus
5 * BITS_PER_WORD / POINTER_SIZE - 1 is the right last element, so I'd
say the previous expression is the right one.  Perhaps you want to round up
rather than down, but certainly not swap the division operands.

Now, if the code actually expects 5 pointers, rather than 5 words, or
something else, then you'd at least need to also fix the comment.

Jakub


Re: GCC's -fsplit-stack disturbing Mach's vm_allocate

2014-05-06 Thread Samuel Thibault
Svante Signell, le Tue 06 May 2014 15:05:20 +0200, a écrit :
> On Tue, 2014-05-06 at 14:51 +0200, Samuel Thibault wrote:
> > Just to explicitly ask for it:
> > 
> > Svante Signell, le Tue 06 May 2014 10:06:49 +0200, a écrit :
> > > For some (yet) unknown reason all libgo tests fails with a segfault when
> > > run in the build tree: make, sh or something else, the test commands are
> > > rather hard to track.
> > 
> > Doesn't that dump a core?  Do you have /servers/crash properly pointing
> > to /servers/crash-dump-core and ulimit -u set to unlimited?
> 
> fsysopts /servers/crash
> ext2fs --writable --no-inherit-dir-group --store-type=typed device:hd0s1

See the type of file, it's a symlink, so just ls -l it.

> > > Number of tests succeeding with libpthread's stack guard fixed: 33 (and
> > > the other libc fixes)
> 
> Additionally 33 test pass with the fixed libpthread (some of them pass
> but segfault before finishing).

Ok, that parenthesis brings the sense to it :)

Samuel


Re: GCC's -fsplit-stack disturbing Mach's vm_allocate

2014-05-06 Thread Svante Signell
On Tue, 2014-05-06 at 14:51 +0200, Samuel Thibault wrote:
> Just to explicitly ask for it:
> 
> Svante Signell, le Tue 06 May 2014 10:06:49 +0200, a écrit :
> > For some (yet) unknown reason all libgo tests fails with a segfault when
> > run in the build tree: make, sh or something else, the test commands are
> > rather hard to track.
> 
> Doesn't that dump a core?  Do you have /servers/crash properly pointing
> to /servers/crash-dump-core and ulimit -u set to unlimited?

fsysopts /servers/crash
ext2fs --writable --no-inherit-dir-group --store-type=typed device:hd0s1
ulimit -u
unlimited

> > Number of tests succeeding with libpthread's stack guard fixed: 33 (and
> > the other libc fixes)

Additionally 33 test pass with the fixed libpthread (some of them pass
but segfault before finishing). Still manual testing, no successful
tests with make -C ... check.



Re: GCC's -fsplit-stack disturbing Mach's vm_allocate

2014-05-06 Thread Ian Lance Taylor
On Tue, May 6, 2014 at 4:06 AM, Svante Signell  wrote:
> On Fri, 2014-05-02 at 12:52 +0200, Samuel Thibault wrote:
>> Svante Signell, le Fri 02 May 2014 12:45:56 +0200, a écrit :
>> > On Fri, 2014-05-02 at 12:00 +0200, Samuel Thibault wrote:
>> > > Samuel Thibault, le Fri 02 May 2014 11:57:53 +0200, a écrit :
>> > > > So we just need to fix guardsize in our libpthread.
>> > >
>> > > (And I'll have a look at it).
>> >
>> > Maybe this can fix the around 40 segfaults (of 50 failures) when split
>> > stack is disabled too? The segfaults are always around the same place in
>> > libpthread.
>>
>> Possibly, if libgo uses small stacks already.
>
> Status update:
> For some (yet) unknown reason all libgo tests fails with a segfault when
> run in the build tree: make, sh or something else, the test commands are
> rather hard to track.

You can see the commands being run by running something like
make GOTESTFLAGS=--trace check-target-libgo

Ian


Go patch committed: Fix bug in embedded method handling

2014-05-06 Thread Ian Lance Taylor
This patch to the Go frontend fixes a bug in the handling of methods of
embedded fields.  If the same type was embedded in a struct at different
levels, only the first embedded instance was considered when building
the set of all methods.  If the second instance was at a higher level,
its methods would not be used.  This only applied when building the set
of all methods, so ambiguous cases were detected correctly.  The bug
only applied for non-ambiguous cases.  I will commit a test case for
this to the master testsuite.

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

Ian

diff -r 4e7f09e27159 go/types.cc
--- a/go/types.cc	Mon May 05 21:13:00 2014 -0400
+++ b/go/types.cc	Tue May 06 01:15:54 2014 -0400
@@ -8924,9 +8924,8 @@
 		   Methods** all_methods)
 {
   *all_methods = NULL;
-  Types_seen types_seen;
-  Type::add_methods_for_type(type, NULL, 0, false, false, &types_seen,
-			 all_methods);
+  std::vector seen;
+  Type::add_methods_for_type(type, NULL, 0, false, false, &seen, all_methods);
   Type::build_stub_methods(gogo, type, *all_methods, location);
 }
 
@@ -8944,7 +8943,7 @@
 			   unsigned int depth,
 			   bool is_embedded_pointer,
 			   bool needs_stub_method,
-			   Types_seen* types_seen,
+			   std::vector* seen,
 			   Methods** methods)
 {
   // Pointer types may not have methods.
@@ -8954,19 +8953,24 @@
   const Named_type* nt = type->named_type();
   if (nt != NULL)
 {
-  std::pair ins = types_seen->insert(nt);
-  if (!ins.second)
-	return;
-}
-
-  if (nt != NULL)
-Type::add_local_methods_for_type(nt, field_indexes, depth,
- is_embedded_pointer, needs_stub_method,
- methods);
+  for (std::vector::const_iterator p = seen->begin();
+	   p != seen->end();
+	   ++p)
+	{
+	  if (*p == nt)
+	return;
+	}
+
+  seen->push_back(nt);
+
+  Type::add_local_methods_for_type(nt, field_indexes, depth,
+   is_embedded_pointer, needs_stub_method,
+   methods);
+}
 
   Type::add_embedded_methods_for_type(type, field_indexes, depth,
   is_embedded_pointer, needs_stub_method,
-  types_seen, methods);
+  seen, methods);
 
   // If we are called with depth > 0, then we are looking at an
   // anonymous field of a struct.  If such a field has interface type,
@@ -8975,6 +8979,9 @@
   // following the usual rules for an interface type.
   if (depth > 0)
 Type::add_interface_methods_for_type(type, field_indexes, depth, methods);
+
+  if (nt != NULL)
+  seen->pop_back();
 }
 
 // Add the local methods for the named type NT to *METHODS.  The
@@ -9020,7 +9027,7 @@
 unsigned int depth,
 bool is_embedded_pointer,
 bool needs_stub_method,
-Types_seen* types_seen,
+std::vector* seen,
 Methods** methods)
 {
   // Look for anonymous fields in TYPE.  TYPE has fields if it is a
@@ -9064,7 +9071,7 @@
  (needs_stub_method
   || is_pointer
   || i > 0),
- types_seen,
+ seen,
  methods);
 }
 }
diff -r 4e7f09e27159 go/types.h
--- a/go/types.h	Mon May 05 21:13:00 2014 -0400
+++ b/go/types.h	Tue May 06 01:15:54 2014 -0400
@@ -1171,14 +1171,11 @@
   static tree
   build_receive_return_type(tree type);
 
-  // A hash table we use to avoid infinite recursion.
-  typedef Unordered_set_hash(const Named_type*, Type_hash_identical,
-			 Type_identical) Types_seen;
-
   // Add all methods for TYPE to the list of methods for THIS.
   static void
   add_methods_for_type(const Type* type, const Method::Field_indexes*,
-		   unsigned int depth, bool, bool, Types_seen*,
+		   unsigned int depth, bool, bool,
+		   std::vector*,
 		   Methods**);
 
   static void
@@ -1189,7 +1186,8 @@
   static void
   add_embedded_methods_for_type(const Type* type,
 const Method::Field_indexes*,
-unsigned int depth, bool, bool, Types_seen*,
+unsigned int depth, bool, bool,
+std::vector*,
 Methods**);
 
   static void


RFA: Fix calculation of size of builtin setjmp buffer

2014-05-06 Thread Nick Clifton
Hi Guys,

  There is a small bug in the computation for the size of the builtin
  setjmp buffer.  The size is based upon BITS_PER_WORD / POINTER_SIZE
  which for most targets equates to 1.  But for targets where pointers
  are larger than a word, it equates to zero.  This leads to stack
  corruption and all kinds of fun things.

  The patch is obvious - see below - but since it affects generic code
  and might have consequences which I have not foreseen, I thought it
  best to ask for approval first.

  No regressions with an x86_64-pc-linux toolchain, and quite a few G++
  testsuite fixes for an rl78-elf toolchain.

  OK to apply ?

Cheers
  Nick

2014-05-06  Nick Clifton  

* except.c (init_eh): Fix computation of builtin setjmp buffer
size.

Index: gcc/except.c
===
--- gcc/except.c(revision 210096)
+++ gcc/except.c(working copy)
@@ -287,7 +287,7 @@
 #endif
 #else
   /* builtin_setjmp takes a pointer to 5 words.  */
-  tmp = size_int (5 * BITS_PER_WORD / POINTER_SIZE - 1);
+  tmp = size_int (5 * POINTER_SIZE / BITS_PER_WORD - 1);
 #endif
   tmp = build_index_type (tmp);
   tmp = build_array_type (ptr_type_node, tmp);


Re: GCC's -fsplit-stack disturbing Mach's vm_allocate

2014-05-06 Thread Samuel Thibault
Just to explicitly ask for it:

Svante Signell, le Tue 06 May 2014 10:06:49 +0200, a écrit :
> For some (yet) unknown reason all libgo tests fails with a segfault when
> run in the build tree: make, sh or something else, the test commands are
> rather hard to track.

Doesn't that dump a core?  Do you have /servers/crash properly pointing
to /servers/crash-dump-core and ulimit -u set to unlimited?

> However, running the tests manually, sigh!, after installing gccgo and
> libgo5 from gcc-4.9-4.9.0-1 with split stack support the result is as
> follows:
> 
> Total: 122
> PASS: 95
> FAIL: 27

Good! :)

> Number of tests succeeding with libpthread's stack guard fixed: 33 (and
> the other libc fixes)

I'm not sure to understand: does it mean only 33 pass instead of 95?

> Note: In many of the failing tests, only a small subset of each test
> fails.

Ok, that's a good sign.

Samuel


Re: [PATCH, Pointer Bounds Checker 9/x] Cgraph extension

2014-05-06 Thread Ilya Enkovich
Ping

2014-04-16 18:03 GMT+04:00 Ilya Enkovich :
> Hi,
>
> This patch introduces changes in call graph for Pointer Bounds Checker.
>
> New fields instrumented_version, instrumentation_clone and orig_decl are 
> added for cgraph_node:
>  - instrumentation_clone field is 1 for nodes created for instrumented 
> version of functions
>  - instrumented_version points to instrumented/original node
>  - orig_decl holds original function declaration for instrumented nodes in 
> case original node is removed
>
> IPA_REF_CHKP reference type is introduced for nodes to reference instrumented 
> function versions from originals.  It is used to have proper reachability 
> analysis.
>
> When original function bodies are not needed anymore, functions are 
> transformed into thunks having call edge to the instrumented function.  
> Therefore new field appeared in cgraph_thunk_info to mark such thunks.
>
> Does it look OK?
>
> Bootstrapped and tested on linux-x86_64.
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2014-04-16  Ilya Enkovich  
>
> * cgraph.h (cgraph_thunk_info): Add add_pointer_bounds_args
> field.
> (cgraph_node): Add instrumented_version, orig_decl and
> instrumentation_clone fields.
> (symtab_alias_target): Allow IPA_REF_CHKP reference.
> * cgraph.c (cgraph_remove_node): Fix instrumented_version
> of the referenced node if any.
> (dump_cgraph_node): Dump instrumentation_clone and
> instrumented_version fields.
> (verify_cgraph_node): Check correctness of IPA_REF_CHKP
> references and instrumentation thunks.
> * cgraphbuild.c (rebuild_cgraph_edges): Rebuild IPA_REF_CHKP
> reference.
> (cgraph_rebuild_references): Likewise.
> * cgraphunit.c (assemble_thunks_and_aliases): Skip thunks
> calling instrumneted function version.
> * ipa-ref.h (ipa_ref_use): Add IPA_REF_CHKP.
> (ipa_ref): increase size of use field.
> * ipa-ref.c (ipa_ref_use_name): Add element for IPA_REF_CHKP.
> * lto-cgraph.c (lto_output_node): Output instrumentation_clone,
> thunk.add_pointer_bounds_args and orig_decl field.
> (lto_output_ref): Adjust to new ipa_ref::use field size.
> (input_overwrite_node): Read instrumentation_clone field.
> (input_node): Read thunk.add_pointer_bounds_args and orig_decl
> fields.
> (input_ref): Adjust to new ipa_ref::use field size.
> (input_cgraph_1): Compute instrumented_version fields and restore
> IDENTIFIER_TRANSPARENT_ALIAS chains.
> * lto-streamer.h (LTO_minor_version): Change minor version from
> 0 to 1.
> * ipa.c (symtab_remove_unreachable_nodes): Consider instrumented
> clone as address taken if the original one is address taken.
> (cgraph_externally_visible_p): Mark instrumented 'main' as
> externally visible.
> (function_and_variable_visibility): Filter instrumentation
> thunks.
>
>
> diff --git a/gcc/cgraph.c b/gcc/cgraph.c
> index be3661a..6210c68 100644
> --- a/gcc/cgraph.c
> +++ b/gcc/cgraph.c
> @@ -1828,6 +1828,12 @@ cgraph_remove_node (struct cgraph_node *node)
>  }
>cgraph_n_nodes--;
>
> +  if (node->instrumented_version)
> +{
> +  node->instrumented_version->instrumented_version = NULL;
> +  node->instrumented_version = NULL;
> +}
> +
>/* Clear out the node to NULL all pointers and add the node to the free
>   list.  */
>memset (node, 0, sizeof (*node));
> @@ -2070,6 +2076,11 @@ dump_cgraph_node (FILE *f, struct cgraph_node *node)
>if (indirect_calls_count)
>  fprintf (f, "  Has %i outgoing edges for indirect calls.\n",
>  indirect_calls_count);
> +
> +  if (node->instrumentation_clone)
> +fprintf (f, "  Is instrumented version.\n");
> +  else if (node->instrumented_version)
> +fprintf (f, "  Has instrumented version.\n");
>  }
>
>
> @@ -2850,7 +2861,9 @@ verify_cgraph_node (struct cgraph_node *node)
> }
>for (i = 0; ipa_ref_list_reference_iterate (&node->ref_list,
>   i, ref); i++)
> -   if (ref->use != IPA_REF_ALIAS)
> +   if (ref->use == IPA_REF_CHKP)
> + ;
> +   else if (ref->use != IPA_REF_ALIAS)
>   {
> error ("Alias has non-alias reference");
> error_found = true;
> @@ -2868,6 +2881,35 @@ verify_cgraph_node (struct cgraph_node *node)
> error_found = true;
>   }
>  }
> +
> +  /* Check all nodes reference their instrumented versions.  */
> +  if (node->analyzed
> +  && node->instrumented_version
> +  && !node->instrumentation_clone)
> +{
> +  bool ref_found = false;
> +  int i;
> +  struct ipa_ref *ref;
> +
> +  for (i = 0; ipa_ref_list_reference_iterate (&node->ref_list,
> + i, ref); i++)
> +   if (ref->use == IPA_REF_CHKP)
> + 

Re: [PATCH, Pointer Bounds Checker 7/x] Call/ret ifaces

2014-05-06 Thread Ilya Enkovich
2014-04-16 17:11 GMT+04:00 Ilya Enkovich :
> Hi,
>
> This patch adds flags and ifaces to mark instrumented calls, extends return 
> stms with additional operand and introduces some basic bounds predicates.  
> These changes were previously reverted from 4.9 and I'll assume patch is OK 
> for trunk if no objections arise.
>
> Patch was bootstrapped and tested for linux-x86_64.
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2014-04-16  Ilya Enkovich  
>
> * gimple.h (gf_mask): Add GF_CALL_WITH_BOUNDS.
> (gimple_call_with_bounds_p): New.
> (gimple_call_set_with_bounds): New.
> (gimple_return_retbnd): New.
> (gimple_return_set_retbnd): New
> * rtl.h (CALL_EXPR_WITH_BOUNDS_P): New.
> * tree.h (POINTER_BOUNDS_P): New.
> (BOUNDED_TYPE_P): New.
> (BOUNDED_P): New.
> (CALL_WITH_BOUNDS_P): New.
> * gimple.c (gimple_build_return): Increase number of ops
> for return statement.
> (gimple_build_call_from_tree): Propagate CALL_WITH_BOUNDS_P
> flag.
> * gimple-pretty-print.c (dump_gimple_return): Print second op.
>
>
> diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
> index 741cd92..a792bb9 100644
> --- a/gcc/gimple-pretty-print.c
> +++ b/gcc/gimple-pretty-print.c
> @@ -547,11 +547,12 @@ dump_gimple_assign (pretty_printer *buffer, gimple gs, 
> int spc, int flags)
>  static void
>  dump_gimple_return (pretty_printer *buffer, gimple gs, int spc, int flags)
>  {
> -  tree t;
> +  tree t, t2;
>
>t = gimple_return_retval (gs);
> +  t2 = gimple_return_retbnd (gs);
>if (flags & TDF_RAW)
> -dump_gimple_fmt (buffer, spc, flags, "%G <%T>", gs, t);
> +dump_gimple_fmt (buffer, spc, flags, "%G <%T %T>", gs, t, t2);
>else
>  {
>pp_string (buffer, "return");
> @@ -560,6 +561,11 @@ dump_gimple_return (pretty_printer *buffer, gimple gs, 
> int spc, int flags)
>   pp_space (buffer);
>   dump_generic_node (buffer, t, spc, flags, false);
> }
> +  if (t2)
> +   {
> + pp_string (buffer, ", ");
> + dump_generic_node (buffer, t2, spc, flags, false);
> +   }
>pp_semicolon (buffer);
>  }
>  }
> diff --git a/gcc/gimple.c b/gcc/gimple.c
> index 2a278e4..89f9b4c 100644
> --- a/gcc/gimple.c
> +++ b/gcc/gimple.c
> @@ -180,7 +180,7 @@ gimple_build_with_ops_stat (enum gimple_code code, 
> unsigned subcode,
>  gimple
>  gimple_build_return (tree retval)
>  {
> -  gimple s = gimple_build_with_ops (GIMPLE_RETURN, ERROR_MARK, 1);
> +  gimple s = gimple_build_with_ops (GIMPLE_RETURN, ERROR_MARK, 2);
>if (retval)
>  gimple_return_set_retval (s, retval);
>return s;
> @@ -367,6 +367,7 @@ gimple_build_call_from_tree (tree t)
>gimple_call_set_va_arg_pack (call, CALL_EXPR_VA_ARG_PACK (t));
>gimple_call_set_nothrow (call, TREE_NOTHROW (t));
>gimple_set_no_warning (call, TREE_NO_WARNING (t));
> +  gimple_call_set_with_bounds (call, CALL_WITH_BOUNDS_P (t));
>
>return call;
>  }
> diff --git a/gcc/gimple.h b/gcc/gimple.h
> index 11959a8..8b8693c 100644
> --- a/gcc/gimple.h
> +++ b/gcc/gimple.h
> @@ -90,6 +90,7 @@ enum gf_mask {
>  GF_CALL_NOTHROW= 1 << 4,
>  GF_CALL_ALLOCA_FOR_VAR = 1 << 5,
>  GF_CALL_INTERNAL   = 1 << 6,
> +GF_CALL_WITH_BOUNDS= 1 << 7,
>  GF_OMP_PARALLEL_COMBINED   = 1 << 0,
>  GF_OMP_FOR_KIND_MASK   = 3 << 0,
>  GF_OMP_FOR_KIND_FOR= 0 << 0,
> @@ -2438,6 +2439,31 @@ gimple_call_internal_p (const_gimple gs)
>  }
>
>
> +/* Return true if call GS is marked as instrumented by
> +   Pointer Bounds Checker.  */
> +
> +static inline bool
> +gimple_call_with_bounds_p (const_gimple gs)
> +{
> +  GIMPLE_CHECK (gs, GIMPLE_CALL);
> +  return (gs->subcode & GF_CALL_WITH_BOUNDS) != 0;
> +}
> +
> +
> +/* If INSTRUMENTED_P is true, marm statement GS as instrumented by
> +   Pointer Bounds Checker.  */
> +
> +static inline void
> +gimple_call_set_with_bounds (gimple gs, bool with_bounds)
> +{
> +  GIMPLE_CHECK (gs, GIMPLE_CALL);
> +  if (with_bounds)
> +gs->subcode |= GF_CALL_WITH_BOUNDS;
> +  else
> +gs->subcode &= ~GF_CALL_WITH_BOUNDS;
> +}
> +
> +
>  /* Return the target of internal call GS.  */
>
>  static inline enum internal_fn
> @@ -5517,6 +5543,26 @@ gimple_return_set_retval (gimple gs, tree retval)
>  }
>
>
> +/* Return the return bounds for GIMPLE_RETURN GS.  */
> +
> +static inline tree
> +gimple_return_retbnd (const_gimple gs)
> +{
> +  GIMPLE_CHECK (gs, GIMPLE_RETURN);
> +  return gimple_op (gs, 1);
> +}
> +
> +
> +/* Set RETVAL to be the return bounds for GIMPLE_RETURN GS.  */
> +
> +static inline void
> +gimple_return_set_retbnd (gimple gs, tree retval)
> +{
> +  GIMPLE_CHECK (gs, GIMPLE_RETURN);
> +  gimple_set_op (gs, 1, retval);
> +}
> +
> +
>  /* Returns true when the gimple statement STMT is any of the OpenMP types.  
> */
>
>  #define CASE_GIMPLE_OMP\
> diff --git a/gcc/rtl.h b/gcc

Re: Hurd port for gcc go PATCH 7-9 (9)

2014-05-06 Thread Svante Signell
On Tue, 2014-05-06 at 11:07 +0200, Samuel Thibault wrote:
> Svante Signell, le Tue 06 May 2014 10:58:38 +0200, a écrit :
> > The patch for st_dev by Thomas Schwinge was not liked by Samuel
> 
> Uh?
> 
> I said “These should be fine, however.” and “a sed rule can't hurt even
> if there is no occurrence...”
> 
> So just keep that precise part back as it was, no need for being clumsy.
> 
> What I however said was:
> 
> “Err, these seem to get applied to all systems, not just GNU/Hurd, isn't
> that a concern?”
> 
> By that, I mean this:
> 
> > +# Special treatment of EWOULDBLOCK for GNU/Hurd
> > +# /usr/include/bits/errno.h: #define EWOULDBLOCK EAGAIN
> > +egrep '^const EWOULDBLOCK = Errno(_EWOULDBLOCK)' ${OUT} | \
> > +sed -i.bak -e 's/_EWOULDBLOCK/_EAGAIN/' ${OUT}
> > +

This applies to all systems yes, how to modify?

> and that:
> 
> > +# Special treatment of SYS_FCNTL for GNU/Hurd
> > +if ! grep '^const SYS_FCNTL' ${OUT} >/dev/null 2>&1; then
> > +  echo "const SYS_FCNTL = 0" >> ${OUT}
> > +fi

And this applies to systems not defining FCNTL.
How many systems could possibly be affected?
 
> AIUI, the patch you propose does those changes for all systems, not just
> GNU/Hurd.  That most probably will pose a problem.

And you wrote in your reply to the above: see e.g.
http://gcc.gnu.org/ml/gcc-patches/2014-04/msg00644.html
> These should be fine, however.

I asked for help with sed but have not obtained any yet, so what to do?



Re: [PATCH, Pointer Bounds Checker 8/x] Add varpool node field

2014-05-06 Thread Ilya Enkovich
2014-04-16 17:18 GMT+04:00 Ilya Enkovich :
> Hi,
>
> This patch add new field for varpool_node to mark vars requiring bounds 
> initalization.  These changes were previously reverted from 4.9 and I'll 
> assume patch is OK for trunk if no objections arise.
>
> Patch was bootstrapped and tested for linux-x86_64.
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2014-04-16  Ilya Enkovich  
>
> * cgraph.h (varpool_node): Add need_bounds_init field.
> * lto-cgraph.c (lto_output_varpool_node): Output
> need_bounds_init value.
> (input_varpool_node): Read need_bounds_init value.
> * varpool.c (dump_varpool_node): Dump need_bounds_init field.
>
>
> diff --git a/gcc/cgraph.h b/gcc/cgraph.h
> index 15310d8..a6a51cf 100644
> --- a/gcc/cgraph.h
> +++ b/gcc/cgraph.h
> @@ -640,6 +640,10 @@ public:
>/* Set when variable is scheduled to be assembled.  */
>unsigned output : 1;
>
> +  /* Set when variable has statically initialized pointer
> + or is a static bounds variable and needs initalization.  */
> +  unsigned need_bounds_init : 1;
> +
>/* Set if the variable is dynamically initialized, except for
>   function local statics.   */
>unsigned dynamically_initialized : 1;
> diff --git a/gcc/lto-cgraph.c b/gcc/lto-cgraph.c
> index 173067f..999ce3d 100644
> --- a/gcc/lto-cgraph.c
> +++ b/gcc/lto-cgraph.c
> @@ -585,6 +585,7 @@ lto_output_varpool_node (struct lto_simple_output_block 
> *ob, varpool_node *node,
>  && boundary_p && !DECL_EXTERNAL (node->decl), 1);
>   /* in_other_partition.  */
>  }
> +  bp_pack_value (&bp, node->need_bounds_init, 1);
>streamer_write_bitpack (&bp);
>if (node->same_comdat_group && !boundary_p)
>  {
> @@ -1160,6 +1161,7 @@ input_varpool_node (struct lto_file_decl_data 
> *file_data,
>node->analyzed = bp_unpack_value (&bp, 1);
>node->used_from_other_partition = bp_unpack_value (&bp, 1);
>node->in_other_partition = bp_unpack_value (&bp, 1);
> +  node->need_bounds_init = bp_unpack_value (&bp, 1);
>if (node->in_other_partition)
>  {
>DECL_EXTERNAL (node->decl) = 1;
> diff --git a/gcc/varpool.c b/gcc/varpool.c
> index acb5221..0eeb2b6 100644
> --- a/gcc/varpool.c
> +++ b/gcc/varpool.c
> @@ -205,6 +205,8 @@ dump_varpool_node (FILE *f, varpool_node *node)
>  fprintf (f, " initialized");
>if (node->output)
>  fprintf (f, " output");
> +  if (node->need_bounds_init)
> +fprintf (f, " need-bounds-init");
>if (TREE_READONLY (node->decl))
>  fprintf (f, " read-only");
>if (ctor_for_folding (node->decl) != error_mark_node)

Will install it in a couple of days.

Ilya


Re: [PATCH, Pointer Bounds Checker 6/x] New static constructor types

2014-05-06 Thread Ilya Enkovich
2014-04-16 16:33 GMT+04:00 Ilya Enkovich :
> Hi,
>
> This patch add new static constructor types used by Pointer Bounds Checker.  
> It was approved earlier for 4.9 and I'll assume patch is OK for trunk if no 
> objections arise.
>
> Patch was bootstrapped and tested for linux-x86_64.
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2014-04-16  Ilya Enkovich  
>
> * ipa.c (cgraph_build_static_cdtor_1): Support contructors
> with "chkp ctor" and "bnd_legacy" attributes.
> * gimplify.c (gimplify_init_constructor): Avoid infinite
> loop during gimplification of bounds initializer.
>
>
> diff --git a/gcc/gimplify.c b/gcc/gimplify.c
> index 7441784..67ab515 100644
> --- a/gcc/gimplify.c
> +++ b/gcc/gimplify.c
> @@ -3803,10 +3803,19 @@ gimplify_init_constructor (tree *expr_p, gimple_seq 
> *pre_p, gimple_seq *post_p,
>individual element initialization.  Also don't do this for small
>all-zero initializers (which aren't big enough to merit
>clearing), and don't try to make bitwise copies of
> -  TREE_ADDRESSABLE types.  */
> +  TREE_ADDRESSABLE types.
> +
> +  We cannot apply such transformation when compiling chkp static
> +  initializer because creation of initializer image in the memory
> +  will require static initialization of bounds for it.  It should
> +  result in another gimplification of similar initializer and we
> +  may fall into infinite loop.  */
> if (valid_const_initializer
> && !(cleared || num_nonzero_elements == 0)
> -   && !TREE_ADDRESSABLE (type))
> +   && !TREE_ADDRESSABLE (type)
> +   && (!current_function_decl
> +   || !lookup_attribute ("chkp ctor",
> + DECL_ATTRIBUTES 
> (current_function_decl
>   {
> HOST_WIDE_INT size = int_size_in_bytes (type);
> unsigned int align;
> diff --git a/gcc/ipa.c b/gcc/ipa.c
> index 26e9b03..5ab3aed 100644
> --- a/gcc/ipa.c
> +++ b/gcc/ipa.c
> @@ -1345,9 +1345,11 @@ make_pass_ipa_whole_program_visibility (gcc::context 
> *ctxt)
>  }
>
>  /* Generate and emit a static constructor or destructor.  WHICH must
> -   be one of 'I' (for a constructor) or 'D' (for a destructor).  BODY
> -   is a STATEMENT_LIST containing GENERIC statements.  PRIORITY is the
> -   initialization priority for this constructor or destructor.
> +   be one of 'I' (for a constructor), 'D' (for a destructor), 'P'
> +   (for chp static vars constructor) or 'B' (for chkp static bounds
> +   constructor).  BODY is a STATEMENT_LIST containing GENERIC
> +   statements.  PRIORITY is the initialization priority for this
> +   constructor or destructor.
>
> FINAL specify whether the externally visible name for collect2 should
> be produced. */
> @@ -1406,6 +1408,20 @@ cgraph_build_static_cdtor_1 (char which, tree body, 
> int priority, bool final)
>DECL_STATIC_CONSTRUCTOR (decl) = 1;
>decl_init_priority_insert (decl, priority);
>break;
> +case 'P':
> +  DECL_STATIC_CONSTRUCTOR (decl) = 1;
> +  DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("chkp ctor"),
> + NULL,
> + NULL_TREE);
> +  decl_init_priority_insert (decl, priority);
> +  break;
> +case 'B':
> +  DECL_STATIC_CONSTRUCTOR (decl) = 1;
> +  DECL_ATTRIBUTES (decl) = tree_cons (get_identifier ("bnd_legacy"),
> + NULL,
> + NULL_TREE);
> +  decl_init_priority_insert (decl, priority);
> +  break;
>  case 'D':
>DECL_STATIC_DESTRUCTOR (decl) = 1;
>decl_fini_priority_insert (decl, priority);
> @@ -1423,9 +1439,11 @@ cgraph_build_static_cdtor_1 (char which, tree body, 
> int priority, bool final)
>  }
>
>  /* Generate and emit a static constructor or destructor.  WHICH must
> -   be one of 'I' (for a constructor) or 'D' (for a destructor).  BODY
> -   is a STATEMENT_LIST containing GENERIC statements.  PRIORITY is the
> -   initialization priority for this constructor or destructor.  */
> +   be one of 'I' (for a constructor), 'D' (for a destructor), 'P'
> +   (for chkp static vars constructor) or 'B' (for chkp static bounds
> +   constructor).  BODY is a STATEMENT_LIST containing GENERIC
> +   statements.  PRIORITY is the initialization priority for this
> +   constructor or destructor.  */
>
>  void
>  cgraph_build_static_cdtor (char which, tree body, int priority)

Will install it in a couple of days.

Ilya


Re: [PATCH, Pointer Bounds Checker 5/x] Attributes

2014-05-06 Thread Ilya Enkovich
Ping

2014-04-16 16:26 GMT+04:00 Ilya Enkovich :
> Hi,
>
> This patch introduces attributes used by Pointer Bounds Checker.  Comparing 
> to what was approved for 4.9, this one has additional attribute 
> 'bnd_instrument' to be used for selective instrumentation.
>
> Bootstrapped and tested on linux-x86_64.
>
> OK for trunk?
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2014-04-16  Ilya Enkovich  
>
> * c-family/c-common.c (handle_bnd_variable_size_attribute): New.
> (handle_bnd_legacy): New.
> (handle_bnd_instrument): New.
> (c_common_attribute_table): Add bnd_variable_size, bnd_legacy
> and bnd_instrument.
> * doc/extend.texi: Document bnd_variable_size, bnd_legacy and
> bnd_instrument attributes.
>
>
> diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
> index 1d56bc0..babf89a 100644
> --- a/gcc/c-family/c-common.c
> +++ b/gcc/c-family/c-common.c
> @@ -379,6 +379,9 @@ static tree handle_omp_declare_simd_attribute (tree *, 
> tree, tree, int,
>bool *);
>  static tree handle_omp_declare_target_attribute (tree *, tree, tree, int,
>  bool *);
> +static tree handle_bnd_variable_size_attribute (tree *, tree, tree, int, 
> bool *);
> +static tree handle_bnd_legacy (tree *, tree, tree, int, bool *);
> +static tree handle_bnd_instrument (tree *, tree, tree, int, bool *);
>
>  static void check_function_nonnull (tree, int, tree *);
>  static void check_nonnull_arg (void *, tree, unsigned HOST_WIDE_INT);
> @@ -772,6 +775,12 @@ const struct attribute_spec c_common_attribute_table[] =
>   handle_alloc_align_attribute, false },
>{ "assume_aligned",1, 2, false, true, true,
>   handle_assume_aligned_attribute, false },
> +  { "bnd_variable_size",  0, 0, true,  false, false,
> + handle_bnd_variable_size_attribute, false },
> +  { "bnd_legacy", 0, 0, true, false, false,
> + handle_bnd_legacy, false },
> +  { "bnd_instrument", 0, 0, true, false, false,
> + handle_bnd_instrument, false },
>{ NULL, 0, 0, false, false, false, NULL, false }
>  };
>
> @@ -8118,6 +8127,54 @@ handle_fnspec_attribute (tree *node ATTRIBUTE_UNUSED, 
> tree ARG_UNUSED (name),
>return NULL_TREE;
>  }
>
> +/* Handle a "bnd_variable_size" attribute; arguments as in
> +   struct attribute_spec.handler.  */
> +
> +static tree
> +handle_bnd_variable_size_attribute (tree *node, tree name, tree ARG_UNUSED 
> (args),
> +   int ARG_UNUSED (flags), bool 
> *no_add_attrs)
> +{
> +  if (TREE_CODE (*node) != FIELD_DECL)
> +{
> +  warning (OPT_Wattributes, "%qE attribute ignored", name);
> +  *no_add_attrs = true;
> +}
> +
> +  return NULL_TREE;
> +}
> +
> +/* Handle a "bnd_legacy" attribute; arguments as in
> +   struct attribute_spec.handler.  */
> +
> +static tree
> +handle_bnd_legacy (tree *node, tree name, tree ARG_UNUSED (args),
> +  int ARG_UNUSED (flags), bool *no_add_attrs)
> +{
> +  if (TREE_CODE (*node) != FUNCTION_DECL)
> +{
> +  warning (OPT_Wattributes, "%qE attribute ignored", name);
> +  *no_add_attrs = true;
> +}
> +
> +  return NULL_TREE;
> +}
> +
> +/* Handle a "bnd_instrument" attribute; arguments as in
> +   struct attribute_spec.handler.  */
> +
> +static tree
> +handle_bnd_instrument (tree *node, tree name, tree ARG_UNUSED (args),
> +  int ARG_UNUSED (flags), bool *no_add_attrs)
> +{
> +  if (TREE_CODE (*node) != FUNCTION_DECL)
> +{
> +  warning (OPT_Wattributes, "%qE attribute ignored", name);
> +  *no_add_attrs = true;
> +}
> +
> +  return NULL_TREE;
> +}
> +
>  /* Handle a "warn_unused" attribute; arguments as in
> struct attribute_spec.handler.  */
>
> diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
> index 1c74990..3c18829 100644
> --- a/gcc/doc/extend.texi
> +++ b/gcc/doc/extend.texi
> @@ -2182,7 +2182,7 @@ attributes are currently defined for functions on all 
> targets:
>  @code{returns_nonnull}, @code{gnu_inline},
>  @code{externally_visible}, @code{hot}, @code{cold}, @code{artificial},
>  @code{no_sanitize_address}, @code{no_address_safety_analysis},
> -@code{no_sanitize_undefined},
> +@code{no_sanitize_undefined}, @code{bnd_legacy}, @code{bnd_instrument},
>  @code{error} and @code{warning}.
>  Several other attributes are defined for functions on particular
>  target systems.  Other attributes, including @code{section} are
> @@ -3684,6 +3684,18 @@ The @code{no_sanitize_undefined} attribute on 
> functions is used
>  to inform the compiler that it should not check for undefined behavior
>  in the function when compiling with the @option{-fsanitize=undefined} option.
>
> +@item bnd_legacy
> +@cindex @code{bnd_legacy} function attribute
> +The @code{bnd_legac

Re: [PATCH, Pointer Bounds Checker 4/x] Built-in functions

2014-05-06 Thread Ilya Enkovich
PING

2014-04-16 16:19 GMT+04:00 Ilya Enkovich :
> Hi,
>
> This patch introduces built-in functions used by Pointer Bounds Checker.  It 
> is mostly similar to what was reverted from 4.9, I just added types and 
> attributes to builtins.  This patch also introduces pointer_bounds_type_node 
> to be used in built-in function type declarations.
>
> Bootstrapped and tested on linux-x86_64.
>
> OK for trunk?
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2014-04-16  Ilya Enkovich  
>
> * tree-core.h (tree_index): Add TI_POINTER_BOUNDS_TYPE.
> * tree.h (pointer_bounds_type_node): New.
> * tree.c (build_common_tree_nodes): Initialize
> pointer_bounds_type_node.
> * builtin-types.def (BT_BND): New.
> (BT_FN_PTR_CONST_PTR): New.
> (BT_FN_CONST_PTR_CONST_PTR): New.
> (BT_FN_BND_CONST_PTR): New.
> (BT_FN_CONST_PTR_BND): New.
> (BT_FN_PTR_CONST_PTR_SIZE): New.
> (BT_FN_PTR_CONST_PTR_CONST_PTR): New.
> (BT_FN_VOID_PTRPTR_CONST_PTR): New.
> (BT_FN_VOID_CONST_PTR_SIZE): New.
> (BT_FN_VOID_PTR_BND): New.
> (BT_FN_CONST_PTR_CONST_PTR_CONST_PTR): New.
> (BT_FN_BND_CONST_PTR_SIZE): New.
> (BT_FN_PTR_CONST_PTR_CONST_PTR_SIZE): New.
> (BT_FN_VOID_CONST_PTR_BND_CONST_PTR): New.
> * chkp-builtins.def: New.
> * builtins.def: include chkp-builtins.def.
> (DEF_CHKP_BUILTIN): New.
> * builtins.c (expand_builtin): Support BUILT_IN_CHKP_INIT_PTR_BOUNDS,
> BUILT_IN_CHKP_NULL_PTR_BOUNDS, BUILT_IN_CHKP_COPY_PTR_BOUNDS,
> BUILT_IN_CHKP_CHECK_PTR_LBOUNDS, BUILT_IN_CHKP_CHECK_PTR_UBOUNDS,
> BUILT_IN_CHKP_CHECK_PTR_BOUNDS, BUILT_IN_CHKP_SET_PTR_BOUNDS,
> BUILT_IN_CHKP_NARROW_PTR_BOUNDS, BUILT_IN_CHKP_STORE_PTR_BOUNDS,
> BUILT_IN_CHKP_GET_PTR_LBOUND, BUILT_IN_CHKP_GET_PTR_UBOUND,
> BUILT_IN_CHKP_BNDMK, BUILT_IN_CHKP_BNDSTX, BUILT_IN_CHKP_BNDCL,
> BUILT_IN_CHKP_BNDCU, BUILT_IN_CHKP_BNDLDX, BUILT_IN_CHKP_BNDRET,
> BUILT_IN_CHKP_INTERSECT, BUILT_IN_CHKP_NARROW,
> BUILT_IN_CHKP_EXTRACT_LOWER, BUILT_IN_CHKP_EXTRACT_UPPER.
> * c-family/c.opt (fcheck-pointer-bounds): New.
> * toplev.c (process_options): Check Pointer Bounds Checker is 
> supported.
> * doc/extend.texi: Document Pointer Bounds Checker built-in functions.
>
>
> diff --git a/gcc/builtin-types.def b/gcc/builtin-types.def
> index fba9c7d..2e5f361 100644
> --- a/gcc/builtin-types.def
> +++ b/gcc/builtin-types.def
> @@ -133,6 +133,8 @@ DEF_PRIMITIVE_TYPE (BT_I4, builtin_type_for_size 
> (BITS_PER_UNIT*4, 1))
>  DEF_PRIMITIVE_TYPE (BT_I8, builtin_type_for_size (BITS_PER_UNIT*8, 1))
>  DEF_PRIMITIVE_TYPE (BT_I16, builtin_type_for_size (BITS_PER_UNIT*16, 1))
>
> +DEF_PRIMITIVE_TYPE (BT_BND, pointer_bounds_type_node)
> +
>  DEF_POINTER_TYPE (BT_PTR_CONST_STRING, BT_CONST_STRING)
>  DEF_POINTER_TYPE (BT_PTR_LONG, BT_LONG)
>  DEF_POINTER_TYPE (BT_PTR_ULONGLONG, BT_ULONGLONG)
> @@ -234,6 +236,10 @@ DEF_FUNCTION_TYPE_1 (BT_FN_UINT16_UINT16, BT_UINT16, 
> BT_UINT16)
>  DEF_FUNCTION_TYPE_1 (BT_FN_UINT32_UINT32, BT_UINT32, BT_UINT32)
>  DEF_FUNCTION_TYPE_1 (BT_FN_UINT64_UINT64, BT_UINT64, BT_UINT64)
>  DEF_FUNCTION_TYPE_1 (BT_FN_BOOL_INT, BT_BOOL, BT_INT)
> +DEF_FUNCTION_TYPE_1 (BT_FN_PTR_CONST_PTR, BT_PTR, BT_CONST_PTR)
> +DEF_FUNCTION_TYPE_1 (BT_FN_CONST_PTR_CONST_PTR, BT_CONST_PTR, BT_CONST_PTR)
> +DEF_FUNCTION_TYPE_1 (BT_FN_BND_CONST_PTR, BT_BND, BT_CONST_PTR)
> +DEF_FUNCTION_TYPE_1 (BT_FN_CONST_PTR_BND, BT_CONST_PTR, BT_BND)
>
>  DEF_POINTER_TYPE (BT_PTR_FN_VOID_PTR, BT_FN_VOID_PTR)
>
> @@ -347,6 +353,13 @@ DEF_FUNCTION_TYPE_2 (BT_FN_BOOL_SIZE_CONST_VPTR, 
> BT_BOOL, BT_SIZE,
>  BT_CONST_VOLATILE_PTR)
>  DEF_FUNCTION_TYPE_2 (BT_FN_BOOL_INT_BOOL, BT_BOOL, BT_INT, BT_BOOL)
>  DEF_FUNCTION_TYPE_2 (BT_FN_VOID_UINT_UINT, BT_VOID, BT_UINT, BT_UINT)
> +DEF_FUNCTION_TYPE_2 (BT_FN_PTR_CONST_PTR_SIZE, BT_PTR, BT_CONST_PTR, BT_SIZE)
> +DEF_FUNCTION_TYPE_2 (BT_FN_PTR_CONST_PTR_CONST_PTR, BT_PTR, BT_CONST_PTR, 
> BT_CONST_PTR)
> +DEF_FUNCTION_TYPE_2 (BT_FN_VOID_PTRPTR_CONST_PTR, BT_VOID, BT_PTR_PTR, 
> BT_CONST_PTR)
> +DEF_FUNCTION_TYPE_2 (BT_FN_VOID_CONST_PTR_SIZE, BT_VOID, BT_CONST_PTR, 
> BT_SIZE)
> +DEF_FUNCTION_TYPE_2 (BT_FN_VOID_PTR_BND, BT_VOID, BT_PTR, BT_BND)
> +DEF_FUNCTION_TYPE_2 (BT_FN_CONST_PTR_CONST_PTR_CONST_PTR, BT_CONST_PTR, 
> BT_CONST_PTR, BT_CONST_PTR)
> +DEF_FUNCTION_TYPE_2 (BT_FN_BND_CONST_PTR_SIZE, BT_BND, BT_CONST_PTR, BT_SIZE)
>
>  DEF_POINTER_TYPE (BT_PTR_FN_VOID_PTR_PTR, BT_FN_VOID_PTR_PTR)
>
> @@ -430,6 +443,8 @@ DEF_FUNCTION_TYPE_3 (BT_FN_VOID_VPTR_I4_INT, BT_VOID, 
> BT_VOLATILE_PTR, BT_I4, BT
>  DEF_FUNCTION_TYPE_3 (BT_FN_VOID_VPTR_I8_INT, BT_VOID, BT_VOLATILE_PTR, 
> BT_I8, BT_INT)
>  DEF_FUNCTION_TYPE_3 (BT_FN_VOID_VPTR_I16_INT, BT_VOID, BT_VOLATILE_PTR, 
> BT_I16, BT_INT)
>  DEF_FUNCTION_TYPE_3 (BT_FN_INT_PTRPTR_SIZE_SIZE, BT_INT, BT_PTR_PTR, 
> BT_SIZE, BT_SIZE)
> +DEF_FUNCTION_TYPE_3 (BT_FN_PTR_CO

Re: [PATCH, Pointer Bounds Checker 3/x] Target hooks for Pointer Bounds Checker

2014-05-06 Thread Ilya Enkovich
PING

2014-04-16 15:52 GMT+04:00 Ilya Enkovich :
> Hi,
>
> This patch introduces target hooks to be used by Pointer Bounds Checker.  
> Hooks set is different from what was approved for 4.9 (and later reverted).  
> I added hooks to work with returned bounds and to prepare incoming bounds for 
> vararg functions.  It allowed to remove some target assumptions from expand 
> code.
>
> Bootstrapped and tested on linux-x86_64.
>
> OK for trunk?
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2014-04-16  Ilya Enkovich  
>
> * target.def (builtin_chkp_function): New.
> (chkp_bound_type): New.
> (chkp_bound_mode): New.
> (chkp_make_bounds_constant): New.
> (chkp_initialize_bounds): New.
> (fn_abi_va_list_bounds_size): New.
> (load_bounds_for_arg): New.
> (store_bounds_for_arg): New.
> (load_returned_bounds): New.
> (store_returned_bounds): New.
> (chkp_function_value_bounds): New.
> (setup_incoming_vararg_bounds): New.
> * targhooks.h (default_load_bounds_for_arg): New.
> (default_store_bounds_for_arg): New.
> (default_load_returned_bounds): New.
> (default_store_returned_bounds): New.
> (default_fn_abi_va_list_bounds_size): New.
> (default_chkp_bound_type): New.
> (default_chkp_bound_mode): New.
> (default_builtin_chkp_function): New.
> (default_chkp_function_value_bounds): New.
> (default_chkp_make_bounds_constant): New.
> (default_chkp_initialize_bounds): New.
> (default_setup_incoming_vararg_bounds): New.
> * targhooks.c (default_load_bounds_for_arg): New.
> (default_store_bounds_for_arg): New.
> (default_load_returned_bounds): New.
> (default_store_returned_bounds): New.
> (default_fn_abi_va_list_bounds_size): New.
> (default_chkp_bound_type): New.
> (default_chkp_bound_mode); New.
> (default_builtin_chkp_function): New.
> (default_chkp_function_value_bounds): New.
> (default_chkp_make_bounds_constant): New.
> (default_chkp_initialize_bounds): New.
> (default_setup_incoming_vararg_bounds): New.
> * doc/tm.texi.in (TARGET_FN_ABI_VA_LIST_BOUNDS_SIZE): New.
> (TARGET_LOAD_BOUNDS_FOR_ARG): New.
> (TARGET_STORE_BOUNDS_FOR_ARG): New.
> (TARGET_LOAD_RETURNED_BOUNDS): New.
> (TARGET_STORE_RETURNED_BOUNDS): New.
> (TARGET_CHKP_FUNCTION_VALUE_BOUNDS): New.
> (TARGET_SETUP_INCOMING_VARARG_BOUNDS): New.
> (TARGET_BUILTIN_CHKP_FUNCTION): New.
> (TARGET_CHKP_BOUND_TYPE): New.
> (TARGET_CHKP_BOUND_MODE): New.
> (TARGET_CHKP_MAKE_BOUNDS_CONSTANT): New.
> (TARGET_CHKP_INITIALIZE_BOUNDS): New.
> * doc/tm.texi: Regenerated.
>
> diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
> index b8ca17e..d868129 100644
> --- a/gcc/doc/tm.texi
> +++ b/gcc/doc/tm.texi
> @@ -4333,6 +4333,13 @@ This hook returns the va_list type of the calling 
> convention specified by
>  The default version of this hook returns @code{va_list_type_node}.
>  @end deftypefn
>
> +@deftypefn {Target Hook} tree TARGET_FN_ABI_VA_LIST_BOUNDS_SIZE (tree 
> @var{fndecl})
> +This hook returns size for @code{va_list} object in function specified
> +by @var{fndecl}.  This hook is used by Pointer Bounds Checker to build bounds
> +for @code{va_list} object.  Return @code{integer_zero_node} if no bounds
> +should be used (e.g. @code{va_list} is a scalar pointer to the stack).
> +@end deftypefn
> +
>  @deftypefn {Target Hook} tree TARGET_CANONICAL_VA_LIST_TYPE (tree @var{type})
>  This hook returns the va_list type of the calling convention specified by the
>  type of @var{type}. If @var{type} is not a valid va_list type, it returns
> @@ -5150,6 +5157,49 @@ defined, then define this hook to return @code{true} if
>  Otherwise, you should not define this hook.
>  @end deftypefn
>
> +@deftypefn {Target Hook} rtx TARGET_LOAD_BOUNDS_FOR_ARG (rtx @var{slot}, rtx 
> @var{arg}, rtx @var{slot_no})
> +This hook is used by expand pass to emit insn to load bounds of
> +@var{arg} passed in @var{slot}.  Expand pass uses this hook in case
> +bounds of @var{arg} are not passed in register.  If @var{slot} is a
> +memory, then bounds are loaded as for regular pointer loaded from
> +memory.  If @var{slot} is not a memory then @var{slot_no} is an integer
> +constant holding number of the target dependent special slot which
> +should be used to obtain bounds.  Hook returns RTX holding loaded bounds.
> +@end deftypefn
> +
> +@deftypefn {Target Hook} void TARGET_STORE_BOUNDS_FOR_ARG (rtx @var{arg}, 
> rtx @var{slot}, rtx @var{bounds}, rtx @var{slot_no})
> +This hook is used by expand pass to emit insns to store @var{bounds} of
> +@var{arg} passed in @var{slot}.  Expand pass uses this hook in case
> +@var{bounds} of @var{arg} are not passed in register.  If @var{slot} is a
> +memory, then @var{bounds} are stored as for regular 

Re: [PATCH, i386, Pointer Bounds Checker 2/x] Intel Memory Protection Extensions (MPX) instructions support

2014-05-06 Thread Ilya Enkovich
2014-04-16 15:35 GMT+04:00 Ilya Enkovich :
> Hi,
>
> This patch introduces Intel MPX bound registers and instructions.  It was 
> approved earlier for 4.9 and had no significant changes since then.  I'll 
> assume patch is OK if no objections arise.
>
> Patch was bootstrapped and tested for linux-x86_64.
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2014-04-16  Ilya Enkovich  
>
> * mode-classes.def (MODE_BOUND): New.
> * tree.def (BOUND_TYPE): New.
> * genmodes.c (complete_mode): Support MODE_BOUND.
> (BOUND_MODE): New.
> (make_bound_mode): New.
> * machmode.h (BOUND_MODE_P): New.
> * stor-layout.c (int_mode_for_mode): Support MODE_BOUND.
> (layout_type): Support BOUND_TYPE.
> * tree-pretty-print.c (dump_generic_node): Support BOUND_TYPE.
> * tree.c (build_int_cst_wide): Support BOUND_TYPE.
> (type_contains_placeholder_1): Likewise.
> * tree.h (BOUND_TYPE_P): New.
> * varasm.c (output_constant): Support BOUND_TYPE.
> * config/i386/constraints.md (B): New.
> (Ti): New.
> (Tb): New.
> * config/i386/i386-modes.def (BND32): New.
> (BND64): New.
> * config/i386/i386-protos.h (ix86_bnd_prefixed_insn_p): New.
> * config/i386/i386.c (isa_opts): Add mmpx.
> (regclass_map): Add bound registers.
> (dbx_register_map): Likewise.
> (dbx64_register_map): Likewise.
> (svr4_dbx_register_map): Likewise.
> (PTA_MPX): New.
> (ix86_option_override_internal) Support MPX ISA.
> (ix86_code_end): Add MPX bnd prefix.
> (output_set_got): Likewise.
> (ix86_output_call_insn): Likewise.
> (get_some_local_dynamic_name): Add '!' (MPX bnd) print prefix support.
> (ix86_print_operand_punct_valid_p): Likewise.
> (ix86_print_operand_address): Support UNSPEC_BNDMK_ADDR and
> UNSPEC_BNDMK_ADDR.
> (ix86_class_likely_spilled_p): Add bound regs support.
> (ix86_hard_regno_mode_ok): Likewise.
> (x86_order_regs_for_local_alloc): Likewise.
> (ix86_bnd_prefixed_insn_p): New.
> * config/i386/i386.h (FIRST_PSEUDO_REGISTER): Fix to new value.
> (FIXED_REGISTERS): Add bound registers.
> (CALL_USED_REGISTERS): Likewise.
> (REG_ALLOC_ORDER): Likewise.
> (HARD_REGNO_NREGS): Likewise.
> (TARGET_MPX): New.
> (VALID_BND_REG_MODE): New.
> (FIRST_BND_REG): New.
> (LAST_BND_REG): New.
> (reg_class): Add BND_REGS.
> (REG_CLASS_NAMES): Likewise.
> (REG_CLASS_CONTENTS): Likewise.
> (BND_REGNO_P): New.
> (ANY_BND_REG_P): New.
> (BNDmode): New.
> (HI_REGISTER_NAMES): Add bound registers.
> * config/i386/i386.md (UNSPEC_BNDMK): New.
> (UNSPEC_BNDMK_ADDR): New.
> (UNSPEC_BNDSTX): New.
> (UNSPEC_BNDLDX): New.
> (UNSPEC_BNDLDX_ADDR): New.
> (UNSPEC_BNDCL): New.
> (UNSPEC_BNDCU): New.
> (UNSPEC_BNDCN): New.
> (UNSPEC_MPX_FENCE): New.
> (BND0_REG): New.
> (BND1_REG): New.
> (type): Add mpxmov, mpxmk, mpxchk, mpxld, mpxst.
> (length_immediate): Likewise.
> (prefix_0f): Likewise.
> (memory): Likewise.
> (prefix_rep): Check for bnd prefix.
> (BND): New.
> (bnd_ptr): New.
> (BNDCHECK): New.
> (bndcheck): New.
> (*jcc_1): Add MPX bnd prefix and fix length.
> (*jcc_2): Likewise.
> (jump): Likewise.
> (simple_return_internal): Likewise.
> (simple_return_pop_internal): Likewise.
> (*indirect_jump): Add MPX bnd prefix.
> (*tablejump_1): Likewise.
> (simple_return_internal_long): Likewise.
> (simple_return_indirect_internal): Likewise.
> (_mk): New.
> (*_mk): New.
> (mov): New.
> (*mov_internal_mpx): New.
> (_): New.
> (*_): New.
> (_ldx): New.
> (*_ldx): New.
> (_stx): New.
> (*_stx): New.
> * config/i386/predicates.md (lea_address_operand) Rename to...
> (address_no_seg_operand): ... this.
> (address_mpx_no_base_operand): New.
> (address_mpx_no_index_operand): New.
> (bnd_mem_operator): New.
> * config/i386/i386.opt (mmpx): New.

Will install it in a couple of days.

Ilya


Re: [PATCH, Pointer Bounds Checker 1/x] Pointer bounds type and mode

2014-05-06 Thread Ilya Enkovich
2014-04-16 15:00 GMT+04:00 Ilya Enkovich :
> Hi,
>
> This patch restarts the series for introducing Pointer Bounds Checker 
> instrumentation and supporting Intel Memory Protection Extension (MPX) 
> technology.  Detailed description is on GCC Wiki page: 
> http://gcc.gnu.org/wiki/Intel%20MPX%20support%20in%20the%20GCC%20compiler.
>
> The first patch introduces pointer bounds type and mode.  It was approved 
> earlier for 4.9 and had no significant changes since then.  I'll assume patch 
> is OK if no objections arise.
>
> Patch was bootstrapped and tested for linux-x86_64.
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2014-04-16  Ilya Enkovich  
>
> * mode-classes.def (MODE_POINTER_BOUNDS): New.
> * tree.def (POINTER_BOUNDS_TYPE): New.
> * genmodes.c (complete_mode): Support MODE_POINTER_BOUNDS.
> (POINTER_BOUNDS_MODE): New.
> (make_pointer_bounds_mode): New.
> * machmode.h (POINTER_BOUNDS_MODE_P): New.
> * stor-layout.c (int_mode_for_mode): Support MODE_POINTER_BOUNDS.
> (layout_type): Support POINTER_BOUNDS_TYPE.
> * tree-pretty-print.c (dump_generic_node): Support 
> POINTER_BOUNDS_TYPE.
> * tree.c (build_int_cst_wide): Support POINTER_BOUNDS_TYPE.
> (type_contains_placeholder_1): Likewise.
> * tree.h (POINTER_BOUNDS_TYPE_P): New.
> * varasm.c (output_constant): Support POINTER_BOUNDS_TYPE.
> * doc/rtl.texi (MODE_POINTER_BOUNDS): New.
>
>
> diff --git a/gcc/doc/rtl.texi b/gcc/doc/rtl.texi
> index 20b7187..3a1014d 100644
> --- a/gcc/doc/rtl.texi
> +++ b/gcc/doc/rtl.texi
> @@ -1382,6 +1382,12 @@ any @code{CC_MODE} modes listed in the 
> @file{@var{machine}-modes.def}.
>  @xref{Jump Patterns},
>  also see @ref{Condition Code}.
>
> +@findex MODE_POINTER_BOUNDS
> +@item MODE_POINTER_BOUNDS
> +Pointer bounds modes.  Used to represent values of pointer bounds type.
> +Operations in these modes may be executed as NOPs depending on hardware
> +features and environment setup.
> +
>  @findex MODE_RANDOM
>  @item MODE_RANDOM
>  This is a catchall mode class for modes which don't fit into the above
> diff --git a/gcc/genmodes.c b/gcc/genmodes.c
> index 8cc3cde..9d0b413 100644
> --- a/gcc/genmodes.c
> +++ b/gcc/genmodes.c
> @@ -333,6 +333,7 @@ complete_mode (struct mode_data *m)
>break;
>
>  case MODE_INT:
> +case MODE_POINTER_BOUNDS:
>  case MODE_FLOAT:
>  case MODE_DECIMAL_FLOAT:
>  case MODE_FRACT:
> @@ -534,6 +535,19 @@ make_special_mode (enum mode_class cl, const char *name,
>new_mode (cl, name, file, line);
>  }
>
> +#define POINTER_BOUNDS_MODE(N, Y) \
> +  make_pointer_bounds_mode (#N, Y, __FILE__, __LINE__)
> +
> +static void ATTRIBUTE_UNUSED
> +make_pointer_bounds_mode (const char *name,
> + unsigned int bytesize,
> + const char *file, unsigned int line)
> +{
> +  struct mode_data *m = new_mode (MODE_POINTER_BOUNDS, name, file, line);
> +  m->bytesize = bytesize;
> +}
> +
> +
>  #define INT_MODE(N, Y) FRACTIONAL_INT_MODE (N, -1U, Y)
>  #define FRACTIONAL_INT_MODE(N, B, Y) \
>make_int_mode (#N, B, Y, __FILE__, __LINE__)
> diff --git a/gcc/machmode.h b/gcc/machmode.h
> index bc5d901..cbe5042 100644
> --- a/gcc/machmode.h
> +++ b/gcc/machmode.h
> @@ -174,6 +174,9 @@ extern const unsigned char mode_class[NUM_MACHINE_MODES];
> || CLASS == MODE_ACCUM  \
> || CLASS == MODE_UACCUM)
>
> +#define POINTER_BOUNDS_MODE_P(MODE)  \
> +  (GET_MODE_CLASS (MODE) == MODE_POINTER_BOUNDS)
> +
>  /* Get the size in bytes and bits of an object of mode MODE.  */
>
>  extern CONST_MODE_SIZE unsigned char mode_size[NUM_MACHINE_MODES];
> diff --git a/gcc/mode-classes.def b/gcc/mode-classes.def
> index 9c6a8bb..b645484 100644
> --- a/gcc/mode-classes.def
> +++ b/gcc/mode-classes.def
> @@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
>DEF_MODE_CLASS (MODE_CC),/* condition code in a register */ \
>DEF_MODE_CLASS (MODE_INT),   /* integer */  \
>DEF_MODE_CLASS (MODE_PARTIAL_INT),   /* integer with padding bits */\
> +  DEF_MODE_CLASS (MODE_POINTER_BOUNDS), /* bounds */   \
>DEF_MODE_CLASS (MODE_FRACT), /* signed fractional number */ \
>DEF_MODE_CLASS (MODE_UFRACT),/* unsigned fractional number 
> */   \
>DEF_MODE_CLASS (MODE_ACCUM), /* signed accumulator */   \
> diff --git a/gcc/stor-layout.c b/gcc/stor-layout.c
> index 084d195..af0ab88 100644
> --- a/gcc/stor-layout.c
> +++ b/gcc/stor-layout.c
> @@ -386,6 +386,7 @@ int_mode_for_mode (enum machine_mode mode)
>  case MODE_VECTOR_ACCUM:
>  case MODE_VECTOR_UFRACT:
>  case MODE_VECTOR_UACCUM:
> +case MODE_POINTER_BOUNDS:
>mode = mode_for_size (GET_MODE_BITSIZE (mode), MODE_INT, 0);
>break;
>
> @@ -2124,6 +2125,11 @@ layout_type (tree type)
>SET_TYPE_MODE (type, VOIDmode);
>break;
>

Re: [PATCH, PR52252] Vectorization for load/store groups of size 3.

2014-05-06 Thread Richard Biener
On Tue, 6 May 2014, Evgeny Stupachenko wrote:

> The patch on cost model was successfully committed.
> I've separated the rest part of the patch on loads/stores group into
> 2: on loads group and on stores group.
> Below is first part on loads group.
> 
> Bootstrap and make check passed on x86.
> 
> Is it ok?
> 
> ChangeLog:
> 
> 2014-05-06  Evgeny Stupachenko  
> 
> * tree-vect-data-refs.c (vect_grouped_load_supported): New
> check for loads group of length 3.
> (vect_permute_load_chain): New permutations for loads group of
> length 3.
> * tree-vect-stmts.c (vect_model_load_cost): Change cost
> of vec_perm_shuffle for the new permutations.
> 
> ChangeLog for testsuite:
> 
> 2014-05-06  Evgeny Stupachenko  
> 
>PR tree-optimization/52252
>* gcc.dg/vect/pr52252-ld.c: Test on loads group of size 3.
> 
> diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
> index 274cdbd..feafb38 100644
> --- a/gcc/tree-vect-data-refs.c
> +++ b/gcc/tree-vect-data-refs.c
> @@ -4812,36 +4812,74 @@ vect_grouped_load_supported (tree vectype,
> unsigned HOST_WIDE_INT count)
>  {
>enum machine_mode mode = TYPE_MODE (vectype);
> 
> -  /* vect_permute_load_chain requires the group size to be a power of two.  
> */
> -  if (exact_log2 (count) == -1)
> +  /* vect_permute_load_chain requires the group size to be equal to 3 or
> + be a power of two.  */
> +  if (count != 3 && exact_log2 (count) == -1)
>  {
>if (dump_enabled_p ())
> dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
> - "the size of the group of accesses"
> - " is not a power of 2\n");
> +"the size of the group of accesses"
> +" is not a power of 2 or not eqaul to 3\n");

equal

>return false;
>  }
> 
>/* Check that the permutation is supported.  */
>if (VECTOR_MODE_P (mode))
>  {
> -  unsigned int i, nelt = GET_MODE_NUNITS (mode);
> +  unsigned int i, j, nelt = GET_MODE_NUNITS (mode);
>unsigned char *sel = XALLOCAVEC (unsigned char, nelt);
> 
> -  for (i = 0; i < nelt; i++)
> -   sel[i] = i * 2;
> -  if (can_vec_perm_p (mode, false, sel))
> +  if (exact_log2 (count) != -1)
> {
>   for (i = 0; i < nelt; i++)
> -   sel[i] = i * 2 + 1;
> +   sel[i] = i * 2;
>   if (can_vec_perm_p (mode, false, sel))
> -   return true;
> +   {
> + for (i = 0; i < nelt; i++)
> +   sel[i] = i * 2 + 1;
> + if (can_vec_perm_p (mode, false, sel))
> +   return true;
> +   }
> +}
> +  else if (count == 3)

Please structure this if as having special cases first and then an
else with gcc_assert (exact_log2 (count)).

> +   {
> + unsigned int k;
> + for (k = 0; k < 3; k++)
> +   {
> + for (i = 0; i < nelt; i++)
> +   if (3 * i + k < 2 * nelt)
> + sel[i] = 3 * i + k;
> +   else
> + sel[i] = 0;
> + if (!can_vec_perm_p (mode, false, sel))
> +   {
> + if (dump_enabled_p ())
> +   dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
> +"shuffle of 3 loads is not supported by \
> +target\n");

Don't use multi-line strings but do

"shuffle of ..."
"target\n");

instead.

> +   return false;
> +   }
> + for (i = 0, j = 0; i < nelt; i++)
> +   if (3 * i + k < 2 * nelt)
> + sel[i] = i;
> +   else
> + sel[i] = nelt + ((nelt + k) % 3) + 3 * (j++);
> + if (!can_vec_perm_p (mode, false, sel))
> +   {
> + if (dump_enabled_p ())
> +   dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
> +"shuffle of 3 loads is not supported by \
> +target\n");

Likewise.

> + return false;
> +   }
> +   }
> + return true;
> }
>  }
> 
>if (dump_enabled_p ())
>  dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
> - "extract even/odd not supported by target\n");
> +"extract even/odd not supported by target\n");
>return false;
>  }
> 
> @@ -4859,8 +4897,9 @@ vect_load_lanes_supported (tree vectype,
> unsigned HOST_WIDE_INT count)
>  /* Function vect_permute_load_chain.
> 
> Given a chain of interleaved loads in DR_CHAIN of LENGTH that must be
> -   a power of 2, generate extract_even/odd stmts to reorder the input data
> -   correctly.  Return the final references for loads in RESULT_CHAIN.
> +   a power of 2 or equal to 3, generate extract_ev

Re: [PATCH] Fix PR39246: -Wuninitialized for partially initialized complex

2014-05-06 Thread Richard Biener
On Tue, May 6, 2014 at 11:56 AM, Thomas Preud'homme
 wrote:
> Sorry, I forgot to include the new ChangeLogs:
>
>
> *** gcc/ChangeLog ***
>
> 2014-05-06  Thomas Preud'homme  
>
> PR middle-end/39246
> * tree-complex.c (expand_complex_move): Keep line info when expanding
> complex move.
> * tree-ssa-uninit.c (uninit_undefined_value_p): For SSA_NAME
> initialized by a COMPLEX_EXPR, recurse on each part of the
> COMPLEX_EXPR.
> (warn_uninit): New argument. Ignore assignment of complex expression.
> Use new argument to display correct location for values coming from
> phi statement.
> (warn_uninitialized_vars): Adapt to new signature of warn_uninit.
> (warn_uninitialized_phi): Pass location of phi argument to 
> warn_uninit.
>
> *** gcc/testsuite/ChangeLog ***
>
> 2014-05-04  Thomas Preud'homme  
>
> * gcc.dg/uninit-13.c: Move warning on the actual source line where the
> uninitialized complex is used.
> * gcc.dg/uninit-17.c: New test to check partial initialization of
> complex with branches.
> * gcc.dg/uninit-17-O0.c: Likewise.
>
> Ok for trunk?

Ok.

Thanks,
Richard.

> Best regards,
>
> Thomas Preud'homme
>
>


Re: [PATCH, PR52252] Vectorization for load/store groups of size 3.

2014-05-06 Thread Evgeny Stupachenko
The patch on cost model was successfully committed.
I've separated the rest part of the patch on loads/stores group into
2: on loads group and on stores group.
Below is first part on loads group.

Bootstrap and make check passed on x86.

Is it ok?

ChangeLog:

2014-05-06  Evgeny Stupachenko  

* tree-vect-data-refs.c (vect_grouped_load_supported): New
check for loads group of length 3.
(vect_permute_load_chain): New permutations for loads group of
length 3.
* tree-vect-stmts.c (vect_model_load_cost): Change cost
of vec_perm_shuffle for the new permutations.

ChangeLog for testsuite:

2014-05-06  Evgeny Stupachenko  

   PR tree-optimization/52252
   * gcc.dg/vect/pr52252-ld.c: Test on loads group of size 3.

diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c
index 274cdbd..feafb38 100644
--- a/gcc/tree-vect-data-refs.c
+++ b/gcc/tree-vect-data-refs.c
@@ -4812,36 +4812,74 @@ vect_grouped_load_supported (tree vectype,
unsigned HOST_WIDE_INT count)
 {
   enum machine_mode mode = TYPE_MODE (vectype);

-  /* vect_permute_load_chain requires the group size to be a power of two.  */
-  if (exact_log2 (count) == -1)
+  /* vect_permute_load_chain requires the group size to be equal to 3 or
+ be a power of two.  */
+  if (count != 3 && exact_log2 (count) == -1)
 {
   if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "the size of the group of accesses"
- " is not a power of 2\n");
+"the size of the group of accesses"
+" is not a power of 2 or not eqaul to 3\n");
   return false;
 }

   /* Check that the permutation is supported.  */
   if (VECTOR_MODE_P (mode))
 {
-  unsigned int i, nelt = GET_MODE_NUNITS (mode);
+  unsigned int i, j, nelt = GET_MODE_NUNITS (mode);
   unsigned char *sel = XALLOCAVEC (unsigned char, nelt);

-  for (i = 0; i < nelt; i++)
-   sel[i] = i * 2;
-  if (can_vec_perm_p (mode, false, sel))
+  if (exact_log2 (count) != -1)
{
  for (i = 0; i < nelt; i++)
-   sel[i] = i * 2 + 1;
+   sel[i] = i * 2;
  if (can_vec_perm_p (mode, false, sel))
-   return true;
+   {
+ for (i = 0; i < nelt; i++)
+   sel[i] = i * 2 + 1;
+ if (can_vec_perm_p (mode, false, sel))
+   return true;
+   }
+}
+  else if (count == 3)
+   {
+ unsigned int k;
+ for (k = 0; k < 3; k++)
+   {
+ for (i = 0; i < nelt; i++)
+   if (3 * i + k < 2 * nelt)
+ sel[i] = 3 * i + k;
+   else
+ sel[i] = 0;
+ if (!can_vec_perm_p (mode, false, sel))
+   {
+ if (dump_enabled_p ())
+   dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+"shuffle of 3 loads is not supported by \
+target\n");
+   return false;
+   }
+ for (i = 0, j = 0; i < nelt; i++)
+   if (3 * i + k < 2 * nelt)
+ sel[i] = i;
+   else
+ sel[i] = nelt + ((nelt + k) % 3) + 3 * (j++);
+ if (!can_vec_perm_p (mode, false, sel))
+   {
+ if (dump_enabled_p ())
+   dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+"shuffle of 3 loads is not supported by \
+target\n");
+ return false;
+   }
+   }
+ return true;
}
 }

   if (dump_enabled_p ())
 dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "extract even/odd not supported by target\n");
+"extract even/odd not supported by target\n");
   return false;
 }

@@ -4859,8 +4897,9 @@ vect_load_lanes_supported (tree vectype,
unsigned HOST_WIDE_INT count)
 /* Function vect_permute_load_chain.

Given a chain of interleaved loads in DR_CHAIN of LENGTH that must be
-   a power of 2, generate extract_even/odd stmts to reorder the input data
-   correctly.  Return the final references for loads in RESULT_CHAIN.
+   a power of 2 or equal to 3, generate extract_even/odd stmts to reorder
+   the input data correctly.  Return the final references for loads in
+   RESULT_CHAIN.

E.g., LENGTH is 4 and the scalar type is short, i.e., VF is 8.
The input is 4 vectors each containing 8 elements. We assign a
number to each
@@ -4941,6 +4980,7 @@ vect_permute_load_chain (vec dr_chain,
 {
   tree data_ref, first_vect, second_vect;
   tree perm_mask_even, perm_mask_odd;
+  tree perm3_mask_low, perm3_mask_high;
   gimple perm_stmt;
   tree vectype = STMT_VINFO_VECTYPE (vinfo_for_stmt (stmt));
   unsigned int i, j, log_l

RE: RE: [PATCH, MIPS] Alter default number of single-precision registers

2014-05-06 Thread Matthew Fortune
Hi Qiuji,

I'll run the tests to double check. I haven't run spec with this patch nor do I 
have current results for spec to hand.

Can I check that spec2000 runs OK for you without the patch for the same base 
version of GCC?

Regards,
Matthew


From: qiuji-loongson [mailto:qi...@loongson.cn] 
Sent: 04 May 2014 23:38
To: Matthew Fortune; Richard Sandiford
Cc: 'gcc-patches@gcc.gnu.org' (gcc-patches@gcc.gnu.org); Rich Fuhler
Subject: Re: RE: [PATCH, MIPS] Alter default number of single-precision 
registers

Hi Matthew:
Test passed on Loongson3a on the case:
void  foo (void)
 {
    register float foo asm ("$f1");
    asm volatile ("" : "=f" (foo));
   }
The cc1 outputs  "error: register specified for ‘foo’ isn’t suitable for data 
type " under -mabi=32 -march=loongson3a options.

But some SPEC CPU2000 test on "test input" are failed,  something like a "Float 
exception" and the error pc is a "teq..." insn.

Have you ever test this benchmark on your platform?

Thanks!


Qiuji


qiuji-loongson
 
From: Matthew Fortune
Date: 2014-04-30 20:45
To: Richard Sandiford
CC: 'gcc-patches@gcc.gnu.org' (gcc-patches@gcc.gnu.org); Rich Fuhler; 
qi...@loongson.cn
Subject: RE: [PATCH, MIPS] Alter default number of single-precision registers
Richard Sandiford  writes:
> -march is "which instructions can I use?" and -mtune is "which
> instructions
> give good performance?".  My understanding is that you wanted to disable
> the instructions for mips32r2 etc. so that they can be safely linked
> with loongson3a code, in which case it's an -march rather than an
> -mtune decision.
> 
> Admittedly the branch-likely case is a bit of a grey area.  It can be
> justified on tuning grounds because it's unlikely that deprecated
> instructions will perform will in general, and the tuning for mips*
> archs is supposed to be an all-round compromise.  But disabling half
> the FPRs for single floats can't be justified on tuning grounds.
> That's never going to help performance. :-)
 
OK.
 
Updated patch attached. I've opted to check for mips as a prefix to the
architecture name as part of the default option handling.
 
regards,
Matthew
 
2014-04-30  Matthew Fortune 
 
gcc/
   * config/mips/mips.c: (mips_option_override) Implement -modd-spreg 
   and defaults.
    * config/mips/mips.h: (TARGET_CPU_CPP_BUILTINS) Add _MIPS_SPFPSET
    builtin define.  (ISA_HAS_ODD_SPREG) Define.  (MIN_FPRS_PER_FMT)
    Redefine in terms of TARGET_ODD_SPREG.
    * config/mips/mips.opt: Add -modd-spreg option.
    * doc/invoke.texi: Document -modd-spreg option.
 
gcc/testsuite/
 
    * gcc.target/mips/mips.exp: Add -m[no-]odd-spreg.  Use
    _MIPS_SPFPSET to determine default odd-spreg option.  Account for
    -modd-spreg in minimum arch code.
    * gcc.target/mips/oddspreg-1.c: New.
    * gcc.target/mips/oddspreg-2.c: New.
    * gcc.target/mips/oddspreg-3.c: New.
    * gcc.target/mips/oddspreg-4.c: New. 
    * gcc.target/mips/oddspreg-5.c: New.
    * gcc.target/mips/oddspreg-6.c: New.
    * gcc.target/mips/oddspreg-7.c: New.
 
---
gcc/config/mips/mips.c |   17 +
gcc/config/mips/mips.h |   13 +++--
gcc/config/mips/mips.opt   |    4 
gcc/doc/invoke.texi    |    7 +++
gcc/testsuite/gcc.target/mips/mips.exp |   16 +++-
gcc/testsuite/gcc.target/mips/oddspreg-1.c |   13 +
gcc/testsuite/gcc.target/mips/oddspreg-2.c |   10 ++
gcc/testsuite/gcc.target/mips/oddspreg-3.c |   10 ++
gcc/testsuite/gcc.target/mips/oddspreg-4.c |   10 ++
gcc/testsuite/gcc.target/mips/oddspreg-5.c |   15 +++
gcc/testsuite/gcc.target/mips/oddspreg-6.c |   15 +++
gcc/testsuite/gcc.target/mips/oddspreg-7.c |   13 +
12 files changed, 140 insertions(+), 3 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/mips/oddspreg-1.c
create mode 100644 gcc/testsuite/gcc.target/mips/oddspreg-2.c
create mode 100644 gcc/testsuite/gcc.target/mips/oddspreg-3.c
create mode 100644 gcc/testsuite/gcc.target/mips/oddspreg-4.c
create mode 100644 gcc/testsuite/gcc.target/mips/oddspreg-5.c
create mode 100644 gcc/testsuite/gcc.target/mips/oddspreg-6.c
create mode 100644 gcc/testsuite/gcc.target/mips/oddspreg-7.c
 
diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 45256e9..c855527 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -17120,6 +17120,23 @@ mips_option_override (void)
 warning (0, "the %qs architecture does not support madd or msub"
 " instructions", mips_arch_info->name);
+  /* If neither -modd-spreg nor -mno-odd-spreg was given on the command
+ line, set MASK_ODD_SPREG bsaed on the target architecture, ABI.  */
+  if ((target_flags_explicit & MASK_ODD_SPREG) == 0)
+    {
+  /* Disable TARGET_ODD_SPREG for generic architectures to make them
+ compatible with those implem

Re: [PATCH][C++] Fix PR61004

2014-05-06 Thread Richard Biener
On Wed, 30 Apr 2014, Richard Biener wrote:

> 
> With no longer recording alias subsets using BINFOs we now emit
> bogus alias warnings for accessing empty bases.  The following
> avoids this, accessing those with an incompatible alias-set is
> harmless.
> 
> Bootstrapped and tested on x86_64-unknown-linux-gnu, ok?

Ping.

> Thanks,
> Richard.
> 
> 2014-04-30  Richard Biener  
> 
>   PR c++/61004
>   * typeck.c (cp_build_indirect_ref): Do not emit strict-aliasing
>   warnings for accessing empty classes.
> 
>   * g++.dg/diagnostic/pr61004.C: New testcase.
> 
> Index: gcc/cp/typeck.c
> ===
> --- gcc/cp/typeck.c   (revision 209928)
> +++ gcc/cp/typeck.c   (working copy)
> @@ -2921,8 +2921,9 @@ cp_build_indirect_ref (tree ptr, ref_ope
>of  the  result  is  "T."  */
>tree t = TREE_TYPE (type);
>  
> -  if (CONVERT_EXPR_P (ptr)
> -  || TREE_CODE (ptr) == VIEW_CONVERT_EXPR)
> +  if ((CONVERT_EXPR_P (ptr)
> +|| TREE_CODE (ptr) == VIEW_CONVERT_EXPR)
> +   && (!CLASS_TYPE_P (t) || !CLASSTYPE_EMPTY_P (t)))
>   {
> /* If a warning is issued, mark it to avoid duplicates from
>the backend.  This only needs to be done at
> Index: gcc/testsuite/g++.dg/diagnostic/pr61004.C
> ===
> --- gcc/testsuite/g++.dg/diagnostic/pr61004.C (revision 0)
> +++ gcc/testsuite/g++.dg/diagnostic/pr61004.C (working copy)
> @@ -0,0 +1,11 @@
> +// { dg-do compile }
> +// { dg-options "-O2 -Wall" }
> +
> +struct A{ };
> +struct B:A{};
> +void f(A const&);
> +int main()
> +{
> +  B b;
> +  f(b); // { dg-bogus "strict-aliasing" }
> +}
> 


Re: [PATCH GCC]Pick up more address lowering cases for ivopt and tree-affine.c

2014-05-06 Thread Richard Biener
On Tue, May 6, 2014 at 10:39 AM, Bin.Cheng  wrote:
> On Fri, Dec 6, 2013 at 6:19 PM, Richard Biener
>  wrote:
>> On Mon, Nov 25, 2013 at 7:41 PM, Jeff Law  wrote:
>>> On 11/25/13 02:22, bin.cheng wrote:

 Hi,
 I previously committed two patches lowering complex address expression for
 IVOPT at http://gcc.gnu.org/ml/gcc-patches/2013-11/msg00546.html and
 http://gcc.gnu.org/ml/gcc-patches/2013-11/msg01103.html
 When I bootstrapping GCC I found there were some peculiar cases like
 &MEM[ptr+CST] + , which should be handled too.  This patch consists
 below two changes:

 1) change in alloc_iv:
 Original code lowers top level complex address expressions like
 &MEM[ptr+off].  The patch relaxes check condition in order to lower
 expressions like &MEM[ptr+off] + xxx, just as the BASE from below dump:
 use 2
generic
in statement _595 = &MEM[(void *)&this_prg + 36B] + _594;

at position
type struct gcov_bucket_type *
base (struct gcov_bucket_type *) &MEM[(void *)&this_prg + 36B] +
 (sizetype) ((unsigned int) (src_i_683 + -1) * 20)
step 4294967276
base object (void *) &this_prg
related candidates

 2) change in tree_to_aff_combination:
 The function get_inner_reference returns "&MEM[ptr+off]" as the core for
 input like the memory ADDRESS in below dump:
 use 2
address
in statement _59 = MEM[(const struct gcov_ctr_summary *)summary_22(D) +
 4B].histogram[h_ix_111].min_value;

at position MEM[(const struct gcov_ctr_summary *)summary_22(D) +
 4B].histogram[h_ix_111].min_value
type const gcov_type *
base (const gcov_type *) &MEM[(const struct gcov_ctr_summary
 *)summary_22(D) + 4B] + 36
step 20
base object (void *) summary_22(D)
related candidates

 Which can be further reduced into something like "summary_22(D) + 40B".
 This change is necessary for the first one, because I am using
 tree_to_aff_combination rather than get_inner_reference_aff now.

 Bootstrap and test on x86/x86_64/arm.  Is it OK?

 Thanks.
 bin

 2013-11-25  Bin Cheng  

 * tree-ssa-loop-ivopts.c (contain_complex_addr_expr): New.
 (alloc_iv): Lower more cases by calling contain_complex_addr_expr
 and tree_to_aff_combination.
 * tree-affine.c (tree_to_aff_combination): Handle &MEM[ptr+CST]
 in core part of complex reference.

 gcc/testsuite/ChangeLog
 2013-11-25  Bin Cheng  

 * gcc.dg/tree-ssa/ivopts-lower_base.c: New test.
>>>
>>> Unless there's a PR for this problem, I think this needs to wait.
>>
>> I agree.  Btw, please split the patch.
>>
>> Index: gcc/tree-affine.c
>> ===
>> --- gcc/tree-affine.c(revision 205087)
>> +++ gcc/tree-affine.c(working copy)
>> @@ -328,7 +328,19 @@ tree_to_aff_combination (tree expr, tree type, aff
>>   double_int::from_uhwi (bitpos / BITS_PER_UNIT));
>>core = build_fold_addr_expr (core);
>>if (TREE_CODE (core) == ADDR_EXPR)
>> -aff_combination_add_elt (comb, core, double_int_one);
>> +{
>> +  /* Handle &MEM[ptr + CST] in core part of complex reference.  */
>> +  if (TREE_CODE (TREE_OPERAND (core, 0)) == MEM_REF)
>> +{
>> +  core = TREE_OPERAND (core, 0);
>> +  tree_to_aff_combination (TREE_OPERAND (core, 0), type, &tmp);
>> +  aff_combination_add (comb, &tmp);
>> +  tree_to_aff_combination (TREE_OPERAND (core, 1), sizetype, &tmp);
>> +  aff_combination_add (comb, &tmp);
>> +}
>> +  else
>> +aff_combination_add_elt (comb, core, double_int_one);
>> +}
>>else
>>  {
>>tree_to_aff_combination (core, type, &tmp)
>>
>> please handle the offset before taking the address, thus
>>
>>   if (TREE_CODE (core) == MEM_REF)
>> {
>>add constant offset;
>>core = TREE_OPERAND (core, 0);
>> }
>>   else
>> core = build_fold_addr_expr (core);
>>
>> that simplifies things and avoids the address building.
>>
> Hi,
> I split the patch into two and updated the test case.
> The patches pass bootstrap/tests on x86/x86_64, also pass test on arm 
> cortex-m3.
> Is it OK?
>
> Thanks,
> bin
>
> PATCH 1:
>
> 2014-05-06  Bin Cheng  
>
> * gcc/tree-affine.c (tree_to_aff_combination): Handle MEM_REF for
> core part of address expressions.

No gcc/ in the changelog

Simplify that by using aff_combination_add_cst:

+  if (TREE_CODE (core) == MEM_REF)
+   {
+ aff_combination_add_cst (comb, mem_ref_offset (core));
+ core = TREE_OPERAND (core, 0);

patch 1 is ok with that change.

> PATCH 2:
>
> 2014-05-06  Bin Cheng  
>
> * gcc/tree-ssa-loop-ivopts.c (contain_complex_addr_expr): New.
> (alloc_iv): Lower base expressions cont

Re: [C PATCH] proposal to add new warning -Wsizeof-array-argument

2014-05-06 Thread Marek Polacek
On Sat, May 03, 2014 at 04:51:53PM +0530, Prathamesh Kulkarni wrote:
>   * c-tree.h (C_ARRAY_PARM): New macro, alias for DECL_LANG_FLAG_2.

"New macro." would be enough.

> --- gcc/c/c-decl.c(revision 210004)
> +++ gcc/c/c-decl.c(working copy)
> @@ -4650,6 +4650,8 @@ push_parm_decl (const struct c_parm *par
>decl = grokdeclarator (parm->declarator, parm->specs, PARM, false, NULL,
>&attrs, expr, NULL, DEPRECATED_NORMAL);
>decl_attributes (&decl, attrs, 0);
> +  

Trailing whitespace (you might want to drop this newline altogether).

> --- gcc/c/c-tree.h(revision 210004)
> +++ gcc/c/c-tree.h(working copy)
> @@ -66,6 +66,9 @@ along with GCC; see the file COPYING3.
>  /* For a FUNCTION_DECL, nonzero if it was an implicit declaration.  */
>  #define C_DECL_IMPLICIT(EXP) DECL_LANG_FLAG_2 (EXP)
>  
> +/* For a PARM_DECL, nonzero if parameter was declared as array */

"as an array.  */"

> --- gcc/c/c-typeck.c  (revision 210004)
> +++ gcc/c/c-typeck.c  (working copy)
> @@ -2732,6 +2732,13 @@ c_expr_sizeof_expr (location_t loc, stru
>else
>  {
>bool expr_const_operands = true;
> +
> +  if (warn_sizeof_array_argument && TREE_CODE (expr.value) == PARM_DECL 
> && C_ARRAY_PARM (expr.value)) 

Line too long.  Please move each condition on its own line.

> + {
> +   warning_at (loc, 0, "sizeof on array parameter %qE shall return size 
> of %qT",

You want OPT_Wsizeof_array_argument instead of 0 here.
Also I'd s/shall/will/.  Also line is too long + trailing whitespace.

> +Wsizeof-array-argument
> +C Var(warn_sizeof_array_argument) Warning
> +Warn when sizeof is applied on a parameter declared as an array

I wonder if we want also ObjC here.  I guess it'd be good to have this
also for C++.

It seems that this could be enabled by default.

Marek


RE: [PATCH] Fix PR39246: -Wuninitialized for partially initialized complex

2014-05-06 Thread Thomas Preud'homme
Sorry, I forgot to include the new ChangeLogs:


*** gcc/ChangeLog ***

2014-05-06  Thomas Preud'homme  

PR middle-end/39246
* tree-complex.c (expand_complex_move): Keep line info when expanding
complex move.
* tree-ssa-uninit.c (uninit_undefined_value_p): For SSA_NAME
initialized by a COMPLEX_EXPR, recurse on each part of the
COMPLEX_EXPR.
(warn_uninit): New argument. Ignore assignment of complex expression.
Use new argument to display correct location for values coming from
phi statement.
(warn_uninitialized_vars): Adapt to new signature of warn_uninit.
(warn_uninitialized_phi): Pass location of phi argument to warn_uninit.

*** gcc/testsuite/ChangeLog ***

2014-05-04  Thomas Preud'homme  

* gcc.dg/uninit-13.c: Move warning on the actual source line where the
uninitialized complex is used.
* gcc.dg/uninit-17.c: New test to check partial initialization of
complex with branches.
* gcc.dg/uninit-17-O0.c: Likewise.

Ok for trunk?

Best regards,

Thomas Preud'homme




RE: [PATCH] Fix PR39246: -Wuninitialized for partially initialized complex

2014-05-06 Thread Thomas Preud'homme
Hi Richard,

> From: Richard Biener [mailto:richard.guent...@gmail.com]
> >
> > The ChangeLog are as follows:
> >
> > *** gcc/ChangeLog ***
> >
> > 2014-05-04  Thomas Preud'homme  
> >
> > PR middle-end/39246
> > * tree-complex.c (expand_complex_move): Keep line info when
> expanding
> > complex move.
> 
> This part and the corresponding testcase adjustment is ok.  You can
> commit it separately.

Only the change to tree-complex.c should be commited then, as it just changes
the location for target where the test was failing to the return line.

The current situation for uninit-13.c is:

Warning location
Target return complex in register(s)partial init
Target return complex on the stack  declaration

With the change to tree-complex.c the situation for the same test becomes:

Warning location
Target return complex in register(s)partial init
Target return complex on the stack  return

So either I don't touch the test or I move it to the return but I will just 
change
the set of target for which this test fails in doing so.

> 
> > * tree-ssa-uninit.c (warn_uninit): New argument. Ignore assignment 
> > of
> > complex expression. Use new argument to display correct location for
> > values coming from phi statement.
> > (warn_uninitialized_vars): Adapt to new signature of warn_uninit.
> > (warn_uninitialized_phi): Pass location of phi argument to 
> > warn_uninit.
> > * tree-ssa.c (ssa_undefined_value_p): For SSA_NAME initialized by a
> > COMPLEX_EXPR, recurse on each part of the COMPLEX_EXPR.
> 
> This change will also affect PRE in a bogus way.  It also affects
> tree-complex.c lowering process, eventually in a similar pessimizing way.
> 
> So please do the change local to tree-ssa-uninit.c.

Done, see attached patch.

Best regards,

Thomas


gcc32rm-91.2.0.diff
Description: Binary data


Re: [PATCH 0/3] Compile-time gimple checking, without typedefs

2014-05-06 Thread Martin Jambor
On Mon, May 05, 2014 at 09:53:49PM +0200, Jakub Jelinek wrote:
> On Mon, May 05, 2014 at 01:44:06PM -0600, Jeff Law wrote:
> > On 05/05/14 11:37, Richard Biener wrote:
> > >
> > >Well, I hope that Andrew doesn't do without a namespace (and I still
> > >don't believe in what he tries to achieve without laying proper ground-work
> > >throughout the compiler).  With a namespace gimple we can use
> > >gimple::stmt.
> > namespaces, while nice, aren't going to solve all these issues.
> > While I think we can get a good separation between gimple and the
> > rest of the world, I suspect namespaces aren't going to help much
> > with the statement vs expression vs type issues.
> > 
> > Ultimately I suspect we're not going to have too many places where
> > we can stick a "using namespace gimple-whatever", but time will
> > tell.
> > 
> > >Agreed on that, btw.  But switch_ can't be the answer either.  Maybe
> > >swidch (similar do klass) or swjdch.  Or swtch.  I like swtch the best
> > >(similar to stmt).
> > As David pointed out there's several others that map to keywords.
> > I'd rather set a standard here across the project so that we don't
> > have folks using gto for goto, others using goto_, _goto, whatever.
> > While swtch works well, I don't think the other examples work nearly
> > as well.  Thus some kind of prefix/suffix seems better to me (though
> > I'm sure my eyes will bleed as a result of looking at those
> > objects).
> 
> But the prefix can be as short as e.g. "g" (for gimple), so gtry, ggoto,
> gassign, gcall.
> 
>   Jakub

My thoughts exactly.  (And I'd also leave the general statement type
called gimple.)

Martin


Re: [PATCH] Disable -ftree-loop-distribute-patterns for -ffreestanding, PR56888

2014-05-06 Thread Jakub Jelinek
On Tue, May 06, 2014 at 11:19:58AM +0200, Richard Biener wrote:
> 
> While I'd still like to detect the obvious wrong cases like outlined
> in comment #27 of the PR the following makes the seemingly obvious
> workarounds work (use -fno-builtin, -ffreestanding or -fno-hosted).
> 
> Ok for trunk and branches?

LGTM.

> 2014-05-06  Richard Biener  
> 
>   c-family/
>   * c-opts.c (c_common_post_options): For -freestanding,
>   -fno-hosted and -fno-builtin disable pattern recognition
>   if not enabled explicitely.
> 
> Index: gcc/c-family/c-opts.c
> ===
> *** gcc/c-family/c-opts.c (revision 210097)
> --- gcc/c-family/c-opts.c (working copy)
> *** c_common_post_options (const char **pfil
> *** 851,856 
> --- 851,862 
> if (flag_objc_exceptions && !flag_objc_sjlj_exceptions)
>   flag_exceptions = 1;
>   
> +   /* If -ffreestanding, -fno-hosted or -fno-builtin then disable
> +  pattern recognition.  */
> +   if (!global_options_set.x_flag_tree_loop_distribute_patterns
> +   && flag_no_builtin)
> + flag_tree_loop_distribute_patterns = 0;
> + 
> /* -Woverlength-strings is off by default, but is enabled by -Wpedantic.
>It is never enabled in C++, as the minimum limit is not normative
>in that standard.  */

Jakub


[PATCH] Disable -ftree-loop-distribute-patterns for -ffreestanding, PR56888

2014-05-06 Thread Richard Biener

While I'd still like to detect the obvious wrong cases like outlined
in comment #27 of the PR the following makes the seemingly obvious
workarounds work (use -fno-builtin, -ffreestanding or -fno-hosted).

Ok for trunk and branches?

Thanks,
Richard.

2014-05-06  Richard Biener  

c-family/
* c-opts.c (c_common_post_options): For -freestanding,
-fno-hosted and -fno-builtin disable pattern recognition
if not enabled explicitely.

Index: gcc/c-family/c-opts.c
===
*** gcc/c-family/c-opts.c   (revision 210097)
--- gcc/c-family/c-opts.c   (working copy)
*** c_common_post_options (const char **pfil
*** 851,856 
--- 851,862 
if (flag_objc_exceptions && !flag_objc_sjlj_exceptions)
  flag_exceptions = 1;
  
+   /* If -ffreestanding, -fno-hosted or -fno-builtin then disable
+  pattern recognition.  */
+   if (!global_options_set.x_flag_tree_loop_distribute_patterns
+   && flag_no_builtin)
+ flag_tree_loop_distribute_patterns = 0;
+ 
/* -Woverlength-strings is off by default, but is enabled by -Wpedantic.
   It is never enabled in C++, as the minimum limit is not normative
   in that standard.  */


Re: Hurd port for gcc go PATCH 7-9 (9)

2014-05-06 Thread Samuel Thibault
Svante Signell, le Tue 06 May 2014 10:58:38 +0200, a écrit :
> The patch for st_dev by Thomas Schwinge was not liked by Samuel

Uh?

I said “These should be fine, however.” and “a sed rule can't hurt even
if there is no occurrence...”

So just keep that precise part back as it was, no need for being clumsy.

What I however said was:

“Err, these seem to get applied to all systems, not just GNU/Hurd, isn't
that a concern?”

By that, I mean this:

> +# Special treatment of EWOULDBLOCK for GNU/Hurd
> +# /usr/include/bits/errno.h: #define EWOULDBLOCK EAGAIN
> +egrep '^const EWOULDBLOCK = Errno(_EWOULDBLOCK)' ${OUT} | \
> +sed -i.bak -e 's/_EWOULDBLOCK/_EAGAIN/' ${OUT}
> +

and that:

> +# Special treatment of SYS_FCNTL for GNU/Hurd
> +if ! grep '^const SYS_FCNTL' ${OUT} >/dev/null 2>&1; then
> +  echo "const SYS_FCNTL = 0" >> ${OUT}
> +fi

AIUI, the patch you propose does those changes for all systems, not just
GNU/Hurd.  That most probably will pose a problem.

Samuel


Re: [C PATCH] Don't reject valid code with _Alignas (PR c/61053)

2014-05-06 Thread Marek Polacek
On Tue, May 06, 2014 at 10:14:42AM +0200, Jakub Jelinek wrote:
> > Hmm, but isn't TYPE_ALIGN_UNIT wrong then?
> 
> No, after all, you don't want to change __alignof__ (long long), that is
> pretty essential part of ABI.

Yeah, as I understand things, for x86_64 __alignof__ (T) returns
*preferred* alignment which is specified for each type in the ABI
(Figure 3.1: Scalar Types), and is the same as sizeof (T).  But
_Alignof (T) (thus also _Alignas (T)) is the *least* alignment for
a type -- and they can differ if the type is in a struct/union.
Please correct me if I'm mistaken.

Marek


Hurd port for gcc go PATCH 7-9 (9)

2014-05-06 Thread Svante Signell

(continued)

patch7.diff: src/libgo/go/syscall/wait.c
Set WCONTINUED to zero if not defined (same fix as for lto in gcc-4.9)

patch8.diff: src/libgo/mksysinfo.sh
Add special treatment of EWOULDBLOCK, SYS_FCNTL and st_dev since they
are either not defined or defined differently for the script to catch
them. The patch for st_dev by Thomas Schwinge was not liked by Samuel so
I have included a more clumsy version. A better solution is needed.
Thomas version is commented out in the patch.

patch9.diff: src/libgo/runtime/netpoll.goc
Rename errno to errno1 since errno clashes with  included in
that file on Hurd.

--- a/src/libgo/go/syscall/wait.c
+++ b/src/libgo/go/syscall/wait.c
@@ -8,6 +8,9 @@
OS-independent.  */
 
 #include 
+#ifndef WCONTINUED
+#define WCONTINUED 0
+#endif
 #include 
 
 #include "runtime.h"
--- a/src/libgo/mksysinfo.sh
+++ b/src/libgo/mksysinfo.sh
@@ -210,6 +210,11 @@
   egrep '#define E[A-Z0-9_]+ ' | \
   sed -e 's/^#define \(E[A-Z0-9_]*\) .*$/const \1 = Errno(_\1)/' >> ${OUT}
 
+# Special treatment of EWOULDBLOCK for GNU/Hurd
+# /usr/include/bits/errno.h: #define EWOULDBLOCK EAGAIN
+egrep '^const EWOULDBLOCK = Errno(_EWOULDBLOCK)' ${OUT} | \
+sed -i.bak -e 's/_EWOULDBLOCK/_EAGAIN/' ${OUT}
+
 # The O_xxx flags.
 egrep '^const _(O|F|FD)_' gen-sysinfo.go | \
   sed -e 's/^\(const \)_\([^= ]*\)\(.*\)$/\1\2 = _\2/' >> ${OUT}
@@ -225,6 +230,11 @@
   echo "const F_DUPFD_CLOEXEC = 0" >> ${OUT}
 fi
 
+# Special treatment of SYS_FCNTL for GNU/Hurd
+if ! grep '^const SYS_FCNTL' ${OUT} >/dev/null 2>&1; then
+  echo "const SYS_FCNTL = 0" >> ${OUT}
+fi
+
 # These flags can be lost on i386 GNU/Linux when using
 # -D_FILE_OFFSET_BITS=64, because we see "#define F_SETLK F_SETLK64"
 # before we see the definition of F_SETLK64.
@@ -528,6 +538,15 @@
 
 # The stat type.
 # Prefer largefile variant if available.
+# Special treatment of st_dev for GNU/Hurd
+# /usr/include/i386-gnu/bits/stat.h: #define st_dev st_fsid
+if grep 'define st_dev st_fsid' gen-sysinfo.go >/dev/null 2>&1; then
+ grep '^type _stat ' gen-sysinfo.go | \
+ sed -i.bak -e 's/st_fsid\([^;]*\)/st_fsid\1; st_dev\1/' gen-sysinfo.go
+ grep '^type _stat ' ${OUT} | \
+ sed -i.bak -e 's/st_fsid\([^;]*\)/&; st_dev\1/' ${OUT}
+fi
+# -e 's/st_fsid/Dev/'
 stat=`grep '^type _stat64 ' gen-sysinfo.go || true`
 if test "$stat" != ""; then
   grep '^type _stat64 ' gen-sysinfo.go
--- a/src/libgo/runtime/netpoll.goc.orig	2013-11-07 01:23:21.0 +0100
+++ b/src/libgo/runtime/netpoll.goc	2014-03-28 09:07:15.0 +0100
@@ -68,7 +68,7 @@
 	runtime_netpollinit();
 }
 
-func runtime_pollOpen(fd uintptr) (pd *PollDesc, errno int) {
+func runtime_pollOpen(fd uintptr) (pd *PollDesc, errno1 int) {
 	pd = allocPollDesc();
 	runtime_lock(pd);
 	if(pd->wg != nil && pd->wg != READY)
@@ -84,7 +84,7 @@
 	pd->wd = 0;
 	runtime_unlock(pd);
 
-	errno = runtime_netpollopen(fd, pd);
+	errno1 = runtime_netpollopen(fd, pd);
 }
 
 func runtime_pollClose(pd *PollDesc) {


Hurd port for gcc go PATCH 4-6 (9)

2014-05-06 Thread Svante Signell

(continued)

patch4.diff: src/libgo/go/syscall/libcall_posix-1.go: New file, a copy
of libcall_posix.go with the mount, mlockall and munlockall calls
removed. mount/umount functionality exists but is currently part of
Hurd utilities, the outhe two functions are not yet implemented.

patch5.diff: src/libgo/go/net/sock_gnu.go
Create a dummy function for maxListenerBacklog() until implemented.

patch6.diff: src/libgo/go/syscall/libcall_gnu.go
Create a dummy function for raw_ptrace() until implemented.


--- /dev/null
+++ b/src/libgo/go/syscall/libcall_posix-1.go
@@ -0,0 +1,397 @@
+// Copyright 2011 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+// POSIX library calls.
+// Removed the mount call for GNU/Hurd, it exists but use translators.
+// Functionality is not the same as descibed in sys/mount.h
+// This file is compiled as ordinary Go code,
+// but it is also input to mksyscall,
+// which parses the //sys lines and generates library call stubs.
+// Note that sometimes we use a lowercase //sys name and
+// wrap it in our own nicer implementation.
+
+package syscall
+
+import "unsafe"
+
+/*
+ * Wrapped
+ */
+
+//sysnb	pipe(p *[2]_C_int) (err error)
+//pipe(p *[2]_C_int) _C_int
+func Pipe(p []int) (err error) {
+	if len(p) != 2 {
+		return EINVAL
+	}
+	var pp [2]_C_int
+	err = pipe(&pp)
+	p[0] = int(pp[0])
+	p[1] = int(pp[1])
+	return
+}
+
+//sys	utimes(path string, times *[2]Timeval) (err error)
+//utimes(path *byte, times *[2]Timeval) _C_int
+func Utimes(path string, tv []Timeval) (err error) {
+	if len(tv) != 2 {
+		return EINVAL
+	}
+	return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
+}
+
+//sys	getcwd(buf *byte, size Size_t) (err error)
+//getcwd(buf *byte, size Size_t) *byte
+
+const ImplementsGetwd = true
+
+func Getwd() (ret string, err error) {
+	for len := Size_t(4096); ; len *= 2 {
+		b := make([]byte, len)
+		err := getcwd(&b[0], len)
+		if err == nil {
+			i := 0
+			for b[i] != 0 {
+i++
+			}
+			return string(b[0:i]), nil
+		}
+		if err != ERANGE {
+			return "", err
+		}
+	}
+}
+
+func Getcwd(buf []byte) (n int, err error) {
+	err = getcwd(&buf[0], Size_t(len(buf)))
+	if err == nil {
+		i := 0
+		for buf[i] != 0 {
+			i++
+		}
+		n = i +1
+	}
+	return
+}
+
+//sysnb	getgroups(size int, list *Gid_t) (nn int, err error)
+//getgroups(size _C_int, list *Gid_t) _C_int
+
+func Getgroups() (gids []int, err error) {
+	n, err := getgroups(0, nil)
+	if err != nil {
+		return nil, err
+	}
+	if n == 0 {
+		return nil, nil
+	}
+
+	// Sanity check group count.  Max is 1<<16 on GNU/Linux.
+	if n < 0 || n > 1<<20 {
+		return nil, EINVAL
+	}
+
+	a := make([]Gid_t, n)
+	n, err = getgroups(n, &a[0])
+	if err != nil {
+		return nil, err
+	}
+	gids = make([]int, n)
+	for i, v := range a[0:n] {
+		gids[i] = int(v)
+	}
+	return
+}
+
+//sysnb	setgroups(n int, list *Gid_t) (err error)
+//setgroups(n Size_t, list *Gid_t) _C_int
+
+func Setgroups(gids []int) (err error) {
+	if len(gids) == 0 {
+		return setgroups(0, nil)
+	}
+
+	a := make([]Gid_t, len(gids))
+	for i, v := range gids {
+		a[i] = Gid_t(v)
+	}
+	return setgroups(len(a), &a[0])
+}
+
+type WaitStatus uint32
+
+// The WaitStatus methods are implemented in C, to pick up the macros
+// #defines in .
+
+func (w WaitStatus) Exited() bool
+func (w WaitStatus) Signaled() bool
+func (w WaitStatus) Stopped() bool
+func (w WaitStatus) Continued() bool
+func (w WaitStatus) CoreDump() bool
+func (w WaitStatus) ExitStatus() int
+func (w WaitStatus) Signal() Signal
+func (w WaitStatus) StopSignal() Signal
+func (w WaitStatus) TrapCause() int
+
+//sys	Mkfifo(path string, mode uint32) (err error)
+//mkfifo(path *byte, mode Mode_t) _C_int
+
+//sys	Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
+//select(nfd _C_int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) _C_int
+
+const nfdbits = int(unsafe.Sizeof(fds_bits_type) * 8)
+
+type FdSet struct {
+	Bits [(FD_SETSIZE +nfdbits - 1) / nfdbits]fds_bits_type
+}
+
+func FDSet(fd int, set *FdSet) {
+	set.Bits[fd/nfdbits] |= (1 << (uint)(fd%nfdbits))
+}
+
+func FDClr(fd int, set *FdSet) {
+	set.Bits[fd/nfdbits] &^= (1 << (uint)(fd%nfdbits))
+}
+
+func FDIsSet(fd int, set *FdSet) bool {
+	if set.Bits[fd/nfdbits]&(1<<(uint)(fd%nfdbits)) != 0 {
+		return true
+	} else {
+		return false
+	}
+}
+
+func FDZero(set *FdSet) {
+	for i := range set.Bits {
+		set.Bits[i] = 0
+	}
+}
+
+//sys	Access(path string, mode uint32) (err error)
+//access(path *byte, mode _C_int) _C_int
+
+//sys	Chdir(path string) (err error)
+//chdir(path *byte) _C_int
+
+//sys	Chmod(path string, mode uint32) (err error)
+//chmod(path *byte, mode Mode_t) _C_int
+
+//sys	Chown(path string, uid int, gid int) (err error)
+//chown(path *byte, uid Uid_t, gid Gid_t) _C_int
+
+//sys	Chroot(path string) (err error)
+//chroot(path *byte) _C_int
+
+//sys	Close(fd int) (err error)
+//close(fd _C_int) _C_int
+
+//sys	Creat(path string

Re: [PATCH GCC]Pick up more address lowering cases for ivopt and tree-affine.c

2014-05-06 Thread Bin.Cheng
On Fri, Dec 6, 2013 at 6:19 PM, Richard Biener
 wrote:
> On Mon, Nov 25, 2013 at 7:41 PM, Jeff Law  wrote:
>> On 11/25/13 02:22, bin.cheng wrote:
>>>
>>> Hi,
>>> I previously committed two patches lowering complex address expression for
>>> IVOPT at http://gcc.gnu.org/ml/gcc-patches/2013-11/msg00546.html and
>>> http://gcc.gnu.org/ml/gcc-patches/2013-11/msg01103.html
>>> When I bootstrapping GCC I found there were some peculiar cases like
>>> &MEM[ptr+CST] + , which should be handled too.  This patch consists
>>> below two changes:
>>>
>>> 1) change in alloc_iv:
>>> Original code lowers top level complex address expressions like
>>> &MEM[ptr+off].  The patch relaxes check condition in order to lower
>>> expressions like &MEM[ptr+off] + xxx, just as the BASE from below dump:
>>> use 2
>>>generic
>>>in statement _595 = &MEM[(void *)&this_prg + 36B] + _594;
>>>
>>>at position
>>>type struct gcov_bucket_type *
>>>base (struct gcov_bucket_type *) &MEM[(void *)&this_prg + 36B] +
>>> (sizetype) ((unsigned int) (src_i_683 + -1) * 20)
>>>step 4294967276
>>>base object (void *) &this_prg
>>>related candidates
>>>
>>> 2) change in tree_to_aff_combination:
>>> The function get_inner_reference returns "&MEM[ptr+off]" as the core for
>>> input like the memory ADDRESS in below dump:
>>> use 2
>>>address
>>>in statement _59 = MEM[(const struct gcov_ctr_summary *)summary_22(D) +
>>> 4B].histogram[h_ix_111].min_value;
>>>
>>>at position MEM[(const struct gcov_ctr_summary *)summary_22(D) +
>>> 4B].histogram[h_ix_111].min_value
>>>type const gcov_type *
>>>base (const gcov_type *) &MEM[(const struct gcov_ctr_summary
>>> *)summary_22(D) + 4B] + 36
>>>step 20
>>>base object (void *) summary_22(D)
>>>related candidates
>>>
>>> Which can be further reduced into something like "summary_22(D) + 40B".
>>> This change is necessary for the first one, because I am using
>>> tree_to_aff_combination rather than get_inner_reference_aff now.
>>>
>>> Bootstrap and test on x86/x86_64/arm.  Is it OK?
>>>
>>> Thanks.
>>> bin
>>>
>>> 2013-11-25  Bin Cheng  
>>>
>>> * tree-ssa-loop-ivopts.c (contain_complex_addr_expr): New.
>>> (alloc_iv): Lower more cases by calling contain_complex_addr_expr
>>> and tree_to_aff_combination.
>>> * tree-affine.c (tree_to_aff_combination): Handle &MEM[ptr+CST]
>>> in core part of complex reference.
>>>
>>> gcc/testsuite/ChangeLog
>>> 2013-11-25  Bin Cheng  
>>>
>>> * gcc.dg/tree-ssa/ivopts-lower_base.c: New test.
>>
>> Unless there's a PR for this problem, I think this needs to wait.
>
> I agree.  Btw, please split the patch.
>
> Index: gcc/tree-affine.c
> ===
> --- gcc/tree-affine.c(revision 205087)
> +++ gcc/tree-affine.c(working copy)
> @@ -328,7 +328,19 @@ tree_to_aff_combination (tree expr, tree type, aff
>   double_int::from_uhwi (bitpos / BITS_PER_UNIT));
>core = build_fold_addr_expr (core);
>if (TREE_CODE (core) == ADDR_EXPR)
> -aff_combination_add_elt (comb, core, double_int_one);
> +{
> +  /* Handle &MEM[ptr + CST] in core part of complex reference.  */
> +  if (TREE_CODE (TREE_OPERAND (core, 0)) == MEM_REF)
> +{
> +  core = TREE_OPERAND (core, 0);
> +  tree_to_aff_combination (TREE_OPERAND (core, 0), type, &tmp);
> +  aff_combination_add (comb, &tmp);
> +  tree_to_aff_combination (TREE_OPERAND (core, 1), sizetype, &tmp);
> +  aff_combination_add (comb, &tmp);
> +}
> +  else
> +aff_combination_add_elt (comb, core, double_int_one);
> +}
>else
>  {
>tree_to_aff_combination (core, type, &tmp)
>
> please handle the offset before taking the address, thus
>
>   if (TREE_CODE (core) == MEM_REF)
> {
>add constant offset;
>core = TREE_OPERAND (core, 0);
> }
>   else
> core = build_fold_addr_expr (core);
>
> that simplifies things and avoids the address building.
>
Hi,
I split the patch into two and updated the test case.
The patches pass bootstrap/tests on x86/x86_64, also pass test on arm cortex-m3.
Is it OK?

Thanks,
bin

PATCH 1:

2014-05-06  Bin Cheng  

* gcc/tree-affine.c (tree_to_aff_combination): Handle MEM_REF for
core part of address expressions.

PATCH 2:

2014-05-06  Bin Cheng  

* gcc/tree-ssa-loop-ivopts.c (contain_complex_addr_expr): New.
(alloc_iv): Lower base expressions containing ADDR_EXPR.

gcc/testsuite/ChangeLog
2014-05-06  Bin Cheng  

* gcc.dg/tree-ssa/ivopts-lower_base.c: New test.



-- 
Best Regards.
Index: gcc/tree-affine.c
===
--- gcc/tree-affine.c   (revision 210047)
+++ gcc/tree-affine.c   (working copy)
@@ -331,7 +331,15 @@ tree_to_aff_combination (tree expr, tree type, aff
break;
   aff_combination_const (comb, type,

Hurd port for gcc go PATCH 0-3 (9)

2014-05-06 Thread Svante Signell

Hi,

Attached are patches to enable gccgo to build properly on Debian
GNU/Hurd on gcc-4.9 (4.9-4.9.0-1). With split stack enabled 95 libgo
tests PASS and 27 FAIL. Many of the failed tests do fail only in a few
sub-tests. patch0.diff is debian specific, while the rest are for
upstream.

patch0.diff is Debian specific, 
patch1.diff should be applied now when split-stack works properly.

patch0.diff: debian/rules.defs:
go_no_systems: remove gnu,
with_go: Check for DEB_TARGET_GNU_OS instead of DEB_TARGET_GNU_SYSTEM.
Otherwise kfreebsd-gnu causes go_no_systems to still be true for gnu.

patch1.diff: src/gcc/config/i386/gnu.h: Enables split stack for
GNU/Hurd. TARGET_THREAD_SSP_OFFSET is not yet supported.

patch2.diff: src/libgo/configure.ac:
Add GNU as a supported target OS for go.

patch3.diff: src/libgo/Makefile.am, src/libgo/Makefile.in
Add GNU specific go routines with the LIBGO_IS_GNU conditional.

Note: Creating the Makefile.in is hard (unnecessary) work since
automake is no longer used in the build system. Both (cd
src/libgo;automake-1.11) and (cd src/libgo;autoreconf2.64) fails. The
diff for Makefile.in was patched by hand with the aid of the diff for
Makefile.am :( This file should be possible to generate from
Makefile.am when modifying manually. In my opinion the Debian build
system is broken at least wrt libgo, since the correct version of
libtool (2.2.7a) is not available.


--- a/debian/rules.defs	2014-01-07 11:10:44.0 +0100
+++ b/debian/rules.defs	2014-01-07 11:23:47.0 +0100
@@ -721,7 +721,7 @@
 ifeq (,$(filter $(distrelease),lenny etch squeeze dapper hardy jaunty karmic lucid maverick natty oneiric))
   go_no_cpus := $(filter-out arm, $(go_no_cpus))
 endif
-go_no_systems := gnu kfreebsd-gnu
+go_no_systems := kfreebsd
 
 ifneq ($(with_base_only),yes)
   ifneq ($(separate_lang),yes)
@@ -731,7 +731,7 @@
 ifneq (,$(filter $(DEB_TARGET_ARCH_CPU),$(go_no_cpus)))
   with_go := disabled for cpu $(DEB_TARGET_ARCH_CPU)
 endif
-ifneq (,$(findstring $(DEB_TARGET_GNU_SYSTEM),$(go_no_systems)))
+ifneq (,$(findstring $(DEB_TARGET_ARCH_OS),$(go_no_systems)))
   with_go := disabled for system $(DEB_TARGET_GNU_SYSTEM)
 endif
 ifeq ($(go_no_cross)-$(DEB_CROSS),yes-yes)
--- a/src/gcc/config/i386/gnu.h
+++ b/src/gcc/config/i386/gnu.h
@@ -39,9 +39,16 @@
 
 /* Not supported yet.  */
 # undef TARGET_THREAD_SSP_OFFSET
+/* i386 glibc provides __stack_chk_guard in %gs:0x14.  */
+/*
+#define TARGET_THREAD_SSP_OFFSET0x14
+ */
 
-/* Not supported yet.  */
-# undef TARGET_CAN_SPLIT_STACK
-# undef TARGET_THREAD_SPLIT_STACK_OFFSET
-
+/* We only build the -fsplit-stack support in libgcc if the
+   assembler has full support for the CFI directives.  */
+#if HAVE_GAS_CFI_PERSONALITY_DIRECTIVE
+#define TARGET_CAN_SPLIT_STACK
+#endif
+/* We steal the last transactional memory word.  */
+#define TARGET_THREAD_SPLIT_STACK_OFFSET 0x30
 #endif
--- a/src/libgo/configure.ac
+++ b/src/libgo/configure.ac
@@ -136,6 +136,7 @@
 is_dragonfly=no
 is_rtems=no
 is_solaris=no
+is_gnu=no
 GOOS=unknown
 case ${host} in
   *-*-darwin*)   is_darwin=yes;  GOOS=darwin ;;
@@ -147,6 +148,7 @@
   *-*-dragonfly*) is_dragonfly=yes; GOOS=dragonfly ;;
   *-*-rtems*)is_rtems=yes;   GOOS=rtems ;;
   *-*-solaris2*) is_solaris=yes; GOOS=solaris ;;
+  *-*-gnu*)  is_gnu=yes; GOOS=gnu ;;
 esac
 AM_CONDITIONAL(LIBGO_IS_DARWIN, test $is_darwin = yes)
 AM_CONDITIONAL(LIBGO_IS_FREEBSD, test $is_freebsd = yes)
@@ -157,6 +159,7 @@
 AM_CONDITIONAL(LIBGO_IS_DRAGONFLY, test $is_dragonfly = yes)
 AM_CONDITIONAL(LIBGO_IS_RTEMS, test $is_rtems = yes)
 AM_CONDITIONAL(LIBGO_IS_SOLARIS, test $is_solaris = yes)
+AM_CONDITIONAL(LIBGO_IS_GNU, test $is_gnu = yes)
 AC_SUBST(GOOS)
 
 dnl Test whether we need to use DejaGNU or whether we can use the
--- a/src/libgo/Makefile.am
+++ b/src/libgo/Makefile.am
@@ -418,9 +418,13 @@
 if LIBGO_IS_SOLARIS
 runtime_netpoll_files = runtime/netpoll_select.c
 else
+if LIBGO_IS_GNU
+runtime_netpoll_files = runtime/netpoll_select.c
+else
 runtime_netpoll_files = runtime/netpoll_kqueue.c
 endif
 endif
+endif
 
 runtime_files = \
 	runtime/go-append.c \
@@ -702,6 +706,12 @@
 go_net_sockopt_file = go/net/sockopt_bsd.go
 go_net_sockoptip_file = go/net/sockoptip_bsd.go go/net/sockoptip_posix.go
 else
+if LIBGO_IS_GNU
+go_net_cgo_file = go/net/cgo_linux.go
+go_net_sock_file = go/net/sock_gnu.go
+go_net_sockopt_file = go/net/sockopt_bsd.go
+go_net_sockoptip_file = go/net/sockoptip_bsd.go go/net/sockoptip_posix.go
+else
 go_net_cgo_file = go/net/cgo_bsd.go
 go_net_sock_file = go/net/sock_bsd.go
 go_net_sockopt_file = go/net/sockopt_bsd.go
@@ -711,6 +721,7 @@
 endif
 endif
 endif
+endif
 
 if LIBGO_IS_LINUX
 go_net_sendfile_file = go/net/sendfile_linux.go
@@ -842,11 +853,15 @@
 if LIBGO_IS_RTEMS
 go_os_sys_file = go/os/sys_uname.go
 else
+if LIBGO_IS_GNU
+go_os_sys_file = go/os/sys_uname.go
+else
 go_os_sys_file = go/os/sys_bsd.go
 endif
 endif
 endif
 endif
+endif
 
 if LIBGO_IS_SOLARIS
 go_os_stat_file = go/os/stat_solaris.go

Re: [RS6000] PR60737, expand_block_clear uses word stores

2014-05-06 Thread Alan Modra
On Fri, May 02, 2014 at 11:28:27AM -0400, David Edelsohn wrote:
> On Fri, May 2, 2014 at 6:20 AM, Alan Modra  wrote:
> > In cases where the compiler has no alignment info, powerpc64le-linux
> > gcc generates byte at a time copies for -mstrict-align (which is on
> > for little-endian power7).  That's awful code, a problem shared by
> > other strict-align targets, see pr50417.  However, we also have a case
> > when -mno-strict-align generates less than ideal code, which I believe
> > stems from using alignment as a proxy for testing an address offset.
> > See http://gcc.gnu.org/ml/gcc-patches/1999-09n/msg01072.html.
> >
> > So my first attempt at fixing this problem looked at address offsets
> > directly.  That worked fine too, but on thinking some more, I believe
> > we no longer have the movdi restriction.  Nowadays we'll reload the
> > address if we have an offset that doesn't satisfy the "Y" constraint
> > (ie. a multiple of 4 offset).  Which led to this simpler patch.
> > Bootstrapped and regression tested powerpc64le-linux, powerpc64-linux
> > and powerpc-linux.  OK to apply?
> 
> Hi, Alan
> 
> Thanks for finding and addressing this.
> 
> As you mention, recent server-class processors, at least POWER8, do
> not have the performance degradation for common, mis-aligned loads and
> stores of wider modes. But the patch should not impose this default on
> the large, installed based of processors, where mis-aligned loads can
> be a severe performance penalty. This heuristic has become
> processor-dependent and should not be hard-coded in the block_move and
> block_clear algorithms.
> 
> PROCESSOR_DEFAULT is POWER8 for ELFv2 (and should be updated as the
> default for PowerLinux in general). Please update the patch to test
> rs6000_cpu, probably another boolean flag set in
> rs6000_option_override_internal(). Because of the processor defaults,
> the preferred instruction sequence will be the default without
> encoding an assumption about the heuristics in the algorithm itself.

David,
I agree that mis-aligned loads can cause large performance penalties
on old 32-bit processors that take alignment traps.  However, the code
that I'm touching here is inside TARGET_POWERPC64 and STRICT_ALIGNMENT.
So we're talking about rs64, 620 and later.  I don't have the book iv
info handy for rs64 or 620, but on my G5, which is getting quite old,
using 64-bit loads is a win over 32-bit.  I expect this to be true for
power4 and later too, for which unaligned loads run at full speed
except when crossing certain byte boundaries related to the size of
cache lines and whether the load was a cache hit or miss.  Note that
it's the crossing of the relevant byte boundary that causes a
slow-down, not the size of the access.

On my G5 I used the following to test the cache hit case:

#include 

int
main (int argc, char **argv)
{
  unsigned int i;
  unsigned int align = 0;
  unsigned long buf[33] __attribute__ ((__aligned__ (128)));
  unsigned long *p;

  if (--argc > 0)
align = strtol (*++argv, NULL, 0);

  p = (unsigned long *)((char *) buf + align);
  for (i = 0; i < 1; i++)
{
#ifdef USE64
  unsigned long scratch[8];
__asm__ __volatile__ ("ld %0,0(%1)"
  : "=r" (scratch[0]) : "r" (p));
__asm__ __volatile__ ("ld %0,0(%1)"
  : "=r" (scratch[1]) : "r" (p));
__asm__ __volatile__ ("ld %0,0(%1)"
  : "=r" (scratch[2]) : "r" (p));
__asm__ __volatile__ ("ld %0,0(%1)"
  : "=r" (scratch[3]) : "r" (p));
__asm__ __volatile__ ("ld %0,0(%1)"
  : "=r" (scratch[4]) : "r" (p));
__asm__ __volatile__ ("ld %0,0(%1)"
  : "=r" (scratch[5]) : "r" (p));
__asm__ __volatile__ ("ld %0,0(%1)"
  : "=r" (scratch[6]) : "r" (p));
__asm__ __volatile__ ("ld %0,0(%1)"
  : "=r" (scratch[7]) : "r" (p));
#else
unsigned int scratch[16];
__asm__ __volatile__ ("lwz %0,0(%2); lwz %1,4(%2)"
  : "=r" (scratch[0]), "=r" (scratch[1]) : "r" (p));
__asm__ __volatile__ ("lwz %0,0(%2); lwz %1,4(%2)"
  : "=r" (scratch[2]), "=r" (scratch[3]) : "r" (p));
__asm__ __volatile__ ("lwz %0,0(%2); lwz %1,4(%2)"
  : "=r" (scratch[4]), "=r" (scratch[5]) : "r" (p));
__asm__ __volatile__ ("lwz %0,0(%2); lwz %1,4(%2)"
  : "=r" (scratch[6]), "=r" (scratch[7]) : "r" (p));
__asm__ __volatile__ ("lwz %0,0(%2); lwz %1,4(%2)"
  : "=r" (scratch[8]), "=r" (scratch[9]) : "r" (p));
__asm__ __volatile__ ("lwz %0,0(%2); lwz %1,4(%2)"
  : "=r" (scratch[10]), "=r" (scratch[11]) : "r" (p));
__asm__ __volatile__ ("lwz %0,0(%2); lwz %1,4(%2)"
  : "=r" (scratch[12]), "=r" (scratch[13]) : "r" (p));
__asm__ __volatile__ ("lwz %0,0(%2); lwz %1,4(%2)"
  : "=

[PATCH] Fix PR61070

2014-05-06 Thread Richard Biener

Committed as obvious.

Richard.

2014-05-06  Richard Biener  

PR middle-end/61070
* bitmap.c (debug_bitmap): Dump to stderr, not stdout.
* tree-ssa-structalias.c (dump_solution_for_var): Likewise.

Index: gcc/bitmap.c
===
--- gcc/bitmap.c(revision 210097)
+++ gcc/bitmap.c(working copy)
@@ -2117,7 +2117,7 @@ debug_bitmap_file (FILE *file, const_bit
 DEBUG_FUNCTION void
 debug_bitmap (const_bitmap head)
 {
-  debug_bitmap_file (stdout, head);
+  debug_bitmap_file (stderr, head);
 }
 
 /* Function to print out the contents of a bitmap.  Unlike debug_bitmap_file,
Index: gcc/tree-ssa-structalias.c
===
--- gcc/tree-ssa-structalias.c  (revision 210097)
+++ gcc/tree-ssa-structalias.c  (working copy)
@@ -5834,12 +5834,12 @@ dump_solution_for_var (FILE *file, unsig
   fprintf (file, "\n");
 }
 
-/* Print the points-to solution for VAR to stdout.  */
+/* Print the points-to solution for VAR to stderr.  */
 
 DEBUG_FUNCTION void
 debug_solution_for_var (unsigned int var)
 {
-  dump_solution_for_var (stdout, var);
+  dump_solution_for_var (stderr, var);
 }
 
 /* Create varinfo structures for all of the variables in the



Re: [C++ Patch] PR 60999

2014-05-06 Thread Paolo Carlini

Hi again,

On 05/05/2014 10:48 PM, Jason Merrill wrote:

On 05/05/2014 12:25 PM, Paolo Carlini wrote:

Good, but is it Ok to use uses_template_parms for that? A few days ago I
struggled to find something simpler ready to use, to no avail (well,
this is probably well known to you, but there are surprisingly few
places in pt.c where we explain either in comments or in obvious code
that we are handling full (vs partial) specializations).


+/* True if the given class type is a template or a partial 
specialization.  */

+#define CLASSTYPE_IS_TEMPLATE_OR_PARTIAL_SPECIALIZATION(NODE) \
+  (CLASSTYPE_TEMPLATE_INFO (NODE)\
+   && uses_template_parms (NODE))


I think this would be true for a non-template member class of a 
template class.
On further thought (yesterday was a little tired, sorry), I think that 
nsdmi-template7.C is telling us that, in fact, we *do* want something 
true when we are handling an NSDMI inside a non-template class of a 
template class! Because in that case too the user code may want to use 
the template parameters in the initialization of the NSDMI. Well, 
assuming this is by and large right, we do *not* want a predicate for 
template or partial specialization, maybe a predicate for "dependent 
context", see what I mean?!? In any case, in practice, something rather 
close to my first try ;) (after all, the simple pattern is already used 
in tsubst for typedefs...)


Paolo.


Re: [wide-int] Handle zero-precision INTEGER_CSTs again

2014-05-06 Thread Richard Biener
On Tue, May 6, 2014 at 10:11 AM, Richard Sandiford
 wrote:
> Richard Biener  writes:
>> On Mon, May 5, 2014 at 10:58 PM, Richard Sandiford
>>  wrote:
>>> Richard Biener  writes:
 On Mon, May 5, 2014 at 4:51 PM, Richard Sandiford
  wrote:
> Richard Biener  writes:
>> On Mon, May 5, 2014 at 12:54 PM, Richard Sandiford
>>  wrote:
>>> Richard Biener  writes:
 On Fri, May 2, 2014 at 9:19 PM, Richard Sandiford
  wrote:
> I'd hoped the days of zero-precision INTEGER_CSTs were behind us after
> Richard's patch to remove min amd max values from zero-width 
> bitfields,
> but a boostrap-ubsan showed otherwise.  One source is in:
>
>   null_pointer_node = build_int_cst (build_pointer_type
> (void_type_node), 0);
>
> if no_target, since the precision of the type comes from ptr_mode,
> which remains the default VOIDmode.  Maybe that's a bug, but setting
> it to an arbitrary nonzero value would also be dangerous.

 Can you explain what 'no_target' should be?  ptr_mode should never be
 VOIDmode.
>>>
>>> Sorry, meant "no_backend" rather than "no_target".  See do_compile.
>>
>> Ok.  So we do
>>
>>   /* This must be run always, because it is needed to compute the FP
>>  predefined macros, such as __LDBL_MAX__, for targets using non
>>  default FP formats.  */
>>   init_adjust_machine_modes ();
>>
>>   /* Set up the back-end if requested.  */
>>   if (!no_backend)
>> backend_init ();
>>
>> where I think that init_adjust_machine_modes should initialize the
>> {byte,word,ptr}_mode globals.  Move from init_emit_once.
>>>
>>> init_adjust_machine_modes is an auto-generated function so I ended up
>>> using a new function instead.  Tested on x86_64-linux-gnu.  OK to install?
>>
>> Ok with also setting double_mode there.
>
> double_mode is just a local variable though, it's only used to set up
> dconstN.

Ah, I see.  Fine then as-is.

Thanks,
Richard.

> Thanks,
> Richard


Re: [C PATCH] Don't reject valid code with _Alignas (PR c/61053)

2014-05-06 Thread Jakub Jelinek
On Tue, May 06, 2014 at 10:04:33AM +0200, Richard Biener wrote:
> On Mon, May 5, 2014 at 10:27 PM, Marek Polacek  wrote:
> > In this PR the issue is that we reject (valid) code such as
> > _Alignas (long long) long long foo;
> > with -m32, because we trip this condition:
> >
> >alignas_align = 1U << declspecs->align_log;
> >if (alignas_align < TYPE_ALIGN_UNIT (type))
> >  {
> >if (name)
> >  error_at (loc, "%<_Alignas%> specifiers cannot reduce "
> >"alignment of %qE", name);
> >
> > and error later on, since alignas_align is 4 (correct, see PR52023 for
> > why), but TYPE_ALIGN_UNIT of long long is 8.  I think TYPE_ALIGN_UNIT
> > is wrong here as that won't give us minimal alignment required.
> > In c_sizeof_or_alignof_type we already have the code to compute such
> > minimal alignment so I just moved the code to a separate function
> > and used that instead of TYPE_ALIGN_UNIT.
> 
> Hmm, but isn't TYPE_ALIGN_UNIT wrong then?

No, after all, you don't want to change __alignof__ (long long), that is
pretty essential part of ABI.

Jakub


Re: [wide-int] Handle zero-precision INTEGER_CSTs again

2014-05-06 Thread Richard Sandiford
Richard Biener  writes:
> On Mon, May 5, 2014 at 10:58 PM, Richard Sandiford
>  wrote:
>> Richard Biener  writes:
>>> On Mon, May 5, 2014 at 4:51 PM, Richard Sandiford
>>>  wrote:
 Richard Biener  writes:
> On Mon, May 5, 2014 at 12:54 PM, Richard Sandiford
>  wrote:
>> Richard Biener  writes:
>>> On Fri, May 2, 2014 at 9:19 PM, Richard Sandiford
>>>  wrote:
 I'd hoped the days of zero-precision INTEGER_CSTs were behind us after
 Richard's patch to remove min amd max values from zero-width bitfields,
 but a boostrap-ubsan showed otherwise.  One source is in:

   null_pointer_node = build_int_cst (build_pointer_type
 (void_type_node), 0);

 if no_target, since the precision of the type comes from ptr_mode,
 which remains the default VOIDmode.  Maybe that's a bug, but setting
 it to an arbitrary nonzero value would also be dangerous.
>>>
>>> Can you explain what 'no_target' should be?  ptr_mode should never be
>>> VOIDmode.
>>
>> Sorry, meant "no_backend" rather than "no_target".  See do_compile.
>
> Ok.  So we do
>
>   /* This must be run always, because it is needed to compute the FP
>  predefined macros, such as __LDBL_MAX__, for targets using non
>  default FP formats.  */
>   init_adjust_machine_modes ();
>
>   /* Set up the back-end if requested.  */
>   if (!no_backend)
> backend_init ();
>
> where I think that init_adjust_machine_modes should initialize the
> {byte,word,ptr}_mode globals.  Move from init_emit_once.
>>
>> init_adjust_machine_modes is an auto-generated function so I ended up
>> using a new function instead.  Tested on x86_64-linux-gnu.  OK to install?
>
> Ok with also setting double_mode there.

double_mode is just a local variable though, it's only used to set up
dconstN.

Thanks,
Richard


Re: [wide-int] Handle zero-precision INTEGER_CSTs again

2014-05-06 Thread Richard Biener
On Mon, May 5, 2014 at 10:58 PM, Richard Sandiford
 wrote:
> Richard Biener  writes:
>> On Mon, May 5, 2014 at 4:51 PM, Richard Sandiford
>>  wrote:
>>> Richard Biener  writes:
 On Mon, May 5, 2014 at 12:54 PM, Richard Sandiford
  wrote:
> Richard Biener  writes:
>> On Fri, May 2, 2014 at 9:19 PM, Richard Sandiford
>>  wrote:
>>> I'd hoped the days of zero-precision INTEGER_CSTs were behind us after
>>> Richard's patch to remove min amd max values from zero-width bitfields,
>>> but a boostrap-ubsan showed otherwise.  One source is in:
>>>
>>>   null_pointer_node = build_int_cst (build_pointer_type
>>> (void_type_node), 0);
>>>
>>> if no_target, since the precision of the type comes from ptr_mode,
>>> which remains the default VOIDmode.  Maybe that's a bug, but setting
>>> it to an arbitrary nonzero value would also be dangerous.
>>
>> Can you explain what 'no_target' should be?  ptr_mode should never be
>> VOIDmode.
>
> Sorry, meant "no_backend" rather than "no_target".  See do_compile.

 Ok.  So we do

   /* This must be run always, because it is needed to compute the FP
  predefined macros, such as __LDBL_MAX__, for targets using non
  default FP formats.  */
   init_adjust_machine_modes ();

   /* Set up the back-end if requested.  */
   if (!no_backend)
 backend_init ();

 where I think that init_adjust_machine_modes should initialize the
 {byte,word,ptr}_mode globals.  Move from init_emit_once.
>
> init_adjust_machine_modes is an auto-generated function so I ended up
> using a new function instead.  Tested on x86_64-linux-gnu.  OK to install?

Ok with also setting double_mode there.

>> So I don't think we want this patch.  Instead stor-layout should
>> ICE on zero-precision integer/pointer types.
>
> What should happen for void_zero_node?

 Not sure what that beast is supposed to be or why it should be
 of INTEGER_CST kind (it's not even initialized in any meaningful
 way).

 That said, the wide-int code shouldn't be slowed down by
 precision == 0 checks.  We should never ever reach wide-int
 with such a constant.
>>>
>>> void_zero_node is used for ubsan too, and survives into gimple.
>>> I did hit this in real tests, it wasn't just theoretical.
>>
>> Ugh - for what does it use that ... :/
>>
>> Please remember how to trigger those issues and I'll happily have
>> a look after the merge.
>
> At the time it was just a normal bootstrap-ubsan, but that was
> before the zero-precision patch.  Probably the best way of
> checking for zero-precision tree constants is to put an assert
> for nonzero precisions in:
>
> inline unsigned int
> wi::int_traits ::get_precision (const_tree tcst)
> {
>   return TYPE_PRECISION (TREE_TYPE (tcst));
> }
>
> and:
>
> template 
> inline wi::extended_tree ::extended_tree (const_tree t)
>   : m_t (t)
> {
>   gcc_checking_assert (TYPE_PRECISION (TREE_TYPE (t)) <= N);
> }
>
> and then bootstrap-ubsan.  But like Marek says, the ubsan code uses
> void_zero_node by name.

I think for the uses it has it can just use NULL_TREE in place of
void_zero_node.

Richard.

> Thanks,
> Richard
>
>
> gcc/
> * emit-rtl.c (init_derived_machine_modes): New functionm, split
> out from...
> (init_emit_once): ...here.
> * rtl.h (init_derived_machine_modes): Declare.
> * toplev.c (do_compile): Call it even if no_backend.
>
> Index: gcc/emit-rtl.c
> ===
> --- gcc/emit-rtl.c  2014-05-03 20:18:49.157107743 +0100
> +++ gcc/emit-rtl.c  2014-05-05 17:44:53.579038259 +0100
> @@ -5620,6 +5620,30 @@ init_emit_regs (void)
>  }
>  }
>
> +/* Initialize global machine_mode variables.  */
> +
> +void
> +init_derived_machine_modes (void)
> +{
> +  byte_mode = VOIDmode;
> +  word_mode = VOIDmode;
> +
> +  for (enum machine_mode mode = GET_CLASS_NARROWEST_MODE (MODE_INT);
> +   mode != VOIDmode;
> +   mode = GET_MODE_WIDER_MODE (mode))
> +{
> +  if (GET_MODE_BITSIZE (mode) == BITS_PER_UNIT
> + && byte_mode == VOIDmode)
> +   byte_mode = mode;
> +
> +  if (GET_MODE_BITSIZE (mode) == BITS_PER_WORD
> + && word_mode == VOIDmode)
> +   word_mode = mode;
> +}
> +
> +  ptr_mode = mode_for_size (POINTER_SIZE, GET_MODE_CLASS (Pmode), 0);
> +}
> +
>  /* Create some permanent unique rtl objects shared between all functions.  */
>
>  void
> @@ -5643,36 +5667,6 @@ init_emit_once (void)
>reg_attrs_htab = htab_create_ggc (37, reg_attrs_htab_hash,
> reg_attrs_htab_eq, NULL);
>
> -  /* Compute the word and byte modes.  */
> -
> -  byte_mode = VOIDmode;
> -  word_mode = VOIDmode;
> -  double_mode = VOIDmode;
> -
> -  for (mode = GET_CLASS_NARROWEST_MODE (MODE_INT);
> -   mode != VOIDmode;
> -   mode = GET_M

Re: GCC's -fsplit-stack disturbing Mach's vm_allocate

2014-05-06 Thread Svante Signell
On Fri, 2014-05-02 at 12:52 +0200, Samuel Thibault wrote:
> Svante Signell, le Fri 02 May 2014 12:45:56 +0200, a écrit :
> > On Fri, 2014-05-02 at 12:00 +0200, Samuel Thibault wrote:
> > > Samuel Thibault, le Fri 02 May 2014 11:57:53 +0200, a écrit :
> > > > So we just need to fix guardsize in our libpthread.
> > > 
> > > (And I'll have a look at it).
> > 
> > Maybe this can fix the around 40 segfaults (of 50 failures) when split
> > stack is disabled too? The segfaults are always around the same place in
> > libpthread. 
> 
> Possibly, if libgo uses small stacks already.

Status update:
For some (yet) unknown reason all libgo tests fails with a segfault when
run in the build tree: make, sh or something else, the test commands are
rather hard to track.
However, running the tests manually, sigh!, after installing gccgo and
libgo5 from gcc-4.9-4.9.0-1 with split stack support the result is as
follows:

Total: 122
PASS: 95
FAIL: 27
Number of tests succeeding with libpthread's stack guard fixed: 33 (and
the other libc fixes)
Note: In many of the failing tests, only a small subset of each test
fails.

GNU/Hurd should now to be considered for upstream inclusion?
Updated patches will be sent again to gcc-patches for review.




Re: [C PATCH] Don't reject valid code with _Alignas (PR c/61053)

2014-05-06 Thread Richard Biener
On Mon, May 5, 2014 at 10:27 PM, Marek Polacek  wrote:
> In this PR the issue is that we reject (valid) code such as
> _Alignas (long long) long long foo;
> with -m32, because we trip this condition:
>
>alignas_align = 1U << declspecs->align_log;
>if (alignas_align < TYPE_ALIGN_UNIT (type))
>  {
>if (name)
>  error_at (loc, "%<_Alignas%> specifiers cannot reduce "
>"alignment of %qE", name);
>
> and error later on, since alignas_align is 4 (correct, see PR52023 for
> why), but TYPE_ALIGN_UNIT of long long is 8.  I think TYPE_ALIGN_UNIT
> is wrong here as that won't give us minimal alignment required.
> In c_sizeof_or_alignof_type we already have the code to compute such
> minimal alignment so I just moved the code to a separate function
> and used that instead of TYPE_ALIGN_UNIT.

Hmm, but isn't TYPE_ALIGN_UNIT wrong then?

Richard.

>
> Note that the test is run only on i?86 and x86_64, because we can't (?)
> easily determine which target requires what alignment.
>
> Regtested/bootstrapped on x86_64-unknown-linux-gnu and
> powerpc64-unknown-linux-gnu, ok for trunk?
>
> 2014-05-05  Marek Polacek  
>
> PR c/61053
> c-family/
> * c-common.c (min_align_of_type): New function factored out from...
> (c_sizeof_or_alignof_type): ...here.
> * c-common.h (min_align_of_type): Declare.
> c/
> * c-decl.c (grokdeclarator): Use min_align_of_type instead of
> TYPE_ALIGN_UNIT.
> testsuite/
> * gcc.dg/pr61053.c: New test.
>
> diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c
> index 0ad955d..6d4440e 100644
> --- gcc/c-family/c-common.c
> +++ gcc/c-family/c-common.c
> @@ -4931,6 +4931,26 @@ c_common_get_alias_set (tree t)
>return -1;
>  }
>
> +/* Return the least alignment required for type TYPE.  */
> +
> +unsigned int
> +min_align_of_type (tree type)
> +{
> +  unsigned int align = TYPE_ALIGN (type);
> +  align = MIN (align, BIGGEST_ALIGNMENT);
> +#ifdef BIGGEST_FIELD_ALIGNMENT
> +  align = MIN (align, BIGGEST_FIELD_ALIGNMENT);
> +#endif
> +  unsigned int field_align = align;
> +#ifdef ADJUST_FIELD_ALIGN
> +  tree field = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL_TREE,
> +  type);
> +  field_align = ADJUST_FIELD_ALIGN (field, field_align);
> +#endif
> +  align = MIN (align, field_align);
> +  return align / BITS_PER_UNIT;
> +}
> +
>  /* Compute the value of 'sizeof (TYPE)' or '__alignof__ (TYPE)', where
> the IS_SIZEOF parameter indicates which operator is being applied.
> The COMPLAIN flag controls whether we should diagnose possibly
> @@ -5009,21 +5029,7 @@ c_sizeof_or_alignof_type (location_t loc,
> size_int (TYPE_PRECISION (char_type_node)
>   / BITS_PER_UNIT));
>else if (min_alignof)
> -   {
> - unsigned int align = TYPE_ALIGN (type);
> - align = MIN (align, BIGGEST_ALIGNMENT);
> -#ifdef BIGGEST_FIELD_ALIGNMENT
> - align = MIN (align, BIGGEST_FIELD_ALIGNMENT);
> -#endif
> - unsigned int field_align = align;
> -#ifdef ADJUST_FIELD_ALIGN
> - tree field = build_decl (UNKNOWN_LOCATION, FIELD_DECL, NULL_TREE,
> -  type);
> - field_align = ADJUST_FIELD_ALIGN (field, field_align);
> -#endif
> - align = MIN (align, field_align);
> - value = size_int (align / BITS_PER_UNIT);
> -   }
> +   value = size_int (min_align_of_type (type));
>else
> value = size_int (TYPE_ALIGN_UNIT (type));
>  }
> diff --git gcc/c-family/c-common.h gcc/c-family/c-common.h
> index 57b7dce..d34d2bb 100644
> --- gcc/c-family/c-common.h
> +++ gcc/c-family/c-common.h
> @@ -758,6 +758,7 @@ extern tree c_wrap_maybe_const (tree, bool);
>  extern tree c_save_expr (tree);
>  extern tree c_common_truthvalue_conversion (location_t, tree);
>  extern void c_apply_type_quals_to_decl (int, tree);
> +extern unsigned int min_align_of_type (tree);
>  extern tree c_sizeof_or_alignof_type (location_t, tree, bool, bool, int);
>  extern tree c_alignof_expr (location_t, tree);
>  /* Print an error message for invalid operands to arith operation CODE.
> diff --git gcc/c/c-decl.c gcc/c/c-decl.c
> index 6e7c589..9f7419a 100644
> --- gcc/c/c-decl.c
> +++ gcc/c/c-decl.c
> @@ -5931,7 +5931,7 @@ grokdeclarator (const struct c_declarator *declarator,
>else if (declspecs->align_log != -1)
> {
>   alignas_align = 1U << declspecs->align_log;
> - if (alignas_align < TYPE_ALIGN_UNIT (type))
> + if (alignas_align < min_align_of_type (type))
> {
>   if (name)
> error_at (loc, "%<_Alignas%> specifiers cannot reduce "
> diff --git gcc/testsuite/gcc.dg/pr61053.c gcc/testsuite/gcc.dg/pr61053.c
> index e69de29..e3db534 100644
> --- gcc/testsuite/gcc.dg/pr61053.c
> +++ gcc/testsuite/gcc.dg/pr61053.c
> @@ -0,0 +1,75 @@
> +/* PR c/61053 */
> +/* { dg-do compile { 

Re: [DOC PATCH] Rewrite docs for inline asm

2014-05-06 Thread Andrew Haley
On 05/05/2014 09:23 PM, Gerald Pfeifer wrote:
> Understood.  Let's see that we can get an update committed soon.
> We can always improve on it further later on, which then will be
> a lot easier to do, review, and get pushed.

Yes.  We already know that this is better than the current docs.
Let's check it in.

Andrew.



Re: Ping2: [PATCH] PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

2014-05-06 Thread Mark Wielaard
On Mon, 2014-04-28 at 14:37 +0200, Mark Wielaard wrote:
> On Mon, 2014-04-28 at 14:23 +0200, Jakub Jelinek wrote:
> > On Mon, Apr 28, 2014 at 01:17:32PM +0200, Mark Wielaard wrote:
> > > Ping2. Please let me know if I should ping/cc other people to get this
> > > reviewed.
> > 
> > Do you want to add DW_AT_type to DW_TAG_enumeration only if it has explicit
> > underlying type (enum class foo: char { ... };) or even when the underlying
> > type is computed emplicitly (then you'd just use TREE_TYPE of the
> > ENUMERAL_TYPE if non-NULL).
> 
> The debugger cares about the actual underlying type used if the language
> can use multiple. Either explicitly assigned by the user or implicitly
> as derived by the language/compile flags used. So the lang hook should
> provide one in both cases, if appropriate.

Please let me know if that answered the question and whether that
information is enough to review the patch. I have attached a rebased
version against current trunk.

Thanks,

Mark
commit 6210291f2a8f01e989565ef0e7ba580144e67472
Author: Mark Wielaard 
Date:   Sun Mar 23 12:05:16 2014 +0100

PR debug/16063. Add DW_AT_type to DW_TAG_enumeration.

Add a new lang-hook that provides the underlying base type of an
ENUMERAL_TYPE. Including implementations for C and C++. Use this
enum_underlying_base_type lang-hook in dwarf2out.c to add a DW_AT_type
base type reference to a DW_TAG_enumeration.

gcc/
	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
	enum_underlying_base_type defined and DWARF version > 3.
	* langhooks.h (struct lang_hooks_for_types): Add
	enum_underlying_base_type.
	* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.

gcc/c-family/
	* c-common.c (c_enum_underlying_base_type): New function.
	* c-common.h (c_enum_underlying_base_type): Add declaration.

gcc/c/
	* c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.

gcc/cp/
	* cp-lang.c (cxx_enum_underlying_base_type): New function.
	(LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 41dee8f..d29281a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2014-03-21  Mark Wielaard  
+
+	PR debug/16063
+	* dwarf2out.c (gen_enumeration_type_die): Add DW_AT_type if
+	enum_underlying_base_type defined and DWARF version > 3.
+	* langhooks.h (struct lang_hooks_for_types): Add
+	enum_underlying_base_type.
+	* langhooks-def.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): New define.
+	(LANG_HOOKS_FOR_TYPES_INITIALIZER): Add new lang hook.
+
 2014-05-05  Jan Hubicka  
 
 	PR ipa/60965
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 3c97323..05e5b55 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,9 @@
+2014-03-21  Mark Wielaard  
+
+	PR debug/16063
+	* c-common.c (c_enum_underlying_base_type): New function.
+	* c-common.h (c_enum_underlying_base_type): Add declaration.
+
 2014-05-02  Marek Polacek  
 
 	* c.opt (Wsizeof-pointer-memaccess): Describe option.
diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 0ad955d..6862c6f 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -3906,6 +3906,14 @@ c_register_builtin_type (tree type, const char* name)
 
   registered_builtin_types = tree_cons (0, type, registered_builtin_types);
 }
+
+/* The C version of the enum_underlying_base_type langhook.  */
+tree
+c_enum_underlying_base_type (const_tree type)
+{
+  return c_common_type_for_size (TYPE_PRECISION (type), TYPE_UNSIGNED (type));
+}
+
 
 /* Print an error message for invalid operands to arith operation
CODE with TYPE0 for operand 0, and TYPE1 for operand 1.
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 57b7dce..25c3272 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -832,6 +832,7 @@ extern void c_common_finish (void);
 extern void c_common_parse_file (void);
 extern alias_set_type c_common_get_alias_set (tree);
 extern void c_register_builtin_type (tree, const char*);
+extern tree c_enum_underlying_base_type (const_tree);
 extern bool c_promoting_integer_type_p (const_tree);
 extern int self_promoting_args_p (const_tree);
 extern tree strip_pointer_operator (tree);
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index e408fef..aa93750 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,8 @@
+2014-03-21  Mark Wielaard  
+
+	PR debug/16063
+	* c-objc-common.h (LANG_HOOKS_ENUM_UNDERLYING_BASE_TYPE): Define.
+
 2014-05-02  Marek Polacek  
 
 	PR c/25801
diff --git a/gcc/c/c-objc-common.h b/gcc/c/c-objc-common.h
index 92cf60f..0651db7 100644
--- a/gcc/c/c-objc-common.h
+++ b/gcc/c/c-objc-common.h
@@ -84,6 +84,8 @@ along with GCC; see the file COPYING3.  If not see
 #define LANG_HOOKS_TO_TARGET_CHARSET c_common_to_target_charset
 #undef LANG_HOOKS_EXPR_TO_DECL
 #define LANG_HOOKS_EXPR_TO_DECL