Re: [PATCH] [gomp4] Initial support of OpenACC loop directive in C front-end.

2014-03-20 Thread Ilmir Usmanov

Hi Thomas!

On 19.03.2014 23:35, Thomas Schwinge wrote:

Do you intend to support loop constructs that are not nested in a
parallel or kernels construct?  As I'm reading it, the specification is
not clear on this.  (I guess I'll raise this question with the OpenACC
guys.)
Yes, I do. There are three reasons to support OpenACC loop directive 
without enclosing construct:

1) The spec doesn't require the directive to be inside of a construct.
2) PGI compiler does support this.
3) GCC OpenMP implementation supports loop construct without parallel.

However, I agree that there no sense to use OpenACC loop without a 
construct. So, should there be a warning, perhaps?


--
Ilmir.


[PATCH] Fix i?86 pic thunk generation (PR target/60568)

2014-03-20 Thread Jakub Jelinek
Hi!

With -flto -fpic -m32 sometimes (unfortunately the testcase provided was
in form of *.o file with LTO bytecode, so can't be reduced), if the thunk
target doesn't bind locally we get ICE because we can't recog what
x86_output_mi_thunk creates.  The problem is that it doesn't
put UNSPEC_GOT into CONST and thus ix86_decompose_address refuses it.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux and
tested with the testcase that it doesn't ICE anymore and can be properly
assembled.  Ok for trunk?

2014-03-19  Jakub Jelinek  

PR target/60568
* config/i386/i386.c (x86_output_mi_thunk): Surround UNSPEC_GOT
into CONST, put pic register as first operand of PLUS.  Use
gen_const_mem for both 32-bit and 64-bit PIC got loads.

--- gcc/config/i386/i386.c.jj   2014-03-17 20:02:31.0 +0100
+++ gcc/config/i386/i386.c  2014-03-20 06:40:05.713956057 +0100
@@ -38753,7 +38753,7 @@ x86_output_mi_thunk (FILE *file,
{
  tmp = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, fnaddr), UNSPEC_GOTPCREL);
  tmp = gen_rtx_CONST (Pmode, tmp);
- fnaddr = gen_rtx_MEM (Pmode, tmp);
+ fnaddr = gen_const_mem (Pmode, tmp);
}
 }
   else
@@ -38773,8 +38773,9 @@ x86_output_mi_thunk (FILE *file,
  output_set_got (tmp, NULL_RTX);
 
  fnaddr = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, fnaddr), UNSPEC_GOT);
- fnaddr = gen_rtx_PLUS (Pmode, fnaddr, tmp);
- fnaddr = gen_rtx_MEM (Pmode, fnaddr);
+ fnaddr = gen_rtx_CONST (Pmode, fnaddr);
+ fnaddr = gen_rtx_PLUS (Pmode, tmp, fnaddr);
+ fnaddr = gen_const_mem (Pmode, fnaddr);
}
 }
 

Jakub


Re: [PATCH] [gomp4] Initial support of OpenACC loop directive in C front-end.

2014-03-20 Thread Tobias Burnus
Ilmir Usmanov wrote:
> On 19.03.2014 23:35, Thomas Schwinge wrote:
> > Do you intend to support loop constructs that are not nested in a
> > parallel or kernels construct?  As I'm reading it, the specification is
> > not clear on this.  (I guess I'll raise this question with the OpenACC
> > guys.)
>
> Yes, I do. There are three reasons to support OpenACC loop directive
> without enclosing construct: 
> 1) The spec doesn't require the directive to be inside of a construct.
> 2) PGI compiler does support this.
> 3) GCC OpenMP implementation supports loop construct without parallel.
>
> However, I agree that there no sense to use OpenACC loop without a
> construct. So, should there be a warning, perhaps? 

Could it happen that such a loop becomes active due to inlining, such
as:

f() __attribute__((inline)) {
#pragma acc loop
for (...) {
   ...
}

...

#pragma acc parallel
{
  f()
}


Or is that not possible? With OpenMP I surely used a similar code, but
there one does no have to generate special accelerator code. I know that
the Cray compiler does even LTO inlining with OpenACC, which permits to
call functions in a kernels/parallel section, which are defined in a
different file. [That is without using the OpenACC 2.0 features of
specially tagging a function as one which also runs on accelerators.]
However, I do not know whether Cray or other OpenACC compilers will
honor the 'loop' in this case. I would assume that they do, but I
haven't tested it.

Tobias


Re: [PATCH] Fix i?86 pic thunk generation (PR target/60568)

2014-03-20 Thread Uros Bizjak
On Thu, Mar 20, 2014 at 10:05 AM, Jakub Jelinek  wrote:

> With -flto -fpic -m32 sometimes (unfortunately the testcase provided was
> in form of *.o file with LTO bytecode, so can't be reduced), if the thunk
> target doesn't bind locally we get ICE because we can't recog what
> x86_output_mi_thunk creates.  The problem is that it doesn't
> put UNSPEC_GOT into CONST and thus ix86_decompose_address refuses it.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux and
> tested with the testcase that it doesn't ICE anymore and can be properly
> assembled.  Ok for trunk?
>
> 2014-03-19  Jakub Jelinek  
>
> PR target/60568
> * config/i386/i386.c (x86_output_mi_thunk): Surround UNSPEC_GOT
> into CONST, put pic register as first operand of PLUS.  Use
> gen_const_mem for both 32-bit and 64-bit PIC got loads.

OK for mainline, and also other release branches.

Thanks,
Uros.


Re: [Patch, Fortran] PRs 60283/60543: Fix two wrong-code bugs related for implicit pure

2014-03-20 Thread Dominique Dhumieres
Tobias,

> However, after I wrote that, I saw that there is a dg-* 
> which permits to check the .mod file for a string.

Are you sure it works now the *.mod files are gzipped?
AFAICT it does not.

The following test

MODULE generalFunctions

USE, INTRINSIC :: ISO_FORTRAN_ENV
IMPLICIT NONE

INTEGER, PARAMETER :: DP = REAL64

CONTAINS

REAL(DP) FUNCTION random()

CALL RANDOM_NUMBER(random)

END FUNCTION random

END MODULE generalFunctions

PROGRAM bugFind

USE generalFunctions
IMPLICIT NONE

REAL(DP), parameter :: half = 1.0_DP/2.0_DP

INTEGER:: i, ih(4)

ih = 0
DO i=1,4

if (random() < half) then
  if (random() < half) then
ih(1) = ih(1) + 1
  else
ih(2) = ih(2) + 1
  end if
else
  if (random() 300)) call abort()

END PROGRAM bugFind

succeeds with your patch, but without it. However if the module is put
in a different file it does not.

Dominique


Re: [PATCH] [gomp4] Initial support of OpenACC loop directive in C front-end.

2014-03-20 Thread Thomas Schwinge
Hi Ilmir!

On Tue, 18 Mar 2014 16:37:24 +0400, Ilmir Usmanov  wrote:
> This patch introduces support of OpenACC loop directive (and combined 
> directives) in C front-end up to GENERIC. Currently no clause is allowed.

> --- /dev/null
> +++ b/gcc/testsuite/c-c++-common/goacc/loop-1.c
> @@ -0,0 +1,89 @@
> +/* { dg-do compile } */
> +
> +int test1()
> +{

> +  /* combined directives may be used*/
> +  #pragma acc parallel loop
> +  for(i = 1; i < 10; i++)
> +{
> +}
> +  #pragma acc kernels loop
> +  for(i = 1; i < 10; i++)
> +{
> +}
> +  return 0;
> +}
> +/* { dg-excess-errors "directive not yet implemented" } */
> \ No newline at end of file

I just realized that this is wrong usage of the dg-excess-errors
directive, for this one will absorb *all* remaining errors, whereas you
just wanted to mask out any »sorry, unimplemented: directive not yet
implemented« ones.

OK to fix as follows?

commit f83fdbfbc52e360b89b31a822a645b7f0dcabc96
Author: Thomas Schwinge 
Date:   Thu Mar 20 11:04:12 2014 +0100

Replace dg-excess-errors usage with dg-prune-output.

gcc/testsuite/
* c-c++-common/goacc/loop-1.c: Replace dg-excess-errors usage with
dg-prune-output.

diff --git gcc/testsuite/c-c++-common/goacc/loop-1.c 
gcc/testsuite/c-c++-common/goacc/loop-1.c
index 4546520..b890f38 100644
--- gcc/testsuite/c-c++-common/goacc/loop-1.c
+++ gcc/testsuite/c-c++-common/goacc/loop-1.c
@@ -69,4 +69,4 @@ int test1()
 }
   return 0;
 }
-/* { dg-excess-errors "directive not yet implemented" } */
\ No newline at end of file
+/* { dg-prune-output "sorry, unimplemented: directive not yet implemented" } */


Grüße,
 Thomas


pgp7cwHIWTF5F.pgp
Description: PGP signature


Re: [PATCH 4/4] [GOMP4] [Fortran] OpenACC 1.0+ support in fortran front-end

2014-03-20 Thread Thomas Schwinge
Hi Ilmir!

On Fri, 7 Mar 2014 14:47:14 +0400, Ilmir Usmanov  wrote:
>  OpenACC 1.0 fortran FE support -- tests.

> --- /dev/null
> +++ b/gcc/testsuite/gfortran.dg/goacc/coarray.f95
> @@ -0,0 +1,35 @@
> +! { dg-do compile } 

> +! { dg-excess-errors "Unimplemented" }
> +! { dg-excess-errors "ACC LOOP" }
> \ No newline at end of file

As in
,
this is wrong usage of the dg-excess-errors directive, for this one will
absorb *all* remaining errors, whereas you just wanted to mask out any
»sorry, unimplemented: [...]« ones.

OK to fix as follows?

commit 6d27a0605bd914a1b51e467e340221c5b018e129
Author: Thomas Schwinge 
Date:   Thu Mar 20 11:04:30 2014 +0100

Replace dg-excess-errors usage with dg-prune-output.

gcc/testsuite/
* gfortran.dg/goacc/cache-1.f95: Replace dg-excess-errors usage
with dg-prune-output.
* gfortran.dg/goacc/coarray.f95: Likewise.
* gfortran.dg/goacc/cray.f95: Likewise.
* gfortran.dg/goacc/data-tree.f95: Likewise.
* gfortran.dg/goacc/declare-1.f95: Likewise.
* gfortran.dg/goacc/host_data-tree.f95: Likewise.
* gfortran.dg/goacc/kernels-tree.f95: Likewise.
* gfortran.dg/goacc/loop-1.f95: Likewise.
* gfortran.dg/goacc/parallel-kernels-regions.f95: Likewise.
* gfortran.dg/goacc/parallel-tree.f95: Likewise.
* gfortran.dg/goacc/parameter.f95: Likewise.

diff --git gcc/testsuite/gfortran.dg/goacc/cache-1.f95 
gcc/testsuite/gfortran.dg/goacc/cache-1.f95
index 6d7f60a..746cf02 100644
--- gcc/testsuite/gfortran.dg/goacc/cache-1.f95
+++ gcc/testsuite/gfortran.dg/goacc/cache-1.f95
@@ -9,4 +9,4 @@ program test
 !$acc cache (d)
   enddo
 end
-! { dg-excess-errors "unimplemented" }
\ No newline at end of file
+! { dg-prune-output "unimplemented" }
diff --git gcc/testsuite/gfortran.dg/goacc/coarray.f95 
gcc/testsuite/gfortran.dg/goacc/coarray.f95
index 7afb4bc..ab13157 100644
--- gcc/testsuite/gfortran.dg/goacc/coarray.f95
+++ gcc/testsuite/gfortran.dg/goacc/coarray.f95
@@ -31,5 +31,4 @@ contains
 !$acc update device (a)
   end subroutine oacc1
 end module test
-! { dg-excess-errors "Unimplemented" }
-! { dg-excess-errors "ACC LOOP" }
\ No newline at end of file
+! { dg-prune-output "ACC cache unimplemented" }
diff --git gcc/testsuite/gfortran.dg/goacc/cray.f95 
gcc/testsuite/gfortran.dg/goacc/cray.f95
index 509f61b..3225b28 100644
--- gcc/testsuite/gfortran.dg/goacc/cray.f95
+++ gcc/testsuite/gfortran.dg/goacc/cray.f95
@@ -51,4 +51,4 @@ contains
 !$acc update device (ptr)
   end subroutine oacc1
 end module test
-! { dg-excess-errors "unimplemented" }
\ No newline at end of file
+! { dg-prune-output "unimplemented" }
diff --git gcc/testsuite/gfortran.dg/goacc/data-tree.f95 
gcc/testsuite/gfortran.dg/goacc/data-tree.f95
index d29c060..a5c012a 100644
--- gcc/testsuite/gfortran.dg/goacc/data-tree.f95
+++ gcc/testsuite/gfortran.dg/goacc/data-tree.f95
@@ -12,7 +12,7 @@ program test
   !$acc end data
 
 end program test
-! { dg-excess-errors "unimplemented" }
+! { dg-prune-output "unimplemented" }
 ! { dg-final { scan-tree-dump-times "pragma acc data" 1 "original" } } 
 
 ! { dg-final { scan-tree-dump-times "if" 1 "original" } }
@@ -28,4 +28,4 @@ end program test
 ! { dg-final { scan-tree-dump-times "map\\(alloc:t\\)" 1 "original" } } 
 
 ! { dg-final { scan-tree-dump-times "map\\(force_deviceptr:u\\)" 1 "original" 
} } 
-! { dg-final { cleanup-tree-dump "original" } } 
\ No newline at end of file
+! { dg-final { cleanup-tree-dump "original" } } 
diff --git gcc/testsuite/gfortran.dg/goacc/declare-1.f95 
gcc/testsuite/gfortran.dg/goacc/declare-1.f95
index aec3ae8..03540f1 100644
--- gcc/testsuite/gfortran.dg/goacc/declare-1.f95
+++ gcc/testsuite/gfortran.dg/goacc/declare-1.f95
@@ -15,6 +15,6 @@ contains
 END BLOCK
   end function foo
 end program test
