Re: [PATCH GCC][refacor]Manage allocation of struct iv in obstack.

2015-07-01 Thread Richard Biener
On Tue, Jun 30, 2015 at 9:49 AM, Richard Biener
 wrote:
> On Tue, Jun 30, 2015 at 4:31 AM, Bin.Cheng  wrote:
>> On Sat, Jun 27, 2015 at 5:13 AM, Jeff Law  wrote:
>>> On 06/26/2015 03:02 AM, Bin Cheng wrote:

 Hi,
 GCC avoids multi-pointers/dangling-pointers of struct iv by allocating
 multiple copies of the structure.  This patch is an obvious fix to the
 issue
 by managing iv structures in obstack.

 Bootstrap on x86_64, will apply to trunk if no objection.

 Thanks,
 bin

 2015-06-26  Bin Cheng  

 * tree-ssa-loop-ivopts.c (struct ivopts_data): New field
 iv_obstack.
 (tree_ssa_iv_optimize_init): Initialize iv_obstack.
 (alloc_iv): New parameter.  Allocate struct iv using
 obstack_alloc.
 (set_iv, find_interesting_uses_address, add_candidate_1): New
 argument.
 (find_interesting_uses_op): Don't duplicate struct iv.
 (free_loop_data): Don't free iv structure explicitly.
 (tree_ssa_iv_optimize_finalize): Free iv_obstack.
>>>
>>> Presumably you're trying to simplify the memory management  here so that you
>>> don't have to track lifetimes of the IV structures so carefully, which in
>>> turn simplifies some upcoming patch?
>> Yes, that's exactly the reason.  I am still on the way fixing
>> missed-optimizations in IVO, and plan to do some
>> refactoring/simplification afterwards.
>>>
>>> Note we don't have a "no objection" policy for this kind of patch. However,
>>> I think it may make sense to look into having you as a maintainer for the IV
>>> optimizations if you're interested.
>> Oh, that would be my great honor.
>
> I'd support that.  Bin has done high quality work on IVOPTs in the past and he
> knows when to ask questions (not that there ever were simple answers
> to those...).

The patch is ok btw.

Thanks,
Richard.

> Thanks,
> Richard.
>
>> Thanks,
>> bin
>>>
>>> Jeff
>>>


Re: [patch] PR debug/66653: avoid late_global_decl on decl_type_context()s

2015-07-01 Thread Richard Biener
On Tue, Jun 30, 2015 at 4:30 PM, Jason Merrill  wrote:
> On 06/29/2015 06:32 PM, Jason Merrill wrote:
>>
>> On 06/29/2015 05:07 AM, Richard Biener wrote:
>>>
>>> On Fri, Jun 26, 2015 at 11:59 PM, Jason Merrill  wrote:

 On 06/26/2015 05:37 AM, Richard Biener wrote:
>
>
> Can we defer TLS model setting to template instantiation?


 We need to represent somehow that __thread (or thread_local) was used in
 the
 declaration, but DECL_THREAD_LOCAL_P was changed to refer to the TLS
 model.
>>>
>>>
>>> Ok, so "easiest" would be to allocate a bit from decl_with_vis for
>>> this...
>>
>>
>> Or I can find a flag in the front end.  I guess I'll do that.
>
>
> Thus.

Looks good to me.

Richard.

> Jason
>


Re: [patch] Fix ICE during SCC hashing in LTO mode

2015-07-01 Thread Richard Biener
On Tue, Jun 30, 2015 at 11:03 PM, Eric Botcazou  wrote:
>> Ok (I suppose this also affects the GCC 5 branch?)
>
> Thanks.  Yes, it does, but I'm not sure if we need to backport it immediately.

Given there is no PR to track this I'll count on you remembering to
backport it then ;)
If you'd want it in 5.2 then you'd need to backport it by this Friday morning.

Richard.

> --
> Eric Botcazou


Re: [patch] Fix ICE during SCC hashing in LTO mode

2015-07-01 Thread Eric Botcazou
> Given there is no PR to track this I'll count on you remembering to
> backport it then ;)

OK.

> If you'd want it in 5.2 then you'd need to backport it by this Friday
> morning.

No thanks. :-)

-- 
Eric Botcazou


Re: [patch] Fix PR middle-end/66633

2015-07-01 Thread Eric Botcazou
Jakub,

> 2015-06-29  Eric Botcazou  
> 
>   PR middle-end/66633
>   * tree-nested.c (convert_nonlocal_omp_clauses): Initialize need_chain
>   to true if the function is nested and if not optimizing.
>   (convert_local_omp_clauses): Initialize need_frame to true if the
>   function contains nested functions and if not optimizing.

Any opinion about it?  Do you want me to backport it onto the 5 branch now?

-- 
Eric Botcazou


Re: [patch] Fix PR middle-end/66633

2015-07-01 Thread Jakub Jelinek
On Wed, Jul 01, 2015 at 09:52:04AM +0200, Eric Botcazou wrote:
> Jakub,
> 
> > 2015-06-29  Eric Botcazou  
> > 
> > PR middle-end/66633
> > * tree-nested.c (convert_nonlocal_omp_clauses): Initialize need_chain
> > to true if the function is nested and if not optimizing.
> > (convert_local_omp_clauses): Initialize need_frame to true if the
> > function contains nested functions and if not optimizing.
> 
> Any opinion about it?  Do you want me to backport it onto the 5 branch now?

LGTM, and I'd apply it to 5 too.

Jakub


PR 66685: parallel returns being misclassified

2015-07-01 Thread Richard Sandiford
This patch should restore bootstrap on hppa (and probably other targets
besides).  The change to use target-insns.def put more stress on the
emit()/classify_insn() group of functions, which were missing a case
for parallel returns.

Tested with a cross-compiler that it fixes the hppa problem.  Bootstrap
in progress on x86_64-linux-gnu.  OK to install?

Sorry for the slow response on this one.  I'd misread the PR and thought
that it was the bug fixed in r225000.

Thanks,
Richard


gcc/
PR bootstrap/66685
* rtl.c (classify_insn): Handle returns in PARALLELs.

Index: gcc/rtl.c
===
--- gcc/rtl.c   2015-07-01 09:13:29.782160299 +0100
+++ gcc/rtl.c   2015-07-01 09:13:29.778160333 +0100
@@ -686,6 +686,8 @@ classify_insn (rtx x)
   for (j = XVECLEN (x, 0) - 1; j >= 0; j--)
if (GET_CODE (XVECEXP (x, 0, j)) == CALL)
  return CALL_INSN;
+   else if (ANY_RETURN_P (XVECEXP (x, 0, j)))
+ return JUMP_INSN;
else if (GET_CODE (XVECEXP (x, 0, j)) == SET
 && GET_CODE (SET_DEST (XVECEXP (x, 0, j))) == PC)
  return JUMP_INSN;



Re: [AArch64] Fall back to -fPIC if no support of -fpic relocation modifer in assembler

2015-07-01 Thread James Greenhalgh
On Mon, Jun 29, 2015 at 01:42:13PM +0100, Jiong Wang wrote:
> 
> This patch fix the breakage caused by
> 
>   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01913.html
> 
> We fall back to -fPIC if there is no assembler support on those new
> relocation modifiers for -fpic.
> 
> OK for trunk?
> 
> gcc/
>   * configure.ac: Add check for aarch64 assembler -fpic relocation
>   modifier support.
>   * configure: Regenerate.
>   * config.in: Regenerate.
>   * config/aarch64/aarch64.c (initialize_aarch64_code_model): Fall back to
>   -fPIC if not support of -fpic relocation modifier in assembler.
> -- 
> Regards,
> Jiong

This patch is OK, but please rename

> +#undef HAVE_AS_SPIC_RELOCS

to

  HAVE_AS_SMALL_PIC_RELOCS

It seems clearer to explicitly spell out what feature this relates to.

Thanks,
James

> 

