Re: [PATCH] rs6000: Follow up for signed integer overflow fix

2014-11-20 Thread Jakub Jelinek
On Thu, Nov 20, 2014 at 07:41:43PM +0100, Markus Trippelsdorf wrote:
> 2014-11-20  Markus Trippelsdorf  
> 
>   * config/rs6000/rs6000.c (includes_rldic_lshift_p): Cast 0 to unsigned.
>   (includes_rldicr_lshift_p): Likewise.
> 
> diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
> index a9604cf3fa97..d7958b33ba1a 100644
> --- a/gcc/config/rs6000/rs6000.c
> +++ b/gcc/config/rs6000/rs6000.c
> @@ -16197,10 +16197,10 @@ includes_rldic_lshift_p (rtx shiftop, rtx andop)
>unsigned HOST_WIDE_INT c, lsb, shift_mask;
>  
>c = INTVAL (andop);
> -  if (c == 0 || c == ~0)
> +  if (c == 0 || c == ~(unsigned HOST_WIDE_INT) 0)
>   return 0;
>  
> -  shift_mask = ~0;
> +  shift_mask = ~(unsigned HOST_WIDE_INT) 0;
>shift_mask <<= INTVAL (shiftop);
>  
>/* Find the least significant one bit.  */
> @@ -16235,7 +16235,7 @@ includes_rldicr_lshift_p (rtx shiftop, rtx andop)
>  {
>unsigned HOST_WIDE_INT c, lsb, shift_mask;
>  
> -  shift_mask = ~0;
> +  shift_mask = ~(unsigned HOST_WIDE_INT) 0;
>shift_mask <<= INTVAL (shiftop);
>c = INTVAL (andop);

You could use ~HOST_WIDE_INT_UC (0) in all the 3 cases.

Jakub


Re: [PATCH] Fix ICE with non-lvalue vector subscripts and make sure non-lvalue vector subscripts aren't used as lvalues (PR target/63764)

2014-11-20 Thread Richard Henderson
On 11/20/2014 07:09 PM, Jakub Jelinek wrote:
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> 
> 2014-11-20  Jakub Jelinek  
> 
>   PR target/63764
> c-family/
>   * c-common.h (convert_vector_to_pointer_for_subscript): Change
>   return type to bool.
>   * c-common.c: Include gimple-expr.c.
>   (convert_vector_to_pointer_for_subscript): Change return type to
>   bool.  If *vecp is not lvalue_p and has VECTOR_TYPE, return true
>   and copy it into a TARGET_EXPR and use that instead of *vecp
>   directly.
> c/
>   * c-typeck.c (build_array_ref): Adjust
>   convert_vector_to_pointer_for_subscript caller.  If it returns true,
>   call non_lvalue_loc on the result.
> cp/
>   * typeck.c (cp_build_array_ref): Adjust
>   convert_vector_to_pointer_for_subscript caller.  If it returns true,
>   call non_lvalue_loc on the result.
> testsuite/
>   * c-c++-common/pr63764-1.c: New test.
>   * c-c++-common/pr63764-2.c: New test.

Ok.


r~


Re: [PATCH] rs6000: Follow up for signed integer overflow fix

2014-11-20 Thread Markus Trippelsdorf
On 2014.11.20 at 19:44 +0100, Jakub Jelinek wrote:
> On Thu, Nov 20, 2014 at 07:41:43PM +0100, Markus Trippelsdorf wrote:
> > 2014-11-20  Markus Trippelsdorf  
> > 
> > * config/rs6000/rs6000.c (includes_rldic_lshift_p): Cast 0 to unsigned.
> > (includes_rldicr_lshift_p): Likewise.
> > 
> > diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
> > index a9604cf3fa97..d7958b33ba1a 100644
> > --- a/gcc/config/rs6000/rs6000.c
> > +++ b/gcc/config/rs6000/rs6000.c
> > @@ -16197,10 +16197,10 @@ includes_rldic_lshift_p (rtx shiftop, rtx andop)
> >unsigned HOST_WIDE_INT c, lsb, shift_mask;
> >  
> >c = INTVAL (andop);
> > -  if (c == 0 || c == ~0)
> > +  if (c == 0 || c == ~(unsigned HOST_WIDE_INT) 0)
> > return 0;
> >  
> > -  shift_mask = ~0;
> > +  shift_mask = ~(unsigned HOST_WIDE_INT) 0;
> >shift_mask <<= INTVAL (shiftop);
> >  
> >/* Find the least significant one bit.  */
> > @@ -16235,7 +16235,7 @@ includes_rldicr_lshift_p (rtx shiftop, rtx andop)
> >  {
> >unsigned HOST_WIDE_INT c, lsb, shift_mask;
> >  
> > -  shift_mask = ~0;
> > +  shift_mask = ~(unsigned HOST_WIDE_INT) 0;
> >shift_mask <<= INTVAL (shiftop);
> >c = INTVAL (andop);
> 
> You could use ~HOST_WIDE_INT_UC (0) in all the 3 cases.

Or better still HOST_WIDE_INT_M1U.

-- 
Markus


Re: [PATCH] Fix ICEs in simplify_immed_subreg on OImode/XImode subregs (PR target/63910)

2014-11-20 Thread Richard Sandiford
Jakub Jelinek  writes:
> On Wed, Nov 19, 2014 at 02:23:47PM -0800, Mike Stump wrote:
>> On Nov 19, 2014, at 1:57 PM, Jakub Jelinek  wrote:
>> > Though, following patch is just fine for me too, I don't think it will
>> > make a significant difference:
>> 
>> This version is fine by me.
>
> Richard, are you ok with that too?

Yeah, looks good to me, thanks.

Richard


Re: [PATCH] Fix ubsan and C++14 constexpr ICEs (PR sanitizer/63956)

2014-11-20 Thread Marek Polacek
On Thu, Nov 20, 2014 at 06:27:25PM +0100, Jakub Jelinek wrote:
> On Thu, Nov 20, 2014 at 06:14:52PM +0100, Marek Polacek wrote:
> > +  if (!current_function_decl && is_ubsan_builtin_p (fun))
> > +return void_node;
> > +
> 
> I don't understand the !current_function_decl here.
 
That is because I only wanted to ignore ubsan builtins in constexpr
functions (in constexpr context), to not to break shift-5.c, where
for C++ we expect 
error: '' is not a constant expression

But that sounds dubious to me now, so I went ahead and did away with
that.  Which means that compile-time diagnostics is now the same no
matter whether -fsanitize=undefined is on.

> Also, looking at is_ubsan_builtin_p definition, I'd say
> it should IMHO at least test DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
> before comparing the function name, you can declare
> __builtin_ubsan_foobarbaz () and use it and it won't be a builtin.
 
Um, ok.

> As for the testcase, I'd like to understand if C++ FE should reject
> the constexpr functions when used with arguments that trigger undefined
> behavior.  But certainly the behavior should not depend on whether
> -fsanitize=undefined or not.

With this patch we generate the same compile-time diagnostics with
-fsanitize=undefined as without it in the new testcase.

> Also, what is the reason for constexpr call flows off the end errors?
> Shouldn't that be avoided if any error is found while interpreting the
> function?

Maybe.  Short testcase:

constexpr int
foo (int i, int j)
{
  if (i != 42)
i /= j;
  return i;
}
constexpr int i = foo (2, 0);

The reason is that we issue "flows off the end" if the result of a constexpr
function is NULL_TREE - and in this case it was.
Perhaps we should set ctx->quiet if an error is encountered during evaluation
of a constexpr function?

Here's updated patch.  Thanks.

2014-11-20  Marek Polacek  

PR sanitizer/63956
* ubsan.c (is_ubsan_builtin_p): Check also built-in class.
cp/
* constexpr.c: Include ubsan.h.
(cxx_eval_call_expression): Bail out for IFN_UBSAN_{NULL,BOUNDS}
internal functions and for ubsan builtins.
* error.c: Include internal-fn.h.
(dump_expr): Add printing of internal functions.
testsuite/
* c-c++-common/ubsan/shift-5.c: Don't use -w for C++.  Change
dg-error to dg-warning for C++.
* g++.dg/ubsan/div-by-zero-1.C: Don't use -w.  Change dg-error
to dg-warning.
* g++.dg/ubsan/pr63956.C: New test.

diff --git gcc/cp/constexpr.c gcc/cp/constexpr.c
index 2678223..32f07be 100644
--- gcc/cp/constexpr.c
+++ gcc/cp/constexpr.c
@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimplify.h"
 #include "builtins.h"
 #include "tree-inline.h"
+#include "ubsan.h"
 
 static bool verify_constant (tree, bool, bool *, bool *);
 #define VERIFY_CONSTANT(X) \
@@ -1151,6 +1152,16 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree 
t,
   constexpr_call *entry;
   bool depth_ok;
 
+  if (fun == NULL_TREE)
+switch (CALL_EXPR_IFN (t))
+  {
+  case IFN_UBSAN_NULL:
+  case IFN_UBSAN_BOUNDS:
+   return void_node;
+  default:
+   break;
+  }
+
   if (TREE_CODE (fun) != FUNCTION_DECL)
 {
   /* Might be a constexpr function pointer.  */
@@ -1171,6 +1182,10 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree 
t,
 }
   if (DECL_CLONED_FUNCTION_P (fun))
 fun = DECL_CLONED_FUNCTION (fun);
+
+  if (is_ubsan_builtin_p (fun))
+return void_node;
+
   if (is_builtin_fn (fun))
 return cxx_eval_builtin_function_call (ctx, t,
   addr, non_constant_p, overflow_p);
diff --git gcc/cp/error.c gcc/cp/error.c
index 76f86cb..09789ad 100644
--- gcc/cp/error.c
+++ gcc/cp/error.c
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-pretty-print.h"
 #include "c-family/c-objc.h"
 #include "ubsan.h"
+#include "internal-fn.h"
 
 #include // For placement-new.
 
@@ -2037,6 +2038,14 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
tree fn = CALL_EXPR_FN (t);
bool skipfirst = false;
 
+   /* Deal with internal functions.  */
+   if (fn == NULL_TREE)
+ {
+   pp_string (pp, internal_fn_name (CALL_EXPR_IFN (t)));
+   dump_call_expr_args (pp, t, flags, skipfirst);
+   break;
+ }
+
if (TREE_CODE (fn) == ADDR_EXPR)
  fn = TREE_OPERAND (fn, 0);
 
diff --git gcc/testsuite/c-c++-common/ubsan/shift-5.c 
gcc/testsuite/c-c++-common/ubsan/shift-5.c
index 6f9c52a..f8a88e0 100644
--- gcc/testsuite/c-c++-common/ubsan/shift-5.c
+++ gcc/testsuite/c-c++-common/ubsan/shift-5.c
@@ -1,32 +1,43 @@
 /* { dg-do compile } */
-/* { dg-options "-fsanitize=shift -w" } */
+/* { dg-options "-fsanitize=shift -w" { target c } } */
+/* { dg-options "-fsanitize=shift" { target c++ } } */
 /* { dg-shouldfail "ubsan" } */
 

[patch c++]: Fix PR/53904

2014-11-20 Thread Kai Tietz
Hello,

this issue fixes a type-overflow issue caused by trying to cast a UHWI
via tree_to_shwi.
As soon as value gets larger then SHWI_MAX, we get an error for it.
So we need to cast it
via tree_to_uhwi, and then casting it to the signed variant.

ChangeLog

2014-11-20  Kai Tietz  

PR c++/63904
* constexpr.c (cxx_eval_vec_init_1): Avoid
type-overflow issue.

2014-11-20  Kai Tietz  

PR c++/63904
* g++.dg/cpp0x/pr63904.C: New.


Regression tested for x86_64-unknown-linux-gnu.  Ok for apply?

Regards,
Kai

Index: gcc/gcc/cp/constexpr.c
===
--- gcc.orig/gcc/cp/constexpr.c
+++ gcc/gcc/cp/constexpr.c
@@ -2006,12 +2050,12 @@ cxx_eval_vec_init_1 (const constexpr_ctx
  bool *non_constant_p, bool *overflow_p)
 {
   tree elttype = TREE_TYPE (atype);
-  int max = tree_to_shwi (array_type_nelts (atype));
+  HOST_WIDE_INT max = (HOST_WIDE_INT) tree_to_uhwi (array_type_nelts (atype));
   verify_ctor_sanity (ctx, atype);
   vec **p = &CONSTRUCTOR_ELTS (ctx->ctor);
   vec_alloc (*p, max + 1);
   bool pre_init = false;
-  int i;
+  HOST_WIDE_INT i;

   /* For the default constructor, build up a call to the default
  constructor of the element type.  We only need to handle class types
Index: gcc/gcc/testsuite/g++.dg/cpp0x/pr63904.C
===
--- /dev/null
+++ gcc/gcc/testsuite/g++.dg/cpp0x/pr63904.C
@@ -0,0 +1,13 @@
+// { dg-do compile { target c++11 } }
+
+template
+struct foo {
+constexpr foo() : a() {}
+int a[N];
+};
+
+int main() {
+  foo< (foo<1>{}).a[0] > f;
+  return 0;
+}
+


[patch] Flatten streamer header files Pt. 1

2014-11-20 Thread Michael Collison
This is a part one of two part patch that flattens gimple-streamer.h, 
lto-streamer.h and tree-streamer.h. This work is part of the GCC 
Re-Architecture effort being led by Andrew MacLeod.


In gimple-streamer.h I moved all exports for gimple-streamer-in.c to a 
new file gimple-streamer-in.h. I also moved all exports for 
gimple-streamer-out.c to a new file gimple-streamer-out.h. Finally 
because gimple-streamer.h only contained exports for 
gimple-streamer-in.c and gimple-streamer-out.c I removed the file.


In lto-streamer.h I moved all exports for lto-streamer-in.c to a new 
file lto-streamer-in.h. I also moved all exports for lto-streamer-out.c 
to a new file gimple-streamer-out.h.


In tree-streamer.h I moved all exports for tree-streamer-in.c to a new 
file tree-streamer-in.h. I also moved all exports for 
tree-streamer-out.c to a new file tree-streamer-out.h.


As a result of the flattening I had to add new include files to gengtype.c.

I performed a full bootstrap with all languages on x86-linux. I also 
bootstrapped on all targets listed in contrib/config-list.mk with c and 
c++ enabled.


Is this okay for trunk?

2014-11-19  Michael Collison  

* gengtype.c (open_base_files): Include gcov-io.h, plugin-api.h,
diagnostic.h when generating gengytpe.c.
* gimple-streamer.h : Remove file and move prototypes to new files
gimple-streamer-in.h and gimple-streamer-out.h.
* gimple-streamer-in.h: New file to contain prototypes for functions
exported from gimple-streamer-in.c.
* gimple-streamer-out.h: New file to contain prototypes for functions
exported from gimple-streamer-out.c.
* lto-streamer.h: Flatten by removing all include files.
Move prototype for lto-streamer-in.c to new file lto-streamer-in.h.
Move prototypes for lto-streamer-out.c to new file lto-streamer-out.h.
* lto-streamer-in.h: New file to contain exports from file 
lto-streamer-in.c.
* lto-streamer-out.h: New file to contain exports from file 
lto-streamer-out.c.

* tree-streamer.h: Flatten by removing all include files.
Move prototypes for tree-streamer-in.c tp new file tree-streamer-in.h.
Move prototypes for tree-streamer-out.c tp new file tree-streamer-out.h
* tree-streamer-in.h: New file to contain exports from file 
tree-streamer-in.c.
* tree-streamer-out.h: New file to contain exports from file 
tree-streamer-out.c.


--
Michael Collison
Linaro Toolchain Working Group
michael.colli...@linaro.org

diff -cr --new-file '--exclude=.git' gcc-trunk/gcc/gengtype.c 
gcc-trunk-streamer/gcc/gengtype.c
*** gcc-trunk/gcc/gengtype.c2014-11-05 01:50:41.201568692 -0700
--- gcc-trunk-streamer/gcc/gengtype.c   2014-11-11 15:29:34.434699522 -0700
***
*** 1841,1849 
"tree-ssa-loop.h", "tree-ssa-loop-ivopts.h", "tree-ssa-loop-manip.h",
"tree-ssa-loop-niter.h", "tree-into-ssa.h", "tree-dfa.h", 
"tree-ssa.h", "reload.h", "cpp-id-data.h", "tree-chrec.h",
!   "except.h", "output.h",  "cfgloop.h", "target.h", "lto-streamer.h",
"target-globals.h", "ipa-ref.h", "cgraph.h", "ipa-prop.h", 
!   "ipa-inline.h", "dwarf2out.h", NULL
  };
  const char *const *ifp;
  outf_p gtype_desc_c;
--- 1841,1850 
"tree-ssa-loop.h", "tree-ssa-loop-ivopts.h", "tree-ssa-loop-manip.h",
"tree-ssa-loop-niter.h", "tree-into-ssa.h", "tree-dfa.h", 
"tree-ssa.h", "reload.h", "cpp-id-data.h", "tree-chrec.h",
!   "except.h", "output.h",  "cfgloop.h", "target.h",
!   "gcov-io.h", "plugin-api.h", "diagnostic.h",
"target-globals.h", "ipa-ref.h", "cgraph.h", "ipa-prop.h", 
!   "ipa-inline.h", "lto-streamer.h","dwarf2out.h", NULL
  };
  const char *const *ifp;
  outf_p gtype_desc_c;
diff -cr --new-file '--exclude=.git' gcc-trunk/gcc/gimple-streamer.h 
gcc-trunk-streamer/gcc/gimple-streamer.h
*** gcc-trunk/gcc/gimple-streamer.h 2014-11-05 01:50:41.209568692 -0700
--- gcc-trunk-streamer/gcc/gimple-streamer.h1969-12-31 17:00:00.0 
-0700
***
*** 1,42 
- /* Data structures and functions for streaming GIMPLE.
- 
-Copyright (C) 2011-2014 Free Software Foundation, Inc.
-Contributed by Diego Novillo 
- 
- This file is part of GCC.
- 
- GCC is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 3, or (at your option) any later
- version.
- 
- GCC is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- for more details.
- 
- You should have received a copy of the GNU General Public License
- along with GCC; see the file COPYING3.  If not see
- .  */
- 
- #ifndef GCC_GIMPLE_STREAMER_H
- #define GCC_GIMPLE_STREAMER_H
- 
- #include "hashtab.h"
- #include "hash-set.h"
- #inclu

[patch] Flatten streamer header files Pt. 2

2014-11-20 Thread Michael Collison


This is a final part  of two part patch that flattens gimple-streamer.h, 
lto-streamer.h and tree-streamer.h.


This patch modifies all source files that previously included the three 
streamer header files to now include the header file(s) that contains 
the exports that it needs.


I performed a full bootstrap with all languages on x86-linux. I also 
bootstrapped on all targets listed in contrib/config-list.mk with c and 
c++ enabled.


Is this okay for trunk?

2014-11-19  Michael Collison  

* builtins.c: Remove include of lto-streamer.h.
Include plugin-api.h and gcov-io.h
* cgraph.h: Include gcov-io.h and lto-streamer-in.h.
* config/darwin.c: Inlude gcov-io.h.
* config/i386/winnt.c: ditto.
* data-streamer-in.c: ditto
* data-streamer.c: Include gcov-io.h and diagnostic.h.
* data-streamer-out.c: ditto.
* gimple-streamer-in.c: Include gcov-io.h, streamer-hooks.h, 
tree-streamer-in.h,

lto-streamer-in.h, and gimple-streamer-in.h.
Remove include of gimple-streamer.h.
* gimple-streamer-out.c: Include gcov-io.h, diagnostic.h, 
gimple-streamer-out.h,

and streamer-hooks.h.
Remove include of gimple-streamer.h.
* ipa-chkp.c: Include plugin-api.h, gcov-io.h, hash-map.h.h, and 
diagnostic.h.

Remove include of lto-streamer.h.
* ipa-icf.c: Include diagnostic.h, lto-streamer-in.h and 
lto-streamer-out.h.

* ipa-icf-gimple.c: Include gcov-io.h and diagnostic.h.
* ipa-inline-analysis.c: Include lto-streamer-in.h, 
lto-streamer-out.h, and

streamer-hooks.h.
* ipa-polymorphic-call.c: Include gcov-io.h.
* ipa-pure-const.c: ditto.
* ipa-reference.c: ditto.
* ipa-utils.c: ditto.
* ipa-profile.c: Include gcov-io.h and diagnostic.h.
* ipa-prop.c: Include gcov-io.h, plugin-api.h, lto-streamer-in.h,
lto-streamer-in.h, lto-streamer-out.h, and streamer-hooks.h.
* lto/lto.c: Include gcov-io.h, target.h, and lto-streamer-in.h.
* lto/lto-lang.c: Include gcov-io.h.
* lto/lto-object.c: ditto.
* lto/lto-partition.c: Include gcov-io.h and diagnostic.h.
* lto/lto-symtab.c: Include gcov-io.h and target.h.
* lto-cgraph.c: Include gcov-io.h, lto-streamer-in.h and 
lto-streamer-out.h,

and streamer-hooks.h,
* lto-compress.c: Include gcov-io.h.
* lto-opts.c: ditto.
* lto-section-in.c: ditto.
* lto-sectio-out.c: Include gcov-io.h and diagnostic.h.
* lto-streamer.c: Include gcov-io.h, lto-streamer-in.h, and 
lto-streamer-out.h.

* lto-streamer-in.c: Include gcov-io.h, target.h, gimple-streamer-in.h,
lto-streamer-in.h and tree-strreamer-in.h.
(lto-input_tree_ref): Add static prototype and make definition static.
(lto_input_data_block): Delete unused function.
* lto-streamer-out.c: Include gcov-io.h, target.h, 
gimple-streamer-out.h

and tree-streamer-out.h.
Remove include of gimple-streamer.h.
(lto_output_decl_state_streams): Add static prototype and make 
definition static.
(lto_output_decl_state_refs): Add static prototype and make 
definition static.

* opts-global.c: Include gcov-io.h.
* passes.c: Include lto-streamer-out.h.
* symtab.c: Include gcov-io.h and target.h.
* tree-chkp.c: Include plugin-api.h and gcov-io.h.
Remove include of lto-streamer.h.
* tree-streamer.c: Include gcov-io.h, diagnostic.h and lto-streamer.h.
* tree-streamer-in.c: Include gcov-io.h, target.h, and 
lto-streamer-in.h.

* tree-streamer-out.c: Include gcov-io.h, target.h, and lto-streamer.h.
* varpool.c: Include gcov-io.h and lto-streamer-in.h.

--
Michael Collison
Linaro Toolchain Working Group
michael.colli...@linaro.org

diff -cr --new-file '--exclude=.git' gcc-trunk/gcc/builtins.c 
gcc-trunk-streamer/gcc/builtins.c
*** gcc-trunk/gcc/builtins.c2014-11-05 14:33:13.751782986 -0700
--- gcc-trunk-streamer/gcc/builtins.c   2014-11-10 22:57:43.999819384 -0700
***
*** 67,73 
  #include "ubsan.h"
  #include "cilk.h"
  #include "ipa-ref.h"
! #include "lto-streamer.h"
  #include "cgraph.h"
  #include "tree-chkp.h"
  #include "rtl-chkp.h"
--- 67,74 
  #include "ubsan.h"
  #include "cilk.h"
  #include "ipa-ref.h"
! #include "plugin-api.h"
! #include "gcov-io.h"
  #include "cgraph.h"
  #include "tree-chkp.h"
  #include "rtl-chkp.h"
diff -cr --new-file '--exclude=.git' gcc-trunk/gcc/cgraph.c 
gcc-trunk-streamer/gcc/cgraph.c
*** gcc-trunk/gcc/cgraph.c  2014-11-05 14:33:13.759782986 -0700
--- gcc-trunk-streamer/gcc/cgraph.c 2014-11-11 13:21:51.530328659 -0700
***
*** 70,76 
--- 70,78 
  #include "diagnostic-core.h"
  #include "rtl.h"
  #include "ipa-utils.h"
+ #include "gcov-io.h"
  #include "lto-streamer.h"
+ #include "lto-streamer-in.h"
  #include "alloc-pool.h"
  #include "ipa-prop.h"
  #include "ipa-inline.h"
diff -cr --new-file '--exclude=.git' gcc-trunk/gcc/config/darwin.c 
gcc-trunk-streamer/gcc/config/darwin.c
*** gcc-trunk/gcc/config/darwin.c   2014-11-05 01:50:40.373568652 -0700
--- gcc-t

Re: [patch] Flatten streamer header files Pt. 1

2014-11-20 Thread Andrew MacLeod

On 11/20/2014 03:05 PM, Michael Collison wrote:
This is a part one of two part patch that flattens gimple-streamer.h, 
lto-streamer.h and tree-streamer.h. This work is part of the GCC 
Re-Architecture effort being led by Andrew MacLeod.


In gimple-streamer.h I moved all exports for gimple-streamer-in.c to a 
new file gimple-streamer-in.h. I also moved all exports for 
gimple-streamer-out.c to a new file gimple-streamer-out.h. Finally 
because gimple-streamer.h only contained exports for 
gimple-streamer-in.c and gimple-streamer-out.c I removed the file.


In lto-streamer.h I moved all exports for lto-streamer-in.c to a new 
file lto-streamer-in.h. I also moved all exports for 
lto-streamer-out.c to a new file gimple-streamer-out.h.


In tree-streamer.h I moved all exports for tree-streamer-in.c to a new 
file tree-streamer-in.h. I also moved all exports for 
tree-streamer-out.c to a new file tree-streamer-out.h.


As a result of the flattening I had to add new include files to 
gengtype.c.


I performed a full bootstrap with all languages on x86-linux. I also 
bootstrapped on all targets listed in contrib/config-list.mk with c 
and c++ enabled.


Is this okay for trunk?



Yes, so thats the question...   Flattening ought not affect code 
generation nor anything else since its just a simple restructure of 
includes.


We could maintain these in a branch, but due to the nature of the 
changes, they can bit rot really quickly so its nicer to get them into 
trunk (especially with other large changes still going in)


So the question to the maintainers is whether its permissible to do a 
bit of flattening into the early parts of stage 3, or whether you'd 
rather it stay on a branch until next stage 1.


Andrew


Re: [patch] Warn on undefined loop exit

2014-11-20 Thread Marek Polacek
On Thu, Nov 20, 2014 at 05:27:35PM +0100, Richard Biener wrote:
> +  if (exit_warned && problem_stmts != vNULL)
> +{
> 
> !problem_stmts.empty ()

/home/marek/src/gcc/gcc/tree-ssa-loop-niter.c: In function ‘void 
maybe_lower_iteration_bound(loop*)’:
/home/marek/src/gcc/gcc/tree-ssa-loop-niter.c:3420:38: error: ‘struct 
vec’ has no member named ‘empty’
if (exit_warned && !problem_stmts.empty ())
  ^
make: *** [tree-ssa-loop-niter.o] Error 1

I'm applying the following.

2014-11-20  Marek Polacek  

* tree-ssa-loop-niter.c (maybe_lower_iteration_bound): Fix typo.

diff --git gcc/tree-ssa-loop-niter.c gcc/tree-ssa-loop-niter.c
index 8ba365c..d17227f 100644
--- gcc/tree-ssa-loop-niter.c
+++ gcc/tree-ssa-loop-niter.c
@@ -3417,7 +3417,7 @@ maybe_lower_iteration_bound (struct loop *loop)
}
}
 
- if (exit_warned && !problem_stmts.empty ())
+ if (exit_warned && !problem_stmts.is_empty ())
{
  gimple stmt;
  int index;

Marek


Re: [patch] Warn on undefined loop exit

2014-11-20 Thread Andrew Stubbs

On 20/11/14 16:27, Richard Biener wrote:

If it's really duplicated code can you split it out to a function?

+  if (OPT_Waggressive_loop_optimizations)
+{

this doesn't do what you think it does ;)  The variable to check is
warn_aggressive_loop_optimizations.

+  if (exit_warned && problem_stmts != vNULL)
+{

!problem_stmts.empty ()

Otherwise it looks ok.


I've committed the attached. I'll work up a patch to dedup the condition 
shortly.


Andrew

2014-11-20  Andrew Stubbs  

	gcc/
	* tree-ssa-loop-niter.c (maybe_lower_iteration_bound): Warn if a loop
	condition would be removed due to undefined behaviour.

	gcc/testsuite/
	* gcc.dg/undefined-loop-1.c: New file.
	* gcc.dg/undefined-loop-2.c: New file.
---
 gcc/testsuite/gcc.dg/undefined-loop-1.c |   18 
 gcc/testsuite/gcc.dg/undefined-loop-2.c |   22 +++
 gcc/tree-ssa-loop-niter.c   |   46 +++
 3 files changed, 86 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/undefined-loop-1.c
 create mode 100644 gcc/testsuite/gcc.dg/undefined-loop-2.c

diff --git a/gcc/testsuite/gcc.dg/undefined-loop-1.c b/gcc/testsuite/gcc.dg/undefined-loop-1.c
new file mode 100644
index 000..80260cc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/undefined-loop-1.c
@@ -0,0 +1,18 @@
+/* Check that loops whose final iteration is undefined are detected.  */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Waggressive-loop-optimizations" } */
+
+void doSomething(char);
+
+char array[5];
+
+void
+foo (void)
+{
+  int i;
+  for (i = 0;
+   array[i]  /* { dg-message "note: possible undefined statement is here" } */
+   && i < 5; /* { dg-warning "loop exit may only be reached after undefined behavior" } */
+   i++)
+doSomething(array[i]);
+}
diff --git a/gcc/testsuite/gcc.dg/undefined-loop-2.c b/gcc/testsuite/gcc.dg/undefined-loop-2.c
new file mode 100644
index 000..dbea62c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/undefined-loop-2.c
@@ -0,0 +1,22 @@
+/* Check that loops whose final iteration is undefined are detected.  */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Waggressive-loop-optimizations" } */
+
+void doSomething(char);
+
+char array1[5];
+char array2[5];
+
+void
+foo (int p)
+{
+  int i;
+  for (i=0;
+   (p
+? array1[i]  /* { dg-message "note: possible undefined statement is here" } */
+: array2[i]) /* { dg-message "note: possible undefined statement is here" } */
+   && i < 5  /* { dg-warning "loop exit may only be reached after undefined behavior" } */
+   && i < 100;   /* { dg-warning "loop exit may only be reached after undefined behavior" } */
+   i++)
+doSomething(array1[i]);
+}
diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c
index fd32d28..486e1a4 100644
--- a/gcc/tree-ssa-loop-niter.c
+++ b/gcc/tree-ssa-loop-niter.c
@@ -3289,6 +3289,7 @@ maybe_lower_iteration_bound (struct loop *loop)
   struct nb_iter_bound *elt;
   bool found_exit = false;
   vec queue = vNULL;
+  vec problem_stmts = vNULL;
   bitmap visited;
 
   /* Collect all statements with interesting (i.e. lower than
@@ -3334,6 +3335,7 @@ maybe_lower_iteration_bound (struct loop *loop)
 	  if (not_executed_last_iteration->contains (stmt))
 	{
 	  stmt_found = true;
+	  problem_stmts.safe_push (stmt);
 	  break;
 	}
 	  if (gimple_has_side_effects (stmt))
@@ -3377,9 +3379,53 @@ maybe_lower_iteration_bound (struct loop *loop)
 		 "undefined statement must be executed at the last iteration.\n");
   record_niter_bound (loop, loop->nb_iterations_upper_bound - 1,
 			  false, true);
+
+  if (warn_aggressive_loop_optimizations)
+	{
+	  bool exit_warned = false;
+	  for (elt = loop->bounds; elt; elt = elt->next)
+	{
+	  if (elt->is_exit
+		  && wi::gtu_p (elt->bound, loop->nb_iterations_upper_bound))
+		{
+		  basic_block bb = gimple_bb (elt->stmt);
+		  edge exit_edge = EDGE_SUCC (bb, 0);
+		  struct tree_niter_desc niter;
+
+		  if (!loop_exit_edge_p (loop, exit_edge))
+		exit_edge = EDGE_SUCC (bb, 1);
+
+		  if(number_of_iterations_exit (loop, exit_edge,
+		&niter, false, false)
+		 && integer_onep (niter.assumptions)
+		 && integer_zerop (niter.may_be_zero)
+		 && niter.niter
+		 && TREE_CODE (niter.niter) == INTEGER_CST
+		 && wi::ltu_p (loop->nb_iterations_upper_bound,
+   wi::to_widest (niter.niter)))
+		   {
+		 if (warning_at (gimple_location (elt->stmt),
+ OPT_Waggressive_loop_optimizations,
+ "loop exit may only be reached after undefined behavior"))
+		   exit_warned = true;
+		   }
+		}
+	}
+
+	  if (exit_warned && !problem_stmts.empty ())
+	{
+	  gimple stmt;
+	  int index;
+	  FOR_EACH_VEC_ELT (problem_stmts, index, stmt)
+		inform (gimple_location (stmt),
+			"possible undefined statement is here");
+	}
+  }
 }
+
   BITMAP_FREE (visited);
   queue.release ();
+  problem_stmts.release ();
   delete not_executed_last_i

Re: LTO streaming of TARGET_OPTIMIZE_NODE

2014-11-20 Thread Jan Hubicka
> On 11/20/2014 02:20 PM, Richard Biener wrote:
> >On Thu, 20 Nov 2014, Bernd Schmidt wrote:
> >
> >>On 11/13/2014 05:06 AM, Jan Hubicka wrote:
> >>>this patch adds infrastructure for proper streaming and merging of
> >>>TREE_TARGET_OPTION.
> >>
> >>This breaks the offloading path via LTO since it introduces an 
> >>incompatibility
> >>in LTO format between host and offload machine.
> >>
> >>A very quick patch to fix it is below - the OpenACC testcase I was using 
> >>seems
> >>to be working again with this. Thoughts, suggestions?
> >
> >The offload target needs to have the same target options as the host?
> 
> Not really meaningful I'd think.
> 
> >Are the offload functions marked somehow?  That is, can we avoid
> >setting TREE_TARGET_OPTION on them?
> 
> Well, they are mostly generated automatically by omp-low.c, so
> TREE_TARGET_OPTION wouldn't normally be set anyway. So the field is
> unnecessary, we just can't write it out since the two compilers
> involved disagree on its layout.

I am currently populating TREE_TARGET_OPTION in free lang data that is probably
called after omp-low and incrementally I plan to set it even for newly 
constructed
functions (profiling, ctors etc.) that are built during IPA, so we do not 
really need
to rely on sane global state at link time.
This however has nothing to do with offloading.

Honza

> 
> >Or rather we need to have a
> >default TREE_TARGET_OPTION node for the offload target which we'd
> >need to set - how would you otherwise transfer different offload
> >target options to the offload compile?  How do you transfer
> >offload target options to the offload compile at all?
> 
> ABI options are transferred via the -foffload-abi mechanism. No
> other target options can be transferred.
> 
> >I think this just shows conceptual issues with the LTO approach...
> 
> I don't think running into a few problems demonstrates a conceptual
> problem when it works fine with some fairly small patches.
> 
> 
> Bernd


Re: [PATCH] PR lto/63968: 175.vpr from cpu2000 fails to build with LTO

2014-11-20 Thread Jan Hubicka
> Hello.
> 
> As I reimplemented fibheap to C++ template, Honza told me that replace_key 
> method actually
> supports just decrement operation. Old implementation suppress any feedback 
> if we try to increase key:
> 
> fibheap.c:
> ...
>   /* If we wanted to, we could actually do a real increase by redeleting and
>  inserting. However, this would require O (log n) time. So just bail out
>  for now.  */
>   if (fibheap_comp_data (heap, key, data, node) > 0)
> return NULL;
> ...
> 
> My reimplementation added assert for such kind operation, as this PR shows we 
> try to do increment in reorder-bb.
> Thus, I added fibonacci_heap::replace_key method that can increment key (it 
> deletes the node and new key
> is associated with the node).
> 
> The patch can bootstrap on x86_64-linux-pc and no new regression was 
> introduced.
> I would like to ask someone if the increase operation for bb-reorder is valid 
> or not?

Can you verify that the implementation is correct? I tend to remember that I 
introduced the
lazy incerementation to inliner both for perofrmance and correctness reasons. I 
used to get
odd orders when keys was increased.

Honza
> 
> Thanks,
> Martin

> gcc/ChangeLog:
> 
> 2014-11-20  Martin Liska  
> 
>   * bb-reorder.c (find_traces_1_round): decreate_key is replaced
>   with replace_key method.
>   * fibonacci_heap.h (fibonacci_heap::insert): New argument.
>   (fibonacci_heap::replace_key_data): Likewise.
>   (fibonacci_heap::replace_key): New method that can even increment key,
>   this operation costs O(log N).
>   (fibonacci_heap::extract_min): New argument.
>   (fibonacci_heap::delete_node): Likewise.

> diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c
> index 689d7b6..b568114 100644
> --- a/gcc/bb-reorder.c
> +++ b/gcc/bb-reorder.c
> @@ -644,7 +644,7 @@ find_traces_1_round (int branch_th, int exec_th, 
> gcov_type count_th,
>  (long) bbd[e->dest->index].node->get_key (),
>  key);
>   }
> -   bbd[e->dest->index].heap->decrease_key
> +   bbd[e->dest->index].heap->replace_key
>   (bbd[e->dest->index].node, key);
>   }
>   }
> @@ -812,7 +812,7 @@ find_traces_1_round (int branch_th, int exec_th, 
> gcov_type count_th,
>  e->dest->index,
>  (long) bbd[e->dest->index].node->get_key (), 
> key);
>   }
> -   bbd[e->dest->index].heap->decrease_key
> +   bbd[e->dest->index].heap->replace_key
>   (bbd[e->dest->index].node, key);
>   }
>   }
> diff --git a/gcc/fibonacci_heap.h b/gcc/fibonacci_heap.h
> index ecb92f8..3fce370 100644
> --- a/gcc/fibonacci_heap.h
> +++ b/gcc/fibonacci_heap.h
> @@ -183,20 +183,27 @@ public:
>}
>  
>/* For given NODE, set new KEY value.  */
> -  K decrease_key (fibonacci_node_t *node, K key)
> +  K replace_key (fibonacci_node_t *node, K key)
>{
>  K okey = node->m_key;
> -gcc_assert (key <= okey);
>  
>  replace_key_data (node, key, node->m_data);
>  return okey;
>}
>  
> +  /* For given NODE, decrease value to new KEY.  */
> +  K decrease_key (fibonacci_node_t *node, K key)
> +  {
> +gcc_assert (key <= node->m_key);
> +return replace_key (node, key);
> +  }
> +
>/* For given NODE, set new KEY and DATA value.  */
>V *replace_key_data (fibonacci_node_t *node, K key, V *data);
>  
> -  /* Extract minimum node in the heap. */
> -  V *extract_min ();
> +  /* Extract minimum node in the heap. If RELEASE is specified,
> + memory is released.  */
> +  V *extract_min (bool release = true);
>  
>/* Return value associated with minimum node in the heap.  */
>V *min ()
> @@ -214,12 +221,15 @@ public:
>}
>  
>/* Delete NODE in the heap.  */
> -  V *delete_node (fibonacci_node_t *node);
> +  V *delete_node (fibonacci_node_t *node, bool release = true);
>  
>/* Union the heap with HEAPB.  */
>fibonacci_heap *union_with (fibonacci_heap *heapb);
>  
>  private:
> +  /* Insert new NODE given by KEY and DATA associated with the key.  */
> +  fibonacci_node_t *insert (fibonacci_node_t *node, K key, V *data);
> +
>/* Insert it into the root list.  */
>void insert_root (fibonacci_node_t *node);
>  
> @@ -322,6 +332,15 @@ fibonacci_heap::insert (K key, V *data)
>/* Create the new node.  */
>fibonacci_node *node = new fibonacci_node_t ();
>  
> +  return insert (node, key, data);
> +}
> +
> +/* Insert new NODE given by KEY and DATA associated with the key.  */
> +
> +template
> +fibonacci_node*
> +fibonacci_heap::insert (fibonacci_node_t *node, K key, V *data)
> +{
>/* Set the node's data.  */
>node->m_data = data;
>node->m_key = key;
> @@ -345,17 +364,22 @@ V*
>  fibonacci_heap::replace_key_data (fibonacci_node *node, K key,
>   

Re: PATCH, PR 63965, rs6000, add support for scalar floating point in Altivec registers

2014-11-20 Thread Michael Meissner
This patch fixes the failures in the following tests if --with-cpu is not used
to set the cpu to cpus with vsx enabled (power7/power8):

gcc.target/powerpc/altivec-splat.c
gcc.target/powerpc/pr27158.c

I have built these patches on power7 systems (default cpu = power7, and
power6), power8 systems (default cpu = power8 and power5).  The compilers
bootstrap and do not have regressions.  Are the patches ok to install?

2014-11-20  Michael Meissner  

PR target/63965
* config/rs6000/rs6000.c (rs6000_setup_reg_addr_masks): Do not set
Altivec & -16 mask if the type is not valid for Altivec registers.
(rs6000_secondary_reload_memory): Add support for ((reg + const) +
reg) that occurs during push_reload processing.

* config/rs6000/altivec.md (altivec_mov): Add instruction
alternative for moving constant vectors which are easy altivec
constants to GPRs.  Set the length attribute each of the
alternatives.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meiss...@linux.vnet.ibm.com, phone: +1 (978) 899-4797
Index: gcc/config/rs6000/rs6000.c
===
--- gcc/config/rs6000/rs6000.c  (revision 217802)
+++ gcc/config/rs6000/rs6000.c  (working copy)
@@ -2505,7 +2505,8 @@ rs6000_setup_reg_addr_masks (void)
 
  /* VMX registers can do (REG & -16) and ((REG+REG) & -16)
 addressing on 128-bit types.  */
- if (rc == RELOAD_REG_VMX && GET_MODE_SIZE (m2) == 16)
+ if (rc == RELOAD_REG_VMX && GET_MODE_SIZE (m2) == 16
+ && (addr_mask & RELOAD_REG_VALID) != 0)
addr_mask |= RELOAD_REG_AND_M16;
 
  reg_addr[m].addr_mask[rc] = addr_mask;
@@ -16652,6 +16653,17 @@ rs6000_secondary_reload_memory (rtx addr
}
}
 
+  /* (plus (plus (reg) (constant)) (reg)) is also generated during
+push_reload processing, so handle it now.  */
+  else if (GET_CODE (plus_arg0) == PLUS && REG_P (plus_arg1))
+   {
+ if ((addr_mask & RELOAD_REG_INDEXED) == 0)
+   {
+ extra_cost = 1;
+ type = "indexed #2";
+   }
+   }
+
   else if (!base_reg_operand (plus_arg0, GET_MODE (plus_arg0)))
{
  fail_msg = "no base register #2";
Index: gcc/config/rs6000/altivec.md
===
--- gcc/config/rs6000/altivec.md(revision 217802)
+++ gcc/config/rs6000/altivec.md(working copy)
@@ -189,8 +189,8 @@ (define_mode_attr VU_char [(V2DI "w") (V
 
 ;; Vector move instructions.
 (define_insn "*altivec_mov"
-  [(set (match_operand:VM2 0 "nonimmediate_operand" "=Z,v,v,*Y,*r,*r,v,v")
-   (match_operand:VM2 1 "input_operand" "v,Z,v,r,Y,r,j,W"))]
+  [(set (match_operand:VM2 0 "nonimmediate_operand" "=Z,v,v,*Y,*r,*r,v,v,*r")
+   (match_operand:VM2 1 "input_operand" "v,Z,v,r,Y,r,j,W,W"))]
   "VECTOR_MEM_ALTIVEC_P (mode)
&& (register_operand (operands[0], mode) 
|| register_operand (operands[1], mode))"
@@ -205,10 +205,12 @@ (define_insn "*altivec_mov"
 case 5: return "#";
 case 6: return "vxor %0,%0,%0";
 case 7: return output_vec_const_move (operands);
+case 8: return "#";
 default: gcc_unreachable ();
 }
 }
-  [(set_attr "type" "vecstore,vecload,vecsimple,store,load,*,vecsimple,*")])
+  [(set_attr "type" "vecstore,vecload,vecsimple,store,load,*,vecsimple,*,*")
+   (set_attr "length" "4,4,4,20,20,20,4,8,32")])
 
 ;; Unlike other altivec moves, allow the GPRs, since a normal use of TImode
 ;; is for unions.  However for plain data movement, slightly favor the vector


Re: [PATCH 1/2] teach mklog to get name / email from git config when available

2014-11-20 Thread Tom de Vries

On 20-11-14 17:43, Segher Boessenkool wrote:

On Thu, Nov 20, 2014 at 05:22:20PM +0100, Tom de Vries wrote:

+my $conf = "$ENV{HOME}/.mklog";
+if (-f "$conf") {
+open (CONF, "$conf")
+   or die "Could not open file '$conf' for reading: $!\n";
+while () {
+   if (m/^\s*NAME\s*=\s*(.*)\s*$/) {


The final \s* never matches anything since the .* gobbles up everything.
Use .*? if you really want to get rid of the trailing whitespace.



Thanks for spotting that, patch updated.

OK for trunk?

Thanks,
- Tom



Segher



2014-11-20  Tom de Vries  
	Peter Bergner  

	* mklog: Handle .mklog.  Use git setting independent of presence .git
	directory.
---
 contrib/mklog | 56 +++-
 1 file changed, 35 insertions(+), 21 deletions(-)

diff --git a/contrib/mklog b/contrib/mklog
index 840f6f8..f7974a7 100755
--- a/contrib/mklog
+++ b/contrib/mklog
@@ -29,32 +29,46 @@
 use File::Temp;
 use File::Copy qw(cp mv);
 
-# Change these settings to reflect your profile.
-$username = $ENV{'USER'};
-$name = `finger $username | grep -o 'Name: .*'`;
-@n = split(/: /, $name);
-$name = $n[1]; chop($name);
-$addr = $username . "\@my.domain.org";
 $date = `date +%Y-%m-%d`; chop ($date);
 
+$dot_mklog_format_msg =
+"The .mklog format is:\n"
+. "NAME = ...\n"
+. "EMAIL = ...\n";
+
+# Create a .mklog to reflect your profile, if necessary.
+my $conf = "$ENV{HOME}/.mklog";
+if (-f "$conf") {
+open (CONF, "$conf")
+	or die "Could not open file '$conf' for reading: $!\n";
+while () {
+	if (m/^\s*NAME\s*=\s*(.*?)\s*$/) {
+	$name = $1;
+	} elsif (m/^\s*EMAIL\s*=\s*(.*?)\s*$/) {
+	$addr = $1;
+	}
+}
+if (!($name && $addr)) {
+	die "Could not read .mklog settings.\n"
+	. $dot_mklog_format_msg;
+}
+} else {
+$name = `git config user.name`;
+chomp($name);
+$addr = `git config user.email`;
+chomp($addr);
+
+if (!($name && $addr)) {
+	die "Could not read git user.name and user.email settings.\n"
+	. "Please add missing git settings, or create a .mklog file in"
+	. " $ENV{HOME}.\n"
+	. $dot_mklog_format_msg;
+}
+}
+
 $gcc_root = $0;
 $gcc_root =~ s/[^\\\/]+$/../;
 
-# if this is a git tree then take name and email from the git configuration
-if (-d "$gcc_root/.git") {
-  $gitname = `git config user.name`;
-  chomp($gitname);
-  if ($gitname) {
-	  $name = $gitname;
-  }
-
-  $gitaddr = `git config user.email`;
-  chomp($gitaddr);
-  if ($gitaddr) {
-	  $addr = $gitaddr;
-  }
-}
-
 #-
 # Program starts here. You should not need to edit anything below this
 # line.
-- 
1.9.1



[PATCH 1/2] PR debug/38757 gcc does not emit DW_LANG_C99.

2014-11-20 Thread Mark Wielaard
On Thu, Nov 13, 2014 at 02:19:57PM +0100, Richard Biener wrote:
> I'm fine with the string solution as well.  Just properly transfer whatever
> info you want through the translation unit decl and LTO stream it.

OK, strings it is then. Here are two patches. The first makes the change
to the lang_hook.name to include the std version for GNU C and GNU C++ and
updates all users. It merges the TRANSLATION_UNIT_LANGUAGE in dwarf2out.c
It uses this to set DW_LANG_C99 when appropriate.

The second patch adds support for C11, C++11 and C++14 as outlined
in the DWARFv5 DRAFT http://dwarfstd.org/doc/dwarf5.20141029.pdf

Note that this does not add DW_LANG_C_plus_plus_03 which I believe
is a mistake: http://thread.gmane.org/gmane.comp.standards.dwarf/218
C++03 isn't actually a new language standard, just C++98 plus some
new DRs, but no actual language changes.

The first patch adds two new tests, which PASS and has no regressions.
The second patch adds four new tests, which PASS, but break the C++
prettyprinters. You need a simple patch to GDB to get them working
again (just add the new dwarf2.h and use the new constants). It might
be better to wait with the second patch till I have patched GDB/binutils,
elfutils and valgrind to accept the new values. I'll submit those ASAP.

OK to commit the first patch now and the second patch as soon as
my patches to GDB/binutils, elfutils and valgrind are accepted upstream?

Thanks,

Mark

<--->

For C and C++ add the language standard version in use to lang_hooks.name.
Change users of lang_hook.name to check with strncmp first for "GNU C++"
then for "GNU C". In dwarf2out.c output the DW_LANG_C version from the
lang_hooks.name and merge any LTO TRANSLATION_UNIT_LANGUAGE found. Adds
two testcases to dwarf2.exp to check the right DWARF DW_AT_language is set
on the compile_unit depending on the -std=c89 or -std=c99 setting.

gcc/c-family/ChangeLog

2014-11-20  Mark Wielaard  

PR debug/38757
* c-opts.c (set_std_c89): Set lang_hooks.name.
(set_std_c99): Likewise.
(set_std_c11): Likewise.
(set_std_cxx98): Likewise.
(set_std_cxx11): Likewise.
(set_std_cxx14): Likewise.
(set_std_cxx1z): Likewise.

gcc/ChangeLog

2014-11-20  Mark Wielaard  

PR debug/38757
* config/avr/avr-c.c (avr_cpu_cpp_builtins): Use strncmp to
check lang_hooks.name.
* config/darwin.c (darwin_file_end): Likewise.
(darwin_override_options): Likewise.
* config/ia64/ia64.c (ia64_struct_retval_addr_is_first_parm_p):
Likewise.
* config/rs6000/rs6000.c (rs6000_output_function_epilogue):
Likewise.
* dbxout.c (get_lang_number): Likewise.
(dbxout_type): Likewise.
(dbxout_symbol_location): Likewise.
* dwarf2out.c (add_prototyped_attribute): Add DW_AT_prototype
also for DW_LANG_{C,C99,ObjC}.
(highest_c_language): New function.
(gen_compile_unit_die): Call highest_c_language to merge LTO
TRANSLATION_UNIT_LANGUAGE. Use strncmp lang_hooks.name to
determine if DW_LANG_C99 or DW_LANG_C89 should be returned.
* fold-const.c (fold_cond_expr_with_comparison): Use strncmp
to check lang_hooks.name.
* langhooks.h (struct lang_hooks): Add version comment to name.
* vmsdbgout.c (vmsdbgout_init): Use strncmp to check
lang_hooks.name.
---
 gcc/ChangeLog| 26 ++
 gcc/c-family/ChangeLog   | 11 ++
 gcc/c-family/c-opts.c|  7 
 gcc/config/avr/avr-c.c   |  3 +-
 gcc/config/darwin.c  |  4 +--
 gcc/config/ia64/ia64.c   |  2 +-
 gcc/config/rs6000/rs6000.c   | 11 +++---
 gcc/dbxout.c | 10 +++---
 gcc/dwarf2out.c  | 53 
 gcc/fold-const.c |  2 +-
 gcc/langhooks.h  |  3 +-
 gcc/testsuite/ChangeLog  |  6 
 gcc/testsuite/gcc.dg/debug/dwarf2/lang-c89.c |  6 
 gcc/testsuite/gcc.dg/debug/dwarf2/lang-c99.c |  6 
 gcc/vmsdbgout.c  |  6 ++--
 15 files changed, 131 insertions(+), 25 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/lang-c89.c
 create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/lang-c99.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 428725b..222558d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,29 @@
+2014-11-20  Mark Wielaard  
+
+   PR debug/38757
+   * config/avr/avr-c.c (avr_cpu_cpp_builtins): Use strncmp to
+   check lang_hooks.name.
+   * config/darwin.c (darwin_file_end): Likewise.
+   (darwin_override_options): Likewise.
+   * config/ia64/ia64.c (ia64_struct_retval_addr_is_first_parm_p):
+   Likewise.
+   * config/rs6000/rs6000.c (rs6000_output_function_epilog

[PATCH 2/2] PR debug/38757 continued. Handle C11, C++11 and C++14.

2014-11-20 Thread Mark Wielaard
This change depends on the new DWARFv5 constants mentioned in the
following draft: http://dwarfstd.org/doc/dwarf5.20141029.pdf

gcc/ChangeLog

* dwarf2out.c (is_cxx): Add DW_LANG_C_plus_plus_11 and
DW_LANG_C_plus_plus_14.
(lower_bound_default): Likewise. Plus DW_LANG_C11.
(gen_compile_unit_die): Output DW_LANG_C_plus_plus_11,
DW_LANG_C_plus_plus_14 or DW_LANG_C11.

gcc/testsuite/ChangeLog

* gcc.dg/debug/dwarf2/lang-c11.c: New test.
* g++.dg/debug/dwarf2/lang-cpp11.C: Likewise.
* g++.dg/debug/dwarf2/lang-cpp14.C: Likewise.
* g++.dg/debug/dwarf2/lang-cpp98.C: Likewise.

include/ChangeLog

* dwarf2.h: Add DW_LANG_C_plus_plus_11, DW_LANG_C11 and
DW_LANG_C_plus_plus_14.
---
 gcc/ChangeLog  |  8 
 gcc/dwarf2out.c| 28 ++
 gcc/testsuite/ChangeLog|  7 +++
 gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp11.C |  6 ++
 gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp14.C |  6 ++
 gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp98.C |  6 ++
 gcc/testsuite/gcc.dg/debug/dwarf2/lang-c11.c   |  6 ++
 include/ChangeLog  |  5 +
 include/dwarf2.h   |  4 
 9 files changed, 72 insertions(+), 4 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp11.C
 create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp14.C
 create mode 100644 gcc/testsuite/g++.dg/debug/dwarf2/lang-cpp98.C
 create mode 100644 gcc/testsuite/gcc.dg/debug/dwarf2/lang-c11.c

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 222558d..f7fabdf 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,13 @@
 2014-11-20  Mark Wielaard  
 
+   * dwarf2out.c (is_cxx): Add DW_LANG_C_plus_plus_11 and
+   DW_LANG_C_plus_plus_14.
+   (lower_bound_default): Likewise. Plus DW_LANG_C11.
+   (gen_compile_unit_die): Output DW_LANG_C_plus_plus_11,
+   DW_LANG_C_plus_plus_14 or DW_LANG_C11.
+
+2014-11-20  Mark Wielaard  
+
PR debug/38757
* config/avr/avr-c.c (avr_cpu_cpp_builtins): Use strncmp to
check lang_hooks.name.
diff --git a/gcc/dwarf2out.c b/gcc/dwarf2out.c
index 7844f33..c28deec 100644
--- a/gcc/dwarf2out.c
+++ b/gcc/dwarf2out.c
@@ -4684,7 +4684,8 @@ is_cxx (void)
 {
   unsigned int lang = get_AT_unsigned (comp_unit_die (), DW_AT_language);
 
-  return lang == DW_LANG_C_plus_plus || lang == DW_LANG_ObjC_plus_plus;
+  return (lang == DW_LANG_C_plus_plus || lang == DW_LANG_ObjC_plus_plus
+ || lang == DW_LANG_C_plus_plus_11 || lang == DW_LANG_C_plus_plus_14);
 }
 
 /* Return TRUE if the language is Java.  */
@@ -16402,7 +16403,10 @@ lower_bound_default (void)
 case DW_LANG_C:
 case DW_LANG_C89:
 case DW_LANG_C99:
+case DW_LANG_C11:
 case DW_LANG_C_plus_plus:
+case DW_LANG_C_plus_plus_11:
+case DW_LANG_C_plus_plus_14:
 case DW_LANG_ObjC:
 case DW_LANG_ObjC_plus_plus:
 case DW_LANG_Java:
@@ -16746,6 +16750,7 @@ add_prototyped_attribute (dw_die_ref die, tree 
func_type)
 case DW_LANG_C:
 case DW_LANG_C89:
 case DW_LANG_C99:
+case DW_LANG_C11:
 case DW_LANG_ObjC:
   if (prototype_p (func_type))
add_AT_flag (die, DW_AT_prototyped, 1);
@@ -19592,13 +19597,28 @@ gen_compile_unit_die (const char *filename)
 
   language = DW_LANG_C;
   if (strncmp (language_string, "GNU C++", 7) == 0)
-language = DW_LANG_C_plus_plus;
+{
+  language = DW_LANG_C_plus_plus;
+  if (dwarf_version >= 5 || !dwarf_strict)
+   {
+ if (strcmp (language_string, "GNU C++11") == 0)
+   language = DW_LANG_C_plus_plus_11;
+ else if (strcmp (language_string, "GNU C++14") == 0)
+   language = DW_LANG_C_plus_plus_14;
+   }
+}
   else if (strncmp (language_string, "GNU C", 5) == 0)
 {
   language = DW_LANG_C89;
   if (dwarf_version >= 3 || !dwarf_strict)
-   if (strcmp (language_string, "GNU C99") == 0)
- language = DW_LANG_C99;
+   {
+ if (strcmp (language_string, "GNU C89") != 0)
+   language = DW_LANG_C99;
+
+ if (dwarf_version >= 5 || !dwarf_strict)
+   if (strcmp (language_string, "GNU C11") == 0)
+ language = DW_LANG_C11;
+   }
 }
   else if (strcmp (language_string, "GNU F77") == 0)
 language = DW_LANG_Fortran77;
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9b29745..59f68ae 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,5 +1,12 @@
 2014-11-20  Mark Wielaard  
 
+   * gcc.dg/debug/dwarf2/lang-c11.c: New test.
+   * g++.dg/debug/dwarf2/lang-cpp11.C: Likewise.
+   * g++.dg/debug/dwarf2/lang-cpp14.C: Likewise.
+   * g++.dg/debug/dwarf2/lang-cpp98.C: Likewise.
+
+2014-11-20  Mark Wielaard  
+
PR debug/38757
* gcc.dg/debug/dwarf2/lang-c89.c: New test.
* gcc.dg/debug/d

Re: [PATCH] gcc/c-family/c-cppbuiltin.c: Use 20 instead of 18 for the maximized 64-bits integer decimal string length

2014-11-20 Thread Joseph Myers
On Thu, 20 Nov 2014, Chen Gang wrote:

> OK, thanks. I guess your meaning is:
> 
>  - If the value is small enough to be expressed by type 'int', we should
>not provide 'LL'.

Yes - and values not small enough should probably not be accepted by this 
function.

>  - If the value is positive number, we should not provide '(' and ')'.

Yes.

> >   Really I think it 
> > would be better to require that this function is only used for values that 
> > fit in target int (given appropriate checks on all the users to make sure 
> > they fit in with that), and put a corresponding assertion there.
> > 
> 
> Excuse me, I am not quite familiar with "target int", could you provide
> more details for it? And if necessary, please help send patch v2 instead
> of me:

"target int" is the type int on the target, as opposed to on the host 
(with precision TYPE_PRECISION (integer_type_node)).  I think you can use 
wi::fits_to_tree_p (n, integer_type_node) to test if n is in range for 
target int.

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


Re: [PATCH] OpenACC for C++ front end

2014-11-20 Thread James Norris

Hi!

On 11/13/2014 07:02 AM, Jakub Jelinek wrote:

On Wed, Nov 05, 2014 at 03:37:08PM -0600, James Norris wrote:

2014-11-05  James Norris  
Cesar Philippidis  
Thomas Schwinge  
Ilmir Usmanov  

...

Please check formatting.  I see various spots with 8 spaces instead of tabs,
e.g. on
+  check_no_duplicate_clause (list, OMP_CLAUSE_VECTOR_LENGTH,
+"vector_length", location);
even the alignment is wrong, I see calls without space before (:
+  if (args == NULL || args->length() == 0)
...
+ error("% expression must be integral");
other spots where the alignment isn't right:


Fixed.


+static tree
+cp_parser_oacc_cache (cp_parser *parser,
+   cp_token *pragma_tok __attribute__((unused)))
(cp_token should be below cp_parser).  While at this,
__attribute__((unused)) should be replaced by ATTRIBUTE_UNUSED, or removing
the parameter name, or removing the parameter altogether even better.


Fixed by removing unused parameter.


For the formatting issues, you can easily look for them in the patch
(in lines starting with +), change the patch and apply interdiff to your
tree.


Thank you for the pointer to interdiff!




--- a/gcc/c-family/c-omp.c
+++ b/gcc/c-family/c-omp.c
@@ -29,8 +29,47 @@ along with GCC; see the file COPYING3.  If not see
  #include "c-pragma.h"
  #include "gimple-expr.h"
  #include "langhooks.h"
+#include "omp-low.h"

As Thomas? has said, you should include gomp-constants.h and use them in:


+t = build_int_cst (integer_type_node, -2);  /* TODO: XXX FIX -2.  */

spots like this.


Fixed.




--- a/gcc/c-family/c-pragma.c
+++ b/gcc/c-family/c-pragma.c
@@ -1180,6 +1180,16 @@ typedef struct
  static vec registered_pp_pragmas;
  
  struct omp_pragma_def { const char *name; unsigned int id; };

+static const struct omp_pragma_def oacc_pragmas[] = {
+  { "data", PRAGMA_OACC_DATA },
+  { "enter", PRAGMA_OACC_ENTER_DATA },
+  { "exit", PRAGMA_OACC_EXIT_DATA },
+  { "kernels", PRAGMA_OACC_KERNELS },
+  { "loop", PRAGMA_OACC_LOOP },
+  { "parallel", PRAGMA_OACC_PARALLEL },
+  { "update", PRAGMA_OACC_UPDATE },
+  { "wait", PRAGMA_OACC_WAIT },

I'd avoid the , after the last element.


Fixed.




@@ -1383,6 +1402,17 @@ c_invoke_pragma_handler (unsigned int id)
  void
  init_pragma (void)
  {
+  if (flag_openacc)
+{
+  const int n_oacc_pragmas
+   = sizeof (oacc_pragmas) / sizeof (*oacc_pragmas);
+  int i;
+
+  for (i = 0; i < n_oacc_pragmas; ++i)
+   cpp_register_deferred_pragma (parse_in, "acc", oacc_pragmas[i].name,
+ oacc_pragmas[i].id, true, true);
+}
+
if (flag_openmp)
  {
const int n_omp_pragmas = sizeof (omp_pragmas) / sizeof (*omp_pragmas);

Is -fopenmp -fopenacc tested not to run out of number of supported pragmas
by libcpp?


Tests will be added in a follow-up patch once the middle end has been 
accepted.





@@ -65,23 +74,30 @@ typedef enum pragma_kind {
  } pragma_kind;
  
  
-/* All clauses defined by OpenMP 2.5, 3.0, 3.1 and 4.0.

+/* All clauses defined by OpenACC 2.0, and OpenMP 2.5, 3.0, 3.1, and 4.0.
 Used internally by both C and C++ parsers.  */
  typedef enum pragma_omp_clause {
PRAGMA_OMP_CLAUSE_NONE = 0,
  
PRAGMA_OMP_CLAUSE_ALIGNED,

+  PRAGMA_OMP_CLAUSE_ASYNC,
PRAGMA_OMP_CLAUSE_COLLAPSE,
+  PRAGMA_OMP_CLAUSE_COPY,
PRAGMA_OMP_CLAUSE_COPYIN,
+  PRAGMA_OMP_CLAUSE_COPYOUT,
PRAGMA_OMP_CLAUSE_COPYPRIVATE,
+  PRAGMA_OMP_CLAUSE_CREATE,
PRAGMA_OMP_CLAUSE_DEFAULT,
+  PRAGMA_OMP_CLAUSE_DELETE,
PRAGMA_OMP_CLAUSE_DEPEND,
PRAGMA_OMP_CLAUSE_DEVICE,
+  PRAGMA_OMP_CLAUSE_DEVICEPTR,
PRAGMA_OMP_CLAUSE_DIST_SCHEDULE,
PRAGMA_OMP_CLAUSE_FINAL,
PRAGMA_OMP_CLAUSE_FIRSTPRIVATE,
PRAGMA_OMP_CLAUSE_FOR,
PRAGMA_OMP_CLAUSE_FROM,
+  PRAGMA_OMP_CLAUSE_HOST,
PRAGMA_OMP_CLAUSE_IF,
PRAGMA_OMP_CLAUSE_INBRANCH,
PRAGMA_OMP_CLAUSE_LASTPRIVATE,
@@ -90,16 +106,24 @@ typedef enum pragma_omp_clause {
PRAGMA_OMP_CLAUSE_MERGEABLE,
PRAGMA_OMP_CLAUSE_NOTINBRANCH,
PRAGMA_OMP_CLAUSE_NOWAIT,
+  PRAGMA_OMP_CLAUSE_NUM_GANGS,
PRAGMA_OMP_CLAUSE_NUM_TEAMS,
PRAGMA_OMP_CLAUSE_NUM_THREADS,
+  PRAGMA_OMP_CLAUSE_NUM_WORKERS,
PRAGMA_OMP_CLAUSE_ORDERED,
PRAGMA_OMP_CLAUSE_PARALLEL,
+  PRAGMA_OMP_CLAUSE_PRESENT,
+  PRAGMA_OMP_CLAUSE_PRESENT_OR_COPY,
+  PRAGMA_OMP_CLAUSE_PRESENT_OR_COPYIN,
+  PRAGMA_OMP_CLAUSE_PRESENT_OR_COPYOUT,
+  PRAGMA_OMP_CLAUSE_PRESENT_OR_CREATE,
PRAGMA_OMP_CLAUSE_PRIVATE,
PRAGMA_OMP_CLAUSE_PROC_BIND,
PRAGMA_OMP_CLAUSE_REDUCTION,
PRAGMA_OMP_CLAUSE_SAFELEN,
PRAGMA_OMP_CLAUSE_SCHEDULE,
PRAGMA_OMP_CLAUSE_SECTIONS,
+  PRAGMA_OMP_CLAUSE_SELF,
PRAGMA_OMP_CLAUSE_SHARED,
PRAGMA_OMP_CLAUSE_SIMDLEN,
PRAGMA_OMP_CLAUSE_TASKGROUP,
@@ -107,6 +131,8 @@ typedef enum pragma_omp_clause {
PRAGMA_OMP_CLAUSE_TO,
PRAGMA_OMP_CLAUSE_UNIFORM,
PRAGMA_OMP_CLAUSE_UNTIED,
+  PRAGMA_OMP_CLAUSE_VECTOR_LENGTH

Re: [PATCH] gcc/c-family/c-cppbuiltin.c: Use 20 instead of 18 for the maximized 64-bits integer decimal string length

2014-11-20 Thread Chen Gang

OK, thank you for your details description.

I shall send patch v2 for it, within this week.

Send from Lenovo A788t.

Joseph Myers  wrote:

>On Thu, 20 Nov 2014, Chen Gang wrote:
>
>> OK, thanks. I guess your meaning is:
>> 
>>  - If the value is small enough to be expressed by type 'int', we should
>>not provide 'LL'.
>
>Yes - and values not small enough should probably not be accepted by this 
>function.
>
>>  - If the value is positive number, we should not provide '(' and ')'.
>
>Yes.
>
>> >   Really I think it 
>> > would be better to require that this function is only used for values that 
>> > fit in target int (given appropriate checks on all the users to make sure 
>> > they fit in with that), and put a corresponding assertion there.
>> > 
>> 
>> Excuse me, I am not quite familiar with "target int", could you provide
>> more details for it? And if necessary, please help send patch v2 instead
>> of me:
>
>"target int" is the type int on the target, as opposed to on the host 
>(with precision TYPE_PRECISION (integer_type_node)).  I think you can use 
>wi::fits_to_tree_p (n, integer_type_node) to test if n is in range for 
>target int.
>
>-- 
>Joseph S. Myers
>jos...@codesourcery.com


[PATCH, rs6000] Fix PR63673 -- missing prototype for vec_vsx_ld/vec_vsx_st

2014-11-20 Thread Bill Schmidt
Hi,

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63673 observes that
vec_vsx_ld doesn't currently permit the base pointer to have a type of
pointer to double, even though this is specified as legal in the GCC
user's manual.  We do allow a pointer to float, so this is just an
oversight.  This patch corrects the problem both for vec_vsx_ld and
vec_vsx_st.

Bootstrapped and tested on powerpc64-unknown-linux-gnu with no
regressions.  Ok for trunk, 4.9, and 4.8?

Thanks,
Bill


2014-11-20  Bill Schmidt  

* config/rs6000/rs6000-c.c (altivec_overloaded_builtins): Allow
the base pointer of vec_vsx_ld and vec_vsx_st to take a pointer to
double.


Index: gcc/config/rs6000/rs6000-c.c
===
--- gcc/config/rs6000/rs6000-c.c(revision 217800)
+++ gcc/config/rs6000/rs6000-c.c(working copy)
@@ -3411,6 +3411,8 @@ const struct altivec_builtin_types altivec_overloa
 
   { VSX_BUILTIN_VEC_LD, VSX_BUILTIN_LXVD2X_V2DF,
 RS6000_BTI_V2DF, RS6000_BTI_INTSI, ~RS6000_BTI_V2DF, 0 },
+  { VSX_BUILTIN_VEC_LD, VSX_BUILTIN_LXVD2X_V2DF,
+RS6000_BTI_V2DF, RS6000_BTI_INTSI, ~RS6000_BTI_double, 0 },
   { VSX_BUILTIN_VEC_LD, VSX_BUILTIN_LXVD2X_V2DI,
 RS6000_BTI_V2DI, RS6000_BTI_INTSI, ~RS6000_BTI_V2DI, 0 },
   { VSX_BUILTIN_VEC_LD, VSX_BUILTIN_LXVD2X_V2DI,
@@ -3465,6 +3467,8 @@ const struct altivec_builtin_types altivec_overloa
 
   { VSX_BUILTIN_VEC_ST, VSX_BUILTIN_STXVD2X_V2DF,
 RS6000_BTI_void, RS6000_BTI_V2DF, RS6000_BTI_INTSI, ~RS6000_BTI_V2DF },
+  { VSX_BUILTIN_VEC_ST, VSX_BUILTIN_STXVD2X_V2DF,
+RS6000_BTI_void, RS6000_BTI_V2DF, RS6000_BTI_INTSI, ~RS6000_BTI_double },
   { VSX_BUILTIN_VEC_ST, VSX_BUILTIN_STXVD2X_V2DI,
 RS6000_BTI_void, RS6000_BTI_V2DI, RS6000_BTI_INTSI, ~RS6000_BTI_V2DI },
   { VSX_BUILTIN_VEC_ST, VSX_BUILTIN_STXVD2X_V2DI,




Re: [PATCH] OpenACC for C front end

2014-11-20 Thread James Norris

Hi!

On 11/13/2014 09:04 AM, Jakub Jelinek wrote:

On Wed, Nov 05, 2014 at 03:39:44PM -0600, James Norris wrote:

* c-typeck.c (c_finish_oacc_parallel, c_finish_oacc_kernels,
c_finish_oacc_data): New functions.
(handle_omp_array_sections, c_finish_omp_clauses):

Handle should be on the above line, no need to wrap too early.


Fixed.




@@ -9763,6 +9830,10 @@ c_parser_omp_clause_name (c_parser *parser)
  else if (!strcmp ("from", p))
result = PRAGMA_OMP_CLAUSE_FROM;
  break;
+   case 'h':
+ if (!strcmp ("host", p))
+   result = PRAGMA_OMP_CLAUSE_SELF;
+ break;

Shouldn't this be PRAGMA_OMP_CLAUSE_HOST (PRAGMA_OACC_CLAUSE_HOST)
instead?  It is _HOST in the C++ patch, are there no C tests with
that clause covering it?


The "host" clause is a synonym for the "self" clause. The initial
C++ patch did not treat "host" as a synonym and has amended
accordingly.


+  tree v = TREE_PURPOSE (t);
+
+  /* FIXME diagnostics: Ideally we should keep individual
+locations for all the variables in the var list to make the
+following errors more precise.  Perhaps
+c_parser_omp_var_list_parens() should construct a list of
+locations to go along with the var list.  */

Like in C++ patch, please avoid the comment, file a PR instead,
or just queue the work for GCC 6.


Will submit a PR.


+  /* Attempt to statically determine when the number isn't positive.  */
+  c = fold_build2_loc (expr_loc, LE_EXPR, boolean_type_node, t,
+  build_int_cst (TREE_TYPE (t), 0));

build_int_cst not aligned below expr_loc.


Fixed.


+  if (CAN_HAVE_LOCATION_P (c))
+   SET_EXPR_LOCATION (c, expr_loc);
+  if (c == boolean_true_node)
+   {
+ warning_at (expr_loc, 0,
+ "% value must be positive");

This would fit perfectly on one line.


Fixed.


+  tree c, t;
+  location_t loc = c_parser_peek_token (parser)->location;
+
+  /* TODO XXX: FIX -1  (acc_async_noval).  */
+  t = build_int_cst (integer_type_node, -1);

Again, as in C++ patch, please avoid this.  Use gomp-constants.h,
or some enum, or explain what the -1 is, but avoid TODO XXX: FIX.


Fixed.


+  else
+{
+  t = c_fully_fold (t, false, NULL);
+}

Please avoid the {}s and reindent.


Fixed.




-/* OpenMP 4.0:
-   parallel
-   for
-   sections
-   taskgroup */
+  if (!INTEGRAL_TYPE_P (TREE_TYPE (t)))
+   {
+ c_parser_error (parser, "expected integer expression");
+ return list;
+   }
  
-static tree

-c_parser_omp_clause_cancelkind (c_parser *parser ATTRIBUTE_UNUSED,
-   enum omp_clause_code code, tree list)
-{
-  tree c = build_omp_clause (c_parser_peek_token (parser)->location, code);
+  /* Attempt to statically determine when the number isn't positive.  */
+  c = fold_build2_loc (expr_loc, LE_EXPR, boolean_type_node, t,
+  build_int_cst (TREE_TYPE (t), 0));

I wonder if it wouldn't be better to just put the new OpenACC routines
into a new block of code, not stick it in between the OpenMP handling
routines, because diff apparently lost track and I'm afraid so will svn 
blame/git blame
and we'll lose history for the OpenMP changes.


There was a mistake in naming the function: 
c_parser_omp_clause_vector_length.

Once it was renamed to: c_parser_oacc_clause_vector_length, diff was able to
keep track.


+   case PRAGMA_OMP_CLAUSE_VECTOR_LENGTH:
+ clauses = c_parser_omp_clause_vector_length (parser, clauses);
+ c_name = "vector_length";
+ break;

That is OpenACC clause, right?  Shouldn't the routine be called
c_parser_oacc_clause_vector_length?


Fixed.


+   case PRAGMA_OMP_CLAUSE_WAIT:
+ clauses = c_parser_oacc_clause_wait (parser, clauses);

E.g. c_parser_oacc_clause_wait is.


Fixed.




+  clauses =  c_parser_oacc_all_clauses (parser, OACC_DATA_CLAUSE_MASK,
+   "#pragma acc data");

Too many spaces after =.


Fixed.


+/* OpenACC 2.0:
+   # pragma acc kernels oacc-kernels-clause[optseq] new-line
+ structured-block
+
+   LOC is the location of the #pragma token.

Again, what is LOC?


Fixed by removal of comment, along with other occurences.


+  clauses =  c_parser_oacc_all_clauses (parser, OACC_KERNELS_CLAUSE_MASK,
+   p_name);

See above.


Fixed.


+  c_parser_error (parser, enter
+ ? "expected % in %<#pragma acc enter data%>"
+ : "expected % in %<#pragma acc exit data%>");
+  c_parser_skip_to_pragma_eol (parser);
+  return;
+}
+
+  const char *p = IDENTIFIER_POINTER (c_parser_peek_token (parser)->value);
+  if (strcmp (p, "data") != 0)
+{
+  c_parser_error (parser, "invalid pragma");

See the C++ patch review.


Fixed.


+  if (find_omp_clause (clauses, OMP_CLAUSE_MAP) == NULL_TREE)
+{
+  error_at (loc, enter
+ 

Re: [PATCH] rs6000: Follow up for signed integer overflow fix

2014-11-20 Thread David Edelsohn
On Thu, Nov 20, 2014 at 1:58 PM, Markus Trippelsdorf
 wrote:
> On 2014.11.20 at 19:44 +0100, Jakub Jelinek wrote:
>> On Thu, Nov 20, 2014 at 07:41:43PM +0100, Markus Trippelsdorf wrote:
>> > 2014-11-20  Markus Trippelsdorf  
>> >
>> > * config/rs6000/rs6000.c (includes_rldic_lshift_p): Cast 0 to unsigned.
>> > (includes_rldicr_lshift_p): Likewise.
>> >
>> > diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
>> > index a9604cf3fa97..d7958b33ba1a 100644
>> > --- a/gcc/config/rs6000/rs6000.c
>> > +++ b/gcc/config/rs6000/rs6000.c
>> > @@ -16197,10 +16197,10 @@ includes_rldic_lshift_p (rtx shiftop, rtx andop)
>> >unsigned HOST_WIDE_INT c, lsb, shift_mask;
>> >
>> >c = INTVAL (andop);
>> > -  if (c == 0 || c == ~0)
>> > +  if (c == 0 || c == ~(unsigned HOST_WIDE_INT) 0)
>> > return 0;
>> >
>> > -  shift_mask = ~0;
>> > +  shift_mask = ~(unsigned HOST_WIDE_INT) 0;
>> >shift_mask <<= INTVAL (shiftop);
>> >
>> >/* Find the least significant one bit.  */
>> > @@ -16235,7 +16235,7 @@ includes_rldicr_lshift_p (rtx shiftop, rtx andop)
>> >  {
>> >unsigned HOST_WIDE_INT c, lsb, shift_mask;
>> >
>> > -  shift_mask = ~0;
>> > +  shift_mask = ~(unsigned HOST_WIDE_INT) 0;
>> >shift_mask <<= INTVAL (shiftop);
>> >c = INTVAL (andop);
>>
>> You could use ~HOST_WIDE_INT_UC (0) in all the 3 cases.
>
> Or better still HOST_WIDE_INT_M1U.

Okay.

Thanks, David


Re: [PATCH, rs6000] Fix PR63673 -- missing prototype for vec_vsx_ld/vec_vsx_st

2014-11-20 Thread David Edelsohn
On Thu, Nov 20, 2014 at 6:49 PM, Bill Schmidt
 wrote:
> Hi,
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63673 observes that
> vec_vsx_ld doesn't currently permit the base pointer to have a type of
> pointer to double, even though this is specified as legal in the GCC
> user's manual.  We do allow a pointer to float, so this is just an
> oversight.  This patch corrects the problem both for vec_vsx_ld and
> vec_vsx_st.
>
> Bootstrapped and tested on powerpc64-unknown-linux-gnu with no
> regressions.  Ok for trunk, 4.9, and 4.8?
>
> Thanks,
> Bill
>
>
> 2014-11-20  Bill Schmidt  
>
> * config/rs6000/rs6000-c.c (altivec_overloaded_builtins): Allow
> the base pointer of vec_vsx_ld and vec_vsx_st to take a pointer to
> double.

Okay.

Thanks, David


Re: PATCH, PR 63965, rs6000, add support for scalar floating point in Altivec registers

2014-11-20 Thread David Edelsohn
On Thu, Nov 20, 2014 at 4:48 PM, Michael Meissner
 wrote:
> This patch fixes the failures in the following tests if --with-cpu is not used
> to set the cpu to cpus with vsx enabled (power7/power8):
>
> gcc.target/powerpc/altivec-splat.c
> gcc.target/powerpc/pr27158.c
>
> I have built these patches on power7 systems (default cpu = power7, and
> power6), power8 systems (default cpu = power8 and power5).  The compilers
> bootstrap and do not have regressions.  Are the patches ok to install?
>
> 2014-11-20  Michael Meissner  
>
> PR target/63965
> * config/rs6000/rs6000.c (rs6000_setup_reg_addr_masks): Do not set
> Altivec & -16 mask if the type is not valid for Altivec registers.
> (rs6000_secondary_reload_memory): Add support for ((reg + const) +
> reg) that occurs during push_reload processing.
>
> * config/rs6000/altivec.md (altivec_mov): Add instruction
> alternative for moving constant vectors which are easy altivec
> constants to GPRs.  Set the length attribute each of the
> alternatives.

Okay.

Thanks, David


C++ PATCH for c++/63658 (reference non-type template parameters)

2014-11-20 Thread Jason Merrill
My patch for c++/58606 changed the internal representation of reference 
template arguments to include the dereference in some places, but not 
enough.


Tested x86_64-cp-linux-gnu, applying to trunk and 4.9.
commit f7ea463fa794117000ef8495cb87d8c054323c7e
Author: Jason Merrill 
Date:   Thu Nov 20 08:46:48 2014 -0500

	PR c++/63658
	* pt.c (convert_nontype_argument): Call convert_from_reference.
	(check_instantiated_arg): Don't be confused by reference refs.
	(unify): Look through reference refs on the arg, too.
	* mangle.c (write_template_arg): Look through reference refs.

diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c
index 576ad1d..4c63df0 100644
--- a/gcc/cp/mangle.c
+++ b/gcc/cp/mangle.c
@@ -3086,6 +3086,8 @@ write_template_arg (tree node)
 	}
 }
 
+  if (REFERENCE_REF_P (node))
+node = TREE_OPERAND (node, 0);
   if (TREE_CODE (node) == NOP_EXPR
   && TREE_CODE (TREE_TYPE (node)) == REFERENCE_TYPE)
 {
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 05ca706..71b7af1 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -6174,7 +6174,7 @@ convert_nontype_argument (tree type, tree expr, tsubst_flags_t complain)
  right type?  */
   gcc_assert (same_type_ignoring_top_level_qualifiers_p
 	  (type, TREE_TYPE (expr)));
-  return expr;
+  return convert_from_reference (expr);
 }
 
 /* Subroutine of coerce_template_template_parms, which returns 1 if
@@ -15740,6 +15740,7 @@ check_instantiated_arg (tree tmpl, tree t, tsubst_flags_t complain)
  constant.  */
   else if (TREE_TYPE (t)
 	   && INTEGRAL_OR_ENUMERATION_TYPE_P (TREE_TYPE (t))
+	   && !REFERENCE_REF_P (t)
 	   && !TREE_CONSTANT (t))
 {
   if (complain & tf_error)
@@ -18473,8 +18474,12 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
 
 case INDIRECT_REF:
   if (REFERENCE_REF_P (parm))
-	return unify (tparms, targs, TREE_OPERAND (parm, 0), arg,
-		  strict, explain_p);
+	{
+	  if (REFERENCE_REF_P (arg))
+	arg = TREE_OPERAND (arg, 0);
+	  return unify (tparms, targs, TREE_OPERAND (parm, 0), arg,
+			strict, explain_p);
+	}
   /* FALLTHRU */
 
 default:
diff --git a/gcc/testsuite/g++.dg/template/ref9.C b/gcc/testsuite/g++.dg/template/ref9.C
new file mode 100644
index 000..983f627
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/ref9.C
@@ -0,0 +1,15 @@
+// PR c++/63658
+
+struct Descriptor {};
+
+template 
+struct foo
+{
+  void size ();
+};
+
+Descriptor g_descriptor = {};
+
+template<> void foo::size()
+{
+}
commit fea8bb6d4f45b8b1388001e59ad73b3ba63f41ea
Author: Jason Merrill 
Date:   Thu Nov 20 09:37:50 2014 -0500

	* error.c (dump_expr): Avoid printing (*&i) for references.

diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 76f86cb..7d79771 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -2299,7 +2299,13 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
 			TREE_TYPE (ttype)))
 	  {
 	if (TREE_CODE (ttype) == REFERENCE_TYPE)
-	  dump_unary_op (pp, "*", t, flags);
+	  {
+		STRIP_NOPS (op);
+		if (TREE_CODE (op) == ADDR_EXPR)
+		  dump_expr (pp, TREE_OPERAND (op, 0), flags);
+		else
+		  dump_unary_op (pp, "*", t, flags);
+	  }
 	else
 	  dump_unary_op (pp, "&", t, flags);
 	  }


[PATCH] Fix PR 63952 (Re: [PATCH, ifcvt] Allow CC mode if HAVE_cbranchcc4)

2014-11-20 Thread Ulrich Weigand
Richard Biener wrote:

> This probably caused bootstrap on s390x-linux to fail as in PR63952
> (last checked with rev. 217714).

It seems we have both a back-end bug and a middle-end bug here.

First of all, this code in optabs.c:prepare_cmp_insn is quite strange:

   if (GET_MODE_CLASS (mode) == MODE_CC)
 {
   gcc_assert (can_compare_p (comparison, CCmode, ccp_jump));
   *ptest = gen_rtx_fmt_ee (comparison, VOIDmode, x, y);
   return;
 }

Note that can_compare_p checks whether the back-end accepts a test
RTX created via:
  test = gen_rtx_fmt_ee (code, mode, const0_rtx, const0_rtx);

All back-end cbranchcc4 patterns however verify that the first operand
of the comparison is the flags register, so a const0_rtx will never
match.  It doesn't seem useful to call can_compare_p with CCmode at all.

The patch below changes prepare_cmp_insn do do an explicit
insn_operand_matches test using the actual operands, just like
is also done for non-CCmode comparisons.


However, even so this is still rejected by the s390 back end.  This is
because the s390 cbranchcc4 pattern is really quite wrong; it is restricted
to accepting only EQ/NE comparisons when it could simply accept any valid
comparison (i.e. where s390_comparison is true).

In addition, it has a TARGET_HARD_FLOAT check for no reason I can see,
and it has custom expander code that is in all cases a no-op and results
in exactly the pattern in the insn to be emitted anyway.

Fixed by the patch below as well.


Tested on s390x-ibm-linux (with and without --with-arch=z196).

OK for mainline?

Bye,
Ulrich


ChangeLog:

PR rtl-optimization/63952
* optabs.c (prepare_cmp_insn): Do not call can_compare_p for CCmode.
* config/s390/s390.md ("cbranchcc4"): Accept any s390_comparison.
Remove incorrect TARGET_HARD_FLOAT check and no-op expander code.

Index: gcc/optabs.c
===
*** gcc/optabs.c(revision 217784)
--- gcc/optabs.c(working copy)
*** prepare_cmp_insn (rtx x, rtx y, enum rtx
*** 4167,4174 
  
if (GET_MODE_CLASS (mode) == MODE_CC)
  {
!   gcc_assert (can_compare_p (comparison, CCmode, ccp_jump));
!   *ptest = gen_rtx_fmt_ee (comparison, VOIDmode, x, y);
return;
  }
  
--- 4167,4177 
  
if (GET_MODE_CLASS (mode) == MODE_CC)
  {
!   enum insn_code icode = optab_handler (cbranch_optab, CCmode);
!   test = gen_rtx_fmt_ee (comparison, VOIDmode, x, y);
!   gcc_assert (icode != CODE_FOR_nothing
!   && insn_operand_matches (icode, 0, test));
!   *ptest = test;
return;
  }
  
Index: gcc/config/s390/s390.md
===
*** gcc/config/s390/s390.md (revision 217784)
--- gcc/config/s390/s390.md (working copy)
***
*** 8142,8157 
  
  (define_expand "cbranchcc4"
[(set (pc)
! (if_then_else (match_operator 0 "s390_eqne_operator"
   [(match_operand 1 "cc_reg_operand" "")
! (match_operand 2 "const0_operand" "")])
  (label_ref (match_operand 3 "" ""))
(pc)))]
!   "TARGET_HARD_FLOAT"
!   "s390_emit_jump (operands[3],
! s390_emit_compare (GET_CODE (operands[0]), operands[1], operands[2]));
!DONE;")
! 
  
  
  ;;
--- 8142,8154 
  
  (define_expand "cbranchcc4"
[(set (pc)
! (if_then_else (match_operator 0 "s390_comparison"
   [(match_operand 1 "cc_reg_operand" "")
! (match_operand 2 "const_int_operand" "")])
  (label_ref (match_operand 3 "" ""))
(pc)))]
!   ""
!   "")
  
  
  ;;

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



[PATCH, combine] Try REG_EQUAL for nonzero_bits

2014-11-20 Thread Zhenqiang Chen
Hi,

The patch tries to use REG_EQUAL to get more precise info for nonzero_bits,
which helps to remove unnecessary zero_extend.

Here is an example when compiling Coremark, we have rtx like,

(insn 1244 386 388 47 (set (reg:SI 263 [ D.5767 ])
(reg:SI 384 [ D.5767 ])) 786 {*thumb2_movsi_insn}
 (expr_list:REG_EQUAL (zero_extend:SI (mem:QI (reg/v/f:SI 271 [ memblock
]) [0 *memblock_13(D)+0 S1 A8]))
(nil)))

from "reg:SI 384", we can only know it is a 32-bit value. But from
REG_EQUAL, we can know it is an 8-bit value. Then for the following rtx seq,

(insn 409 407 410 50 (set (reg:SI 308)
(plus:SI (reg:SI 263 [ D.5767 ])
(const_int -48 [0xffd0]))) core_state.c:170 4
{*arm_addsi3}
 (nil))
(insn 410 409 411 50 (set (reg:SI 309)
(zero_extend:SI (subreg:QI (reg:SI 308) 0))) core_state.c:170 812
{thumb2_zero_extendqisi2_v6}
 (expr_list:REG_DEAD (reg:SI 308)
(nil)))

the zero_extend for r309 can be optimized by combine pass.

Bootstrap and no make check regression on X86-64.
No make check regression on Cortex-M4 qemu.
No Spec2K INT regression on X86-64 and Cortex-A15 with -O3.
Coremark on Cortex-M7 is 0.3% better.
Coremark on Cortex-M4 is 0.07% regression due to alignment change.
No Coremark change on Corter-M0 and Cortex-A15.

Unfortunately I failed to generate a meaningful small case for it. So no
test case is included in the patch.

Ok for trunk?

Thanks!
-Zhenqiang

ChangeLog:
2014-11-21  Zhenqiang Chen  

* combine.c (set_nonzero_bits_and_sign_copies): Try REG_EQUAL note.

diff --git a/gcc/combine.c b/gcc/combine.c
index 6a7d16b..68a883b 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -1713,7 +1713,15 @@ set_nonzero_bits_and_sign_copies (rtx x, const_rtx
set, void *data)
 
  /* Don't call nonzero_bits if it cannot change anything.  */
  if (rsp->nonzero_bits != ~(unsigned HOST_WIDE_INT) 0)
-   rsp->nonzero_bits |= nonzero_bits (src, nonzero_bits_mode);
+   {
+ rtx reg_equal = insn ? find_reg_note (insn, REG_EQUAL,
NULL_RTX)
+: NULL_RTX;
+ if (reg_equal)
+   rsp->nonzero_bits |= nonzero_bits (XEXP (reg_equal, 0),
+  nonzero_bits_mode);
+ else
+   rsp->nonzero_bits |= nonzero_bits (src, nonzero_bits_mode);
+   }
  num = num_sign_bit_copies (SET_SRC (set), GET_MODE (x));
  if (rsp->sign_bit_copies == 0
  || rsp->sign_bit_copies > num)





[PATCH, nds32] Committed: Complete -march= option design.

2014-11-20 Thread Chung-Ju Wu
Hi, all,

When the help option --target-help is issued, the available items
for -march=X are supposed to be displayed automatically.
We need to complete -march= option design to perform such mechanism.


gcc/ChangeLog

2014-11-21  Chung-Ju Wu  

* config/nds32/nds32.opt (march): Add help message.


Committed as Rev. 217901: https://gcc.gnu.org/r217901


Best regards,
jasonwucj


Re: [PATCH, nds32] Committed: Complete -march= option design.

2014-11-20 Thread Chung-Ju Wu
2014-11-21 14:33 GMT+08:00 Chung-Ju Wu :
> Hi, all,
[snip]
>
> gcc/ChangeLog
>
> 2014-11-21  Chung-Ju Wu  
>
> * config/nds32/nds32.opt (march): Add help message.
>

Sorry for that I forgot to attach patch file in the previous mail.

Best regards,
jasonwucj


0001-Complete-march-option-design-so-that-it-can-display-.patch
Description: Binary data


[PATCH, nds32] Committed: Add missing RTX_FRAME_RELATED_P to set fp_adjust_insn rtx.

2014-11-20 Thread Chung-Ju Wu
Hi, all,

There is a wrong CFI info when frame pointer is needed.
The root cause is that we forgot to set fp_adjust_insn as
RTX_FRAME_RELATED_P rtx.

Fix this issue with following patch.


gcc/ChangeLog

2014-11-21  Chung-Ju Wu  

* config/nds32/nds32.c (nds32_expand_prologue): Set fp_adjust_insn
as RTX_FRAME_RELATED_P rtx.


Committed as Rev. 217902: https://gcc.gnu.org/r217902


Best regards,
jasonwucj


0002-Add-missing-RTX_FRAME_RELATED_P-to-set-fp_adjust_ins.patch
Description: Binary data


Re: [PATCH] Fix tree-ssa-strlen ICE introduced by r211956 (PR tree-optimization/61773)

2014-11-20 Thread Richard Biener
On November 20, 2014 7:16:04 PM CET, Jakub Jelinek  wrote:
>Hi!
>
>Before the r211956 changes, the only places that set si->stmt
>were required to check that stpcpy has been declared (with the right
>prototype) to signal the strlen pass that it can use stpcpy for
>optimization.  But r211956 sets si->stmt also for malloca call,
>which isn't in any way related to stpcpy.  So, this patch moves the
>assertion where it really is needed (for strcat/strcpy and their
>checking
>variants cases).
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

OK.

Thanks,
Richard.

>2014-11-20  Jakub Jelinek  
>
>   PR tree-optimization/61773
>   * tree-ssa-strlen.c (get_string_length): Don't assert
>   stpcpy has been prototyped if si->stmt is BUILT_IN_MALLOC.
>
>   * gcc.dg/pr61773.c: New test.
>
>--- gcc/tree-ssa-strlen.c.jj   2014-11-19 18:47:59.0 +0100
>+++ gcc/tree-ssa-strlen.c  2014-11-20 09:46:33.949017462 +0100
>@@ -430,7 +430,6 @@ get_string_length (strinfo si)
>   callee = gimple_call_fndecl (stmt);
>gcc_assert (callee && DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL);
>   lhs = gimple_call_lhs (stmt);
>-  gcc_assert (builtin_decl_implicit_p (BUILT_IN_STPCPY));
>/* unshare_strinfo is intentionally not called here.  The (delayed)
>transformation of strcpy or strcat into stpcpy is done at the place
>of the former strcpy/strcat call and so can affect all the strinfos
>@@ -479,6 +478,7 @@ get_string_length (strinfo si)
>   case BUILT_IN_STRCPY_CHK:
>   case BUILT_IN_STRCPY_CHKP:
>   case BUILT_IN_STRCPY_CHK_CHKP:
>+gcc_assert (builtin_decl_implicit_p (BUILT_IN_STPCPY));
> if (gimple_call_num_args (stmt) == (with_bounds ? 4 : 2))
>   fn = builtin_decl_implicit (BUILT_IN_STPCPY);
> else
>--- gcc/testsuite/gcc.dg/pr61773.c.jj  2014-11-20 10:12:48.664616764
>+0100
>+++ gcc/testsuite/gcc.dg/pr61773.c 2014-11-20 10:13:47.384557904 +0100
>@@ -0,0 +1,16 @@
>+/* PR tree-optimization/61773 */
>+/* { dg-do compile } */
>+/* { dg-options "-O2" } */
>+
>+void
>+foo (char **x)
>+{
>+  char *p = __builtin_malloc (64);
>+  char *q = __builtin_malloc (64);
>+  __builtin_strcat (q, "abcde");
>+  __builtin_strcat (p, "ab");
>+  p[1] = q[3];
>+  __builtin_strcat (p, q);
>+  x[0] = p;
>+  x[1] = q;
>+}
>
>   Jakub




[PATCH, nds32] Committed: Fix CFI info for variadic function arguments.

2014-11-20 Thread Chung-Ju Wu
Hi, all,

In nds32 ABI, the vararg arguments are pushed onto stack by callee.
However, those registers content are unnecessary to be restored.
We need to create an extra register note to inform gcc such information
so that it can generate correct CFI info for variadic function.


gcc/ChangeLog

2014-11-21  Chung-Ju Wu  

* config/nds32/nds32.c (nds32_emit_stack_push_multiple): Add new
vaarg_p argument and create correct CFI info.
(nds32_expand_prologue): Pass true or false to
nds32_emit_stack_push_multiple function.


Committed as Rev. 217903: https://gcc.gnu.org/r217903


Best regards,
jasonwucj


0003-Fix-CFI-for-variadic-function-arguments.patch
Description: Binary data


Re: [PATCH 1/2] PR debug/38757 gcc does not emit DW_LANG_C99.

2014-11-20 Thread Jakub Jelinek
On Thu, Nov 20, 2014 at 11:30:11PM +0100, Mark Wielaard wrote:
> --- a/gcc/config/avr/avr-c.c
> +++ b/gcc/config/avr/avr-c.c
> @@ -386,7 +386,8 @@ avr_cpu_cpp_builtins (struct cpp_reader *pfile)
>   (as mentioned in ISO/IEC DTR 18037; Annex F.2) which is not
>   implemented in GCC up to now.  */
>  
> -  if (!strcmp (lang_hooks.name, "GNU C"))
> +  if (strncmp (lang_hooks.name, "GNU C", 5) == 0
> +  && strncmp (lang_hooks.name, "GNU C++", 7) != 0)

I wonder if the tests for C language shouldn't be better done
as (strncmp (lang_hooks.name, "GNU C", 5) == 0
&& strchr ("0123456789", lang_hooks.name[5]) != NULL)
or (strncmp (lang_hooks.name, "GNU C", 5) == 0
&& (ISDIGIT (lang_hooks.name[5]) || lang_hooks.name[5] == '\0'))
to make it explicit what we are looking for, not what we aren't.

> +  either, so for now use 0.  Match GNU C++ first, since it needs to
> +  be compared with strncmp, like GNU C, which has the same prefix.  */
> +  if (! strncmp (language_string, "GNU C++", 7)
> +|| ! strcmp (language_string, "GNU Objective-C++"))

Wrong formatting, || should be below ! on the previous line.

> + i = 9;
> +  else if (! strncmp (language_string, "GNU C", 5)
> || ! strcmp (language_string, "GNU GIMPLE")
> || ! strcmp (language_string, "GNU Go"))

And here too.  But if you use a different check for C (see above), you could
avoid moving the C++ case first.

> --- a/gcc/langhooks.h
> +++ b/gcc/langhooks.h
> @@ -261,7 +261,8 @@ struct lang_hooks_for_lto
>  
>  struct lang_hooks
>  {
> -  /* String identifying the front end.  e.g. "GNU C++".  */
> +  /* String identifying the front end.  e.g. "GNU C++".
> + Might include language version being used.  */

As we no longer have GNU C++ as any name, using it as an example
is weird.  So,
  /* String identifying the front end and optionally language standard
 version, e.g. "GNU C++98" or "GNU Java".  */
?

LGTM otherwise.

Jakub


[PATCH, nds32] Committed: Look into LO_SUM's operand to determine whether it is a valid address.

2014-11-20 Thread Chung-Ju Wu
Hi, all,

In the nds32_legitimate_address_p function, we should look into LO_SUM's
operand so that we can precisely identify if it is a valid address.
This can help to avoid extra move instruction and improve code generation.


gcc/ChangeLog

2014-11-21  Chung-Ju Wu  

* config/nds32/nds32.c (nds32_legitimate_address_p): For LO_SUM,
we need to look into its operand to determine whether it is a valid
address.


Committed as Rev. 217904: https://gcc.gnu.org/r217904


Best regards,
jasonwucj


0004-For-LO_SUM-rtx-we-need-to-look-into-its-operand-to-d.patch
Description: Binary data


<    1   2