-! { dg-excess-errors "unimplemented" }
+! { dg-prune-output "unimplemented" }
 ! { dg-final { scan-tree-dump-times "pragma acc declare 
map\\(force_tofrom:i\\)" 2 "original" } } 
 ! { dg-final { cleanup-tree-dump "original" } } 
diff --git gcc/testsuite/gfortran.dg/goacc/host_data-tree.f95 
gcc/testsuite/gfortran.dg/goacc/host_data-tree.f95
index 1c24fe7..19e7411 100644
--- gcc/testsuite/gfortran.dg/goacc/host_data-tree.f95
+++ gcc/testsuite/gfortran.dg/goacc/host_data-tree.f95
@@ -8,6 +8,6 @@ program test
   !$acc host_data use_device(i)
   !$acc end host_data
 end program test
-! { dg-excess-errors "unimplemented" }
+! { dg-prune-output "unimplemented" }
 ! { dg-final { scan-tree-dump-times "pragma acc host_data use_device\\(i\\)" 1 
"original" } } 
 ! { dg-final { cleanup-tree-dump "original" } } 
diff --git gcc/testsuite/gfortran.dg/goacc/kernels-tree.f95 
gcc/testsuite/gfortran.dg/goacc/kernels-tree.f95
index 5c65d2a..73f172c 100644
--- gcc/testsuite/gfortran.dg/goacc/kernels-tree.f95
+++ gcc/testsuite/gfortran.dg/goacc/kernels-tree.f95
@@ -12,7 +

Re: [C++ PATCH] [gomp4] Initial OpenACC support to C++ front-end

2014-03-20 Thread Thomas Schwinge
Hi Ilmir!

On Thu, 13 Mar 2014 21:05:17 +0400, Ilmir Usmanov  wrote:
> On 07.03.2014 15:37, Ilmir Usmanov wrote:
> > I prepared simple patch to add support of OpenACC data, kernels and 
> > parallel constructs to C++ FE.
> >
> > It adds support of data clauses too.

> OK to gomp4 branch?

OK once Joseph is fine with the patch, and the following addressed:

>   * gcc/testsuite/c-c++-common/goacc/deviceptr-1.c: Move to ...
>   * gcc/testsuite/gcc.dg/goacc/deviceptr-1.c ... here.

OK, I see that the diagnostic messages do differ between C and C++, so
that it indeed seems to be better to split the file between the two.
Same for the structured block tests, sb*.*.

> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/goacc-gomp/goacc-gomp.exp
> @@ -0,0 +1,38 @@
> +# Copyright (C) 2006-2013 Free Software Foundation, Inc.

2014.

> +# Main loop.
> +dg-runtest [lsort [concat \
> + [find $srcdir/$subdir *.C] \
> + [find $srcdir/c-c++-common/goacc-gomp *.c]]] "" "-fopenacc -fopenmp"

I see gcc/testsuite/g++.dg/gomp/gomp.exp using g++-dg-runtest instead of
plain dg-runtest.  (I have not yet looked what's different there; can you
have a look, please?)

> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/goacc/goacc.exp
> @@ -0,0 +1,37 @@
> +# Copyright (C) 2006-2013 Free Software Foundation, Inc.

Likewise.

> +# Main loop.
> +dg-runtest [lsort [concat \
> + [find $srcdir/$subdir *.C] \
> + [find $srcdir/c-c++-common/goacc *.c]]] "" "-fopenacc"

Likewise.


Grüße,
 Thomas


pgpfZvuNd6DyH.pgp
Description: PGP signature


[C PATCH] Warn if inline attributes conflict (PR c/18079)

2014-03-20 Thread Marek Polacek
We should warn if someone wants to use both always_inline and noinline
attributes.

Regtested/bootstrapped on x86_64-linux.  This is hardly 4.9 material,
so ok for 5.0?

2014-03-20  Marek Polacek  

PR c/18079
c-family/
* c-common.c (handle_noinline_attribute): Warn if the attribute
conflicts with always_inline attribute.
(handle_always_inline_attribute): Warn if the attribute conflicts
with noinline attribute.
testsuite/
* gcc.dg/pr18079.c: New test.

diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c
index abd96fb..14c838a 100644
--- gcc/c-family/c-common.c
+++ gcc/c-family/c-common.c
@@ -,7 +,16 @@ handle_noinline_attribute (tree *node, tree name,
   int ARG_UNUSED (flags), bool *no_add_attrs)
 {
   if (TREE_CODE (*node) == FUNCTION_DECL)
-DECL_UNINLINABLE (*node) = 1;
+{
+  if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node)))
+   {
+ warning (OPT_Wattributes, "%qE attribute conflicts with attribute %s",
+  name, "always_inline");
+ *no_add_attrs = true;
+   }
+  else
+   DECL_UNINLINABLE (*node) = 1;
+}
   else
 {
   warning (OPT_Wattributes, "%qE attribute ignored", name);
@@ -6704,9 +6713,16 @@ handle_always_inline_attribute (tree *node, tree name,
 {
   if (TREE_CODE (*node) == FUNCTION_DECL)
 {
-  /* Set the attribute and mark it for disregarding inline
-limits.  */
-  DECL_DISREGARD_INLINE_LIMITS (*node) = 1;
+  if (lookup_attribute ("noinline", DECL_ATTRIBUTES (*node)))
+   {
+ warning (OPT_Wattributes, "%qE attribute conflicts with attribute %s",
+  name, "noinline");
+ *no_add_attrs = true;
+   }
+  else
+   /* Set the attribute and mark it for disregarding inline
+  limits.  */
+   DECL_DISREGARD_INLINE_LIMITS (*node) = 1;
 }
   else
 {
diff --git gcc/testsuite/gcc.dg/pr18079.c gcc/testsuite/gcc.dg/pr18079.c
index e69de29..adb5cdf 100644
--- gcc/testsuite/gcc.dg/pr18079.c
+++ gcc/testsuite/gcc.dg/pr18079.c
@@ -0,0 +1,33 @@
+/* PR c/18079 */
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+
+__attribute__ ((noinline))
+__attribute__ ((always_inline))
+int
+fn1 (int r)
+{ /* { dg-warning "attribute conflicts with attribute noinline" } */
+  return r & 4;
+}
+
+__attribute__ ((noinline, always_inline))
+int
+fn2 (int r)
+{ /* { dg-warning "attribute conflicts with attribute noinline" } */
+  return r & 4;
+}
+
+__attribute__ ((always_inline))
+__attribute__ ((noinline))
+inline int
+fn3 (int r)
+{ /* { dg-warning "attribute conflicts with attribute always_inline" } */
+  return r & 8;
+}
+
+__attribute__ ((always_inline, noinline))
+inline int
+fn4 (int r)
+{ /* { dg-warning "attribute conflicts with attribute always_inline" } */
+  return r & 8;
+}

Marek


Re: [C PATCH] Warn if inline attributes conflict (PR c/18079)

2014-03-20 Thread Richard Biener
On Thu, Mar 20, 2014 at 12:07 PM, Marek Polacek  wrote:
> We should warn if someone wants to use both always_inline and noinline
> attributes.
>
> Regtested/bootstrapped on x86_64-linux.  This is hardly 4.9 material,
> so ok for 5.0?

Shouldn't the warning state that the attribute will be ignored?  That is,
the common warning is

  warning (OPT_Wattributes, "%qE attribute ignored", name);

which could be amended with " due to conflict with ".

Richard.

> 2014-03-20  Marek Polacek  
>
> PR c/18079
> c-family/
> * c-common.c (handle_noinline_attribute): Warn if the attribute
> conflicts with always_inline attribute.
> (handle_always_inline_attribute): Warn if the attribute conflicts
> with noinline attribute.
> testsuite/
> * gcc.dg/pr18079.c: New test.
>
> diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c
> index abd96fb..14c838a 100644
> --- gcc/c-family/c-common.c
> +++ gcc/c-family/c-common.c
> @@ -,7 +,16 @@ handle_noinline_attribute (tree *node, tree name,
>int ARG_UNUSED (flags), bool *no_add_attrs)
>  {
>if (TREE_CODE (*node) == FUNCTION_DECL)
> -DECL_UNINLINABLE (*node) = 1;
> +{
> +  if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node)))
> +   {
> + warning (OPT_Wattributes, "%qE attribute conflicts with attribute 
> %s",
> +  name, "always_inline");
> + *no_add_attrs = true;
> +   }
> +  else
> +   DECL_UNINLINABLE (*node) = 1;
> +}
>else
>  {
>warning (OPT_Wattributes, "%qE attribute ignored", name);
> @@ -6704,9 +6713,16 @@ handle_always_inline_attribute (tree *node, tree name,
>  {
>if (TREE_CODE (*node) == FUNCTION_DECL)
>  {
> -  /* Set the attribute and mark it for disregarding inline
> -limits.  */
> -  DECL_DISREGARD_INLINE_LIMITS (*node) = 1;
> +  if (lookup_attribute ("noinline", DECL_ATTRIBUTES (*node)))
> +   {
> + warning (OPT_Wattributes, "%qE attribute conflicts with attribute 
> %s",
> +  name, "noinline");
> + *no_add_attrs = true;
> +   }
> +  else
> +   /* Set the attribute and mark it for disregarding inline
> +  limits.  */
> +   DECL_DISREGARD_INLINE_LIMITS (*node) = 1;
>  }
>else
>  {
> diff --git gcc/testsuite/gcc.dg/pr18079.c gcc/testsuite/gcc.dg/pr18079.c
> index e69de29..adb5cdf 100644
> --- gcc/testsuite/gcc.dg/pr18079.c
> +++ gcc/testsuite/gcc.dg/pr18079.c
> @@ -0,0 +1,33 @@
> +/* PR c/18079 */
> +/* { dg-do compile } */
> +/* { dg-options "-Wall" } */
> +
> +__attribute__ ((noinline))
> +__attribute__ ((always_inline))
> +int
> +fn1 (int r)
> +{ /* { dg-warning "attribute conflicts with attribute noinline" } */
> +  return r & 4;
> +}
> +
> +__attribute__ ((noinline, always_inline))
> +int
> +fn2 (int r)
> +{ /* { dg-warning "attribute conflicts with attribute noinline" } */
> +  return r & 4;
> +}
> +
> +__attribute__ ((always_inline))
> +__attribute__ ((noinline))
> +inline int
> +fn3 (int r)
> +{ /* { dg-warning "attribute conflicts with attribute always_inline" } */
> +  return r & 8;
> +}
> +
> +__attribute__ ((always_inline, noinline))
> +inline int
> +fn4 (int r)
> +{ /* { dg-warning "attribute conflicts with attribute always_inline" } */
> +  return r & 8;
> +}
>
> Marek


Re: [Patch, Fortran] PRs 60283/60543: Fix two wrong-code bugs related for implicit pure

2014-03-20 Thread Dominique Dhumieres
Tobias,

> succeeds with your patch, but without it.

was supposed to be "succeeds with your patch, but not without it."

I also understand what happened when the test was split in two files:

If the module file is compiled with the patched compiler, then the test
succeed with ot without the patch. On the other hand, if the module file
is compiled with the unpatched compiler, then the test fails even with the
patched compiler, i.e., the error is in the module and it is not recompiled.

Dominique


Remove left-overs from RTX_UNCHANGING_P era

2014-03-20 Thread Eric Botcazou
While investigating PR rtl-opt/60452, I stumbled upon left-overs of the 
RTX_UNCHANGING_P era, in the form the following idiom:

  target
= assign_temp (build_qualified_type (type, (TYPE_QUALS (type)
| (TREE_READONLY (exp)
   * TYPE_QUAL_CONST))),
   TREE_ADDRESSABLE (exp), 1);
  target = assign_temp (type, TREE_ADDRESSABLE (exp), 1);

with 'target' being stored to just after.  This used to be correct with 
RTX_UNCHANGING_P which roughly meant "read-only except for the first access 
which can be a write" and assign_stack_temp_for_type used to contain:

  RTX_UNCHANGING_P (slot)
= (lang_hooks.honor_readonly && TYPE_READONLY (type));

but is not correct in the current RTL world anymore (as a matter of fact, the 
4 examples are all dead code since TYPE_READONLY isn't used anymore, verified 
on the compiler proper at -O2 that there is not a single byte changed in the 
generated code).

Tested on x86_64-suse-linux, applied on the mainline as obvious.


2014-03-20  Eric Botcazou  

* calls.c (store_one_arg): Remove incorrect const qualification on the
type of the temporary.
* cfgexpand.c (expand_return): Likewise.
* expr.c (expand_constructor): Likewise.
(expand_expr_real_1): Likewise.


-- 
Eric BotcazouIndex: calls.c
===
--- calls.c	(revision 208674)
+++ calls.c	(working copy)
@@ -4451,11 +4451,8 @@ store_one_arg (struct arg_data *arg, rtx
 
 	  if (save_mode == BLKmode)
 		{
-		  tree ot = TREE_TYPE (arg->tree_value);
-		  tree nt = build_qualified_type (ot, (TYPE_QUALS (ot)
-		   | TYPE_QUAL_CONST));
-
-		  arg->save_area = assign_temp (nt, 1, 1);
+		  arg->save_area
+		= assign_temp (TREE_TYPE (arg->tree_value), 1, 1);
 		  preserve_temp_slots (arg->save_area);
 		  emit_block_move (validize_mem (arg->save_area), stack_area,
    GEN_INT (arg->locate.size.constant),
Index: cfgexpand.c
===
--- cfgexpand.c	(revision 208674)
+++ cfgexpand.c	(working copy)
@@ -3105,15 +3105,11 @@ expand_return (tree retval)
 	   && (REG_P (result_rtl)
 	   || (GET_CODE (result_rtl) == PARALLEL)))
 {
-  /* Calculate the return value into a temporary (usually a pseudo
- reg).  */
-  tree ot = TREE_TYPE (DECL_RESULT (current_function_decl));
-  tree nt = build_qualified_type (ot, TYPE_QUALS (ot) | TYPE_QUAL_CONST);
-
-  val = assign_temp (nt, 0, 1);
+  /* Compute the return value into a temporary (usually a pseudo reg).  */
+  val
+	= assign_temp (TREE_TYPE (DECL_RESULT (current_function_decl)), 0, 1);
   val = expand_expr (retval_rhs, val, GET_MODE (val), EXPAND_NORMAL);
   val = force_not_mem (val);
-  /* Return the calculated value.  */
   expand_value_return (val);
 }
   else
Index: expr.c
===
--- expr.c	(revision 208674)
+++ expr.c	(working copy)
@@ -7867,11 +7867,7 @@ expand_constructor (tree exp, rtx target
   if (avoid_temp_mem)
 	return NULL_RTX;
 
-  target
-	= assign_temp (build_qualified_type (type, (TYPE_QUALS (type)
-		| (TREE_READONLY (exp)
-		   * TYPE_QUAL_CONST))),
-		   TREE_ADDRESSABLE (exp), 1);
+  target = assign_temp (type, TREE_ADDRESSABLE (exp), 1);
 }
 
   store_constructor (exp, target, 0, int_expr_size (exp));
@@ -10088,10 +10084,7 @@ expand_expr_real_1 (tree exp, rtx target
 	   and need be, put it there.  */
 	else if (CONSTANT_P (op0) || (!MEM_P (op0) && must_force_mem))
 	  {
-	tree nt = build_qualified_type (TREE_TYPE (tem),
-	(TYPE_QUALS (TREE_TYPE (tem))
-	 | TYPE_QUAL_CONST));
-	memloc = assign_temp (nt, 1, 1);
+	memloc = assign_temp (TREE_TYPE (tem), 1, 1);
 	emit_move_insn (memloc, op0);
 	op0 = memloc;
 	mem_attrs_from_type = true;

[SPARC] Implement workaround for new FPU erratum on LEON3

2014-03-20 Thread Eric Botcazou
This implements a workaround for the recently-disclosed FPU erratum on LEON3.

Tested on SPARC/Solaris, applied on the mainline and 4.8 branch.


2014-03-20  Eric Botcazou  

* config/sparc/sparc.c (sparc_do_work_around_errata): Implement work
around for store forwarding issue in the FPU on the UT699.
* config/sparc/sparc.md (in_branch_delay): Return false for single FP
loads and operations if -mfix-ut699 is specified.
(divtf3_hq): Tweak attribute.
(sqrttf2_hq): Likewise.


-- 
Eric BotcazouIndex: config/sparc/sparc.md
===
--- config/sparc/sparc.md	(revision 208674)
+++ config/sparc/sparc.md	(working copy)
@@ -462,6 +462,10 @@ (define_attr "in_branch_delay" "false,tr
 	   (const_string "false")
 	 (and (eq_attr "fix_ut699" "true") (eq_attr "type" "load,sload"))
 	   (const_string "false")
+	 (and (eq_attr "fix_ut699" "true")
+	  (and (eq_attr "type" "fpload,fp,fpmove,fpmul,fpdivs,fpsqrts")
+		   (eq_attr "fptype" "single")))
+	   (const_string "false")
 	 (eq_attr "length" "1")
 	   (const_string "true")
 	] (const_string "false")))
@@ -5513,7 +5517,7 @@ (define_insn "*divtf3_hq"
 		(match_operand:TF 2 "register_operand" "e")))]
   "TARGET_FPU && TARGET_HARD_QUAD"
   "fdivq\t%1, %2, %0"
-  [(set_attr "type" "fpdivd")])
+  [(set_attr "type" "fpdivs")])
 
 (define_expand "divdf3"
   [(set (match_operand:DF 0 "register_operand" "=e")
@@ -5744,7 +5748,7 @@ (define_insn "*sqrttf2_hq"
 	(sqrt:TF (match_operand:TF 1 "register_operand" "e")))]
   "TARGET_FPU && TARGET_HARD_QUAD"
   "fsqrtq\t%1, %0"
-  [(set_attr "type" "fpsqrtd")])
+  [(set_attr "type" "fpsqrts")])
 
 (define_expand "sqrtdf2"
   [(set (match_operand:DF 0 "register_operand" "=e")
Index: config/sparc/sparc.c
===
--- config/sparc/sparc.c	(revision 208674)
+++ config/sparc/sparc.c	(working copy)
@@ -1012,6 +1012,106 @@ sparc_do_work_around_errata (void)
 	}
 	}
 
+  /* Look for a single-word load/operation into an FP register.  */
+  else if (sparc_fix_ut699
+	   && NONJUMP_INSN_P (insn)
+	   && (set = single_set (insn)) != NULL_RTX
+	   && GET_MODE_SIZE (GET_MODE (SET_SRC (set))) == 4
+	   && REG_P (SET_DEST (set))
+	   && REGNO (SET_DEST (set)) > 31)
+	{
+	  /* Number of instructions in the problematic window.  */
+	  const int n_insns = 4;
+	  /* The problematic combination is with the sibling FP register.  */
+	  const unsigned int x = REGNO (SET_DEST (set));
+	  const unsigned int y = x ^ 1;
+	  rtx after;
+	  int i;
+
+	  next = next_active_insn (insn);
+	  if (!next)
+	break;
+	  /* If the insn is a branch, then it cannot be problematic.  */
+	  if (!NONJUMP_INSN_P (next) || GET_CODE (PATTERN (next)) == SEQUENCE)
+	continue;
+
+	  /* Look for a second load/operation into the sibling FP register.  */
+	  if (!((set = single_set (next)) != NULL_RTX
+		&& GET_MODE_SIZE (GET_MODE (SET_SRC (set))) == 4
+		&& REG_P (SET_DEST (set))
+		&& REGNO (SET_DEST (set)) == y))
+	continue;
+
+	  /* Look for a (possible) store from the FP register in the next N
+	 instructions, but bail out if it is again modified or if there
+	 is a store from the sibling FP register before this store.  */
+	  for (after = next, i = 0; i < n_insns; i++)
+	{
+	  bool branch_p;
+
+	  after = next_active_insn (after);
+	  if (!after)
+		break;
+
+	  /* This is a branch with an empty delay slot.  */
+	  if (!NONJUMP_INSN_P (after))
+		{
+		  if (++i == n_insns)
+		break;
+		  branch_p = true;
+		  after = NULL_RTX;
+		}
+	  /* This is a branch with a filled delay slot.  */
+	  else if (GET_CODE (PATTERN (after)) == SEQUENCE)
+		{
+		  if (++i == n_insns)
+		break;
+		  branch_p = true;
+		  after = XVECEXP (PATTERN (after), 0, 1);
+		}
+	  /* This is a regular instruction.  */
+	  else
+		branch_p = false;
+
+	  if (after && (set = single_set (after)) != NULL_RTX)
+		{
+		  const rtx src = SET_SRC (set);
+		  const rtx dest = SET_DEST (set);
+		  const unsigned int size = GET_MODE_SIZE (GET_MODE (dest));
+
+		  /* If the FP register is again modified before the store,
+		 then the store isn't affected.  */
+		  if (REG_P (dest)
+		  && (REGNO (dest) == x
+			  || (REGNO (dest) == y && size == 8)))
+		break;
+
+		  if (MEM_P (dest) && REG_P (src))
+		{
+		  /* If there is a store from the sibling FP register
+			 before the store, then the store is not affected.  */
+		  if (REGNO (src) == y || (REGNO (src) == x && size == 8))
+			break;
+
+		  /* Otherwise, the store is affected.  */
+		  if (REGNO (src) == x && size == 4)
+			{
+			  insert_nop = true;
+			  break;
+			}
+		}
+		}
+
+	  /* If we have a branch in the first M instructions, then we
+		 cannot see the (M+2)th instruction so we play safe.  */
+	  if (branch_p && i <= (n_insns - 2))
+		{
+		  inser

Re: [C PATCH] Warn if inline attributes conflict (PR c/18079)

2014-03-20 Thread Marek Polacek
On Thu, Mar 20, 2014 at 12:10:35PM +0100, Richard Biener wrote:
> On Thu, Mar 20, 2014 at 12:07 PM, Marek Polacek  wrote:
> > We should warn if someone wants to use both always_inline and noinline
> > attributes.
> >
> > Regtested/bootstrapped on x86_64-linux.  This is hardly 4.9 material,
> > so ok for 5.0?
> 
> Shouldn't the warning state that the attribute will be ignored?  That is,
> the common warning is
> 
>   warning (OPT_Wattributes, "%qE attribute ignored", name);
> 
> which could be amended with " due to conflict with ".

Dunno.  I did what we do wrt conflicting cold/hot attributes.  But
here's a patch with what you suggest (with some Extra Quotes).

2014-03-20  Marek Polacek  

PR c/18079
c-family/
* c-common.c (handle_noinline_attribute): Warn if the attribute
conflicts with always_inline attribute.
(handle_always_inline_attribute): Warn if the attribute conflicts
with noinline attribute.
testsuite/
* gcc.dg/pr18079.c: New test.

diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c
index abd96fb..5258e52 100644
--- gcc/c-family/c-common.c
+++ gcc/c-family/c-common.c
@@ -,7 +,16 @@ handle_noinline_attribute (tree *node, tree name,
   int ARG_UNUSED (flags), bool *no_add_attrs)
 {
   if (TREE_CODE (*node) == FUNCTION_DECL)
-DECL_UNINLINABLE (*node) = 1;
+{
+  if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node)))
+   {
+ warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
+  "with % attribute", name);
+ *no_add_attrs = true;
+   }
+  else
+   DECL_UNINLINABLE (*node) = 1;
+}
   else
 {
   warning (OPT_Wattributes, "%qE attribute ignored", name);
@@ -6704,9 +6713,16 @@ handle_always_inline_attribute (tree *node, tree name,
 {
   if (TREE_CODE (*node) == FUNCTION_DECL)
 {
-  /* Set the attribute and mark it for disregarding inline
-limits.  */
-  DECL_DISREGARD_INLINE_LIMITS (*node) = 1;
+  if (lookup_attribute ("noinline", DECL_ATTRIBUTES (*node)))
+   {
+ warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
+  "with % attribute", name);
+ *no_add_attrs = true;
+   }
+  else
+   /* Set the attribute and mark it for disregarding inline
+  limits.  */
+   DECL_DISREGARD_INLINE_LIMITS (*node) = 1;
 }
   else
 {
diff --git gcc/testsuite/gcc.dg/pr18079.c gcc/testsuite/gcc.dg/pr18079.c
index e69de29..b84cdeb 100644
--- gcc/testsuite/gcc.dg/pr18079.c
+++ gcc/testsuite/gcc.dg/pr18079.c
@@ -0,0 +1,33 @@
+/* PR c/18079 */
+/* { dg-do compile } */
+/* { dg-options "-Wall" } */
+
+__attribute__ ((noinline))
+__attribute__ ((always_inline))
+int
+fn1 (int r)
+{ /* { dg-warning "attribute ignored due to conflict" } */
+  return r & 4;
+}
+
+__attribute__ ((noinline, always_inline))
+int
+fn2 (int r)
+{ /* { dg-warning "attribute ignored due to conflict" } */
+  return r & 4;
+}
+
+__attribute__ ((always_inline))
+__attribute__ ((noinline))
+inline int
+fn3 (int r)
+{ /* { dg-warning "attribute ignored due to conflict" } */
+  return r & 8;
+}
+
+__attribute__ ((always_inline, noinline))
+inline int
+fn4 (int r)
+{ /* { dg-warning "attribute ignored due to conflict" } */
+  return r & 8;
+}

Marek


Re: [C PATCH] Warn if inline attributes conflict (PR c/18079)

2014-03-20 Thread Richard Biener
On Thu, Mar 20, 2014 at 12:45 PM, Marek Polacek  wrote:
> On Thu, Mar 20, 2014 at 12:10:35PM +0100, Richard Biener wrote:
>> On Thu, Mar 20, 2014 at 12:07 PM, Marek Polacek  wrote:
>> > We should warn if someone wants to use both always_inline and noinline
>> > attributes.
>> >
>> > Regtested/bootstrapped on x86_64-linux.  This is hardly 4.9 material,
>> > so ok for 5.0?
>>
>> Shouldn't the warning state that the attribute will be ignored?  That is,
>> the common warning is
>>
>>   warning (OPT_Wattributes, "%qE attribute ignored", name);
>>
>> which could be amended with " due to conflict with ".
>
> Dunno.  I did what we do wrt conflicting cold/hot attributes.  But
> here's a patch with what you suggest (with some Extra Quotes).

That works for me, please let Joseph some time to comment.

The "%qE attribute conflicts with attribute %s" way leaves me out in
the dark on what attribute will be in effect for the decl - it could be
either or none as far as I read it.  Or even both, with unspecified
behavior.

Richard.

> 2014-03-20  Marek Polacek  
>
> PR c/18079
> c-family/
> * c-common.c (handle_noinline_attribute): Warn if the attribute
> conflicts with always_inline attribute.
> (handle_always_inline_attribute): Warn if the attribute conflicts
> with noinline attribute.
> testsuite/
> * gcc.dg/pr18079.c: New test.
>
> diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c
> index abd96fb..5258e52 100644
> --- gcc/c-family/c-common.c
> +++ gcc/c-family/c-common.c
> @@ -,7 +,16 @@ handle_noinline_attribute (tree *node, tree name,
>int ARG_UNUSED (flags), bool *no_add_attrs)
>  {
>if (TREE_CODE (*node) == FUNCTION_DECL)
> -DECL_UNINLINABLE (*node) = 1;
> +{
> +  if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node)))
> +   {
> + warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
> +  "with % attribute", name);
> + *no_add_attrs = true;
> +   }
> +  else
> +   DECL_UNINLINABLE (*node) = 1;
> +}
>else
>  {
>warning (OPT_Wattributes, "%qE attribute ignored", name);
> @@ -6704,9 +6713,16 @@ handle_always_inline_attribute (tree *node, tree name,
>  {
>if (TREE_CODE (*node) == FUNCTION_DECL)
>  {
> -  /* Set the attribute and mark it for disregarding inline
> -limits.  */
> -  DECL_DISREGARD_INLINE_LIMITS (*node) = 1;
> +  if (lookup_attribute ("noinline", DECL_ATTRIBUTES (*node)))
> +   {
> + warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
> +  "with % attribute", name);
> + *no_add_attrs = true;
> +   }
> +  else
> +   /* Set the attribute and mark it for disregarding inline
> +  limits.  */
> +   DECL_DISREGARD_INLINE_LIMITS (*node) = 1;
>  }
>else
>  {
> diff --git gcc/testsuite/gcc.dg/pr18079.c gcc/testsuite/gcc.dg/pr18079.c
> index e69de29..b84cdeb 100644
> --- gcc/testsuite/gcc.dg/pr18079.c
> +++ gcc/testsuite/gcc.dg/pr18079.c
> @@ -0,0 +1,33 @@
> +/* PR c/18079 */
> +/* { dg-do compile } */
> +/* { dg-options "-Wall" } */
> +
> +__attribute__ ((noinline))
> +__attribute__ ((always_inline))
> +int
> +fn1 (int r)
> +{ /* { dg-warning "attribute ignored due to conflict" } */
> +  return r & 4;
> +}
> +
> +__attribute__ ((noinline, always_inline))
> +int
> +fn2 (int r)
> +{ /* { dg-warning "attribute ignored due to conflict" } */
> +  return r & 4;
> +}
> +
> +__attribute__ ((always_inline))
> +__attribute__ ((noinline))
> +inline int
> +fn3 (int r)
> +{ /* { dg-warning "attribute ignored due to conflict" } */
> +  return r & 8;
> +}
> +
> +__attribute__ ((always_inline, noinline))
> +inline int
> +fn4 (int r)
> +{ /* { dg-warning "attribute ignored due to conflict" } */
> +  return r & 8;
> +}
>
> Marek


Re: [C PATCH] Warn if inline attributes conflict (PR c/18079)

2014-03-20 Thread Joseph S. Myers
On Thu, 20 Mar 2014, Marek Polacek wrote:

> Dunno.  I did what we do wrt conflicting cold/hot attributes.  But
> here's a patch with what you suggest (with some Extra Quotes).
> 
> 2014-03-20  Marek Polacek  
> 
>   PR c/18079
> c-family/
>   * c-common.c (handle_noinline_attribute): Warn if the attribute
>   conflicts with always_inline attribute.
>   (handle_always_inline_attribute): Warn if the attribute conflicts
>   with noinline attribute.
> testsuite/
>   * gcc.dg/pr18079.c: New test.

This version is OK (for after 4.9 branches).

What happens if there are two declarations of the function, one with each 
attribute?  The testcase doesn't cover that.

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


[PATCH] Don't bootstrap libsanitizer or libvtv unless needed

2014-03-20 Thread Jakub Jelinek
Hi!

We currently bootstrap both libsanitizer and libvtv, the former
just in case somebody decides to --with-build-config=bootstrap-asan
(or --with-build-config=bootstrap-ubsan), the latter if somebody decides
to --enable-vtable-verify.

This patch changes it so that we only bootstrap libsanitizer if
bootstrap-asan or bootstrap-ubsan is in BOOT_CONFIG, and only bootstrap
libvtv if --enable-vtable-verify.

Bootstrapped/regtested on x86_64-linux and i686-linux, on x86_64 it
saved a few minutes of build time, neither libsanitizer nor libvtv
has been bootstrapped, only built in stage3.
Currently also bootstrapping on i686-linux with
--enable-vtable-verify --with-build-config=bootstrap-asan
but already got into stage2 and verified that both libsanitizer and libvtv
are being bootstrapped in that case.

Ok for trunk?

2014-03-20  Jakub Jelinek  

* configure.ac: Move BUILD_CONFIG set up earlier.  Add
--enable-vtable-verify option parsing.  Don't add
target-libsanitizer to bootstrap_target_libs unless
--with-build-config=bootstrap-asan or
--with-build-config=bootstrap-ubsan.  Don't add target-libvtv
to bootstrap_target_libs unless --enable-vtable-verify.
* configure: Regenerated.

--- configure.ac.jj 2014-03-03 08:24:36.0 +0100
+++ configure.ac2014-03-20 09:47:17.676017039 +0100
@@ -2472,6 +2472,62 @@ else
   GCC_SHLIB_SUBDIR=
 fi
 
+# Adjust the toplevel makefile according to whether bootstrap was selected.
+case $enable_bootstrap in
+  yes)
+bootstrap_suffix=bootstrap
+BUILD_CONFIG=bootstrap-debug
+;;
+  no)
+bootstrap_suffix=no-bootstrap
+BUILD_CONFIG=
+;;
+esac
+
+AC_MSG_CHECKING(for default BUILD_CONFIG)
+
+AC_ARG_WITH([build-config],
+  [AS_HELP_STRING([--with-build-config='NAME NAME2...'],
+ [use config/NAME.mk build configuration])],
+  [case $with_build_config in
+   yes) with_build_config= ;;
+   no) with_build_config= BUILD_CONFIG= ;;
+   esac])
+
+if test "x${with_build_config}" != x; then
+  BUILD_CONFIG=$with_build_config
+else
+  case $BUILD_CONFIG in
+  bootstrap-debug)
+if echo "int f (void) { return 0; }" > conftest.c &&
+   ${CC} -c conftest.c &&
+   mv conftest.o conftest.o.g0 &&
+   ${CC} -c -g conftest.c &&
+   mv conftest.o conftest.o.g &&
+   ${srcdir}/contrib/compare-debug conftest.o.g0 conftest.o.g > /dev/null 
2>&1; then
+  :
+else
+  BUILD_CONFIG=
+fi
+rm -f conftest.c conftest.o conftest.o.g0 conftest.o.g
+;;
+  esac
+fi
+AC_MSG_RESULT($BUILD_CONFIG)
+AC_SUBST(BUILD_CONFIG)
+
+# Use same top-level configure hooks in libgcc/libstdc++/libvtv.
+AC_MSG_CHECKING([for --enable-vtable-verify])
+AC_ARG_ENABLE(vtable-verify,
+[  --enable-vtable-verifyEnable vtable verification feature ],
+[case "$enableval" in
+ yes) enable_vtable_verify=yes ;;
+ no)  enable_vtable_verify=no ;;
+ *)   enable_vtable_verify=no;;
+ esac],
+[enable_vtable_verify=no])
+AC_MSG_RESULT($enable_vtable_verify)
+
 # Record target_configdirs and the configure arguments for target and
 # build configuration in Makefile.
 target_configdirs=`echo "${target_configdirs}" | sed -e 's/target-//g'`
@@ -2482,13 +2538,19 @@ if echo " ${target_configdirs} " | grep
   bootstrap_target_libs=${bootstrap_target_libs}target-libgomp,
 fi
 
-# If we are building libsanitizer, bootstrap it.
-if echo " ${target_configdirs} " | grep " libsanitizer " > /dev/null 2>&1 ; 
then
-  bootstrap_target_libs=${bootstrap_target_libs}target-libsanitizer,
+# If we are building libsanitizer and $BUILD_CONFIG contains bootstrap-asan
+# or bootstrap-ubsan, bootstrap it.
+if echo " ${target_configdirs} " | grep " libsanitizer " > /dev/null 2>&1; then
+  case "$BUILD_CONFIG" in
+*bootstrap-asan* | *bootstrap-ubsan* )
+  bootstrap_target_libs=${bootstrap_target_libs}target-libsanitizer,
+  ;;
+  esac
 fi
 
-# If we are building libvtv, bootstrap it.
-if echo " ${target_configdirs} " | grep " libvtv " > /dev/null 2>&1 ; then
+# If we are building libvtv and --enable-vtable-verify, bootstrap it.
+if echo " ${target_configdirs} " | grep " libvtv " > /dev/null 2>&1 &&
+   test "$enable_vtable_verify" != no; then
   bootstrap_target_libs=${bootstrap_target_libs}target-libvtv,
 fi
 
@@ -2541,50 +2603,6 @@ case "$enable_bootstrap:$ENABLE_GOLD: $c
 ;;
 esac
 
-# Adjust the toplevel makefile according to whether bootstrap was selected.
-case $enable_bootstrap in
-  yes)
-bootstrap_suffix=bootstrap
-BUILD_CONFIG=bootstrap-debug
-;;
-  no)
-bootstrap_suffix=no-bootstrap
-BUILD_CONFIG=
-;;
-esac
-
-AC_MSG_CHECKING(for default BUILD_CONFIG)
-
-AC_ARG_WITH([build-config],
-  [AS_HELP_STRING([--with-build-config='NAME NAME2...'],
- [use config/NAME.mk build configuration])],
-  [case $with_build_config in
-   yes) with_build_config= ;;
-   no) with_build_config= BUILD_CONFIG= ;;
-   esac])
-
-if test "x${with_build_config}" != x; then
-  BUILD_CONFIG=$with_

Re: [PATCH] Don't bootstrap libsanitizer or libvtv unless needed

2014-03-20 Thread Richard Biener
On Thu, 20 Mar 2014, Jakub Jelinek wrote:

> Hi!
> 
> We currently bootstrap both libsanitizer and libvtv, the former
> just in case somebody decides to --with-build-config=bootstrap-asan
> (or --with-build-config=bootstrap-ubsan), the latter if somebody decides
> to --enable-vtable-verify.
> 
> This patch changes it so that we only bootstrap libsanitizer if
> bootstrap-asan or bootstrap-ubsan is in BOOT_CONFIG, and only bootstrap
> libvtv if --enable-vtable-verify.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, on x86_64 it
> saved a few minutes of build time, neither libsanitizer nor libvtv
> has been bootstrapped, only built in stage3.
> Currently also bootstrapping on i686-linux with
> --enable-vtable-verify --with-build-config=bootstrap-asan
> but already got into stage2 and verified that both libsanitizer and libvtv
> are being bootstrapped in that case.
> 
> Ok for trunk?

Fine with me though I'd like to see the build of libvtv disabled
alltogether if not --enable-vtable-verify as the build/install is
quite useless without building the startfiles referenced at link-time
when doing -fvtable-verify=XY (Caroline also thinks that not
instrumenting libstdc++ will make most use-cases fail).

Easy to do as followup though.

Thanks,
Richard.