> diff --git a/gcc/config.in b/gcc/config.in
> index 3aee936..476d585 100644
> --- a/gcc/config.in
> +++ b/gcc/config.in
> @@ -606,6 +606,12 @@
>  #endif
>  
>  
> +/* Define if your assembler supports relocs needed by -fpic. */
> +#ifndef USED_FOR_TARGET
> +#undef HAVE_AS_SPIC_RELOCS
> +#endif
> +
> +
>  /* Define if your assembler and linker support thread-local storage. */
>  #ifndef USED_FOR_TARGET
>  #undef HAVE_AS_TLS
> diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
> index f130f8d..7e09e3b 100644
> --- a/gcc/config/aarch64/aarch64.c
> +++ b/gcc/config/aarch64/aarch64.c
> @@ -7581,9 +7581,13 @@ initialize_aarch64_code_model (void)
>  aarch64_cmodel = AARCH64_CMODEL_TINY_PIC;
>  break;
>case AARCH64_CMODEL_SMALL:
> +#ifdef HAVE_AS_SPIC_RELOCS
>  aarch64_cmodel = (flag_pic == 2
>? AARCH64_CMODEL_SMALL_PIC
>: AARCH64_CMODEL_SMALL_SPIC);
> +#else
> +aarch64_cmodel = AARCH64_CMODEL_SMALL_PIC;
> +#endif
>  break;
>case AARCH64_CMODEL_LARGE:
>  sorry ("code model %qs with -f%s", "large",
> diff --git a/gcc/configure b/gcc/configure
> index 3f3f578..b72cde7 100755
> --- a/gcc/configure
> +++ b/gcc/configure
> @@ -24228,6 +24228,40 @@ $as_echo "#define HAVE_AS_MABI_OPTION 1" >>confdefs.h
>  done
>fi
>  fi
> +# Check if we have binutils support for relocations types needed by -fpic
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -fpic 
> relocs" >&5
> +$as_echo_n "checking assembler for -fpic relocs... " >&6; }
> +if test "${gcc_cv_as_aarch64_picreloc+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  gcc_cv_as_aarch64_picreloc=no
> +  if test x$gcc_cv_as != x; then
> +$as_echo '
> + .text
> + ldr x0, [x2, #:gotpage_lo15:globalsym]
> +' > conftest.s
> +if { ac_try='$gcc_cv_as $gcc_cv_as_flags  -o conftest.o conftest.s >&5'
> +  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
> +  (eval $ac_try) 2>&5
> +  ac_status=$?
> +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
> +  test $ac_status = 0; }; }
> +then
> + gcc_cv_as_aarch64_picreloc=yes
> +else
> +  echo "configure: failed program was" >&5
> +  cat conftest.s >&5
> +fi
> +rm -f conftest.o conftest.s
> +  fi
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: 
> $gcc_cv_as_aarch64_picreloc" >&5
> +$as_echo "$gcc_cv_as_aarch64_picreloc" >&6; }
> +if test $gcc_cv_as_aarch64_picreloc = yes; then
> +
> +$as_echo "#define HAVE_AS_SPIC_RELOCS 1" >>confdefs.h
> +
> +fi
>  # Enable default workaround for AArch64 Cortex-A53 erratum 835769.
>  # Check whether --enable-fix-cortex-a53-835769 was given.
>  if test "${enable_fix_cortex_a53_835769+set}" = set; then :
> diff --git a/gcc/configure.ac b/gcc/configure.ac
> index 85f72d5..fb7dbfb 100644
> --- a/gcc/configure.ac
> +++ b/gcc/configure.ac
> @@ -3562,6 +3562,13 @@ case "$target" in
>  done
>fi
>  fi
> +# Check if we have binutils support for relocations types needed by -fpic
> +gcc_GAS_CHECK_FEATURE([-fpic relocs], gcc_cv_as_aarch64_picreloc,,,
> +[
> + .text
> + ldr x0, [[x2, #:gotpage_lo15:globalsym]]
> +],,[AC_DEFINE(HAVE_AS_SPIC_RELOCS, 1,
> + [Define if your assembler supports relocs needed by -fpic.])])
>  # Enable default workaround for AArch64 Cortex-A53 erratum 835769.
>  AC_ARG_ENABLE(fix-cortex-a53-835769,
>  [



Re: PR 66685: parallel returns being misclassified

2015-07-01 Thread Richard Biener
On Wed, Jul 1, 2015 at 10:27 AM, Richard Sandiford
 wrote:
> This patch should restore bootstrap on hppa (and probably other targets
> besides).  The change to use target-insns.def put more stress on the
> emit()/classify_insn() group of functions, which were missing a case
> for parallel returns.
>
> Tested with a cross-compiler that it fixes the hppa problem.  Bootstrap
> in progress on x86_64-linux-gnu.  OK to install?

Ok.

Richard.

> Sorry for the slow response on this one.  I'd misread the PR and thought
> that it was the bug fixed in r225000.
>
> Thanks,
> Richard
>
>
> gcc/
> PR bootstrap/66685
> * rtl.c (classify_insn): Handle returns in PARALLELs.
>
> Index: gcc/rtl.c
> ===
> --- gcc/rtl.c   2015-07-01 09:13:29.782160299 +0100
> +++ gcc/rtl.c   2015-07-01 09:13:29.778160333 +0100
> @@ -686,6 +686,8 @@ classify_insn (rtx x)
>for (j = XVECLEN (x, 0) - 1; j >= 0; j--)
> if (GET_CODE (XVECEXP (x, 0, j)) == CALL)
>   return CALL_INSN;
> +   else if (ANY_RETURN_P (XVECEXP (x, 0, j)))
> + return JUMP_INSN;
> else if (GET_CODE (XVECEXP (x, 0, j)) == SET
>  && GET_CODE (SET_DEST (XVECEXP (x, 0, j))) == PC)
>   return JUMP_INSN;
>


Re: [AArch64/testsuite] Restrict pic-small.c by a new directive "check_effective_target_aarch64_small_fpic"

2015-07-01 Thread James Greenhalgh
On Tue, Jun 30, 2015 at 03:17:00PM +0100, Jiong Wang wrote:
> 
> As discussed here
> 
>   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg02151.html,
> 
> Since have enabled binutils feature detection when configuring gcc,
> -fpic will not be enabled if there is no binutils support on those new
> relocation modifiers, thus we should update the testcase pic-small.c,
> only run it if check_effective_target_aarch64_small_fpic is true.
> 
> On AArch64, if -fpic is not supported, then we will fall back to -fPIC
> silently.  So, we can't rely on the existed "check_effective_target_fpic" as
> it assume compiler will give warning if -fpic not supported.  Here we
> check whether binutils support those new -fpic relocation modifiers, and
> assume -fpic is supported if there is binutils support, as gcc
> configuration will enable -fpic for AArch64 on such case. This will not
> apply if the test system is with new binutils and old gcc which is rare
> and this patch will not handle.
> 
> OK for trunk?

OK, with a couple of very minor changes in the documentation/comments.

> diff --git a/gcc/testsuite/lib/target-supports.exp 
> b/gcc/testsuite/lib/target-supports.exp
> index f0c209f..4c743c3 100644
> --- a/gcc/testsuite/lib/target-supports.exp
> +++ b/gcc/testsuite/lib/target-supports.exp
> @@ -937,6 +937,26 @@ proc check_effective_target_fpic { } {
>  return 0
>  }
>  
> +# On AArch64, if -fpic is not supported, then we will fall back to -fPIC
> +# silently.  So, we can't rely on above "check_effective_target_fpic" as it
> +# assume compiler will give warning if -fpic not supported.  Here we check

s/assume/assumes/

> +# whether binutils support those new -fpic relocation modifiers, and assume

s/support/supports/

> +# -fpic is supported is there is binutils support, as gcc configuration will

s/is there is/if there is/
s/, as gcc/.  GCC/

> +# enable -fpic for AArch64 on such case.

s/on such case/in this case/

> diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
> index 13f63d1..a0bab65 100644
> --- a/gcc/doc/sourcebuild.texi
> +++ b/gcc/doc/sourcebuild.texi
> @@ -1580,6 +1580,15 @@ ARM target prefers @code{LDRD} and @code{STRD} 
> instructions over
>  
>  @end table
>  
> +@subsubsection AArch64-specific attributes
> +
> +@table @code
> +@item aarch64_small_fpic
> +Binutils installed on test system support relocation types required by -fpic

s/support/supports/

> +for AArch64 small memory model.
> +
> +@end table
> +
>  @subsubsection MIPS-specific attributes
>  
>  @table @code


Thanks,
James

> 
> Thanks.
> 
> 2015-06-30  Jiong Wang  
> 
> gcc/
>   * doc/sourcebuild.texi (AArch64-specific attributes): New subsection.
>   Document "aarch64_small_fpic".
> 
> gcc/testsuite/
>   * lib/target-supports.exp (check_effective_target_aarch64_small_fpic): New 
> function.
>   * gcc.target/aarch64/pic-small.c: Restrict this test by
>   check_effective_target_aarch64_small_fpic.
>   

> diff --git a/gcc/testsuite/gcc.target/aarch64/pic-small.c 
> b/gcc/testsuite/gcc.target/aarch64/pic-small.c
> index 874f81b..282e4d0 100644
> --- a/gcc/testsuite/gcc.target/aarch64/pic-small.c
> +++ b/gcc/testsuite/gcc.target/aarch64/pic-small.c
> @@ -1,4 +1,5 @@
>  /* { dg-do compile } */
> +/* { dg-require-effective-target aarch64_small_fpic } */
>  /* { dg-options "-O2 -fpic -fno-inline --save-temps" } */
>  
>  void abort ();
> diff --git a/gcc/testsuite/lib/target-supports.exp 
> b/gcc/testsuite/lib/target-supports.exp
> index f0c209f..4c743c3 100644
> --- a/gcc/testsuite/lib/target-supports.exp
> +++ b/gcc/testsuite/lib/target-supports.exp
> @@ -937,6 +937,26 @@ proc check_effective_target_fpic { } {
>  return 0
>  }
>  
> +# On AArch64, if -fpic is not supported, then we will fall back to -fPIC
> +# silently.  So, we can't rely on above "check_effective_target_fpic" as it
> +# assume compiler will give warning if -fpic not supported.  Here we check
> +# whether binutils support those new -fpic relocation modifiers, and assume
> +# -fpic is supported is there is binutils support, as gcc configuration will
> +# enable -fpic for AArch64 on such case.
> +#
> +# "check_effective_target_aarch64_small_fpic" is dedicated for checking small
> +# memory model -fpic relocation types.
> +
> +proc check_effective_target_aarch64_small_fpic { } {
> +if { [istarget aarch64*-*-*] } {
> + return [check_no_compiler_messages aarch64_small_fpic object {
> + void foo (void) { asm ("ldr x0, [x2, #:gotpage_lo15:globalsym]"); }
> + }]
> +} else {
> + return 0
> +}
> +}
> +
>  # Return 1 if -shared is supported, as in no warnings or errors
>  # emitted, 0 otherwise.
>  
> diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
> index 13f63d1..a0bab65 100644
> --- a/gcc/doc/sourcebuild.texi
> +++ b/gcc/doc/sourcebuild.texi
> @@ -1580,6 +1580,15 @@ ARM target prefers @code{LDRD} and @code{STRD} 
> instructions over
>  
>  @end table
>  
> +@subsubsection AArch64-specific attributes
> +
> +@table @c

[COMMITTED][AArch64] Fall back to -fPIC if no support of -fpic relocation modifer in assembler

2015-07-01 Thread Jiong Wang

James Greenhalgh writes:

> On Mon, Jun 29, 2015 at 01:42:13PM +0100, Jiong Wang wrote:
>> 
>> This patch fix the breakage caused by
>> 
>>   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg01913.html
>> 
>> We fall back to -fPIC if there is no assembler support on those new
>> relocation modifiers for -fpic.
>> 
>> OK for trunk?
>> 
>> gcc/
>>   * configure.ac: Add check for aarch64 assembler -fpic relocation
>>   modifier support.
>>   * configure: Regenerate.
>>   * config.in: Regenerate.
>>   * config/aarch64/aarch64.c (initialize_aarch64_code_model): Fall back to
>>   -fPIC if not support of -fpic relocation modifier in assembler.
>> -- 
>> Regards,
>> Jiong
>
> This patch is OK, but please rename
>
>> +#undef HAVE_AS_SPIC_RELOCS
>
> to
>
>   HAVE_AS_SMALL_PIC_RELOCS
>
> It seems clearer to explicitly spell out what feature this relates to.

Thanks, commited below patch as 225231.

Index: gcc/config/aarch64/aarch64.c
===
--- gcc/config/aarch64/aarch64.c(revision 225228)
+++ gcc/config/aarch64/aarch64.c(working copy)
@@ -7581,9 +7581,13 @@
   aarch64_cmodel = AARCH64_CMODEL_TINY_PIC;
   break;
 case AARCH64_CMODEL_SMALL:
+#ifdef HAVE_AS_SMALL_PIC_RELOCS
   aarch64_cmodel = (flag_pic == 2
 ? AARCH64_CMODEL_SMALL_PIC
 : AARCH64_CMODEL_SMALL_SPIC);
+#else
+  aarch64_cmodel = AARCH64_CMODEL_SMALL_PIC;
+#endif
   break;
 case AARCH64_CMODEL_LARGE:
   sorry ("code model %qs with -f%s", "large",
Index: gcc/config.in
===
--- gcc/config.in   (revision 225228)
+++ gcc/config.in   (working copy)
@@ -606,6 +606,12 @@
 #endif
 
 
+/* Define if your assembler supports relocs needed by -fpic. */
+#ifndef USED_FOR_TARGET
+#undef HAVE_AS_SMALL_PIC_RELOCS
+#endif
+
+
 /* Define if your assembler and linker support thread-local storage. */
 #ifndef USED_FOR_TARGET
 #undef HAVE_AS_TLS
Index: gcc/configure
===
--- gcc/configure   (revision 225228)
+++ gcc/configure   (working copy)
@@ -24228,6 +24228,40 @@
 done
   fi
 fi
+# Check if we have binutils support for relocations types needed by -fpic
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -fpic 
relocs" >&5
+$as_echo_n "checking assembler for -fpic relocs... " >&6; }
+if test "${gcc_cv_as_aarch64_picreloc+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  gcc_cv_as_aarch64_picreloc=no
+  if test x$gcc_cv_as != x; then
+$as_echo '
+   .text
+   ldr x0, [x2, #:gotpage_lo15:globalsym]
+' > conftest.s
+if { ac_try='$gcc_cv_as $gcc_cv_as_flags  -o conftest.o conftest.s >&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }
+then
+   gcc_cv_as_aarch64_picreloc=yes
+else
+  echo "configure: failed program was" >&5
+  cat conftest.s >&5
+fi
+rm -f conftest.o conftest.s
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_aarch64_picreloc" 
>&5
+$as_echo "$gcc_cv_as_aarch64_picreloc" >&6; }
+if test $gcc_cv_as_aarch64_picreloc = yes; then
+
+$as_echo "#define HAVE_AS_SMALL_PIC_RELOCS 1" >>confdefs.h
+
+fi
 # Enable default workaround for AArch64 Cortex-A53 erratum 835769.
 # Check whether --enable-fix-cortex-a53-835769 was given.
 if test "${enable_fix_cortex_a53_835769+set}" = set; then :
Index: gcc/configure.ac
===
--- gcc/configure.ac(revision 225228)
+++ gcc/configure.ac(working copy)
@@ -3562,6 +3562,13 @@
 done
   fi
 fi
+# Check if we have binutils support for relocations types needed by -fpic
+gcc_GAS_CHECK_FEATURE([-fpic relocs], gcc_cv_as_aarch64_picreloc,,,
+[
+   .text
+   ldr x0, [[x2, #:gotpage_lo15:globalsym]]
+],,[AC_DEFINE(HAVE_AS_SMALL_PIC_RELOCS, 1,
+   [Define if your assembler supports relocs needed by -fpic.])])
 # Enable default workaround for AArch64 Cortex-A53 erratum 835769.
 AC_ARG_ENABLE(fix-cortex-a53-835769,
 [


[COMMITTED][AArch64/testsuite] Restrict pic-small.c by a new directive "check_effective_target_aarch64_small_fpic"

2015-07-01 Thread Jiong Wang

James Greenhalgh writes:

> On Tue, Jun 30, 2015 at 03:17:00PM +0100, Jiong Wang wrote:
>> 
>> As discussed here
>> 
>>   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg02151.html,
>> 
>> Since have enabled binutils feature detection when configuring gcc,
>> -fpic will not be enabled if there is no binutils support on those new
>> relocation modifiers, thus we should update the testcase pic-small.c,
>> only run it if check_effective_target_aarch64_small_fpic is true.
>> 
>> On AArch64, if -fpic is not supported, then we will fall back to -fPIC
>> silently.  So, we can't rely on the existed "check_effective_target_fpic" as
>> it assume compiler will give warning if -fpic not supported.  Here we
>> check whether binutils support those new -fpic relocation modifiers, and
>> assume -fpic is supported if there is binutils support, as gcc
>> configuration will enable -fpic for AArch64 on such case. This will not
>> apply if the test system is with new binutils and old gcc which is rare
>> and this patch will not handle.
>> 
>> OK for trunk?
>
> OK, with a couple of very minor changes in the documentation/comments.

Thanks. Committed patch below as 225232.

Index: gcc/doc/sourcebuild.texi
===
--- gcc/doc/sourcebuild.texi(revision 225230)
+++ gcc/doc/sourcebuild.texi(working copy)
@@ -1580,6 +1580,15 @@
 
 @end table
 
+@subsubsection AArch64-specific attributes
+
+@table @code
+@item aarch64_small_fpic
+Binutils installed on test system supports relocation types required by -fpic
+for AArch64 small memory model.
+
+@end table
+
 @subsubsection MIPS-specific attributes
 
 @table @code
Index: gcc/testsuite/gcc.target/aarch64/pic-small.c
===
--- gcc/testsuite/gcc.target/aarch64/pic-small.c(revision 225230)
+++ gcc/testsuite/gcc.target/aarch64/pic-small.c(working copy)
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-require-effective-target aarch64_small_fpic } */
 /* { dg-options "-O2 -fpic -fno-inline --save-temps" } */
 
 void abort ();
Index: gcc/testsuite/lib/target-supports.exp
===
--- gcc/testsuite/lib/target-supports.exp   (revision 225230)
+++ gcc/testsuite/lib/target-supports.exp   (working copy)
@@ -937,6 +937,26 @@
 return 0
 }
 
+# On AArch64, if -fpic is not supported, then we will fall back to -fPIC
+# silently.  So, we can't rely on above "check_effective_target_fpic" as it
+# assumes compiler will give warning if -fpic not supported.  Here we check
+# whether binutils supports those new -fpic relocation modifiers, and assume
+# -fpic is supported if there is binutils support.  GCC configuration will
+# enable -fpic for AArch64 in this case.
+#
+# "check_effective_target_aarch64_small_fpic" is dedicated for checking small
+# memory model -fpic relocation types.
+
+proc check_effective_target_aarch64_small_fpic { } {
+if { [istarget aarch64*-*-*] } {
+   return [check_no_compiler_messages aarch64_small_fpic object {
+   void foo (void) { asm ("ldr x0, [x2, #:gotpage_lo15:globalsym]"); }
+   }]
+} else {
+   return 0
+}
+}
+
 # Return 1 if -shared is supported, as in no warnings or errors
 # emitted, 0 otherwise.
 


[COMMITTED][obivious] Document several AArch64-specific test directives

2015-07-01 Thread Jiong Wang

committed as 225233.

2015-07-01  Jiong Wang  

  gcc/   
* doc/sourcebuild.texi (AArch64-specific attributes): Document
"aarch64_tiny", "aarch64_small", "aarch64_large",
"aarch64_little_endian", "aarch64_big_endian".

Index: gcc/ChangeLog
===
--- gcc/ChangeLog   (revision 225232)
+++ gcc/ChangeLog   (working copy)
@@ -1,5 +1,11 @@
 2015-07-01  Jiong Wang  
 
+   * doc/sourcebuild.texi (AArch64-specific attributes): Document
+   "aarch64_tiny", "aarch64_small", "aarch64_large",
+   "aarch64_little_endian", "aarch64_big_endian".
+
+2015-07-01  Jiong Wang  
+
* doc/sourcebuild.texi (AArch64-specific attributes): New subsection.
Document "aarch64_small_fpic".
 
Index: gcc/doc/sourcebuild.texi
===
--- gcc/doc/sourcebuild.texi(revision 225232)
+++ gcc/doc/sourcebuild.texi(working copy)
@@ -1583,6 +1583,16 @@
 @subsubsection AArch64-specific attributes
 
 @table @code
+@item aarch64_tiny
+AArch64 target which generates instruction sequences for tiny memory model.
+@item aarch64_small
+AArch64 target which generates instruction sequences for small memory model.
+@item aarch64_large
+AArch64 target which generates instruction sequences for large memory model.
+@item aarch64_little_endian
+AArch64 target which generates instruction sequences for little endian.
+@item aarch64_big_endian
+AArch64 target which generates instruction sequences for big endian.
 @item aarch64_small_fpic
 Binutils installed on test system supports relocation types required by -fpic
 for AArch64 small memory model.


Re: Add .def file for public target instructions

2015-07-01 Thread Trevor Saunders
On Tue, Jun 23, 2015 at 07:41:42PM +0100, Richard Sandiford wrote:
> [A fair bit later than promised, sorry...]
> 
> Mikhail posted a patch to make genflags generate the default HAVE_foo
> and gen_foo definitions that have recently been added to defaults.h:
> 
>   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00723.html
> 
> I agree it'd be a good idea to generate this kind of thing automatically,
> but I think we should take the opportunity to move the interface to the
> target structure.  I.e.:
> 
>   HAVE_foo -> targetm.have_foo ()
>   gen_foo -> targetm.gen_foo ()
> 
> This should move us closer to the pipedream goal of supporting multiple
> targets at once.  It should also mean that only the target code depends
> on insn-flags.h.

using targetm. certainly seems like an improvement.  I wonder if it
would be faster to stick this data on a per function object.  I think
that would mean you could compute what insns are available once when the
function is created and afterwards all checks would only needed to be
reading computed values.

Trev



Re: [02/13] Replace handle_cache_entry with new interface

2015-07-01 Thread Trevor Saunders
On Tue, Jun 16, 2015 at 09:45:56AM +0100, Richard Sandiford wrote:
> As described in the covering note, this patch replaces handle_cache_entry
> with a new function keep_cache_entry.  It also ensures that elements are
> deleted using the proper function, so that m_n_deleted is updated.

Thanks for taking this off my to do list ;-)

> I couldn't tell whether the unusual name of the function
> ("gt_cleare_cache") is deliberate or not, but I left it be.

I'm not sure what's particularly unusual about it?

> +  static int
> +  keep_cache_entry (tree_int_map *&m)

I think we could now change the interface to take const T *?  I imagine
inlining may get rid of the extra indirection anyway, but it feels
cleaner anyway.

> +  - An optional static function named 'keep_cache_entry'.  This
> +  function is provided only for garbage-collected elements that
> +  are not marked by the normal gc mark pass.  It describes what
> +  what should happen to the element at the end of the gc mark phase.
> +  The return value should be:
> +- 0 if the element should be deleted
> +- 1 if the element should be kept and needs to be marked
> +- -1 if the element should be kept and is already marked.
> +  Returning -1 rather than 1 is purely an optimization.

In theory using an enum seems better, but I'm not sure if the extra
verbosity makes it better in practice.

> +  static int
> +  keep_cache_entry (T &e)
>{
> -if (e != HTAB_EMPTY_ENTRY && e != HTAB_DELETED_ENTRY && !ggc_marked_p 
> (e))
> -  e = static_cast (HTAB_DELETED_ENTRY);
> +return ggc_marked_p (e) ? -1 : 0;

 hmm, this is the only place where -1 is used right?  I believe this
 case only works if the hash table is storing pointers to things in gc
 memory, and only keeps things that get marked by other paths.  I
 believe that means -1 is only a very small optimization because in the
 case we return -1 all we save is the check that that pointer itself is
 marked.  So i'm tempted to change this interface to just return a bool.
 Of course it would be nice if the compiler could inline enough to
 actually optimize out the redundant check if the pointer is makred, but
 that might take some shuffling code around.

thanks for cleaning this up, and sorry my response is delayed.

Trev


Re: Add .def file for public target instructions

2015-07-01 Thread Richard Biener
On Wed, Jul 1, 2015 at 11:39 AM, Trevor Saunders  wrote:
> On Tue, Jun 23, 2015 at 07:41:42PM +0100, Richard Sandiford wrote:
>> [A fair bit later than promised, sorry...]
>>
>> Mikhail posted a patch to make genflags generate the default HAVE_foo
>> and gen_foo definitions that have recently been added to defaults.h:
>>
>>   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00723.html
>>
>> I agree it'd be a good idea to generate this kind of thing automatically,
>> but I think we should take the opportunity to move the interface to the
>> target structure.  I.e.:
>>
>>   HAVE_foo -> targetm.have_foo ()
>>   gen_foo -> targetm.gen_foo ()
>>
>> This should move us closer to the pipedream goal of supporting multiple
>> targets at once.  It should also mean that only the target code depends
>> on insn-flags.h.
>
> using targetm. certainly seems like an improvement.  I wonder if it
> would be faster to stick this data on a per function object.  I think
> that would mean you could compute what insns are available once when the
> function is created and afterwards all checks would only needed to be
> reading computed values.

I think the memory cost of this is prohibitive.

Richard.

> Trev
>


Re: [02/13] Replace handle_cache_entry with new interface

2015-07-01 Thread Richard Sandiford
Trevor Saunders  writes:
> On Tue, Jun 16, 2015 at 09:45:56AM +0100, Richard Sandiford wrote:
>> I couldn't tell whether the unusual name of the function
>> ("gt_cleare_cache") is deliberate or not, but I left it be.
>
> I'm not sure what's particularly unusual about it?

"cleare" rather than "clear".

>> +  static int
>> +  keep_cache_entry (tree_int_map *&m)
>
> I think we could now change the interface to take const T *?  I imagine
> inlining may get rid of the extra indirection anyway, but it feels
> cleaner anyway.

Yeah, good point.

>> + - An optional static function named 'keep_cache_entry'.  This
>> + function is provided only for garbage-collected elements that
>> + are not marked by the normal gc mark pass.  It describes what
>> + what should happen to the element at the end of the gc mark phase.
>> + The return value should be:
>> +   - 0 if the element should be deleted
>> +   - 1 if the element should be kept and needs to be marked
>> +   - -1 if the element should be kept and is already marked.
>> + Returning -1 rather than 1 is purely an optimization.
>
> In theory using an enum seems better, but I'm not sure if the extra
> verbosity makes it better in practice.

Yeah, I wondered about an enum but it seemed like overkill.

>> +  static int
>> +  keep_cache_entry (T &e)
>>{
>> - if (e != HTAB_EMPTY_ENTRY && e != HTAB_DELETED_ENTRY &&
>> !ggc_marked_p (e))
>> -  e = static_cast (HTAB_DELETED_ENTRY);
>> +return ggc_marked_p (e) ? -1 : 0;
>
>  hmm, this is the only place where -1 is used right?  I believe this
>  case only works if the hash table is storing pointers to things in gc
>  memory, and only keeps things that get marked by other paths.  I
>  believe that means -1 is only a very small optimization because in the
>  case we return -1 all we save is the check that that pointer itself is
>  marked.

Right.  But it's an optimisation that we had before and I think we
should keep it.  The -1 case is in the generic traits rather than
"user" code.

>  So i'm tempted to change this interface to just return a bool.
>  Of course it would be nice if the compiler could inline enough to
>  actually optimize out the redundant check if the pointer is makred, but
>  that might take some shuffling code around.

In practice all calls will return from {0, 1} or {0, -1}, so assuming
sensible inlining, no caller will use all three paths.

Thanks,
Richard



[PATCH, libiberty]: Avoid "enum conversion when passing argument 1 of ‘getrusage’ is invalid in C++" warning

2015-07-01 Thread Uros Bizjak
Hello!

This patch avoids "enum conversion when passing argument 1 of
‘getrusage’ is invalid in C++" warning when compiling getruntime.c.
The condition is copied from sys/resource.h.

2015-07-01  Uros Bizjak  

* getruntime.c (get_run_time) [__USE_GNU]: Use RUSAGE_SELF as
argument 1 of getrusage call.

Bootstrapped on x86_64-linux-gnu.

OK for mainline?

Uros.
Index: getruntime.c
===
--- getruntime.c(revision 225221)
+++ getruntime.c(working copy)
@@ -95,7 +95,11 @@ get_run_time (void)
 #if defined (HAVE_GETRUSAGE) && defined (HAVE_SYS_RESOURCE_H)
   struct rusage rusage;
 
+#if defined __USE_GNU && !defined __cplusplus
+  getrusage (RUSAGE_SELF, &rusage);
+#else
   getrusage (0, &rusage);
+#endif
   return (rusage.ru_utime.tv_sec * 100 + rusage.ru_utime.tv_usec
  + rusage.ru_stime.tv_sec * 100 + rusage.ru_stime.tv_usec);
 #else /* ! HAVE_GETRUSAGE */


Re: libgomp: libgomp.oacc-c-c++-common/lib-62.c is for acc_device_nvidia only

2015-07-01 Thread Tom de Vries

On 19/06/15 09:50, Thomas Schwinge wrote:

Hi!

On Tue, 5 May 2015 16:09:18 +0200, I wrote:

I don't know why libgomp.oacc-c-c++-common/lib-62.c contains this
explicit acc_init call with acc_device_nvidia -- generally, the test
cases should not contain such unconditional statements.  So, let's then
please remove this.  See
libgomp/testsuite/libgomp.oacc-c-c++-common/lib-66.c for a very similar
test case, which does this differently.


Committed in r224640:

commit 3625ad60ab1ad783f4afead68f44b19011e4780d
Author: tschwinge 
Date:   Fri Jun 19 07:41:44 2015 +

 libgomp: libgomp.oacc-c-c++-common/lib-62.c is for acc_device_nvidia only

libgomp/
* testsuite/libgomp.oacc-c-c++-common/lib-62.c: Only consider for
acc_device_nvidia.

 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@224640 
138bc75d-0d04-0410-961f-82ee72b054a4


Hi Thomas,

I've committed attached patch to gomp-4_0-branch, before finding this 
patch (which is a bit more thorough). You can drop it with the next 
merge from trunk.


Thanks,
- Tom
Run libgomp.oacc-c-c++-common/lib-62.c only for nvidia

2015-07-01  Tom de Vries  

	* testsuite/libgomp.oacc-c-c++-common/lib-62.c: Only run for nvidia.
---
 libgomp/testsuite/libgomp.oacc-c-c++-common/lib-62.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-62.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-62.c
index 47dc953..6e6f8c5 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-62.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-62.c
@@ -1,4 +1,4 @@
-/* { dg-do run } */
+/* { dg-do run { target openacc_nvidia_accel_selected } } */
 
 #include 
 #include 
-- 
1.9.1



Re: Add .def file for public target instructions

2015-07-01 Thread Richard Sandiford
Richard Biener  writes:
> On Wed, Jul 1, 2015 at 11:39 AM, Trevor Saunders  
> wrote:
>> On Tue, Jun 23, 2015 at 07:41:42PM +0100, Richard Sandiford wrote:
>>> [A fair bit later than promised, sorry...]
>>>
>>> Mikhail posted a patch to make genflags generate the default HAVE_foo
>>> and gen_foo definitions that have recently been added to defaults.h:
>>>
>>>   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00723.html
>>>
>>> I agree it'd be a good idea to generate this kind of thing automatically,
>>> but I think we should take the opportunity to move the interface to the
>>> target structure.  I.e.:
>>>
>>>   HAVE_foo -> targetm.have_foo ()
>>>   gen_foo -> targetm.gen_foo ()
>>>
>>> This should move us closer to the pipedream goal of supporting multiple
>>> targets at once.  It should also mean that only the target code depends
>>> on insn-flags.h.
>>
>> using targetm. certainly seems like an improvement.  I wonder if it
>> would be faster to stick this data on a per function object.  I think
>> that would mean you could compute what insns are available once when the
>> function is created and afterwards all checks would only needed to be
>> reading computed values.
>
> I think the memory cost of this is prohibitive.

Yeah.  I did wonder about having optabs-like caching in some
target_globals structure, but I don't think it's really worth it.
In practice we only tend to call the have_*() functions when we're
trying to generate something (unlike optabs), and so any saving would
be dwarfed by the cost of generating whatever rtx we go on to create.

Thanks,
Richard



Re: Add .def file for public target instructions

2015-07-01 Thread Richard Sandiford
Richard Sandiford  writes:
> Richard Biener  writes:
>> On Wed, Jul 1, 2015 at 11:39 AM, Trevor Saunders
>>  wrote:
>>> On Tue, Jun 23, 2015 at 07:41:42PM +0100, Richard Sandiford wrote:
 [A fair bit later than promised, sorry...]

 Mikhail posted a patch to make genflags generate the default HAVE_foo
 and gen_foo definitions that have recently been added to defaults.h:

   https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00723.html

 I agree it'd be a good idea to generate this kind of thing automatically,
 but I think we should take the opportunity to move the interface to the
 target structure.  I.e.:

   HAVE_foo -> targetm.have_foo ()
   gen_foo -> targetm.gen_foo ()

 This should move us closer to the pipedream goal of supporting multiple
 targets at once.  It should also mean that only the target code depends
 on insn-flags.h.
>>>
>>> using targetm. certainly seems like an improvement.  I wonder if it
>>> would be faster to stick this data on a per function object.  I think
>>> that would mean you could compute what insns are available once when the
>>> function is created and afterwards all checks would only needed to be
>>> reading computed values.
>>
>> I think the memory cost of this is prohibitive.
>
> Yeah.  I did wonder about having optabs-like caching in some
> target_globals structure, but I don't think it's really worth it.
> In practice we only tend to call the have_*() functions when we're
> trying to generate something (unlike optabs), and so any saving would
> be dwarfed by the cost of generating whatever rtx we go on to create.

...plus (forgot the main reason): the condition for things like return
and simple_return are only available after register allocation.

Thanks,
Richard



[PATCH, libstdc++]: Avoid "libsupc++/guard.cc:118:18: warning: variable ‘__p’ set but not used" warning

2015-07-01 Thread Uros Bizjak
Hello!

2015-07-01  Uros Bizjak  

* libsupc++/guard.cc (__test_and_acquire): Use __p after __atomic_load
to avoid unused variable warning.
(__set_and_release): Use __p after __atomic_store to avoid unused
variable warning.

Bootstrapped and regression tested on x86_64-linux-gnu.

OK for mainline?

Uros.
Index: libsupc++/guard.cc
===
--- libsupc++/guard.cc  (revision 225221)
+++ libsupc++/guard.cc  (working copy)
@@ -117,6 +117,7 @@ __test_and_acquire (__cxxabiv1::__guard *g)
   unsigned char __c;
   unsigned char *__p = reinterpret_cast(g);
   __atomic_load (__p, &__c,  __ATOMIC_ACQUIRE);
+  (void) __p;
   return _GLIBCXX_GUARD_TEST(&__c);
 }
 #  define _GLIBCXX_GUARD_TEST_AND_ACQUIRE(G) __test_and_acquire (G)
@@ -132,6 +133,7 @@ __set_and_release (__cxxabiv1::__guard *g)
   unsigned char *__p = reinterpret_cast(g);
   unsigned char val = 1;
   __atomic_store (__p, &val, __ATOMIC_RELEASE);
+  (void) __p;
 }
 #  define _GLIBCXX_GUARD_SET_AND_RELEASE(G) __set_and_release (G)
 # endif


[scalar-storage-order] Add pragma scalar_storage_order

2015-07-01 Thread Eric Botcazou
This adds a #pragma scalar_storage_order directive to the C family of 
languages that makes it possible to specify a default SSO.

Tested on x86_64-suse-linux. applied on the branch.


* doc/extend.texi (Structure-Packing Pragmas): Rename into...
( Structure-Layout Pragmas): ...this.  Document scalar_storage_order.
c-family/
* c-common.c (handle_scalar_storage_order_attribute): Add the attribute
on success and tweak.
* c-pragma.c (enum scalar_storage_order_kind): New enumeration.
(global_sso_kind): New variable.
(maybe_apply_pragma_scalar_storage_order): New function.
(handle_pragma_scalar_storage_order): Likewise.
(init_pragma): Register scalar_storage_order.
* c-pragma.h (maybe_apply_pragma_scalar_storage_order): Declare.
c/
* c-decl.c (finish_struct): Call it.
cp/
* class.c (finish_struct_1): Likewise.
testsuite/
* c-c++-common/sso-5.c: New test.

-- 
Eric BotcazouIndex: doc/extend.texi
===
--- doc/extend.texi	(revision 224700)
+++ doc/extend.texi	(working copy)
@@ -18108,7 +18108,7 @@ for further explanation.
 * Darwin Pragmas::
 * Solaris Pragmas::
 * Symbol-Renaming Pragmas::
-* Structure-Packing Pragmas::
+* Structure-Layout Pragmas::
 * Weak Pragmas::
 * Diagnostic Pragmas::
 * Visibility Pragmas::
@@ -18371,8 +18371,8 @@ the name does not change.
 always the C-language name.
 @end enumerate
 
-@node Structure-Packing Pragmas
-@subsection Structure-Packing Pragmas
+@node Structure-Layout Pragmas
+@subsection Structure-Layout Pragmas
 
 For compatibility with Microsoft Windows compilers, GCC supports a
 set of @code{#pragma} directives that change the maximum alignment of
@@ -18395,17 +18395,29 @@ multiple @code{#pragma pack(@var{n})} in
 @code{#pragma pack(pop)}.
 @end enumerate
 
-Some targets, e.g.@: x86 and PowerPC, support the @code{ms_struct}
-@code{#pragma} which lays out a structure as the documented
-@code{__attribute__ ((ms_struct))}.
+Some targets, e.g.@: x86 and PowerPC, support the @code{#pragma ms_struct}
+directive which lays out structures, unions and classes subsequently defined
+as the documented @code{__attribute__ ((ms_struct))}.
+
 @enumerate
-@item @code{#pragma ms_struct on} turns on the layout for structures
-declared.
-@item @code{#pragma ms_struct off} turns off the layout for structures
-declared.
+@item @code{#pragma ms_struct on} turns on the Microsoft layout.
+@item @code{#pragma ms_struct off} turns off the Microsoft layout.
 @item @code{#pragma ms_struct reset} goes back to the default layout.
 @end enumerate
 
+Most targets also support the @code{#pragma scalar_storage_order} directive
+which lays out structures, unions and classes subsequently defined as the
+documented @code{__attribute__ ((scalar_storage_order))}.
+
+@enumerate
+@item @code{#pragma scalar_storage_order big-endian} sets the storage order
+of the scalar fields to big-endian.
+@item @code{#pragma scalar_storage_order little-endian} sets the storage order
+of the scalar fields to little-endian.
+@item @code{#pragma scalar_storage_order default} goes back to the default
+endianness.
+@end enumerate
+
 @node Weak Pragmas
 @subsection Weak Pragmas
 
Index: c-family/c-common.c
===
--- c-family/c-common.c	(revision 224700)
+++ c-family/c-common.c	(working copy)
@@ -7504,8 +7504,6 @@ handle_scalar_storage_order_attribute (t
   tree id = TREE_VALUE (args);
   tree type;
 
-  *no_add_attrs = true;
-
   if (TREE_CODE (*node) == TYPE_DECL
   && ! (flags & ATTR_FLAG_CXX11))
 node = &TREE_TYPE (*node);
@@ -7521,16 +7519,10 @@ handle_scalar_storage_order_attribute (t
 
   if (TREE_CODE (id) == STRING_CST
 	  && strcmp (TREE_STRING_POINTER (id), "big-endian") == 0)
-	{
-	  if (!BYTES_BIG_ENDIAN)
-	TYPE_REVERSE_STORAGE_ORDER (type) = 1;
-	}
+	TYPE_REVERSE_STORAGE_ORDER (type) = !BYTES_BIG_ENDIAN;
   else if (TREE_CODE (id) == STRING_CST
 	   && strcmp (TREE_STRING_POINTER (id), "little-endian") == 0)
-	{
-	  if (BYTES_BIG_ENDIAN)
-	TYPE_REVERSE_STORAGE_ORDER (type) = 1;
-	}
+	TYPE_REVERSE_STORAGE_ORDER (type) = BYTES_BIG_ENDIAN;
   else
 	error ("scalar_storage_order argument must be one of \"big-endian\" "
 	   "or \"little-endian\"");
@@ -7540,6 +7532,7 @@ handle_scalar_storage_order_attribute (t
 
  ignored:
   warning (OPT_Wattributes, "%qE attribute ignored", name);
+  *no_add_attrs = true;
   return NULL_TREE;
 }
 
Index: c-family/c-pragma.c
===
--- c-family/c-pragma.c	(revision 224467)
+++ c-family/c-pragma.c	(working copy)
@@ -400,6 +400,58 @@ handle_pragma_weak (cpp_reader * ARG_UNU
 }
 }
 
+enum scalar_storage_order_kind
+{
+  SSO_DEFAULT,
+  SSO_BIG_ENDIAN,
+  SSO_LITTLE_ENDIAN
+};
+
+static enum scalar_storage_order_kind global_sso_kind = SSO_DEFAULT;
+
+void
+maybe_apply_pr

[gomp4.1] Handle linear clause modifiers in declare simd

2015-07-01 Thread Jakub Jelinek
Hi!

I've committed following patch, which per the new ABI additions
mangles and handles the various new linear clause modifiers in
declare simd functions.  The vectorizer side is not done yet,
for now we'll never use SIMD_CLONE_ARG_TYPE_LINEAR_*_CONSTANT_STEP
in vectorized routines, that waits first for resolution of
PR66718.

2015-07-01  Jakub Jelinek  

* cgraph.h (enum cgraph_simd_clone_arg_type): Add
SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP,
SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP,
and SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP.
(struct cgraph_simd_clone_arg): Adjust comment.
* omp-low.c (simd_clone_clauses_extract): Honor
OMP_CLAUSE_LINEAR_KIND.
(simd_clone_mangle): Mangle the various linear kinds
per the new ABI.
(simd_clone_adjust_argument_types): Handle
SIMD_CLONE_ARG_TYPE_LINEAR_*_CONSTANT_STEP.
(simd_clone_init_simd_arrays): Don't do anything
for uval.
(simd_clone_adjust): Handle
SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP like
SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP.
Handle SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP.
c/
* c-tree.h (c_finish_omp_clauses): Add declare_simd argument.
* c-parser.c (c_parser_omp_clause_linear): Don't handle uval
modifier in C.
(c_parser_omp_all_clauses): If mask includes uniform clause,
pass true to c_finish_omp_clauses' declare_simd.
* c-typeck.c (c_finish_omp_clauses): Add declare_simd argument,
don't set need_implicitly_determined if it is true.
cp/
* cp-tree.h (finish_omp_clauses): Add declare_simd argument.
* parser.c (cp_parser_omp_all_clauses): If mask includes uniform
clause, pass true to finish_omp_clauses' declare_simd.
* pt.c (apply_late_template_attributes): Pass true to
finish_omp_clauses' declare_simd.
* semantics.c (finish_omp_clauses): Add declare_simd argument,
don't set need_implicitly_determined if it is true.
testsuite/
* gcc.dg/gomp/clause-1.c (foo): Add some linear clause tests.
* g++.dg/gomp/clause-3.C (foo): Likewise.
* g++.dg/gomp/declare-simd-3.C: New test.

--- gcc/cgraph.h.jj 2015-06-30 14:24:39.515064819 +0200
+++ gcc/cgraph.h2015-06-30 15:12:25.534761008 +0200
@@ -645,8 +645,14 @@ enum cgraph_simd_clone_arg_type
 {
   SIMD_CLONE_ARG_TYPE_VECTOR,
   SIMD_CLONE_ARG_TYPE_UNIFORM,
+  /* These are only for integer/pointer arguments passed by value.  */
   SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP,
   SIMD_CLONE_ARG_TYPE_LINEAR_VARIABLE_STEP,
+  /* These 3 are only for reference type arguments or arguments passed
+ by reference.  */
+  SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP,
+  SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP,
+  SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP,
   SIMD_CLONE_ARG_TYPE_MASK
 };
 
@@ -686,7 +692,7 @@ struct GTY(()) cgraph_simd_clone_arg {
  variable), uniform, or vector.  */
   enum cgraph_simd_clone_arg_type arg_type;
 
-  /* For arg_type SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP this is
+  /* For arg_type SIMD_CLONE_ARG_TYPE_LINEAR_*CONSTANT_STEP this is
  the constant linear step, if arg_type is
  SIMD_CLONE_ARG_TYPE_LINEAR_VARIABLE_STEP, this is index of
  the uniform argument holding the step, otherwise 0.  */
--- gcc/omp-low.c.jj2015-06-30 14:24:56.618812148 +0200
+++ gcc/omp-low.c   2015-06-30 17:35:21.700736990 +0200
@@ -14092,8 +14092,29 @@ simd_clone_clauses_extract (struct cgrap
  }
else
  {
-   clone_info->args[argno].arg_type
- = SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP;
+   enum cgraph_simd_clone_arg_type arg_type;
+   if (TREE_CODE (args[argno]) == REFERENCE_TYPE)
+ switch (OMP_CLAUSE_LINEAR_KIND (t))
+   {
+   case OMP_CLAUSE_LINEAR_REF:
+ arg_type
+   = SIMD_CLONE_ARG_TYPE_LINEAR_REF_CONSTANT_STEP;
+ break;
+   case OMP_CLAUSE_LINEAR_UVAL:
+ arg_type
+   = SIMD_CLONE_ARG_TYPE_LINEAR_UVAL_CONSTANT_STEP;
+ break;
+   case OMP_CLAUSE_LINEAR_VAL:
+   case OMP_CLAUSE_LINEAR_DEFAULT:
+ arg_type
+   = SIMD_CLONE_ARG_TYPE_LINEAR_VAL_CONSTANT_STEP;
+ break;
+   default:
+ gcc_unreachable ();
+   }
+   else
+ arg_type = SIMD_CLONE_ARG_TYPE_LINEAR_CONSTANT_STEP;
+   clone_info->args[argno].arg_type = arg_type;
clone_info->args[argno].linear_step = tree_to_shwi (step);
  }
  }
@@ -1

[gomp4, committed] Gracefully handle acc_init (nvidia) when not supported

2015-07-01 Thread Tom de Vries

Hi,

I noticed on gomp-4_0-branch that lib-62.c was failing with a sigsegv:
...
Program received signal SIGSEGV, Segmentation fault.
acc_init_1 (d=acc_device_nvidia) at src/libgomp/oacc-init.c:179
179   ndevs = base_dev->get_num_devices_func ();
(gdb) p base_dev
$1 = (struct gomp_device_descr *) 0x0
...

The problem is in acc_init_1, where we use base_dev before the base_dev 
NULL check:

...
  base_dev = resolve_device (d);

  ndevs = base_dev->get_num_devices_func ();

  if (!base_dev || ndevs <= 0 || goacc_device_num >= ndevs)
gomp_fatal ("device %s not supported", name_of_acc_device_t (d));
...

base_dev is NULL because the device type nvidia is not supported.

This patch fixes the sigsegv, and adds a test that calls 'acc_init 
(acc_device_nvidia)' when device type nvidia is not supported.


Committed to gomp-4_0-branch.

Thanks,
- Tom
Gracefully handle acc_init (nvidia) when not supported

2015-07-01  Tom de Vries  

	* oacc-init.c (acc_init_1): Move base_dev NULL test to before use.
	* testsuite/lib/libgomp.exp
	(check_effective_target_openacc_nvidia_accel_supported): New proc.
	* testsuite/libgomp.oacc-c-c++-common/lib-93.c: New test.
---
 libgomp/oacc-init.c  |  5 -
 libgomp/testsuite/lib/libgomp.exp|  9 +
 libgomp/testsuite/libgomp.oacc-c-c++-common/lib-93.c | 16 
 3 files changed, 29 insertions(+), 1 deletion(-)
 create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/lib-93.c

diff --git a/libgomp/oacc-init.c b/libgomp/oacc-init.c
index e772f48..4d0fc90 100644
--- a/libgomp/oacc-init.c
+++ b/libgomp/oacc-init.c
@@ -176,9 +176,12 @@ acc_init_1 (acc_device_t d)
 
   base_dev = resolve_device (d);
 
+  if (!base_dev)
+gomp_fatal ("device %s not supported", name_of_acc_device_t (d));
+
   ndevs = base_dev->get_num_devices_func ();
 
-  if (!base_dev || ndevs <= 0 || goacc_device_num >= ndevs)
+  if (ndevs <= 0 || goacc_device_num >= ndevs)
 gomp_fatal ("device %s not supported", name_of_acc_device_t (d));
 
   acc_dev = &base_dev[goacc_device_num];
diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index 06bab54..6dba22b 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -369,6 +369,15 @@ proc check_effective_target_offload_device { } {
 } ]
 }
 
+proc check_effective_target_openacc_nvidia_accel_supported { } {
+global offload_targets_s_openacc
+set res [lsearch $offload_targets_s_openacc "nvidia" ]
+if { $res != -1 } {
+	return 1;
+}
+return 0;
+}
+
 # Return 1 if at least one nvidia board is present.
 
 proc check_effective_target_openacc_nvidia_accel_present { } {
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-93.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-93.c
new file mode 100644
index 000..853de33
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-93.c
@@ -0,0 +1,16 @@
+/* { dg-do run { target { ! openacc_nvidia_accel_supported } } } */
+
+#include 
+
+int
+main (void)
+{
+  acc_init (acc_device_nvidia);
+
+  acc_shutdown (acc_device_nvidia);
+
+  return 0;
+}
+
+/* { dg-output "device nvidia not supported" } */
+/* { dg-shouldfail "" } */
-- 
1.9.1



[gomp4, PATCH] Fix libgomp.oacc-c-c++-common/lib-3.c

2015-07-01 Thread Tom de Vries

Hi,

testcase libgomp.oacc-c-c++-common/lib-3.c is supposed to fail.

It fails currently in two ways:
- no device found, if there is no nonhost device type supported, so
  just host and host_nonshm
- no device initialized, if there is a nonhost device type supported,
  f.i. nvidia

The reason for the different failure modes is the usage of 
acc_device_not_host.


Neither of the current failure modes is matches by the current dg-output:
...
/* { dg-output "device \[0-9\]+\\\(\[0-9\]+\\\) is initialized" } */
...
I don't understand what this dg-output is trying to achieve.

Attached patch makes sure that both current failure modes are tested and 
accepted.


OK for gomp-4_0-branch?

Thanks,
- Tom
Fix libgomp.oacc-c-c++-common/lib-3.c

2015-07-01  Tom de Vries  

	* testsuite/lib/libgomp.exp (offload_targets_nonhost): New var.
	(check_effective_target_offload_target_nonhost_supported): New proc.
	* testsuite/libgomp.oacc-c-c++-common/lib-3.c: Only run if
	offload_target_nonhost_supported.
	* testsuite/libgomp.oacc-c-c++-common/lib-3b.c: New test.  Copy of
	lib-3.c, but only run if !offload_target_nonhost_supported.
---
 libgomp/testsuite/lib/libgomp.exp| 13 +
 libgomp/testsuite/libgomp.oacc-c-c++-common/lib-3.c  |  4 ++--
 libgomp/testsuite/libgomp.oacc-c-c++-common/lib-3b.c | 16 
 3 files changed, 31 insertions(+), 2 deletions(-)
 create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/lib-3b.c

diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index 6dba22b..951e043 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -38,9 +38,11 @@ load_file libgomp-test-support.exp
 # Populate offload_targets_s (offloading targets separated by a space), and
 # offload_targets_s_openacc (the same, but with OpenACC names; OpenACC spells
 # some of them a little differently).
+set offload_targets_nonhost 0
 set offload_targets_s [split $offload_targets ","]
 set offload_targets_s_openacc {}
 foreach offload_target_openacc $offload_targets_s {
+set nonhost 1
 switch $offload_target_openacc {
 	intelmic {
 	# TODO.  Skip; will all FAIL because of missing
@@ -50,8 +52,14 @@ foreach offload_target_openacc $offload_targets_s {
 	nvptx {
 	set offload_target_openacc "nvidia"
 	}
+	host_nonshm {
+	set nonhost 0
+	}
 }
 lappend offload_targets_s_openacc "$offload_target_openacc"
+if { $nonhost == 1 } {
+	set offload_targets_nonhost 1
+}
 }
 lappend offload_targets_s_openacc "host"
 
@@ -369,6 +377,11 @@ proc check_effective_target_offload_device { } {
 } ]
 }
 
+proc check_effective_target_offload_target_nonhost_supported { } {
+global offload_targets_nonhost
+return $offload_targets_nonhost;
+}
+
 proc check_effective_target_openacc_nvidia_accel_supported { } {
 global offload_targets_s_openacc
 set res [lsearch $offload_targets_s_openacc "nvidia" ]
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-3.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-3.c
index bb76c82..2a8c437 100644
--- a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-3.c
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-3.c
@@ -1,4 +1,4 @@
-/* { dg-do run } */
+/* { dg-do run { target { offload_target_nonhost_supported } } } */
 
 #include 
 
@@ -12,5 +12,5 @@ main (int argc, char **argv)
   return 0;
 }
 
-/* { dg-output "device \[0-9\]+\\\(\[0-9\]+\\\) is initialized" } */
+/* { dg-output "no device initialized" } */
 /* { dg-shouldfail "" } */
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-3b.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-3b.c
new file mode 100644
index 000..f21830c
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-3b.c
@@ -0,0 +1,16 @@
+/* { dg-do run { target { ! offload_target_nonhost_supported } } } */
+
+#include 
+
+int
+main (int argc, char **argv)
+{
+  acc_init (acc_device_host);
+
+  acc_shutdown (acc_device_not_host);
+
+  return 0;
+}
+
+/* { dg-output "no device found" } */
+/* { dg-shouldfail "" } */
-- 
1.9.1



Re: [PATCH, C++-1z] Implement N4197 - Adding u8 character literals

2015-07-01 Thread Richard Biener
On Mon, Jun 29, 2015 at 3:41 PM, Jason Merrill  wrote:
> On 06/27/2015 08:14 PM, Ed Smith-Rowland wrote:
>>
>> In c-ada-specs.c/print_ada_macros() I just write these as a char
>> constant rather than spelling the token.
>> We could do the latter.  You'd see the "u8" then I think.  I couldn't
>> find in the Ada test suite where this was exercised.
>
>
> If Ada folks don't respond, let's do the latter.  OK with that change.

It seems like this change caused genmatch to now emit

g++ -fno-PIE -c   -g  -DIN_GCC-fno-exceptions -fno-rtti
-fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
-Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic
-Wno-long-long -Wno-variadic-macros -Wno-overlength-strings
-fno-common  -DHAVE_CONFIG_H -I. -I.
-I/space/rguenther/tramp3d/trunk/gcc
-I/space/rguenther/tramp3d/trunk/gcc/.
-I/space/rguenther/tramp3d/trunk/gcc/../include
-I/space/rguenther/tramp3d/trunk/gcc/../libcpp/include
-I/space/rguenther/tramp3d/trunk/gcc/../libdecnumber
-I/space/rguenther/tramp3d/trunk/gcc/../libdecnumber/bid
-I../libdecnumber -I/space/rguenther/tramp3d/trunk/gcc/../libbacktrace
  -o fold-const.o -MT fold-const.o -MMD -MP -MF ./.deps/fold-const.TPo
/space/rguenther/tramp3d/trunk/gcc/fold-const.c
build/genmatch --gimple /space/rguenther/tramp3d/trunk/gcc/match.pd \
> tmp-gimple-match.c
/space/rguenther/tramp3d/trunk/gcc/match.pd:1636:0 error: unspellable
token PADDING

^
/space/rguenther/tramp3d/trunk/gcc/match.pd:1636:0 error: unspellable
token PADDING

^...

genmatch "spells" tokens to re-generate input.

Any idea what specifically could have caused this?

Thanks,
Richard.

> Jason
>


Re: [02/13] Replace handle_cache_entry with new interface

2015-07-01 Thread Trevor Saunders
On Wed, Jul 01, 2015 at 10:59:15AM +0100, Richard Sandiford wrote:
> Trevor Saunders  writes:
> > On Tue, Jun 16, 2015 at 09:45:56AM +0100, Richard Sandiford wrote:
> >> I couldn't tell whether the unusual name of the function
> >> ("gt_cleare_cache") is deliberate or not, but I left it be.
> >
> > I'm not sure what's particularly unusual about it?
> 
> "cleare" rather than "clear".

oh! I didn't notice that but yeah its wierd probably just being a bad
typist.

> >> +  static int
> >> +  keep_cache_entry (tree_int_map *&m)
> >
> > I think we could now change the interface to take const T *?  I imagine
> > inlining may get rid of the extra indirection anyway, but it feels
> > cleaner anyway.
> 
> Yeah, good point.
> 
> >> +   - An optional static function named 'keep_cache_entry'.  This
> >> +   function is provided only for garbage-collected elements that
> >> +   are not marked by the normal gc mark pass.  It describes what
> >> +   what should happen to the element at the end of the gc mark phase.
> >> +   The return value should be:
> >> + - 0 if the element should be deleted
> >> + - 1 if the element should be kept and needs to be marked
> >> + - -1 if the element should be kept and is already marked.
> >> +   Returning -1 rather than 1 is purely an optimization.
> >
> > In theory using an enum seems better, but I'm not sure if the extra
> > verbosity makes it better in practice.
> 
> Yeah, I wondered about an enum but it seemed like overkill.
> 
> >> +  static int
> >> +  keep_cache_entry (T &e)
> >>{
> >> - if (e != HTAB_EMPTY_ENTRY && e != HTAB_DELETED_ENTRY &&
> >> !ggc_marked_p (e))
> >> -  e = static_cast (HTAB_DELETED_ENTRY);
> >> +return ggc_marked_p (e) ? -1 : 0;
> >
> >  hmm, this is the only place where -1 is used right?  I believe this
> >  case only works if the hash table is storing pointers to things in gc
> >  memory, and only keeps things that get marked by other paths.  I
> >  believe that means -1 is only a very small optimization because in the
> >  case we return -1 all we save is the check that that pointer itself is
> >  marked.
> 
> Right.  But it's an optimisation that we had before and I think we
> should keep it.  The -1 case is in the generic traits rather than
> "user" code.
> 
> >  So i'm tempted to change this interface to just return a bool.
> >  Of course it would be nice if the compiler could inline enough to
> >  actually optimize out the redundant check if the pointer is makred, but
> >  that might take some shuffling code around.
> 
> In practice all calls will return from {0, 1} or {0, -1}, so assuming
> sensible inlining, no caller will use all three paths.

yeah

Trev


> 
> Thanks,
> Richard
> 


Re: [PATCH, C++-1z] Implement N4197 - Adding u8 character literals

2015-07-01 Thread Richard Biener
On Wed, Jul 1, 2015 at 1:24 PM, Richard Biener
 wrote:
> On Mon, Jun 29, 2015 at 3:41 PM, Jason Merrill  wrote:
>> On 06/27/2015 08:14 PM, Ed Smith-Rowland wrote:
>>>
>>> In c-ada-specs.c/print_ada_macros() I just write these as a char
>>> constant rather than spelling the token.
>>> We could do the latter.  You'd see the "u8" then I think.  I couldn't
>>> find in the Ada test suite where this was exercised.
>>
>>
>> If Ada folks don't respond, let's do the latter.  OK with that change.
>
> It seems like this change caused genmatch to now emit
>
> g++ -fno-PIE -c   -g  -DIN_GCC-fno-exceptions -fno-rtti
> -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings
> -Wcast-qual -Wmissing-format-attribute -Woverloaded-virtual -pedantic
> -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings
> -fno-common  -DHAVE_CONFIG_H -I. -I.
> -I/space/rguenther/tramp3d/trunk/gcc
> -I/space/rguenther/tramp3d/trunk/gcc/.
> -I/space/rguenther/tramp3d/trunk/gcc/../include
> -I/space/rguenther/tramp3d/trunk/gcc/../libcpp/include
> -I/space/rguenther/tramp3d/trunk/gcc/../libdecnumber
> -I/space/rguenther/tramp3d/trunk/gcc/../libdecnumber/bid
> -I../libdecnumber -I/space/rguenther/tramp3d/trunk/gcc/../libbacktrace
>   -o fold-const.o -MT fold-const.o -MMD -MP -MF ./.deps/fold-const.TPo
> /space/rguenther/tramp3d/trunk/gcc/fold-const.c
> build/genmatch --gimple /space/rguenther/tramp3d/trunk/gcc/match.pd \
> > tmp-gimple-match.c
> /space/rguenther/tramp3d/trunk/gcc/match.pd:1636:0 error: unspellable
> token PADDING
>
> ^
> /space/rguenther/tramp3d/trunk/gcc/match.pd:1636:0 error: unspellable
> token PADDING
>
> ^...
>
> genmatch "spells" tokens to re-generate input.
>
> Any idea what specifically could have caused this?

Oh, it just seems that genmatch is not re-linked when libcpp changed.
So the above is spurious in my dev-tree.

Richard.

> Thanks,
> Richard.
>
>> Jason
>>


[ARM] Fix typos in ARMv8 __sync builtins tests.

2015-07-01 Thread Matthew Wahab

Hello,

Tests I recently added for the code generated by the ARM backend for the __sync
builtins had

- 'do-require-effective-target', instead of the directive
  'dg-require-effective-target' and
- 'stlex' instead of 'strex' in the expected output for armv8-sync-op-acquire.c

This meant the tests ran on targets that did not support them and reported a
failure for correct code. This patch fixes both mistakes.

Tested arm-none-linux-gnueabihf with check-gcc.

Ok for trunk?
Matthew

gcc/testsuite
2015-07-01  Matthew Wahab  

* gcc.target/arm/armv8-sync-comp-swap.c: Replace
'do-require-effective-target' with 'dg-require-effective-target'.
* gcc.target/arm/armv8-sync-op-full.c: Likewise.
* gcc.target/arm/armv8-sync-op-release.c: Likewise.
* gcc.target/arm/armv8-sync-op-acquire.c: Likewise.  Also, replace
'stlex' with 'strex' as the expected output.
diff --git a/gcc/testsuite/gcc.target/arm/armv8-sync-comp-swap.c b/gcc/testsuite/gcc.target/arm/armv8-sync-comp-swap.c
index f96c81a..0e95986 100644
--- a/gcc/testsuite/gcc.target/arm/armv8-sync-comp-swap.c
+++ b/gcc/testsuite/gcc.target/arm/armv8-sync-comp-swap.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { do-require-effective-target arm_arch_v8a_ok } */
+/* { dg-require-effective-target arm_arch_v8a_ok } */
 /* { dg-options "-O2" } */
 /* { dg-add-options arm_arch_v8a } */
 
diff --git a/gcc/testsuite/gcc.target/arm/armv8-sync-op-acquire.c b/gcc/testsuite/gcc.target/arm/armv8-sync-op-acquire.c
index 8d6659b..c448599 100644
--- a/gcc/testsuite/gcc.target/arm/armv8-sync-op-acquire.c
+++ b/gcc/testsuite/gcc.target/arm/armv8-sync-op-acquire.c
@@ -1,10 +1,10 @@
 /* { dg-do compile } */
-/* { do-require-effective-target arm_arch_v8a_ok } */
+/* { dg-require-effective-target arm_arch_v8a_ok } */
 /* { dg-options "-O2" } */
 /* { dg-add-options arm_arch_v8a } */
 
 #include "../aarch64/sync-op-acquire.x"
 
 /* { dg-final { scan-assembler-times "ldrex" 1 } } */
-/* { dg-final { scan-assembler-times "stlex" 1 } } */
+/* { dg-final { scan-assembler-times "strex" 1 } } */
 /* { dg-final { scan-assembler-times "dmb" 1 } } */
diff --git a/gcc/testsuite/gcc.target/arm/armv8-sync-op-full.c b/gcc/testsuite/gcc.target/arm/armv8-sync-op-full.c
index a5ad3bd..cce9e00 100644
--- a/gcc/testsuite/gcc.target/arm/armv8-sync-op-full.c
+++ b/gcc/testsuite/gcc.target/arm/armv8-sync-op-full.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { do-require-effective-target arm_arch_v8a_ok } */
+/* { dg-require-effective-target arm_arch_v8a_ok } */
 /* { dg-options "-O2" } */
 /* { dg-add-options arm_arch_v8a } */
 
diff --git a/gcc/testsuite/gcc.target/arm/armv8-sync-op-release.c b/gcc/testsuite/gcc.target/arm/armv8-sync-op-release.c
index 0d3be7b..502a266 100644
--- a/gcc/testsuite/gcc.target/arm/armv8-sync-op-release.c
+++ b/gcc/testsuite/gcc.target/arm/armv8-sync-op-release.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { do-require-effective-target arm_arch_v8a_ok } */
+/* { dg-require-effective-target arm_arch_v8a_ok } */
 /* { dg-options "-O2" } */
 /* { dg-add-options arm_arch_v8a } */
 


Commit: MSP430: Fix zero-extending a 16-bit value to a 20-bit value, in memory

2015-07-01 Thread Nick Clifton
Hi Guys,

  I am applying the patch below to fix a problem with the MSP430's
  zero_extendhipsi2 pattern.  When the destination is memory, four bytes
  must be written, even though only a 20-bit value is being stored, as
  otherwise the top nibble will be lost.

Cheers
  Nick

gcc/ChangeLog
2015-07-01  Nick Clifton  

* config/msp430/msp430.md (zero_extendhipsi2): Use MOVX.A to store
a 16-bit value into a 20-bit memory slot.

Index: config/msp430/msp430.md
===
--- config/msp430/msp430.md (revision 225239)
+++ config/msp430/msp430.md (working copy)
@@ -572,7 +572,9 @@
   [(set (match_operand:PSI 0 "msp_nonimmediate_operand" "=r,m")
(zero_extend:PSI (match_operand:HI 1 "msp_nonimmediate_operand" 
"rm,r")))]
   ""
-  "MOVX\t%1, %0"
+  "@
+  MOVX\t%1, %0
+  MOVX.A\t%1, %0"
 )
 
 (define_insn "truncpsihi2"


[PATCH, PR66432] Handle PARM_DECL in remap_gimple_op_r

2015-07-01 Thread Tom de Vries

Hi,

I.

When running test libgomp.c/appendix-a/a.29.1.c with '--target_board 
unix/-O2/-g', we run into this failure:

...
FAIL: libgomp.c/appendix-a/a.29.1.c (test for excess errors)
Excess errors:
src/libgomp/testsuite/libgomp.c/appendix-a/a.29.1.c:6:1: error: type 
mismatch between an SSA_NAME and its symbol

...

Without -g, the testcase passes.


II.

The scenario for the failure is as follows:

At fnsplit, we split off f.part.0 from f, which at source level looks 
like this:

...
void
f (int n, int B[n][n], int C[])
{
  int D[2][2] = { 1, 2, 3, 4 };
  int E[n][n];
  assert (n >= 2);
  E[1][1] = 4;
#pragma omp parallel firstprivate(B, C, D, E)
  {
assert (sizeof (B) == sizeof (int (*)[n]));
assert (sizeof (C) == sizeof (int *));
assert (sizeof (D) == 4 * sizeof (int));
assert (sizeof (E) == n * n * sizeof (int));
/* Private B and C have values of original B and C. */
assert (&B[1][1] == &A[1][1]);
assert (&C[3] == &A[1][1]);
assert (D[1][1] == 4);
assert (E[1][1] == 4);
  }
}
...

The split introduces a debug_insn and ssa-name that references param B in f:
...
  # DEBUG D#4ptD.0 => B_3(D)
..

And a debug_insn that references param B in f.part.0:
...
  # DEBUG D#7ptD.0 s=> BD.1846
...

At this point, the type of the ssa name and the param are the same.

Then at inline, we decide to inline f.part.0 back into function f.

For inlining, we rewrite the body of inlined function f.part.0. While 
rewriting the debug insn mentioned above, we hit this code for param B:

...
  if (TREE_CODE (*tp) != OMP_CLAUSE)
TREE_TYPE (*tp) = remap_type (TREE_TYPE (*tp), id);
...
And since it's a variable-sized type, the type of param is changed.

Now the type of the ssa name and the param are no longer the same, and a 
bit later we hit the ICE.



III.

Attached patch fixes the ICE by handling PARM_DECL in remap_gimple_op_r.
[ I'm not confident though this is the right fix ]

Bootstrapped and reg-tested on x86_64.

OK for trunk, or to be fixed otherwise?

Thanks,
- Tom
Handle PARM_DECL in remap_gimple_op_r

2015-06-30  Tom de Vries  

	PR middle-end/66432
	* tree-inline.c (remap_gimple_op_r): Handle PARM_DECL in
	remap_gimple_op_r.

	* testsuite/libgomp.c/appendix-a/a.29.1-g.c: New test.
---
 gcc/tree-inline.c | 10 ++--
 libgomp/testsuite/libgomp.c/appendix-a/a.29.1-g.c | 31 +++
 2 files changed, 39 insertions(+), 2 deletions(-)
 create mode 100644 libgomp/testsuite/libgomp.c/appendix-a/a.29.1-g.c

diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 6f138ed..422fd33 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -919,10 +919,16 @@ remap_gimple_op_r (tree *tp, int *walk_subtrees, void *data)
 	   || decl_function_context (*tp) == id->src_fn))
 /* These may need to be remapped for EH handling.  */
 *tp = remap_decl (*tp, id);
-  else if (TREE_CODE (*tp) == FIELD_DECL)
+  else if (TREE_CODE (*tp) == FIELD_DECL
+	  || TREE_CODE (*tp) == PARM_DECL)
 {
   /* If the enclosing record type is variably_modified_type_p, the field
-	 has already been remapped.  Otherwise, it need not be.  */
+	has already been remapped.  Otherwise, it need not be.
+	Likewise, if the PARM_DECL is a param of the inlined function, it will
+	already have been remapped.  Otherwise, it might be a param of the
+	inlining function.  This can happen if a code block in a function is
+	first split off by fnsplit, and then inlined back into the same
+	function.  In that case, we don't remap.  */
   tree *n = id->decl_map->get (*tp);
   if (n)
 	*tp = *n;
diff --git a/libgomp/testsuite/libgomp.c/appendix-a/a.29.1-g.c b/libgomp/testsuite/libgomp.c/appendix-a/a.29.1-g.c
new file mode 100644
index 000..140f89f
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/appendix-a/a.29.1-g.c
@@ -0,0 +1,31 @@
+/* { dg-do run } */
+/* { dg-additional-options "-g" } */
+
+#include 
+int A[2][2] = { 1, 2, 3, 4 };
+void
+f (int n, int B[n][n], int C[])
+{
+  int D[2][2] = { 1, 2, 3, 4 };
+  int E[n][n];
+  assert (n >= 2);
+  E[1][1] = 4;
+#pragma omp parallel firstprivate(B, C, D, E)
+  {
+assert (sizeof (B) == sizeof (int (*)[n])); /* { dg-warning "on array function parameter" } */
+assert (sizeof (C) == sizeof (int *)); /* { dg-warning "on array function parameter" } */
+assert (sizeof (D) == 4 * sizeof (int));
+assert (sizeof (E) == n * n * sizeof (int));
+/* Private B and C have values of original B and C.  */
+assert (&B[1][1] == &A[1][1]);
+assert (&C[3] == &A[1][1]);
+assert (D[1][1] == 4);
+assert (E[1][1] == 4);
+  }
+}
+int
+main ()
+{
+  f (2, A, A[0]);
+  return 0;
+}
-- 
1.9.1



Re: [PATCH, libstdc++]: Avoid "libsupc++/guard.cc:118:18: warning: variable ‘__p’ set but not used" warning

2015-07-01 Thread Jonathan Wakely

On 01/07/15 12:22 +0200, Uros Bizjak wrote:

Hello!

2015-07-01  Uros Bizjak  

   * libsupc++/guard.cc (__test_and_acquire): Use __p after __atomic_load
   to avoid unused variable warning.
   (__set_and_release): Use __p after __atomic_store to avoid unused
   variable warning.

Bootstrapped and regression tested on x86_64-linux-gnu.

OK for mainline?


Yes, OK, although I was wondering if this should really be fixed in
the front end, the warning is spurious, isn't it? __p is not unused,
because the load is done through it.


Index: libsupc++/guard.cc
===
--- libsupc++/guard.cc  (revision 225221)
+++ libsupc++/guard.cc  (working copy)
@@ -117,6 +117,7 @@ __test_and_acquire (__cxxabiv1::__guard *g)
  unsigned char __c;
  unsigned char *__p = reinterpret_cast(g);
  __atomic_load (__p, &__c,  __ATOMIC_ACQUIRE);
+  (void) __p;
  return _GLIBCXX_GUARD_TEST(&__c);
}
#  define _GLIBCXX_GUARD_TEST_AND_ACQUIRE(G) __test_and_acquire (G)
@@ -132,6 +133,7 @@ __set_and_release (__cxxabiv1::__guard *g)
  unsigned char *__p = reinterpret_cast(g);
  unsigned char val = 1;
  __atomic_store (__p, &val, __ATOMIC_RELEASE);
+  (void) __p;
}
#  define _GLIBCXX_GUARD_SET_AND_RELEASE(G) __set_and_release (G)
# endif




Re: [PATCH, PR66432] Handle PARM_DECL in remap_gimple_op_r

2015-07-01 Thread Richard Biener
On Wed, Jul 1, 2015 at 1:43 PM, Tom de Vries  wrote:
> Hi,
>
> I.
>
> When running test libgomp.c/appendix-a/a.29.1.c with '--target_board
> unix/-O2/-g', we run into this failure:
> ...
> FAIL: libgomp.c/appendix-a/a.29.1.c (test for excess errors)
> Excess errors:
> src/libgomp/testsuite/libgomp.c/appendix-a/a.29.1.c:6:1: error: type
> mismatch between an SSA_NAME and its symbol
> ...
>
> Without -g, the testcase passes.
>
>
> II.
>
> The scenario for the failure is as follows:
>
> At fnsplit, we split off f.part.0 from f, which at source level looks like
> this:
> ...
> void
> f (int n, int B[n][n], int C[])
> {
>   int D[2][2] = { 1, 2, 3, 4 };
>   int E[n][n];
>   assert (n >= 2);
>   E[1][1] = 4;
> #pragma omp parallel firstprivate(B, C, D, E)
>   {
> assert (sizeof (B) == sizeof (int (*)[n]));
> assert (sizeof (C) == sizeof (int *));
> assert (sizeof (D) == 4 * sizeof (int));
> assert (sizeof (E) == n * n * sizeof (int));
> /* Private B and C have values of original B and C. */
> assert (&B[1][1] == &A[1][1]);
> assert (&C[3] == &A[1][1]);
> assert (D[1][1] == 4);
> assert (E[1][1] == 4);
>   }
> }
> ...
>
> The split introduces a debug_insn and ssa-name that references param B in f:
> ...
>   # DEBUG D#4ptD.0 => B_3(D)
> ..
>
> And a debug_insn that references param B in f.part.0:
> ...
>   # DEBUG D#7ptD.0 s=> BD.1846
> ...
>
> At this point, the type of the ssa name and the param are the same.

With the same PARM_DECL?  I think that's the bug.

> Then at inline, we decide to inline f.part.0 back into function f.
>
> For inlining, we rewrite the body of inlined function f.part.0. While
> rewriting the debug insn mentioned above, we hit this code for param B:
> ...
>   if (TREE_CODE (*tp) != OMP_CLAUSE)
> TREE_TYPE (*tp) = remap_type (TREE_TYPE (*tp), id);
> ...
> And since it's a variable-sized type, the type of param is changed.

The param of the inlined body but that should be unrelated to that refered to by

  # DEBUG D#4ptD.0 => B_3(D)

in f.

> Now the type of the ssa name and the param are no longer the same, and a bit
> later we hit the ICE.
>
>
> III.
>
> Attached patch fixes the ICE by handling PARM_DECL in remap_gimple_op_r.
> [ I'm not confident though this is the right fix ]
>
> Bootstrapped and reg-tested on x86_64.
>
> OK for trunk, or to be fixed otherwise?
>
> Thanks,
> - Tom


Re: [ARM] Fix typos in ARMv8 __sync builtins tests.

2015-07-01 Thread Ramana Radhakrishnan
On Wed, Jul 1, 2015 at 12:32 PM, Matthew Wahab
 wrote:
> Hello,
>
> Tests I recently added for the code generated by the ARM backend for the
> __sync
> builtins had
>
> - 'do-require-effective-target', instead of the directive
>   'dg-require-effective-target' and
> - 'stlex' instead of 'strex' in the expected output for
> armv8-sync-op-acquire.c
>
> This meant the tests ran on targets that did not support them and reported a
> failure for correct code. This patch fixes both mistakes.
>
> Tested arm-none-linux-gnueabihf with check-gcc.
>
> Ok for trunk?
> Matthew

OK  - I must be going blind.

Ramana
>
> gcc/testsuite
> 2015-07-01  Matthew Wahab  
>
> * gcc.target/arm/armv8-sync-comp-swap.c: Replace
> 'do-require-effective-target' with 'dg-require-effective-target'.
> * gcc.target/arm/armv8-sync-op-full.c: Likewise.
> * gcc.target/arm/armv8-sync-op-release.c: Likewise.
> * gcc.target/arm/armv8-sync-op-acquire.c: Likewise.  Also, replace
> 'stlex' with 'strex' as the expected output.


[PATCH] X86: Optimize access to globals in PIE with copy reloc

2015-07-01 Thread H.J. Lu
Normally, with PIE, GCC accesses globals that are extern to the module
using GOT.  This is two instructions, one to get the address of the global
from GOT and the other to get the value.  Examples:

---
extern int a_glob;
int
main ()
{
  return a_glob;
}
---

With PIE, the generated code accesses global via GOT using two memory
loads:

movqa_glob@GOTPCREL(%rip), %rax
movl(%rax), %eax

for 64-bit or

movla_glob@GOT(%ecx), %eax
movl(%eax), %eax

for 32-bit.

Some experiments on google and SPEC CPU benchmarks show that the extra
instruction affects performance by 1% to 5%.

Solution - Copy Relocations:

When the linker supports copy relocations, GCC can always assume that
the global will be defined in the executable.  For globals that are
truly extern (come from shared objects), the linker will create copy
relocations and have them defined in the executable.  Result is that
no global access needs to go through GOT and hence improves performance.
We can generate

movla_glob(%rip), %eax

for 64-bit and

movla_glob@GOTOFF(%eax), %eax

for 32-bit.  This optimization only applies to undefined non-weak
non-TLS global data.  Undefined weak global or TLS data access still
must go through GOT.

This patch reverts legitimate_pic_address_disp_p change made in revision
218397, which only applies to x86-64.  Instead, this patch updates
targetm.binds_local_p to indicate if undefined non-weak non-TLS global
data is defined locally in PIE.  It also introduces a new target hook,
binds_tls_local_p to distinguish TLS variable from non-TLS variable.  By
default, binds_tls_local_p is the same as binds_local_p which assumes
TLS variable.

This patch checks if 32-bit and 64-bit linkers support PIE with copy
reloc at configure time.  64-bit linker is enabled in binutils 2.25
and 32-bit linker is enabled in binutils 2.26.  This optimization
is enabled only if the linker support is available.

Since copy relocation in PIE is incompatible with DSO created by
-Wl,-Bsymbolic, this patch also adds a new option, -fsymbolic, which
controls how references to global symbols are bound.  The -fsymbolic
option binds references to global symbols to the local definitions
and external references globally.  It avoids copy relocations in PIE
and optimizes global symbol references in shared library created
by -Wl,-Bsymbolic.

gcc/

PR target/65846
PR target/65886
* configure.ac (HAVE_LD_PIE_COPYRELOC): Renamed to ...
(HAVE_LD_X86_64_PIE_COPYRELOC): This.
(HAVE_LD_386_PIE_COPYRELOC): New.   Defined to 1 if Linux/ia32
linker supports PIE with copy reloc.
* output.h (default_binds_tls_local_p): New.
(default_binds_local_p_3): Add 2 bool arguments.
* target.def (binds_tls_local_p): New target hook.
* varasm.c (decl_default_tls_model): Replace targetm.binds_local_p
with targetm.binds_tls_local_p.
(default_binds_local_p_3): Add a bool argument to indicate TLS
variable and a bool argument to indicate if an undefined non-TLS
non-weak data is local.  Double check TLS variable.  If an
undefined non-TLS non-weak data is local, treat it as defined
locally.
(default_binds_local_p): Pass true and false to
default_binds_local_p_3.
(default_binds_local_p_2): Likewise.
(default_binds_local_p_1): Likewise.
(default_binds_tls_local_p): New.
* config.in: Regenerated.
* configure: Likewise.
* doc/tm.texi: Likewise.
* config/i386/i386.c (legitimate_pic_address_disp_p): Don't
check HAVE_LD_PIE_COPYRELOC here.
(ix86_binds_local): New.
(ix86_binds_tls_local_p): Likewise.
(ix86_binds_local_p): Use it.
(TARGET_BINDS_TLS_LOCAL_P): New.
* doc/tm.texi.in (TARGET_BINDS_TLS_LOCAL_P): New hook.

gcc/testsuite/

PR target/65846
PR target/65886
* gcc.target/i386/pie-copyrelocs-1.c: Updated for ia32.
* gcc.target/i386/pie-copyrelocs-2.c: Likewise.
* gcc.target/i386/pie-copyrelocs-3.c: Likewise.
* gcc.target/i386/pie-copyrelocs-4.c: Likewise.
* gcc.target/i386/pr32219-9.c: Likewise.
* gcc.target/i386/pr32219-10.c: New file.
* gcc.target/i386/pr65886-1.c: Likewise.
* gcc.target/i386/pr65886-2.c: Likewise.
* gcc.target/i386/pr65886-3.c: Likewise.
* gcc.target/i386/pr65886-4.c: Likewise.
* gcc.target/i386/pr65886-4.c: Likewise.
* gcc.target/i386/pr65886-5.c: Likewise.

* lib/target-supports.exp (check_effective_target_pie_copyreloc):
Check HAVE_LD_X86_64_PIE_COPYRELOC and HAVE_LD_386_PIE_COPYRELOC
instead of HAVE_LD_X86_64_PIE_COPYRELOC.
---
 gcc/common.opt   |  4 ++
 gcc/config.in| 18 ---
 gcc/config/i386/i386.c   | 44 ++-
 gcc/configur

[v3 patch] Implement N4502 Standard Library Support for the C++ Detection Idiom

2015-07-01 Thread Jonathan Wakely

This adds the "detection idiom" API from N4502

http://open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4502.pdf

I've added the low-level parts to , with public aliases
in , so that I can use them elsewhere in the
library.

Tested powerpc64le-linux, committed to trunk.
commit 280016fc93e2c62e1c07f2588002d422ba5ac7b1
Author: Jonathan Wakely 
Date:   Tue Jun 30 23:19:50 2015 +0100

Implement N4502, the C++ Detection Idiom.

	* doc/xml/manual/status_cxx2017.xml: Update status table.
	* include/experimental/type_traits (void_t, is_detected,
	is_detected_v, detected_t, detected_or, detected_or_t,
	is_detected_exact, is_detected_exact_v, is_detected_convertible,
	is_detected_convertible_v): Define.
	* include/std/type_traits (__detector, __detected_or, __detected_or_t,
	__detected_or_t_): Define.
	* testsuite/experimental/type_traits/detection.cc: New.

diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2017.xml b/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
index d110572..07e2dbe 100644
--- a/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
+++ b/libstdc++-v3/doc/xml/manual/status_cxx2017.xml
@@ -328,14 +328,13 @@ not in any particular release.
 
 
 
-  
   
 	http://www.w3.org/1999/xlink"; xlink:href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4502.pdf";>
 	  N4502
 	
   
Support for the C++ Detection Idiom, V2 
-  N
+  Y
   Library Fundamentals 2 TS
 
 
diff --git a/libstdc++-v3/include/experimental/type_traits b/libstdc++-v3/include/experimental/type_traits
index db78eec..b0ed3b0 100644
--- a/libstdc++-v3/include/experimental/type_traits
+++ b/libstdc++-v3/include/experimental/type_traits
@@ -220,6 +220,59 @@ template 
   // raw_invocation_type_t (still unimplemented)
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace fundamentals_v1
+
+inline namespace fundamentals_v2
+{
+_GLIBCXX_BEGIN_NAMESPACE_VERSION
+
+#define __cpp_lib_experimental_detect 201505
+
+// [meta.detect]
+
+template using void_t = void;
+
+struct nonesuch
+{
+  nonesuch() = delete;
+  ~nonesuch() = delete;
+  nonesuch(nonesuch const&) = delete;
+  void operator=(nonesuch const&) = delete;
+};
+
+template class _Op, typename... _Args>
+  using is_detected
+= typename std::__detector::value_t;
+
+template class _Op, typename... _Args>
+  constexpr bool is_detected_v = is_detected<_Op, _Args...>::value;
+
+template class _Op, typename... _Args>
+  using detected_t
+= typename std::__detector::type;
+
+template class _Op, typename... _Args>
+  using detected_or = std::__detected_or<_Default, _Op, _Args...>;
+
+template class _Op, typename... _Args>
+  using detected_or_t = typename detected_or<_Default, _Op, _Args...>::type;
+
+template class _Op, typename... _Args>
+  using is_detected_exact = is_same>;
+
+template class _Op, typename... _Args>
+  constexpr bool is_detected_exact_v
+= is_detected_exact::value;
+
+template class _Op, typename... _Args>
+  using is_detected_convertible
+= is_convertible, _To>;
+
+template class _Op, typename... _Args>
+  constexpr bool is_detected_convertible_v
+= is_detected_convertible<_To, _Op, _Args...>::value;
+
+_GLIBCXX_END_NAMESPACE_VERSION
+} // namespace fundamentals_v2
 } // namespace experimental
 } // namespace std
 
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index e09c856..55ca916 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -2417,6 +2417,41 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template using void_t = void;
 #endif
 
+  /// Implementation of the detection idiom (negative case).
+  template class _Op, typename... _Args>
+struct __detector
+{
+  using value_t = false_type;
+  using type = _Default;
+};
+
+  /// Implementation of the detection idiom (positive case).
+  template class _Op,
+	typename... _Args>
+struct __detector<_Default, __void_t<_Op<_Args...>>, _Op, _Args...>
+{
+  using value_t = true_type;
+  using type = _Op<_Args...>;
+};
+
+  // Detect whether _Op<_Args...> is a valid type, use _Default if not.
+  template class _Op,
+	   typename... _Args>
+using __detected_or = __detector<_Default, void, _Op, _Args...>;
+
+  // _Op<_Args...> if that is a valid type, otherwise _Default.
+  template class _Op,
+	   typename... _Args>
+using __detected_or_t
+  = typename __detected_or<_Default, _Op, _Args...>::type;
+
+  // _Op<_Args...> if that is a valid type, otherwise _Default<_Args...>.
+  template class _Default,
+	   template class _Op, typename... _Args>
+using __detected_or_t_ =
+  __detected_or_t<_Default<_Args...>, _Op, _Args...>;
+
   /// @} group metaprogramming
 
   /**
diff --git a/libstdc++-v3/testsuite/experimental/type_traits/detection.cc b/libstdc++-v3/testsuite/experimental/type_traits/detection.cc
new file mode 100644
index 000..45d0692
--- /dev/null
+++ b/libstdc++-v3/testsuite/experimental/type_tra

[PATCH, lto-plugin]: Avoid "warning: implicit declaration of function ‘asprintf’ when building lto-plugin.o"

2015-07-01 Thread Uros Bizjak
Hello!

We have to enable OS extensions (GNU_SOURCE) to use asprintf.

2015-07-01  Uros Bizjak  

* configure.ac: Add AC_USE_SYSTEM_EXTENSIONS.
* configure: Regenerate.
* config.h.in: Ditto.

Bootstrapped on x86_64-linux-gnu.

OK for mainline?

Uros.

Index: configure.ac
===
--- configure.ac(revision 225240)
+++ configure.ac(working copy)
@@ -9,6 +9,7 @@
[specify the directory where to find libiberty [../libiberty]])],
  [], with_libiberty=../libiberty)
AC_SUBST(with_libiberty)
+AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
AC_SYS_LARGEFILE
ACX_PROG_CC_WARNING_OPTS([-Wall], [ac_lto_plugin_warn_cflags])


Re: [v3 patch] Implement N4502 Standard Library Support for the C++ Detection Idiom

2015-07-01 Thread Jonathan Wakely

On 01/07/15 13:23 +0100, Jonathan Wakely wrote:

This adds the "detection idiom" API from N4502

http://open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4502.pdf

I've added the low-level parts to , with public aliases
in , so that I can use them elsewhere in the
library.


For example this uses the new features to simplify pointer_traits.

These changes caused some new FAILs due to invalid uses of
pointer_traits that the standard says should be ill-formed but didn't
fail before. The patch fixes those tests.

Tested powerpc64le-linux, committed to trunk.


commit 9014ff9e72ef2d0048e1985d282341a3c37162ef
Author: Jonathan Wakely 
Date:   Wed Jul 1 12:27:46 2015 +0100

	* include/bits/ptr_traits.h (__ptrtr_elt_type, __ptrtr_diff_type,
	__ptrtr_rebind, __ptrtr_not_void): Remove
	(__get_first_arg, __replace_first_arg, __make_not_void): Define new
	transformations.
	(__detected_or_): New detection trait.
	(pointer_traits): Use new traits.
	* testsuite/20_util/pointer_traits/pointer_to.cc: Add rebind member.
	* testsuite/20_util/pointer_traits/requirements/
	explicit_instantiation.cc: Use valid arguments to pointer_traits.

diff --git a/libstdc++-v3/include/bits/ptr_traits.h b/libstdc++-v3/include/bits/ptr_traits.h
index 9fd6bf8..84cc4da 100644
--- a/libstdc++-v3/include/bits/ptr_traits.h
+++ b/libstdc++-v3/include/bits/ptr_traits.h
@@ -32,114 +32,86 @@
 
 #if __cplusplus >= 201103L
 
-#include  // For _GLIBCXX_HAS_NESTED_TYPE
+#include 
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
-_GLIBCXX_HAS_NESTED_TYPE(element_type)
-_GLIBCXX_HAS_NESTED_TYPE(difference_type)
-
-  template::value>
-struct __ptrtr_elt_type;
+  class __undefined;
 
+  // Given Template return T, otherwise invalid.
   template
-struct __ptrtr_elt_type<_Tp, true>
-{
-  typedef typename _Tp::element_type __type;
-};
-
-  template class _SomePtr, typename _Tp,
-typename... _Args>
-struct __ptrtr_elt_type<_SomePtr<_Tp, _Args...>, false>
-{
-  typedef _Tp __type;
-};
+struct __get_first_arg
+{ using type = __undefined; };
 
-  template::value>
-struct __ptrtr_diff_type
-{
-  typedef typename _Tp::difference_type __type;
-};
+  template class _Template, typename _Tp,
+   typename... _Types>
+struct __get_first_arg<_Template<_Tp, _Types...>>
+{ using type = _Tp; };
 
   template
-struct __ptrtr_diff_type<_Tp, false>
-{
-  typedef ptrdiff_t __type;
-};
-
-  template
-class __ptrtr_rebind_helper
-{
-  template
-	static constexpr true_type
-	_S_chk(typename _Ptr2::template rebind<_Up2>*);
-
-  template
-	static constexpr false_type
-	_S_chk(...);
-
-public:
-  using __type = decltype(_S_chk<_Ptr, _Up>(nullptr));
-};
-
-  template::__type::value>
-struct __ptrtr_rebind;
+using __get_first_arg_t = typename __get_first_arg<_Tp>::type;
 
+  // Given Template and U return Template, otherwise invalid.
   template
-struct __ptrtr_rebind<_Tp, _Up, true>
-{
-  typedef typename _Tp::template rebind<_Up> __type;
-};
+struct __replace_first_arg
+{ using type = __undefined; };
 
-  template class _SomePtr, typename _Up,
-typename _Tp, typename... _Args>
-struct __ptrtr_rebind<_SomePtr<_Tp, _Args...>, _Up, false>
-{
-  typedef _SomePtr<_Up, _Args...> __type;
-};
+  template class _Template, typename _Up,
+   typename _Tp, typename... _Types>
+struct __replace_first_arg<_Template<_Tp, _Types...>, _Up>
+{ using type = _Template<_Up, _Types...>; };
 
-  template::type>
-struct __ptrtr_not_void
-{
-  typedef _Tp __type;
-};
+  template
+using __replace_first_arg_t = typename __replace_first_arg<_Tp, _Up>::type;
 
   template
-struct __ptrtr_not_void<_Tp, void>
-{
-  struct __type { };
-};
-
-  template
-class __ptrtr_pointer_to
-{
-  typedef typename __ptrtr_elt_type<_Ptr>::__type   __orig_type;
-  typedef typename __ptrtr_not_void<__orig_type>::__type __element_type;
-
-public:
-  static _Ptr pointer_to(__element_type& __e)
-  { return _Ptr::pointer_to(__e); }
-};
+using __make_not_void
+  = typename conditional::value, __undefined, _Tp>::type;
 
   /**
* @brief  Uniform interface to all pointer-like types
* @ingroup pointer_abstractions
   */
   template
-struct pointer_traits : __ptrtr_pointer_to<_Ptr>
+struct pointer_traits
 {
-  /// The pointer type
-  typedef _Ptr  pointer;
-  /// The type pointed to
-  typedef typename __ptrtr_elt_type<_Ptr>::__type   element_type;
-  /// Type used to represent the difference between two pointers
-  typedef typename __ptrtr_diff_type<_Ptr>::__type  difference_type;
+private:
+  template
+	using __element_type = typename _Tp::element_type;
+
+  template
+	using __difference_type = typename _T

Re: [v3 patch] Implement N4502 Standard Library Support for the C++ Detection Idiom

2015-07-01 Thread Jonathan Wakely

On 01/07/15 13:25 +0100, Jonathan Wakely wrote:

On 01/07/15 13:23 +0100, Jonathan Wakely wrote:

This adds the "detection idiom" API from N4502

http://open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4502.pdf

I've added the low-level parts to , with public aliases
in , so that I can use them elsewhere in the
library.


For example this uses the new features to simplify pointer_traits.


And this does the same for allocator_traits.

Tested powerpc64le-linux, committed to trunk.
commit bdccabb2604c4a2f714cea5846ad8526cd2eb496
Author: redi 
Date:   Wed Jul 1 12:24:09 2015 +

	* include/bits/alloc_traits.h (__alloctr_rebind): Remove.
	(__allocator_traits_base): New base class.
	(__alloc_rebind): Reimplement in terms of detection idiom.
	(allocator_traits): Derive from __allocator_traits_base. Reimplement
	nested types in terms of detection idiom. Simplify SFINAE constraints
	on overloaded static member functions.
	* include/bits/hashtable.h (_Hashtable): Use __alloc_rebind instead
	of __alloctr_rebind.
	* testsuite/20_util/scoped_allocator/propagation.cc: Define rebind.
	* testsuite/23_containers/unordered_set/instantiation_neg.cc: Adjust
	dg-error line number.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@225244 138bc75d-0d04-0410-961f-82ee72b054a4

diff --git a/libstdc++-v3/include/bits/alloc_traits.h b/libstdc++-v3/include/bits/alloc_traits.h
index bb98c1d..e5ed92b 100644
--- a/libstdc++-v3/include/bits/alloc_traits.h
+++ b/libstdc++-v3/include/bits/alloc_traits.h
@@ -40,72 +40,57 @@ namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
-  template
-class __alloctr_rebind_helper
-{
-  template
-	static constexpr true_type
-	_S_chk(typename _Alloc2::template rebind<_Tp2>::other*);
-
-  template
-	static constexpr false_type
-	_S_chk(...);
-
-public:
-  using __type = decltype(_S_chk<_Alloc, _Tp>(nullptr));
-};
-
-  template::__type::value>
-struct __alloctr_rebind;
-
-  template
-struct __alloctr_rebind<_Alloc, _Tp, true>
-{
-  typedef typename _Alloc::template rebind<_Tp>::other __type;
-};
-
-  template class _Alloc, typename _Tp,
-	   typename _Up, typename... _Args>
-struct __alloctr_rebind<_Alloc<_Up, _Args...>, _Tp, false>
-{
-  typedef _Alloc<_Tp, _Args...> __type;
-};
-
-  template
-using __alloc_rebind = typename __alloctr_rebind<_Alloc, _Tp>::__type;
+  struct __allocator_traits_base
+  {
+template
+  using __rebind = typename _Alloc::template rebind<_Up>::other;
+
+  protected:
+template
+  using __pointer = typename _Tp::pointer;
+template
+  using __c_pointer = typename _Tp::const_pointer;
+template
+  using __v_pointer = typename _Tp::void_pointer;
+template
+  using __cv_pointer = typename _Tp::const_void_pointer;
+template
+  using __diff_type = typename _Tp::difference_type;
+template
+  using __size_type = typename _Tp::size_type;
+template
+  using __pocca = typename _Tp::propagate_on_container_copy_assignment;
+template
+  using __pocma = typename _Tp::propagate_on_container_move_assignment;
+template
+  using __pocs = typename _Tp::propagate_on_container_swap;
+template
+  using __equal = typename _Tp::is_always_equal;
+  };
+
+  template
+using __alloc_rebind = __detected_or_t_<__replace_first_arg_t,
+	__allocator_traits_base::__rebind,
+	_Alloc, _Up>;
 
   /**
* @brief  Uniform interface to all allocator types.
* @ingroup allocators
   */
   template
-struct allocator_traits
+struct allocator_traits : __allocator_traits_base
 {
   /// The allocator type
   typedef _Alloc allocator_type;
   /// The allocated type
   typedef typename _Alloc::value_type value_type;
 
-#define _GLIBCXX_ALLOC_TR_NESTED_TYPE(_NTYPE, _ALT) \
-  private: \
-template \
-  static typename _Tp::_NTYPE _S_##_NTYPE##_helper(_Tp*); \
-static _ALT _S_##_NTYPE##_helper(...); \
-typedef decltype(_S_##_NTYPE##_helper((_Alloc*)0)) __##_NTYPE; \
-  public:
-
-_GLIBCXX_ALLOC_TR_NESTED_TYPE(pointer, value_type*)
-
   /**
* @brief   The allocator's pointer type.
*
* @c Alloc::pointer if that type exists, otherwise @c value_type*
   */
-  typedef __pointer pointer;
-
-_GLIBCXX_ALLOC_TR_NESTED_TYPE(const_pointer,
-  typename pointer_traits::template rebind)
+  using pointer = __detected_or_t;
 
   /**
* @brief   The allocator's const pointer type.
@@ -113,10 +98,9 @@ _GLIBCXX_ALLOC_TR_NESTED_TYPE(const_pointer,
* @c Alloc::const_pointer if that type exists, otherwise
*  pointer_traits::rebind 
   */
-  typedef __const_pointer const_pointer;
-
-_GLIBCXX_ALLOC_TR_NESTED_TYPE(void_pointer,
-  typename pointer_traits::template rebind)
+  using const_pointer
+	= __detected_or_t<__ptr_rebind,
+			  __c_pointer, _Alloc>;
 
   /**
* @

RE: [PING] [RFC] Sanitize rtx_addr_can_trap_p_1

2015-07-01 Thread Bernd Edlinger
Hi,


the bogus offsets-issue is now entered in bugzilla, see PR66614.

It is however only a very minor issue, and does probably have
no impact on the generated code at all.


How should I continue with the rtx_addr_can_trap-patch?
Is it OK to commit?


Thanks
Bernd.



> From: bernd.edlin...@hotmail.de
> To: gcc-patches@gcc.gnu.org
> CC: richard.guent...@gmail.com; ja...@redhat.com; l...@redhat.com; 
> ebotca...@adacore.com
> Subject: RE: [RFC] Sanitize rtx_addr_can_trap_p_1
> Date: Mon, 15 Jun 2015 05:50:46 +0200
>
> Hi,
>
> I have here an updated patch, which improves two things:
>
> First it moves debug code out to an extra patch, as suggested by Jakub.
>
> Secondly, it fixes the checks on STACK_GROWS_DOWNWARD and
> ARGS_GROW_DOWNWARD.  Previously these used to be conditionally defined
> symbols, but recently they were changed to be always defined, but with 0 or 1.
>
> That made all #ifndef checks on those two flags work the wrong way, and it 
> caused
> most of the false positives in the previous version.
>
> Now the number of false positives in the stage2 drops significantly to only 4 
> new ones:
>
> *** argp can trap: function=uw_init_context_1, pass=reload, offset=236, 
> size=4, low_bound=-16, high_bound=16
> *** argp can trap: function=uw_init_context_1, pass=reload, offset=236, 
> size=4, low_bound=-16, high_bound=16
> *** argp can trap: function=uw_init_context_1, pass=reload, offset=440, 
> size=8, low_bound=-16, high_bound=16
> *** argp can trap: function=uw_init_context_1, pass=reload, offset=440, 
> size=8, low_bound=-16, high_bound=16
>
> These came from libgcc/unwind-dw2.c
>
> They seem to have the same reason as the 2930 "frame can trap" warnings that 
> were already
> there before the patch.
>
>
> All these seem to happen due to some hidden bug.  In the debugger the call 
> stack looks always like this:
>
> #0  rtx_addr_can_trap_p_1 (x=0x76ecb378, offset=440, size=8, mode=DImode, 
> unaligned_mems=false) at ../../gcc-trunk/gcc/rtlanal.c:671
> #1  0x00d90f4a in rtx_addr_can_trap_p_1 (x=0x767ac7f8, offset=0, 
> size=8, mode=DImode, unaligned_mems=false) at 
> ../../gcc-trunk/gcc/rtlanal.c:699
> #2  0x00d953c4 in may_trap_p_1 (x=0x767ac810, flags=0) at 
> ../../gcc-trunk/gcc/rtlanal.c:2760
> #3  0x00d95619 in may_trap_p_1 (x=0x7671ac90, flags=0) at 
> ../../gcc-trunk/gcc/rtlanal.c:2838
> #4  0x00d956cc in may_trap_p (x=0x7671ac90) at 
> ../../gcc-trunk/gcc/rtlanal.c:2857
> #5  0x00c6b2ab in process_bb_lives (bb=0x76c3a958, 
> curr_point=@0x7fffd8e4: 23, dead_insn_p=true) at 
> ../../gcc-trunk/gcc/lra-lives.c:698
> #6  0x00c6d19a in lra_create_live_ranges_1 (all_p=true, 
> dead_insn_p=true) at ../../gcc-trunk/gcc/lra-lives.c:1262
> #7  0x00c6d47c in lra_create_live_ranges (all_p=true, 
> dead_insn_p=true) at ../../gcc-trunk/gcc/lra-lives.c:1327
> #8  0x00c4a253 in lra (f=0x24f7940) at ../../gcc-trunk/gcc/lra.c:2309
> #9  0x00bf3d25 in do_reload () at ../../gcc-trunk/gcc/ira.c:5401
> #10 0x00bf40d3 in (anonymous namespace)::pass_reload::execute 
> (this=0x23fce20) at ../../gcc-trunk/gcc/ira.c:5572
> #11 0x00d08e37 in execute_one_pass (pass=0x23fce20) at 
> ../../gcc-trunk/gcc/passes.c:2359
> #12 0x00d09081 in execute_pass_list_1 (pass=0x23fce20) at 
> ../../gcc-trunk/gcc/passes.c:2412
> #13 0x00d090b2 in execute_pass_list_1 (pass=0x23fbda0) at 
> ../../gcc-trunk/gcc/passes.c:2413
> #14 0x00d090ef in execute_pass_list (fn=0x77044c78, 
> pass=0x23f8bc0) at ../../gcc-trunk/gcc/passes.c:2423
> #15 0x008de80c in cgraph_node::expand (this=0x76c09498) at 
> ../../gcc-trunk/gcc/cgraphunit.c:1937
> #16 0x008dee3d in expand_all_functions () at 
> ../../gcc-trunk/gcc/cgraphunit.c:2073
> #17 0x008df954 in symbol_table::compile (this=0x76ecf000) at 
> ../../gcc-trunk/gcc/cgraphunit.c:2426
> #18 0x008dfb68 in symbol_table::finalize_compilation_unit 
> (this=0x76ecf000) at ../../gcc-trunk/gcc/cgraphunit.c:2513
> #19 0x00e094ba in compile_file () at ../../gcc-trunk/gcc/toplev.c:580
> #20 0x00e0b9fa in do_compile () at ../../gcc-trunk/gcc/toplev.c:2070
> #21 0x00e0bc46 in toplev::main (this=0x7fffdc50, argc=35, 
> argv=0x7fffdd58) at ../../gcc-trunk/gcc/toplev.c:2171
> #22 0x016b656d in main (argc=35, argv=0x7fffdd58) at 
> ../../gcc-trunk/gcc/main.c:39
>
> I cannot find any instruction in the rtl dumps that corresponds to this large 
> argp offset.  So I think there must be
> something wrong along the call stack above, which looks identically even on 
> the bogus frame pointer references.
>
>
> Is this patch OK for trunk now?
>
> At least Jakub and I are in favour of it, Eric is against it.
> That makes 2:1 ...
>
>
> Thanks
> Bernd.
>
  

[PATCH, committed] jit: clarify (lack of) lifetime requirements on input const char *

2015-07-01 Thread David Malcolm
Committed to trunk as r225245.

gcc/jit/ChangeLog:
* docs/topics/contexts.rst (gcc_jit_context_set_bool_option):
Clarify lack of lifetime requirements on (const char *) parameter.
* docs/topics/expressions.rst
(gcc_jit_context_new_string_literal): Likewise.
(gcc_jit_context_new_global): Likewise.
* docs/topics/functions.rst (gcc_jit_context_new_param): Likewise.
(gcc_jit_context_new_function): Likewise.
(gcc_jit_function_new_block): Likewise.
(gcc_jit_block_add_comment): Likewise.
* docs/topics/locations.rst (gcc_jit_context_new_location):
Likewise.
* docs/topics/types.rst (gcc_jit_context_new_field): Likewise.
(gcc_jit_context_new_struct_type): Likewise.
* docs/_build/texinfo/libgccjit.texi: Regenerate.
---
 gcc/jit/docs/topics/contexts.rst|  4 
 gcc/jit/docs/topics/expressions.rst |  7 +++
 gcc/jit/docs/topics/functions.rst   | 34 +-
 gcc/jit/docs/topics/locations.rst   |  4 
 gcc/jit/docs/topics/types.rst   | 12 
 5 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/gcc/jit/docs/topics/contexts.rst b/gcc/jit/docs/topics/contexts.rst
index 1dd4685..78bcb71 100644
--- a/gcc/jit/docs/topics/contexts.rst
+++ b/gcc/jit/docs/topics/contexts.rst
@@ -313,6 +313,10 @@ String Options
 
.. type:: enum gcc_jit_str_option
 
+   The parameter ``value`` can be NULL.   If non-NULL, the call takes a
+   copy of the underlying string, so it is valid to pass in a pointer to
+   an on-stack buffer.
+
There is just one string option specified this way:
 
.. macro:: GCC_JIT_STR_OPTION_PROGNAME
diff --git a/gcc/jit/docs/topics/expressions.rst 
b/gcc/jit/docs/topics/expressions.rst
index 621991f..c12a378 100644
--- a/gcc/jit/docs/topics/expressions.rst
+++ b/gcc/jit/docs/topics/expressions.rst
@@ -122,6 +122,9 @@ Simple expressions
Generate an rvalue for the given NIL-terminated string, of type
:c:data:`GCC_JIT_TYPE_CONST_CHAR_PTR`.
 
+   The parameter ``value`` must be non-NULL.  The call takes a copy of the
+   underlying string, so it is valid to pass in a pointer to an on-stack
+   buffer.
 
 Unary Operations
 
@@ -466,6 +469,10 @@ Global variables
 
Add a new global variable of the given type and name to the context.
 
+   The parameter ``name`` must be non-NULL.  The call takes a copy of the
+   underlying string, so it is valid to pass in a pointer to an on-stack
+   buffer.
+
The "kind" parameter determines the visibility of the "global" outside
of the :c:type:`gcc_jit_result`:
 
diff --git a/gcc/jit/docs/topics/functions.rst 
b/gcc/jit/docs/topics/functions.rst
index 94db471..f2f8f34 100644
--- a/gcc/jit/docs/topics/functions.rst
+++ b/gcc/jit/docs/topics/functions.rst
@@ -35,6 +35,10 @@ Params
In preparation for creating a function, create a new parameter of the
given type and name.
 
+   The parameter ``name`` must be non-NULL.  The call takes a copy of the
+   underlying string, so it is valid to pass in a pointer to an on-stack
+   buffer.
+
 Parameters are lvalues, and thus are also rvalues (and objects), so the
 following upcasts are available:
 
@@ -111,6 +115,10 @@ Functions
  above 0; when optimization is off, this is essentially the
  same as GCC_JIT_FUNCTION_INTERNAL.
 
+   The parameter ``name`` must be non-NULL.  The call takes a copy of the
+   underlying string, so it is valid to pass in a pointer to an on-stack
+   buffer.
+
 .. function::  gcc_jit_function *\
gcc_jit_context_get_builtin_function (gcc_jit_context *ctxt,\
  const char *name)
@@ -140,6 +148,9 @@ Functions
Create a new local variable within the function, of the given type and
name.
 
+   The parameter ``name`` must be non-NULL.  The call takes a copy of the
+   underlying string, so it is valid to pass in a pointer to an on-stack
+   buffer.
 
 Blocks
 --
@@ -166,7 +177,17 @@ Blocks
Create a basic block of the given name.  The name may be NULL, but
providing meaningful names is often helpful when debugging: it may
show up in dumps of the internal representation, and in error
-   messages.
+   messages.  It is copied, so the input buffer does not need to outlive
+   the call; you can pass in a pointer to an on-stack buffer, e.g.:
+
+   .. code-block:: c
+
+ for (pc = 0; pc < fn->fn_num_ops; pc++)
+  {
+char buf[16];
+sprintf (buf, "instr%i", pc);
+state.op_blocks[pc] = gcc_jit_function_new_block (state.fn, buf);
+  }
 
 .. function::  gcc_jit_object *\
gcc_jit_block_as_object (gcc_jit_block *block)
@@ -252,6 +273,17 @@ Statements
and thus may be of use when debugging how your project's internal
representation gets converted to the libgccjit IR.
 
+   The parameter ``text`` must be non-NULL.  It is copied, so the input
+   buffer does not

Re: [PING] [RFC] Sanitize rtx_addr_can_trap_p_1

2015-07-01 Thread Jakub Jelinek
On Wed, Jul 01, 2015 at 02:31:41PM +0200, Bernd Edlinger wrote:
> the bogus offsets-issue is now entered in bugzilla, see PR66614.
> 
> It is however only a very minor issue, and does probably have
> no impact on the generated code at all.
> 
> 
> How should I continue with the rtx_addr_can_trap-patch?
> Is it OK to commit?

Please commit it (the non-debug patch only of course), but watch
for fallout.  Thanks.

Jakub


[PATCH, committed] jit: document union types

2015-07-01 Thread David Malcolm
Committed to trunk as r225246.

gcc/jit/ChangeLog:
* docs/topics/types.rst (gcc_jit_context_new_union_type): Add
documentation.
* docs/_build/texinfo/libgccjit.texi: Regenerate.

gcc/testsuite/ChangeLog:
* jit.dg/test-accessing-union.c: Add comments for use by
gcc/jit/docs/topics/types.rst.
---
 gcc/jit/docs/topics/types.rst   | 19 +++
 gcc/testsuite/jit.dg/test-accessing-union.c |  4 
 2 files changed, 23 insertions(+)

diff --git a/gcc/jit/docs/topics/types.rst b/gcc/jit/docs/topics/types.rst
index 5bfba72..41fa40e 100644
--- a/gcc/jit/docs/topics/types.rst
+++ b/gcc/jit/docs/topics/types.rst
@@ -230,3 +230,22 @@ You can model C `struct` types by creating 
:c:type:`gcc_jit_struct *` and
Populate the fields of a formerly-opaque struct type.
 
This can only be called once on a given struct type.
+
+.. function:: gcc_jit_type *\
+  gcc_jit_context_new_union_type (gcc_jit_context *ctxt,\
+  gcc_jit_location *loc,\
+  const char *name,\
+  int num_fields,\
+  gcc_jit_field **fields)
+
+ Construct a new union type, with the given name and fields.
+
+ The parameter ``name`` must be non-NULL.  It is copied, so the input
+ buffer does not need to outlive the call.
+
+ Example of use:
+
+ .. literalinclude:: ../../../testsuite/jit.dg/test-accessing-union.c
+   :start-after: /* Quote from here in docs/topics/types.rst.  */
+   :end-before: /* Quote up to here in docs/topics/types.rst.  */
+   :language: c
diff --git a/gcc/testsuite/jit.dg/test-accessing-union.c 
b/gcc/testsuite/jit.dg/test-accessing-union.c
index 658d1bc..15656e9 100644
--- a/gcc/testsuite/jit.dg/test-accessing-union.c
+++ b/gcc/testsuite/jit.dg/test-accessing-union.c
@@ -5,6 +5,8 @@
 
 #include "harness.h"
 
+/* Quote from here in docs/topics/types.rst.  */
+
 union int_or_float
 {
   int as_int;
@@ -77,6 +79,8 @@ create_code (gcc_jit_context *ctxt, void *user_data)
 as_float));
 }
 
+/* Quote up to here in docs/topics/types.rst.  */
+
 void
 verify_code (gcc_jit_context *ctxt, gcc_jit_result *result)
 {
-- 
1.8.5.3



[PATCH, committed] PR jit/66700: set TREE_ADDRESSABLE when building an ADDR_EXPR

2015-07-01 Thread David Malcolm
Tested by visual inspection of gimple dump of reproducer
supplied by bug reporter [1], and via "make check-jit"; takes jit.sum
from 8234 to 8289 passes.

Committed to trunk as r225248.

[1] https://gcc.gnu.org/ml/jit/2015-q2/msg00134.html

gcc/jit/ChangeLog:
PR jit/66700
* jit-playback.c (jit_mark_addressable): New function.
(gcc::jit::playback::lvalue::get_address): Call
jit_mark_addressable on the underlying tree.

gcc/testsuite/ChangeLog:
PR jit/66700
* jit.dg/all-non-failing-tests.h: Add
test-pr66700-observing-write-through-ptr.c.
* jit.dg/test-pr66700-observing-write-through-ptr.c: New testcase.
---
 gcc/jit/jit-playback.c |  42 
 gcc/testsuite/jit.dg/all-non-failing-tests.h   |  10 ++
 .../test-pr66700-observing-write-through-ptr.c | 109 +
 3 files changed, 161 insertions(+)
 create mode 100644 
gcc/testsuite/jit.dg/test-pr66700-observing-write-through-ptr.c

diff --git a/gcc/jit/jit-playback.c b/gcc/jit/jit-playback.c
index c9d7c8c..1fe1091 100644
--- a/gcc/jit/jit-playback.c
+++ b/gcc/jit/jit-playback.c
@@ -1164,6 +1164,47 @@ dereference (location *loc)
   return new lvalue (get_context (), datum);
 }
 
+/* Mark EXP saying that we need to be able to take the
+   address of it; it should not be allocated in a register.
+   Compare with e.g. c/c-typeck.c: c_mark_addressable.  */
+
+static void
+jit_mark_addressable (tree exp)
+{
+  tree x = exp;
+
+  while (1)
+switch (TREE_CODE (x))
+  {
+  case COMPONENT_REF:
+   /* (we don't yet support bitfields)  */
+   /* fallthrough */
+  case ADDR_EXPR:
+  case ARRAY_REF:
+  case REALPART_EXPR:
+  case IMAGPART_EXPR:
+   x = TREE_OPERAND (x, 0);
+   break;
+
+  case COMPOUND_LITERAL_EXPR:
+  case CONSTRUCTOR:
+   TREE_ADDRESSABLE (x) = 1;
+   return;
+
+  case VAR_DECL:
+  case CONST_DECL:
+  case PARM_DECL:
+  case RESULT_DECL:
+   /* (we don't have a concept of a "register" declaration) */
+   /* fallthrough */
+  case FUNCTION_DECL:
+   TREE_ADDRESSABLE (x) = 1;
+   /* fallthrough */
+  default:
+   return;
+  }
+}
+
 /* Construct a playback::rvalue instance (wrapping a tree) for an
address-lookup.  */
 
@@ -1177,6 +1218,7 @@ get_address (location *loc)
   tree ptr = build1 (ADDR_EXPR, t_ptrtype, t_lvalue);
   if (loc)
 get_context ()->set_tree_location (ptr, loc);
+  jit_mark_addressable (t_lvalue);
   return new rvalue (get_context (), ptr);
 }
 
diff --git a/gcc/testsuite/jit.dg/all-non-failing-tests.h 
b/gcc/testsuite/jit.dg/all-non-failing-tests.h
index 36a6160..21ff428 100644
--- a/gcc/testsuite/jit.dg/all-non-failing-tests.h
+++ b/gcc/testsuite/jit.dg/all-non-failing-tests.h
@@ -154,6 +154,13 @@
 #undef create_code
 #undef verify_code
 
+/* test-pr66700-observing-write-through-ptr.c */
+#define create_code create_code_pr66700_observing_write_through_ptr
+#define verify_code verify_code_pr66700_observing_write_through_ptr
+#include "test-pr66700-observing-write-through-ptr.c"
+#undef create_code
+#undef verify_code
+
 /* test-reading-struct.c */
 #define create_code create_code_reading_struct
 #define verify_code verify_code_reading_struct
@@ -279,6 +286,9 @@ const struct testcase testcases[] = {
   {"nested_loop",
create_code_nested_loop,
verify_code_nested_loop},
+  {"pr66700_observing_write_through_ptr",
+   create_code_pr66700_observing_write_through_ptr,
+   verify_code_pr66700_observing_write_through_ptr},
   {"reading_struct ",
create_code_reading_struct ,
verify_code_reading_struct },
diff --git a/gcc/testsuite/jit.dg/test-pr66700-observing-write-through-ptr.c 
b/gcc/testsuite/jit.dg/test-pr66700-observing-write-through-ptr.c
new file mode 100644
index 000..4ffbfac
--- /dev/null
+++ b/gcc/testsuite/jit.dg/test-pr66700-observing-write-through-ptr.c
@@ -0,0 +1,109 @@
+/* Test of PR jit/66700.  */
+
+#include 
+#include 
+
+#include "libgccjit.h"
+
+#include "harness.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+  extern void
+  write_back_through_ptr (double *d);
+
+#ifdef __cplusplus
+}
+#endif
+
+void
+create_code (gcc_jit_context *ctxt, void *user_data)
+{
+  /* Let's try to inject the equivalent of:
+
+ double
+ test_caller_of_write_back_through_ptr (void)
+ {
+   double d;
+   d = 4.0;
+   write_back_through_ptr (&d);
+   return d;
+ }
+  */
+  gcc_jit_type *t_void =
+gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_VOID);
+  gcc_jit_type *t_double =
+gcc_jit_context_get_type (ctxt, GCC_JIT_TYPE_DOUBLE);
+  gcc_jit_type *t_ptr_to_double =
+gcc_jit_type_get_pointer (t_double);
+
+  /* Declare the imported function.  */
+  gcc_jit_param *params[1];
+  params[0] =
+gcc_jit_context_new_param (ctxt, NULL, t_ptr_to_double, "d");
+  gcc_jit_function *called_fn =
+gcc_jit_context_new_function (ctxt, NULL,
+   

[gomp4] Remove clause from device_type options

2015-07-01 Thread James Norris

Hi,

The independent clause is not available for use
with device_type clauses associated with loop
directives. This patch removes the usage.

Committed to gomp-4_0-branch

Jim
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index bcbd163..88e68ae 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -13069,7 +13069,6 @@ c_parser_oacc_host_data (location_t loc, c_parser *parser)
 	| (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_WORKER)		\
 	| (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_VECTOR)		\
 	| (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_AUTO)		\
-	| (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_INDEPENDENT) 	\
 	| (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_SEQ)			\
 	| (OMP_CLAUSE_MASK_1 << PRAGMA_OACC_CLAUSE_TILE) )
 


[PATCH][10/n] Remove GENERIC stmt combining from SCCVN

2015-07-01 Thread Richard Biener

This merges the complete comparison patterns from the match-and-simplify
branch, leaving incomplete implementations of fold-const.c code alone.

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

Richard.

2015-07-01  Richard Biener  

* fold-const.c (fold_comparison): Move X - Y CMP 0 -> X CMP Y,
X * C1 CMP 0 -> X CMP 0, X CMP X, ~X CMP ~Y -> Y CMP X and
~X CMP C -> X CMP' ~C to ...
* match.pd: ... patterns here.

Index: gcc/fold-const.c
===
--- gcc/fold-const.c(revision 225225)
+++ gcc/fold-const.c(working copy)
@@ -8783,23 +8734,6 @@ fold_comparison (location_t loc, enum tr
}
 }
 
-  /* Transform comparisons of the form X - Y CMP 0 to X CMP Y.  */
-  if (TREE_CODE (arg0) == MINUS_EXPR
-  && equality_code
-  && integer_zerop (arg1))
-{
-  /* ??? The transformation is valid for the other operators if overflow
-is undefined for the type, but performing it here badly interacts
-with the transformation in fold_cond_expr_with_comparison which
-attempts to synthetize ABS_EXPR.  */
-  if (!equality_code)
-   fold_overflow_warning ("assuming signed overflow does not occur "
-  "when changing X - Y cmp 0 to X cmp Y",
-  WARN_STRICT_OVERFLOW_COMPARISON);
-  return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0),
- TREE_OPERAND (arg0, 1));
-}
-
   /* For comparisons of pointers we can decompose it to a compile time
  comparison of the base objects and the offsets into the object.
  This requires at least one operand being an ADDR_EXPR or a
@@ -9088,38 +9022,6 @@ fold_comparison (location_t loc, enum tr
}
 }
 
-  /* Transform comparisons of the form X * C1 CMP 0 to X CMP 0 in the
- signed arithmetic case.  That form is created by the compiler
- often enough for folding it to be of value.  One example is in
- computing loop trip counts after Operator Strength Reduction.  */
-  if (ANY_INTEGRAL_TYPE_P (TREE_TYPE (arg0))
-  && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (arg0))
-  && TREE_CODE (arg0) == MULT_EXPR
-  && (TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST
-  && !TREE_OVERFLOW (TREE_OPERAND (arg0, 1)))
-  && integer_zerop (arg1))
-{
-  tree const1 = TREE_OPERAND (arg0, 1);
-  tree const2 = arg1;   /* zero */
-  tree variable1 = TREE_OPERAND (arg0, 0);
-  enum tree_code cmp_code = code;
-
-  /* Handle unfolded multiplication by zero.  */
-  if (integer_zerop (const1))
-   return fold_build2_loc (loc, cmp_code, type, const1, const2);
-
-  fold_overflow_warning (("assuming signed overflow does not occur when "
- "eliminating multiplication in comparison "
- "with zero"),
-WARN_STRICT_OVERFLOW_COMPARISON);
-
-  /* If const1 is negative we swap the sense of the comparison.  */
-  if (tree_int_cst_sgn (const1) < 0)
-cmp_code = swap_tree_comparison (cmp_code);
-
-  return fold_build2_loc (loc, cmp_code, type, variable1, const2);
-}
-
   tem = maybe_canonicalize_comparison (loc, code, type, arg0, arg1);
   if (tem)
 return tem;
@@ -9241,40 +9138,6 @@ fold_comparison (location_t loc, enum tr
return tem;
 }
 
-  /* Simplify comparison of something with itself.  (For IEEE
- floating-point, we can only do some of these simplifications.)  */
-  if (operand_equal_p (arg0, arg1, 0))
-{
-  switch (code)
-   {
-   case EQ_EXPR:
- if (! FLOAT_TYPE_P (TREE_TYPE (arg0))
- || ! HONOR_NANS (arg0))
-   return constant_boolean_node (1, type);
- break;
-
-   case GE_EXPR:
-   case LE_EXPR:
- if (! FLOAT_TYPE_P (TREE_TYPE (arg0))
- || ! HONOR_NANS (arg0))
-   return constant_boolean_node (1, type);
- return fold_build2_loc (loc, EQ_EXPR, type, arg0, arg1);
-
-   case NE_EXPR:
- /* For NE, we can only do this simplification if integer
-or we don't honor IEEE floating point NaNs.  */
- if (FLOAT_TYPE_P (TREE_TYPE (arg0))
- && HONOR_NANS (arg0))
-   break;
- /* ... fall through ...  */
-   case GT_EXPR:
-   case LT_EXPR:
- return constant_boolean_node (0, type);
-   default:
- gcc_unreachable ();
-   }
-}
-
   /* If we are comparing an expression that just has comparisons
  of two integer values, arithmetic expressions of those comparisons,
  and constants, we can simplify it.  There are only three cases
@@ -9392,28 +9255,6 @@ fold_comparison (location_t loc, enum tr
return tem;
 }
 
-  /* Fold ~X op ~Y as Y op X.  */
-  if (TREE_CODE (arg0) == BIT_NOT_EXPR
-  && TREE_CODE (arg1) == BIT_NOT_EXPR)
-{
-  tree cmp_type

[PATCH] Improve DOM condition handling

2015-07-01 Thread Richard Biener

I've just noticed that DOM doesn't handle

  if (x >= y)
return 1;

  if (y == x)
abort ();

in that it records y != x on the else edge but not !(y == x).

The following fixes that.

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

Richard.

2015-07-01  Richard Biener  

* tree-ssa-dom.c (build_and_record_new_cond): Add optional
parameter to record a condition that is false.
(record_conditions): When recording an extra NE_EXPR that is
true also record a EQ_EXPR that is false.

* gcc.dg/tree-ssa/ssa-dom-cse-4.c: New testcase.

Index: gcc/tree-ssa-dom.c
===
*** gcc/tree-ssa-dom.c  (revision 225225)
--- gcc/tree-ssa-dom.c  (working copy)
*** free_all_edge_infos (void)
*** 813,819 
  static void
  build_and_record_new_cond (enum tree_code code,
 tree op0, tree op1,
!vec *p)
  {
cond_equivalence c;
struct hashable_expr *cond = &c.cond;
--- 813,820 
  static void
  build_and_record_new_cond (enum tree_code code,
 tree op0, tree op1,
!vec *p,
!  bool val = true)
  {
cond_equivalence c;
struct hashable_expr *cond = &c.cond;
*** build_and_record_new_cond (enum tree_cod
*** 826,832 
cond->ops.binary.opnd0 = op0;
cond->ops.binary.opnd1 = op1;
  
!   c.value = boolean_true_node;
p->safe_push (c);
  }
  
--- 827,833 
cond->ops.binary.opnd0 = op0;
cond->ops.binary.opnd1 = op1;
  
!   c.value = val ? boolean_true_node : boolean_false_node;
p->safe_push (c);
  }
  
*** record_conditions (struct edge_info *edg
*** 865,870 
--- 866,873 
 op0, op1, &edge_info->cond_equivalences);
build_and_record_new_cond (NE_EXPR, op0, op1,
 &edge_info->cond_equivalences);
+   build_and_record_new_cond (EQ_EXPR, op0, op1,
+&edge_info->cond_equivalences, false);
break;
  
  case GE_EXPR:
Index: gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-4.c
===
--- gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-4.c   (revision 0)
+++ gcc/testsuite/gcc.dg/tree-ssa/ssa-dom-cse-4.c   (revision 0)
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-optimized" } */
+
+extern void abort (void);
+
+unsigned int
+foo (unsigned int x, unsigned int y)
+{
+  unsigned int z;
+
+  if (x >= y)
+return 1;
+
+  if (y == x)
+abort ();
+
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-not "abort" "optimized" } } */


[patch] Change valid arguments for --with-default-libstdcxx-abi

2015-07-01 Thread Jonathan Wakely

I intend to commit this to trunk and the gcc-5-branch either today or
tomorrow.

I made a mistake in using "c++98" and "c++11" as the valid arguments
for the ABI configure option, because it confuses people into thinking
that it is affected by, or affects, the -std=c++11 option.  In fact
the ABI mode and -std standard mode are independent.

The inline namespace is called __cxx11, the ABI-tag is "cxx11" and the
controlling macro is _GLIBCXX_USE_CXX11_ABI so I think referring to
the ABI as "cxx11" might help distinguish it from the -std=c++11 mode.

This will require distros that are using the
--with-default-libstdcxx-abi option to change their build scripts,
because using c++98 (or similar) now gives an error:

checking for default std::string ABI to use... configure: error: Supported arguments for 
--with-default-libstdcxx-abi have changed, use "cxx11" or "cxx98"
Makefile:11390: recipe for target 'configure-target-libstdc++-v3' failed

commit 6baea9aaba16ee07e0ad2a190ec9c2a2d6f5648c
Author: Jonathan Wakely 
Date:   Wed Jul 1 14:22:05 2015 +0100

	* acinclude.m4 (GLIBCXX_DEFAULT_ABI): Change valid arguments for
	--with-default-libstdcxx-abi
	* configure: Regenerate.
	* doc/xml/manual/configure.xml: Document valid arguments.

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index 8340572..df71a08 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -3792,7 +3792,7 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI], [
   fi
   if test x"$enable_libstdcxx_dual_abi" != xyes; then
 AC_MSG_NOTICE([dual ABI is disabled])
-default_libstdcxx_abi="c++98"
+default_libstdcxx_abi="cxx98"
   fi
   GLIBCXX_CONDITIONAL(ENABLE_DUAL_ABI, test $enable_libstdcxx_dual_abi = yes)
 ])
@@ -3800,7 +3800,7 @@ AC_DEFUN([GLIBCXX_ENABLE_LIBSTDCXX_DUAL_ABI], [
 dnl
 dnl Check to see which ABI should be enabled by default.
 dnl
-dnl --with-default-libstdcxx-abi={c++98,c++11}
+dnl --with-default-libstdcxx-abi={cxx98,cxx11}
 dnl
 dnl Defines:
 dnl  _GLIBCXX_USE_CXX11_ABI (always defined, either to 1 or 0)
@@ -3812,14 +3812,16 @@ AC_DEFUN([GLIBCXX_DEFAULT_ABI], [
 AS_HELP_STRING([--with-default-libstdcxx-abi],
[set the std::string ABI to use by default]),
 [case "$withval" in
-  c++98|gnu++98|c++03|gnu++03)  default_libstdcxx_abi="c++98" ;;
-  c++1?|gnu++1?)  default_libstdcxx_abi="c++11" ;;
+  cxx98)  default_libstdcxx_abi="cxx98" ;;
+  cxx11)  default_libstdcxx_abi="cxx11" ;;
+  c++*|gnu++*) AC_MSG_ERROR([Supported arguments for --with-default-libstdcxx-abi have changed, use "cxx11" or "cxx98"]) ;;
   *)  AC_MSG_ERROR([Invalid argument for --with-default-libstdcxx-abi]) ;;
- esac],
-[default_libstdcxx_abi="c++11"])
+ esac
+ ],
+[default_libstdcxx_abi="cxx11"])
   AC_MSG_RESULT(${default_libstdcxx_abi})
   fi
-  if test $default_libstdcxx_abi = "c++11"; then
+  if test $default_libstdcxx_abi = "cxx11"; then
 glibcxx_cxx11_abi=1
 glibcxx_cxx98_abi=0
   else
diff --git a/libstdc++-v3/doc/xml/manual/configure.xml b/libstdc++-v3/doc/xml/manual/configure.xml
index 9ba9c1a..40d7138 100644
--- a/libstdc++-v3/doc/xml/manual/configure.xml
+++ b/libstdc++-v3/doc/xml/manual/configure.xml
@@ -389,9 +389,9 @@

  Set the default value for the _GLIBCXX_USE_CXX11_ABI
  macro (see ).
- The default is OPTION=c++11 which sets the macro to
+ The default is OPTION=cxx11 which sets the macro to
  1,
- use OPTION=c++98 to set it to 0.
+ use OPTION=cxx98 to set it to 0.
  This option does not change the library ABI.

  


Re: [gomp] openacc reduction cleanup

2015-07-01 Thread Cesar Philippidis
On 06/30/2015 11:01 AM, Cesar Philippidis wrote:

> This patch has been applied to gomp-4_0-branch.

It was brought to my attention that I forgot to attach the patch.

Cesar
2015-06-30  Cesar Philippidis  

	gcc/
	* omp-low.c (oacc_get_reduction_array_id): Remove.
	(oacc_parallel_max_reduction_array_size): Remove.
	(install_array_var_ganglocal): Remove.
	(oacc_outermost_parallel_kernels_context): Remove.
	(oacc_inside_routine): Remove.
	(is_oacc_multithreaded): Remove.
	(oacc_needs_global_memory): Remove.
	(oacc_max_threads): Remove.
	(scan_sharing_clauses): Don't allocate an array for openacc reductions.
	(oacc_lower_reduction_var_helper): Remove.
	(lower_reduction_clauses): Handle all OpenACC reductions using atomics.
	(oacc_gimple_assign): Remove.
	(oacc_initialize_reduction_data): Remove.
	(oacc_serial_reduction): Remove.
	(oacc_finalize_reduction_data): Remove.
	(oacc_process_reduction_data_helper): Remove.
	(oacc_process_reduction_data): Remove.
	(lower_omp_target): Don't call oacc_process_reduction_data anymore.

diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 24fac7c..11ac909 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -305,18 +305,6 @@ static basic_block oacc_broadcast (basic_block, basic_block,
   *handled_ops_p = false; \
   break;
 
-/* Helper function to get the name of the array containing the partial
-   reductions for OpenACC reductions.  */
-static const char *
-oacc_get_reduction_array_id (tree node)
-{
-  const char *id = IDENTIFIER_POINTER (DECL_NAME (node));
-  int len = strlen ("OACC") + strlen (id);
-  char *temp_name = XALLOCAVEC (char, len + 1);
-  snprintf (temp_name, len + 1, "OACC%s", id);
-  return IDENTIFIER_POINTER (get_identifier (temp_name));
-}
-
 static bool
 is_oacc_parallel (omp_context *ctx)
 {
@@ -326,68 +314,6 @@ is_oacc_parallel (omp_context *ctx)
 	  == GF_OMP_TARGET_KIND_OACC_PARALLEL));
 }
 
-/* Determine the maximum number of threads available to the current omp
-   context for a parallel OpenACC reduction.  */
-
-static tree
-oacc_parallel_max_reduction_array_size (omp_context *ctx, tree clauses,
-	gimple_seq *seqp)
-{
-  tree nthreads;
-  bool gangs, workers, vectors;
-  omp_context *oc;
-
-  gangs = find_omp_clause (clauses, OMP_CLAUSE_GANG) != NULL_TREE;
-  workers = find_omp_clause (clauses, OMP_CLAUSE_WORKER) != NULL_TREE;
-  vectors = find_omp_clause (clauses, OMP_CLAUSE_VECTOR) != NULL_TREE;
-
-  /* num_gangs, num_workers and vector_length is set in innermost parallel
- gimple stmt.  Find that stmt and extract those values.  */
-
-  for (oc = ctx; !is_oacc_parallel (oc); oc = oc->outer)
-;
-
-  clauses = gimple_omp_target_clauses (oc->stmt);
-
-  /* FIXME: this assignment may be useless.  */
-  nthreads = create_tmp_var (sizetype, NULL);
-  gimplify_assign (nthreads, build_int_cst (sizetype, 1), seqp);
-
-  if (vectors)
-{
-  tree v = find_omp_clause (clauses, OMP_CLAUSE_VECTOR_LENGTH);
-  if (v)
-	{
-	  //tree t = fold_convert (sizetype, OMP_CLAUSE_VECTOR_LENGTH_EXPR (v));
-	  gimplify_assign (nthreads, build_int_cst (sizetype, 1), seqp);
-	}
-}
-
-  if (workers)
-{
-  tree w = find_omp_clause (clauses, OMP_CLAUSE_NUM_WORKERS);
-  if (w)
-	{
-	  tree t = fold_convert (sizetype, OMP_CLAUSE_NUM_WORKERS_EXPR (w));
-	  gimple stmt = gimple_build_assign (nthreads, MULT_EXPR, nthreads, t);
-	  gimple_seq_add_stmt (seqp, stmt);
-	}
-}
-
-  if (gangs)
-{
-  tree g = find_omp_clause (clauses, OMP_CLAUSE_NUM_GANGS);
-  if (g)
-	{
-	  tree t = fold_convert (sizetype, OMP_CLAUSE_NUM_GANGS_EXPR (g));
-	  gimple stmt = gimple_build_assign(nthreads, MULT_EXPR, nthreads, t);
-	  gimple_seq_add_stmt (seqp, stmt);
-	}
-}
-
-  return nthreads;
-}
-
 /* Holds offload tables with decls.  */
 vec *offload_funcs, *offload_vars;
 
@@ -1583,14 +1509,6 @@ install_var_ganglocal (tree decl, omp_context *ctx)
   return new_var;
 }
 
-static tree
-install_array_var_ganglocal (tree decl, tree type, tree size, omp_context *ctx)
-{
-  tree ptr = alloc_var_ganglocal (decl, type, ctx, size);
-  insert_decl_map (&ctx->cb, decl, ptr);
-  return ptr;
-}
-
 /* Debugging dumps for parallel regions.  */
 void dump_omp_region (FILE *, struct omp_region *, int);
 void debug_omp_region (struct omp_region *);
@@ -1870,140 +1788,6 @@ fixup_child_record_type (omp_context *ctx)
 = build_qualified_type (build_reference_type (type), TYPE_QUAL_RESTRICT);
 }
 
-static omp_context *
-oacc_outermost_parallel_kernels_context (omp_context *ctx)
-{
-  omp_context *octx = ctx;
-
-  while (octx)
-{
-  if (gimple_code (octx->stmt) == GIMPLE_OMP_TARGET)
-	{
-	  int kind = gimple_omp_target_kind (octx->stmt);
-	  if (kind == GF_OMP_TARGET_KIND_OACC_PARALLEL
-	  || kind == GF_OMP_TARGET_KIND_OACC_KERNELS)
-	return octx;
-	}
-
-  octx = octx->outer;
-}
-
-  return ctx;
-}
-
-/* OpenACC routines contain acc loops without any kernels or parallel
-   regions.  If the omp_context isn't a descendant of a kernels or

Re: [PATCH] config/bfin/bfin.c (hwloop_optimize): Use return false instead of gcc_assert for checking jump_insn.

2015-07-01 Thread Bernd Schmidt

On 07/01/2015 03:04 AM, Chen Gang wrote:


For me, the more details are:

  - The insns have 2 loops which can be lsetup optimized.

  - After hwloop_optimize finishes 1st lsetup optimization, it generates
new lsetup insn which appends to jump insn in the basic block (which
causes the insns are not 'standard' but OK for code generation).


The problem is that you can't append anything to a basic block after a 
jump. You need to create a new one. This problem doesn't usually show up 
since nothing ever looks at the basic block again, unless both 
directions from the conditional branch happen to branch to lsetup 
candidate loops.


Below is a patch. Can you test this with anything you have beyond the 
testsuite?



Bernd

diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c
index 8c1e18a..2c6f195 100644
--- a/gcc/config/bfin/bfin.c
+++ b/gcc/config/bfin/bfin.c
@@ -3796,8 +3796,19 @@ hwloop_optimize (hwloop_info loop)
 	{
 	  gcc_assert (JUMP_P (prev));
 	  prev = PREV_INSN (prev);
+	  emit_insn_after (seq, prev);
+	}
+  else
+	{
+	  emit_insn_after (seq, prev);
+	  BB_END (loop->incoming_src) = prev;
+	  basic_block new_bb = create_basic_block (seq, seq_end,
+		   loop->head->prev_bb);
+	  edge e = loop->incoming->last ();
+	  gcc_assert (e->flags & EDGE_FALLTHRU);
+	  redirect_edge_succ (e, new_bb);
+	  make_edge (new_bb, loop->head, 0);
 	}
-  emit_insn_after (seq, prev);
 }
   else
 {


Re: [Patch 0/4] PowerPC64 Linux split stack support

2015-07-01 Thread Lynn A. Boger
If further testing is needed on this patch I can do it, but I need more 
information what variations need to be tested?


It's not clear to me what distro/gcc/glibc versions and type of build 
causes the error.  I have not been able to reproduce the

original problem.

On 06/15/2015 01:58 PM, Andreas Schwab wrote:

* go-lang.c (go_langhook_init_options_struct): Don't set
x_flag_split_stack.
(go_langhook_post_options): Set it here instead.
---
  gcc/go/go-lang.c | 9 +
  1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/gcc/go/go-lang.c b/gcc/go/go-lang.c
index ce4dd9b..d952e0f 100644
--- a/gcc/go/go-lang.c
+++ b/gcc/go/go-lang.c
@@ -158,10 +158,6 @@ go_langhook_init_options_struct (struct gcc_options *opts)
opts->x_flag_errno_math = 0;
opts->frontend_set_flag_errno_math = true;

-  /* We turn on stack splitting if we can.  */
-  if (targetm_common.supports_split_stack (false, opts))
-opts->x_flag_split_stack = 1;
-
/* Exceptions are used to handle recovering from panics.  */
opts->x_flag_exceptions = 1;
opts->x_flag_non_call_exceptions = 1;
@@ -295,6 +291,11 @@ go_langhook_post_options (const char **pfilename 
ATTRIBUTE_UNUSED)
&& global_options.x_write_symbols == NO_DEBUG)
  global_options.x_write_symbols = PREFERRED_DEBUGGING_TYPE;

+  /* We turn on stack splitting if we can.  */
+  if (!global_options_set.x_flag_split_stack
+  && targetm_common.supports_split_stack (false, &global_options))
+global_options.x_flag_split_stack = 1;
+
/* Returning false means that the backend should be used.  */
return false;
  }




Re: [Patch 0/4] PowerPC64 Linux split stack support

2015-07-01 Thread Andreas Schwab
"Lynn A. Boger"  writes:

> It's not clear to me what distro/gcc/glibc versions and type of build
> causes the error.  I have not been able to reproduce the
> original problem.

The failure mode is quite obvious: go_langhook_init_options_struct is
called before the options are parsed, so -m32 hasn't been acted upon and
supports_split_stack falsely returns true.

Andreas.

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


[gomp4] implicit firstprivate and other testcase fixes

2015-07-01 Thread Chung-Lin Tang
This patch "notices" the index variable of an acc loop (internally an OMP_FOR)
inside an OpenACC construct, and completes the implicit firstprivate
behavior as described in the spec. The firstprivate clauses and FIXME in
libgomp.oacc-c-c++-common/parallel-loop-2.h has also been removed together
in the patch.

Also a typo-bug in testcase libgomp.oacc-c-c++-common/reduction-4.c is also 
corrected,
where reduction variable names are apparently wrong.

Tested without regressions, and applied to gomp-4_0-branch.

Chung-Lin

2015-07-01  Chung-Lin Tang  

gcc/
* gimplify.c (gimplify_omp_for): For acc loops inside OpenACC 
constructs,
notice the use of the index variable in the surrounding 
gimplify_omp_ctx.

libgomp/
* testsuite/libgomp.oacc-c-c++-common/reduction-4.c (main): Correct
the names of reduction variables in '&&' and '||' tests.
* testsuite/libgomp.oacc-c-c++-common/parallel-loop-2.h:
Remove uses of the firstprivate clause, remove FIXME comment.
Index: gcc/gimplify.c
===
--- gcc/gimplify.c  (revision 225248)
+++ gcc/gimplify.c  (working copy)
@@ -7348,7 +7348,11 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
   else if (omp_is_private (gimplify_omp_ctxp, decl, 0))
omp_notice_variable (gimplify_omp_ctxp, decl, true);
   else
-   omp_add_variable (gimplify_omp_ctxp, decl, GOVD_PRIVATE | GOVD_SEEN);
+   {
+ if (ork == ORK_OACC && gimplify_omp_ctxp->outer_context)
+   omp_notice_variable (gimplify_omp_ctxp->outer_context, decl, true);
+ omp_add_variable (gimplify_omp_ctxp, decl, GOVD_PRIVATE | GOVD_SEEN);
+   }
 
   /* If DECL is not a gimple register, create a temporary variable to act
 as an iteration counter.  This is valid, since DECL cannot be
Index: libgomp/testsuite/libgomp.oacc-c-c++-common/reduction-4.c
===
--- libgomp/testsuite/libgomp.oacc-c-c++-common/reduction-4.c   (revision 
225248)
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/reduction-4.c   (working copy)
@@ -59,14 +59,14 @@ main(void)
   lvresult = false;
 
   /* '&&' reductions.  */
-#pragma acc parallel num_gangs (ng) copy (result)
+#pragma acc parallel num_gangs (ng) copy (lresult)
 #pragma acc loop reduction (&&:lresult) gang
   for (i = 0; i < n; i++)
 lresult = lresult && (creal(result) > creal(array[i]));
 
   /* Verify the reduction.  */
   for (i = 0; i < n; i++)
-lvresult = lresult && (creal(result) > creal(array[i]));
+lvresult = lvresult && (creal(result) > creal(array[i]));
 
   if (lresult != lvresult)
 abort ();
@@ -78,14 +78,14 @@ main(void)
   lvresult = false;
 
   /* '||' reductions.  */
-#pragma acc parallel num_gangs (ng) copy (result)
+#pragma acc parallel num_gangs (ng) copy (lresult)
 #pragma acc loop reduction (||:lresult) gang
   for (i = 0; i < n; i++)
 lresult = lresult || (creal(result) > creal(array[i]));
 
   /* Verify the reduction.  */
   for (i = 0; i < n; i++)
-lvresult = lresult || (creal(result) > creal(array[i]));
+lvresult = lvresult || (creal(result) > creal(array[i]));
 
   if (lresult != lvresult)
 abort ();
Index: libgomp/testsuite/libgomp.oacc-c-c++-common/parallel-loop-2.h
===
--- libgomp/testsuite/libgomp.oacc-c-c++-common/parallel-loop-2.h   
(revision 225248)
+++ libgomp/testsuite/libgomp.oacc-c-c++-common/parallel-loop-2.h   
(working copy)
@@ -1,5 +1,3 @@
-/* FIXME: Remove the firstprivate clauses from the paralle regions.  */
-
 #ifndef VARS
 #define VARS
 int a[1500];
@@ -19,7 +17,7 @@ __attribute__((noinline, noclone)) void
 N(f0) (void)
 {
   int i;
-#pragma acc parallel loop L F firstprivate (i)
+#pragma acc parallel loop L F
   for (i = 0; i < 1500; i++)
 a[i] += 2;
 }
@@ -36,7 +34,7 @@ __attribute__((noinline, noclone)) void
 N(f2) (void)
 {
   unsigned long long i;
-#pragma acc parallel loop L F firstprivate (i)
+#pragma acc parallel loop L F
   for (i = __LONG_LONG_MAX__ + 4500ULL - 27;
i > __LONG_LONG_MAX__ - 27ULL; i -= 3)
 a[(i + 26LL - __LONG_LONG_MAX__) / 3] -= 4;
@@ -54,7 +52,7 @@ __attribute__((noinline, noclone)) void
 N(f4) (void)
 {
   unsigned int i;
-#pragma acc parallel loop L F firstprivate (i)
+#pragma acc parallel loop L F
   for (i = 30; i < 20; i += 2)
 a[i] += 10;
 }
@@ -64,7 +62,7 @@ N(f5) (int n11, int n12, int n21, int n22, int n31
int s1, int s2, int s3)
 {
   SC int v1, v2, v3;
-#pragma acc parallel loop L F firstprivate (v1, v2, v3)
+#pragma acc parallel loop L F
   for (v1 = n11; v1 < n12; v1 += s1)
 #pragma acc loop S
 for (v2 = n21; v2 < n22; v2 += s2)
@@ -78,7 +76,7 @@ N(f6) (int n11, int n12, int n21, int n22, long lo
 {
   SC int v1, v2;
   SC long long v3;
-#pragma acc parallel loop L F firstprivate (v1, v2, v3)
+#pragma acc parallel loop L F
   f

Eight more jit backports to gcc 5 branch

2015-07-01 Thread David Malcolm
I've gone over the changes to the gcc/jit and gcc/testsuite/jit.dg
directories in trunk since the last backports to gcc 5 [1] and
backported the following 8 changes from trunk to the gcc-5-branch:

gcc-5-branch's r225251:
  * trunk's r225203 (9bd7a189c372465fb757ecd67336379779f4ea60,
"jit: fix some .rst issues in docs")
https://gcc.gnu.org/ml/gcc-patches/2015-06/msg02248.html

gcc-5-branch's r225252:
  * trunk's r225204 (cc36aead6a4e5017477c9c0836672317128ed6b3,
"fixes to gcc_jit_context_dump_reproducer_to_file")
https://gcc.gnu.org/ml/gcc-patches/2015-06/msg02249.html

gcc-5-branch's r225253:
  * trunk's r225205 (adb2df5592cdf8e70aa44c0f3c447da1d0134f4c,
"PR jit/66628: add gcc_jit_context_add_command_line_option")
https://gcc.gnu.org/ml/gcc-patches/2015-06/msg02250.html

gcc-5-branch's r225254:
  * trunk's r225206 (04feb56e6acd497d0add042232afd7940ef61adb,
"PR jit/66546: Add gcc_jit_context_set_bool_allow_unreachable_blocks")
https://gcc.gnu.org/ml/gcc-patches/2015-06/msg02251.html

gcc-5-branch's r225255:
  * trunk's r225207 (a24ef8d231d1015c5a4ee68050ed78f5582342fe,
"jit: add switch statements")
https://gcc.gnu.org/ml/gcc-patches/2015-06/msg02256.html

gcc-5-branch's r225256:
  * trunk's r225245 (1fa42b0566972abc668f3aa88e5534092af99c2c,
"jit: clarify (lack of) lifetime requirements on input const char *")
https://gcc.gnu.org/ml/gcc-patches/2015-07/msg00043.html

gcc-5-branch's r225257:
  * trunk's r225246 (eb2d3e4a67c699257e42280e6bf800b8a92ffad7,
"jit: document union types")
https://gcc.gnu.org/ml/gcc-patches/2015-07/msg00045.html

gcc-5-branch's r225258:
  * trunk's r225248 (f410e1f5b44007c6cf6609df0afc16e7dcfeabd2,
"PR jit/66700: set TREE_ADDRESSABLE when building an ADDR_EXPR")
https://gcc.gnu.org/ml/gcc-patches/2015-07/msg00046.html

"make check-jit" on gcc-5-branch went from 8014 to 8289 passes.

In particular, note that this adds symbol versioning to libgccjit.so on
the branch to track (so far) the changes made on trunk, adding some API
entrypoints needed by users (for PR jit/66546 and PR jit/66700).

Dave

[1] ec2e0095a3a5988b03a2706b5ffe0e807b238ba8 (on 2015-06-25)




Re: Four jit backports to gcc 5 branch

2015-07-01 Thread David Malcolm
On Tue, 2015-06-30 at 09:01 -0400, David Malcolm wrote:
> On Tue, 2015-06-30 at 08:43 +0200, Basile Starynkevitch wrote:
> > On Mon, Jun 29, 2015 at 11:44:31AM -0400, David Malcolm wrote:
> > > I've gone over the changes to the gcc/jit and gcc/testsuite/jit.dg
> > > directories in trunk since gcc 5 and backported the following 4 changes
> > > from trunk to the gcc-5-branch:
> > > 
> > 
> > 
> > I'll be delighted if switch statements ability would be backported to
> > GCC 5.  (Its absence is IMHO a severe bug in GCCJIT, but perhaps GCC rules
> > forbid backporting new features, even when they correct a huge
> > deficiency and when the patch adding them is probably quite small).
> 
> I don't agree with your characterization of the severity of this, but I
> do think we ought to fix it if possible.
> 
> I don't know of any rules about what is and what isn't suitable for
> backporting.  The jit work as a whole is relatively new and has been
> messaged as "experimental".
> 
> I'm the jit maintainer, and I believe the patch is reasonable to
> backport: it doesn't break API or ABI (although it extends it), it has
> docs and test coverage, and doesn't touch anything outside of the jit
> (beyond adding the new header gcc/typed-splay-tree.h, which is only used
> by the jit).  
> 
> Hence I intend to backport it to gcc-5-branch, but I've got to get it
> into trunk first :)  (hopefully later today)