> 2014-03-20  Jakub Jelinek  
> 
>   * configure.ac: Move BUILD_CONFIG set up earlier.  Add
>   --enable-vtable-verify option parsing.  Don't add
>   target-libsanitizer to bootstrap_target_libs unless
>   --with-build-config=bootstrap-asan or
>   --with-build-config=bootstrap-ubsan.  Don't add target-libvtv
>   to bootstrap_target_libs unless --enable-vtable-verify.
>   * configure: Regenerated.
> 
> --- configure.ac.jj   2014-03-03 08:24:36.0 +0100
> +++ configure.ac  2014-03-20 09:47:17.676017039 +0100
> @@ -2472,6 +2472,62 @@ else
>GCC_SHLIB_SUBDIR=
>  fi
>  
> +# Adjust the toplevel makefile according to whether bootstrap was selected.
> +case $enable_bootstrap in
> +  yes)
> +bootstrap_suffix=bootstrap
> +BUILD_CONFIG=bootstrap-debug
> +;;
> +  no)
> +bootstrap_suffix=no-bootstrap
> +BUILD_CONFIG=
> +;;
> +esac
> +
> +AC_MSG_CHECKING(for default BUILD_CONFIG)
> +
> +AC_ARG_WITH([build-config],
> +  [AS_HELP_STRING([--with-build-config='NAME NAME2...'],
> +   [use config/NAME.mk build configuration])],
> +  [case $with_build_config in
> +   yes) with_build_config= ;;
> +   no) with_build_config= BUILD_CONFIG= ;;
> +   esac])
> +
> +if test "x${with_build_config}" != x; then
> +  BUILD_CONFIG=$with_build_config
> +else
> +  case $BUILD_CONFIG in
> +  bootstrap-debug)
> +if echo "int f (void) { return 0; }" > conftest.c &&
> +   ${CC} -c conftest.c &&
> +   mv conftest.o conftest.o.g0 &&
> +   ${CC} -c -g conftest.c &&
> +   mv conftest.o conftest.o.g &&
> +   ${srcdir}/contrib/compare-debug conftest.o.g0 conftest.o.g > 
> /dev/null 2>&1; then
> +  :
> +else
> +  BUILD_CONFIG=
> +fi
> +rm -f conftest.c conftest.o conftest.o.g0 conftest.o.g
> +;;
> +  esac
> +fi
> +AC_MSG_RESULT($BUILD_CONFIG)
> +AC_SUBST(BUILD_CONFIG)
> +
> +# Use same top-level configure hooks in libgcc/libstdc++/libvtv.
> +AC_MSG_CHECKING([for --enable-vtable-verify])
> +AC_ARG_ENABLE(vtable-verify,
> +[  --enable-vtable-verifyEnable vtable verification feature ],
> +[case "$enableval" in
> + yes) enable_vtable_verify=yes ;;
> + no)  enable_vtable_verify=no ;;
> + *)   enable_vtable_verify=no;;
> + esac],
> +[enable_vtable_verify=no])
> +AC_MSG_RESULT($enable_vtable_verify)
> +
>  # Record target_configdirs and the configure arguments for target and
>  # build configuration in Makefile.
>  target_configdirs=`echo "${target_configdirs}" | sed -e 's/target-//g'`
> @@ -2482,13 +2538,19 @@ if echo " ${target_configdirs} " | grep
>bootstrap_target_libs=${bootstrap_target_libs}target-libgomp,
>  fi
>  
> -# If we are building libsanitizer, bootstrap it.
> -if echo " ${target_configdirs} " | grep " libsanitizer " > /dev/null 2>&1 ; 
> then
> -  bootstrap_target_libs=${bootstrap_target_libs}target-libsanitizer,
> +# If we are building libsanitizer and $BUILD_CONFIG contains bootstrap-asan
> +# or bootstrap-ubsan, bootstrap it.
> +if echo " ${target_configdirs} " | grep " libsanitizer " > /dev/null 2>&1; 
> then
> +  case "$BUILD_CONFIG" in
> +*bootstrap-asan* | *bootstrap-ubsan* )
> +  bootstrap_target_libs=${bootstrap_target_libs}target-libsanitizer,
> +  ;;
> +  esac
>  fi
>  
> -# If we are building libvtv, bootstrap it.
> -if echo " ${target_configdirs} " | grep " libvtv " > /dev/null 2>&1 ; then
> +# If we are building libvtv and --enable-vtable-verify, bootstrap it.
> +if echo " ${target_configdirs} " | grep " libvtv " > /dev/null 2>&1 &&
> +   test "$enable_vtable_verify" != no; then
>bootstrap_target_libs=${bootstrap_target_libs}target-libvtv,
>  fi
>  
> @@ -2541,50 +2603,6 @@ case "$enable_bootstrap:$ENABLE_GOLD: $c
>  ;;
>  esac

Re: [AArch64] VDUP Testcases

2014-03-20 Thread Marcus Shawcroft
On 14 March 2014 16:22, Alex Velenko  wrote:
> Hi,
> This patch adds vdup intrinsic testcases for AArch64. those testcases
> are nice to have, as it allows to reason about vdup consistency for
> both LE and BE compiler flavors.

> gcc/testsuite/
>
> 2014-03-14  Alex Velenko  
>
> * gcc.target/aarch64/vdup_lane_1.c: New testcase.
> * gcc.target/aarch64/vdup_lane_2.c: New testcase.
> * gcc.target/aarch64/vdup_n_1.c: New testcase.

This is OK for stage-1.
/Marcus


Re: [PATCH] [gomp4] Initial support of OpenACC loop directive in C front-end.

2014-03-20 Thread Ilmir Usmanov

Hi Thomas!

On 20.03.2014 14:21, Thomas Schwinge wrote:


I just realized that this is wrong usage of the dg-excess-errors
directive, for this one will absorb *all* remaining errors, whereas you
just wanted to mask out any »sorry, unimplemented: directive not yet
implemented« ones.

Sorry for that. Next time I will more precise.


OK to fix as follows?

Sure. Thanks!

--
Ilmir.


Re: [PATCH 4/4] [GOMP4] [Fortran] OpenACC 1.0+ support in fortran front-end

2014-03-20 Thread Ilmir Usmanov

Hi Thomas!

On 20.03.2014 14:22, Thomas Schwinge wrote:


As in
,
this is wrong usage of the dg-excess-errors directive, for this one will
absorb *all* remaining errors, whereas you just wanted to mask out any
»sorry, unimplemented: [...]« ones.

OK to fix as follows?


Sure. Thanks!

--
Ilmir.


Re: [4.8, PATCH 0/26] Backport Power8 and LE support

2014-03-20 Thread Ulrich Weigand
Alan Modra wrote:
> On Wed, Mar 19, 2014 at 03:35:59PM -0600, Jeff Law wrote:
> > On 03/19/14 15:03, Bill Schmidt wrote:
> > >The three pieces that are somewhat controversial for non-powerpc targets
> > >are 9/26, 10/26, 15/26.
> > >
> > >  * Uli and Alan, can you speak to any concerns for 9/26?
> > I've got no concerns about 9/26.  Uli, Alan and myself worked
> > through this pretty thoroughly.  I've had those in the back of my
> > mind as something we're going to want to make sure to pull in.
> 
> Thanks Jeff.  I don't have any concern over 9/26, it's quite
> conservative like most of the ELFv2 implementation.  When we were
> looking at parameter passing changes we didn't go as far as we could.
> For example, we still pass fp to varargs functions in both fp regs and
> on the stack, when only the stack will be used by a callee correctly
> implementing either ELFv2 or ELFv1 ABIs.  Another thing that we didn't
> change is that sibcalls can be allowed in more cases than the current
> code allows.

I concur with Jeff and Alan that 9/26 should be safe.

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  ulrich.weig...@de.ibm.com



Re: [AArch64] Logical vector shift right conformance

2014-03-20 Thread Marcus Shawcroft
On 25 February 2014 11:58, Alex Velenko  wrote:
> Hi,
>
> This patch fixes a bug in vshr_n_u64 and vshrd_n_u64 intrinsic
> behavior in case of shift by 64. Shift by 64 is strictly defined in ACLE to
> use ushr instruction intended by those intrinsics.
>
> The testcase provided also tests the behavior for intrinsics mentioned
> above with values other then 64. Besides, the test checks that an illeagal
> ushr shift by 0 is not generated, expecting the test to compile and run
> correctly generating instructions other than ushr.
>
> The patch was tested for LE and BE with no regressions.
>
> Is given patch ok for stage-4?

I think this is OK for stage-4, but leave 24h before committing to
allow the RM's opportunity to object / comment.

Cheers
/Marcus


Re: [gomp4 9/9] OpenACC: Basic support for #pragma acc parallel.

2014-03-20 Thread Thomas Schwinge
Hi!

On Wed, 6 Nov 2013 20:53:00 +0100, I wrote:
> --- /dev/null
> +++ gcc/testsuite/c-c++-common/goacc/parallel-1.c
> @@ -0,0 +1,6 @@
> +void
> +foo (void)
> +{
> +#pragma acc parallel
> +  foo ();
> +}

Applied in r208699 on gomp-4_0-branch:

commit 4a854d643b300adc0b79ad5dadd132aa1cdd535a
Author: tschwinge 
Date:   Thu Mar 20 14:22:41 2014 +

Fix OpenACC parallel testcase to avoid nonsensical recursion.

gcc/testsuite/
* c-c++-common/goacc/parallel-1.c: Don't recurse.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@208699 
138bc75d-0d04-0410-961f-82ee72b054a4

diff --git gcc/testsuite/ChangeLog.gomp gcc/testsuite/ChangeLog.gomp
index 1f4d704..81876ec 100644
--- gcc/testsuite/ChangeLog.gomp
+++ gcc/testsuite/ChangeLog.gomp
@@ -1,5 +1,7 @@
 2014-03-20  Thomas Schwinge  
 
+   * c-c++-common/goacc/parallel-1.c: Don't recurse.
+
* gfortran.dg/goacc/cache-1.f95: Replace dg-excess-errors usage
with dg-prune-output.
* gfortran.dg/goacc/coarray.f95: Likewise.
diff --git gcc/testsuite/c-c++-common/goacc/parallel-1.c 
gcc/testsuite/c-c++-common/goacc/parallel-1.c
index cd19527..a860526 100644
--- gcc/testsuite/c-c++-common/goacc/parallel-1.c
+++ gcc/testsuite/c-c++-common/goacc/parallel-1.c
@@ -2,5 +2,5 @@ void
 foo (void)
 {
 #pragma acc parallel
-  foo ();
+  ;
 }


Grüße,
 Thomas


pgpPmdme5k3IR.pgp
Description: PGP signature


Re: [gomp4 2/2] Initial support for the OpenACC kernels construct in the C front end.

2014-03-20 Thread Thomas Schwinge
Hi!

On Fri, 28 Feb 2014 10:23:01 +0100, I wrote:
> diff --git gcc/testsuite/c-c++-common/goacc/nesting-fail-1.c 
> gcc/testsuite/c-c++-common/goacc/nesting-fail-1.c
> index 24a4c11..d88ee8a 100644
> --- gcc/testsuite/c-c++-common/goacc/nesting-fail-1.c
> +++ gcc/testsuite/c-c++-common/goacc/nesting-fail-1.c

> +/* TODO: While the OpenACC specification does allow for certain kinds of
> +   nesting, we don't support that yet.  */
> +void
> +f_acc_kernels (void)
> +{
> +#pragma acc parallel
> +  {
> +#pragma acc parallel /* { dg-error "may not be nested" } */
> +;
> +#pragma acc kernels  /* { dg-error "may not be nested" } */
> +;
>  #pragma acc data /* { dg-error "may not be nested" } */
>  ;
>}

Applied in r208700 to gomp-4_0-branch:

commit 82e6bd6f0623d40a7653cf1ca61d14726cbe398f
Author: tschwinge 
Date:   Thu Mar 20 14:25:47 2014 +

Fix test to actually test for nesting inside of OpenACC kernels construct.

gcc/testsuite/
* c-c++-common/goacc/nesting-fail-1.c (f_acc_kernels): Replace
OpenACC parallel with kernels directive.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@208700 
138bc75d-0d04-0410-961f-82ee72b054a4

diff --git gcc/testsuite/ChangeLog.gomp gcc/testsuite/ChangeLog.gomp
index 81876ec..fd38d80 100644
--- gcc/testsuite/ChangeLog.gomp
+++ gcc/testsuite/ChangeLog.gomp
@@ -1,5 +1,8 @@
 2014-03-20  Thomas Schwinge  
 
+   * c-c++-common/goacc/nesting-fail-1.c (f_acc_kernels): Replace
+   OpenACC parallel with kernels directive.
+
* c-c++-common/goacc/parallel-1.c: Don't recurse.
 
* gfortran.dg/goacc/cache-1.f95: Replace dg-excess-errors usage
diff --git gcc/testsuite/c-c++-common/goacc/nesting-fail-1.c 
gcc/testsuite/c-c++-common/goacc/nesting-fail-1.c
index d88ee8a..ca8921f 100644
--- gcc/testsuite/c-c++-common/goacc/nesting-fail-1.c
+++ gcc/testsuite/c-c++-common/goacc/nesting-fail-1.c
@@ -19,7 +19,7 @@ f_acc_parallel (void)
 void
 f_acc_kernels (void)
 {
-#pragma acc parallel
+#pragma acc kernels
   {
 #pragma acc parallel   /* { dg-error "may not be nested" } */
 ;


Grüße,
 Thomas


pgpwPI4VSO4jZ.pgp
Description: PGP signature


[gomp4] Nesting of OpenACC constructs inside of OpenACC data constructs (was: [gomp4 2/3] OpenACC data construct implementation in terms of GF_OMP_TARGET_KIND_OACC_DATA.)

2014-03-20 Thread Thomas Schwinge
Hi!

Applied in r208701 to gomp-4_0-branch:

commit 22dd36a31c433dcd8bcc890d245a9e4ac6ed9c7f
Author: tschwinge 
Date:   Thu Mar 20 14:33:28 2014 +

Nesting of OpenACC constructs inside of OpenACC data constructs.

gcc/
* omp-low.c (check_omp_nesting_restrictions): Allow nesting of
OpenACC constructs inside of OpenACC data constructs.
gcc/testsuite/
* c-c++-common/goacc/nesting-1.c: New file.
* c-c++-common/goacc/nesting-data-1.c: Likewise.
* c-c++-common/goacc/nesting-fail-1.c: Update.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@208701 
138bc75d-0d04-0410-961f-82ee72b054a4

diff --git gcc/ChangeLog.gomp gcc/ChangeLog.gomp
index 1aebc4d..f43452c 100644
--- gcc/ChangeLog.gomp
+++ gcc/ChangeLog.gomp
@@ -1,3 +1,8 @@
+2014-03-20  Thomas Schwinge  
+
+   * omp-low.c (check_omp_nesting_restrictions): Allow nesting of
+   OpenACC constructs inside of OpenACC data constructs.
+
 2014-03-18  Ilmir Usmanov  
 
* tree.def (OACC_LOOP): New tree code.
diff --git gcc/omp-low.c gcc/omp-low.c
index f1b0fa5..23a0dda 100644
--- gcc/omp-low.c
+++ gcc/omp-low.c
@@ -2416,26 +2416,31 @@ scan_omp_teams (gimple stmt, omp_context *outer_ctx)
 static bool
 check_omp_nesting_restrictions (gimple stmt, omp_context *ctx)
 {
-  omp_context *ctx_;
-
   /* TODO: While the OpenACC specification does allow for certain kinds of
- nesting, we don't support that yet.  */
-  /* No nesting of STMT (which is an OpenACC or OpenMP one, or a GOMP builtin)
- inside any OpenACC CTX.  */
-  for (ctx_ = ctx; ctx_ != NULL; ctx_ = ctx_->outer)
-if (is_gimple_omp (ctx_->stmt)
-   && is_gimple_omp_oacc_specifically (ctx_->stmt))
-  {
-   error_at (gimple_location (stmt),
- "may not be nested");
-   return false;
-  }
-  /* No nesting of OpenACC STMT inside any OpenACC or OpenMP CTX.  */
+ nesting, we don't support many of these yet.  */
   if (is_gimple_omp (stmt)
   && is_gimple_omp_oacc_specifically (stmt))
 {
-  for (ctx_ = ctx; ctx_ != NULL; ctx_ = ctx_->outer)
-   if (is_gimple_omp (ctx_->stmt))
+  /* No nesting of OpenACC STMT inside any OpenACC or OpenMP CTX different
+from an OpenACC data construct.  */
+  for (omp_context *ctx_ = ctx; ctx_ != NULL; ctx_ = ctx_->outer)
+   if (is_gimple_omp (ctx_->stmt)
+   && !(gimple_code (ctx_->stmt) == GIMPLE_OMP_TARGET
+&& (gimple_omp_target_kind (ctx_->stmt)
+== GF_OMP_TARGET_KIND_OACC_DATA)))
+ {
+   error_at (gimple_location (stmt),
+ "may not be nested");
+   return false;
+ }
+}
+  else
+{
+  /* No nesting of non-OpenACC STMT (that is, an OpenMP one, or a GOMP
+builtin) inside any OpenACC CTX.  */
+  for (omp_context *ctx_ = ctx; ctx_ != NULL; ctx_ = ctx_->outer)
+   if (is_gimple_omp (ctx_->stmt)
+   && is_gimple_omp_oacc_specifically (ctx_->stmt))
  {
error_at (gimple_location (stmt),
  "may not be nested");
diff --git gcc/testsuite/ChangeLog.gomp gcc/testsuite/ChangeLog.gomp
index fd38d80..13e99d5 100644
--- gcc/testsuite/ChangeLog.gomp
+++ gcc/testsuite/ChangeLog.gomp
@@ -1,5 +1,9 @@
 2014-03-20  Thomas Schwinge  
 
+   * c-c++-common/goacc/nesting-1.c: New file.
+   * c-c++-common/goacc/nesting-data-1.c: Likewise.
+   * c-c++-common/goacc/nesting-fail-1.c: Update.
+
* c-c++-common/goacc/nesting-fail-1.c (f_acc_kernels): Replace
OpenACC parallel with kernels directive.
 
diff --git gcc/testsuite/c-c++-common/goacc/nesting-1.c 
gcc/testsuite/c-c++-common/goacc/nesting-1.c
new file mode 100644
index 000..3a22292
--- /dev/null
+++ gcc/testsuite/c-c++-common/goacc/nesting-1.c
@@ -0,0 +1,13 @@
+void
+f_acc_data (void)
+{
+#pragma acc data
+  {
+#pragma acc parallel
+;
+#pragma acc kernels
+;
+#pragma acc data
+;
+  }
+}
diff --git gcc/testsuite/c-c++-common/goacc/nesting-data-1.c 
gcc/testsuite/c-c++-common/goacc/nesting-data-1.c
new file mode 100644
index 000..fefe6cd
--- /dev/null
+++ gcc/testsuite/c-c++-common/goacc/nesting-data-1.c
@@ -0,0 +1,61 @@
+void
+f (void)
+{
+  unsigned char c, ca[15], caa[20][30];
+
+#pragma acc data copyin(c)
+  {
+c = 5;
+ca[3] = c;
+caa[3][12] = ca[3] + caa[3][12];
+
+#pragma acc data copyin(ca[2:4])
+{
+  c = 6;
+  ca[4] = c;
+  caa[3][12] = ca[3] + caa[3][12];
+}
+
+#pragma acc parallel copyout(ca[3:4])
+{
+  c = 7;
+  ca[5] = c;
+  caa[3][12] = ca[3] + caa[3][12];
+}
+
+#pragma acc kernels copy(ca[4:4])
+{
+  c = 8;
+  ca[6] = c;
+  caa[3][12] = ca[3] + caa[3][12];
+}
+
+#pragma acc data pcopy(ca[5:7])
+{
+  c = 15;
+  ca[7] = c;
+  caa[3][12] = ca[3] + caa[3][12];
+
+#pragma acc data pcopyin(caa[3:7][0:30])
+  {
+   c = 16;
+   ca[8] = c;
+   caa[3][12

Re: [PATCH 4/4] [GOMP4] [Fortran] OpenACC 1.0+ support in fortran front-end

2014-03-20 Thread Jakub Jelinek
On Thu, Mar 20, 2014 at 11:22:59AM +0100, Thomas Schwinge wrote:
> > --- /dev/null
> > +++ b/gcc/testsuite/gfortran.dg/goacc/coarray.f95
> > @@ -0,0 +1,35 @@
> > +! { dg-do compile } 
> 
> > +! { dg-excess-errors "Unimplemented" }
> > +! { dg-excess-errors "ACC LOOP" }
> > \ No newline at end of file

Note, in any case, please avoid files without trailing newline unless
strictly necessary (primarily, testing that compiler handles those).

Jakub


Re: [C PATCH] Warn if inline attributes conflict (PR c/18079)

2014-03-20 Thread Marek Polacek
On Thu, Mar 20, 2014 at 11:57:57AM +, Joseph S. Myers wrote:
> This version is OK (for after 4.9 branches).

Thanks.
 
> What happens if there are two declarations of the function, one with each 
> attribute?  The testcase doesn't cover that.

Nothing :(.  I had to add some code into diagnose_mismatched_decls to
detect such conflicting decls (plus for cold/hot; there may be others).

Tested x86_64-linux.  Is this version ok?

2014-03-20  Marek Polacek  

PR c/18079
c/
* c-decl.c (diagnose_mismatched_decls): Warn for mismatched
always_inline/noinline and hot/cold attributes.
c-family/
* c-common.c (handle_noinline_attribute): Warn if the attribute
conflicts with always_inline attribute.
(handle_always_inline_attribute): Warn if the attribute conflicts
with noinline attribute.
testsuite/
* gcc.dg/pr18079.c: New test.
* gcc.dg/pr18079-2.c: New test.

diff --git gcc/c-family/c-common.c gcc/c-family/c-common.c
index abd96fb..5258e52 100644
--- gcc/c-family/c-common.c
+++ gcc/c-family/c-common.c
@@ -,7 +,16 @@ handle_noinline_attribute (tree *node, tree name,
   int ARG_UNUSED (flags), bool *no_add_attrs)
 {
   if (TREE_CODE (*node) == FUNCTION_DECL)
-DECL_UNINLINABLE (*node) = 1;
+{
+  if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (*node)))
+   {
+ warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
+  "with % attribute", name);
+ *no_add_attrs = true;
+   }
+  else
+   DECL_UNINLINABLE (*node) = 1;
+}
   else
 {
   warning (OPT_Wattributes, "%qE attribute ignored", name);
@@ -6704,9 +6713,16 @@ handle_always_inline_attribute (tree *node, tree name,
 {
   if (TREE_CODE (*node) == FUNCTION_DECL)
 {
-  /* Set the attribute and mark it for disregarding inline
-limits.  */
-  DECL_DISREGARD_INLINE_LIMITS (*node) = 1;
+  if (lookup_attribute ("noinline", DECL_ATTRIBUTES (*node)))
+   {
+ warning (OPT_Wattributes, "%qE attribute ignored due to conflict "
+  "with % attribute", name);
+ *no_add_attrs = true;
+   }
+  else
+   /* Set the attribute and mark it for disregarding inline
+  limits.  */
+   DECL_DISREGARD_INLINE_LIMITS (*node) = 1;
 }
   else
 {
diff --git gcc/c/c-decl.c gcc/c/c-decl.c
index 2c41bf2..f96cc5e 100644
--- gcc/c/c-decl.c
+++ gcc/c/c-decl.c
@@ -2099,18 +2099,36 @@ diagnose_mismatched_decls (tree newdecl, tree olddecl,
   /* Diagnose inline __attribute__ ((noinline)) which is silly.  */
   if (DECL_DECLARED_INLINE_P (newdecl)
  && lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl)))
-   {
- warned |= warning (OPT_Wattributes,
-"inline declaration of %qD follows "
-"declaration with attribute noinline", newdecl);
-   }
+   warned |= warning (OPT_Wattributes,
+  "inline declaration of %qD follows "
+  "declaration with attribute noinline", newdecl);
   else if (DECL_DECLARED_INLINE_P (olddecl)
   && lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl)))
-   {
- warned |= warning (OPT_Wattributes,
-"declaration of %q+D with attribute "
-"noinline follows inline declaration ", newdecl);
-   }
+   warned |= warning (OPT_Wattributes,
+  "declaration of %q+D with attribute "
+  "noinline follows inline declaration ", newdecl);
+  else if (lookup_attribute ("noinline", DECL_ATTRIBUTES (newdecl))
+  && lookup_attribute ("always_inline", DECL_ATTRIBUTES (olddecl)))
+   warned |= warning (OPT_Wattributes,
+  "declaration of %q+D with attribute "
+  "noinline follows declaration with attribute "
+  "always_inline", newdecl);
+  else if (lookup_attribute ("always_inline", DECL_ATTRIBUTES (newdecl))
+  && lookup_attribute ("noinline", DECL_ATTRIBUTES (olddecl)))
+   warned |= warning (OPT_Wattributes,
+  "declaration of %q+D with attribute "
+  "always_inline follows declaration with attribute "
+  "noinline", newdecl);
+  else if (lookup_attribute ("cold", DECL_ATTRIBUTES (newdecl))
+  && lookup_attribute ("hot", DECL_ATTRIBUTES (olddecl)))
+   warned |= warning (OPT_Wattributes,
+  "declaration of %q+D with attribute cold follows "
+  "declaration with attribute hot", newdecl);
+  else if (lookup_attribute ("hot", DECL_ATTRIBUTES (newdecl))
+  && lookup_attribute ("cold", DECL_ATTRIBUTES (olddecl)))
+   warned |= warning (OPT_Wattributes,
+  "dec

Re: [PATCH] [gomp4] Initial support of OpenACC loop directive in C front-end.

2014-03-20 Thread Jakub Jelinek
On Thu, Mar 20, 2014 at 03:42:48PM +0100, Thomas Schwinge wrote:
> Here are the patches, committed in r208702..4 to gomp-4_0-branch.  Jakub,
> are the first two fine for trunk, or shall I wait until stage 1?

Stage1 IMHO.

Jakub


[RFA jit] initialize input_location

2014-03-20 Thread Tom Tromey
This patch initializes input_location at the same spot where the line
table is initialized.  Without this, it's possible to crash when
emitting a diagnostic in a reinvocation of the compiler, because
input_location refers to a location that is no longer valid.
---
 gcc/ChangeLog.jit | 4 
 gcc/toplev.c  | 1 +
 2 files changed, 5 insertions(+)

diff --git a/gcc/ChangeLog.jit b/gcc/ChangeLog.jit
index ee1df88..a9b0817 100644
--- a/gcc/ChangeLog.jit
+++ b/gcc/ChangeLog.jit
@@ -1,5 +1,9 @@
 2014-03-19  Tom Tromey  
 
+   * toplev.c (general_init): Initialize input_location.
+
+2014-03-19  Tom Tromey  
+
* timevar.h (auto_timevar): New class.
 
 2014-03-19  Tom Tromey  
diff --git a/gcc/toplev.c b/gcc/toplev.c
index b257ab2..1febc2e 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1161,6 +1161,7 @@ general_init (const char *argv0)
  table.  */
   init_ggc ();
   init_stringpool ();
+  input_location = 0;
   line_table = ggc_alloc_line_maps ();
   linemap_init (line_table);
   line_table->reallocator = realloc_for_line_map;
-- 
1.8.5.3



Re: [PATCH] [gomp4] Initial support of OpenACC loop directive in C front-end.

2014-03-20 Thread Jakub Jelinek
On Thu, Mar 20, 2014 at 10:27:20AM +0100, Tobias Burnus wrote:
> > 3) GCC OpenMP implementation supports loop construct without parallel.

It is not about GCC OpenMP implementation, it is the standard that requires
it.  If you have an orphaned #pragma omp for e.g., you still can call the
containing function from inside of #pragma omp parallel and then it should
be properly distributed across the threads.  Of course with OpenMP you
can enter orphaned #pragma omp for even from outside of parallel region,
but that in OpenMP terms is essentially just a degenerated parallel with a
single thread only, so you have to distribute it across the single thread.
Same thing as if you do
#pragma omp parallel num_threads(1) (or if(0))
{
...
  #pragma omp for
}

Jakub


Re: [C PATCH] Warn if inline attributes conflict (PR c/18079)

2014-03-20 Thread Joseph S. Myers
On Thu, 20 Mar 2014, Marek Polacek wrote:

> On Thu, Mar 20, 2014 at 11:57:57AM +, Joseph S. Myers wrote:
> > This version is OK (for after 4.9 branches).
> 
> Thanks.
>  
> > What happens if there are two declarations of the function, one with each 
> > attribute?  The testcase doesn't cover that.
> 
> Nothing :(.  I had to add some code into diagnose_mismatched_decls to
> detect such conflicting decls (plus for cold/hot; there may be others).
> 
> Tested x86_64-linux.  Is this version ok?

Yes.

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


libgcc/config.host: Fix v850-rtems bug

2014-03-20 Thread Joel Sherrill
Hi

It took a while to find this but v850-rtems lost the include
paths for the rtems specific .h files in newlib due to
the line that resets tmake_file rather than appends to it.

Is this OK to apply to all impacted branches and the head?

2014-03-20  Joel Sherrill  

* config.host (v850*-*-*): Add to tmake_file instead of resetting
it. This was removing the v850*-*-rtems* settings.

diff --git a/libgcc/config.host b/libgcc/config.host
index bdc725f..f8f74cc 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -1195,7 +1195,7 @@ tilepro*-*-linux*)
md_unwind_header=tilepro/linux-unwind.h
 ;;
 v850*-*-*)
-   tmake_file="v850/t-v850 t-fdpbit"
+   tmake_file="${tmake_file} v850/t-v850 t-fdpbit"
;;
 vax-*-linux*)
tmake_file="$tmake_file vax/t-linux"

-- 
Joel Sherrill, Ph.D. Director of Research & Development
joel.sherr...@oarcorp.comOn-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available(256) 722-9985



Re: libgcc/config.host: Fix v850-rtems bug

2014-03-20 Thread Rainer Orth
Hi Joel,

> It took a while to find this but v850-rtems lost the include
> paths for the rtems specific .h files in newlib due to
> the line that resets tmake_file rather than appends to it.
>
> Is this OK to apply to all impacted branches and the head?
>
> 2014-03-20  Joel Sherrill  
>
> * config.host (v850*-*-*): Add to tmake_file instead of resetting
> it. This was removing the v850*-*-rtems* settings.

Omit the `This was removing...' part: no explanations in ChangeLogs.

I believe this is your call as RTEMS maintainer, even this late in the
4.9 release cycle, since it cannot affect any other target.

Rainer

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


[PATCH, PR 59176] Mark "zombie" call graph nodes to remove verifier false positive

2014-03-20 Thread Martin Jambor
Hi,

in the PR, verifier claims an edge is pointing to a wrong declaration
even though it has successfully verified the edge multiple times
before.  The reason is that symtab_remove_unreachable_nodes decides to
"remove the body" of a node and also clear any information that it is
an alias of another in the process (more detailed analysis in comment
#9 of the bug).

In bugzilla Honza wrote that "silencing the verifier" is the way to
go.  Either we can dedicate a new flag in each cgraph_node or
symtab_node just for the purpose of verification or do something more
hackish like the patch below which re-uses the former_clone_of field
for this purpose.  Since clones are always private nodes, they should
always either survive removal of unreachable nodes or be completely
killed by it and should never enter the in_border zombie state.
Therefore their former_clone_of must always be NULL.  So I added a new
special value, error_mark_node, to mark this zombie state and taught
the verifier to be happy with such nodes.

Bootstrapped and tested on x86_64-linux.  What do you think?

Thanks,

Martin


2014-03-19  Martin Jambor  

PR ipa/59176
* ipa.c (symtab_remove_unreachable_nodes): Assert nodes in border
are not former clones.  Set their former_clone_of to
error_mark_node.
* cgraphclones.c (cgraph_materialize_clone): Do not copy
error_mark_node former_clone_of.
* cgraph.c (verify_edge_corresponds_to_fndecl): Ignore nodes with
error_mark_node former_clone_of.

testsuite/
* g++.dg/torture/pr59176.C: New test.

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index a15b6bc..3bf5ecd 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -1935,6 +1935,8 @@ dump_cgraph_node (FILE *f, struct cgraph_node *node)
 fprintf (f, "  Clone of %s/%i\n",
 node->clone_of->asm_name (),
 node->clone_of->order);
+  if (node->former_clone_of == error_mark_node)
+fprintf (f, "  Body removed by symtab_remove_unreachable_nodes\n");
   if (cgraph_function_flags_ready)
 fprintf (f, "  Availability: %s\n",
 cgraph_availability_names [cgraph_function_body_availability 
(node)]);
@@ -2602,7 +2604,10 @@ verify_edge_corresponds_to_fndecl (struct cgraph_edge 
*e, tree decl)
 
   /* We do not know if a node from a different partition is an alias or what it
  aliases and therefore cannot do the former_clone_of check reliably.  */
-  if (!node || node->in_other_partition || e->callee->in_other_partition)
+  if (!node
+  || node->former_clone_of == error_mark_node
+  || node->in_other_partition
+  || e->callee->in_other_partition)
 return false;
   node = cgraph_function_or_thunk_node (node, NULL);
 
diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index ca69033..ba08281 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -914,7 +914,8 @@ cgraph_materialize_clone (struct cgraph_node *node)
 {
   bitmap_obstack_initialize (NULL);
   node->former_clone_of = node->clone_of->decl;
-  if (node->clone_of->former_clone_of)
+  if (node->clone_of->former_clone_of
+  && node->clone_of->former_clone_of != error_mark_node)
 node->former_clone_of = node->clone_of->former_clone_of;
   /* Copy the OLD_VERSION_NODE function tree to the new version.  */
   tree_function_versioning (node->clone_of->decl, node->decl,
diff --git a/gcc/ipa.c b/gcc/ipa.c
index 572dba1..85c73ef 100644
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -484,6 +484,8 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, 
FILE *file)
{
  if (file)
fprintf (file, " %s", node->name ());
+ gcc_assert (!node->former_clone_of);
+ node->former_clone_of = error_mark_node;
  node->analyzed = false;
  node->definition = false;
  node->cpp_implicit_alias = false;
diff --git a/gcc/testsuite/g++.dg/ipa/pr59176.C 
b/gcc/testsuite/g++.dg/ipa/pr59176.C
new file mode 100644
index 000..d576bc3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr59176.C
@@ -0,0 +1,41 @@
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+template  class A {
+protected:
+  void m_fn2();
+  ~A() { m_fn2(); }
+  virtual void m_fn1();
+};
+
+class D : A {};
+template  void A::m_fn2() {
+  m_fn1();
+  m_fn1();
+  m_fn1();
+}
+
+#pragma interface
+class B {
+  D m_cellsAlreadyProcessed;
+  D m_cellsNotToProcess;
+
+public:
+  virtual ~B() {}
+  void m_fn1();
+};
+
+class C {
+  unsigned long m_fn1();
+  B m_fn2();
+  unsigned long m_fn3();
+};
+unsigned long C::m_fn1() {
+CellHierarchy:
+  m_fn2().m_fn1();
+}
+
+unsigned long C::m_fn3() {
+CellHierarchy:
+  m_fn2().m_fn1();
+}


[gomp4] Accelerator configury and paths changes 1/3

2014-03-20 Thread Bernd Schmidt
This adds the --enable-accelerator option.  This isn't too useful yet as 
there's no nvptx target so far, but it's part of the other changes to 
the configury that allows for offloading/accelerator targets.


Committed on gomp-4_0-branch.


Bernd
Index: ChangeLog
===
--- ChangeLog	(revision 208706)
+++ ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2014-03-20  Bernd Schmidt  
+
+	From Nathan Sidwell and Thomas Schwinge.
+	* configure.ac: Add --enable-accelerator.
+	* configure: Rebuilt.
+
 2014-03-04  Jonathan Wakely  
 
 	* MAINTAINERS: Update my email address.
Index: configure.ac
===
--- configure.ac	(revision 208706)
+++ configure.ac	(working copy)
@@ -286,6 +286,37 @@ case ${with_newlib} in
   yes) skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'` ;;
 esac
 
+# Handle --enable-accelerator.  This is in top-level because both libgomp and
+# GCC proper need this information.
+# --disable-accelerator
+#   Default.  Do not build accelerator pieces, only support host execution.
+# --enable-accelerator=auto-device-triplet
+#   If possible, build accelerator pieces for 'device-triplet'.
+# --enable-accelerator=device-triplet
+#   Build accelerator pieces for 'device-triplet'.
+AC_ARG_ENABLE(accelerator,
+[AS_HELP_STRING([[--enable-accelerator[=ARG]]],
+		[build accelerator @<:@ARG={no,auto-device-triplet,device-triplet}@:>@])],
+ENABLE_ACCELERATOR=$enableval,
+ENABLE_ACCELERATOR=no)
+accel_target_noncanonical=NONE
+case "${ENABLE_ACCELERATOR}" in
+  yes)
+AC_MSG_ERROR([--enable-accelerators must name accelerator])
+skipdirs="${skipdirs} accel-gcc"
+;;
+  no)
+skipdirs="${skipdirs} accel-gcc"
+;;
+  auto-nvptx*|nvptx*)
+accel_target_noncanonical=`echo "$ENABLE_ACCELERATOR" | sed -e s/auto-//g`
+;;
+  *)
+AC_MSG_ERROR([unrecognized accelerator])
+skipdirs="${skipdirs} accel-gcc"
+;;
+esac
+
 # Handle --enable-gold, --enable-ld.
 # --disable-gold [--enable-ld]
 # Build only ld.  Default option.
Index: configure
===
--- configure	(revision 208706)
+++ configure	(working copy)
@@ -744,6 +744,7 @@ ospace_frag'
 ac_user_opts='
 enable_option_checking
 with_build_libsubdir
+enable_accelerator
 enable_gold
 enable_ld
 enable_libquadmath
@@ -1460,6 +1461,9 @@ Optional Features:
   --disable-option-checking  ignore unrecognized --enable/--with options
   --disable-FEATURE   do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --enable-accelerator[=ARG]
+  build accelerator
+  [ARG={no,auto-device-triplet,device-triplet}]
   --enable-gold[=ARG] build gold [ARG={default,yes,no}]
   --enable-ld[=ARG]   build ld [ARG={default,yes,no}]
   --disable-libquadmath   do not build libquadmath directory
@@ -2922,6 +2926,39 @@ case ${with_newlib} in
   yes) skipdirs=`echo " ${skipdirs} " | sed -e 's/ target-newlib / /'` ;;
 esac
 
+# Handle --enable-accelerator.  This is in top-level because both libgomp and
+# GCC proper need this information.
+# --disable-accelerator
+#   Default.  Do not build accelerator pieces, only support host execution.
+# --enable-accelerator=auto-device-triplet
+#   If possible, build accelerator pieces for 'device-triplet'.
+# --enable-accelerator=device-triplet
+#   Build accelerator pieces for 'device-triplet'.
+# Check whether --enable-accelerator was given.
+if test "${enable_accelerator+set}" = set; then :
+  enableval=$enable_accelerator; ENABLE_ACCELERATOR=$enableval
+else
+  ENABLE_ACCELERATOR=no
+fi
+
+accel_target_noncanonical=NONE
+case "${ENABLE_ACCELERATOR}" in
+  yes)
+as_fn_error "--enable-accelerators must name accelerator" "$LINENO" 5
+skipdirs="${skipdirs} accel-gcc"
+;;
+  no)
+skipdirs="${skipdirs} accel-gcc"
+;;
+  auto-nvptx*|nvptx*)
+accel_target_noncanonical=`echo "$ENABLE_ACCELERATOR" | sed -e s/auto-//g`
+;;
+  *)
+as_fn_error "unrecognized accelerator" "$LINENO" 5
+skipdirs="${skipdirs} accel-gcc"
+;;
+esac
+
 # Handle --enable-gold, --enable-ld.
 # --disable-gold [--enable-ld]
 # Build only ld.  Default option.