Switch statements for the jit are now in gcc-5-branch, as of r225255.



Re: PR 66685: parallel returns being misclassified

2015-07-01 Thread Richard Sandiford
Richard Biener  writes:
> On Wed, Jul 1, 2015 at 10:27 AM, Richard Sandiford
>  wrote:
>> This patch should restore bootstrap on hppa (and probably other targets
>> besides).  The change to use target-insns.def put more stress on the
>> emit()/classify_insn() group of functions, which were missing a case
>> for parallel returns.
>>
>> Tested with a cross-compiler that it fixes the hppa problem.  Bootstrap
>> in progress on x86_64-linux-gnu.  OK to install?
>
> Ok.

I think this has probably broken bootstrap on powerpc64, where sibcalls
have both calls and returns.  The loop picks the last candidate,
which is the return.

Is this patch OK?

Thanks,
Richard

gcc/
PR bootstrap/66685
* rtl.c (classify_insn): Only return JUMP_INSN for parallel returns if
there are no CALLs in the same pattern.

Index: gcc/rtl.c
===
--- gcc/rtl.c   2015-07-01 16:19:55.055415254 +0100
+++ gcc/rtl.c   2015-07-01 16:19:55.383411635 +0100
@@ -683,17 +683,20 @@ classify_insn (rtx x)
   if (GET_CODE (x) == PARALLEL)
 {
   int j;
+  bool has_return_p = false;
   for (j = XVECLEN (x, 0) - 1; j >= 0; j--)
if (GET_CODE (XVECEXP (x, 0, j)) == CALL)
  return CALL_INSN;
else if (ANY_RETURN_P (XVECEXP (x, 0, j)))
- return JUMP_INSN;
+ has_return_p = true;
else if (GET_CODE (XVECEXP (x, 0, j)) == SET
 && GET_CODE (SET_DEST (XVECEXP (x, 0, j))) == PC)
  return JUMP_INSN;
else if (GET_CODE (XVECEXP (x, 0, j)) == SET
 && GET_CODE (SET_SRC (XVECEXP (x, 0, j))) == CALL)
  return CALL_INSN;
+  if (has_return_p)
+   return JUMP_INSN;
 }
 #ifdef GENERATOR_FILE
   if (GET_CODE (x) == MATCH_OPERAND



Re: [PATCH] config/bfin/bfin.c (hwloop_optimize): Use return false instead of gcc_assert for checking jump_insn.

2015-07-01 Thread Chen Gang
On 7/1/15 21:52, Bernd Schmidt wrote:
> On 07/01/2015 03:04 AM, Chen Gang wrote:
> 
>> For me, the more details are:
>>
>>   - The insns have 2 loops which can be lsetup optimized.
>>
>>   - After hwloop_optimize finishes 1st lsetup optimization, it generates
>> new lsetup insn which appends to jump insn in the basic block (which
>> causes the insns are not 'standard' but OK for code generation).
> 
> The problem is that you can't append anything to a basic block after a jump. 
> You need to create a new one. This problem doesn't usually show up since 
> nothing ever looks at the basic block again, unless both directions from the 
> conditional branch happen to branch to lsetup candidate loops.
>

OK, thanks. What you said sound reasonable to me.
 
> Below is a patch. Can you test this with anything you have beyond the 
> testsuite?
> 

It can fix this issue (Bug66620), let the insns standard, and can build
the bfin kernel with allmodconfig successfully (although for bfin kernel
members, they stick to allmodconfig is not a good idea for bfin kernel).

It finished lsetup optimization for one loop, but still left the other (
get the same .s as my original fix). for 2nd times in hwloop_optimize, it
return false. And welcome any additional ideas for it.

For me, my original fix is incorrect: it still remains the insns in the
incorrect state (although my fix can generate the correct .s, and can
build bfin kernel with allmodconfig successfully).


Thanks.
-- 
Chen Gang

Open, share, and attitude like air, water, and life which God blessed


[gomp4, committed, PR66716] Fix compilation libgomp.oacc-c-c++-common/kernels-loop.c -g

2015-07-01 Thread Tom de Vries

Hi,

when compiling libgomp.oacc-c-c++-common/kernels-loop at -O2 -g, we run 
into:

...
FAIL: libgomp.oacc-c/../libgomp.oacc-c-c++-common/kernels-loop.c 
-DACC_DEVICE_TYPE_host=1 -DACC_MEM_SHARED=1 (internal compiler error)

...

The ICE in more detail:
...
src/libgomp/testsuite/libgomp.oacc-c/../libgomp.oacc-c-c++-common/kernels-loop.c: 
In function ‘main’:
src/libgomp/testsuite/libgomp.oacc-c/../libgomp.oacc-c-c++-common/kernels-loop.c:41:1: 
error: definition in block 10 does not dominate use in block 19

for SSA_NAME: ii_69 in statement:
# DEBUG ii => ii_69
src/libgomp/testsuite/libgomp.oacc-c/../libgomp.oacc-c-c++-common/kernels-loop.c:41:1: 
internal compiler error: verify_ssa failed

0x1123966 verify_ssa(bool, bool)
src/gcc/tree-ssa.c:1068
0xd1a9d8 execute_function_todo
src/gcc/passes.c:1953
0xd19abf do_per_function
src/gcc/passes.c:1638
0xd1ab76 execute_todo
src/gcc/passes.c:2003
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See  for instructions
...


Before transform_to_exit_first_loop_alt we have this loop:
...
  
  goto ;

  :
  # ivtmp_19 = PHI 
  ii_36 = ivtmp_19;
  # DEBUG ii => ii_36
  _52 = (long unsigned int) ii_36;
  _53 = _52 * 4;
  _54 = c.6_51 + _53;
  _59 = a.7_56 + _53;
  _60 = *_59;
  _65 = b.8_62 + _53;
  _66 = *_65;
  _67 = _60 + _66;
  *_54 = _67;
  ii_69 = ii_36 + 1;
  # DEBUG ii => ii_69
  # DEBUG ii => ii_69
  if (ivtmp_19 < 524287)
goto ;
  else
goto ;

  :
  ivtmp_7 = ivtmp_19 + 1;
  goto ;
...

And after transform_to_exit_first_loop_alt we have this loop:
...
  
  goto ;

  :
  # ivtmp_19 = PHI 
  ii_36 = ivtmp_19;
  # DEBUG ii => ii_36
  _52 = (long unsigned int) ii_36;
  _53 = _52 * 4;
  _54 = c.6_51 + _53;
  _59 = a.7_56 + _53;
  _60 = *_59;
  _65 = b.8_62 + _53;
  _66 = *_65;
  _67 = _60 + _66;
  *_54 = _67;
  ii_69 = ii_36 + 1;
  goto ;

  :
  # ivtmp_35 = PHI 
  # DEBUG ii => ii_69
  # DEBUG ii => ii_69
  if (ivtmp_35 < 524288)
goto ;
  else
goto ;

  :
  ivtmp_7 = ivtmp_19 + 1;
  goto ;
...

So, the use of ii_69 in debug insn 'DEBUG ii => ii_69' in bb 19 is no 
longer dominated by the def of ii_68 in bb 10.



The patch fixes this by ensuring that 
gimple_split_block_before_cond_jump really splits before cond_jump, 
instead of after the last nondebug insn before cond_jump, as it does 
now. This behaviour also better matches the rtl implementation of the 
cfghook. Btw, note that the only user of cfghook 
split_block_before_cond_jump is transform_to_exit_first_loop_alt.


Committed to gomp-4_0-branch.

Thanks,
- Tom
Fix compilation libgomp.oacc-c-c++-common/kernels-loop.c -g

2015-07-01  Tom de Vries  

	PR tree-optimization/66716
	* tree-cfg.c (gimple_split_block_before_cond_jump): Split before
	cond_jump, instead of split after last nondebug insn before cond_jump.

	* c-c++-common/goacc/kernels-loop-g.c: New test.

	* testsuite/libgomp.oacc-c-c++-common/kernels-loop-g.c: New test.
---
 gcc/testsuite/c-c++-common/goacc/kernels-loop-g.c | 19 +++
 gcc/tree-cfg.c|  2 +-
 .../libgomp.oacc-c-c++-common/kernels-loop-g.c|  5 +
 3 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/c-c++-common/goacc/kernels-loop-g.c
 create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/kernels-loop-g.c

diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-loop-g.c b/gcc/testsuite/c-c++-common/goacc/kernels-loop-g.c
new file mode 100644
index 000..331503a
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-loop-g.c
@@ -0,0 +1,19 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-g" } */
+/* { dg-additional-options "-ftree-parallelize-loops=32" } */
+/* { dg-additional-options "-fdump-tree-parloops_oacc_kernels-all" } */
+/* { dg-additional-options "-fdump-tree-optimized" } */
+
+#include "kernels-loop.c"
+
+/* Check that only one loop is analyzed, and that it can be parallelized.  */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops_oacc_kernels" } } */
+/* { dg-final { scan-tree-dump-not "FAILED:" "parloops_oacc_kernels" } } */
+
+/* Check that the loop has been split off into a function.  */
+/* { dg-final { scan-tree-dump-times "(?n);; Function .*main._omp_fn.0" 1 "optimized" } } */
+
+/* { dg-final { scan-tree-dump-times "(?n)pragma omp target oacc_parallel.*num_gangs\\(32\\)" 1 "parloops_oacc_kernels" } } */
+
+/* { dg-final { cleanup-tree-dump "parloops_oacc_kernels" } } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 99b27c7..a8aec26 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -5837,7 +5837,7 @@ gimple_split_block_before_cond_jump (basic_block bb)
   if (gimple_code (last) != GIMPLE_COND
   && gimple_code (last) != GIMPLE_SWITCH)
 return NULL;
-  gsi_prev_nondebug (&gsi);

Re: PR 66685: parallel returns being misclassified

2015-07-01 Thread Jeff Law

On 07/01/2015 09:25 AM, Richard Sandiford wrote:

Richard Biener  writes:

On Wed, Jul 1, 2015 at 10:27 AM, Richard Sandiford
 wrote:

This patch should restore bootstrap on hppa (and probably other targets
besides).  The change to use target-insns.def put more stress on the
emit()/classify_insn() group of functions, which were missing a case
for parallel returns.

Tested with a cross-compiler that it fixes the hppa problem.  Bootstrap
in progress on x86_64-linux-gnu.  OK to install?


Ok.


I think this has probably broken bootstrap on powerpc64, where sibcalls
have both calls and returns.  The loop picks the last candidate,
which is the return.

Is this patch OK?

Thanks,
Richard

gcc/
PR bootstrap/66685
* rtl.c (classify_insn): Only return JUMP_INSN for parallel returns if
there are no CALLs in the same pattern.

OK.
jeff



Re: [patch] fix regrename pass to ensure renamings produce valid insns

2015-07-01 Thread Jeff Law

On 06/28/2015 03:08 PM, Sandra Loosemore wrote:


Re the testcase, this fixed 16 FAILs on existing tests in the gcc
testsuite with the forthcoming nios2 load/store multiple instruction
support, all assembler errors due to the bad instructions being
generated.  There's nothing I can do on nios2 for a testcase until I get
those patches committed (I'm still trying to re-test and tidy them up
for submission), plus I think the failures are rather fragile --
depending on the register allocator choosing an initial register
numbering that allows peephole optimizers to trigger, etc.  But, I will
revisit this later and see what I can do.

OK.  As long as there's going to be some tests, that works for me.

jeff


[patch, wwwdocs, committed] Document -Winteger-division for Fortran

2015-07-01 Thread Thomas Koenig
Hello world,

I just committed the following patch to the WWW docs.

An error was reported by Gerald's script, but that seems to
have been spurious.  At least, there was no error on
revalidation.

Regards

Thomas

2015-07-01  Thomas Koenig  

* gcc-6/changes.html:  Document -Winteger-division for
Fortran.
Index: changes.html
===
RCS file: /cvs/gcc/wwwdocs/htdocs/gcc-6/changes.html,v
retrieving revision 1.12
diff -r1.12 changes.html
67a68,70
> The -Winteger-division option has been added, which
>   warns about divisions of integer constants which are truncated.
>   This option is included in -Wall by default.


Re: RFA: Use target-insns.def for casesi and tablejump

2015-07-01 Thread Jeff Law

On 06/30/2015 02:58 PM, Richard Sandiford wrote:

This patch uses target-insns.def to define casesi and tablejump.
It's the first point in the series at which we need access to the
instruction code, so the patch adds that to targetm as well.

Bootstrapped & regression-tested on x86_64-linux-gnu and aarch64-linux-gnu.
Also tested via config-list.mk.  OK to install?

Thanks,
Richard


gcc/
* target.def: Add code_for_* hooks.
* gentarget-def.c (def_target_insn): Add TARGET_CODE_FOR_* macros.
* defaults.h (HAVE_tablejump, gen_tablejump): Delete.
* target-insns.def (casesi, tablejump): New targetm instruction
patterns.
* expr.c (try_casesi): Use them instead of HAVE_*/gen_* interface.
(do_tablejump): Likewise.
* stmt.c (expand_switch_as_decision_tree_p): Likewise.
(expand_sjlj_dispatch_table): Likewise.
* targhooks.c (default_case_values_threshold): Likewise.

OK.
jeff



Re: [PATCH/RFC] Make loop-header-copying more aggressive, rerun before tree-if-conversion

2015-07-01 Thread Jeff Law

On 06/30/2015 10:04 AM, Alan Lawrence wrote:

Jeff Law wrote:

Thanks.  Does running the phi-only propagator after the loop header
copying help?  At first glance it would seem that it ought to
propagate the values of those degenerate PHIs then eliminate those PHIs.

It was written to cleanup after jump threading which has a tendency to
create very similar code to what you've shown below and to do so very
quickly.


Thanks for the tip - this fixes up some examples, but not at all. Other
examples require also a call to rewrite_into_loop_closed_ssa and
recomputing dominators...maybe I can get everything to work with all of
those, but my feeling is to keep it as a pass: if the first pass_ch
justifies being a pass in its own right, then surely a *more aggressive*
version of that, does too...

Works for me.  Thanks for investigating.

jeff



C++ PATCH for c++/65945 (nullptr_t alignment)

2015-07-01 Thread Jason Merrill
It's trivial to fix the alignment of nullptr_t, but I was concerned 
about ABI impact.  On further research it seems that it won't cause any 
trouble with argument alignment, since that doesn't seem to rely on 
TYPE_ALIGN at all; I think the only ABI breakage would come from 
unaligned nullptr_t fields in classes, which I expect to be very rare. 
The testcases that were breaking on SPARC and ARM without this fix have 
to do with local stack slots, which are not part of an interface.


Activating the warning requires passing an explicit version number to 
-Wabi, e.g. -Wabi=8.


Tested x86_64-pc-linux-gnu, applying to trunk and 5.
commit 6ec8347672eec505f13f03f3612a847327a96815
Author: Jason Merrill 
Date:   Fri Jun 19 15:29:33 2015 -0400

	PR c++/65945
gcc/c-family/
	* c-opts.c (c_common_post_options): Highest ABI version is 9.
gcc/cp/
	* decl.c (cxx_init_decl_processing): Set TYPE_ALIGN of nullptr_t.
	* class.c (layout_nonempty_base_or_field): Warn if that affects
	the offset of a field.

diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index 1a67b5a..718a052 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -889,7 +889,7 @@ c_common_post_options (const char **pfilename)
   /* Change flag_abi_version to be the actual current ABI level for the
  benefit of c_cpp_builtins.  */
   if (flag_abi_version == 0)
-flag_abi_version = 8;
+flag_abi_version = 9;
 
   if (cxx_dialect >= cxx11)
 {
diff --git a/gcc/common.opt b/gcc/common.opt
index e5553cd..1218a71 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -833,6 +833,9 @@ Driver Undocumented
 ; 8: The version of the ABI that corrects the substitution behavior of
 ;function types with function-cv-qualifiers.
 ;First selectable in G++ 4.9 and default in G++ 5
+;
+; 9: The version of the ABI that corrects the alignment of nullptr_t.
+;First selectable and default in G++ 5.2.
 ;(set in c_common_post_options).
 ;
 ; Additional positive integers will be assigned as new versions of
diff --git a/gcc/cp/class.c b/gcc/cp/class.c
index 12e62df..d59d351 100644
--- a/gcc/cp/class.c
+++ b/gcc/cp/class.c
@@ -4286,6 +4286,25 @@ layout_nonempty_base_or_field (record_layout_info rli,
    : TYPE_ALIGN (type)));
 	  normalize_rli (rli);
 	}
+  else if (TREE_CODE (type) == NULLPTR_TYPE
+	   && warn_abi && abi_version_crosses (9))
+	{
+	  /* Before ABI v9, we were giving nullptr_t alignment of 1; if
+	 the offset wasn't aligned like a pointer when we started to
+	 layout this field, that affects its position.  */
+	  tree pos = rli_size_unit_so_far (&old_rli);
+	  if (int_cst_value (pos) % TYPE_ALIGN_UNIT (ptr_type_node) != 0)
+	{
+	  if (abi_version_at_least (9))
+		warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wabi,
+			"alignment of %qD increased in -fabi-version=9 "
+			"(GCC 5.2)", decl);
+	  else
+		warning_at (DECL_SOURCE_LOCATION (decl), OPT_Wabi, "alignment "
+			"of %qD will increase in -fabi-version=9", decl);
+	}
+	  break;
+	}
   else
 	/* There was no conflict.  We're done laying out this field.  */
 	break;
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 0adb3ce..d24b02a 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -4013,6 +4013,8 @@ cxx_init_decl_processing (void)
 TYPE_SIZE_UNIT (nullptr_type_node) = size_int (GET_MODE_SIZE (ptr_mode));
 TYPE_UNSIGNED (nullptr_type_node) = 1;
 TYPE_PRECISION (nullptr_type_node) = GET_MODE_BITSIZE (ptr_mode);