Re: libgcc/config.host: Fix v850-rtems bug

2014-03-20 Thread Joel Sherrill

On 3/20/2014 10:57 AM, Rainer Orth wrote:
> Hi Joel,
>
>> It took a while to find this but v850-rtems lost the include
>> paths for the rtems specific .h files in newlib due to
>> the line that resets tmake_file rather than appends to it.
>>
>> Is this OK to apply to all impacted branches and the head?
>>
>> 2014-03-20  Joel Sherrill  
>>
>> * config.host (v850*-*-*): Add to tmake_file instead of resetting
>> it. This was removing the v850*-*-rtems* settings.
> Omit the `This was removing...' part: no explanations in ChangeLogs.
>
> I believe this is your call as RTEMS maintainer, even this late in the
> 4.9 release cycle, since it cannot affect any other target.
Done. This is a minor issue which results in the target being unbuildable.

Also committed to 4.7 and 4.8.

Thanks.
>   Rainer
>

-- 
Joel Sherrill, Ph.D. Director of Research & Development
joel.sherr...@oarcorp.comOn-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available(256) 722-9985



[PATCH, PR 60419] Clear thunk flag of "zombie" nodes

2014-03-20 Thread Martin Jambor
Hi,

in PR 60419 we end up with a call graph node for a thunk that has no
callee because symtab_remove_unreachable_nodes has determined its body
is not needed although its declaration is still reachable (more
details in comment 11 in bugzilla) and removal of callees is a part of
the zombification process that such nodes undergo.  Later on, the last
stage of inlining that runs after that connects the thunk to the call
graph and we segfault because we expect thunks to have a callee.

So we can either keep thunk targets alive or clear the thunk flag.
Thunks and aliases are quite similar and
symtab_remove_unreachable_nodes does clear the alias flag and the "in
border" nodes are referred to but not output and thus just another
symbol.  Therefore I believe it is correct and much simpler to remove
the thunk flag s well.

Bootstrapped and tested on x86_64, I have also build Mozilla Firefox
witht the patch (without LTO, partly on purpose, partly because again
I'm having issues with LTO after updating FF).  OK for trunk?

There is the same issue on the 4.8 branch, but the patch does not
apply, I'm in the process of preparing it.

Thanks,

Martin


2014-03-20  Martin Jambor  

PR ipa/60419
* ipa.c (symtab_remove_unreachable_nodes): Clear thunk flag of nodes
in the border.

testsuite/
* g++.dg/ipa/pr60419.C: New test.

diff --git a/gcc/ipa.c b/gcc/ipa.c
index 572dba1..164de0d 100644
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -488,6 +488,7 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, 
FILE *file)
  node->definition = false;
  node->cpp_implicit_alias = false;
  node->alias = false;
+ node->thunk.thunk_p = false;
  node->weakref = false;
  if (!node->in_other_partition)
node->local.local = false;
diff --git a/gcc/testsuite/g++.dg/ipa/pr60419.C 
b/gcc/testsuite/g++.dg/ipa/pr60419.C
new file mode 100644
index 000..84461f3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr60419.C
@@ -0,0 +1,80 @@
+// PR middle-end/60419
+// { dg-do compile }
+// { dg-options "-O2" }
+
+struct C
+{
+};
+
+struct I : C
+{
+  I ();
+};
+
+struct J
+{
+  void foo ();
+  J ();
+  virtual void foo (int &, int);
+};
+
+template 
+struct D
+{
+  virtual void foo (I &) const;
+  void bar ()
+  {
+I p;
+foo (p);
+  }
+};
+
+struct K : J, public D
+{
+};
+
+struct F
+{
+  K *operator->();
+};
+
+struct N : public K
+{
+  void foo (int &, int);
+  I n;
+  void foo (I &) const {}
+};
+
+struct L : J
+{
+  F l;
+};
+
+struct M : F
+{
+  L *operator->();
+};
+
+struct G
+{
+  G ();
+};
+
+M h;
+
+G::G ()
+try
+{
+  N f;
+  f.bar ();
+  throw;
+}
+catch (int)
+{
+}
+
+void
+baz ()
+{
+  h->l->bar ();
+}


[gomp4] Accelerator configury and paths changes 2/3

2014-03-20 Thread Bernd Schmidt

This adds three options to gcc's configure for accelerator/offload targets.

--enable-as-accelerator-for=host
  This is used to build offload compilers. They get installed in a
  subdirectory of their host compiler's install directory, with the
  driver going into the standard bin/ directory but with a different
  names
--enable-accelerator=target
--enable-offload-targets=target-list
  These have similar purposes; --enable-accelerator= is used if there's
  just a single offload target being built in-tree in the accel-gcc
  subdirectory (implemented by the next patch, and expected to be used
  for ptx), --enable-offload-targets= is used if there are multiple
  offload target compilers already built and installed.

Committed on gomp-4_0-branch.


Bernd
Index: gcc/ChangeLog
===
--- gcc/ChangeLog	(revision 208706)
+++ gcc/ChangeLog	(working copy)
@@ -1,3 +1,26 @@
+2014-03-20  Bernd Schmidt  
+
+	* configure.ac (real_target_noncanonical, tool_prefix,
+	accel_dir_suffix, offload_targets): Compute new variables.
+	(--enable-as-accelerator-for, --enable-as-accelerator,
+	--enable-offload-targets): New options.
+	* configure: Regenerate.
+	* config.in: Regenerate.
+	* Makefile.in (real_target_noncanonical, tool_prefix,
+	accel_dir_suffix, enable_as_accelerator): New variables substituted
+	by configure.
+	(libsubdir, libexecsubdir, GCC_TARGET_INSTALL_NAME): Tweak for the
+	possibility of being configured as an offload compiler.
+	(install_driver): Likewise.
+	(DRIVER_DEFINES): Pass new defines DEFAULT_REAL_TARGET_MACHINE and
+	ACCEL_DIR_SUFFIX.
+	* gcc.c (spec_host_machine, accel_dir_suffix): New variables.
+	(process_command): Tweak path construction for the possibility
+	of being configured as an offload compiler.
+	(main): Likewise. Look up specs in just_machine_suffix only if not
+	ACCEL_COMPILER.  Construct OFFLOAD_TARGET_NAMES environment variable
+	if we have OFFLOAD_TARGETS.
+
 2014-03-05  Jakub Jelinek  
 
 	PR plugins/59335
Index: gcc/Makefile.in
===
--- gcc/Makefile.in	(revision 208706)
+++ gcc/Makefile.in	(working copy)
@@ -58,6 +58,7 @@ build=@build@
 host=@host@
 target=@target@
 target_noncanonical:=@target_noncanonical@
+real_target_noncanonical:=@real_target_noncanonical@
 
 # Sed command to transform gcc to installed name.
 program_transform_name := @program_transform_name@
@@ -66,6 +67,11 @@ program_transform_name := @program_trans
 # Directories used during build
 # -
 
+# Normally identical to target_noncanonical, except for compilers built
+# as accelerator targets.
+tool_prefix = @tool_prefix@
+accel_dir_suffix = @accel_dir_suffix@
+
 # Directory where sources are, from where we are.
 srcdir = @srcdir@
 gcc_docdir = @srcdir@/doc
@@ -351,6 +357,8 @@ enable_plugin = @enable_plugin@
 
 enable_host_shared = @enable_host_shared@
 
+enable_as_accelerator = @enable_as_accelerator@
+
 CPPLIB = ../libcpp/libcpp.a
 CPPINC = -I$(srcdir)/../libcpp/include
 
@@ -586,9 +594,9 @@ libexecdir = @libexecdir@
 # 
 
 # Directory in which the compiler finds libraries etc.
-libsubdir = $(libdir)/gcc/$(target_noncanonical)/$(version)
+libsubdir = $(libdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix)
 # Directory in which the compiler finds executables
-libexecsubdir = $(libexecdir)/gcc/$(target_noncanonical)/$(version)
+libexecsubdir = $(libexecdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix)
 # Directory in which all plugin resources are installed
 plugin_resourcesdir = $(libsubdir)/plugin
  # Directory in which plugin headers are installed
@@ -766,7 +774,7 @@ BUILD_CPPFLAGS= -I. -I$(@D) -I$(srcdir)
 
 # Actual name to use when installing a native compiler.
 GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)')
-GCC_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gcc|sed '$(program_transform_name)')
+GCC_TARGET_INSTALL_NAME := $(tool_prefix)-$(shell echo gcc|sed '$(program_transform_name)')
 CPP_INSTALL_NAME := $(shell echo cpp|sed '$(program_transform_name)')
 GCOV_INSTALL_NAME := $(shell echo gcov|sed '$(program_transform_name)')
 
@@ -1935,9 +1943,11 @@ DRIVER_DEFINES = \
   -DSTANDARD_EXEC_PREFIX=\"$(libdir)/gcc/\" \
   -DSTANDARD_LIBEXEC_PREFIX=\"$(libexecdir)/gcc/\" \
   -DDEFAULT_TARGET_VERSION=\"$(version)\" \
+  -DDEFAULT_REAL_TARGET_MACHINE=\"$(real_target_noncanonical)\" \
   -DDEFAULT_TARGET_MACHINE=\"$(target_noncanonical)\" \
   -DSTANDARD_BINDIR_PREFIX=\"$(bindir)/\" \
   -DTOOLDIR_BASE_PREFIX=\"$(libsubdir_to_prefix)$(prefix_to_exec_prefix)\" \
+  -DACCEL_DIR_SUFFIX=\"$(accel_dir_suffix)\" \
   @TARGET_SYSTEM_ROOT_DEFINE@ \
   $(VALGRIND_DRIVER_DEFINES) \
   $(if $(SHLIB),$(if $(filter yes,@enable_shared@),-DENABLE_SHARED_LIBGCC)) \
@@ -3204,16 +3214,22 @@ install-common: native lang.install-comm
 # Install the driver program as $(target_noncanonical)-gcc,
 # $(target_noncan

[gomp4/stage1] Clean up lto section name headers

2014-03-20 Thread Bernd Schmidt
This reduces duplication of a number of defines related to LTO 
section/segment names.


Committed on gomp-4_0-branch; ok for stage1?


Bernd
Index: gcc/lto/ChangeLog
===
--- gcc/lto/ChangeLog	(revision 208706)
+++ gcc/lto/ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2014-03-20  Bernd Schmidt  
+
+	* lto-object.c: Include "lto-section-names.h".
+	(LTO_SEGMENT_NAME): Don't define.
+	* lto.c: Include "lto-section-names.h".
+
 2014-02-14  Jan Hubicka  
 
 	PR lto/60295
Index: gcc/ChangeLog
===
--- gcc/ChangeLog	(revision 208715)
+++ gcc/ChangeLog	(working copy)
@@ -1,5 +1,17 @@
 2014-03-20  Bernd Schmidt  
 
+	* config/darwin.c: Include "lto-section-names.h".
+	(LTO_SEGMENT_NAME): Don't define.
+	* config/i386/winnt.c: Include "lto-section-names.h".
+	* lto-streamer.c: Include "lto-section-names.h".
+	* lto-streamer.h (LTO_SECTION_NAME_PREFIX, OMP_SECTION_NAME_PREFIX):
+	Don't define.
+	(section_name_prefix): Don't declare.
+	* lto-wrapper.c: Include "lto-section-names.h".
+	(LTO_SECTION_NAME_PREFIX): Don't define.
+	* lto-section-names.h: New file.
+	* cgraphunit.c: Include "lto-section-names.h".
+
 	* configure.ac (real_target_noncanonical, tool_prefix,
 	accel_dir_suffix, offload_targets): Compute new variables.
 	(--enable-as-accelerator-for, --enable-as-accelerator,
Index: gcc/cgraphunit.c
===
--- gcc/cgraphunit.c	(revision 208706)
+++ gcc/cgraphunit.c	(working copy)
@@ -210,6 +210,7 @@ along with GCC; see the file COPYING3.
 #include "pass_manager.h"
 #include "tree-nested.h"
 #include "gimplify.h"
+#include "lto-section-names.h"
 
 /* Queue of cgraph nodes scheduled to be added into cgraph.  This is a
secondary queue used during optimization to accommodate passes that
Index: gcc/config/darwin.c
===
--- gcc/config/darwin.c	(revision 208706)
+++ gcc/config/darwin.c	(working copy)
@@ -61,6 +61,7 @@ along with GCC; see the file COPYING3.
 #include "gimple.h"
 #include "gimplify.h"
 #include "lto-streamer.h"
+#include "lto-section-names.h"
 
 /* Darwin supports a feature called fix-and-continue, which is used
for rapid turn around debugging.  When code is compiled with the
@@ -1900,9 +1901,6 @@ typedef struct GTY (()) darwin_lto_secti
 
 static GTY (()) vec *lto_section_names;
 
-/* Segment for LTO data.  */
-#define LTO_SEGMENT_NAME "__GNU_LTO"
-
 /* Section wrapper scheme (used here to wrap the unlimited number of LTO
sections into three Mach-O ones).
NOTE: These names MUST be kept in sync with those in
Index: gcc/config/i386/winnt.c
===
--- gcc/config/i386/winnt.c	(revision 208706)
+++ gcc/config/i386/winnt.c	(working copy)
@@ -49,6 +49,7 @@ along with GCC; see the file COPYING3.
 #include "is-a.h"
 #include "gimple.h"
 #include "lto-streamer.h"
+#include "lto-section-names.h"
 
 /* i386/PE specific attribute support.
 
Index: gcc/lto/lto-object.c
===
--- gcc/lto/lto-object.c	(revision 208706)
+++ gcc/lto/lto-object.c	(working copy)
@@ -32,13 +32,9 @@ along with GCC; see the file COPYING3.
 #include "lto.h"
 #include "tm.h"
 #include "lto-streamer.h"
+#include "lto-section-names.h"
 #include "simple-object.h"
 
-/* Segment name for LTO sections.  This is only used for Mach-O.
-   FIXME: This needs to be kept in sync with darwin.c.  */
-
-#define LTO_SEGMENT_NAME "__GNU_LTO"
-
 /* An LTO file wrapped around an simple_object.  */
 
 struct lto_simple_object
Index: gcc/lto/lto.c
===
--- gcc/lto/lto.c	(revision 208706)
+++ gcc/lto/lto.c	(working copy)
@@ -43,6 +43,7 @@ along with GCC; see the file COPYING3.
 #include "lto.h"
 #include "lto-tree.h"
 #include "lto-streamer.h"
+#include "lto-section-names.h"
 #include "tree-streamer.h"
 #include "splay-tree.h"
 #include "lto-partition.h"
Index: gcc/lto-section-names.h
===
--- gcc/lto-section-names.h	(revision 0)
+++ gcc/lto-section-names.h	(working copy)
@@ -0,0 +1,33 @@
+/* Definitions for LTO section names.
+   Copyright (C) 2013 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If 

Re: libgcc/config.host: Fix v850-rtems bug

2014-03-20 Thread Jeff Law

On 03/20/14 09:33, Joel Sherrill wrote:

Hi

It took a while to find this but v850-rtems lost the include
paths for the rtems specific .h files in newlib due to
the line that resets tmake_file rather than appends to it.

Is this OK to apply to all impacted branches and the head?




2014-03-20  Joel Sherrill  

 * config.host (v850*-*-*): Add to tmake_file instead of resetting
 it. This was removing the v850*-*-rtems* settings.

Yes.  This is fine.
jeff



[gomp4] Use OMP_SECTION_NAME_PREFIX in offload compilers

2014-03-20 Thread Bernd Schmidt
This makes us read in the offloaded functions in an offload compiler's 
lto1. This is essentially Michael Zolotukhin's patch 1/3 from a while ago.


Committed on gomp-4_0-branch.


Bernd
Index: gcc/lto/ChangeLog
===
--- gcc/lto/ChangeLog	(revision 208720)
+++ gcc/lto/ChangeLog	(working copy)
@@ -1,5 +1,11 @@
 2014-03-20  Bernd Schmidt  
 
+	From Michael Zolotukhin.
+	* lto-object.c (lto_obj_add_section): Compare against the
+	section_name_prefix variable.
+	* lto.c (lto_section_with_id): Likewise.
+	(read_cgraph_and_symbols): Change it if ACCEL_COMPILER.
+
 	* lto-object.c: Include "lto-section-names.h".
 	(LTO_SEGMENT_NAME): Don't define.
 	* lto.c: Include "lto-section-names.h".
Index: gcc/lto/lto-object.c
===
--- gcc/lto/lto-object.c	(revision 208720)
+++ gcc/lto/lto-object.c	(working copy)
@@ -230,8 +230,7 @@ lto_obj_add_section (void *data, const c
   void **slot;
   struct lto_section_list *list = loasd->list;
 
-  if (strncmp (name, LTO_SECTION_NAME_PREFIX,
-	   strlen (LTO_SECTION_NAME_PREFIX)) != 0)
+  if (strncmp (name, section_name_prefix, strlen (section_name_prefix)))
 return 1;
 
   new_name = xstrdup (name);
Index: gcc/lto/lto.c
===
--- gcc/lto/lto.c	(revision 208720)
+++ gcc/lto/lto.c	(working copy)
@@ -2128,7 +2128,7 @@ lto_section_with_id (const char *name, u
 {
   const char *s;
 
-  if (strncmp (name, LTO_SECTION_NAME_PREFIX, strlen (LTO_SECTION_NAME_PREFIX)))
+  if (strncmp (name, section_name_prefix, strlen (section_name_prefix)))
 return 0;
   s = strrchr (name, '.');
   return s && sscanf (s, "." HOST_WIDE_INT_PRINT_HEX_PURE, id) == 1;
@@ -2903,6 +2903,10 @@ read_cgraph_and_symbols (unsigned nfiles
 
   timevar_push (TV_IPA_LTO_DECL_IN);
 
+#ifdef ACCEL_COMPILER
+section_name_prefix = OMP_SECTION_NAME_PREFIX;
+#endif
+
   real_file_decl_data
 = decl_data = ggc_alloc_cleared_vec_lto_file_decl_data_ptr (nfiles + 1);
   real_file_count = nfiles;


[PATCH, PR 60556] Fix ICE on platforms with signed pointer extension.

2014-03-20 Thread Steve Ellcey
This patch fixes pr60556, a GCC ICE.  The problem is in convert_move where,
if we are trying to put a 32 bit address into a 64 bit destination we
can wind up calling emit_move_insn with NULL_RTX as a source.

The problem comes when creating fill_value.  If unsignedp is false
then we call emit_store_flag to set fill_value.  If lowfrom is a symbol
reference then emit_store_flag returns NULL_RTX (because symbol references
are constant) and we wind up calling emit_move_insn with NULL_RTX as a
source and getting an ICE.

My fix is to check for a symbol reference up where we are already 
checking for memory references and force the symbol into a register
before calling emit_store_flag.  This will prevent emit_store_flag
from returning NULL_RTX.  In theory we could force the symbol
reference into a register only if unsignedp is false, but I think
it is cleaner to always put the symbol reference into a register.

Tested on mips-mti-linux-gnu with no regressions.

OK for checkin?

Steve Ellcey
sell...@mips.com


2014-03-20  Steve Ellcey  

PR middle-end/60556
* expr.c (convert_move): Force symbol references into register.


diff --git a/gcc/expr.c b/gcc/expr.c
index be62c53..d065588 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -533,7 +533,8 @@ convert_move (rtx to, rtx from, int unsignedp)
  conversion sequence might require several references to it and we
  must ensure we're getting the same value every time.  */
 
-  if (MEM_P (from) || reg_overlap_mentioned_p (to, from))
+  if (MEM_P (from) || GET_CODE (from) == SYMBOL_REF
+ || reg_overlap_mentioned_p (to, from))
from = force_reg (from_mode, from);
 
   /* Get a copy of FROM widened to a word, if necessary.  */



2014-03-20  Steve Ellcey  

PR middle-end/60556
gcc.dg/pr60556.c: New.


diff --git a/gcc/testsuite/gcc.dg/pr60556.c b/gcc/testsuite/gcc.dg/pr60556.c
new file mode 100644
index 000..3b5bbe5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr60556.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int g (int);
+unsigned long long f(void) {
+ return (unsigned long long)(long)&g;
+}


[gomp4] Add tables generation

2014-03-20 Thread Bernd Schmidt
This is based on Michael Zolotukhin's patch 2/3 from a while ago. It 
adds functionality to build function/variable tables that will allow 
libgomp to look up offload target code based on the address of the 
corresponding host function. There are two alternatives, one based on 
named sections, and one based on a target hook when named sections are 
unavailable (as on ptx).


Committed on gomp-4_0-branch.


Bernd
Index: libgcc/ChangeLog
===
--- libgcc/ChangeLog	(revision 208706)
+++ libgcc/ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2014-03-20  Bernd Schmidt  
+
+	* crtstuff.c (_omp_func_table, _omp_var_table, _omp_funcs_end,
+	_omp_vars_end): New array fragments.
+	(__OPENMP_TARGET__): New variable.
+
 2014-02-28  Joey Ye  
 
 	PR libgcc/60166
Index: gcc/ChangeLog
===
--- gcc/ChangeLog	(revision 208720)
+++ gcc/ChangeLog	(working copy)
@@ -1,5 +1,20 @@
 2014-03-20  Bernd Schmidt  
 
+	Mostly by Michael Zolotukhin:
+	* omp-low.c: Include "common/common-target.h".
+	(expand_omp_target): Pass in address of __OPENMP_TARGET__.
+	(add_decls_addresses_to_decl_constructor, omp_finish_file): New
+	functions.
+	* omp-low.h (omp_finish_file): Declare.
+	* toplev.c: Include "omp-low.h".
+	(compile_file): Call omp_finish_file.
+	* target.def (record_offload_symbol): New hook.
+	* doc/tm.texi.in (TARGET_RECORD_OFFLOAD_SYMBOL): Add.
+	* doc/tm.texi: Regenerate.
+	* configure.ac (ENABLE_OFFLOADING): Define if we have offload_targets.
+	* configure: Regenerate.
+	* config.in: Regenerate.
+
 	* config/darwin.c: Include "lto-section-names.h".
 	(LTO_SEGMENT_NAME): Don't define.
 	* config/i386/winnt.c: Include "lto-section-names.h".
Index: gcc/config.in
===
--- gcc/config.in	(revision 208715)
+++ gcc/config.in	(working copy)
@@ -139,6 +139,12 @@
 #endif
 
 
+/* Define this to enable support for offloading. */
+#ifndef USED_FOR_TARGET
+#undef ENABLE_OFFLOADING
+#endif
+
+
 /* Define to enable plugin support. */
 #ifndef USED_FOR_TARGET
 #undef ENABLE_PLUGIN
Index: gcc/configure
===
--- gcc/configure	(revision 208715)
+++ gcc/configure	(working copy)
@@ -7363,6 +7363,11 @@ cat >>confdefs.h <<_ACEOF
 #define OFFLOAD_TARGETS "$offload_targets"
 _ACEOF
 
+if test x$offload_targets != x; then
+
+$as_echo "#define ENABLE_OFFLOADING 1" >>confdefs.h
+
+fi
 
 
 # Check whether --with-multilib-list was given.
@@ -18008,7 +18013,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18011 "configure"
+#line 18016 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18114,7 +18119,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 18117 "configure"
+#line 18122 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
Index: gcc/configure.ac
===
--- gcc/configure.ac	(revision 208715)
+++ gcc/configure.ac	(working copy)
@@ -887,6 +887,10 @@ AC_SUBST(enable_accelerator)
 offload_targets=`echo $offload_targets | sed -e 's#,#:#'`
 AC_DEFINE_UNQUOTED(OFFLOAD_TARGETS, "$offload_targets",
  [Define to hold the list of target names suitable for offloading.])
+if test x$offload_targets != x; then
+  AC_DEFINE(ENABLE_OFFLOADING, 1,
+[Define this to enable support for offloading.])
+fi
 
 AC_ARG_WITH(multilib-list,
 [AS_HELP_STRING([--with-multilib-list], [select multilibs (AArch64, SH and x86-64 only)])],
Index: gcc/doc/tm.texi
===
--- gcc/doc/tm.texi	(revision 208706)
+++ gcc/doc/tm.texi	(working copy)
@@ -11418,3 +11418,9 @@ If defined, this function returns an app
 @deftypefn {Target Hook} void TARGET_ATOMIC_ASSIGN_EXPAND_FENV (tree *@var{hold}, tree *@var{clear}, tree *@var{update})
 ISO C11 requires atomic compound assignments that may raise floating-point exceptions to raise exceptions corresponding to the arithmetic operation whose result was successfully stored in a compare-and-exchange sequence.  This requires code equivalent to calls to @code{feholdexcept}, @code{feclearexcept} and @code{feupdateenv} to be generated at appropriate points in the compare-and-exchange sequence.  This hook should set @code{*@var{hold}} to an expression equivalent to the call to @code{feholdexcept}, @code{*@var{clear}} to an expression equivalent to the call to @code{feclearexcept} and @code{*@var{update}} to an expression equivalent to the call to @code{feupdateenv}.  The three expressions are @code{NULL_TREE} on entry to the hook and may be left as @code{NULL_TREE} if no code is required in a particular place.  The default implementation leaves all three expressions as @code{NULL_TREE}.  The @code{__atomic_ferais

[gomp4/stage1] Utility functions for collect2/lto-wrapper/mkoffload 1/2

2014-03-20 Thread Bernd Schmidt
Since we're about to introduce new mkoffload programs, and they're going 
to require a lot of functionality that's already present in lto-wrapper 
and collect2, I've decided to make a new set of utility functions that 
can be linked in with these programs.


This is the first step, splitting off code from lto-wrapper into a new 
collect-utils.c file. The next step will replace some of these with 
almost-identical ones from collect2 and make that tool also link with 
collect-utils.


Committed on gomp-4_0-branch; ok for stage1?


Bernd
Index: gcc/ChangeLog
===
--- gcc/ChangeLog	(revision 208723)
+++ gcc/ChangeLog	(working copy)
@@ -1,5 +1,17 @@
 2014-03-20  Bernd Schmidt  
 
+	* Makefile.in (ALL_HOST_BACKEND_OBJS): Add collect-utils.o.
+	(lto-wrapper$(exeext)): Link with collect-utils.o.
+	* collect-utils.c: New file.
+	* collect-utils.h: New file.
+	* lto-wrapper.c: Include "collect-utils.h".
+	(args_name): Delete variable.
+	(tool_name): New variable.
+	(tool_cleanup): New function.
+	(maybe_unlink): Renamed from maybe_unlink_file.  All callers changed.
+	(lto_wrapper_cleanup, fatal_signal, fatal, fatal_perror,
+	collect_execute, collect_wait, fork_execute): Remove functions.
+
 	Mostly by Michael Zolotukhin:
 	* omp-low.c: Include "common/common-target.h".
 	(expand_omp_target): Pass in address of __OPENMP_TARGET__.
Index: gcc/Makefile.in
===
--- gcc/Makefile.in	(revision 208715)
+++ gcc/Makefile.in	(working copy)
@@ -1496,7 +1496,7 @@ ALL_HOST_FRONTEND_OBJS = $(foreach v,$(C
 ALL_HOST_BACKEND_OBJS = $(GCC_OBJS) $(OBJS) $(OBJS-libcommon) \
   $(OBJS-libcommon-target) @TREEBROWSER@ main.o c-family/cppspec.o \
   $(COLLECT2_OBJS) $(EXTRA_GCC_OBJS) $(GCOV_OBJS) $(GCOV_DUMP_OBJS) \
-  lto-wrapper.o
+  lto-wrapper.o collect-utils.o
 
 # This lists all host object files, whether they are included in this
 # compilation or not.
@@ -1915,9 +1915,11 @@ collect2$(exeext): $(COLLECT2_OBJS) $(LI
 CFLAGS-collect2.o += -DTARGET_MACHINE=\"$(target_noncanonical)\" \
 	@TARGET_SYSTEM_ROOT_DEFINE@
 
-lto-wrapper$(exeext): lto-wrapper.o ggc-none.o libcommon-target.a $(LIBDEPS)
+lto-wrapper$(exeext): lto-wrapper.o collect-utils.o ggc-none.o \
+  libcommon-target.a $(LIBDEPS)
 	+$(LINKER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o T$@ \
-	lto-wrapper.o ggc-none.o libcommon-target.a $(LIBS)
+	lto-wrapper.o collect-utils.o ggc-none.o libcommon-target.a \
+	$(LIBS)
 	mv -f T$@ $@
 
 # Files used by all variants of C or by the stand-alone pre-processor.
Index: gcc/collect-utils.c
===
--- gcc/collect-utils.c	(revision 0)
+++ gcc/collect-utils.c	(working copy)
@@ -0,0 +1,259 @@
+/* Utility functions used by tools like collect2 and lto-wrapper.
+   Copyright (C) 2009-2014 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "intl.h"
+#include "diagnostic.h"
+#include "obstack.h"
+#include "opts.h"
+#include "options.h"
+#include "simple-object.h"
+#include "lto-section-names.h"
+#include "collect-utils.h"
+
+static char *response_file;
+
+bool debug;
+bool verbose;
+
+/* Delete tempfiles.  */
+
+void
+utils_cleanup (void)
+{
+  static bool cleanup_done = false;
+
+  if (cleanup_done)
+return;
+
+  /* Setting cleanup_done prevents an infinite loop if one of the
+ calls to maybe_unlink fails. */
+  cleanup_done = true;
+
+  if (response_file)
+maybe_unlink (response_file);
+  tool_cleanup ();
+}
+
+/* Notify user of a non-error.  */
+void
+notice (const char *cmsgid, ...)
+{
+  va_list ap;
+
+  va_start (ap, cmsgid);
+  vfprintf (stderr, _(cmsgid), ap);
+  va_end (ap);
+}
+
+void
+fatal_signal (int signum)
+{
+  signal (signum, SIG_DFL);
+  utils_cleanup ();
+  /* Get the same signal again, this time not handled,
+ so its normal effect occurs.  */
+  kill (getpid (), signum);
+}
+
+/* Just die. CMSGID is the error message. */
+
+void __attribute__ ((format (printf, 1, 2)))
+fatal (const char * cmsgid, ...)
+{
+  va_list ap;
+
+  va_start (ap, cmsgid);
+  fprintf (stderr, "%s: ", tool_name);
+  vfprintf (stderr, _(cmsgid), ap);
+  fprintf (stderr, "\n");
+  va_end (ap);
+
+  utils_cleanup ();
+  exit (FATAL_EXIT_CODE);
+}
+
+
+/* Di

[gomp4/stage1] Utility functions for collect2/lto-wrapper/mkoffload 2/2

2014-03-20 Thread Bernd Schmidt
This is the second part of making a set of utility functions to be used 
by collect2, lto-wrapper and mkoffload.


The implementations of some functions like fork_execute are changed to 
those from collect2 and the calls in lto-wrapper adapted accordingly. 
There are some minor changes in these functions: for example I avoid 
calling fatal_error, instead using the fatal/fatal_perror functions so 
that the cleanup routine is called properly (lto-wrapper does not use 
atexit as collect2 does).


Committed on gomp-4_0-branch; ok for stage1?


Bernd

Index: gcc/ChangeLog
===
--- gcc/ChangeLog	(revision 208724)
+++ gcc/ChangeLog	(working copy)
@@ -1,5 +1,40 @@
 2014-03-20  Bernd Schmidt  
 
+	* Makefile.in (COLLECT2_OBJS): Add collect-utils.o.
+	(LTO_WRAPPER_OBJS): New variable.
+	(lto-wrapper$(exeext)): Use it.
+	* collect2.c: Include "collect-utils.h".
+	(vflag, debug): Remove variables.  Rename all uses of vflag to
+	verbose.
+	(at_file_supplied): No longer static.
+	(tool_name): New variable.
+	(do_wait, fork_execute, maybe_unlink): Don't declare.
+	(tool_cleanup): Renamed from collect_atexit.  New arg from_signal.
+	(collect_atexit): New static function.
+	(notice): Remove function.
+	(handler): Just call tool_cleanup.
+	(maybe_run_lto_and_relink, main, do_dsymutil): Add new arg to
+	fork_execute calls.
+	(collect_wait, do_wait, collect_execute): Remove functions.
+	(maybe_unlink): No longer static.
+	* collect2.h (vflag, debug): Don't declare.
+	(at_file_supplied): Declare.
+	* collect-utils.c (utils_cleanup): New arg from_signal.  All callers
+	changed.
+	(collect_execute): Replace with implementation from collect2, plus a
+	new arg use_atfile.  All callers changed.
+	(collect_wait): Replace with implementation from collect2.
+	(maybe_unlink_file): Remove function.
+	(fork_execute): Replace with implementation from collect2, plus a
+	new arg use_atfile.  All callers changed.
+	(do_wait): Add call to utils_cleanup to the error path.
+	* collect-utils.h (collect_execute, fork_execute, utils_cleanup,
+	tool_cleanup): Adjust declarations.
+	* lto-wrapper.c (tool_cleanup): Add unused bool argument.
+	* tlink.c: Include "collect-utils.h".
+	(tlink_execute): New arg use_atfile.  All callers changed.
+	(tlink_init, tlink_execute): Remove declarations.
+
 	* Makefile.in (ALL_HOST_BACKEND_OBJS): Add collect-utils.o.
 	(lto-wrapper$(exeext)): Link with collect-utils.o.
 	* collect-utils.c: New file.
Index: gcc/collect-utils.c
===
--- gcc/collect-utils.c	(revision 208724)
+++ gcc/collect-utils.c	(working copy)
@@ -34,24 +34,6 @@ static char *response_file;
 bool debug;
 bool verbose;
 
-/* Delete tempfiles.  */
-
-void
-utils_cleanup (void)
-{
-  static bool cleanup_done = false;
-
-  if (cleanup_done)
-return;
-
-  /* Setting cleanup_done prevents an infinite loop if one of the
- calls to maybe_unlink fails. */
-  cleanup_done = true;
-
-  if (response_file)
-maybe_unlink (response_file);
-  tool_cleanup ();
-}
 
 /* Notify user of a non-error.  */
 void
@@ -68,7 +50,7 @@ void
 fatal_signal (int signum)
 {
   signal (signum, SIG_DFL);
-  utils_cleanup ();
+  utils_cleanup (true);
   /* Get the same signal again, this time not handled,
  so its normal effect occurs.  */
   kill (getpid (), signum);
@@ -87,7 +69,7 @@ fatal (const char * cmsgid, ...)
   fprintf (stderr, "\n");
   va_end (ap);
 
-  utils_cleanup ();
+  utils_cleanup (false);
   exit (FATAL_EXIT_CODE);
 }
 
@@ -106,61 +88,12 @@ fatal_perror (const char *cmsgid, ...)
   fprintf (stderr, ": %s\n", xstrerror (e));
   va_end (ap);
 
-  utils_cleanup ();
+  utils_cleanup (false);
   exit (FATAL_EXIT_CODE);
 }
 
-
-/* Execute a program, and wait for the reply. ARGV are the arguments. The
-   last one must be NULL. */
-
-struct pex_obj *
-collect_execute (char **argv)
-{
-  struct pex_obj *pex;
-  const char *errmsg;
-  int err;
-
-  if (verbose)
-{
-  char **p_argv;
-  const char *str;
-
-  for (p_argv = argv; (str = *p_argv) != (char *) 0; p_argv++)
-	fprintf (stderr, " %s", str);
-
-  fprintf (stderr, "\n");
-}
-
-  fflush (stdout);
-  fflush (stderr);
-
-  pex = pex_init (0, tool_name, NULL);
-  if (pex == NULL)
-fatal_perror ("pex_init failed");
-
-  /* Do not use PEX_LAST here, we use our stdout for communicating with
- collect2 or the linker-plugin.  Any output from the sub-process
- will confuse that.  */
-  errmsg = pex_run (pex, PEX_SEARCH, argv[0], argv, NULL,
-		NULL, &err);
-  if (errmsg != NULL)
-{
-  if (err != 0)
-	{
-	  errno = err;
-	  fatal_perror (errmsg);
-	}
-  else
-	fatal (errmsg);
-}
-
-  return pex;
-}
-
-
-/* Wait for a process to finish, and exit if a nonzero status is found.
-   PROG is the program name. PEX is the process we should wait for. */
+
+/* Wait for a process to finish, and exit if a nonzero status is found.  */
 
 int
 col

[gomp4] Add mkoffload invocations to lto-wrapper

2014-03-20 Thread Bernd Schmidt
This is based on Michael Zolotukhin's patch 3/3 from a while ago. It 
enables lto-wrapper to build target images using the offload compilers 
(identifying them through an env variable passed in by the gcc driver). 
All the target-specific code is gone, however. We now expect an offload 
compiler to provide a mkoffload tool to generate the image, and we just 
call it from lto-wrapper.


Committed on gomp-4_0-branch.


Bernd
Index: gcc/ChangeLog
===
--- gcc/ChangeLog	(revision 208725)
+++ gcc/ChangeLog	(working copy)
@@ -1,5 +1,15 @@
 2014-03-20  Bernd Schmidt  
 
+	Mostly by Michael Zolotukhin:
+	* lto-wrapper.c (OFFLOAD_FUNC_TABLE_SECTION_NAME,
+	OFFLOAD_TARGET_NAMES_ENV): New defines.
+	(offload_names): New static variable.
+	(free_array_of_ptrs, parse_env_var, access_check,
+	prepare_target_image, replace_special_characters,
+	compile_images_for_openmp_targets): New static functions.
+	(run_gcc): Determine whether offload sections are present.  If so,
+	run compile_images_for_openmp_targets and print the image names.
+
 	* Makefile.in (COLLECT2_OBJS): Add collect-utils.o.
 	(LTO_WRAPPER_OBJS): New variable.
 	(lto-wrapper$(exeext)): Use it.
Index: gcc/lto-wrapper.c
===
--- gcc/lto-wrapper.c	(revision 208725)
+++ gcc/lto-wrapper.c	(working copy)
@@ -49,6 +49,9 @@ along with GCC; see the file COPYING3.
 #include "lto-section-names.h"
 #include "collect-utils.h"
 
+#define OFFLOAD_FUNC_TABLE_SECTION_NAME ".offload_func_table_section"
+#define OFFLOAD_TARGET_NAMES_ENV	"OFFLOAD_TARGET_NAMES"
+
 enum lto_mode_d {
   LTO_MODE_NONE,			/* Not doing LTO.  */
   LTO_MODE_LTO,/* Normal LTO.  */
@@ -63,6 +66,7 @@ static char *flto_out;
 static unsigned int nr;
 static char **input_names;
 static char **output_names;
+static char **offload_names;
 static char *makefile;
 
 const char tool_name[] = "lto-wrapper";
@@ -279,6 +283,203 @@ merge_and_complain (struct cl_decoded_op
 }
 }
 
+/* Auxiliary function that frees elements of PTR and PTR itself.
+   N is number of elements to be freed.
+   If PTR is NULL, nothing is freed.  If an element is NULL, subsequent elements
+   are not freed.  */
+static void**
+free_array_of_ptrs (void **ptr, unsigned n)
+{
+  unsigned i;
+  if (!ptr)
+return NULL;
+  for (i = 0; i < n; i++)
+{
+  if (!ptr[i])
+	break;
+  free (ptr[i]);
+}
+  free (ptr);
+  return NULL;
+}
+
+/* Parse STR, saving found tokens into PVALUES and return their number.
+   Tokens are assumed to be delimited by ':'.  If APPEND is non-null,
+   append it to every token we find.  */
+
+static unsigned
+parse_env_var (const char *str, char ***pvalues, const char *append)
+{
+  const char *curval, *nextval;
+  char **values;
+  unsigned num = 1, i;
+
+  curval = strchr (str, ':');
+  while (curval)
+{
+  num++;
+  curval = strchr (curval + 1, ':');
+}
+
+  values = (char**) xmalloc (num * sizeof (char*));
+  curval = str;
+  nextval = strchrnul (curval, ':');
+
+  int append_len = append ? strlen (append) : 0;
+  for (i = 0; i < num; i++)
+{
+  int l = nextval - curval;
+  values[i] = (char*) xmalloc (l + 1 + append_len);
+  memcpy (values[i], curval, l);
+  values[i][l] = 0;
+  if (append)
+	strcat (values[i], append);
+  curval = nextval + 1;
+  nextval = strchrnul (curval, ':');
+}
+  *pvalues = values;
+  return num;
+}
+
+/* Check whether NAME can be accessed in MODE.  This is like access,
+   except that it never considers directories to be executable.  */
+
+static int
+access_check (const char *name, int mode)
+{
+  if (mode == X_OK)
+{
+  struct stat st;
+
+  if (stat (name, &st) < 0
+	  || S_ISDIR (st.st_mode))
+	return -1;
+}
+
+  return access (name, mode);
+}
+
+/* Prepare target image for target NAME.
+   Firstly, we execute COMPILER, passing all input files to it to produce DSO.
+   When target DSO is ready, we pass it to objcopy to place its image into a
+   special data section.  After that we rename target image's symbols to values,
+   expected by the host side, and return the name of the resultant file.  */
+
+static char*
+prepare_target_image (const char *target, const char *compiler_path,
+		  unsigned in_argc, char *in_argv[])
+{
+  const char **argv;
+  struct obstack argv_obstack;
+  unsigned i;
+  char *filename = NULL;
+  char *suffix = XALLOCAVEC (char, strlen ("/accel//mkoffload") + 1 + strlen (target));
+  const char *compiler = NULL;
+
+  strcpy (suffix, "/accel/");
+  strcat (suffix, target);
+  strcat (suffix, "/mkoffload");
+
+  char **paths;
+  int n_paths = parse_env_var (compiler_path, &paths, suffix);
+
+  for (int i = 0; i < n_paths; i++)
+if (access_check (paths[i], X_OK) == 0)
+  {
+	compiler = paths[i];
+	break;
+  }
+
+  if (compiler == NULL)
+goto out;
+
+  /* Generate temp file name.  */
+  filename = make_temp_file (".target.o");
+

Re: Fwd: [RFC][gomp4] Offloading patches (2/3): Add tables generation

2014-03-20 Thread Bernd Schmidt

On 03/12/2014 03:51 PM, Ilya Verbin wrote:

2014-03-12 18:12 GMT+04:00 Bernd Schmidt :

LGTM. Shall I start committing my changes to the branch?


Yes, I think you should commit your changes.
And we will rewrite our part to use the new configure approach.


Done now.  I think/hope that I've committed all the ones that are not 
entirely related to ptx - let me know if you find there are any missing 
pieces.



Bernd




Fwd: [GOOGLE] update ssa before compute_inline_parameters

2014-03-20 Thread Dehao Chen
This patch calls update_ssa before compute_inline_paramters.

Bootstrapped and perf test on-going.

OK for google-4_8?

Thanks,
Dehao

Index: gcc/auto-profile.c
===
--- gcc/auto-profile.c (revision 208726)
+++ gcc/auto-profile.c (working copy)
@@ -1613,6 +1613,7 @@ auto_profile (void)
   early_inliner ();
  }

+  update_ssa (TODO_update_ssa);
   compute_inline_parameters (cgraph_get_node
(current_function_decl), true);
   early_inliner ();
   autofdo::afdo_annotate_cfg (promoted_stmts);


Re: [gomp4/stage1] Utility functions for collect2/lto-wrapper/mkoffload 2/2

2014-03-20 Thread Bernd Schmidt

On 03/20/2014 06:03 PM, Bernd Schmidt wrote:

This is the second part of making a set of utility functions to be used
by collect2, lto-wrapper and mkoffload.

The implementations of some functions like fork_execute are changed to
those from collect2 and the calls in lto-wrapper adapted accordingly.
There are some minor changes in these functions: for example I avoid
calling fatal_error, instead using the fatal/fatal_perror functions so
that the cleanup routine is called properly (lto-wrapper does not use
atexit as collect2 does).

Committed on gomp-4_0-branch; ok for stage1?


This was missing Makefile.in from the commit. Now fixed.


Bernd


Index: gcc/Makefile.in
===
--- gcc/Makefile.in	(revision 208724)
+++ gcc/Makefile.in	(working copy)
@@ -1904,7 +1904,8 @@ gcc-ranlib.c: gcc-ar.c
 gcc-nm.c: gcc-ar.c
 	cp $^ $@
 
-COLLECT2_OBJS = collect2.o collect2-aix.o tlink.o vec.o ggc-none.o file-find.o
+COLLECT2_OBJS = collect2.o collect2-aix.o tlink.o vec.o ggc-none.o \
+  collect-utils.o file-find.o
 COLLECT2_LIBS = @COLLECT2_LIBS@
 collect2$(exeext): $(COLLECT2_OBJS) $(LIBDEPS)
 # Don't try modifying collect2 (aka ld) in place--it might be linking this.
@@ -1915,11 +1916,10 @@ collect2$(exeext): $(COLLECT2_OBJS) $(LI
 CFLAGS-collect2.o += -DTARGET_MACHINE=\"$(target_noncanonical)\" \
 	@TARGET_SYSTEM_ROOT_DEFINE@
 
-lto-wrapper$(exeext): lto-wrapper.o collect-utils.o ggc-none.o \
-  libcommon-target.a $(LIBDEPS)
+LTO_WRAPPER_OBJS = lto-wrapper.o collect-utils.o ggc-none.o
+lto-wrapper$(exeext): $(LTO_WRAPPER_OBJS) libcommon-target.a $(LIBDEPS)
 	+$(LINKER) $(ALL_COMPILERFLAGS) $(LDFLAGS) -o T$@ \
-	lto-wrapper.o collect-utils.o ggc-none.o libcommon-target.a \
-	$(LIBS)
+	$(LTO_WRAPPER_OBJS) libcommon-target.a $(LIBS)
 	mv -f T$@ $@
 
 # Files used by all variants of C or by the stand-alone pre-processor.


[PATCH] dwarf2out: Represent bound_info with normal constant values if possible.

2014-03-20 Thread Mark Wielaard
Hi,

The following patch made it so that 64-bit bounds could be output on
32-bit hosts with DWARF.

2009-07-11  Eric Botcazou  

* dwarf2out.c (enum dw_val_class): Replace dw_val_class_long_long
with dw_val_class_const_double.
(struct dw_long_long_struct): Delete.
(struct dw_val_struct): Adjust for above change.
(add_AT_long_long): Rename into...
(add_AT_double): ...this.
(print_die): Replace dw_val_class_long_long case with
dw_val_class_const_double case.
(attr_checksum): Likewise.
(same_dw_val_p): Likewise.
(size_of_die): Likewise.
(value_format): Likewise.
(output_die): Likewise.
(add_const_value_attribute) : Call add_AT_double
instead of add_AT_long_long.
(add_bound_info) : Generate the bound as an unsigned
value with the precision of its type.

http://gcc.gnu.org/ml/gcc-patches/2009-07/msg00653.html

This was done by using add_AT_double whenever a constant needed to be
output that didn't fit a HOST_WIDE_INT. It also changed the representation
of DW_AT_lower_bound and DW_AT_higher_bound when the range did fit in a
HOST_WIDE_INT. Up to that patch the range values were added
using add_AT_unsigned. But to represent signed values it didn't use
add_AT_int, but used an unsigned value with the precision of its type.

As the comment added at the time says:
"The precision and signedness of the type will be necessary to re-interpret
it unambiguously."

This is a little unfortunate. Since in other cases this isn't necessary.
In particular in all other cases gdb and other DWARF consumers (elfutils at
least) assume that when they encounter a DW_FORM_data[1248] they can simply
zero-extend it to get the actual constant value. Or that DW_FORM_sdata is
used to represent an actual negative constant. (There are a couple of
comments about relying on this behavior in both the gcc and gdb sources.)

So the patch below makes it so that if HOST_WIDE_INT is wide enough then,
depending on whether the range type is signed or not, add_AT_unsigned or
add_AT_int is used. This is more efficient for small ranges. And makes it
so that the value can be deduced from the DW_FORM by the consumer (which
can assume again that DW_FORM_data[1248] are simply zero-extended and
that negative constant values are represented by DW_FORM_sdata).

I tested this on x86_64 with --enable-languages=c,ada,c++,fortran,java,objc
without regressions. I also made sure that the example ada program range
is recognized correctly by gdb with this patch.

A couple of questions:

- Are there more ada DWARF tests? Something like guality used for c/fortran?
- What values of HOST_BITS_PER_WIDE_INT are actually supported in GCC?
  The dwarf2out.c code tries to handle 8, 16, 32 and 64 bits for
  dw_val_class_const_double.
- Which setups use 32bit (or lower?) HOST_BITS_PER_WIDE_INT?
  i686 seems to require 64BIT HOST_WIDE_INTs too these days.

I would like to test a bit on a setup that uses HOST_BITS_PER_WIDE_INT < 64
because currently I believe the use of add_AT_double is slightly wrong in
dwarf2out. It looks like a DWARF consumer can no longer rely on simply
zero-extending DW_FORM_data[1248] values if add_AT_double is used. And
add_AT_double is currently used for two slightly different things. To output
constant class values (such as bounds) that don't fit a HOST_WIDE_INT and
to output large (block class) values for DW_AT_const_value. But these are
not always similar (constants class values cannot be represented by
DW_FORM_block for example). So it would be good to at least have a
add_AT_double_unsigned and add_AT_double_int that can be used just like
add_AT_unsigned and add_AT_int. That seems to also require some additions
to be able to output DW_FORM_sdata for constants larger than HOST_WIDE_INT
in dwarf2asm. Any thoughts on this?

Thanks,

Mark

---
 gcc/dwarf2out.c |   32 
 1 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 2b584a5..9f8b3b0 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -16198,21 +16198,29 @@ add_bound_info (dw_die_ref subrange_die, enum 
dwarf_attribute bound_attr, tree b
&& tree_to_shwi (bound) == dflt)
  ;
 
-   /* Otherwise represent the bound as an unsigned value with the
-  precision of its type.  The precision and signedness of the
-  type will be necessary to re-interpret it unambiguously.  */
-   else if (prec < HOST_BITS_PER_WIDE_INT)
+   /* If HOST_WIDE_INT is big enough then represent the bound as
+  a constant value.  Note that we need to make sure the type
+  is signed or unsigned.  We cannot just add an unsigned
+  constant if the value itself is positive.  Some DWARF
+  consumers will lookup the bounds type and then sign extend
+  any unsigned values found for signed types.  This is only
+  for DW_AT_lower_bound, 

[PATCH] Support spu-elf in libstdc++ crossconfig.m4

2014-03-20 Thread Ulrich Weigand
Hello,

currently, there is no support for spu-elf in crossconfig.m4.  In the past,
we've usually worked around this by configuring GCC with --with-newlib.

But that has other drawbacks since it performs no link tests at all, and
thus assumes only a very minimal set of features available via newlib.

This has become a problem since libgfortran switched to respecting
--with-newlib; now many tests fail due to supposedly unavailable
library features, which newlib actually would support -- on SPU.

So we want to move away from using --with-newlib and do the normal
link-time tests, even though the library still is newlib.  (The link
checks will work fine if you actually have an SPU library installed.)

That now breaks libstdc++ builds due to missing crossconfig.m4 support.
The patch below adds such support, by performing the usual link checks.
The only missing features (as compared to the -linux crossconfig.m4
entry) are TLS (SPU is single-threaded), and random (SPU code should
not access /dev files on the host).

Tested on spu-elf.
OK for mainline?

Bye,
Ulrich


ChangeLog:

* crossconfig.m4: Support spu-*-elf* targets.
* configure: Regenerate.

Index: libstdc++-v3/crossconfig.m4
===
*** libstdc++-v3/crossconfig.m4 (revision 208613)
--- libstdc++-v3/crossconfig.m4 (working copy)
*** case "${host}" in
*** 28,33 
--- 28,41 
  AC_DEFINE(HAVE_SQRTF)
  ;;
  
+   spu-*-elf*)
+ GLIBCXX_CHECK_COMPILER_FEATURES
+ GLIBCXX_CHECK_LINKER_FEATURES
+ GLIBCXX_CHECK_MATH_SUPPORT
+ GLIBCXX_CHECK_STDLIB_SUPPORT
+ AM_ICONV
+ ;;
+ 
*-aix*)
  GLIBCXX_CHECK_LINKER_FEATURES
  GLIBCXX_CHECK_MATH_SUPPORT



Re: [PATCH] Support spu-elf in libstdc++ crossconfig.m4

2014-03-20 Thread Jonathan Wakely
On 20 March 2014 18:04, Ulrich Weigand wrote:
> Hello,
>
> currently, there is no support for spu-elf in crossconfig.m4.  In the past,
> we've usually worked around this by configuring GCC with --with-newlib.
>
> But that has other drawbacks since it performs no link tests at all, and
> thus assumes only a very minimal set of features available via newlib.
>
> This has become a problem since libgfortran switched to respecting
> --with-newlib; now many tests fail due to supposedly unavailable
> library features, which newlib actually would support -- on SPU.

So this fixes a regression?


Re: extending constants in rtl

2014-03-20 Thread Mike Stump
On Mar 17, 2014, at 8:36 PM, Mike Stump  wrote:
> So, to support things like this:
> 
> (define_constants
>   (C1_TEMP_REGNUM  PROLOGUE_SCRATCH_1)
>   (C1_TEMP2_REGNUM PROLOGUE_SCRATCH_2)


> Absent a better solution, I’d like to pursue this.

So, it turns out the patch won’t do what I really wanted to do and the amount 
of extending the .md language would be more extensive that I had hoped for, so 
I’m withdrawing it. I can generate some .md content early on with a .c program 
and just use the generated content directly.  This bridges the gap nicely and 
is easy to implement.


Re: [PATCH] Support spu-elf in libstdc++ crossconfig.m4

2014-03-20 Thread Ulrich Weigand
Jonathan Wakely wrote:
> On 20 March 2014 18:04, Ulrich Weigand wrote:
> > Hello,
> >
> > currently, there is no support for spu-elf in crossconfig.m4.  In the past,
> > we've usually worked around this by configuring GCC with --with-newlib.
> >
> > But that has other drawbacks since it performs no link tests at all, and
> > thus assumes only a very minimal set of features available via newlib.
> >
> > This has become a problem since libgfortran switched to respecting
> > --with-newlib; now many tests fail due to supposedly unavailable
> > library features, which newlib actually would support -- on SPU.
> 
> So this fixes a regression?

Yes.  Using this patch allows building without --with-newlib, which
in turn gets the Fortran test suite back into shape as it was before
this patch was applied:
http://gcc.gnu.org/ml/fortran/2013-06/msg00115.html

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  ulrich.weig...@de.ibm.com



Re: [GOOGLE] update ssa before compute_inline_parameters

2014-03-20 Thread Xinliang David Li
I think the right way to fix this is to wrap the call to early_inliner
and check the TODO flags.  See execute_function_todo:

 if (flags & TODO_cleanup_cfg)
{
  cleanup_tree_cfg ();

  if (!(flags & TODO_update_ssa_any) && need_ssa_update_p (cfun))
flags |= TODO_update_ssa;
}

  if (flags & TODO_update_ssa_any)
{
  unsigned update_flags = flags & TODO_update_ssa_any;
  update_ssa (update_flags);
  cfun->last_verified &= ~TODO_verify_ssa;
}

David

On Thu, Mar 20, 2014 at 10:39 AM, Dehao Chen  wrote:
> This patch calls update_ssa before compute_inline_paramters.
>
> Bootstrapped and perf test on-going.
>
> OK for google-4_8?
>
> Thanks,
> Dehao
>
> Index: gcc/auto-profile.c
> ===
> --- gcc/auto-profile.c (revision 208726)
> +++ gcc/auto-profile.c (working copy)
> @@ -1613,6 +1613,7 @@ auto_profile (void)
>early_inliner ();
>   }
>
> +  update_ssa (TODO_update_ssa);
>compute_inline_parameters (cgraph_get_node (current_function_decl),
> true);
>early_inliner ();
>autofdo::afdo_annotate_cfg (promoted_stmts);
>


Re: [PATCH, PR 59176] Mark "zombie" call graph nodes to remove verifier false positive

2014-03-20 Thread Jakub Jelinek
On Thu, Mar 20, 2014 at 05:07:32PM +0100, Martin Jambor wrote:
> in the PR, verifier claims an edge is pointing to a wrong declaration
> even though it has successfully verified the edge multiple times
> before.  The reason is that symtab_remove_unreachable_nodes decides to
> "remove the body" of a node and also clear any information that it is
> an alias of another in the process (more detailed analysis in comment
> #9 of the bug).
> 
> In bugzilla Honza wrote that "silencing the verifier" is the way to
> go.  Either we can dedicate a new flag in each cgraph_node or
> symtab_node just for the purpose of verification or do something more
> hackish like the patch below which re-uses the former_clone_of field
> for this purpose.  Since clones are always private nodes, they should
> always either survive removal of unreachable nodes or be completely
> killed by it and should never enter the in_border zombie state.
> Therefore their former_clone_of must always be NULL.  So I added a new
> special value, error_mark_node, to mark this zombie state and taught
> the verifier to be happy with such nodes.
> 
> Bootstrapped and tested on x86_64-linux.  What do you think?

Don't we have like 22 spare bits in cgraph_node and 20 spare bits in
symtab_node?  I'd find it clearer if you just used a new flag to mark the
zombie nodes.  Though, I'll let Richard or Honza to decide, don't feel
strongly about it.

Jakub


Re: [PATCH] Support spu-elf in libstdc++ crossconfig.m4

2014-03-20 Thread Jonathan Wakely
On 20 March 2014 18:31, Ulrich Weigand wrote:
> Jonathan Wakely wrote:
>> On 20 March 2014 18:04, Ulrich Weigand wrote:
>> > Hello,
>> >
>> > currently, there is no support for spu-elf in crossconfig.m4.  In the past,
>> > we've usually worked around this by configuring GCC with --with-newlib.
>> >
>> > But that has other drawbacks since it performs no link tests at all, and
>> > thus assumes only a very minimal set of features available via newlib.
>> >
>> > This has become a problem since libgfortran switched to respecting
>> > --with-newlib; now many tests fail due to supposedly unavailable
>> > library features, which newlib actually would support -- on SPU.
>>
>> So this fixes a regression?
>
> Yes.  Using this patch allows building without --with-newlib, which
> in turn gets the Fortran test suite back into shape as it was before
> this patch was applied:
> http://gcc.gnu.org/ml/fortran/2013-06/msg00115.html

This is OK for mainline then, since it fixes a regression (and only
affects the spu-elf target anyway).

Thanks.


Re: [gomp4] Add tables generation

2014-03-20 Thread Jakub Jelinek
On Thu, Mar 20, 2014 at 05:50:13PM +0100, Bernd Schmidt wrote:
> --- libgcc/crtstuff.c (revision 208706)
> +++ libgcc/crtstuff.c (working copy)
> @@ -311,6 +311,15 @@ register_tm_clones (void)
>  }
>  #endif /* USE_TM_CLONE_REGISTRY */
>  
> +#if defined(HAVE_GAS_HIDDEN) && defined(ENABLE_OFFLOADING)
> +void *_omp_func_table[0]
> +  __attribute__ ((__used__, visibility ("protected"),
> +   section (".offload_func_table_section"))) = { };
> +void *_omp_var_table[0]
> +  __attribute__ ((__used__, visibility ("protected"),
> +   section (".offload_var_table_section"))) = { };
> +#endif
> +
>  #if defined(INIT_SECTION_ASM_OP) || defined(INIT_ARRAY_SECTION_ASM_OP)
>  
>  #ifdef OBJECT_FORMAT_ELF
> @@ -752,6 +761,23 @@ __do_global_ctors (void)
>  #error "What are you doing with crtstuff.c, then?"
>  #endif
>  
> +#if defined(HAVE_GAS_HIDDEN) && defined(ENABLE_OFFLOADING)
> +void *_omp_funcs_end[0]
> +  __attribute__ ((__used__, visibility ("protected"),
> +   section (".offload_func_table_section"))) = { };
> +void *_omp_vars_end[0]
> +  __attribute__ ((__used__, visibility ("protected"),
> +   section (".offload_var_table_section"))) = { };
> +extern void *_omp_func_table[];
> +extern void *_omp_var_table[];
> +void *__OPENMP_TARGET__[] __attribute__ ((__visibility__ ("protected"))) =
> +{
> +  &_omp_func_table, &_omp_funcs_end,
> +  &_omp_var_table, &_omp_vars_end
> +};
> +#endif
> +
> +
>  #else /* ! CRT_BEGIN && ! CRT_END */
>  #error "One of CRT_BEGIN or CRT_END must be defined."
>  #endif

I don't like these libgcc changes at all.

First of all, we should find a way which has no runtime costs for at least
programs not compiled with -fopenmp/-fopenacc at all, preferrably no runtime
cost for any program or shared library that actually doesn't contain any
offloading code.  The above costs every single binary/shared library 5
exported symbols (with the worst ever visibility, protected should basically
never be used, it is even more costly than normal symbol visibility, why it
isn't just hidden?) and 4 * sizeof (void *) bytes in data section and 4
runtime relocations (with the protected visibility costly ones).

When we were discussing the design last year, my strong preference was that
either this lives in some other crt object that mkoffload/linker plugin adds
to link, or that it would be completely mkoffload synthetized.

Also, I'd prefer if __OPENMP_TARGET__ header was as compact as possible for the
case when there is nothing to offload (ideally, if __OPENMP_TARGET__ symbol
is never referenced, not create it at all, if it is referenced, but there is
nothing to offload, say just a single 0 byte, otherwise say an uleb128
number how many different kinds of offload data there are and then for each
one some identification which offload it is for, the tables, where to find
it.

Jakub


[Testsuite, Patch] Fix testsuite/lib/gcc-dg.exp's scan-module-absence

2014-03-20 Thread Tobias Burnus
gfortran's modules are since GCC 4.9 zipped. There are two functions, 
which test for the existence and absent of strings in the .mod files.


While one was updated to apply gunzip before reading, the other wasn't. 
This patch copies over the unzip call from the other function. I have 
tested it that it properly fails if and only if the string is present in 
the (uncompressed) .mod file.


OK for the trunk?

Tobias

PS: Thanks to Dominique for pointing out this problem!
2014-03-20  Tobias Burnus  

	PR fortran/60599
	* lib/gcc-dg.exp (scan-module): Uncompress .mod files for
	reading.

diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 59d394c..f9d52bc 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -656,7 +656,7 @@ proc scan-module { args } {
 # Argument 1 is the regexp to match
 proc scan-module-absence { args } {
 set modfilename [string tolower [lindex $args 0]].mod
-set fd [open $modfilename r]
+set fd [open [list | gzip -dc $modfilename] r]
 set text [read $fd]
 close $fd
 


Re: [C++ PATCH] Fix ICE in build_zero_init_1 (PR c++/60572)

2014-03-20 Thread Jason Merrill

OK.

Jason


Re: [PATCH, PR 59176] Mark "zombie" call graph nodes to remove verifier false positive

2014-03-20 Thread Martin Jambor
Hi,

On Thu, Mar 20, 2014 at 07:40:56PM +0100, Jakub Jelinek wrote:
> On Thu, Mar 20, 2014 at 05:07:32PM +0100, Martin Jambor wrote:
> > in the PR, verifier claims an edge is pointing to a wrong declaration
> > even though it has successfully verified the edge multiple times
> > before.  The reason is that symtab_remove_unreachable_nodes decides to
> > "remove the body" of a node and also clear any information that it is
> > an alias of another in the process (more detailed analysis in comment
> > #9 of the bug).
> > 
> > In bugzilla Honza wrote that "silencing the verifier" is the way to
> > go.  Either we can dedicate a new flag in each cgraph_node or
> > symtab_node just for the purpose of verification or do something more
> > hackish like the patch below which re-uses the former_clone_of field
> > for this purpose.  Since clones are always private nodes, they should
> > always either survive removal of unreachable nodes or be completely
> > killed by it and should never enter the in_border zombie state.
> > Therefore their former_clone_of must always be NULL.  So I added a new
> > special value, error_mark_node, to mark this zombie state and taught
> > the verifier to be happy with such nodes.
> > 
> > Bootstrapped and tested on x86_64-linux.  What do you think?
> 
> Don't we have like 22 spare bits in cgraph_node and 20 spare bits in
> symtab_node?  I'd find it clearer if you just used a new flag to mark the
> zombie nodes.  Though, I'll let Richard or Honza to decide, don't feel
> strongly about it.
> 

I guess you are right, here is the proper version which is currently
undergoing bootstrap and testing.

Thanks,

Martin

2014-03-20  Martin Jambor  

PR ipa/59176
* cgraph.h (symtab_node): New flag body_removed.
* ipa.c (symtab_remove_unreachable_nodes): Set body_removed flag
when removing bodies.
* symtab.c (dump_symtab_base): Dump body_removed flag.
* cgraph.c (verify_edge_corresponds_to_fndecl): Skip nodes which
had their bodies removed.

testsuite/
* g++.dg/torture/pr59176.C: New test.

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index a15b6bc..fb6880c 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -2601,8 +2601,13 @@ verify_edge_corresponds_to_fndecl (struct cgraph_edge 
*e, tree decl)
   node = cgraph_get_node (decl);
 
   /* We do not know if a node from a different partition is an alias or what it
- aliases and therefore cannot do the former_clone_of check reliably.  */
-  if (!node || node->in_other_partition || e->callee->in_other_partition)
+ aliases and therefore cannot do the former_clone_of check reliably.  When
+ body_removed is set, we have lost all information about what was alias or
+ thunk of and also cannot proceed.  */
+  if (!node
+  || node->body_removed
+  || node->in_other_partition
+  || e->callee->in_other_partition)
 return false;
   node = cgraph_function_or_thunk_node (node, NULL);
 
diff --git a/gcc/cgraph.h b/gcc/cgraph.h
index 32b1ee1..59d9ce6 100644
--- a/gcc/cgraph.h
+++ b/gcc/cgraph.h
@@ -91,7 +91,9 @@ public:
   unsigned forced_by_abi : 1;
   /* True when the name is known to be unique and thus it does not need 
mangling.  */
   unsigned unique_name : 1;
-
+  /* True when body and other characteristics have been removed by
+ symtab_remove_unreachable_nodes. */
+  unsigned body_removed : 1;
 
   /*** WHOPR Partitioning flags.
These flags are used at ltrans stage when only part of the callgraph is
diff --git a/gcc/ipa.c b/gcc/ipa.c
index 572dba1..4a8c6b7 100644
--- a/gcc/ipa.c
+++ b/gcc/ipa.c
@@ -484,6 +484,7 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, 
FILE *file)
{
  if (file)
fprintf (file, " %s", node->name ());
+ node->body_removed = true;
  node->analyzed = false;
  node->definition = false;
  node->cpp_implicit_alias = false;
@@ -542,6 +543,7 @@ symtab_remove_unreachable_nodes (bool before_inlining_p, 
FILE *file)
fprintf (file, " %s", vnode->name ());
  changed = true;
}
+ vnode->body_removed = true;
  vnode->definition = false;
  vnode->analyzed = false;
  vnode->aux = NULL;
diff --git a/gcc/symtab.c b/gcc/symtab.c
index 5d69803..0ce8e8e 100644
--- a/gcc/symtab.c
+++ b/gcc/symtab.c
@@ -601,6 +601,8 @@ dump_symtab_base (FILE *f, symtab_node *node)
 ? IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME
 (node->alias_target))
 : IDENTIFIER_POINTER (node->alias_target));
+  if (node->body_removed)
+fprintf (f, "\n  Body removed by symtab_remove_unreachable_nodes");
   fprintf (f, "\n  Visibility:");
   if (node->in_other_partition)
 fprintf (f, " in_other_partition");
diff --git a/gcc/testsuite/g++.dg/ipa/pr59176.C 
b/gcc/testsuite/g++.dg/ipa/pr59176.C
new file mode 100644
index 000..d576bc3
--- /dev/null
+++ b/gcc/testsuite/g

Go patch committed: Fix bug leading to invalid initializer loop report

2014-03-20 Thread Ian Lance Taylor
This patch by Chris Manghane fixes a bug in which gccgo could
incorrectly report an invalid initializer loop when a struct field name
is confused with a variable name.  This is http://golang.org/issue/7590.
Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

diff -r d43179a88410 go/expressions.cc
--- a/go/expressions.cc	Mon Mar 17 21:25:04 2014 -0700
+++ b/go/expressions.cc	Thu Mar 20 11:49:49 2014 -0700
@@ -12993,6 +12993,20 @@
 {
   // The type may not be resolvable at this point.
   Type* type = this->type_;
+
+  for (int depth = this->depth_; depth > 0; --depth)
+{
+  if (type->array_type() != NULL)
+type = type->array_type()->element_type();
+  else if (type->map_type() != NULL)
+type = type->map_type()->val_type();
+  else
+{
+  // This error will be reported during lowering.
+  return TRAVERSE_CONTINUE;
+}
+}
+
   while (true)
 	{
 	  if (type->classification() == Type::TYPE_NAMED)


Re: [GOOGLE] update ssa before compute_inline_parameters

2014-03-20 Thread Dehao Chen
Patch updated to add a wrapper early_inline function

Index: gcc/auto-profile.c
===
--- gcc/auto-profile.c (revision 208726)
+++ gcc/auto-profile.c (working copy)
@@ -1449,8 +1449,6 @@ afdo_vpt_for_early_inline (stmt_set *promoted_stmt
   calculate_dominance_info (CDI_POST_DOMINATORS);
   calculate_dominance_info (CDI_DOMINATORS);
   rebuild_cgraph_edges ();
-  update_ssa (TODO_update_ssa);
-  compute_inline_parameters (cgraph_get_node
(current_function_decl), true);
   return true;
 }
   else
@@ -1516,6 +1514,14 @@ afdo_annotate_cfg (const stmt_set &promoted_stmts)
 }
 }  /* namespace autofdo.  */

+static void early_inline ()
+{
+  compute_inline_parameters (cgraph_get_node (current_function_decl), true);
+  unsigned todo = early_inliner ();
+  if (todo & TODO_update_ssa_any)
+update_ssa (TODO_update_ssa);
+}
+
 /* Use AutoFDO profile to annoate the control flow graph.
Return the todo flag.  */

@@ -1610,11 +1616,10 @@ auto_profile (void)
   if (!flag_value_profile_transformations
   || !autofdo::afdo_vpt_for_early_inline (&promoted_stmts))
 break;
-  early_inliner ();
+  early_inline ();
  }

-  compute_inline_parameters (cgraph_get_node
(current_function_decl), true);
-  early_inliner ();
+  early_inline ();
   autofdo::afdo_annotate_cfg (promoted_stmts);
   compute_function_frequency ();
   update_ssa (TODO_update_ssa);

On Thu, Mar 20, 2014 at 11:36 AM, Xinliang David Li  wrote:
> I think the right way to fix this is to wrap the call to early_inliner
> and check the TODO flags.  See execute_function_todo:
>
>  if (flags & TODO_cleanup_cfg)
> {
>   cleanup_tree_cfg ();
>
>   if (!(flags & TODO_update_ssa_any) && need_ssa_update_p (cfun))
> flags |= TODO_update_ssa;
> }
>
>   if (flags & TODO_update_ssa_any)
> {
>   unsigned update_flags = flags & TODO_update_ssa_any;
>   update_ssa (update_flags);
>   cfun->last_verified &= ~TODO_verify_ssa;
> }
>
> David
>
> On Thu, Mar 20, 2014 at 10:39 AM, Dehao Chen  wrote:
>> This patch calls update_ssa before compute_inline_paramters.
>>
>> Bootstrapped and perf test on-going.
>>
>> OK for google-4_8?
>>
>> Thanks,
>> Dehao
>>
>> Index: gcc/auto-profile.c
>> ===
>> --- gcc/auto-profile.c (revision 208726)
>> +++ gcc/auto-profile.c (working copy)
>> @@ -1613,6 +1613,7 @@ auto_profile (void)
>>early_inliner ();
>>   }
>>
>> +  update_ssa (TODO_update_ssa);
>>compute_inline_parameters (cgraph_get_node (current_function_decl),
>> true);
>>early_inliner ();
>>autofdo::afdo_annotate_cfg (promoted_stmts);
>>


[committed] Fix a DEBUG_INSN related invalid RTL sharing bug in IRA (PR middle-end/60597)

2014-03-20 Thread Jakub Jelinek
Hi!

This patch fixes a RTL sharing issue, if *reg_equiv[REGNO (loc)].src_p
is e.g. a MEM and the cleared reg would be used in more than one
DEBUG_INSN or more than once in a single one, we'd incorrectly share it,
which can result e.g. in DF verification issue - change of one DEBUG_INSN
with the shared MEM results in a df insn rescan, but on the other DEBUG_INSN
no changes would be performed and thus rescanning wouldn't be performed.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk as obvious.

2014-03-20  Jakub Jelinek  

PR middle-end/60597
* ira.c (adjust_cleared_regs): Call copy_rtx on
*reg_equiv[REGNO (loc)].src_p before passing it to
simplify_replace_fn_rtx.

* g++.dg/opt/pr60597.C: New test.

--- gcc/ira.c.jj2014-01-25 00:16:53.0 +0100
+++ gcc/ira.c   2014-03-20 16:35:11.881516283 +0100
@@ -3428,7 +3428,7 @@ adjust_cleared_regs (rtx loc, const_rtx
 {
   bitmap cleared_regs = (bitmap) data;
   if (bitmap_bit_p (cleared_regs, REGNO (loc)))
-   return simplify_replace_fn_rtx (*reg_equiv[REGNO (loc)].src_p,
+   return simplify_replace_fn_rtx (copy_rtx (*reg_equiv[REGNO 
(loc)].src_p),
NULL_RTX, adjust_cleared_regs, data);
 }
   return NULL_RTX;
--- gcc/testsuite/g++.dg/opt/pr60597.C.jj   2014-03-20 16:34:40.915677263 
+0100
+++ gcc/testsuite/g++.dg/opt/pr60597.C  2014-03-20 16:34:21.0 +0100
@@ -0,0 +1,46 @@
+// PR middle-end/60597
+// { dg-do compile }
+// { dg-options "-O2 -g" }
+
+struct A
+{
+  int foo () const;
+  int bar () const;
+  int a;
+};
+
+struct B
+{
+  int foo ();
+  int bar ();
+};
+
+int *c, d;
+
+int
+A::foo () const
+{
+  int b = a >> 16;
+  return b;
+}
+
+int
+A::bar () const
+{
+  int b = a;
+  return b;
+}
+
+void
+baz (A &x, B h, int i, int j)
+{
+  for (; i < h.bar (); ++i)
+for (; h.foo (); ++j)
+  {
+   int g = x.foo ();
+   int f = x.bar ();
+   int e = c[0] & 1;
+   d = (e << 1) | (g << 16) | (f & 1);
+   c[j] = 0;
+  }
+}

Jakub


Re: [GOOGLE] update ssa before compute_inline_parameters

2014-03-20 Thread Xinliang David Li
On Thu, Mar 20, 2014 at 12:40 PM, Dehao Chen  wrote:
> Patch updated to add a wrapper early_inline function
>
> Index: gcc/auto-profile.c
> ===
> --- gcc/auto-profile.c (revision 208726)
> +++ gcc/auto-profile.c (working copy)
> @@ -1449,8 +1449,6 @@ afdo_vpt_for_early_inline (stmt_set *promoted_stmt
>calculate_dominance_info (CDI_POST_DOMINATORS);
>calculate_dominance_info (CDI_DOMINATORS);
>rebuild_cgraph_edges ();
> -  update_ssa (TODO_update_ssa);
> -  compute_inline_parameters (cgraph_get_node
> (current_function_decl), true);
>return true;
>  }
>else
> @@ -1516,6 +1514,14 @@ afdo_annotate_cfg (const stmt_set &promoted_stmts)
>  }
>  }  /* namespace autofdo.  */
>
> +static void early_inline ()
> +{
> +  compute_inline_parameters (cgraph_get_node (current_function_decl), true);
> +  unsigned todo = early_inliner ();
> +  if (todo & TODO_update_ssa_any)
> +update_ssa (TODO_update_ssa);
> +}
> +
>  /* Use AutoFDO profile to annoate the control flow graph.
> Return the todo flag.  */
>
> @@ -1610,11 +1616,10 @@ auto_profile (void)
>if (!flag_value_profile_transformations
>|| !autofdo::afdo_vpt_for_early_inline (&promoted_stmts))
>  break;
> -  early_inliner ();
> +  early_inline ();
>   }
>
> -  compute_inline_parameters (cgraph_get_node
> (current_function_decl), true);
> -  early_inliner ();
> +  early_inline ();
>autofdo::afdo_annotate_cfg (promoted_stmts);
>compute_function_frequency ();
>update_ssa (TODO_update_ssa);

Is this update still needed?

David

>
> On Thu, Mar 20, 2014 at 11:36 AM, Xinliang David Li  
> wrote:
>> I think the right way to fix this is to wrap the call to early_inliner
>> and check the TODO flags.  See execute_function_todo:
>>
>>  if (flags & TODO_cleanup_cfg)
>> {
>>   cleanup_tree_cfg ();
>>
>>   if (!(flags & TODO_update_ssa_any) && need_ssa_update_p (cfun))
>> flags |= TODO_update_ssa;
>> }
>>
>>   if (flags & TODO_update_ssa_any)
>> {
>>   unsigned update_flags = flags & TODO_update_ssa_any;
>>   update_ssa (update_flags);
>>   cfun->last_verified &= ~TODO_verify_ssa;
>> }
>>
>> David
>>
>> On Thu, Mar 20, 2014 at 10:39 AM, Dehao Chen  wrote:
>>> This patch calls update_ssa before compute_inline_paramters.
>>>
>>> Bootstrapped and perf test on-going.
>>>
>>> OK for google-4_8?
>>>
>>> Thanks,
>>> Dehao
>>>
>>> Index: gcc/auto-profile.c
>>> ===
>>> --- gcc/auto-profile.c (revision 208726)
>>> +++ gcc/auto-profile.c (working copy)
>>> @@ -1613,6 +1613,7 @@ auto_profile (void)
>>>early_inliner ();
>>>   }
>>>
>>> +  update_ssa (TODO_update_ssa);
>>>compute_inline_parameters (cgraph_get_node (current_function_decl),
>>> true);
>>>early_inliner ();
>>>autofdo::afdo_annotate_cfg (promoted_stmts);
>>>


Re: [GOOGLE] update ssa before compute_inline_parameters

2014-03-20 Thread Dehao Chen
On Thu, Mar 20, 2014 at 1:02 PM, Xinliang David Li  wrote:
> On Thu, Mar 20, 2014 at 12:40 PM, Dehao Chen  wrote:
>> Patch updated to add a wrapper early_inline function
>>
>> Index: gcc/auto-profile.c
>> ===
>> --- gcc/auto-profile.c (revision 208726)
>> +++ gcc/auto-profile.c (working copy)
>> @@ -1449,8 +1449,6 @@ afdo_vpt_for_early_inline (stmt_set *promoted_stmt
>>calculate_dominance_info (CDI_POST_DOMINATORS);
>>calculate_dominance_info (CDI_DOMINATORS);
>>rebuild_cgraph_edges ();
>> -  update_ssa (TODO_update_ssa);
>> -  compute_inline_parameters (cgraph_get_node
>> (current_function_decl), true);
>>return true;
>>  }
>>else
>> @@ -1516,6 +1514,14 @@ afdo_annotate_cfg (const stmt_set &promoted_stmts)
>>  }
>>  }  /* namespace autofdo.  */
>>
>> +static void early_inline ()
>> +{
>> +  compute_inline_parameters (cgraph_get_node (current_function_decl), true);
>> +  unsigned todo = early_inliner ();
>> +  if (todo & TODO_update_ssa_any)
>> +update_ssa (TODO_update_ssa);
>> +}
>> +
>>  /* Use AutoFDO profile to annoate the control flow graph.
>> Return the todo flag.  */
>>
>> @@ -1610,11 +1616,10 @@ auto_profile (void)
>>if (!flag_value_profile_transformations
>>|| !autofdo::afdo_vpt_for_early_inline (&promoted_stmts))
>>  break;
>> -  early_inliner ();
>> +  early_inline ();
>>   }
>>
>> -  compute_inline_parameters (cgraph_get_node
>> (current_function_decl), true);
>> -  early_inliner ();
>> +  early_inline ();
>>autofdo::afdo_annotate_cfg (promoted_stmts);
>>compute_function_frequency ();
>>update_ssa (TODO_update_ssa);
>
> Is this update still needed?

Yes because in autofdo::afdo_annotate_cfg,
gimple_value_profile_transformations is invoked.

Dehao

>
> David
>
>>
>> On Thu, Mar 20, 2014 at 11:36 AM, Xinliang David Li  
>> wrote:
>>> I think the right way to fix this is to wrap the call to early_inliner
>>> and check the TODO flags.  See execute_function_todo:
>>>
>>>  if (flags & TODO_cleanup_cfg)
>>> {
>>>   cleanup_tree_cfg ();
>>>
>>>   if (!(flags & TODO_update_ssa_any) && need_ssa_update_p (cfun))
>>> flags |= TODO_update_ssa;
>>> }
>>>
>>>   if (flags & TODO_update_ssa_any)
>>> {
>>>   unsigned update_flags = flags & TODO_update_ssa_any;
>>>   update_ssa (update_flags);
>>>   cfun->last_verified &= ~TODO_verify_ssa;
>>> }
>>>
>>> David
>>>
>>> On Thu, Mar 20, 2014 at 10:39 AM, Dehao Chen  wrote:
 This patch calls update_ssa before compute_inline_paramters.

 Bootstrapped and perf test on-going.

 OK for google-4_8?

 Thanks,
 Dehao

 Index: gcc/auto-profile.c
 ===
 --- gcc/auto-profile.c (revision 208726)
 +++ gcc/auto-profile.c (working copy)
 @@ -1613,6 +1613,7 @@ auto_profile (void)
early_inliner ();
   }

 +  update_ssa (TODO_update_ssa);
compute_inline_parameters (cgraph_get_node (current_function_decl),
 true);
early_inliner ();
autofdo::afdo_annotate_cfg (promoted_stmts);



Re: [GOOGLE] update ssa before compute_inline_parameters

2014-03-20 Thread Xinliang David Li
The patch is ok.

David

On Thu, Mar 20, 2014 at 1:10 PM, Dehao Chen  wrote:
> On Thu, Mar 20, 2014 at 1:02 PM, Xinliang David Li  wrote:
>> On Thu, Mar 20, 2014 at 12:40 PM, Dehao Chen  wrote:
>>> Patch updated to add a wrapper early_inline function
>>>
>>> Index: gcc/auto-profile.c
>>> ===
>>> --- gcc/auto-profile.c (revision 208726)
>>> +++ gcc/auto-profile.c (working copy)
>>> @@ -1449,8 +1449,6 @@ afdo_vpt_for_early_inline (stmt_set *promoted_stmt
>>>calculate_dominance_info (CDI_POST_DOMINATORS);
>>>calculate_dominance_info (CDI_DOMINATORS);
>>>rebuild_cgraph_edges ();
>>> -  update_ssa (TODO_update_ssa);
>>> -  compute_inline_parameters (cgraph_get_node
>>> (current_function_decl), true);
>>>return true;
>>>  }
>>>else
>>> @@ -1516,6 +1514,14 @@ afdo_annotate_cfg (const stmt_set &promoted_stmts)
>>>  }
>>>  }  /* namespace autofdo.  */
>>>
>>> +static void early_inline ()
>>> +{
>>> +  compute_inline_parameters (cgraph_get_node (current_function_decl), 
>>> true);
>>> +  unsigned todo = early_inliner ();
>>> +  if (todo & TODO_update_ssa_any)
>>> +update_ssa (TODO_update_ssa);
>>> +}
>>> +
>>>  /* Use AutoFDO profile to annoate the control flow graph.
>>> Return the todo flag.  */
>>>
>>> @@ -1610,11 +1616,10 @@ auto_profile (void)
>>>if (!flag_value_profile_transformations
>>>|| !autofdo::afdo_vpt_for_early_inline (&promoted_stmts))
>>>  break;
>>> -  early_inliner ();
>>> +  early_inline ();
>>>   }
>>>
>>> -  compute_inline_parameters (cgraph_get_node
>>> (current_function_decl), true);
>>> -  early_inliner ();
>>> +  early_inline ();
>>>autofdo::afdo_annotate_cfg (promoted_stmts);
>>>compute_function_frequency ();
>>>update_ssa (TODO_update_ssa);
>>
>> Is this update still needed?
>
> Yes because in autofdo::afdo_annotate_cfg,
> gimple_value_profile_transformations is invoked.
>
> Dehao
>
>>
>> David
>>
>>>
>>> On Thu, Mar 20, 2014 at 11:36 AM, Xinliang David Li  
>>> wrote:
 I think the right way to fix this is to wrap the call to early_inliner
 and check the TODO flags.  See execute_function_todo:

  if (flags & TODO_cleanup_cfg)
 {
   cleanup_tree_cfg ();

   if (!(flags & TODO_update_ssa_any) && need_ssa_update_p (cfun))
 flags |= TODO_update_ssa;
 }

   if (flags & TODO_update_ssa_any)
 {
   unsigned update_flags = flags & TODO_update_ssa_any;
   update_ssa (update_flags);
   cfun->last_verified &= ~TODO_verify_ssa;
 }

 David

 On Thu, Mar 20, 2014 at 10:39 AM, Dehao Chen  wrote:
> This patch calls update_ssa before compute_inline_paramters.
>
> Bootstrapped and perf test on-going.
>
> OK for google-4_8?
>
> Thanks,
> Dehao
>
> Index: gcc/auto-profile.c
> ===
> --- gcc/auto-profile.c (revision 208726)
> +++ gcc/auto-profile.c (working copy)
> @@ -1613,6 +1613,7 @@ auto_profile (void)
>early_inliner ();
>   }
>
> +  update_ssa (TODO_update_ssa);
>compute_inline_parameters (cgraph_get_node (current_function_decl),
> true);
>early_inliner ();
>autofdo::afdo_annotate_cfg (promoted_stmts);
>


Re: [Build] libcilkrts/Makefile.am: Install cilk.h

2014-03-20 Thread Tobias Burnus
It turned out, that my testing of the original state was screwed up and 
cilk.h was actually installed - see R other/60589. (Sorry!) There is 
still another issue, but that I will by a new patch.


Reverted the patch of Rev. 208440 in Rev. 208736

Tobias


Tobias Burnus wrote:
The attached patch installs cilk.h such that "#include " 
works.


Bootstrapped on x86-64-gnu-linux.
OK for the trunk?

(If you wonder about the other changes in the generated-files diff: I 
think they are due to r205357, where configure.ac changed and 
configure was regenerated but Makefile.in and aclocal.m4 were not.)


Tobias




[Build] Don't install libcilkrt's include/cilk/ header files twice for multi-lib installations

2014-03-20 Thread Tobias Burnus
When looking at PR 60589, I saw that libcilk's header files are 
installed multiple times. On my x86-64-gnu-linux system, I have them as:


lib/gcc/x86_64-unknown-linux-gnu/4.9.0/include/cilk/*.h
lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/include/cilk/*.h

However, GCC only reads the latter - even with -m32. I think the 
attached patch does the right thing - at least it matches the other 
libraries and I only end up with the headers in lib64.


OK for the trunk?

* * *

Actually, libssp has the same issue: It also installs the headers twice. 
As I am not sure which projects all include libssp and where the 
development happens, I have not updated its Makefile.am.


Tobias
2014-03-20  Tobias Burnus  

PR other/60589
	* Makefile.am: Add nodist_ to the to-be-installed
	headers.
	* Makefile.in: Regenerate.

diff --git a/libcilkrts/Makefile.am b/libcilkrts/Makefile.am
index f2d13aa..4fa4d30 100644
--- a/libcilkrts/Makefile.am
+++ b/libcilkrts/Makefile.am
@@ -110,7 +110,7 @@ libcilkrts_la_LDFLAGS += -no-undefined
 # C/C++ header files for Cilk.
 # cilkincludedir = $(includedir)/cilk
 cilkincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include/cilk
-cilkinclude_HEADERS =  \
+nodist_cilkinclude_HEADERS =   \
   include/cilk/cilk_api.h  \
   include/cilk/cilk_api_linux.h\
   include/cilk/cilk.h  \
diff --git a/libcilkrts/Makefile.in b/libcilkrts/Makefile.in
index 092e2f7..9c10e7e 100644
--- a/libcilkrts/Makefile.in
+++ b/libcilkrts/Makefile.in
@@ -112,8 +112,7 @@ target_triplet = @target@
 DIST_COMMON = $(srcdir)/include/internal/rev.mk README ChangeLog \
 	$(srcdir)/Makefile.in $(srcdir)/Makefile.am \
 	$(top_srcdir)/configure $(am__configure_deps) \
-	$(srcdir)/../mkinstalldirs $(srcdir)/../depcomp \
-	$(cilkinclude_HEADERS)
+	$(srcdir)/../mkinstalldirs $(srcdir)/../depcomp
 
 # If we're building on Linux, use the Linux version script
 @LINUX_LINKER_SCRIPT_TRUE@am__append_1 = -Wl,--version-script,$(srcdir)/runtime/linux-symbols.ver
@@ -204,7 +203,7 @@ MULTIDIRS =
 MULTISUBDIR = 
 MULTIDO = true
 MULTICLEAN = true
-HEADERS = $(cilkinclude_HEADERS)
+HEADERS = $(nodist_cilkinclude_HEADERS)
 ETAGS = etags
 CTAGS = ctags
 ACLOCAL = @ACLOCAL@
@@ -245,8 +244,6 @@ LD = @LD@
 LDFLAGS = @LDFLAGS@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
-LIBSTDCXX_RAW_CXX_CXXFLAGS = @LIBSTDCXX_RAW_CXX_CXXFLAGS@
-LIBSTDCXX_RAW_CXX_LDFLAGS = @LIBSTDCXX_RAW_CXX_LDFLAGS@
 LIBTOOL = @LIBTOOL@
 LIPO = @LIPO@
 LN_S = @LN_S@
@@ -328,7 +325,6 @@ sysconfdir = @sysconfdir@
 target = @target@
 target_alias = @target_alias@
 target_cpu = @target_cpu@
-target_noncanonical = @target_noncanonical@
 target_os = @target_os@
 target_vendor = @target_vendor@
 toolexecdir = @toolexecdir@
@@ -403,7 +399,7 @@ libcilkrts_la_LDFLAGS = -version-info 5:0:0 -lpthread \
 # C/C++ header files for Cilk.
 # cilkincludedir = $(includedir)/cilk
 cilkincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include/cilk
-cilkinclude_HEADERS = \
+nodist_cilkinclude_HEADERS = \
   include/cilk/cilk_api.h  \
   include/cilk/cilk_api_linux.h\
   include/cilk/cilk.h  \
@@ -853,10 +849,10 @@ distclean-multi:
 	$(MULTICLEAN) $(AM_MAKEFLAGS) DO=distclean multi-clean # $(MAKE)
 maintainer-clean-multi:
 	$(MULTICLEAN) $(AM_MAKEFLAGS) DO=maintainer-clean multi-clean # $(MAKE)
-install-cilkincludeHEADERS: $(cilkinclude_HEADERS)
+install-nodist_cilkincludeHEADERS: $(nodist_cilkinclude_HEADERS)
 	@$(NORMAL_INSTALL)
 	test -z "$(cilkincludedir)" || $(MKDIR_P) "$(DESTDIR)$(cilkincludedir)"
-	@list='$(cilkinclude_HEADERS)'; test -n "$(cilkincludedir)" || list=; \
+	@list='$(nodist_cilkinclude_HEADERS)'; test -n "$(cilkincludedir)" || list=; \
 	for p in $$list; do \
 	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
 	  echo "$$d$$p"; \
@@ -866,9 +862,9 @@ install-cilkincludeHEADERS: $(cilkinclude_HEADERS)
 	  $(INSTALL_HEADER) $$files "$(DESTDIR)$(cilkincludedir)" || exit $$?; \
 	done
 
-uninstall-cilkincludeHEADERS:
+uninstall-nodist_cilkincludeHEADERS:
 	@$(NORMAL_UNINSTALL)
-	@list='$(cilkinclude_HEADERS)'; test -n "$(cilkincludedir)" || list=; \
+	@list='$(nodist_cilkinclude_HEADERS)'; test -n "$(cilkincludedir)" || list=; \
 	files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
 	test -n "$$files" || exit 0; \
 	echo " ( cd '$(DESTDIR)$(cilkincludedir)' && rm -f" $$files ")"; \
@@ -981,7 +977,7 @@ info: info-am
 
 info-am:
 
-install-data-am: install-cilkincludeHEADERS
+install-data-am: install-nodist_cilkincludeHEADERS
 
 install-dvi: install-dvi-am
 
@@ -1029,7 +1025,7 @@ ps: ps-am
 
 ps-am:
 
-uninstall-am: uninstall-cilkincludeHEADERS \
+uninstall-am: uninstall-nodist_cilkincludeHEADERS \
 	uninstall-toolexeclibLTLIBRARIES
 
 .MAKE: all-multi clean-multi distclean-multi install-am install-multi \
@@ -1040,17 +1036,18 @@ uninstall-am: uninstall-cilkincludeHEADERS \
 	clean-toolexeclibLTLIBRARIES ctags distclean distclean-compile \
 	distclean-generic distclean-libtool distclean-multi \
 

Re: PR libstdc++/60587

2014-03-20 Thread Jonathan Wakely

On 19/03/14 23:38 +0100, Paolo Carlini wrote:

On 19/03/14 21:39 +, Jonathan Wakely wrote:
I think the safe thing to do is (as I suggested at the time) to have a
trait saying which iterator types refer to contiguous memory. Our
debug mode only supports our own containers, so the ones which are
contiguous are known.  For 4.9.0 I think the right option is simply
to remove __foreign_iterator_aux3 and __foreign_iterator_aux4
completely. The fixed version of __foreign_iterator_aux2() can detect
when we have iterators referring to the same sequence, which is what
we really want to detect. That's what the attached patch does and what
I'm going to test.


With my suggested change we get an XPASS for
testsuite/23_containers/vector/debug/57779_neg.cc

An __is_contiguous trait would solve that.


Funny, I thought we already had it...


I think we might have added it and removed it at some point ... not
sure though.

This is what I plan to commit, it's almost a total rewrite of
__foreign_iterator()  :-(

Dereferencing invalid iterators is avoided by passing in both
iterators representing the range, not just the first.

The suspect pointer arithmetic that tries to determine if a pointer
points inside a container is made unnecessary by adding
__gnu_debug::_Is_contiguous_sequence, currently only true for
std::vector for all T except bool.  We don't need to make it true
for std::string because that defines _Insert_range_from_self_is_safe
instead, so we can never reach the code that depends on contiguous
storage. As a benefit of the rewrite it no longer depends on C++11 and
so works in C++98 mode.

The overload resolution issue is solved by consistently using
const-refs for the parameters of __foreign_iterator_aux2. I also added
another overload for debug iterators into different debug container
types, so they can be identified as foreign sooner, without calling
__foreign_iterator_aux3.

Everything passes for "make check check-debug", so I plan to commit it
tomorrow, unless anyone points out a problem.

commit f1b942879722242f21e5b4d2babae0fddcfb7a90
Author: Jonathan Wakely 
Date:   Thu Mar 20 19:23:23 2014 +

PR libstdc++/60587
* include/debug/functions.h (_Is_contiguous_sequence): Define.
(__foreign_iterator): Accept additional iterator. Do not dispatch on
iterator category.
(__foreign_iterator_aux2): Likewise. Add overload for iterators
from different types of debug container. Use _Is_contiguous_sequence
instead of is_lvalue_reference.
(__foreign_iterator_aux3): Accept additional iterator. Avoid
dereferencing past-the-end iterator.
(__foreign_iterator_aux4): Use const value_type* instead of
potentially user-defined const_pointer type.
* include/debug/macros.h (__glibcxx_check_insert_range): Fix comment
and pass end iterator to __gnu_debug::__foreign_iterator.
(__glibcxx_check_insert_range_after): Likewise.
(__glibcxx_check_max_load_factor): Fix comment.
* include/debug/vector (_Is_contiguous_sequence): Define partial
specializations.
* testsuite/23_containers/vector/debug/57779_neg.cc: Remove
-std=gnu++11 option and unused header.
* testsuite/23_containers/vector/debug/60587.cc: New.
* testsuite/23_containers/vector/debug/60587_neg.cc: New.

diff --git a/libstdc++-v3/include/debug/functions.h 
b/libstdc++-v3/include/debug/functions.h
index 5dda0c3..b48c36d 100644
--- a/libstdc++-v3/include/debug/functions.h
+++ b/libstdc++-v3/include/debug/functions.h
@@ -34,8 +34,8 @@
  // _Iter_base
 #include // for __is_integer
 #include // for __addressof and addressof
+# include   // for less
 #if __cplusplus >= 201103L
-# include   // for less and greater_equal
 # include   // for is_lvalue_reference 
and __and_
 #endif
 #include 
@@ -52,6 +52,9 @@ namespace __gnu_debug
 struct _Insert_range_from_self_is_safe
 { enum { __value = 0 }; };
 
+  template
+struct _Is_contiguous_sequence : std::__false_type { };
+
   // An arbitrary iterator pointer is not singular.
   inline bool
   __check_singular_aux(const void*) { return false; }
@@ -175,123 +178,112 @@ namespace __gnu_debug
   return __first;
 }
 
-#if __cplusplus >= 201103L
-  // Default implementation.
+  /* Handle the case where __other is a pointer to _Sequence::value_type. */
   template
 inline bool
 __foreign_iterator_aux4(const _Safe_iterator<_Iterator, _Sequence>& __it,
-   typename _Sequence::const_pointer __begin,
-   typename _Sequence::const_pointer __other)
+   const typename _Sequence::value_type* __other)
 {
-  typedef typename _Sequence::const_pointer _PointerType;
-  constexpr std::less<_PointerType> __l{};
+  typedef const typename _Sequence::value_type

Re: [Build] Don't install libcilkrt's include/cilk/ header files twice for multi-lib installations

2014-03-20 Thread H.J. Lu
On Thu, Mar 20, 2014 at 1:25 PM, Tobias Burnus  wrote:
> When looking at PR 60589, I saw that libcilk's header files are installed
> multiple times. On my x86-64-gnu-linux system, I have them as:
>
> lib/gcc/x86_64-unknown-linux-gnu/4.9.0/include/cilk/*.h
> lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/include/cilk/*.h
>
> However, GCC only reads the latter - even with -m32. I think the attached

Did you mean "former"? My x86-64 GCC only reads header files under

lib/gcc/x86_64-unknown-linux-gnu/4.9.0/include/

> patch does the right thing - at least it matches the other libraries and I
> only end up with the headers in lib64.
>
> OK for the trunk?
>
> * * *
>
> Actually, libssp has the same issue: It also installs the headers twice. As
> I am not sure which projects all include libssp and where the development
> happens, I have not updated its Makefile.am.
>
> Tobias



-- 
H.J.


FW: [PING] [PATCH] _Cilk_for for C and C++

2014-03-20 Thread Iyer, Balaji V
I mis-spelled the "org" as "og" and thus the email got bounced. So, here it is 
again.

Thanks,
Balaji V. Iyer.

> -Original Message-
> From: Iyer, Balaji V
> Sent: Thursday, March 20, 2014 4:34 PM
> To: 'Jakub Jelinek'
> Cc: gcc-patc...@gcc.gnu.og
> Subject: RE: [PING] [PATCH] _Cilk_for for C and C++
> 
> 
> 
> > -Original Message-
> > From: Jakub Jelinek [mailto:ja...@redhat.com]
> > Sent: Thursday, March 6, 2014 6:55 AM
> > To: Iyer, Balaji V
> > Cc: gcc-patc...@gcc.gnu.og
> > Subject: Re: [PING] [PATCH] _Cilk_for for C and C++
> >
> > On Tue, Mar 04, 2014 at 03:35:32PM +, Iyer, Balaji V wrote:
> > >   Did you get a chance to look at this?
> >
> > Please look what you are emitting for cf3.cc, e.g. in *.gimple:
> >
> > D.2883 = J::begin (j);
> > I::I (&i, D.2883);
> > D.2885 = J::end (j);
> > retval.0 = operator- (D.2885, &i);
> > D.2886 = retval.0 /[cl] 2;
> > #pragma omp parallel firstprivate(i) if(D.2886) shared(D.2865)
> > lastprivate(D.2864)
> >   {
> > const difference_type D.2866;
> > long int D.2887;
> > struct I & D.2888;
> >
> > try
> >   {
> >
> > _Cilk_for (D.2864 = 0; D.2864 < 0; D.2864 = D.2864 +
> > 2) linear(D.2864:2) schedule(cilk-for grain,0)
> >
> > That is just plain wrong, you aren't iterating zero times, but
> > D.2886 times, so there should be D.2864 < retval.0.
> > In *.original that is:
> > < >   (void) (i = TARGET_EXPR  >   5
> >   __comp_ctor
> >   D.2854
> >   0B
> >   (const struct I &) (const struct I *) J::begin ((struct J *) j) )
> >;
> > #pragma omp parallel firstprivate(i) schedule(cilk-for grain,0)
> > if(< ((const struct I &) (const struct I
> > *) J::end ((struct J *) j), (const struct I &) (const struct I *) 
> > &i)>> /[cl] 2)
> >   {
> > {
> >   try  < HERE
> 
> > {
> > difference_type D.2864;
> > difference_type D.2865;
> >
> > {
> >   < > (D.2865 = 0)
> > >
> >   _Cilk_for (D.2864 = 0; D.2864 < 0; D.2864 = D.2864 +
> > 2) schedule(cilk- for grain,0) if(<
> > ((const struct I &) (const struct I *) J::end ((struct J *) j),
> > (const struct I &) (const struct I *) &i)>> /[cl] 2)
> >
> > As I've said several times before, don't put the operator- expression
> > into if clause, instead evaluate it into a scalar temporary first
> > (get_temp_regvar), before the #pragma omp parallel, and use the result
> > of get_temp_regvar in the if clause (temp /[cl] 2) and in firstprivate
> > clause on omp parallel and as the high bound of _Cilk_for.
> 
> Hi Jakub,
>   First off, I am sorry for the delay in response. I had a couple family
> issues to deal with that tied me up for the past week.
>   Yes, I agree that it looks weird in the intermediate code. I tried to
> move the operator-(...) value into a variable (in the function
> handle_omp_for_class_iterator) and it was giving me an ICE during gimplify
> case. The issue was scoping. The if clause is sitting on #pragma omp parallel,
> but when I move the operator- to a variable it is inside the try block (marked
> by < HERE =). Also, this only happens when we deal with iterators
> and overloaded opeators. All the other cases the intermediate code looks
> OK. This only happens in dump of gimple and original. All the intermediate
> codes after that (>= .012) looks OK. Since this is a specific case, can you
> accept this as a workaround for now?
> 
> Thanks,
> 
> Balaji V. Iyer.


Re: [Testsuite, Patch] Fix testsuite/lib/gcc-dg.exp's scan-module-absence

2014-03-20 Thread Steve Kargl
On Thu, Mar 20, 2014 at 08:24:49PM +0100, Tobias Burnus wrote:
> gfortran's modules are since GCC 4.9 zipped. There are two functions, 
> which test for the existence and absent of strings in the .mod files.
> 
> While one was updated to apply gunzip before reading, the other wasn't. 
> This patch copies over the unzip call from the other function. I have 
> tested it that it properly fails if and only if the string is present in 
> the (uncompressed) .mod file.
> 
> OK for the trunk?
> 
> Tobias
> 
> PS: Thanks to Dominique for pointing out this problem!

> 2014-03-20  Tobias Burnus  
> 
>   PR fortran/60599
>   * lib/gcc-dg.exp (scan-module): Uncompress .mod files for
>   reading.
> 

Looks good to me.  Not sure, I can give an OK as the 
file is outside of gfortran directories.

-- 
Steve


Re: [4.8, PATCH 0/26] Backport Power8 and LE support

2014-03-20 Thread Peter Bergner
On Wed, 2014-03-19 at 16:03 -0500, Bill Schmidt wrote:
> On Wed, 2014-03-19 at 21:05 +0100, Jakub Jelinek wrote:
> 
> > I guess the most important question is what guarantees there are that it
> > won't affect non-powerpc* ports too much (my main concern is the 9/26 patch,
> > plus the C++ FE / libstdc++ changes), and how much does this affect
> > code generation and overall stability of the PowerPC big endian existing
> > targets.
>
>  * 15/26 might be one we can do without.  I need to check with Peter
> Bergner, who originally backported Fabien's patch, but unfortunately he
> is on vacation.  That patch fixed a problem that originated on an x86
> platform.  I can try respinning the patch series without this one and
> see what breaks, or if Peter happens to see this while he's on vacation,
> perhaps he can comment.

This was a fix to bring GCC into agreement with XLC++ and clang wrt the
test case in PR54537.  The XL team also had complained separately that
they couldn't compile programs that included the header file tr1/cmath
because it contained that bug.

That said, this "fix" is not required for POWER8 or LE support, so
if the RMs don't want this backported to the FSF 4.8 tree, I'm ok
with that.  That being said, we will ask the 4.8 based distros to
pick up this patch since it fixes a bug that XL cannot workaround.

Peter




Re: [Build] Don't install libcilkrt's include/cilk/ header files twice for multi-lib installations

2014-03-20 Thread Tobias Burnus


H.J. Lu wrote:

On Thu, Mar 20, 2014 at 1:25 PM, Tobias Burnus  wrote:

When looking at PR 60589, I saw that libcilk's header files are installed
multiple times. On my x86-64-gnu-linux system, I have them as:

lib/gcc/x86_64-unknown-linux-gnu/4.9.0/include/cilk/*.h
lib64/gcc/x86_64-unknown-linux-gnu/4.9.0/include/cilk/*.h

However, GCC only reads the latter - even with -m32. I think the attached

Did you mean "former"? My x86-64 GCC only reads header files under
lib/gcc/x86_64-unknown-linux-gnu/4.9.0/include/


No, I meant the latter. However, it is system dependent whether it is in 
"lib" or "lib64".


Tobias


Re: [PATCH][AArch64] Implement %c output template

2014-03-20 Thread Maxim Kuvyrkov
On Oct 18, 2013, at 12:13 AM, Kyrill Tkachov  wrote:

> Hi all,
> 
> This patch implements the %c output template for inline asm. The code for it 
> is almost identical to the support in arm, so it's pretty straightforward. 
> I've added a few compile tests for it as well.
> 
> Tested aarch64-none-elf on a model.
> 
> Ok for trunk?
> 
> Thanks,
> Kyrill
> 
> [gcc/]
> 2013-10-17  Kyrylo Tkachov  
> 
>* config/aarch64/aarch64.c (aarch64_print_operand): Handle 'c'.
> 
> [gcc/testsuite]
> 2013-10-17  Kyrylo Tkachov  
> 
>* gcc.target/aarch64/c-output-template.c: New testcase.
>* gcc.target/aarch64/c-output-template-2.c: Likewise.
>* gcc.target/aarch64/c-output-template-3.c: 
> Likewise.

Kyrill,

>From the testcases it appears that %c constraint modifier can be used by users 
>through inline assembly -- is this intended use-case or an [unsupported] 
>side-effect?

If "yes" then it, probably, needs documentation in doc/tm.texi or elsewhere.

Thank you,

--
Maxim Kuvyrkov
www.linaro.org



Re: [4.8, PATCH 0/26] Backport Power8 and LE support

2014-03-20 Thread Jakub Jelinek
On Thu, Mar 20, 2014 at 04:25:54PM -0500, Peter Bergner wrote:
> On Wed, 2014-03-19 at 16:03 -0500, Bill Schmidt wrote:
> > On Wed, 2014-03-19 at 21:05 +0100, Jakub Jelinek wrote:
> > 
> > > I guess the most important question is what guarantees there are that it
> > > won't affect non-powerpc* ports too much (my main concern is the 9/26 
> > > patch,
> > > plus the C++ FE / libstdc++ changes), and how much does this affect
> > > code generation and overall stability of the PowerPC big endian existing
> > > targets.
> >
> >  * 15/26 might be one we can do without.  I need to check with Peter
> > Bergner, who originally backported Fabien's patch, but unfortunately he
> > is on vacation.  That patch fixed a problem that originated on an x86
> > platform.  I can try respinning the patch series without this one and
> > see what breaks, or if Peter happens to see this while he's on vacation,
> > perhaps he can comment.
> 
> This was a fix to bring GCC into agreement with XLC++ and clang wrt the
> test case in PR54537.  The XL team also had complained separately that
> they couldn't compile programs that included the header file tr1/cmath
> because it contained that bug.
> 
> That said, this "fix" is not required for POWER8 or LE support, so
> if the RMs don't want this backported to the FSF 4.8 tree, I'm ok
> with that.  That being said, we will ask the 4.8 based distros to
> pick up this patch since it fixes a bug that XL cannot workaround.

IMHO it shouldn't be backported as part of the POWER8/LE series,
it seems unrelated.

If the C++ and libstdc++ maintainers agree that it should be backported,
then it can be, but please do it independently on the rest of the backports.

Jakub


Re: [4.8, PATCH 0/26] Backport Power8 and LE support

2014-03-20 Thread Jeff Law

On 03/19/14 21:18, Alan Modra wrote:

implementing either ELFv2 or ELFv1 ABIs.  Another thing that we didn't
change is that sibcalls can be allowed in more cases than the current
code allows.
Right.  IIRC we deferred allowing more sibcalls until the next stage1 
out of an abundance of caution.

jeff


Re: Remove left-overs from RTX_UNCHANGING_P era

2014-03-20 Thread Eric Botcazou
> 2014-03-20  Eric Botcazou  
> 
>   * calls.c (store_one_arg): Remove incorrect const qualification on the
>   type of the temporary.
>   * cfgexpand.c (expand_return): Likewise.
>   * expr.c (expand_constructor): Likewise.
>   (expand_expr_real_1): Likewise.

There is also a related comment in the last function, removed as well.


2014-03-20  Eric Botcazou  

* expr.c (expand_expr_real_1): Remove outdated comment.


-- 
Eric BotcazouIndex: expr.c
===
--- expr.c	(revision 208694)
+++ expr.c	(working copy)
@@ -1993,7 +1993,6 @@ emit_group_store (rtx orig_dst, rtx src,
   /* It is unclear if we can ever reach here, but we may as well handle
 	 it.  Allocate a temporary, and split this into a store/load to/from
 	 the temporary.  */
-
   temp = assign_stack_temp (GET_MODE (dst), ssize);
   emit_group_store (temp, src, type, ssize);
   emit_group_load (dst, temp, type, ssize);
@@ -10242,19 +10241,13 @@ expand_expr_real_1 (tree exp, rtx target
 
 	/* If the result type is BLKmode, store the data into a temporary
 	   of the appropriate type, but with the mode corresponding to the
-	   mode for the data we have (op0's mode).  It's tempting to make
-	   this a constant type, since we know it's only being stored once,
-	   but that can cause problems if we are taking the address of this
-	   COMPONENT_REF because the MEM of any reference via that address
-	   will have flags corresponding to the type, which will not
-	   necessarily be constant.  */
+	   mode for the data we have (op0's mode).  */
 	if (mode == BLKmode)
 	  {
-		rtx new_rtx;
-
-		new_rtx = assign_stack_temp_for_type (ext_mode,
-		   GET_MODE_BITSIZE (ext_mode),
-		   type);
+		rtx new_rtx
+		  = assign_stack_temp_for_type (ext_mode,
+		GET_MODE_BITSIZE (ext_mode),
+		type);
 		emit_move_insn (new_rtx, op0);
 		op0 = copy_rtx (new_rtx);
 		PUT_MODE (op0, BLKmode);

Re: Remove left-overs from RTX_UNCHANGING_P era

2014-03-20 Thread Eric Botcazou
> 2014-03-20  Eric Botcazou  
> 
>   * calls.c (store_one_arg): Remove incorrect const qualification on the
>   type of the temporary.
>   * cfgexpand.c (expand_return): Likewise.
>   * expr.c (expand_constructor): Likewise.
>   (expand_expr_real_1): Likewise.

There is also a related comment in the last function, removed as well.


2014-03-20  Eric Botcazou  

* expr.c (expand_expr_real_1): Remove outdated comment.


-- 
Eric BotcazouIndex: expr.c
===
--- expr.c	(revision 208694)
+++ expr.c	(working copy)
@@ -1993,7 +1993,6 @@ emit_group_store (rtx orig_dst, rtx src,
   /* It is unclear if we can ever reach here, but we may as well handle
 	 it.  Allocate a temporary, and split this into a store/load to/from
 	 the temporary.  */
-
   temp = assign_stack_temp (GET_MODE (dst), ssize);
   emit_group_store (temp, src, type, ssize);
   emit_group_load (dst, temp, type, ssize);
@@ -10242,19 +10241,13 @@ expand_expr_real_1 (tree exp, rtx target
 
 	/* If the result type is BLKmode, store the data into a temporary
 	   of the appropriate type, but with the mode corresponding to the
-	   mode for the data we have (op0's mode).  It's tempting to make
-	   this a constant type, since we know it's only being stored once,
-	   but that can cause problems if we are taking the address of this
-	   COMPONENT_REF because the MEM of any reference via that address
-	   will have flags corresponding to the type, which will not
-	   necessarily be constant.  */
+	   mode for the data we have (op0's mode).  */
 	if (mode == BLKmode)
 	  {
-		rtx new_rtx;
-
-		new_rtx = assign_stack_temp_for_type (ext_mode,
-		   GET_MODE_BITSIZE (ext_mode),
-		   type);
+		rtx new_rtx
+		  = assign_stack_temp_for_type (ext_mode,
+		GET_MODE_BITSIZE (ext_mode),
+		type);
 		emit_move_insn (new_rtx, op0);
 		op0 = copy_rtx (new_rtx);
 		PUT_MODE (op0, BLKmode);


[patch] Fix PR59295 -- remove useless warning

2014-03-20 Thread Paul Pluzhnikov
Greetings,

Attached patch deletes code to warn about repeated friend declaration.

The warning has apparently been present since at least 1997, but it's
unlikely to have ever prevented any actual bugs.

Ok for trunk once it opens in stage1?

Tested on Linux/x86_64 with no regressions.

Thanks,


Google ref: b/11542609

--

2014-03-20  Paul Pluzhnikov  

PR c++/59295
* gcc/cp/friend.c (add_friend): Remove complain parameter.
(do_friend): Adjust.
* gcc/cp/cp-tree.h (add_friend): Adjust.
* gcc/cp/pt.c (instantiate_class_template_1): Adjust.

gcc/testsuite/ChangeLog:

2014-03-20  Paul Pluzhnikov  

PR c++/59295
* g++.old-deja/g++.benjamin/warn02.C: Adjust.


Index: gcc/cp/friend.c
===
--- gcc/cp/friend.c (revision 208738)
+++ gcc/cp/friend.c (working copy)
@@ -116,14 +116,10 @@
 }
 
 /* Add a new friend to the friends of the aggregate type TYPE.
-   DECL is the FUNCTION_DECL of the friend being added.
+   DECL is the FUNCTION_DECL of the friend being added.  */
 
-   If COMPLAIN is true, warning about duplicate friend is issued.
-   We want to have this diagnostics during parsing but not
-   when a template is being instantiated.  */
-
 void
-add_friend (tree type, tree decl, bool complain)
+add_friend (tree type, tree decl)
 {
   tree typedecl;
   tree list;
@@ -146,12 +142,7 @@
  for (; friends ; friends = TREE_CHAIN (friends))
{
  if (decl == TREE_VALUE (friends))
-   {
- if (complain)
-   warning (0, "%qD is already a friend of class %qT",
-decl, type);
- return;
-   }
+   return;
}
 
  maybe_add_class_template_decl_list (type, decl, /*friend_p=*/1);
@@ -374,20 +365,12 @@
   if (TREE_CODE (friend_type) == TEMPLATE_DECL)
{
  if (friend_type == probe)
-   {
- if (complain)
-   warning (0, "%qD is already a friend of %qT", probe, type);
- break;
-   }
+   break;
}
   else if (TREE_CODE (probe) != TEMPLATE_DECL)
{
  if (same_type_p (probe, friend_type))
-   {
- if (complain)
-   warning (0, "%qT is already a friend of %qT", probe, type);
- break;
-   }
+   break;
}
 }
 
@@ -511,7 +494,7 @@
decl = DECL_TI_TEMPLATE (decl);
 
  if (decl)
-   add_friend (current_class_type, decl, /*complain=*/true);
+   add_friend (current_class_type, decl);
}
   else
error ("member %qD declared as friend before type %qT defined",
@@ -602,8 +585,7 @@
return error_mark_node;
 
   add_friend (current_class_type,
- is_friend_template ? DECL_TI_TEMPLATE (decl) : decl,
- /*complain=*/true);
+ is_friend_template ? DECL_TI_TEMPLATE (decl) : decl);
   DECL_FRIEND_P (decl) = 1;
 }
 
Index: gcc/cp/cp-tree.h
===
--- gcc/cp/cp-tree.h(revision 208738)
+++ gcc/cp/cp-tree.h(working copy)
@@ -5402,7 +5402,7 @@
 /* friend.c */
 extern int is_friend   (tree, tree);
 extern void make_friend_class  (tree, tree, bool);
-extern void add_friend (tree, tree, bool);
+extern void add_friend (tree, tree);
 extern tree do_friend  (tree, tree, tree, tree, enum 
overload_flags, bool);
 
 /* in init.c */
Index: gcc/cp/pt.c
===
--- gcc/cp/pt.c (revision 208738)
+++ gcc/cp/pt.c (working copy)
@@ -9315,7 +9315,7 @@
}
 
  r = tsubst_friend_function (t, args);
- add_friend (type, r, /*complain=*/false);
+ add_friend (type, r);
  if (TREE_CODE (t) == TEMPLATE_DECL)
{
  pop_deferring_access_checks ();
Index: gcc/testsuite/g++.old-deja/g++.benjamin/warn02.C
===
--- gcc/testsuite/g++.old-deja/g++.benjamin/warn02.C(revision 208736)
+++ gcc/testsuite/g++.old-deja/g++.benjamin/warn02.C(working copy)
@@ -20,14 +20,6 @@
   int b;
 };
 
-class C
-{
-  friend int foo(const char *);
-  friend int foo(const char *); // { dg-warning "" } 
-  int foo2() {return b;}
-  int b;
-};
-
 class D
 {
 public:


[PATCH, rs6000] More efficient vector permute for little endian

2014-03-20 Thread Bill Schmidt
Hi,

The original workaround for vector permute on a little endian platform
includes subtracting each element of the permute control vector from 31.
Because the upper 3 bits of each element are unimportant, this was
implemented as subtracting the whole vector from a splat of -1.  On
reflection this can be done more efficiently with a vector nor
operation.  This patch makes that change.

Bootstrapped and tested on powerpc64le-unknown-linux-gnu with no
regressions.  Is this ok for trunk?

Thanks,
Bill


2014-03-20  Bill Schmidt  

* config/rs6000/rs6000.c (rs6000_expand_vector_set): Generate a
pattern for vector nor instead of subtract from splat(-1).
(altivec_expand_vec_perm_const_le): Likewise.


Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 208704)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -5622,12 +5622,10 @@ rs6000_expand_vector_set (rtx target, rtx val, int
   else 
 {
   /* Invert selector.  */
-  rtx splat = gen_rtx_VEC_DUPLICATE (V16QImode,
-gen_rtx_CONST_INT (QImode, -1));
+  rtx notx = gen_rtx_NOT (V16QImode, force_reg (V16QImode, x));
+  rtx andx = gen_rtx_AND (V16QImode, notx, notx);
   rtx tmp = gen_reg_rtx (V16QImode);
-  emit_move_insn (tmp, splat);
-  x = gen_rtx_MINUS (V16QImode, tmp, force_reg (V16QImode, x));
-  emit_move_insn (tmp, x);
+  emit_move_insn (tmp, andx);
 
   /* Permute with operands reversed and adjusted selector.  */
   x = gen_rtx_UNSPEC (mode, gen_rtvec (3, reg, target, tmp),
@@ -30321,18 +30319,18 @@ altivec_expand_vec_perm_const_le (rtx operands[4])
 
 /* Similarly to altivec_expand_vec_perm_const_le, we must adjust the
permute control vector.  But here it's not a constant, so we must
-   generate a vector splat/subtract to do the adjustment.  */
+   generate a vector NOR to do the adjustment.  */
 
 void
 altivec_expand_vec_perm_le (rtx operands[4])
 {
-  rtx splat, unspec;
+  rtx notx, andx, unspec;
   rtx target = operands[0];
   rtx op0 = operands[1];
   rtx op1 = operands[2];
   rtx sel = operands[3];
   rtx tmp = target;
-  rtx splatreg = gen_reg_rtx (V16QImode);
+  rtx norreg = gen_reg_rtx (V16QImode);
   enum machine_mode mode = GET_MODE (target);
 
   /* Get everything in regs so the pattern matches.  */
@@ -30345,18 +30343,14 @@ altivec_expand_vec_perm_le (rtx operands[4])
   if (!REG_P (target))
 tmp = gen_reg_rtx (mode);
 
-  /* SEL = splat(31) - SEL.  */
-  /* We want to subtract from 31, but we can't vspltisb 31 since
- it's out of range.  -1 works as well because only the low-order
- five bits of the permute control vector elements are used.  */
-  splat = gen_rtx_VEC_DUPLICATE (V16QImode,
-gen_rtx_CONST_INT (QImode, -1));
-  emit_move_insn (splatreg, splat);
-  sel = gen_rtx_MINUS (V16QImode, splatreg, sel);
-  emit_move_insn (splatreg, sel);
+  /* Invert the selector with a VNOR.  */
+  notx = gen_rtx_NOT (V16QImode, sel);
+  andx = gen_rtx_AND (V16QImode, notx, notx);
+  emit_move_insn (norreg, andx);
 
   /* Permute with operands reversed and adjusted selector.  */
-  unspec = gen_rtx_UNSPEC (mode, gen_rtvec (3, op1, op0, splatreg), 
UNSPEC_VPERM);
+  unspec = gen_rtx_UNSPEC (mode, gen_rtvec (3, op1, op0, norreg),
+  UNSPEC_VPERM);
 
   /* Copy into target, possibly by way of a register.  */
   if (!REG_P (target))