+if (abi_version_at_least (9))
+  TYPE_ALIGN (nullptr_type_node) = GET_MODE_ALIGNMENT (ptr_mode);
 SET_TYPE_MODE (nullptr_type_node, ptr_mode);
 record_builtin_type (RID_MAX, "decltype(nullptr)", nullptr_type_node);
 nullptr_node = build_int_cst (nullptr_type_node, 0);
diff --git a/gcc/testsuite/g++.dg/abi/macro0.C b/gcc/testsuite/g++.dg/abi/macro0.C
index fbcbb2c..35b8769 100644
--- a/gcc/testsuite/g++.dg/abi/macro0.C
+++ b/gcc/testsuite/g++.dg/abi/macro0.C
@@ -1,6 +1,6 @@
 // This testcase will need to be kept in sync with c_common_post_options.
 // { dg-options "-fabi-version=0" }
 
-#if __GXX_ABI_VERSION != 1008
+#if __GXX_ABI_VERSION != 1009
 #error "Incorrect value of __GXX_ABI_VERSION"
 #endif
diff --git a/gcc/testsuite/g++.dg/abi/nullptr-align.C b/gcc/testsuite/g++.dg/abi/nullptr-align.C
new file mode 100644
index 000..7de365a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/nullptr-align.C
@@ -0,0 +1,5 @@
+// PR c++/65945
+// { dg-do compile { target c++11 } }
+// { dg-options "-fabi-version=9" }
+
+static_assert(alignof (decltype (nullptr)) == alignof (void *), "");
diff --git a/gcc/testsuite/g++.dg/abi/nullptr-align2.C b/gcc/testsuite/g++.dg/abi/nullptr-align2.C
new file mode 100644
index 000..66a9011
--- /dev/null
+++ b/gcc/testsuite/g++.dg/abi/nullptr-align2.C
@@ -0,0 +1,20 @@
+// { dg-do compile { target c++11 } }
+// { dg-options "-fabi-version=0 -Wabi=8" }
+
+struct A
+{
+  decltype(nullptr) n;
+  decltype(nullptr) n2;
+};
+
+struct 

Re: [PATCH, PR66432] Handle PARM_DECL in remap_gimple_op_r

2015-07-01 Thread Tom de Vries

On 01/07/15 13:58, Richard Biener wrote:

On Wed, Jul 1, 2015 at 1:43 PM, Tom de Vries  wrote:

Hi,

I.

When running test libgomp.c/appendix-a/a.29.1.c with '--target_board
unix/-O2/-g', we run into this failure:
...
FAIL: libgomp.c/appendix-a/a.29.1.c (test for excess errors)
Excess errors:
src/libgomp/testsuite/libgomp.c/appendix-a/a.29.1.c:6:1: error: type
mismatch between an SSA_NAME and its symbol
...

Without -g, the testcase passes.


II.

The scenario for the failure is as follows:

At fnsplit, we split off f.part.0 from f, which at source level looks like
this:
...
void
f (int n, int B[n][n], int C[])
{
   int D[2][2] = { 1, 2, 3, 4 };
   int E[n][n];
   assert (n >= 2);
   E[1][1] = 4;
#pragma omp parallel firstprivate(B, C, D, E)
   {
 assert (sizeof (B) == sizeof (int (*)[n]));
 assert (sizeof (C) == sizeof (int *));
 assert (sizeof (D) == 4 * sizeof (int));
 assert (sizeof (E) == n * n * sizeof (int));
 /* Private B and C have values of original B and C. */
 assert (&B[1][1] == &A[1][1]);
 assert (&C[3] == &A[1][1]);
 assert (D[1][1] == 4);
 assert (E[1][1] == 4);
   }
}
...

The split introduces a debug_insn and ssa-name that references param B in f:
...
   # DEBUG D#4ptD.0 => B_3(D)
..

And a debug_insn that references param B in f.part.0:
...
   # DEBUG D#7ptD.0 s=> BD.1846
...

At this point, the type of the ssa name and the param are the same.


With the same PARM_DECL?  I think that's the bug.



Attached patch also fixes the ICE, by copying the PARM_DECL using in the 
debug insn. Does this look ok for testing?


Thanks,
- Tom
Copy PARM_DECL for use in split off function.

2015-06-30  Tom de Vries  

	PR middle-end/66432
	* ipa-split.c (split_function): Copy PARM_DECL for use in split off
	function.

	* testsuite/libgomp.c/pr66432.c: New test.
---
 gcc/ipa-split.c   | 2 +-
 libgomp/testsuite/libgomp.c/pr66432.c | 4 
 2 files changed, 5 insertions(+), 1 deletion(-)
 create mode 100644 libgomp/testsuite/libgomp.c/pr66432.c

diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index 13d9a64..e923cee 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -1458,7 +1458,7 @@ split_function (basic_block return_bb, struct split_point *split_point,
 	  DECL_ARTIFICIAL (ddecl) = 1;
 	  TREE_TYPE (ddecl) = TREE_TYPE (parm);
 	  DECL_MODE (ddecl) = DECL_MODE (parm);
-	  vec_safe_push (*debug_args, DECL_ORIGIN (parm));
+	  vec_safe_push (*debug_args, copy_node (DECL_ORIGIN (parm)));
 	  vec_safe_push (*debug_args, ddecl);
 	  def_temp = gimple_build_debug_bind (ddecl, unshare_expr (arg),
 	  call);
diff --git a/libgomp/testsuite/libgomp.c/pr66432.c b/libgomp/testsuite/libgomp.c/pr66432.c
new file mode 100644
index 000..2259a69
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/pr66432.c
@@ -0,0 +1,4 @@
+/* { dg-do run } */
+/* { dg-additional-options "-g" } */
+
+#include "appendix-a/a.29.1.c"
-- 
1.9.1



Re: [RFA] Factor conversion out of COND_EXPR using match.pd pattern

2015-07-01 Thread Jeff Law

On 06/30/2015 01:45 AM, Richard Biener wrote:

On Mon, Jun 29, 2015 at 7:51 PM, Jeff Law  wrote:


So do we want to restrict the new pattern on GENERIC, then rely on
phiopt to get smarter and catch this stuff for GIMPLE?  Or drop the
pattern totally and do everything in phiopt on GIMPLE?


Note that IMHO it doesn't make a lot of sense to add match.pd
patterns restricted to GENERIC - those should simply go to / stay in
fold-const.c.  For patterns restricted to GIMPLE match.pd is still
the proper place.


[ snip ]


So it's indeed not clear if re-writing phiopt to match.pd patterns is
possible or desirable.
Probably the thing to do is drop this match.pd change from consideration 
and instead look into improving phi-opt.


I'll open a BZ to capture the missed optimization and include a link 
back to this discussion.




And using operand_equal_p seems more appropriate to me (and is
still better than the original (cond @0 ...) and grubbing around
inside @0 to look at operands.


We do use operand_equal_p to query whether @0 and @0 are equal.
Ah.  I had no idea.  I assumed that for multiple @N references we'd just 
use pointer equality.  My bad.


Jeff


Re: [PATCH 1/2] Add gcc/typed-splay-tree.h

2015-07-01 Thread Jeff Law

On 06/29/2015 11:36 AM, David Malcolm wrote:

On Thu, 2015-06-25 at 13:18 -0600, Jeff Law wrote:

On 06/25/2015 01:13 PM, David Malcolm wrote:

I found when implementing switch statements for the jit that it
was much easier to work with libiberty's splay-tree.h by first
wrapping it in a C++ wrapper to add typesafety.

This patch adds such a wrapper, implementing the methods I needed.

It's unused in this patch, but is used in the followup patch (which only
touches the jit).

OK for trunk?

gcc/ChangeLog:
* typed-splay-tree.h: New file.

OK.


Well, this is embarrassing, it seems the patch I posted to the list
doesn't actually compile.
It happens.  It's one of the reasons why we have the rules around 
bootstrap testing :-)  I can't count how many of these kinds of goofs 
I've made through the years.





The underlying splay_tree_insert returns a splay_tree_node, I had the
typed_splay_tree::insert returning a value_type.  I dropped this bogus
return type from the "insert" method in the implementation, in favor of
"void", but I forgot to update the declaration, leading to errors when
attempting to actually compile this (via jit/jit-recording.c in the
followup patch).

The attached one-liner patch drops it from the declaration, and applies
to [PATCH 1/2].  I don't know if I can count this as "obvious"...  It
does compile now, and "make check-jit" looks good.

I'd think this qualifies :-)

jeff


[testsuite, committed, PR66723] Use scan-rtl-dump in i386/vararg-loc.c

2015-07-01 Thread Tom de Vries

Hi,

I've committed this patch, which rewrites the scan lines in test-case 
i386/vararg-loc.c from scan-assembler to scan-rtl-dump, to fix PR66723.


Thanks,
- Tom
Use scan-rtl-dump in i386/vararg-loc.c

2015-07-01  Tom de Vries  

	PR testsuite/66723
	* gcc.target/i386/vararg-loc.c: Use scan-rtl-dump instead of
	scan-assembler.
---
 gcc/testsuite/gcc.target/i386/vararg-loc.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/gcc.target/i386/vararg-loc.c b/gcc/testsuite/gcc.target/i386/vararg-loc.c
index f236fe3..8134ba8 100644
--- a/gcc/testsuite/gcc.target/i386/vararg-loc.c
+++ b/gcc/testsuite/gcc.target/i386/vararg-loc.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-g -O0" } */
+/* { dg-options "-g -O0 -fdump-rtl-final" } */
 
 #include 
 
@@ -22,6 +22,6 @@ f (int a, ...)			/* 8.  */
   return sum;
 }
 
-/* { dg-final { scan-assembler-not "\\.loc 1 \[6789\] 0" } } */
-/* { dg-final { scan-assembler-times "\\.loc 1 18 0" 1 } } */
-/* { dg-final { scan-assembler-times "\\.loc 1 20 0" 1 } } */
+/* { dg-final { scan-rtl-dump-not "vararg-loc\\.c:\[6789\] " "final" } } */
+/* { dg-final { scan-rtl-dump "vararg-loc\\.c:18 " "final" } } */
+/* { dg-final { scan-rtl-dump "vararg-loc\\.c:20 " "final" } } */
-- 
1.9.1



[PATCH] PR fortran/56520 -- Special case unary minus/plus

2015-07-01 Thread Steve Kargl
The attached patch special cases unary minus/plus when
gfotran tries to match a function keyword in a mangled
statement.  The testcase contains examples, but for
context consider 'c = exp(-a) )' where the final ')'
is erronous.  gfortran is trying to match a keyword
such as 'c = exp(x=-a)' so it expects the character
after the '(' to be in [a-z] or '_'.  Prior to this
patch, gfortran would do

% gfc -c sd.f90
sd.f90:8:13:

 c = exp(-a) )! dg-error { "Unclassifiable statement" }
 1
Error: Invalid character in name at (1)

with the patch gfortran will instead issue

% gfc -c sd.f90
sd.f90:8:4:

 c = exp(-a) )! dg-error { "Unclassifiable statement" }
1
Error: Unclassifiable statement at (1)

It can be debated that the new error message isn't much better
than old.  I don't care to enter into such a debate, so will 
ignore comments complaining the new meesage isn't much of an
improvement over the old.

Regression tested on trunk.  Ok to commit?

2015-07-01  Steven G. Kargl  

PR fortran/56520
* match.c (gfc_match_name): Special case unary minus and plus.

2015-07-01  Steven G. Kargl  

PR fortran/56520
* gfortran.dg/pr56520.f90: New test.

-- 
Steve
Index: gcc/fortran/match.c
===
--- gcc/fortran/match.c	(revision 224920)
+++ gcc/fortran/match.c	(working copy)
@@ -537,7 +537,10 @@ gfc_match_name (char *buffer)
   c = gfc_next_ascii_char ();
   if (!(ISALPHA (c) || (c == '_' && flag_allow_leading_underscore)))
 {
-  if (!gfc_error_flag_test () && c != '(')
+  /* Special cases for unary minus and plus, which allows for a sensible
+	 error message for code of the form 'c = exp(-a*b) )' where an
+	 extra ')' appears at the end of statement.  */
+  if (!gfc_error_flag_test () && c != '(' && c != '-' && c != '+')
 	gfc_error ("Invalid character in name at %C");
   gfc_current_locus = old_loc;
   return MATCH_NO;
Index: gcc/testsuite/gfortran.dg/pr56520.f90
===
--- gcc/testsuite/gfortran.dg/pr56520.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/pr56520.f90	(working copy)
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! PR fortran/56520
+!
+program misleading
+implicit none
+real a, c
+a = 1.0
+c = exp(+a) )! { dg-error "Unclassifiable statement" }
+c = exp(-a) )! { dg-error "Unclassifiable statement" }
+c = exp((a)) )   ! { dg-error "Unclassifiable statement" }
+c = exp(a) ) ! { dg-error "Unclassifiable statement" }
+c = exp(a)
+end program misleading


[PATCH] Adjust argument ordering in pa/linux-atomic.c

2015-07-01 Thread John David Anglin
The attached change revises the argument order of the __kernel_cmpxchg and 
__kernel_cmpxchg2
calls so that they now match the argument order of the light-weight syscalls.  
All callers were updated.

The clobbers and written arguments of the asms in these two functions were 
reviewed and updated
to match the kernel implementation.

Tested on hppa-unknown-linux-gnu with no observed regressions.  Committed to 
trunk, gcc-5 and gcc-4.9.

Dave
--
John David Anglin   dave.ang...@bell.net


2015-07-01  John David Anglin  

* config/pa/linux-atomic.c (__kernel_cmpxchg): Reorder arguments to
better match light-weight syscall argument order.
(__kernel_cmpxchg2): Likewise.
Adjust callers.

Index: config/pa/linux-atomic.c
===
--- config/pa/linux-atomic.c(revision 224978)
+++ config/pa/linux-atomic.c(working copy)
@@ -46,18 +46,17 @@
 
 /* Kernel helper for compare-and-exchange a 32-bit value.  */
 static inline long
-__kernel_cmpxchg (int oldval, int newval, int *mem)
+__kernel_cmpxchg (int *mem, int oldval, int newval)
 {
   register unsigned long lws_mem asm("r26") = (unsigned long) (mem);
+  register int lws_old asm("r25") = oldval;
+  register int lws_new asm("r24") = newval;
   register long lws_ret   asm("r28");
   register long lws_errno asm("r21");
-  register int lws_old asm("r25") = oldval;
-  register int lws_new asm("r24") = newval;
   asm volatile (   "ble0xb0(%%sr2, %%r0)   \n\t"
-   "ldi%5, %%r20   \n\t"
-   : "=r" (lws_ret), "=r" (lws_errno), "=r" (lws_mem),
- "=r" (lws_old), "=r" (lws_new)
-   : "i" (LWS_CAS), "2" (lws_mem), "3" (lws_old), "4" (lws_new)
+   "ldi%2, %%r20   \n\t"
+   : "=r" (lws_ret), "=r" (lws_errno)
+   : "i" (LWS_CAS), "r" (lws_mem), "r" (lws_old), "r" (lws_new)
: "r1", "r20", "r22", "r23", "r29", "r31", "memory"
   );
   if (__builtin_expect (lws_errno == -EFAULT || lws_errno == -ENOSYS, 0))
@@ -73,19 +72,20 @@
 }
 
 static inline long
-__kernel_cmpxchg2 (const void *oldval, const void *newval, void *mem,
+__kernel_cmpxchg2 (void *mem, const void *oldval, const void *newval,
   int val_size)
 {
   register unsigned long lws_mem asm("r26") = (unsigned long) (mem);
-  register long lws_ret   asm("r28");
-  register long lws_errno asm("r21");
   register unsigned long lws_old asm("r25") = (unsigned long) oldval;
   register unsigned long lws_new asm("r24") = (unsigned long) newval;
   register int lws_size asm("r23") = val_size;
+  register long lws_ret   asm("r28");
+  register long lws_errno asm("r21");
   asm volatile (   "ble0xb0(%%sr2, %%r0)   \n\t"
-   "ldi%2, %%r20   \n\t"
-   : "=r" (lws_ret), "=r" (lws_errno)
-   : "i" (2), "r" (lws_mem), "r" (lws_old), "r" (lws_new), "r" (lws_size)
+   "ldi%6, %%r20   \n\t"
+   : "=r" (lws_ret), "=r" (lws_errno), "+r" (lws_mem),
+ "+r" (lws_old), "+r" (lws_new), "+r" (lws_size)
+   : "i" (2)
: "r1", "r20", "r22", "r29", "r31", "fr4", "memory"
   );
   if (__builtin_expect (lws_errno == -EFAULT || lws_errno == -ENOSYS, 0))
@@ -116,7 +116,7 @@
 do {   \
   tmp = __atomic_load_n (ptr, __ATOMIC_SEQ_CST);   \
   newval = PFX_OP (tmp INF_OP val);
\
-  failure = __kernel_cmpxchg2 (&tmp, &newval, ptr, INDEX); \
+  failure = __kernel_cmpxchg2 (ptr, &tmp, &newval, INDEX); \
 } while (failure != 0);\
\
 return tmp;
\
@@ -146,7 +146,7 @@
 do {   \
   tmp = __atomic_load_n (ptr, __ATOMIC_SEQ_CST);   \
   newval = PFX_OP (tmp INF_OP val);
\
-  failure = __kernel_cmpxchg2 (&tmp, &newval, ptr, INDEX); \
+  failure = __kernel_cmpxchg2 (ptr, &tmp, &newval, INDEX); \
 } while (failure != 0);\
\
 return PFX_OP (tmp INF_OP val);\
@@ -174,7 +174,7 @@
\
 do {   \
   tmp = __atomic_load_n (ptr, __ATOMIC_SEQ_CST);   \
-  failure = __kernel_cmpxchg (tmp, PFX_OP (tmp INF_OP val), ptr);  \
+  failure = __kernel_cmpxchg (ptr, tmp, PFX_OP (tmp INF_OP val));  \
 } while (failure != 0);

C++ PATCH to change default dialect to C++14

2015-07-01 Thread Jason Merrill
I've been threatening to do this for a couple of months, and now that 
the regressions are under control I think it's time.  This patch changes 
the default C++ dialect to C++14.


Tested x86_64-pc-linux-gnu, applying to trunk.
commit 6f2b3941ffb3734cecc05507dd8ed46f6a6d4f2d
Author: Jason Merrill 
Date:   Fri May 8 17:02:05 2015 -0500

gcc/c-family/
	* c-opts.c (c_common_post_options): Default to C++14.
gcc/testsuite/
	* lib/target-supports.exp (cxx_default): Set to C++14.

diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c
index 195045e..80481c3 100644
--- a/gcc/c-family/c-opts.c
+++ b/gcc/c-family/c-opts.c
@@ -889,9 +889,9 @@ c_common_post_options (const char **pfilename)
   if (flag_abi_version == 0)
 flag_abi_version = 10;
 
-  /* Set C++ standard to C++98 if not specified on the command line.  */
+  /* Set C++ standard to C++14 if not specified on the command line.  */
   if (c_dialect_cxx () && cxx_dialect == cxx_unset)
-set_std_cxx98 (/*ISO*/false);
+set_std_cxx14 (/*ISO*/false);
 
   if (cxx_dialect >= cxx11)
 {
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index fc05e84..bf512e9 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -5935,7 +5935,7 @@ proc check_effective_target_c++ { } {
  return 0
 }
 
-set cxx_default "c++98"
+set cxx_default "c++14"
 # Check whether the current active language standard supports the features
 # of C++11/C++14 by checking for the presence of one of the -std flags.
 # This assumes that the default for the compiler is $cxx_default, and that


Re: C++ PATCH to change default dialect to C++14

2015-07-01 Thread Marek Polacek
On Wed, Jul 01, 2015 at 02:26:59PM -0400, Jason Merrill wrote:
> I've been threatening to do this for a couple of months, and now that the
> regressions are under control I think it's time.  This patch changes the
> default C++ dialect to C++14.

Great!

It seems that our cppopts.texi is very outdated wrt C++ standards...

Marek


Regressions with "[committed] Use target-insns.def for prologue & epilogue insns"

2015-07-01 Thread Hans-Peter Nilsson
> From: Richard Sandiford 
> Date: Tue, 30 Jun 2015 22:55:24 +0200

> Bootstrapped & regression-tested on x86_64-linux-gnu and aarch64-linux-gnu.
> Also tested via config-list.mk.  Committed as preapproved.
> 
> Thanks,
> Richard
> 
> 
> gcc/
> * defaults.h (HAVE_epilogue, gen_epilogue): Delete.
> * target-insns.def (epilogue, prologue, sibcall_prologue): New
> targetm instruction patterns.
> * alias.c (init_alias_analysis): Use them instead of HAVE_*/gen_*
> interface.
> * calls.c (expand_call): Likewise.
> * cfgrtl.c (cfg_layout_finalize): Likewise.
> * df-scan.c (df_get_entry_block_def_set): Likewise.
> (df_get_exit_block_use_set): Likewise.
> * dwarf2cfi.c (pass_dwarf2_frame::gate): Likewise.
> * final.c (final_start_function): Likewise.
> * function.c (thread_prologue_and_epilogue_insns): Likewise.
> (reposition_prologue_and_epilogue_notes): Likewise.
> * reorg.c (find_end_label): Likewise.
> * toplev.c (process_options): Likewise.

I think this one -being the most fitting patch in the range
(225190:225210]- caused this regression for cris-elf:

Running 
/tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.target/cris/torture/cris-torture.exp 
...
FAIL: gcc.target/cris/torture/no-pro-epi-1.c   -O3 -g  (internal compiler error)
FAIL: gcc.target/cris/torture/no-pro-epi-1.c   -O3 -g  (test for excess errors)

This test checks that the -mno-prologue-epilogue option works,
whose semantics is supposedly self-explanatory.

gcc.log:
Executing on host: /tmp/hpautotest-gcc1/cris-elf/gccobj/gcc/xgcc 
-B/tmp/hpautotest-gcc1/cris-elf/gccobj/gcc/ 
/tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.target/cris/torture/no-pro-epi-1.c  
-fno-diagnostics-show-caret -fdiagnostics-color=never-O3 -g  
-mno-prologue-epilogue -S   -isystem 
/tmp/hpautotest-gcc1/cris-elf/gccobj/cris-elf/./newlib/targ-include -isystem 
/tmp/hpautotest-gcc1/gcc/newlib/libc/include   -o no-pro-epi-1.s(timeout = 
300)
/tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.target/cris/torture/no-pro-epi-1.c:4:1:
 internal compiler error: Segmentation fault
0xa6ba45 crash_signal
/tmp/hpautotest-gcc1/gcc/gcc/toplev.c:360
0x6b4724 vec::iterate(unsigned int, 
dw_cfi_node**) const
/tmp/hpautotest-gcc1/gcc/gcc/vec.h:755
0x6b4724 output_call_frame_info
/tmp/hpautotest-gcc1/gcc/gcc/dwarf2out.c:925
0x6b4f36 dwarf2out_frame_finish()
/tmp/hpautotest-gcc1/gcc/gcc/dwarf2out.c:1177
Please submit a full bug report,

brgds, H-P


[gomp4] Fix syntax error

2015-07-01 Thread James Norris

Hi,

The attached patch fixes a syntax error in one of
the OpenACC runtime tests.

Committed to gomp-4_0-branch

Jim
diff --git a/libgomp/testsuite/libgomp.oacc-fortran/if-1.f90 b/libgomp/testsuite/libgomp.oacc-fortran/if-1.f90
index 3ea9681..1729a3b 100644
--- a/libgomp/testsuite/libgomp.oacc-fortran/if-1.f90
+++ b/libgomp/testsuite/libgomp.oacc-fortran/if-1.f90
@@ -410,7 +410,7 @@ program main
   if (acc_is_present (b) .eqv. .TRUE.) call abort
 #endif
 
-  !$pragma acc enter data copyin (b(1:N)) if (zero == 1)
+  !$acc enter data copyin (b(1:N)) if (zero == 1)
 
 #if !ACC_MEM_SHARED
 if (acc_is_present (b) .eqv. .TRUE.) call abort


Re: [s390] Revert TPF C++ library changes

2015-07-01 Thread DJ Delorie

> Ah, then approved.

Thanks, committed.


Re: update gthr-tpf.h

2015-07-01 Thread DJ Delorie

Ping?
https://gcc.gnu.org/ml/gcc-patches/2015-06/msg00149.html

> This patch updates gthr-tpf.h to the current gthr.h API and TPF API.  Ok?
> 
>   * gthr-tpf.h (__GTHREADS_CXX0X): Define.
>   (__gthread_t): Define.
>   (__gthread_cond_t): Define.
>   (__gthread_time_t): Define.
>   (__GTHREAD_HAS_COND): Define.
>   (__GTHREAD_COND_INIT): Define.
> 
>   (__gthread_active_p): Check __tpf_pthread_active().
>   (__gthread_mutex_lock): Remove unneeded conditional.
>   (__gthread_mutex_trylock): Likewise.
>   (__gthread_recursive_mutex_lock): Likewise.
>   (__gthread_recursive_mutex_trylock): Likewise.
>   (__gthread_recursive_mutex_unlock): Likewise.
>   (__gthread_recursive_mutex_init_function): Likewise.
> 
>   (__gthread_join): New.
>   (__gthread_detach): New.
>   (__gthread_equal): New.
>   (__gthread_self): New.
>   (__gthread_yield): New.
>   (__gthread_mutex_timedlock): New.
>   (__gthread_recursive_mutex_timedlock): New.
>   (__gthread_cond_broadcast): New.
>   (__gthread_cond_signal): New.
>   (__gthread_cond_wait): New.
>   (__gthread_cond_wait_recursive): New.
>   (__gthread_cond_timedwait): New.
>   (__gthread_cond_timedwait_recursive): New.
>   (__gthread_cond_destroy): New.


[C++/preprocessor Patch] PR c++/53690

2015-07-01 Thread Paolo Carlini

Hi,

this issue isn't a regression but it's getting a lot of attention and 
duplicates. Essentially, due to the lines at the very end of _cpp_valid_ucn:


  if (result == 0)
result = 1;

  return result;
}

we can't possibly get the encoding of \U right in C++, that is 
zero, even after Jason's r152614 which added the following special case 
for C++ earlier in the function:


  else if ((result < 0xa0
&& !CPP_OPTION (pfile, cplusplus)
&& (result != 0x24 && result != 0x40 && result != 0x60))
   || (result & 0x8000)
   || (result >= 0xD800 && result <= 0xDFFF))
{
  cpp_error (pfile, CPP_DL_ERROR,
 "%.*s is not a valid universal character",
 (int) (str - base), base);
  result = 1;
}

thus letting result == 0 thru until the very end of the function. Now, 
fixing the problem seems easy: just change the return type of the 
function to int, thus return zero for success; add a cppchar_t* 
parameter cp where *cp is computed exactly like the current return value 
*without* the final reset to one. Note that this is supposed to have 
*no* effects whatsoever outside C++ because currently, for all those 
languages, the final reset never triggers: in the second conditional 
above, a result == 0 triggers a cpp_error and result becomes == 1, thus 
the final conditional never sees result == 0.


Thus I'm finishing testing the below...

Thanks!
Paolo.


/libcpp
2015-07-01  Paolo Carlini  

PR c++/53690
* charset.c (_cpp_valid_ucn): Add cppchar_t * parameter and change
return type to int.  Fix encoding of \u and \U in C++.
(convert_ucn): Adjust call.
* lex.c (forms_identifier_p): Likewise.
* internal.h (_cpp_valid_ucn): Adjust declaration.

/gcc/testsuite
2015-07-01  Paolo Carlini  

PR c++/53690
* g++.dg/cpp/pr53690.C: New.
Index: gcc/testsuite/g++.dg/cpp/pr53690.C
===
--- gcc/testsuite/g++.dg/cpp/pr53690.C  (revision 0)
+++ gcc/testsuite/g++.dg/cpp/pr53690.C  (working copy)
@@ -0,0 +1,7 @@
+// PR c++/53690
+// { dg-do compile { target c++11 } }
+
+int array1[U'\U' == 0 ? 1 : -1];
+int array2[U'\u' == 0 ? 1 : -1];
+int array3[u'\U' == 0 ? 1 : -1];
+int array4[u'\u' == 0 ? 1 : -1];
Index: libcpp/charset.c
===
--- libcpp/charset.c(revision 225265)
+++ libcpp/charset.c(working copy)
@@ -972,21 +972,20 @@ ucn_valid_in_identifier (cpp_reader *pfile, cppcha
or 0060 (`), nor one in the range D800 through DFFF inclusive.
 
*PSTR must be preceded by "\u" or "\U"; it is assumed that the
-   buffer end is delimited by a non-hex digit.  Returns zero if the
-   UCN has not been consumed.
+   buffer end is delimited by a non-hex digit.  Returns one if the
+   UCN has not been consumed, zero otherwise.
 
-   Otherwise the nonzero value of the UCN, whether valid or invalid,
-   is returned.  Diagnostics are emitted for invalid values.  PSTR
-   is updated to point one beyond the UCN, or to the syntactically
-   invalid character.
+   The value of the UCN, whether valid or invalid, is returned in *CP.
+   Diagnostics are emitted for invalid values.  PSTR is updated to point
+   one beyond the UCN, or to the syntactically invalid character.
 
IDENTIFIER_POS is 0 when not in an identifier, 1 for the start of
an identifier, or 2 otherwise.  */
 
-cppchar_t
+int
 _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
const uchar *limit, int identifier_pos,
-   struct normalize_state *nst)
+   struct normalize_state *nst, cppchar_t *cp)
 {
   cppchar_t result, c;
   unsigned int length;
@@ -1030,8 +1029,11 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **p
  multiple tokens in identifiers, so we can't give a helpful
  error message in that case.  */
   if (length && identifier_pos)
-return 0;
-  
+{
+  *cp = 0;
+  return 1;
+}
+
   *pstr = str;
   if (length)
 {
@@ -1079,10 +1081,8 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **p
   (int) (str - base), base);
 }
 
-  if (result == 0)
-result = 1;
-
-  return result;
+  *cp = result;
+  return 0;
 }
 
 /* Convert an UCN, pointed to by FROM, to UTF-8 encoding, then translate
@@ -1100,7 +1100,7 @@ convert_ucn (cpp_reader *pfile, const uchar *from,
   struct normalize_state nst = INITIAL_NORMALIZE_STATE;
 
   from++;  /* Skip u/U.  */
-  ucn = _cpp_valid_ucn (pfile, &from, limit, 0, &nst);
+  _cpp_valid_ucn (pfile, &from, limit, 0, &nst, &ucn);
 
   rval = one_cppchar_to_utf8 (ucn, &bufp, &bytesleft);
   if (rval)
Index: libcpp/internal.h
===
--- libcpp/internal.h   (revision 225265)
+++ libcpp/internal.h   (working copy)
@@ -744,9 +744,10 @@ struct normalize_state
 #define NORMALIZE_STATE_UP

Re: [PATCH] toplevel: fixes for in-tree libiconv

2015-07-01 Thread Yaakov Selkowitz
On Fri, 2015-05-29 at 16:14 -0500, Yaakov Selkowitz wrote:
> This is the first in a series of patches to make a build with an in-tree
> GNU libiconv work as designed.
> 
> This patch fixes dependencies for parallel make, and avoids failures
> with make targets not supported by GNU libiconv.

Thanks Jeff and DJ for reviewing.  Further testing exposed an
insufficiency in my patch in the case of the 3-stage bootstrap.  Revised
patch attached, bootstrapped on x86_64-cygwin both with and without a
libiconv directory, and also with a directory and configured
--disable-libiconv.

I don't have write permissions to either gcc SVN nor binutils-gdb.git,
so please apply once approved.

-- 
Yaakov Selkowitz
Associate Software Engineer, ARM
Red Hat, Inc.

2015-07-01  Yaakov Selkowitz  

	* Makefile.def (libiconv): Define bootstrap=true.
	Mark pdf/html/info as missing.
	(configure-gcc): Depend on all-libiconv.
	(all-gcc): Ditto.
	(configure-libcpp): Ditto.
	(all-libcpp): Ditto.
	(configure-intl): Ditto.
	(all-intl): Ditto.
	* Makefile.in: Regenerate.

Index: Makefile.def
===
--- Makefile.def	(revision 225215)
+++ Makefile.def	(working copy)
@@ -93,9 +93,12 @@
 		extra_make_flags='@extra_linker_plugin_flags@'; };
 // We abuse missing to avoid installing anything for libiconv.
 host_modules= { module= libiconv;
+		bootstrap=true;
 		extra_configure_flags='--disable-shared';
 		no_install= true;
-		missing= install-info;
+		missing= pdf;
+		missing= html;
+		missing= info;
 		missing= install-pdf;
 		missing= install-html;
 		missing= install-info; };
@@ -322,6 +325,7 @@
 dependencies = { module=configure-gcc; on=all-ld; };
 dependencies = { module=configure-gcc; on=all-gold; };
 dependencies = { module=configure-gcc; on=all-libelf; };
+dependencies = { module=configure-gcc; on=all-libiconv; };
 dependencies = { module=all-gcc; on=all-libiberty; hard=true; };
 dependencies = { module=all-gcc; on=all-intl; };
 dependencies = { module=all-gcc; on=all-mpfr; };
@@ -340,6 +344,7 @@
 dependencies = { module=all-gcc; on=all-libiberty; };
 dependencies = { module=all-gcc; on=all-fixincludes; };
 dependencies = { module=all-gcc; on=all-lto-plugin; };
+dependencies = { module=all-gcc; on=all-libiconv; };
 dependencies = { module=info-gcc; on=all-build-libiberty; };
 dependencies = { module=dvi-gcc; on=all-build-libiberty; };
 dependencies = { module=pdf-gcc; on=all-build-libiberty; };
@@ -351,8 +356,10 @@
 
 dependencies = { module=configure-libcpp; on=configure-libiberty; hard=true; };
 dependencies = { module=configure-libcpp; on=configure-intl; };
+dependencies = { module=configure-libcpp; on=all-libiconv; };
 dependencies = { module=all-libcpp; on=all-libiberty; hard=true; };
 dependencies = { module=all-libcpp; on=all-intl; };
+dependencies = { module=all-libcpp; on=all-libiconv; };
 
 dependencies = { module=all-fixincludes; on=all-libiberty; };
 
@@ -371,9 +378,11 @@
 
 dependencies = { module=all-utils; on=all-libiberty; };
 
+dependencies = { module=configure-intl; on=all-libiconv; };
 dependencies = { module=configure-mpfr; on=all-gmp; };
 dependencies = { module=configure-mpc; on=all-mpfr; };
 dependencies = { module=configure-isl; on=all-gmp; };
+dependencies = { module=all-intl; on=all-libiconv; };
 
 // Host modules specific to gdb.
 dependencies = { module=configure-gdb; on=all-intl; };
Index: Makefile.in
===
--- Makefile.in	(revision 225215)
+++ Makefile.in	(working copy)
@@ -1079,7 +1079,9 @@
 @if libiberty-linker-plugin-no-bootstrap
 all-host: maybe-all-libiberty-linker-plugin
 @endif libiberty-linker-plugin-no-bootstrap
+@if libiconv-no-bootstrap
 all-host: maybe-all-libiconv
+@endif libiconv-no-bootstrap
 all-host: maybe-all-m4
 all-host: maybe-all-readline
 all-host: maybe-all-sid
@@ -24134,7 +24136,6 @@
 @if libiconv
 maybe-configure-libiconv: configure-libiconv
 configure-libiconv: 
-	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	test ! -f $(HOST_SUBDIR)/libiconv/Makefile || exit 0; \
@@ -24158,8 +24159,213 @@
 
 
 
+.PHONY: configure-stage1-libiconv maybe-configure-stage1-libiconv
+maybe-configure-stage1-libiconv:
+@if libiconv-bootstrap
+maybe-configure-stage1-libiconv: configure-stage1-libiconv
+configure-stage1-libiconv:
+	@[ $(current_stage) = stage1 ] || $(MAKE) stage1-start
+	@$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/libiconv
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE1_TFLAGS)"; \
+	test ! -f $(HOST_SUBDIR)/libiconv/Makefile || exit 0; \
+	$(HOST_EXPORTS) \
+	CFLAGS="$(STAGE1_CFLAGS)"; export CFLAGS; \
+	CXXFLAGS="$(STAGE1_CXXFLAGS)"; export CXXFLAGS; \
+	LIBCFLAGS="$(LIBCFLAGS)"; export LIBCFLAGS;  \
+	echo Configuring stage 1 in $(HOST_SUBDIR)/libiconv; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/libiconv; \
+	cd $(HOST_SUBDIR)/libiconv || exit

Re: [PATCH] toplevel: fixes for in-tree libiconv

2015-07-01 Thread Yaakov Selkowitz
On Fri, 2015-05-29 at 16:14 -0500, Yaakov Selkowitz wrote:
> This is the first in a series of patches to make a build with an in-tree
> GNU libiconv work as designed.
> 
> This patch fixes dependencies for parallel make, and avoids failures
> with make targets not supported by GNU libiconv.

Thanks Jeff and DJ for reviewing.  Further testing exposed an
insufficiency in my patch in the case of the 3-stage bootstrap.  Revised
patch attached, bootstrapped on x86_64-cygwin both with and without a
libiconv directory, and also with a directory and configured
--disable-libiconv.

I don't have write permissions to either gcc SVN nor binutils-gdb.git,
so please apply once approved.

-- 
Yaakov Selkowitz
Associate Software Engineer, ARM
Red Hat, Inc.

2015-07-01  Yaakov Selkowitz  

	* Makefile.def (libiconv): Define bootstrap=true.
	Mark pdf/html/info as missing.
	(configure-gcc): Depend on all-libiconv.
	(all-gcc): Ditto.
	(configure-libcpp): Ditto.
	(all-libcpp): Ditto.
	(configure-intl): Ditto.
	(all-intl): Ditto.
	* Makefile.in: Regenerate.

Index: Makefile.def
===
--- Makefile.def	(revision 225215)
+++ Makefile.def	(working copy)
@@ -93,9 +93,12 @@
 		extra_make_flags='@extra_linker_plugin_flags@'; };
 // We abuse missing to avoid installing anything for libiconv.
 host_modules= { module= libiconv;
+		bootstrap=true;
 		extra_configure_flags='--disable-shared';
 		no_install= true;
-		missing= install-info;
+		missing= pdf;
+		missing= html;
+		missing= info;
 		missing= install-pdf;
 		missing= install-html;
 		missing= install-info; };
@@ -322,6 +325,7 @@
 dependencies = { module=configure-gcc; on=all-ld; };
 dependencies = { module=configure-gcc; on=all-gold; };
 dependencies = { module=configure-gcc; on=all-libelf; };
+dependencies = { module=configure-gcc; on=all-libiconv; };
 dependencies = { module=all-gcc; on=all-libiberty; hard=true; };
 dependencies = { module=all-gcc; on=all-intl; };
 dependencies = { module=all-gcc; on=all-mpfr; };
@@ -340,6 +344,7 @@
 dependencies = { module=all-gcc; on=all-libiberty; };
 dependencies = { module=all-gcc; on=all-fixincludes; };
 dependencies = { module=all-gcc; on=all-lto-plugin; };
+dependencies = { module=all-gcc; on=all-libiconv; };
 dependencies = { module=info-gcc; on=all-build-libiberty; };
 dependencies = { module=dvi-gcc; on=all-build-libiberty; };
 dependencies = { module=pdf-gcc; on=all-build-libiberty; };
@@ -351,8 +356,10 @@
 
 dependencies = { module=configure-libcpp; on=configure-libiberty; hard=true; };
 dependencies = { module=configure-libcpp; on=configure-intl; };
+dependencies = { module=configure-libcpp; on=all-libiconv; };
 dependencies = { module=all-libcpp; on=all-libiberty; hard=true; };
 dependencies = { module=all-libcpp; on=all-intl; };
+dependencies = { module=all-libcpp; on=all-libiconv; };
 
 dependencies = { module=all-fixincludes; on=all-libiberty; };
 
@@ -371,9 +378,11 @@
 
 dependencies = { module=all-utils; on=all-libiberty; };
 
+dependencies = { module=configure-intl; on=all-libiconv; };
 dependencies = { module=configure-mpfr; on=all-gmp; };
 dependencies = { module=configure-mpc; on=all-mpfr; };
 dependencies = { module=configure-isl; on=all-gmp; };
+dependencies = { module=all-intl; on=all-libiconv; };
 
 // Host modules specific to gdb.
 dependencies = { module=configure-gdb; on=all-intl; };
Index: Makefile.in
===
--- Makefile.in	(revision 225215)
+++ Makefile.in	(working copy)
@@ -1079,7 +1079,9 @@
 @if libiberty-linker-plugin-no-bootstrap
 all-host: maybe-all-libiberty-linker-plugin
 @endif libiberty-linker-plugin-no-bootstrap
+@if libiconv-no-bootstrap
 all-host: maybe-all-libiconv
+@endif libiconv-no-bootstrap
 all-host: maybe-all-m4
 all-host: maybe-all-readline
 all-host: maybe-all-sid
@@ -24134,7 +24136,6 @@
 @if libiconv
 maybe-configure-libiconv: configure-libiconv
 configure-libiconv: 
-	@: $(MAKE); $(unstage)
 	@r=`${PWD_COMMAND}`; export r; \
 	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
 	test ! -f $(HOST_SUBDIR)/libiconv/Makefile || exit 0; \
@@ -24158,8 +24159,213 @@
 
 
 
+.PHONY: configure-stage1-libiconv maybe-configure-stage1-libiconv
+maybe-configure-stage1-libiconv:
+@if libiconv-bootstrap
+maybe-configure-stage1-libiconv: configure-stage1-libiconv
+configure-stage1-libiconv:
+	@[ $(current_stage) = stage1 ] || $(MAKE) stage1-start
+	@$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/libiconv
+	@r=`${PWD_COMMAND}`; export r; \
+	s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
+	TFLAGS="$(STAGE1_TFLAGS)"; \
+	test ! -f $(HOST_SUBDIR)/libiconv/Makefile || exit 0; \
+	$(HOST_EXPORTS) \
+	CFLAGS="$(STAGE1_CFLAGS)"; export CFLAGS; \
+	CXXFLAGS="$(STAGE1_CXXFLAGS)"; export CXXFLAGS; \
+	LIBCFLAGS="$(LIBCFLAGS)"; export LIBCFLAGS;  \
+	echo Configuring stage 1 in $(HOST_SUBDIR)/libiconv; \
+	$(SHELL) $(srcdir)/mkinstalldirs $(HOST_SUBDIR)/libiconv; \
+	cd $(HOST_SUBDIR)/libiconv || exit

Re: [C++/preprocessor Patch] PR c++/53690

2015-07-01 Thread Andreas Schwab
Paolo Carlini  writes:

> @@ -972,21 +972,20 @@ ucn_valid_in_identifier (cpp_reader *pfile, cppcha
> or 0060 (`), nor one in the range D800 through DFFF inclusive.
>  
> *PSTR must be preceded by "\u" or "\U"; it is assumed that the
> -   buffer end is delimited by a non-hex digit.  Returns zero if the
> -   UCN has not been consumed.
> +   buffer end is delimited by a non-hex digit.  Returns one if the
> +   UCN has not been consumed, zero otherwise.

The name of the function would make more sense if it returned a boolean
with true meaning success.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


Re: [PATCH] config: fix AM_ICONV for in-tree libiconv

2015-07-01 Thread Yaakov Selkowitz
On Fri, 2015-05-29 at 16:25 -0500, Yaakov Selkowitz wrote:
> This is the second in a series of patches to make a build with an
> in-tree GNU libiconv work as designed.
> 
> Currently GDB is the only toolchain component which actually uses an
> in-tree libiconv.  This patch modifies the common AM_ICONV to use an
> in-tree libiconv when present and not already provided by libc.  (GDB's
> workaround uses an in-tree libiconv even when libc provides iconv(3);
> I'm not sure when or why that would be desirable.)
> 
> Once these two patches are merged in to each tree, I will follow with
> patches to regenerate the various configure scripts and a few other
> minor corresponding changes.

This patch was bootstrapped in conjunction with the toplevel libiconv
patch.  I don't have write permissions to either repository, so please
apply once approved.

-- 
Yaakov Selkowitz
Associate Software Engineer, ARM
Red Hat, Inc.




Re: [PATCH] config: fix AM_ICONV for in-tree libiconv

2015-07-01 Thread Yaakov Selkowitz
On Wed, 2015-07-01 at 15:46 -0500, Yaakov Selkowitz wrote:
> On Fri, 2015-05-29 at 16:25 -0500, Yaakov Selkowitz wrote:
> > This is the second in a series of patches to make a build with an
> > in-tree GNU libiconv work as designed.
> > 
> > Currently GDB is the only toolchain component which actually uses an
> > in-tree libiconv.  This patch modifies the common AM_ICONV to use an
> > in-tree libiconv when present and not already provided by libc.  (GDB's
> > workaround uses an in-tree libiconv even when libc provides iconv(3);
> > I'm not sure when or why that would be desirable.)
> > 
> > Once these two patches are merged in to each tree, I will follow with
> > patches to regenerate the various configure scripts and a few other
> > minor corresponding changes.
> 
> This patch was bootstrapped in conjunction with the toplevel libiconv
> patch.  I don't have write permissions to either repository, so please
> apply once approved.

Ditto for this patch, which regenerates intl/configure for the changes
in config/iconv.m4.

-- 
Yaakov Selkowitz
Associate Software Engineer, ARM
Red Hat, Inc.




Re: [PATCH] config: fix AM_ICONV for in-tree libiconv

2015-07-01 Thread Yaakov Selkowitz
On Wed, 2015-07-01 at 15:46 -0500, Yaakov Selkowitz wrote:
> On Fri, 2015-05-29 at 16:25 -0500, Yaakov Selkowitz wrote:
> > This is the second in a series of patches to make a build with an
> > in-tree GNU libiconv work as designed.
> > 
> > Currently GDB is the only toolchain component which actually uses an
> > in-tree libiconv.  This patch modifies the common AM_ICONV to use an
> > in-tree libiconv when present and not already provided by libc.  (GDB's
> > workaround uses an in-tree libiconv even when libc provides iconv(3);
> > I'm not sure when or why that would be desirable.)
> > 
> > Once these two patches are merged in to each tree, I will follow with
> > patches to regenerate the various configure scripts and a few other
> > minor corresponding changes.
> 
> This patch was bootstrapped in conjunction with the toplevel libiconv
> patch.  I don't have write permissions to either repository, so please
> apply once approved.

This patch includes the relevant changes for libcpp/configure and
gcc/configure{.ac,}.

-- 
Yaakov Selkowitz
Associate Software Engineer, ARM
Red Hat, Inc.

2015-07-01  Yaakov Selkowitz  

	libcpp/
	* configure: Regenerate.

	gcc/
	* configure.ac: Define LIBICONV_DEP with in-tree libiconv.
	* configure: Regenerate.

Index: libcpp/configure
===
--- libcpp/configure	(revision 225215)
+++ libcpp/configure	(working copy)
@@ -4733,6 +4733,12 @@
 # Figure out what compiler warnings we can enable.
 # See config/warnings.m4 for details.
 
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
 warn=
 save_CFLAGS="$CFLAGS"
 for real_option in -W -Wall -Wno-narrowing -Wwrite-strings \
@@ -4778,7 +4784,19 @@
 fi
   done
 CFLAGS="$save_CFLAGS"
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
 c_warn=
 save_CFLAGS="$CFLAGS"
 for real_option in -Wstrict-prototypes -Wmissing-prototypes \
@@ -4824,7 +4842,19 @@
 fi
   done
 CFLAGS="$save_CFLAGS"
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
 WARN_PEDANTIC=
 # Do the check with the no- prefix removed from the warning options
 # since gcc silently accepts any -Wno-* option on purpose
@@ -4862,9 +4892,21 @@
 fi
 
 fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
+
 # Disable exceptions and RTTI if building with g++
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
 noexception_flags=
 save_CFLAGS="$CFLAGS"
 for real_option in -fno-exceptions -fno-rtti; do
@@ -4909,10 +4951,22 @@
 fi
   done
 CFLAGS="$save_CFLAGS"
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
+
 # Only enable with --enable-werror-always until existing warnings are
 # corrected.
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
 WERROR=
 # Check whether --enable-werror-always was given.
 if test "${enable_werror_always+set}" = set; then :
@@ -4925,8 +4979,14 @@
   WERROR="$WERROR${WERROR:+ }-Werror"
 fi
 
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
+
 # Dependency checking.
 rm -rf .tst 2>/dev/null
 mkdir .tst 2>/dev/null
@@ -6971,31 +7031,6 @@
 
 
 
-  am_save_CPPFLAGS="$CPPFLAGS"
-
-  for element in $INCICONV; do
-haveit=
-for x in $CPPFLAGS; do

[PATCH] PR fortran/66545 -- Fix NULL pointer dereference

2015-07-01 Thread Steve Kargl
The attached patch avoid the dereference of a NULL pointer,
and thereby avoids an ICE.  Regression tested on trunk.
OK to commit?

2015-07-01  Steven g. Kargl   

PR fortran/66545
* primary.c (match_sym_complex_part): Do not dereference NULL pointer.

2015-07-01  Steven g. Kargl   

PR fortran/66545
* gfortran.dg/pr66545_1.f90: New test.
* gfortran.dg/pr66545_2.f90: New test.

-- 
Steve
Index: gcc/fortran/primary.c
===
--- gcc/fortran/primary.c	(revision 225272)
+++ gcc/fortran/primary.c	(working copy)
@@ -1254,6 +1254,9 @@ match_sym_complex_part (gfc_expr **resul
   return MATCH_ERROR;
 }
 
+  if (!sym->value)
+goto error;
+
   if (!gfc_numeric_ts (&sym->value->ts))
 {
   gfc_error ("Numeric PARAMETER required in complex constant at %C");
Index: gcc/testsuite/gfortran.dg/pr66545_1.f90
===
--- gcc/testsuite/gfortran.dg/pr66545_1.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/pr66545_1.f90	(working copy)
@@ -0,0 +1,17 @@
+! { dg-do compile }
+! { dg-options "-Wall" }
+! PR fortran/66545
+!
+subroutine p
+   complex, parameter :: c1 = (c1) ! { dg-error "before its definition" }
+   complex, parameter :: c2 = c2   ! { dg-error "before its definition" }
+   complex :: c3 = (c3)! { dg-error "has not been declared or is a variable" }
+   complex :: c4 = c4  ! { dg-error "has not been declared or is a variable" }
+end subroutine p
+
+subroutine q
+   real, parameter :: r1 = (r1)  ! { dg-error "before its definition" }
+   real, parameter :: r2 = r2! { dg-error "before its definition" }
+   real :: r3 = (r3) ! { dg-error "has not been declared or is a variable" }
+   real :: r4 = r4   ! { dg-error "has not been declared or is a variable" }
+end subroutine q
Index: gcc/testsuite/gfortran.dg/pr66545_2.f90
===
--- gcc/testsuite/gfortran.dg/pr66545_2.f90	(revision 0)
+++ gcc/testsuite/gfortran.dg/pr66545_2.f90	(working copy)
@@ -0,0 +1,23 @@
+! { dg-do compile }
+! { dg-options "-Wuninitialized" }
+! PR fortran/66545
+!
+program foo
+   implicit none
+   call p1
+   call q1
+end program foo
+
+subroutine p1
+   complex :: c5
+   complex :: c6
+   c5 = (c5)  ! { dg-warning "used uninitialized in this" }
+   c6 = c6! { dg-warning "used uninitialized in this" }
+end subroutine p1
+
+subroutine q1
+   real :: r5
+   real :: r6
+   r5 = (r5)   ! { dg-warning "used uninitialized in this" }
+   r6 = r6 ! { dg-warning "used uninitialized in this" }
+end subroutine q1


Re: [PATCH] config: fix AM_ICONV for in-tree libiconv

2015-07-01 Thread Yaakov Selkowitz
On Wed, 2015-07-01 at 15:52 -0500, Yaakov Selkowitz wrote:
> On Wed, 2015-07-01 at 15:46 -0500, Yaakov Selkowitz wrote:
> > On Fri, 2015-05-29 at 16:25 -0500, Yaakov Selkowitz wrote:
> > > This is the second in a series of patches to make a build with an
> > > in-tree GNU libiconv work as designed.
> > > 
> > > Currently GDB is the only toolchain component which actually uses an
> > > in-tree libiconv.  This patch modifies the common AM_ICONV to use an
> > > in-tree libiconv when present and not already provided by libc.  (GDB's
> > > workaround uses an in-tree libiconv even when libc provides iconv(3);
> > > I'm not sure when or why that would be desirable.)
> > > 
> > > Once these two patches are merged in to each tree, I will follow with
> > > patches to regenerate the various configure scripts and a few other
> > > minor corresponding changes.
> > 
> > This patch was bootstrapped in conjunction with the toplevel libiconv
> > patch.  I don't have write permissions to either repository, so please
> > apply once approved.
> 
> Ditto for this patch, which regenerates intl/configure for the changes
> in config/iconv.m4.

With the patch attached this time.

-- 
Yaakov Selkowitz
Associate Software Engineer, ARM
Red Hat, Inc.

Index: intl/configure
===
--- intl/configure	(revision 225215)
+++ intl/configure	(working copy)
@@ -609,8 +609,6 @@
 USE_INCLUDED_LIBINTL
 BUILD_INCLUDED_LIBINTL
 INTLBISON
-LTLIBICONV
-LIBICONV
 GLIBC21
 ALLOCA
 EGREP
@@ -684,9 +682,9 @@
 ac_user_opts='
 enable_option_checking
 enable_nls
+with_libiconv_prefix
 with_gnu_ld
 enable_rpath
-with_libiconv_prefix
 with_included_gettext
 with_libintl_prefix
 enable_maintainer_mode
@@ -1319,9 +1317,9 @@
 Optional Packages:
   --with-PACKAGE[=ARG]use PACKAGE [ARG=yes]
   --without-PACKAGE   do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-libiconv-prefix=DIR
+  search for libiconv in DIR/include and DIR/lib
   --with-gnu-ld   assume the C compiler uses GNU ld default=no
-  --with-libiconv-prefix[=DIR]  search for libiconv in DIR/include and DIR/lib
-  --without-libiconv-prefix don't search for libiconv in includedir and libdir
   --with-included-gettext use the GNU gettext library included here
   --with-libintl-prefix[=DIR]  search for libintl in DIR/include and DIR/lib
   --without-libintl-prefix don't search for libintl in includedir and libdir
@@ -4849,548 +4847,7 @@
   fi
 
 
-  if test "X$prefix" = "XNONE"; then
-acl_final_prefix="$ac_default_prefix"
-  else
-acl_final_prefix="$prefix"
-  fi
-  if test "X$exec_prefix" = "XNONE"; then
-acl_final_exec_prefix='${prefix}'
-  else
-acl_final_exec_prefix="$exec_prefix"
-  fi
-  acl_save_prefix="$prefix"
-  prefix="$acl_final_prefix"
-  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
-  prefix="$acl_save_prefix"
 
-
-# Check whether --with-gnu-ld was given.
-if test "${with_gnu_ld+set}" = set; then :
-  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
-else
-  with_gnu_ld=no
-fi
-
-# Prepare PATH_SEPARATOR.
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
-  echo "#! /bin/sh" >conf$$.sh
-  echo  "exit 0"   >>conf$$.sh
-  chmod +x conf$$.sh
-  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
-PATH_SEPARATOR=';'
-  else
-PATH_SEPARATOR=:
-  fi
-  rm -f conf$$.sh
-fi
-ac_prog=ld
-if test "$GCC" = yes; then
-  # Check if gcc -print-prog-name=ld gives a path.
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
-$as_echo_n "checking for ld used by GCC... " >&6; }
-  case $host in
-  *-*-mingw*)
-# gcc leaves a trailing carriage return which upsets mingw
-ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
-  *)
-ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
-  esac
-  case $ac_prog in
-# Accept absolute paths.
-[\\/]* | [A-Za-z]:[\\/]*)
-  re_direlt='/[^/][^/]*/\.\./'
-  # Canonicalize the path of ld
-  ac_prog=`echo $ac_prog| sed 's%%/%g'`
-  while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
-	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
-  done
-  test -z "$LD" && LD="$ac_prog"
-  ;;
-  "")
-# If it fails, then pretend we aren't using GCC.
-ac_prog=ld
-;;
-  *)
-# If it is relative, then search for the first ld in PATH.
-with_gnu_ld=unknown
-;;
-  esac
-elif test "$with_gnu_ld" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
-$as_echo_n "checking for GNU ld... " >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
-$as_echo_n "checking for non-GNU ld... " >&6; }
-fi
-if test "${acl_cv_path_LD+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -z "$LD"; then
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
-  for ac_dir in $PATH; do
-test -z "$ac_dir" && ac_dir=.
-if test

Re: [C++/preprocessor Patch] PR c++/53690

2015-07-01 Thread Paolo Carlini

Hi,

On 07/01/2015 10:45 PM, Andreas Schwab wrote:

Paolo Carlini  writes:


@@ -972,21 +972,20 @@ ucn_valid_in_identifier (cpp_reader *pfile, cppcha
 or 0060 (`), nor one in the range D800 through DFFF inclusive.
  
 *PSTR must be preceded by "\u" or "\U"; it is assumed that the

-   buffer end is delimited by a non-hex digit.  Returns zero if the
-   UCN has not been consumed.
+   buffer end is delimited by a non-hex digit.  Returns one if the
+   UCN has not been consumed, zero otherwise.

The name of the function would make more sense if it returned a boolean
with true meaning success.
To be clear (the diff can be a little confusing) we are talking about 
_cpp_valid_ucn, the name of the function I'm patching. That said, I'm of 
course open to proposals about a better name for the patched function. 
Likewise for the values returned, which I picked for consistency with 
all the other functions in libcpp, the usual "unix" convention.


Paolo.


Re: [gomp4.1] Support #pragma omp target {enter,exit} data

2015-07-01 Thread Ilya Verbin
On Tue, Jun 30, 2015 at 18:10:44 +0200, Jakub Jelinek wrote:
> The thing is whether it is actually a good idea to allocate the enter data
> allocated objects together.
> In OpenMP 4.0, generally objects would be allocated and deallocated at the
> same times, except for multiple host threads trying to map the same variables
> into the target.  In OpenMP 4.1, due to enter data/exit data, they can be
> allocated and freed quite independently, and it is true that is the case
> even for target data, one can either target data, then target enter data
> to prevent something from being deallocated, then target data end freeing
> only parts, etc.  So the question is if we think in real-world the
> allocation or deallocation will be usually together or not.

IMHO, it's OK to allocate "target data" objects together and "target enter data"
objects one by one.  I've implemented this approach in the patch bellow.

However, if someone writes a program like this:

  #pragma omp target data map(tofrom: small, arr[:big])
{
  #pragma omp target enter data map(to: small)
}
  do_a_lot_of_something ();
  #pragma omp target exit data map(from: small)

Big array will be deallocated on target only with 'small' at the end.
Is this acceptable?


The patch is not ready though, I don't know how to unmap GOMP_MAP_POINTER vars.
In gomp_unmap_vars they're unmapped through tgt->list[], but in gomp_exit_data
it's impossible to find such var in the splay tree, because hostaddr differs
from the address, used at mapping.


libgomp/
* target.c (gomp_map_vars_existing): Fix target address for 'always to'
array sections.  Handle special refcount UINTPTR_MAX.
(gomp_map_vars): Handle special refcount UINTPTR_MAX.   
 
(gomp_unmap_vars): Decrement k->refcount when it's 1 and
k->async_refcount is 0.
(gomp_offload_image_to_device): Set refcounts to UINTPTR_MAX.
(gomp_exit_data): New static function.
(GOMP_target_enter_exit_data): Add mapping/unmapping.
* testsuite/libgomp.c/target-11.c: Extend for testing 'always to' array
sections.
* testsuite/libgomp.c/target-12.c: New test.


diff --git a/libgomp/target.c b/libgomp/target.c
index a394e95..20e32f8 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -171,10 +171,13 @@ gomp_map_vars_existing (struct gomp_device_descr 
*devicep, splay_tree_key oldn,
 
   if (GOMP_MAP_ALWAYS_TO_P (kind))
 devicep->host2dev_func (devicep->target_id,
-   (void *) (oldn->tgt->tgt_start + oldn->tgt_offset),
+   (void *) (oldn->tgt->tgt_start + oldn->tgt_offset
+ + newn->host_start - oldn->host_start),
(void *) newn->host_start,
newn->host_end - newn->host_start);
-  oldn->refcount++;
+
+  if (oldn->refcount != UINTPTR_MAX)
+oldn->refcount++;
 }
 
 static int
@@ -439,7 +442,8 @@ gomp_map_vars (struct gomp_device_descr *devicep, size_t 
mapnum,
  tgt->list[j].key = k;
  tgt->list[j].copy_from = false;
  tgt->list[j].always_copy_from = false;
- k->refcount++;
+ if (k->refcount != UINTPTR_MAX)
+   k->refcount++;
  gomp_map_pointer (tgt,
(uintptr_t) *(void **) hostaddrs[j],
k->tgt_offset
@@ -578,12 +582,18 @@ gomp_unmap_vars (struct target_mem_desc *tgt, bool 
do_copyfrom)
continue;
 
   bool do_unmap = false;
-  if (k->refcount > 1)
+  if (k->refcount > 1 && k->refcount != UINTPTR_MAX)
k->refcount--;
-  else if (k->async_refcount > 0)
-   k->async_refcount--;
-  else
-   do_unmap = true;
+  else if (k->refcount == 1)
+   {
+ if (k->async_refcount > 0)
+   k->async_refcount--;
+ else
+   {
+ k->refcount--;
+ do_unmap = true;
+   }
+   }
 
   if ((do_unmap && do_copyfrom && tgt->list[i].copy_from)
  || tgt->list[i].always_copy_from)
@@ -709,7 +719,7 @@ gomp_offload_image_to_device (struct gomp_device_descr 
*devicep,
   /* Insert host-target address mapping into splay tree.  */
   struct target_mem_desc *tgt = gomp_malloc (sizeof (*tgt));
   tgt->array = gomp_malloc ((num_funcs + num_vars) * sizeof (*tgt->array));
-  tgt->refcount = 1;
+  tgt->refcount = UINTPTR_MAX;
   tgt->tgt_start = 0;
   tgt->tgt_end = 0;
   tgt->to_free = NULL;
@@ -725,7 +735,7 @@ gomp_offload_image_to_device (struct gomp_device_descr 
*devicep,
   k->host_end = k->host_start + 1;
   k->tgt = tgt;
   k->tgt_offset = target_table[i].start;
-  k->refcount = 1;
+  k->refcount = UINTPTR_MAX;
   k->async_refcount = 0;
   array->left = NULL;
   array->right = NULL;
@@ -750,7 

Re: [PATCH] PR fortran/66545 -- Fix NULL pointer dereference

2015-07-01 Thread Thomas Koenig
Hi Steve,

> The attached patch avoid the dereference of a NULL pointer,
> and thereby avoids an ICE.  Regression tested on trunk.
> OK to commit?

OK.

Thanks for the patch!

Thomas



Re: [C++/preprocessor Patch] PR c++/53690

2015-07-01 Thread Paolo Carlini

Hi again,

On 07/01/2015 10:54 PM, Paolo Carlini wrote:

Hi,

On 07/01/2015 10:45 PM, Andreas Schwab wrote:

Paolo Carlini  writes:

@@ -972,21 +972,20 @@ ucn_valid_in_identifier (cpp_reader *pfile, 
cppcha

 or 0060 (`), nor one in the range D800 through DFFF inclusive.
   *PSTR must be preceded by "\u" or "\U"; it is assumed that the
-   buffer end is delimited by a non-hex digit.  Returns zero if the
-   UCN has not been consumed.
+   buffer end is delimited by a non-hex digit.  Returns one if the
+   UCN has not been consumed, zero otherwise.

The name of the function would make more sense if it returned a boolean
with true meaning success.
To be clear (the diff can be a little confusing) we are talking about 
_cpp_valid_ucn, the name of the function I'm patching. That said, I'm 
of course open to proposals about a better name for the patched 
function. Likewise for the values returned, which I picked for 
consistency with all the other functions in libcpp, the usual "unix" 
convention.
I stand corrected: in fact we are already using a mix of bool and int 
return types in those functions. Thus I'm also testing the below 
version, which simply changes the return type to bool with true meaning 
success.


Thanks!
Paolo.

///
/libcpp
2015-07-01  Paolo Carlini  

PR c++/53690
* charset.c (_cpp_valid_ucn): Add cppchar_t * parameter and change
return type to bool.  Fix encoding of \u and \U in C++.
(convert_ucn): Adjust call.
* lex.c (forms_identifier_p): Likewise.
* internal.h (_cpp_valid_ucn): Adjust declaration.

/gcc/testsuite
2015-07-01  Paolo Carlini  

PR c++/53690
* g++.dg/cpp/pr53690.C: New.
Index: gcc/testsuite/g++.dg/cpp/pr53690.C
===
--- gcc/testsuite/g++.dg/cpp/pr53690.C  (revision 0)
+++ gcc/testsuite/g++.dg/cpp/pr53690.C  (working copy)
@@ -0,0 +1,7 @@
+// PR c++/53690
+// { dg-do compile { target c++11 } }
+
+int array1[U'\U' == 0 ? 1 : -1];
+int array2[U'\u' == 0 ? 1 : -1];
+int array3[u'\U' == 0 ? 1 : -1];
+int array4[u'\u' == 0 ? 1 : -1];
Index: libcpp/charset.c
===
--- libcpp/charset.c(revision 225275)
+++ libcpp/charset.c(working copy)
@@ -972,21 +972,20 @@ ucn_valid_in_identifier (cpp_reader *pfile, cppcha
or 0060 (`), nor one in the range D800 through DFFF inclusive.
 
*PSTR must be preceded by "\u" or "\U"; it is assumed that the
-   buffer end is delimited by a non-hex digit.  Returns zero if the
-   UCN has not been consumed.
+   buffer end is delimited by a non-hex digit.  Returns false if the
+   UCN has not been consumed, true otherwise.
 
-   Otherwise the nonzero value of the UCN, whether valid or invalid,
-   is returned.  Diagnostics are emitted for invalid values.  PSTR
-   is updated to point one beyond the UCN, or to the syntactically
-   invalid character.
+   The value of the UCN, whether valid or invalid, is returned in *CP.
+   Diagnostics are emitted for invalid values.  PSTR is updated to point
+   one beyond the UCN, or to the syntactically invalid character.
 
IDENTIFIER_POS is 0 when not in an identifier, 1 for the start of
an identifier, or 2 otherwise.  */
 
-cppchar_t
+bool
 _cpp_valid_ucn (cpp_reader *pfile, const uchar **pstr,
const uchar *limit, int identifier_pos,
-   struct normalize_state *nst)
+   struct normalize_state *nst, cppchar_t *cp)
 {
   cppchar_t result, c;
   unsigned int length;
@@ -1030,8 +1029,11 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **p
  multiple tokens in identifiers, so we can't give a helpful
  error message in that case.  */
   if (length && identifier_pos)
-return 0;
-  
+{
+  *cp = 0;
+  return false;
+}
+
   *pstr = str;
   if (length)
 {
@@ -1079,10 +1081,8 @@ _cpp_valid_ucn (cpp_reader *pfile, const uchar **p
   (int) (str - base), base);
 }
 
-  if (result == 0)
-result = 1;
-
-  return result;
+  *cp = result;
+  return true;
 }
 
 /* Convert an UCN, pointed to by FROM, to UTF-8 encoding, then translate
@@ -1100,7 +1100,7 @@ convert_ucn (cpp_reader *pfile, const uchar *from,
   struct normalize_state nst = INITIAL_NORMALIZE_STATE;
 
   from++;  /* Skip u/U.  */
-  ucn = _cpp_valid_ucn (pfile, &from, limit, 0, &nst);
+  _cpp_valid_ucn (pfile, &from, limit, 0, &nst, &ucn);
 
   rval = one_cppchar_to_utf8 (ucn, &bufp, &bytesleft);
   if (rval)
Index: libcpp/internal.h
===
--- libcpp/internal.h   (revision 225275)
+++ libcpp/internal.h   (working copy)
@@ -744,9 +744,10 @@ struct normalize_state
 #define NORMALIZE_STATE_UPDATE_IDNUM(st, c)\
   ((st)->previous = (c), (st)->prev_class = 0)
 
-extern cppchar_t _cpp_valid_ucn (cpp_reader *, const unsigned char **,
-  

[gomp4] Allow parameter declarations with deviceptr

2015-07-01 Thread James Norris

Hi,

This patch allows parameter declarations to be used as
arguments to deviceptr for C and C++.

Committed to gomp-4_0-branch.

Jim
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 88e68ae..dc244ce 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -10749,7 +10749,7 @@ c_parser_oacc_data_clause_deviceptr (c_parser *parser, tree list)
 	 c_parser_omp_var_list_parens() should construct a list of
 	 locations to go along with the var list.  */
 
-  if (TREE_CODE (v) != VAR_DECL)
+  if (TREE_CODE (v) != VAR_DECL && TREE_CODE (v) != PARM_DECL)
 	error_at (loc, "%qD is not a variable", v);
   else if (TREE_TYPE (v) == error_mark_node)
 	;
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 41fb35e..c233595 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -28122,7 +28122,7 @@ cp_parser_oacc_data_clause_deviceptr (cp_parser *parser, tree list)
 	 c_parser_omp_var_list_parens should construct a list of
 	 locations to go along with the var list.  */
 
-  if (TREE_CODE (v) != VAR_DECL)
+  if (TREE_CODE (v) != VAR_DECL && TREE_CODE (v) != PARM_DECL)
 	error_at (loc, "%qD is not a variable", v);
   else if (TREE_TYPE (v) == error_mark_node)
 	;


Re: Regressions with "[committed] Use target-insns.def for prologue & epilogue insns"

2015-07-01 Thread Richard Sandiford
Hans-Peter Nilsson  writes:
>> From: Richard Sandiford 
>> Date: Tue, 30 Jun 2015 22:55:24 +0200
>
>> Bootstrapped & regression-tested on x86_64-linux-gnu and aarch64-linux-gnu.
>> Also tested via config-list.mk.  Committed as preapproved.
>> 
>> Thanks,
>> Richard
>> 
>> 
>> gcc/
>> * defaults.h (HAVE_epilogue, gen_epilogue): Delete.
>> * target-insns.def (epilogue, prologue, sibcall_prologue): New
>> targetm instruction patterns.
>> * alias.c (init_alias_analysis): Use them instead of HAVE_*/gen_*
>> interface.
>> * calls.c (expand_call): Likewise.
>> * cfgrtl.c (cfg_layout_finalize): Likewise.
>> * df-scan.c (df_get_entry_block_def_set): Likewise.
>> (df_get_exit_block_use_set): Likewise.
>> * dwarf2cfi.c (pass_dwarf2_frame::gate): Likewise.
>> * final.c (final_start_function): Likewise.
>> * function.c (thread_prologue_and_epilogue_insns): Likewise.
>> (reposition_prologue_and_epilogue_notes): Likewise.
>> * reorg.c (find_end_label): Likewise.
>> * toplev.c (process_options): Likewise.
>
> I think this one -being the most fitting patch in the range
> (225190:225210]- caused this regression for cris-elf:
>
> Running
> /tmp/hpautotest-gcc1/gcc/gcc/testsuite/gcc.target/cris/torture/cris-torture.exp
> ...
> FAIL: gcc.target/cris/torture/no-pro-epi-1.c   -O3 -g  (internal compiler 
> error)
> FAIL: gcc.target/cris/torture/no-pro-epi-1.c   -O3 -g  (test for excess 
> errors)
>
> This test checks that the -mno-prologue-epilogue option works,
> whose semantics is supposedly self-explanatory.

Well, yes and no :-)  The crash is coming from the code that outputs
dwarf CFI information.  The code that records this information is skipped
for targets without rtl prologues, with the comment:

  /* Targets which still implement the prologue in assembler text
 cannot use the generic dwarf2 unwinding.  */

That seems accurate.  So what's -mno-prologue-epilogue supposed to do
wrt CFI entries?  Should it output empty entries or none at all?

The first-order reason for the failure is that the code used to be
conditional on #ifndef HAVE_prologue and didn't care what HAVE_prologue
itself evaluated to.  So the condition on the pattern wasn't actually
tested.

Which I suppose leads to the question: does !HAVE_prologue when "prologue"
is defined mean "I know how to output rtl prologues, but the prologue
for this function is empty" or "I'll output the prologue as text rather
than rtl".  I think it logically means the second.  The condition says
whether the pattern can be used; if the pattern can be used but happens
to generate no code then it just outputs no instructions (which is pretty
common for prologues in leaf functions).

The port seems to hedge its bets here.  It has both:

(define_expand "prologue"
  [(const_int 0)]
  "TARGET_PROLOGUE_EPILOGUE"
  "cris_expand_prologue (); DONE;")

and:

void
cris_expand_prologue (void)
{
  [...]
  /* Don't do anything if no prologues or epilogues are wanted.  */
  if (!TARGET_PROLOGUE_EPILOGUE)
return;

which I guess means that the HAVE_prologue condition wasn't being
consistently tested.  Now that it is: is -mno-prologue-epilogue
just supposed to generate empty prologues and epilogues, as implied
by the cris.c code?  If so then removing the conditions on "prologue"
and "epilogue" should work.  If not, then which of the targetm.have_prologue ()
etc. conditions do you need to be true for -mno-prologue-epilogue?

(You have the distinction of having the only port with conditional
prologue and epilogue patterns. :-))

Thanks,
Richard


Re: [patch, wwwdocs, committed] Document -Winteger-division for Fortran

2015-07-01 Thread Gerald Pfeifer
On Wed, 1 Jul 2015, Thomas Koenig wrote:
> I just committed the following patch to the WWW docs.

Thanks.  In the description, are the integers constants truncated
or (the result of) the division?

> An error was reported by Gerald's script, but that seems to have 
> been spurious.  At least, there was no error on revalidation.

Sorry about that!  This happens perhaps once a year and I believe
is due to a server or connection timeout somewhere.  Your change
and the page per see indeed appear fine.

erald


Re: [patch, wwwdocs, committed] Document -Winteger-division for Fortran

2015-07-01 Thread Steve Kargl
On Wed, Jul 01, 2015 at 11:39:09PM +0200, Gerald Pfeifer wrote:
> On Wed, 1 Jul 2015, Thomas Koenig wrote:
> > I just committed the following patch to the WWW docs.
> 
> Thanks.  In the description, are the integers constants truncated
> or (the result of) the division?
> 

The result is truncated.

real x
x = 4/5 
end

is truncated to 'x = 0'.  The remainder of 4 is tossed.

-- 
Steve


Re: [gomp4] Allow parameter declarations with deviceptr

2015-07-01 Thread Cesar Philippidis
On 07/01/2015 02:25 PM, James Norris wrote:

> This patch allows parameter declarations to be used as
> arguments to deviceptr for C and C++.

Does this fix an existing failure? If not, can you please add a new test
case?

Thanks,
Cesar



Re: [PATCH] PR fortran/56520 -- Special case unary minus/plus

2015-07-01 Thread Jerry DeLisle
On 07/01/2015 10:53 AM, Steve Kargl wrote:
> The attached patch special cases unary minus/plus when
> gfotran tries to match a function keyword in a mangled
> statement.  The testcase contains examples, but for
> context consider 'c = exp(-a) )' where the final ')'
> is erronous.  gfortran is trying to match a keyword
> such as 'c = exp(x=-a)' so it expects the character
> after the '(' to be in [a-z] or '_'.  Prior to this
> patch, gfortran would do
> 
> % gfc -c sd.f90
> sd.f90:8:13:
> 
>  c = exp(-a) )! dg-error { "Unclassifiable statement" }
>  1
> Error: Invalid character in name at (1)
> 
> with the patch gfortran will instead issue
> 
> % gfc -c sd.f90
> sd.f90:8:4:
> 
>  c = exp(-a) )! dg-error { "Unclassifiable statement" }
> 1
> Error: Unclassifiable statement at (1)
> 
> It can be debated that the new error message isn't much better
> than old.  I don't care to enter into such a debate, so will 
> ignore comments complaining the new meesage isn't much of an
> improvement over the old.
> 
> Regression tested on trunk.  Ok to commit?
> 

Yes OK. I agree we should not quibble over the error message as long as it is
not misleading.

Thanks,

Jerry


RE: [Patch,tree-optimization]: Add new path Splitting pass on tree ssa representation

2015-07-01 Thread Ajit Kumar Agarwal


-Original Message-
From: Joseph Myers [mailto:jos...@codesourcery.com] 
Sent: Wednesday, July 01, 2015 3:48 AM
To: Ajit Kumar Agarwal
Cc: l...@redhat.com; GCC Patches; Vinod Kathail; Shail Aditya Gupta; Vidhumouli 
Hunsigida; Nagaraju Mekala
Subject: Re: [Patch,tree-optimization]: Add new path Splitting pass on tree ssa 
representation

On Tue, 30 Jun 2015, Ajit Kumar Agarwal wrote:

> * gcc/common.opt: Add the new flag ftree-path-split.

>>All options need documenting in invoke.texi.

Sure.
> +#include "tm.h"

>>Why?  Does some other header depend on this, or are you using a target macro?

I am not using any target macro. There are many header files that includes the 
tm.h and also there are many tree-ssa optimization
files that have included  "tm.h"  listing some of them tree-ssa-threadupdate.c  
tree-vrp.c ,  tree-ssa-threadedge.c.

Thanks & Regards
Ajit
--
Joseph S. Myers
jos...@codesourcery.com


Re: C++ PATCH to change default dialect to C++14

2015-07-01 Thread Jim Wilson
On 07/01/2015 11:26 AM, Jason Merrill wrote:
> I've been threatening to do this for a couple of months, and now that
> the regressions are under control I think it's time.  This patch changes
> the default C++ dialect to C++14.
> 
> Tested x86_64-pc-linux-gnu, applying to trunk.

This causes a build failure on Ubuntu 14.04 LTS (Trusty) for x86_64 and
armhf and probably others.  All of the graphite*.c files fail with
/home/wilson/FOSS/GCC/X-palantir/prev-x86_64-unknown-linux-gnu/libstdc++-v3/include/cstddef:51:11:
error: ‘::max_align_t’ has not been declared
   using ::max_align_t;

This is a known gmp problem, documented in PR56019 and in
https://gcc.gnu.org/gcc-4.9/porting_to.html
near the bottom where it discusses cstddef.h changes.  Except the
cstddef.h changes didn't matter until C++11 or later became the default.

This is apparently fixed in gmp 6.0.0.  I haven't had a chance to try
that yet.  The prereqs section on doc/install.texi says we need gmp
4.3.2 or later, so it appears that this needs to change too.

This is maybe only a problem if you have the isl libraries installed.

Jim



Re: [PATCH, CHKP, PR middle-end/66568] Fix internal compiler error: in expand_expr_addr_expr_1

2015-07-01 Thread H.J. Lu
On Thu, Jun 18, 2015 at 3:16 AM, Ilya Enkovich  wrote:
> Hi,
>
> Currently return statement with no bounds in instrumented function causes 
> ICE.  This patch uses zero bounds in such cases instead.  Bootstrapped and 
> regtested for x86_64-unknown-linux-gnu.  Applied to trunk.  Is it OK for 
> gcc-5-branch?
>

> diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr66568.c 
> b/gcc/testsuite/gcc.target/i386/mpx/pr66568.c
> new file mode 100644
> index 000..d7bb9f6
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/i386/mpx/pr66568.c
> @@ -0,0 +1,10 @@
> +/* { dg-do compile } */
> +/* { dg-require-effective-target fpic } */
> +/* { dg-options "-O2 -fcheck-pointer-bounds -mmpx -O2 -fPIC" } */
> +
> +int a, b, c;
> +void *set_test () {
> +  if (b)
> +a ? exit (0) : exit (1);
> +  b = c;
> +}

I checked in this patch to add a prototype for exit.


H.J.
Index: ChangeLog
===
--- ChangeLog (revision 225294)
+++ ChangeLog (working copy)
@@ -1,3 +1,7 @@
+2015-07-01  H.J. Lu  
+
+ * gcc.target/i386/mpx/pr66568.c (exit): New prototype.
+
 2015-07-01  Jason Merrill  

  * lib/target-supports.exp (cxx_default): Set to C++14.
Index: gcc.target/i386/mpx/pr66568.c
===
--- gcc.target/i386/mpx/pr66568.c (revision 225294)
+++ gcc.target/i386/mpx/pr66568.c (working copy)
@@ -2,6 +2,7 @@
 /* { dg-require-effective-target fpic } */
 /* { dg-options "-O2 -fcheck-pointer-bounds -mmpx -O2 -fPIC" } */

+extern void exit (int);
 int a, b, c;
 void *set_test () {
   if (b)


-- 
H.J.


Re: C++ PATCH to change default dialect to C++14

2015-07-01 Thread Jason Merrill

On 07/02/2015 12:10 AM, Jim Wilson wrote:

This is a known gmp problem, documented in PR56019 and in
 https://gcc.gnu.org/gcc-4.9/porting_to.html
near the bottom where it discusses cstddef.h changes.


This document also says that "A workaround until libraries get updated 
is to include  or  before any headers from that library."


Can you try modifying the graphite* files accordingly?

Thanks,
Jason



  1   2   >