Re: [PATCH] Fix ubsan ICE (PR sanitizer/79897)

2017-03-07 Thread Richard Biener
On Mon, 6 Mar 2017, Jeff Law wrote:

> On 03/06/2017 03:58 PM, Jakub Jelinek wrote:
> > Hi!
> > 
> > Apparently fold_build_addr_expr doesn't make the argument addressable,
> > it is only made addressable during following gimplification and that is too
> > late here.
> Yea.  There's some special stuff going on here.  I've never dug into the
> details myself -- Richi knows it better than I.

You can't generally make things addressable out of thin air unless you
know what you're doing (and fold_build_addr_expr is called all over the 
place).  This is because doing that generally needs adjustment of
points-to-info.

> > 
> > Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> > trunk?
> > 
> > 2017-03-06  Jakub Jelinek  
> > 
> > PR sanitizer/79897
> > * ubsan.c (ubsan_encode_value): Call mark_addressable on the
> > temporary.
> IMHO, you've got carte blanche in the sanitizer bits.  So Ok.

Yes, looks like the correct fix.

Richard.


Re: [PATCH] Fix PR79887

2017-03-07 Thread Christophe Lyon
Hi Richard,


On 6 March 2017 at 13:05, Richard Biener  wrote:
>
> This fixes a crash when we try to re-use a folded loop_vectorized_call
> when vectorizing an epilogue.
>
> Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
>
> Richard.
>
> 2017-03-06  Richard Biener  
>
> PR tree-optimization/79894
> * tree-vectorizer.c (vectorize_loops): Set loop_vectorized_call
> to NULL after folding it.
>
> * gcc.dg/vect/pr79887.c: New testcase.
>

The new testcase causes an ICE on arm-* targets.

The backtrace is as follows:
/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/vect/pr79887.c:
In function 'foo':
/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/vect/pr79887.c:8:1:
error: control flow in the middle of basic block 10
/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/vect/pr79887.c:8:1:
error: wrong outgoing edge flags at end of bb 10
/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/vect/pr79887.c:8:1:
internal compiler error: verify_flow_info failed
0x6b0205 verify_flow_info()
/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cfghooks.c:260
0xb9a794 checking_verify_flow_info
/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cfghooks.h:198
0xb9a794 cleanup_tree_cfg_noloop
/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree-cfgcleanup.c:774
0xb9a794 cleanup_tree_cfg()
/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree-cfgcleanup.c:820
0xa5af54 execute_function_todo
/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1919
0xa5aca5 execute_todo
/aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:2016

Christophe

> Index: gcc/tree-vectorizer.c
> ===
> --- gcc/tree-vectorizer.c   (revision 245908)
> +++ gcc/tree-vectorizer.c   (working copy)
> @@ -651,6 +651,7 @@ vectorize_loops (void)
>  "basic block vectorized\n");
> fold_loop_vectorized_call (loop_vectorized_call,
>boolean_true_node);
> +   loop_vectorized_call = NULL;
> ret |= TODO_cleanup_cfg;
>   }
>   }
> @@ -703,6 +704,7 @@ vectorize_loops (void)
> if (loop_vectorized_call)
>   {
> fold_loop_vectorized_call (loop_vectorized_call, 
> boolean_true_node);
> +   loop_vectorized_call = NULL;
> ret |= TODO_cleanup_cfg;
>   }
>
> Index: gcc/testsuite/gcc.dg/vect/pr79887.c
> ===
> --- gcc/testsuite/gcc.dg/vect/pr79887.c (nonexistent)
> +++ gcc/testsuite/gcc.dg/vect/pr79887.c (working copy)
> @@ -0,0 +1,14 @@
> +/* Test for pr79887.  */
> +/* { dg-do compile } */
> +/* { dg-require-effective-target vect_condition } */
> +/* { dg-additional-options "-fno-trapping-math --param 
> vect-epilogues-nomask=1" } */
> +/* { dg-additional-options "-mavx512ifma" { target x86_64-*-* i?86-*-* } } */
> +
> +void
> +foo (float a[32], float b[2][32])
> +{
> +  int i;
> +  for (i = 0; i < 32; i++)
> +a[i] = (b[0][i] > b[1][i]) ? b[0][i] : b[1][i];
> +}
> +


Re: [PATCH] Use array_at_struct_end_p in tree-chkp.c (PR middle-end/68270).

2017-03-07 Thread Richard Biener
On Mon, Mar 6, 2017 at 2:20 PM, Martin Liška  wrote:
> Hello.
>
> As mentioned by Richard ([1]), the function should be used instead of
> DECL_CHAIN(..) checking.
>
> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>
> Ready to be installed?

Ok.
Richard.

> Martin
>
>
> [1] https://gcc.gnu.org/ml/gcc-patches/2017-01/msg00172.html


Re: [PATCH] Fix GC PCH bug in dwarf2out.c (PR c++/79821)

2017-03-07 Thread Richard Biener
On Mon, Mar 6, 2017 at 9:56 PM, Jakub Jelinek  wrote:
> Hi!
>
> gengtype.c considers all GC arrays with char/unsigned char/signed char
> element type as strings, for which it computes size e.g. in gt_pch_note_object
> using:
>   if (note_ptr_fn == gt_pch_p_S)
> (*slot)->size = strlen ((const char *)obj) + 1;
>   else
> (*slot)->size = ggc_get_size (obj);
> That is really undesirable if the array is actually a collection of random
> bytes rather than a NUL terminated string - then we can either compute
> smaller size if there are zeros in the array, or if unlucky enough and there
> are no zero bytes until end of mapped region, segfault.
>
> Fixed by avoiding the gt_pch_*_S handling by using void * pointer instead.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, and Rainer has kindly
> tested it on sparc*-solaris* where it caused bootstrap issues.  Ok for
> trunk?
>
> 2017-03-06  Jakub Jelinek  
>
> PR c++/79821
> * dwarf2out.h (dw_vec_const): Change array type from unsigned char *
> to void * for PCH reasons.
> * dwarf2out.c (output_loc_operands, output_die): Cast
> v.val_vec.array to unsigned char *.
>
> --- gcc/dwarf2out.h.jj  2017-01-01 12:45:37.0 +0100
> +++ gcc/dwarf2out.h 2017-03-06 12:13:48.809589411 +0100
> @@ -163,7 +163,7 @@ enum dw_val_class
>  /* Describe a floating point constant value, or a vector constant value.  */
>
>  struct GTY(()) dw_vec_const {
> -  unsigned char * GTY((atomic)) array;
> +  void * GTY((atomic)) array;

Please add a comment here why this is void *.  I wonder if we can't
tell gengtype
how to compute the length though via some GTY attribute?

>unsigned length;
>unsigned elt_size;
>  };
> --- gcc/dwarf2out.c.jj  2017-02-25 09:17:44.0 +0100
> +++ gcc/dwarf2out.c 2017-03-06 12:15:52.668958458 +0100
> @@ -2020,7 +2020,7 @@ output_loc_operands (dw_loc_descr_ref lo
> elt_size /= 2;
> len *= 2;
>   }
> -   for (i = 0, p = val2->v.val_vec.array;
> +   for (i = 0, p = (unsigned char *) val2->v.val_vec.array;
>  i < len;
>  i++, p += elt_size)
>   dw2_asm_output_data (elt_size, extract_int (p, elt_size),
> @@ -2273,7 +2273,7 @@ output_loc_operands (dw_loc_descr_ref lo
>   elt_size /= 2;
>   len *= 2;
> }
> - for (i = 0, p = val2->v.val_vec.array;
> + for (i = 0, p = (unsigned char *) val2->v.val_vec.array;
>i < len;
>i++, p += elt_size)
> dw2_asm_output_data (elt_size, extract_int (p, elt_size),
> @@ -10105,7 +10105,7 @@ output_die (dw_die_ref die)
> elt_size /= 2;
> len *= 2;
>   }
> -   for (i = 0, p = a->dw_attr_val.v.val_vec.array;
> +   for (i = 0, p = (unsigned char *) a->dw_attr_val.v.val_vec.array;
>  i < len;
>  i++, p += elt_size)
>   dw2_asm_output_data (elt_size, extract_int (p, elt_size),
>
> Jakub


Re: [PATCH] Fix GC PCH bug in dwarf2out.c (PR c++/79821)

2017-03-07 Thread Jakub Jelinek
On Tue, Mar 07, 2017 at 09:55:19AM +0100, Richard Biener wrote:
> > --- gcc/dwarf2out.h.jj  2017-01-01 12:45:37.0 +0100
> > +++ gcc/dwarf2out.h 2017-03-06 12:13:48.809589411 +0100
> > @@ -163,7 +163,7 @@ enum dw_val_class
> >  /* Describe a floating point constant value, or a vector constant value.  
> > */
> >
> >  struct GTY(()) dw_vec_const {
> > -  unsigned char * GTY((atomic)) array;
> > +  void * GTY((atomic)) array;
> 
> Please add a comment here why this is void *.  I wonder if we can't

I've already committed the patch, but will add some comment.

> tell gengtype
> how to compute the length though via some GTY attribute?

Maybe.  The documentation mentions that length attribute doesn't
apply to GC allocations that don't contain pointers, maybe we could change
that.  But my gengtype knowledge is very limited.

Jakub


[PATCH] PR c/79855: add full stop to store merging param descriptions

2017-03-07 Thread Kyrill Tkachov

Committing as obvious.

Thanks,
Kyrill

2017-03-07  Kyrylo Tkachov  

PR c/79855
* params.def (PARAM_STORE_MERGING_ALLOW_UNALIGNED): Add full stop
to end of description.
(PARAM_MAX_STORES_TO_MERGE): Likewise.
diff --git a/gcc/params.def b/gcc/params.def
index 31847ef..83b3014 100644
--- a/gcc/params.def
+++ b/gcc/params.def
@@ -1102,13 +1102,13 @@ DEFPARAM (PARAM_MAX_TAIL_MERGE_COMPARISONS,
 DEFPARAM (PARAM_STORE_MERGING_ALLOW_UNALIGNED,
 	  "store-merging-allow-unaligned",
 	  "Allow the store merging pass to introduce unaligned stores "
-	  "if it is legal to do so",
+	  "if it is legal to do so.",
 	  1, 0, 1)
 
 DEFPARAM (PARAM_MAX_STORES_TO_MERGE,
 	  "max-stores-to-merge",
 	  "Maximum number of constant stores to merge in the "
-	  "store merging pass",
+	  "store merging pass.",
 	  64, 2, 0)
 
 DEFPARAM (PARAM_MAX_TAIL_MERGE_ITERATIONS,


Re: [PATCH] Fix PR79887

2017-03-07 Thread Richard Biener
On Tue, 7 Mar 2017, Christophe Lyon wrote:

> Hi Richard,
> 
> 
> On 6 March 2017 at 13:05, Richard Biener  wrote:
> >
> > This fixes a crash when we try to re-use a folded loop_vectorized_call
> > when vectorizing an epilogue.
> >
> > Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
> >
> > Richard.
> >
> > 2017-03-06  Richard Biener  
> >
> > PR tree-optimization/79894
> > * tree-vectorizer.c (vectorize_loops): Set loop_vectorized_call
> > to NULL after folding it.
> >
> > * gcc.dg/vect/pr79887.c: New testcase.
> >
> 
> The new testcase causes an ICE on arm-* targets.
> 
> The backtrace is as follows:
> /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/vect/pr79887.c:
> In function 'foo':
> /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/vect/pr79887.c:8:1:
> error: control flow in the middle of basic block 10
> /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/vect/pr79887.c:8:1:
> error: wrong outgoing edge flags at end of bb 10
> /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/testsuite/gcc.dg/vect/pr79887.c:8:1:
> internal compiler error: verify_flow_info failed
> 0x6b0205 verify_flow_info()
> /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cfghooks.c:260
> 0xb9a794 checking_verify_flow_info
> /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/cfghooks.h:198
> 0xb9a794 cleanup_tree_cfg_noloop
> /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree-cfgcleanup.c:774
> 0xb9a794 cleanup_tree_cfg()
> /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/tree-cfgcleanup.c:820
> 0xa5af54 execute_function_todo
> /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:1919
> 0xa5aca5 execute_todo
> /aci-gcc-fsf/sources/gcc-fsf/gccsrc/gcc/passes.c:2016

Thanks for reporting - prologue vectorization seems to hit a latent 
bug where the vectorizer (rightfully) assumes pre-headers but does
not maintain them.

Bootstrap / regtest in progress on x86_64-unknown-linux-gnu.

Richard.

2017-03-07  Richard Biener  

* tree-vect-loop-manip.c (slpeel_add_loop_guard): Preserve
preheaders.

Index: gcc/tree-vect-loop-manip.c
===
--- gcc/tree-vect-loop-manip.c  (revision 245947)
+++ gcc/tree-vect-loop-manip.c  (working copy)
@@ -569,6 +569,11 @@ slpeel_add_loop_guard (basic_block guard
   enter_e->count -= new_e->count;
   enter_e->probability = inverse_probability (probability);
   set_immediate_dominator (CDI_DOMINATORS, guard_to, dom_bb);
+
+  /* Split enter_e to preserve LOOPS_HAVE_PREHEADERS.  */
+  if (enter_e->dest->loop_father->header == enter_e->dest)
+split_edge (enter_e);
+
   return new_e;
 }
 


Fix IRA issue, PR79728

2017-03-07 Thread Uros Bizjak
Hello!

> This is an ICE where setup_pressure_classes fails if xmm0 is a global reg. 
> Instead of
> GENERAL/FLOAT/SSE/MMX_REGS, it computes only SSE_FIRST_REG as the third 
> register
> class. The problem is that the costs for moving between SSE_FIRST_REG and 
> SSE_REGS are
> inflated because we think we have no available registers in SSE_FIRST_REG 
> (since the only
> register in that class is global), and that somewhat confuses the algorithm.

Index: gcc/testsuite/gcc.target/i386/sse-globalreg.c
===
--- gcc/testsuite/gcc.target/i386/sse-globalreg.c (nonexistent)
+++ gcc/testsuite/gcc.target/i386/sse-globalreg.c (working copy)
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -msse2 -w" } */
+/* { dg-require-effective-target sse2 } */

There is no need for effective-target checks for compile-only testcase.

Uros.


[PATCH 0/5] Fix various MPX issues

2017-03-07 Thread marxin
Hello.

I'm sending a small series that fixes MPX issue that are quite easily fixable.
The series can bootstrap on ppc64le and survives regression tests.

Thanks for review,
Martin

marxin (5):
  Fix *_CST ICEs connected to MPX.
  Get bounds for a PARM_DECL (PR ipa/79761).
  Fix ICE in tree-chkp-opt.c (PR tree-optimization/79631).
  Disable -fcheck-pointer-bounds with sanitizers.
  Support BIT_FIELD_REF in MPX (PR ipa/79764).

 gcc/testsuite/g++.dg/pr79761.C  | 34 ++
 gcc/testsuite/g++.dg/pr79764.C  | 12 
 gcc/testsuite/g++.dg/pr79769.C  |  4 ++
 gcc/testsuite/gcc.target/i386/mpx/pr79631.c | 15 +
 gcc/testsuite/gcc.target/i386/mpx/pr79763.c |  6 ++
 gcc/testsuite/gcc.target/i386/mpx/pr79770.c | 20 ++
 gcc/testsuite/gcc.target/i386/pr71458.c |  2 +-
 gcc/toplev.c| 29 -
 gcc/tree-chkp-opt.c |  3 +-
 gcc/tree-chkp.c | 96 +++--
 10 files changed, 184 insertions(+), 37 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/pr79761.C
 create mode 100644 gcc/testsuite/g++.dg/pr79764.C
 create mode 100644 gcc/testsuite/g++.dg/pr79769.C
 create mode 100644 gcc/testsuite/gcc.target/i386/mpx/pr79631.c
 create mode 100644 gcc/testsuite/gcc.target/i386/mpx/pr79763.c
 create mode 100644 gcc/testsuite/gcc.target/i386/mpx/pr79770.c

-- 
2.11.1



[PATCH 1/5] Fix *_CST ICEs connected to MPX.

2017-03-07 Thread marxin
gcc/ChangeLog:

2017-03-06  Martin Liska  

PR target/79763
PR target/79769
PR target/79770
* tree-chkp.c (chkp_find_bounds_1): Handle REAL_CST,
COMPLEX_CST and VECTOR_CST.

gcc/testsuite/ChangeLog:

2017-03-06  Martin Liska  

PR target/79763
PR target/79769
PR target/79770
* g++.dg/pr79769.C: New test.
* gcc.target/i386/mpx/pr79763.c: New test.
* gcc.target/i386/mpx/pr79770.c: New test.
---
 gcc/testsuite/g++.dg/pr79769.C  |  4 
 gcc/testsuite/gcc.target/i386/mpx/pr79763.c |  6 ++
 gcc/testsuite/gcc.target/i386/mpx/pr79770.c | 20 
 gcc/tree-chkp.c |  3 +++
 4 files changed, 33 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/pr79769.C
 create mode 100644 gcc/testsuite/gcc.target/i386/mpx/pr79763.c
 create mode 100644 gcc/testsuite/gcc.target/i386/mpx/pr79770.c

diff --git a/gcc/testsuite/g++.dg/pr79769.C b/gcc/testsuite/g++.dg/pr79769.C
new file mode 100644
index 000..f9223db1b2d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr79769.C
@@ -0,0 +1,4 @@
+/* { dg-do compile { target { ! x32 } } } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms" } */
+
+void a (_Complex) { a (3); }
diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr79763.c 
b/gcc/testsuite/gcc.target/i386/mpx/pr79763.c
new file mode 100644
index 000..59c2dececc2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/mpx/pr79763.c
@@ -0,0 +1,6 @@
+/* { dg-do compile { target { ! x32 } } } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms" } */
+
+int q_sk_num(void *a);
+typedef int (*fptr)(double);
+void a() { ((fptr)q_sk_num)(0); } /* { dg-warning "function called through a 
non-compatible type" } */
diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr79770.c 
b/gcc/testsuite/gcc.target/i386/mpx/pr79770.c
new file mode 100644
index 000..ede9a8a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/mpx/pr79770.c
@@ -0,0 +1,20 @@
+/* { dg-do compile { target lp64 } } */
+/* { dg-do compile { target { ! x32 } } } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms -Wno-psabi" } */
+
+typedef unsigned U __attribute__ ((vector_size (64)));
+typedef unsigned __int128 V __attribute__ ((vector_size (64)));
+
+static inline V
+bar (U u, U x, V v)
+{
+  v = (V)(U) { 0, ~0 };
+  v[x[0]] <<= u[-63];
+  return v;
+}
+
+V
+foo (U u)
+{
+  return bar (u, (U) {}, (V) {});
+}
diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index 02ae2d2d2c7..3d497f51ed8 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -3665,6 +3665,9 @@ chkp_find_bounds_1 (tree ptr, tree ptr_src, 
gimple_stmt_iterator *iter)
   break;
 
 case INTEGER_CST:
+case REAL_CST:
+case COMPLEX_CST:
+case VECTOR_CST:
   if (integer_zerop (ptr_src))
bounds = chkp_get_none_bounds ();
   else
-- 
2.11.1




[PATCH 5/5] Support BIT_FIELD_REF in MPX (PR ipa/79764).

2017-03-07 Thread marxin
gcc/ChangeLog:

2017-03-06  Martin Liska  

PR ipa/79764
* tree-chkp.c (chkp_narrow_bounds_for_field): Fix typo in
comment.
(chkp_narrow_size_and_offset): New function.
(chkp_parse_array_and_component_ref): Support BIT_FIELD_REF.
(void chkp_parse_bit_field_ref): New function.
(chkp_make_addressed_object_bounds): Add case for BIT_FIELD_REF.
(chkp_process_stmt): Use chkp_parse_bit_field_ref.

gcc/testsuite/ChangeLog:

2017-03-06  Martin Liska  

PR ipa/79764
* g++.dg/pr79764.C: New test.
---
 gcc/testsuite/g++.dg/pr79764.C | 12 ++
 gcc/tree-chkp.c| 90 ++
 2 files changed, 85 insertions(+), 17 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/pr79764.C

diff --git a/gcc/testsuite/g++.dg/pr79764.C b/gcc/testsuite/g++.dg/pr79764.C
new file mode 100644
index 000..47fb88da19b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr79764.C
@@ -0,0 +1,12 @@
+/* { dg-do compile { target { ! x32 } } } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
+
+typedef float __m256 __attribute__ (( __vector_size__(32), __may_alias__ ));
+struct A {
+  __m256 ymm;
+  const float &f() const;
+};
+
+const float &A::f() const {
+  return ymm[1];
+}
diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index d5683b1b9cf..14ebff294f9 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -325,6 +325,8 @@ static void chkp_parse_array_and_component_ref (tree node, 
tree *ptr,
tree *bounds,
gimple_stmt_iterator *iter,
bool innermost_bounds);
+static void chkp_parse_bit_field_ref (tree node, location_t loc,
+ tree *offset, tree *size);
 
 #define chkp_bndldx_fndecl \
   (targetm.builtin_chkp_function (BUILT_IN_CHKP_BNDLDX))
@@ -3266,7 +3268,7 @@ chkp_intersect_bounds (tree bounds1, tree bounds2, 
gimple_stmt_iterator *iter)
 }
 
 /* Return 1 if we are allowed to narrow bounds for addressed FIELD
-   and 0 othersize.  */
+   and 0 otherwise.  */
 static bool
 chkp_may_narrow_to_field (tree field)
 {
@@ -3294,7 +3296,7 @@ chkp_narrow_bounds_for_field (tree field)
   if (!chkp_may_narrow_to_field (field))
 return false;
 
-  /* Accesse to compiler generated fields should not cause
+  /* Access to compiler generated fields should not cause
  bounds narrowing.  */
   if (DECL_ARTIFICIAL (field))
 return false;
@@ -3308,9 +3310,36 @@ chkp_narrow_bounds_for_field (tree field)
  || bit_offs));
 }
 
+/* Perform narrowing for BOUNDS of an INNER reference.  Shift boundary
+   by OFFSET bytes and limit to SIZE bytes.  Newly created statements are
+   added to ITER.  */
+
+static tree
+chkp_narrow_size_and_offset (tree bounds, tree inner, tree offset,
+tree size, gimple_stmt_iterator *iter)
+{
+  tree addr = chkp_build_addr_expr (unshare_expr (inner));
+  tree t = TREE_TYPE (addr);
+
+  gimple *stmt = gimple_build_assign (NULL_TREE, addr);
+  addr = make_temp_ssa_name (t, stmt, CHKP_BOUND_TMP_NAME);
+  gimple_assign_set_lhs (stmt, addr);
+  gsi_insert_seq_before (iter, stmt, GSI_SAME_STMT);
+
+  stmt = gimple_build_assign (NULL_TREE, POINTER_PLUS_EXPR, addr, offset);
+  tree shifted = make_temp_ssa_name (t, stmt, CHKP_BOUND_TMP_NAME);
+  gimple_assign_set_lhs (stmt, shifted);
+  gsi_insert_seq_before (iter, stmt, GSI_SAME_STMT);
+
+  tree bounds2 = chkp_make_bounds (shifted, size, iter, false);
+
+  return chkp_intersect_bounds (bounds, bounds2, iter);
+}
+
 /* Perform narrowing for BOUNDS using bounds computed for field
access COMPONENT.  ITER meaning is the same as for
chkp_intersect_bounds.  */
+
 static tree
 chkp_narrow_bounds_to_field (tree bounds, tree component,
gimple_stmt_iterator *iter)
@@ -3363,7 +3392,8 @@ chkp_parse_array_and_component_ref (tree node, tree *ptr,
   len = 1;
   while (TREE_CODE (var) == COMPONENT_REF
 || TREE_CODE (var) == ARRAY_REF
-|| TREE_CODE (var) == VIEW_CONVERT_EXPR)
+|| TREE_CODE (var) == VIEW_CONVERT_EXPR
+|| TREE_CODE (var) == BIT_FIELD_REF)
 {
   var = TREE_OPERAND (var, 0);
   len++;
@@ -3382,9 +3412,10 @@ chkp_parse_array_and_component_ref (tree node, tree *ptr,
   if (bounds)
 *bounds = NULL;
   *safe = true;
-  *bitfield = (TREE_CODE (node) == COMPONENT_REF
-  && DECL_BIT_FIELD_TYPE (TREE_OPERAND (node, 1)));
-  /* To get bitfield address we will need outer elemnt.  */
+  *bitfield = ((TREE_CODE (node) == COMPONENT_REF
+  && DECL_BIT_FIELD_TYPE (TREE_OPERAND (node, 1)))
+  || TREE_CODE (node) == BIT_FIELD_REF);
+  /* To get bitfield address we will need outer element.  */
   if (*bitfield)
 *elt = nodes[len - 2];
   else
@@ -3453,6 +3484,17 @@ chkp_parse_array_and_component_ref (tree node, tree *ptr,
  comp_

[PATCH 2/5] Get bounds for a PARM_DECL (PR ipa/79761).

2017-03-07 Thread marxin
gcc/ChangeLog:

2017-03-06  Martin Liska  

PR ipa/79761
* tree-chkp.c (chkp_get_bound_for_parm): Get bounds for a param.
(chkp_find_bounds_1): Remove gcc_unreachable.

gcc/testsuite/ChangeLog:

2017-03-06  Martin Liska  

PR ipa/79761
* g++.dg/pr79761.C: New test.
---
 gcc/testsuite/g++.dg/pr79761.C | 34 ++
 gcc/tree-chkp.c|  3 +--
 2 files changed, 35 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/pr79761.C

diff --git a/gcc/testsuite/g++.dg/pr79761.C b/gcc/testsuite/g++.dg/pr79761.C
new file mode 100644
index 000..b1f92d2b036
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr79761.C
@@ -0,0 +1,34 @@
+/* { dg-do compile { target { ! x32 } } } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms" } */
+
+struct Foo
+{
+  Foo() : a(1), b(1), c('a') {}
+  int a;
+  int b;
+  char c;
+};
+
+static Foo copy_foo(Foo) __attribute__((noinline, noclone));
+
+static Foo copy_foo(Foo A)
+{
+  return A;
+}
+
+struct Bar : Foo
+{
+  Bar(Foo t) : Foo(copy_foo(t)) {}
+};
+
+Foo F;
+
+int main (void)
+{
+  Bar B (F);
+
+  if (B.a != 1 || B.b != 1 || B.c != 'a')
+__builtin_abort ();
+
+  return 0;
+}
diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index 3d497f51ed8..d5683b1b9cf 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -2353,7 +2353,7 @@ chkp_get_next_bounds_parm (tree parm)
 static tree
 chkp_get_bound_for_parm (tree parm)
 {
-  tree decl = SSA_NAME_VAR (parm);
+  tree decl = TREE_CODE (parm) == PARM_DECL ? parm : SSA_NAME_VAR (parm);
   tree bounds;
 
   gcc_assert (TREE_CODE (decl) == PARM_DECL);
@@ -3602,7 +3602,6 @@ chkp_find_bounds_1 (tree ptr, tree ptr_src, 
gimple_stmt_iterator *iter)
   break;
 
 case PARM_DECL:
-  gcc_unreachable ();
   bounds = chkp_get_bound_for_parm (ptr_src);
   break;
 
-- 
2.11.1




[PATCH 4/5] Disable -fcheck-pointer-bounds with sanitizers.

2017-03-07 Thread marxin
gcc/ChangeLog:

2017-03-06  Martin Liska  

PR target/65705
PR target/69804
* toplev.c (process_options): Disable -fcheck-pointer-bounds with
sanitizers.

gcc/testsuite/ChangeLog:

2017-03-06  Martin Liska  

PR target/65705
PR target/69804
* gcc.target/i386/pr71458.c: Update scanned pattern.
---
 gcc/testsuite/gcc.target/i386/pr71458.c |  2 +-
 gcc/toplev.c| 29 +
 2 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/gcc/testsuite/gcc.target/i386/pr71458.c 
b/gcc/testsuite/gcc.target/i386/pr71458.c
index 27e7764b5a0..2faf6bb9391 100644
--- a/gcc/testsuite/gcc.target/i386/pr71458.c
+++ b/gcc/testsuite/gcc.target/i386/pr71458.c
@@ -1,6 +1,6 @@
 /* { dg-do compile { target { ! x32 } } } */
 /* { dg-options "-fcheck-pointer-bounds -mmpx -fsanitize=bounds" } */
-/* { dg-error "-fcheck-pointer-bounds is not supported with -fsanitize=bounds" 
"" { target *-*-* } 0 } */
+/* { dg-error "-fcheck-pointer-bounds is not supported with Undefined Behavior 
Sanitizer" "" { target *-*-* } 0 } */
 
 enum {} a[0];
 void fn1(int);
diff --git a/gcc/toplev.c b/gcc/toplev.c
index beb581aba55..b8f87b878da 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1274,22 +1274,19 @@ process_options (void)
  flag_check_pointer_bounds = 0;
}
 
-  if (flag_sanitize & SANITIZE_ADDRESS)
-   {
- error_at (UNKNOWN_LOCATION,
-   "-fcheck-pointer-bounds is not supported with "
-   "Address Sanitizer");
- flag_check_pointer_bounds = 0;
-   }
-
-  if (flag_sanitize & SANITIZE_BOUNDS)
-   {
- error_at (UNKNOWN_LOCATION,
-   "-fcheck-pointer-bounds is not supported with "
-   "-fsanitize=bounds");
- flag_check_pointer_bounds = 0;
-   }
-
+  const char *sanitizer_names[] = { "Address", "Undefined Behavior",
+   "Leak", "Thread" };
+  const int sanitizer_flags[] = { SANITIZE_ADDRESS, SANITIZE_UNDEFINED,
+   SANITIZE_LEAK, SANITIZE_THREAD };
+
+  for (unsigned i = 0; i < sizeof (sanitizer_flags) / sizeof (int); i++)
+   if (flag_sanitize & sanitizer_flags[i])
+ {
+   error_at (UNKNOWN_LOCATION,
+ "-fcheck-pointer-bounds is not supported with "
+ "%s Sanitizer", sanitizer_names[i]);
+   flag_check_pointer_bounds = 0;
+ }
 }
 
   /* One region RA really helps to decrease the code size.  */
-- 
2.11.1




[PATCH 3/5] Fix ICE in tree-chkp-opt.c (PR tree-optimization/79631).

2017-03-07 Thread marxin
gcc/ChangeLog:

2017-03-06  Martin Liska  

PR tree-optimization/79631
* tree-chkp-opt.c (chkp_is_constant_addr): Call
tree_int_cst_sign_bit just for INTEGER constants.

gcc/testsuite/ChangeLog:

2017-03-06  Martin Liska  

PR tree-optimization/79631
* gcc.target/i386/mpx/pr79631.c: New test.
---
 gcc/testsuite/gcc.target/i386/mpx/pr79631.c | 15 +++
 gcc/tree-chkp-opt.c |  3 ++-
 2 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/mpx/pr79631.c

diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr79631.c 
b/gcc/testsuite/gcc.target/i386/mpx/pr79631.c
new file mode 100644
index 000..075d46b835f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/mpx/pr79631.c
@@ -0,0 +1,15 @@
+/* { dg-do compile { target { ! x32 } } } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -O2" } */
+
+typedef struct { int _mp_size; } mpz_t[1];
+int a, b;
+void fn1()
+{
+  mpz_t c[1][b];
+  for (;;) {
+  int d = 0 >= 0 ? 0 == 0 ? c[0][0]->_mp_size ? -1 : 0 : 0 : 0,
+ e = 0 >= 0 ? 0 == 0 ? c[1][1]->_mp_size ? -1 : 0 : 0 : 0;
+  if (d != e)
+   a++;
+  }
+}
diff --git a/gcc/tree-chkp-opt.c b/gcc/tree-chkp-opt.c
index ebe05459773..286f7853921 100644
--- a/gcc/tree-chkp-opt.c
+++ b/gcc/tree-chkp-opt.c
@@ -241,7 +241,8 @@ chkp_is_constant_addr (const address_t &addr, int *sign)
 return false;
   else if (integer_zerop (addr.pol[0].cst))
 *sign = 0;
-  else if  (tree_int_cst_sign_bit (addr.pol[0].cst))
+  else if (TREE_CODE (addr.pol[0].cst) == INTEGER_CST
+  && tree_int_cst_sign_bit (addr.pol[0].cst))
 *sign = -1;
   else
 *sign = 1;
-- 
2.11.1




Re: [PATCH 2/5] Get bounds for a PARM_DECL (PR ipa/79761).

2017-03-07 Thread Rainer Orth
marxin  writes:

> diff --git a/gcc/testsuite/g++.dg/pr79761.C b/gcc/testsuite/g++.dg/pr79761.C
> new file mode 100644
> index 000..b1f92d2b036
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/pr79761.C
> @@ -0,0 +1,34 @@
> +/* { dg-do compile { target { ! x32 } } } */
> +/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms" } */

This isn't right: the test must be restricted to x86 targets like
g++.dg/pr71633.C.

Rainer

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


Re: [PATCH 1/5] Fix *_CST ICEs connected to MPX.

2017-03-07 Thread Rainer Orth
marxin  writes:

> diff --git a/gcc/testsuite/g++.dg/pr79769.C b/gcc/testsuite/g++.dg/pr79769.C
> new file mode 100644
> index 000..f9223db1b2d
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/pr79769.C
> @@ -0,0 +1,4 @@
> +/* { dg-do compile { target { ! x32 } } } */
> +/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms" } */

... and again: make this x86-only.

Rainer

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


Re: [PATCH 5/5] Support BIT_FIELD_REF in MPX (PR ipa/79764).

2017-03-07 Thread Rainer Orth
marxin  writes:

> diff --git a/gcc/testsuite/g++.dg/pr79764.C b/gcc/testsuite/g++.dg/pr79764.C
> new file mode 100644
> index 000..47fb88da19b
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/pr79764.C
> @@ -0,0 +1,12 @@
> +/* { dg-do compile { target { ! x32 } } } */
> +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */

Same here.

Rainer

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


Re: [PATCH 1/5] Fix *_CST ICEs connected to MPX.

2017-03-07 Thread Uros Bizjak
Hello!

> 2017-03-06  Martin Liska  
>
> PR target/79763
> PR target/79769
> PR target/79770
> * tree-chkp.c (chkp_find_bounds_1): Handle REAL_CST,
> COMPLEX_CST and VECTOR_CST.
>
> gcc/testsuite/ChangeLog:
>
> 2017-03-06  Martin Liska  
>
> PR target/79763
> PR target/79769
> PR target/79770
> * g++.dg/pr79769.C: New test.
> * gcc.target/i386/mpx/pr79763.c: New test.
> * gcc.target/i386/mpx/pr79770.c: New test.

diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr79770.c
b/gcc/testsuite/gcc.target/i386/mpx/pr79770.c
new file mode 100644
index 000..ede9a8a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/mpx/pr79770.c
@@ -0,0 +1,20 @@
+/* { dg-do compile { target lp64 } } */
+/* { dg-do compile { target { ! x32 } } } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms -Wno-psabi" } */

You don't need to check for x32 here, lp64 check is enough.

Uros.


Re: [PATCH 0/5] Fix various MPX issues

2017-03-07 Thread Uros Bizjak
Hello!

> I'm sending a small series that fixes MPX issue that are quite easily fixable.
> The series can bootstrap on ppc64le and survives regression tests.

Several testcases in the serie are put outside gcc.target/i386
directory. You need full target specifier in these cases, "{ {
i?86-*-* x86_64-*-* } && { ! x32 } }".

Uros.


[PATCH] Increment value instead of a pointer in ADA macro processing.

2017-03-07 Thread Martin Liška
Hello.

Looks there's real issues spotted by -Wchkp:

../../gcc/c-family/c-ada-spec.c: In function ‘void 
print_ada_macros.chkp(pretty_printer*, 
\xe2\x80\x98pointer_bounds_typ\xe2\x80\x99 not supported by dump_type#, cpp_hashnode**, \xe2\x80\x98pointer_bounds_typ\xe2\x80\x99 not 
supported by dump_type#, int, void, ...)’:
../../gcc/c-family/c-ada-spec.c:80:15: error: memory access check always fail 
[-Werror=chkp]
*param_len += NODE_LEN (param);
~~~^~~~   
../../gcc/c-family/c-ada-spec.c:80:15: error: memory access check always fail 
[-Werror=chkp]
../../gcc/c-family/c-ada-spec.c:84:19: error: memory access check always fail 
[-Werror=chkp]
*param_len += 2;  /* ", " */
~~~^~~~
../../gcc/c-family/c-ada-spec.c:84:19: error: memory access check always fail 
[-Werror=chkp]
../../gcc/c-family/c-ada-spec.c:92:18: error: memory access check always fail 
[-Werror=chkp]
   *param_len += 2;  /* ")\0" */
   ~~~^~~~
../../gcc/c-family/c-ada-spec.c:92:18: error: memory access check always fail 
[-Werror=chkp]

I prepared quite obvious fix for that and tested make check -k 
RUNTESTFLAGS="dg.exp=dump-ada-spec-*"
on x86_64-linux-gnu.

Ready to be installed?
Martin
>From 9137ddcf413585f557c4ef263d731bf457cb79f4 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Tue, 7 Mar 2017 11:10:30 +0100
Subject: [PATCH] Increment value instead of a pointer in ADA macro processing.

gcc/c-family/ChangeLog:

2017-03-07  Martin Liska  

	* c-ada-spec.c (macro_length): Increment value instead of a pointer.
---
 gcc/c-family/c-ada-spec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/c-family/c-ada-spec.c b/gcc/c-family/c-ada-spec.c
index 6db741107a3..18c5ccf1054 100644
--- a/gcc/c-family/c-ada-spec.c
+++ b/gcc/c-family/c-ada-spec.c
@@ -72,7 +72,7 @@ macro_length (const cpp_macro *macro, int *supported, int *buffer_len,
 
   if (macro->fun_like)
 {
-  param_len++;
+  (*param_len)++;
   for (i = 0; i < macro->paramc; i++)
 	{
 	  cpp_hashnode *param = macro->params[i];
-- 
2.11.1



[PATCH] Fix MIPS-specific ICE in gcc.dg/pr77834.c (PR rtl-optimization/79150).

2017-03-07 Thread Toma Tabacu
Hi,

This ICE is caused by "gcc_assert (!JUMP_P (last))" in
commit_one_edge_insertion (gcc/cfgrtl.c):

  if (returnjump_p (last))
{
  /* ??? Remove all outgoing edges from BB and add one for EXIT.
 This is not currently a problem because this only happens
 for the (single) epilogue, which already has a fallthru edge
 to EXIT.  */

  e = single_succ_edge (bb);
  gcc_assert (e->dest == EXIT_BLOCK_PTR_FOR_FN (cfun)
  && single_succ_p (bb) && (e->flags & EDGE_FALLTHRU));

  e->flags &= ~EDGE_FALLTHRU;
  emit_barrier_after (last);

  if (before)
delete_insn (before);
}
  else
gcc_assert (!JUMP_P (last));

The assert is triggered because we're removing an edge which ends on
a conditional jump, which is part of a loop.

The reason for the existence of this loop is the size of the vector used in
gcc.dg/pr77834.c.
When compiling code which uses vectors for MIPS, a looping memcpy is generated
if the vectors are big enough (>32 bytes for MIPS32 or >64 bytes for MIPS64).
This takes place in mips_expand_block_move (gcc/config/mips.c).

In our case, a looping memcpy gets generated for a partition copy which is
inserted on an edge (in insert_partition_copy_on_edge, gcc/tree-outof-ssa.c).
This happens during PHI node elimination, which is done by eliminate_phi
(gcc/tree-outof-ssa.c), as a part of expand_phi_nodes, which is called by the
expand pass (gcc/cfgexpand.c).

My original fix was to update the CFG by calling find_many_sub_basic_blocks
with an all-one block bitmap (which also happens in cfgexpand.c, after edge
removal) whenever an edge contains an insn which satisfies control_flow_insn_p.
However, Segher Boessenkool said that this would be too risky for stage 4
and suggested inserting a NOP after the conditional jump in order to fool the
assert. This assumes that it is safe to delay the CFG update for this
particular case.

This patch changes mips_block_move_loop to emit a NOP after the conditional
jump, if the jump is the last insn of the loop. This prevents
"gcc_assert (!JUMP_P (last))" from triggering.

The NOP will never make it into the final assembly code because it is removed
during the cse1 pass through DCE for -O1, -O2, and -O3, and it's not even
emitted for -O0 and -Os because looping memcpy's are not generated for those
optimization levels, as can be seen in mips_expand_block_move from mips.c:

  if (INTVAL (length) <= MIPS_MAX_MOVE_BYTES_STRAIGHT)
{
  mips_block_move_straight (dest, src, INTVAL (length));
  return true;
}
  else if (optimize)
{
  mips_block_move_loop (dest, src, INTVAL (length),
MIPS_MAX_MOVE_BYTES_PER_LOOP_ITER);
  return true;
}

Tested with mips-mti-elf.

Regards,
Toma Tabacu

gcc/

* config/mips/mips.c (mips_block_move_loop): Emit a NOP after the
conditional jump, if the jump is the last insn of the loop.

diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 4e13fbe..43e719f 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -8098,6 +8098,9 @@ mips_block_move_loop (rtx dest, rtx src, HOST_WIDE_INT 
length,
   /* Mop up any left-over bytes.  */
   if (leftover)
 mips_block_move_straight (dest, src, leftover);
+  else
+/* Temporary fix for PR79150.  */
+emit_insn (gen_nop ());
 }
 
 /* Expand a movmemsi instruction, which copies LENGTH bytes from



Re: [PATCH] i386: Do not align small stack slots to 16 bytes

2017-03-07 Thread Segher Boessenkool
On Tue, Mar 07, 2017 at 08:23:17AM +0100, Uros Bizjak wrote:
> > 2017-03-06  Segher Boessenkool  
> >
> > * gcc/config/i386/i386.c (ix86_local_alignment): Align most 
> > aggregates
> > of 16 bytes and more to 16 bytes, not those of 16 bits and more.
> 
> OK for trunk and backports.

I did trunk; could you handle the backports?  I'm not set up to test x86
on old branches.


Segher


Re: [PATCH] PR libstdc++/79789 fix non-reserved names in headers

2017-03-07 Thread Jonathan Wakely

On 03/03/17 10:47 -0500, David Edelsohn wrote:

This patch caused a new regression on AIX.

- David

FAIL: 17_intro/names.cc (test for excess errors)
Excess errors:
/tmp/GCC/gcc/include-fixed/sys/types.h:600: error: expected
unqualified-id before '[' token
/tmp/GCC/gcc/include-fixed/sys/types.h:600: error: expected ')' before '[' token
/tmp/GCC/gcc/include-fixed/sys/types.h:668: error: expected
unqualified-id before '[' token
/tmp/GCC/gcc/include-fixed/sys/types.h:668: error: expected ')' before '[' token
/tmp/GCC/gcc/include-fixed/stdlib.h:332: error: 'parameter' declared
as function returning a function
/tmp/GCC/gcc/include-fixed/stdlib.h:332: error: expected
primary-expression before 'void'
/tmp/GCC/gcc/include-fixed/math.h:1458: error: expected unqualified-id
before ',' token
/tmp/GCC/gcc/include-fixed/math.h:1458: error: expected ')' before ',' token

AIX types.h:600 is

typedef struct { int r[1]; } *  physadr_t;

stdlib.h:332 is

   extern int  at_quick_exit(void (*f)(void));

math.h:1458 is

struct dbl_hypot {
double x, y;
};


I think the AIX headers should be using reserved names there, but this
should fix it:

--- a/libstdc++-v3/testsuite/17_intro/names.cc
+++ b/libstdc++-v3/testsuite/17_intro/names.cc
@@ -55,7 +55,9 @@
//  and  defined data members called c
#define d (
#define e (
+#ifndef _AIX
#define f (
+#endif
#define g (
#if __cplusplus >= 201402L
//  defines operator ""h in C++14
@@ -84,7 +86,9 @@
#define p (
#endif
#define q (
+#ifndef _AIX
#define r (
+#endif
#if __cplusplus >= 201103L
//  defines member functions called s() and t()
//  and  define operator ""s in C++14
@@ -95,7 +99,9 @@
#define u (
#define v (
#define w (
+#ifndef _AIX
#define x (
#define y (
+#endif
#define z (
#include 

I'll test it later today.




Re: [PATCH] For broken exception handling in GDB on AIX platform

2017-03-07 Thread Nitish Kumar Mishra
Hi,

I have update the patch according to some comments from GDB community.
Please find the attachments.

Thanks and Regards,
Nitish K Mishra

On Wed, Mar 1, 2017 at 1:33 PM, Nitish Kumar Mishra
 wrote:
> Hi,
> I have opened a defect for the same here:
> https://sourceware.org/bugzilla/show_bug.cgi?id=21187
>
> Thanks and Regards,
> Nitish K Mishra
>
> On Wed, Mar 1, 2017 at 1:25 PM, Nitish Kumar Mishra
>  wrote:
>> Hi,
>> The patch is for the broken exception handling in GDB on AIX platform.
>> When linked statically with libstdc++ and libgcc on AIX platform, GDB
>> is facing broken exception handling issues.
>> Following is the error output when GDB is linked statically with
>> mentioned libraries: (GDB-7.12.1, built with GCC-6.2, 64 bit mode, AIX
>> platform):
>>
>> # ./gdb
>> GNU gdb (GDB) 7.12.1
>> Copyright (C) 2017 Free Software Foundation, Inc.
>> License GPLv3+: GNU GPL version 3 or later 
>> This is free software: you are free to change and redistribute it.
>> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
>> and "show warranty" for details.
>> This GDB was configured as "powerpc64-ibm-aix7.2.0.0".
>> Type "show configuration" for configuration details.
>> For bug reporting instructions, please see:
>> .
>> Find the GDB manual and other documentation resources online at:
>> .
>> For help, type "help".
>> Type "apropos word" to search for commands related to "word".
>> (gdb) kill
>> terminate called after throwing an instance of 
>> 'gdb_exception_RETURN_MASK_ERROR'
>> IOT/Abort trap (core dumped)
>>
>>
>> The issue has been discussed here:
>> https://sourceware.org/ml/gdb/2017-02/msg00047.html
>>
>> I have manually built and tested GDB-7.12.1 with this patch on AIX-7.2
>> and Ubuntu-16.04 with GCC-6.2 and GCC-4.8.5. On both operating system
>> GDB is working fine with the patch. I generated configure file using
>> autoconf-2.64.
>>
>> The attached patch is for configure.ac file in binutils-gdb, in which
>> one more option "--disable-staticlib" is implemented to link libstdc++
>> and libgcc dynamically.
>> I believe this issue is specific to AIX platform.
>>
>> Please find the attachment for patch file, and ChangeLog file.
>>
>> Thanks and Regards,
>> Nitish K Mishra
2016-03-01  Nitish K Mishra  

* configure.ac: Include one more option "--disable-staticlib"
to link libstdc++ and libgcc dynamically.diff --git a/configure.ac b/configure.ac
index 3ec86c1..c400251 100644
--- a/configure.ac
+++ b/configure.ac
@@ -140,7 +140,7 @@ host_libs="intl libiberty opcodes bfd readline tcl tk itcl libgui zlib libbacktr
 # binutils, gas and ld appear in that order because it makes sense to run
 # "make check" in that particular order.
 # If --enable-gold is used, "gold" may replace "ld".
-host_tools="texinfo flex bison binutils gas ld fixincludes gcc cgen sid sim gdb gprof etc expect dejagnu m4 utils guile fastjar gnattools libcc1 gotools"
+host_tools="flex bison binutils gas ld fixincludes gcc cgen sid sim gdb gprof etc expect dejagnu m4 utils guile fastjar gnattools libcc1 gotools"
 
 # libgcj represents the runtime libraries only used by gcj.
 libgcj="target-libffi \
@@ -337,7 +337,7 @@ case "${ENABLE_GOLD}" in
   *-*-elf* | *-*-sysv4* | *-*-unixware* | *-*-eabi* | hppa*64*-*-hpux* \
   | *-*-linux* | *-*-gnu* | frv-*-uclinux* | *-*-irix5* | *-*-irix6* \
   | *-*-netbsd* | *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* \
-  | *-*-solaris2* | *-*-nto* | *-*-nacl* | *-*-fuchsia*)
+  | *-*-solaris2* | *-*-nto* | *-*-nacl*)
 case "${target}" in
   *-*-linux*aout* | *-*-linux*oldld*)
 ;;
@@ -471,6 +471,13 @@ ENABLE_LIBSTDCXX=default)
   noconfigdirs="$noconfigdirs target-libstdc++-v3"
 fi]
 
+AC_ARG_ENABLE(staticlib,
+AS_HELP_STRING([--disable-staticlib],
+  [do not link libstdc++ and libgcc library statically, default is static linking]),
+ENABLE_STATICLIB=$enableval,
+ENABLE_STATICLIB=yes)
+
+
 # If this is accelerator compiler and its target is intelmic we enable
 # target liboffloadmic by default.  If this is compiler with offloading
 # for intelmic we enable host liboffloadmic by default.  Otherwise
@@ -1406,9 +1413,10 @@ if test -z "$LD"; then
   fi
 fi
 
-# Check whether -static-libstdc++ -static-libgcc is supported.
+# If ENABLE_STATICLIB is set for configuration, check whether -static-libstdc++ -static-libgcc is supported
 have_static_libs=no
-if test "$GCC" = yes; then
+if test "$ENABLE_STATICLIB" = yes; then
+ if test "$GCC" = yes; then
   saved_LDFLAGS="$LDFLAGS"
 
   LDFLAGS="$LDFLAGS -static-libstdc++ -static-libgcc"
@@ -1424,6 +1432,7 @@ int main() {}],
   AC_LANG_POP(C++)
 
   LDFLAGS="$saved_LDFLAGS"
+ fi
 fi
 
 ACX_PROG_GNAT
@@ -1741,6 +1750,9 @@ AC_ARG_WITH(stage1-ldflags,
  # trust that they are doing what they want.
  if test "$stage1_libs" = "" -a "$have_static_libs" = yes; then
sta

Re: [PATCH, rs6000][GCC6] Fix PR78543, ICE in push_reload on powerpc64le-linux-gnu

2017-03-07 Thread Ulrich Weigand
Peter Bergner wrote:

> If we look at rs6000_mode_dependent_address(), it accepts some addresses
> as not being mode dependent:
> 
> case PLUS:
>   /* Any offset from virtual_stack_vars_rtx and arg_pointer_rtx
>  is considered a legitimate address before reload, so there
>  are no offset restrictions in that case.  Note that this
>  condition is safe in strict mode because any address involving
>  virtual_stack_vars_rtx or arg_pointer_rtx would already have
>  been rejected as illegitimate.  */
>   if (XEXP (addr, 0) != virtual_stack_vars_rtx
>   && XEXP (addr, 0) != arg_pointer_rtx
>   && GET_CODE (XEXP (addr, 1)) == CONST_INT)
> {
>   unsigned HOST_WIDE_INT val = INTVAL (XEXP (addr, 1));
>   return val + 0x8000 >= 0x1 - (TARGET_POWERPC64 ? 8 : 12);
> }
>   break;
> 
> It seems wrong that we accept addresses based off virtual_stack_vars_rtx
> and arg_pointer_rtx, but not stack_pointer_rtx (ie, r1) like we have in
> these test cases.

This check is usually done in legitimate_address_p, and there this
distinction is in fact correct: the problem is that when rewriting
an address based on a virtual register into one based on the stack
(or frame) pointer, the offset will change, and may change significantly.
(E.g. you may end up with "frame size - original offset".)

This means that checking the offset relative to the virtual register
is completely pointless:
(A) If the offset relative to the virtual register is in range, the
resulting offset relative to the stack pointer may be out of range.
(B) If the offset relative to the virtual register is out of range,
the resulting offset may still end up *in* range.

Because of (A), reload will re-check offsets after eliminating
registers, and fix up offsets that are now out of range.  But
because if (B), if we were to reject out-of-range offsets relative
to a virtual register already in legitimate_address_p, we'd already
commit to generatcwinge more complex code (e.g. precomputing the address)
and even if the final offset would be in range, nobody would then
clean up that unnecessary code any more.

That is why the legitimate_address_p deliberately and correctly
accepts *any* offset for virtual (and eliminable) registers,
thereby deferring the offset validity check until after the
register has been replaced by a real register.  But for any
actually real register (like the stack pointer), of course we
*do* have to perform the precise check -- nobody would do that
check otherwise, and we'd end up with invalid instructions.


Now, here we are in mode_dependent_address, which in general
should return true if legitimate_address_p on this address might
return different results depending on the mode of the address.

And in fact, for stack-pointer based addresses, legitimate_address_p
*can* return different results depending on the mode, as the comment
in front of mode_dependent_address explains:

/* Go to LABEL if ADDR (a legitimate address expression)
   has an effect that depends on the machine mode it is used for.

   On the RS/6000 this is true of all integral offsets (since AltiVec
   and VSX modes don't allow them) or is a pre-increment or decrement.


On the other hand, for addresses based on a virtual register,
legitimate_address_p does not depend on the mode since those
are special-cased to be always accepted (see the discussion above).

So I'm not sure that the proposed change is in fact correct ...

Bye,
Ulrich

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



[OBVIOUS][PATCH] gcov: put comment to correct location.

2017-03-07 Thread Martin Liška
Hello.

The issues was created when I added new option (-x).

Martin
>From 4015b8f22dbdf8d3019ce4a8927c5f91bef7258b Mon Sep 17 00:00:00 2001
From: marxin 
Date: Tue, 7 Mar 2017 14:51:08 +0100
Subject: [PATCH] gcov: put comment to correct location.

gcc/ChangeLog:

2017-03-07  Martin Liska  

	* gcov.c (process_args): Put comment to correct location.
---
 gcc/gcov.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/gcov.c b/gcc/gcov.c
index 06880c1d182..4198decdabc 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -776,11 +776,11 @@ process_args (int argc, char **argv)
 case 'd':
   flag_display_progress = 1;
   break;
-	case 'v':
-	  print_version ();
 	case 'x':
 	  flag_hash_filenames = 1;
 	  break;
+	case 'v':
+	  print_version ();
 	  /* print_version will exit.  */
 	default:
 	  print_usage (true);
-- 
2.11.1



Re: [PATCH 0/5] Fix various MPX issues

2017-03-07 Thread Martin Liška
On 03/07/2017 11:26 AM, Uros Bizjak wrote:
> Hello!
> 
>> I'm sending a small series that fixes MPX issue that are quite easily 
>> fixable.
>> The series can bootstrap on ppc64le and survives regression tests.
> 
> Several testcases in the serie are put outside gcc.target/i386
> directory. You need full target specifier in these cases, "{ {
> i?86-*-* x86_64-*-* } && { ! x32 } }".
> 
> Uros.
> 

Thanks for noticing, I'll re-send patches. As Jakub notified me, I also run
regression tests on a x86_64-linux-gnu machine and it works fine.

M.


Re: [PATCH 2/5] Get bounds for a PARM_DECL (PR ipa/79761).

2017-03-07 Thread Martin Liška
On 03/07/2017 11:16 AM, Rainer Orth wrote:
> marxin  writes:
> 
>> diff --git a/gcc/testsuite/g++.dg/pr79761.C b/gcc/testsuite/g++.dg/pr79761.C
>> new file mode 100644
>> index 000..b1f92d2b036
>> --- /dev/null
>> +++ b/gcc/testsuite/g++.dg/pr79761.C
>> @@ -0,0 +1,34 @@
>> +/* { dg-do compile { target { ! x32 } } } */
>> +/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms" } */
> 
> This isn't right: the test must be restricted to x86 targets like
> g++.dg/pr71633.C.
> 
>   Rainer
> 

Thanks. I'm sending v2 of the patch.

Martin
>From e42fa451780336b06bd8fb63ab352a9cb72323ee Mon Sep 17 00:00:00 2001
From: marxin 
Date: Thu, 2 Mar 2017 18:06:39 +0100
Subject: [PATCH 2/5] Get bounds for a PARM_DECL (PR ipa/79761).

gcc/ChangeLog:

2017-03-06  Martin Liska  

	PR ipa/79761
	* tree-chkp.c (chkp_get_bound_for_parm): Get bounds for a param.
	(chkp_find_bounds_1): Remove gcc_unreachable.

gcc/testsuite/ChangeLog:

2017-03-06  Martin Liska  

	PR ipa/79761
	* g++.dg/pr79761.C: New test.
---
 gcc/testsuite/g++.dg/pr79761.C | 34 ++
 gcc/tree-chkp.c|  3 +--
 2 files changed, 35 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/pr79761.C

diff --git a/gcc/testsuite/g++.dg/pr79761.C b/gcc/testsuite/g++.dg/pr79761.C
new file mode 100644
index 000..a97325a1fc4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr79761.C
@@ -0,0 +1,34 @@
+/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && { ! x32 } } } } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms" } */
+
+struct Foo
+{
+  Foo() : a(1), b(1), c('a') {}
+  int a;
+  int b;
+  char c;
+};
+
+static Foo copy_foo(Foo) __attribute__((noinline, noclone));
+
+static Foo copy_foo(Foo A)
+{
+  return A;
+}
+
+struct Bar : Foo
+{
+  Bar(Foo t) : Foo(copy_foo(t)) {}
+};
+
+Foo F;
+
+int main (void)
+{
+  Bar B (F);
+
+  if (B.a != 1 || B.b != 1 || B.c != 'a')
+__builtin_abort ();
+
+  return 0;
+}
diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index 3d497f51ed8..d5683b1b9cf 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -2353,7 +2353,7 @@ chkp_get_next_bounds_parm (tree parm)
 static tree
 chkp_get_bound_for_parm (tree parm)
 {
-  tree decl = SSA_NAME_VAR (parm);
+  tree decl = TREE_CODE (parm) == PARM_DECL ? parm : SSA_NAME_VAR (parm);
   tree bounds;
 
   gcc_assert (TREE_CODE (decl) == PARM_DECL);
@@ -3602,7 +3602,6 @@ chkp_find_bounds_1 (tree ptr, tree ptr_src, gimple_stmt_iterator *iter)
   break;
 
 case PARM_DECL:
-  gcc_unreachable ();
   bounds = chkp_get_bound_for_parm (ptr_src);
   break;
 
-- 
2.11.1



Re: [PATCH 5/5] Support BIT_FIELD_REF in MPX (PR ipa/79764).

2017-03-07 Thread Martin Liška
On 03/07/2017 11:18 AM, Rainer Orth wrote:
> marxin  writes:
> 
>> diff --git a/gcc/testsuite/g++.dg/pr79764.C b/gcc/testsuite/g++.dg/pr79764.C
>> new file mode 100644
>> index 000..47fb88da19b
>> --- /dev/null
>> +++ b/gcc/testsuite/g++.dg/pr79764.C
>> @@ -0,0 +1,12 @@
>> +/* { dg-do compile { target { ! x32 } } } */
>> +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
> 
> Same here.
> 
>   Rainer
> 

Thanks. I'm sending v2 of the patch.

Martin
>From 7c54acbb0a2d36a3d1676533937d78b3e0a40874 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Thu, 2 Mar 2017 17:52:03 +0100
Subject: [PATCH 5/5] Support BIT_FIELD_REF in MPX (PR ipa/79764).

gcc/ChangeLog:

2017-03-06  Martin Liska  

	PR ipa/79764
	* tree-chkp.c (chkp_narrow_bounds_for_field): Fix typo in
	comment.
	(chkp_narrow_size_and_offset): New function.
	(chkp_parse_array_and_component_ref): Support BIT_FIELD_REF.
	(void chkp_parse_bit_field_ref): New function.
	(chkp_make_addressed_object_bounds): Add case for BIT_FIELD_REF.
	(chkp_process_stmt): Use chkp_parse_bit_field_ref.

gcc/testsuite/ChangeLog:

2017-03-06  Martin Liska  

	PR ipa/79764
	* g++.dg/pr79764.C: New test.
---
 gcc/testsuite/g++.dg/pr79764.C | 12 ++
 gcc/tree-chkp.c| 90 ++
 2 files changed, 85 insertions(+), 17 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/pr79764.C

diff --git a/gcc/testsuite/g++.dg/pr79764.C b/gcc/testsuite/g++.dg/pr79764.C
new file mode 100644
index 000..293aa337693
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr79764.C
@@ -0,0 +1,12 @@
+/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && { ! x32 } } } } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
+
+typedef float __m256 __attribute__ (( __vector_size__(32), __may_alias__ ));
+struct A {
+  __m256 ymm;
+  const float &f() const;
+};
+
+const float &A::f() const {
+  return ymm[1];
+}
diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index d5683b1b9cf..14ebff294f9 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -325,6 +325,8 @@ static void chkp_parse_array_and_component_ref (tree node, tree *ptr,
 		tree *bounds,
 		gimple_stmt_iterator *iter,
 		bool innermost_bounds);
+static void chkp_parse_bit_field_ref (tree node, location_t loc,
+  tree *offset, tree *size);
 
 #define chkp_bndldx_fndecl \
   (targetm.builtin_chkp_function (BUILT_IN_CHKP_BNDLDX))
@@ -3266,7 +3268,7 @@ chkp_intersect_bounds (tree bounds1, tree bounds2, gimple_stmt_iterator *iter)
 }
 
 /* Return 1 if we are allowed to narrow bounds for addressed FIELD
-   and 0 othersize.  */
+   and 0 otherwise.  */
 static bool
 chkp_may_narrow_to_field (tree field)
 {
@@ -3294,7 +3296,7 @@ chkp_narrow_bounds_for_field (tree field)
   if (!chkp_may_narrow_to_field (field))
 return false;
 
-  /* Accesse to compiler generated fields should not cause
+  /* Access to compiler generated fields should not cause
  bounds narrowing.  */
   if (DECL_ARTIFICIAL (field))
 return false;
@@ -3308,9 +3310,36 @@ chkp_narrow_bounds_for_field (tree field)
 	  || bit_offs));
 }
 
+/* Perform narrowing for BOUNDS of an INNER reference.  Shift boundary
+   by OFFSET bytes and limit to SIZE bytes.  Newly created statements are
+   added to ITER.  */
+
+static tree
+chkp_narrow_size_and_offset (tree bounds, tree inner, tree offset,
+			 tree size, gimple_stmt_iterator *iter)
+{
+  tree addr = chkp_build_addr_expr (unshare_expr (inner));
+  tree t = TREE_TYPE (addr);
+
+  gimple *stmt = gimple_build_assign (NULL_TREE, addr);
+  addr = make_temp_ssa_name (t, stmt, CHKP_BOUND_TMP_NAME);
+  gimple_assign_set_lhs (stmt, addr);
+  gsi_insert_seq_before (iter, stmt, GSI_SAME_STMT);
+
+  stmt = gimple_build_assign (NULL_TREE, POINTER_PLUS_EXPR, addr, offset);
+  tree shifted = make_temp_ssa_name (t, stmt, CHKP_BOUND_TMP_NAME);
+  gimple_assign_set_lhs (stmt, shifted);
+  gsi_insert_seq_before (iter, stmt, GSI_SAME_STMT);
+
+  tree bounds2 = chkp_make_bounds (shifted, size, iter, false);
+
+  return chkp_intersect_bounds (bounds, bounds2, iter);
+}
+
 /* Perform narrowing for BOUNDS using bounds computed for field
access COMPONENT.  ITER meaning is the same as for
chkp_intersect_bounds.  */
+
 static tree
 chkp_narrow_bounds_to_field (tree bounds, tree component,
 			gimple_stmt_iterator *iter)
@@ -3363,7 +3392,8 @@ chkp_parse_array_and_component_ref (tree node, tree *ptr,
   len = 1;
   while (TREE_CODE (var) == COMPONENT_REF
 	 || TREE_CODE (var) == ARRAY_REF
-	 || TREE_CODE (var) == VIEW_CONVERT_EXPR)
+	 || TREE_CODE (var) == VIEW_CONVERT_EXPR
+	 || TREE_CODE (var) == BIT_FIELD_REF)
 {
   var = TREE_OPERAND (var, 0);
   len++;
@@ -3382,9 +3412,10 @@ chkp_parse_array_and_component_ref (tree node, tree *ptr,
   if (bounds)
 *bounds = NULL;
   *safe = true;
-  *bitfield = (TREE_CODE (node) == COMPONENT_REF
-	   && DECL_BIT_FIELD_TYPE (TREE_OPERAND (node, 1)));
-  /* To get bitfield address we will need outer elemnt.

Re: [PATCH 1/5] Fix *_CST ICEs connected to MPX.

2017-03-07 Thread Martin Liška
On 03/07/2017 11:17 AM, Rainer Orth wrote:
> marxin  writes:
> 
>> diff --git a/gcc/testsuite/g++.dg/pr79769.C b/gcc/testsuite/g++.dg/pr79769.C
>> new file mode 100644
>> index 000..f9223db1b2d
>> --- /dev/null
>> +++ b/gcc/testsuite/g++.dg/pr79769.C
>> @@ -0,0 +1,4 @@
>> +/* { dg-do compile { target { ! x32 } } } */
>> +/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms" } */
> 
> ... and again: make this x86-only.
> 
>   Rainer
> 

Thanks. I'm sending v2 of the patch.

Martin
>From 7abb81c9836562344f49544a98a8afd28a6203e4 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Thu, 2 Mar 2017 17:59:06 +0100
Subject: [PATCH 1/5] Fix *_CST ICEs connected to MPX.

gcc/ChangeLog:

2017-03-06  Martin Liska  

	PR target/79763
	PR target/79769
	PR target/79770
	* tree-chkp.c (chkp_find_bounds_1): Handle REAL_CST,
	COMPLEX_CST and VECTOR_CST.

gcc/testsuite/ChangeLog:

2017-03-06  Martin Liska  

	PR target/79763
	PR target/79769
	PR target/79770
	* g++.dg/pr79769.C: New test.
	* gcc.target/i386/mpx/pr79763.c: New test.
	* gcc.target/i386/mpx/pr79770.c: New test.
---
 gcc/testsuite/g++.dg/pr79769.C  |  4 
 gcc/testsuite/gcc.target/i386/mpx/pr79763.c |  6 ++
 gcc/testsuite/gcc.target/i386/mpx/pr79770.c | 19 +++
 gcc/tree-chkp.c |  3 +++
 4 files changed, 32 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/pr79769.C
 create mode 100644 gcc/testsuite/gcc.target/i386/mpx/pr79763.c
 create mode 100644 gcc/testsuite/gcc.target/i386/mpx/pr79770.c

diff --git a/gcc/testsuite/g++.dg/pr79769.C b/gcc/testsuite/g++.dg/pr79769.C
new file mode 100644
index 000..c3186877f60
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr79769.C
@@ -0,0 +1,4 @@
+/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && { ! x32 } } } } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms" } */
+
+void a (_Complex) { a (3); }
diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr79763.c b/gcc/testsuite/gcc.target/i386/mpx/pr79763.c
new file mode 100644
index 000..59c2dececc2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/mpx/pr79763.c
@@ -0,0 +1,6 @@
+/* { dg-do compile { target { ! x32 } } } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms" } */
+
+int q_sk_num(void *a);
+typedef int (*fptr)(double);
+void a() { ((fptr)q_sk_num)(0); } /* { dg-warning "function called through a non-compatible type" } */
diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr79770.c b/gcc/testsuite/gcc.target/i386/mpx/pr79770.c
new file mode 100644
index 000..0890fcc7bf1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/mpx/pr79770.c
@@ -0,0 +1,19 @@
+/* { dg-do compile { target lp64 } } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms -Wno-psabi" } */
+
+typedef unsigned U __attribute__ ((vector_size (64)));
+typedef unsigned __int128 V __attribute__ ((vector_size (64)));
+
+static inline V
+bar (U u, U x, V v)
+{
+  v = (V)(U) { 0, ~0 };
+  v[x[0]] <<= u[-63];
+  return v;
+}
+
+V
+foo (U u)
+{
+  return bar (u, (U) {}, (V) {});
+}
diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index 02ae2d2d2c7..3d497f51ed8 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -3665,6 +3665,9 @@ chkp_find_bounds_1 (tree ptr, tree ptr_src, gimple_stmt_iterator *iter)
   break;
 
 case INTEGER_CST:
+case REAL_CST:
+case COMPLEX_CST:
+case VECTOR_CST:
   if (integer_zerop (ptr_src))
 	bounds = chkp_get_none_bounds ();
   else
-- 
2.11.1



Re: [PATCH 1/5] Fix *_CST ICEs connected to MPX.

2017-03-07 Thread Richard Biener
On Tue, Mar 7, 2017 at 3:48 PM, Martin Liška  wrote:
> On 03/07/2017 11:17 AM, Rainer Orth wrote:
>> marxin  writes:
>>
>>> diff --git a/gcc/testsuite/g++.dg/pr79769.C b/gcc/testsuite/g++.dg/pr79769.C
>>> new file mode 100644
>>> index 000..f9223db1b2d
>>> --- /dev/null
>>> +++ b/gcc/testsuite/g++.dg/pr79769.C
>>> @@ -0,0 +1,4 @@
>>> +/* { dg-do compile { target { ! x32 } } } */
>>> +/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms" } */
>>
>> ... and again: make this x86-only.
>>
>>   Rainer
>>
>
> Thanks. I'm sending v2 of the patch.

Hmm, not sure why we should handle REAL_CST here explicitely for example.

Why not, instead of internal_error in the default: case do

  bounds = chkp_get_invalid_op_bounds ();

there?  For the testcase why do we invoke chkp_find_bounds_1 on sth that is
a REAL_CST for example?

Richard.

> Martin


Re: [PATCH 2/5] Get bounds for a PARM_DECL (PR ipa/79761).

2017-03-07 Thread Richard Biener
On Thu, Mar 2, 2017 at 6:06 PM, marxin  wrote:
> gcc/ChangeLog:
>
> 2017-03-06  Martin Liska  
>
> PR ipa/79761
> * tree-chkp.c (chkp_get_bound_for_parm): Get bounds for a param.
> (chkp_find_bounds_1): Remove gcc_unreachable.
>
> gcc/testsuite/ChangeLog:
>
> 2017-03-06  Martin Liska  
>
> PR ipa/79761
> * g++.dg/pr79761.C: New test.
> ---
>  gcc/testsuite/g++.dg/pr79761.C | 34 ++
>  gcc/tree-chkp.c|  3 +--
>  2 files changed, 35 insertions(+), 2 deletions(-)
>  create mode 100644 gcc/testsuite/g++.dg/pr79761.C
>
> diff --git a/gcc/testsuite/g++.dg/pr79761.C b/gcc/testsuite/g++.dg/pr79761.C
> new file mode 100644
> index 000..b1f92d2b036
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/pr79761.C
> @@ -0,0 +1,34 @@
> +/* { dg-do compile { target { ! x32 } } } */
> +/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms" } */
> +
> +struct Foo
> +{
> +  Foo() : a(1), b(1), c('a') {}
> +  int a;
> +  int b;
> +  char c;
> +};
> +
> +static Foo copy_foo(Foo) __attribute__((noinline, noclone));
> +
> +static Foo copy_foo(Foo A)
> +{
> +  return A;
> +}
> +
> +struct Bar : Foo
> +{
> +  Bar(Foo t) : Foo(copy_foo(t)) {}
> +};
> +
> +Foo F;
> +
> +int main (void)
> +{
> +  Bar B (F);
> +
> +  if (B.a != 1 || B.b != 1 || B.c != 'a')
> +__builtin_abort ();
> +
> +  return 0;
> +}
> diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
> index 3d497f51ed8..d5683b1b9cf 100644
> --- a/gcc/tree-chkp.c
> +++ b/gcc/tree-chkp.c
> @@ -2353,7 +2353,7 @@ chkp_get_next_bounds_parm (tree parm)
>  static tree
>  chkp_get_bound_for_parm (tree parm)
>  {
> -  tree decl = SSA_NAME_VAR (parm);
> +  tree decl = TREE_CODE (parm) == PARM_DECL ? parm : SSA_NAME_VAR (parm);
>tree bounds;
>
>gcc_assert (TREE_CODE (decl) == PARM_DECL);
> @@ -3602,7 +3602,6 @@ chkp_find_bounds_1 (tree ptr, tree ptr_src, 
> gimple_stmt_iterator *iter)
>break;
>
>  case PARM_DECL:
> -  gcc_unreachable ();
>bounds = chkp_get_bound_for_parm (ptr_src);

But this is just useless work ... just do

  case PARM_DECL:
 /* Handled above but failed.  */
 break;

the SSA_NAME case is similarly redundantly calling chkp_get_registered_bounds.

Richard.

>break;
>
> --
> 2.11.1
>
>


Re: [PATCH 5/5] Support BIT_FIELD_REF in MPX (PR ipa/79764).

2017-03-07 Thread Richard Biener
On Tue, Mar 7, 2017 at 3:49 PM, Martin Liška  wrote:
> On 03/07/2017 11:18 AM, Rainer Orth wrote:
>> marxin  writes:
>>
>>> diff --git a/gcc/testsuite/g++.dg/pr79764.C b/gcc/testsuite/g++.dg/pr79764.C
>>> new file mode 100644
>>> index 000..47fb88da19b
>>> --- /dev/null
>>> +++ b/gcc/testsuite/g++.dg/pr79764.C
>>> @@ -0,0 +1,12 @@
>>> +/* { dg-do compile { target { ! x32 } } } */
>>> +/* { dg-options "-fcheck-pointer-bounds -mmpx" } */
>>
>> Same here.
>>
>>   Rainer
>>
>
> Thanks. I'm sending v2 of the patch.

Ok.

Richard.

> Martin


Re: [PATCH 2/5] Get bounds for a PARM_DECL (PR ipa/79761).

2017-03-07 Thread Martin Liška
On 03/07/2017 03:57 PM, Richard Biener wrote:
> On Thu, Mar 2, 2017 at 6:06 PM, marxin  wrote:
>> gcc/ChangeLog:
>>
>> 2017-03-06  Martin Liska  
>>
>> PR ipa/79761
>> * tree-chkp.c (chkp_get_bound_for_parm): Get bounds for a param.
>> (chkp_find_bounds_1): Remove gcc_unreachable.
>>
>> gcc/testsuite/ChangeLog:
>>
>> 2017-03-06  Martin Liska  
>>
>> PR ipa/79761
>> * g++.dg/pr79761.C: New test.
>> ---
>>  gcc/testsuite/g++.dg/pr79761.C | 34 ++
>>  gcc/tree-chkp.c|  3 +--
>>  2 files changed, 35 insertions(+), 2 deletions(-)
>>  create mode 100644 gcc/testsuite/g++.dg/pr79761.C
>>
>> diff --git a/gcc/testsuite/g++.dg/pr79761.C b/gcc/testsuite/g++.dg/pr79761.C
>> new file mode 100644
>> index 000..b1f92d2b036
>> --- /dev/null
>> +++ b/gcc/testsuite/g++.dg/pr79761.C
>> @@ -0,0 +1,34 @@
>> +/* { dg-do compile { target { ! x32 } } } */
>> +/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms" } */
>> +
>> +struct Foo
>> +{
>> +  Foo() : a(1), b(1), c('a') {}
>> +  int a;
>> +  int b;
>> +  char c;
>> +};
>> +
>> +static Foo copy_foo(Foo) __attribute__((noinline, noclone));
>> +
>> +static Foo copy_foo(Foo A)
>> +{
>> +  return A;
>> +}
>> +
>> +struct Bar : Foo
>> +{
>> +  Bar(Foo t) : Foo(copy_foo(t)) {}
>> +};
>> +
>> +Foo F;
>> +
>> +int main (void)
>> +{
>> +  Bar B (F);
>> +
>> +  if (B.a != 1 || B.b != 1 || B.c != 'a')
>> +__builtin_abort ();
>> +
>> +  return 0;
>> +}
>> diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
>> index 3d497f51ed8..d5683b1b9cf 100644
>> --- a/gcc/tree-chkp.c
>> +++ b/gcc/tree-chkp.c
>> @@ -2353,7 +2353,7 @@ chkp_get_next_bounds_parm (tree parm)
>>  static tree
>>  chkp_get_bound_for_parm (tree parm)
>>  {
>> -  tree decl = SSA_NAME_VAR (parm);
>> +  tree decl = TREE_CODE (parm) == PARM_DECL ? parm : SSA_NAME_VAR (parm);
>>tree bounds;
>>
>>gcc_assert (TREE_CODE (decl) == PARM_DECL);
>> @@ -3602,7 +3602,6 @@ chkp_find_bounds_1 (tree ptr, tree ptr_src, 
>> gimple_stmt_iterator *iter)
>>break;
>>
>>  case PARM_DECL:
>> -  gcc_unreachable ();
>>bounds = chkp_get_bound_for_parm (ptr_src);
> 
> But this is just useless work ... just do
> 
>   case PARM_DECL:
>  /* Handled above but failed.  */
>  break;

Ok, let's return invalid bounds. Please see updated patch.

Martin

> 
> the SSA_NAME case is similarly redundantly calling chkp_get_registered_bounds.
> 
> Richard.
> 
>>break;
>>
>> --
>> 2.11.1
>>
>>

>From feb00580b4f084ccd376a548d1121b1718a4806e Mon Sep 17 00:00:00 2001
From: marxin 
Date: Thu, 2 Mar 2017 18:06:39 +0100
Subject: [PATCH 2/5] Get bounds for a PARM_DECL (PR ipa/79761).

gcc/ChangeLog:

2017-03-06  Martin Liska  

	PR ipa/79761
	* tree-chkp.c (chkp_get_bound_for_parm): Get bounds for a param.
	(chkp_find_bounds_1): Remove gcc_unreachable.

gcc/testsuite/ChangeLog:

2017-03-06  Martin Liska  

	PR ipa/79761
	* g++.dg/pr79761.C: New test.
---
 gcc/testsuite/g++.dg/pr79761.C | 34 ++
 gcc/tree-chkp.c|  4 ++--
 2 files changed, 36 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/pr79761.C

diff --git a/gcc/testsuite/g++.dg/pr79761.C b/gcc/testsuite/g++.dg/pr79761.C
new file mode 100644
index 000..a97325a1fc4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr79761.C
@@ -0,0 +1,34 @@
+/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && { ! x32 } } } } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms" } */
+
+struct Foo
+{
+  Foo() : a(1), b(1), c('a') {}
+  int a;
+  int b;
+  char c;
+};
+
+static Foo copy_foo(Foo) __attribute__((noinline, noclone));
+
+static Foo copy_foo(Foo A)
+{
+  return A;
+}
+
+struct Bar : Foo
+{
+  Bar(Foo t) : Foo(copy_foo(t)) {}
+};
+
+Foo F;
+
+int main (void)
+{
+  Bar B (F);
+
+  if (B.a != 1 || B.b != 1 || B.c != 'a')
+__builtin_abort ();
+
+  return 0;
+}
diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index 3d497f51ed8..75d8b5829d0 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -3602,8 +3602,8 @@ chkp_find_bounds_1 (tree ptr, tree ptr_src, gimple_stmt_iterator *iter)
   break;
 
 case PARM_DECL:
-  gcc_unreachable ();
-  bounds = chkp_get_bound_for_parm (ptr_src);
+  /* Handled above but failed.  */
+  bounds = chkp_get_invalid_op_bounds ();
   break;
 
 case TARGET_MEM_REF:
-- 
2.11.1



Re: [PATCH 1/5] Fix *_CST ICEs connected to MPX.

2017-03-07 Thread Martin Liška
On 03/07/2017 03:53 PM, Richard Biener wrote:
> On Tue, Mar 7, 2017 at 3:48 PM, Martin Liška  wrote:
>> On 03/07/2017 11:17 AM, Rainer Orth wrote:
>>> marxin  writes:
>>>
 diff --git a/gcc/testsuite/g++.dg/pr79769.C 
 b/gcc/testsuite/g++.dg/pr79769.C
 new file mode 100644
 index 000..f9223db1b2d
 --- /dev/null
 +++ b/gcc/testsuite/g++.dg/pr79769.C
 @@ -0,0 +1,4 @@
 +/* { dg-do compile { target { ! x32 } } } */
 +/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms" } */
>>>
>>> ... and again: make this x86-only.
>>>
>>>   Rainer
>>>
>>
>> Thanks. I'm sending v2 of the patch.
> 
> Hmm, not sure why we should handle REAL_CST here explicitely for example.
> 
> Why not, instead of internal_error in the default: case do
> 
>   bounds = chkp_get_invalid_op_bounds ();

Because chkp_get_invalid_op_bounds() returns bounds that are always valid and 
as it's
security extension, I would be strict here in order to not handle something 
that can bypass
the checking.

> 
> there?  For the testcase why do we invoke chkp_find_bounds_1 on sth that is
> a REAL_CST for example?

It's called when setting bounds in a call expr:

#0  chkp_find_bounds_1 (ptr=0x76a03720, ptr_src=0x76a03720, 
iter=0x7fffd5d0) at ../../gcc/tree-chkp.c:3734
#1  0x00ec7c7d in chkp_find_bounds (ptr=0x76a03720, 
iter=0x7fffd5d0) at ../../gcc/tree-chkp.c:3768
#2  0x00ec22e1 in chkp_add_bounds_to_call_stmt (gsi=0x7fffd5d0) at 
../../gcc/tree-chkp.c:1901
#3  0x00ec9a1a in chkp_instrument_function () at 
../../gcc/tree-chkp.c:4344
#4  0x00eca4cb in chkp_execute () at ../../gcc/tree-chkp.c:4528

...

Martin

> 
> Richard.
> 
>> Martin



Re: [PATCH 4/5] Disable -fcheck-pointer-bounds with sanitizers.

2017-03-07 Thread Jeff Law

On 03/06/2017 06:07 AM, marxin wrote:

gcc/ChangeLog:

2017-03-06  Martin Liska  

PR target/65705
PR target/69804
* toplev.c (process_options): Disable -fcheck-pointer-bounds with
sanitizers.

gcc/testsuite/ChangeLog:

2017-03-06  Martin Liska  

PR target/65705
PR target/69804
* gcc.target/i386/pr71458.c: Update scanned pattern.

OK.
jeff



Re: [PATCH 2/5] Get bounds for a PARM_DECL (PR ipa/79761).

2017-03-07 Thread Jeff Law

On 03/07/2017 09:07 AM, Martin Liška wrote:

On 03/07/2017 03:57 PM, Richard Biener wrote:

On Thu, Mar 2, 2017 at 6:06 PM, marxin  wrote:

gcc/ChangeLog:

2017-03-06  Martin Liska  

PR ipa/79761
* tree-chkp.c (chkp_get_bound_for_parm): Get bounds for a param.
(chkp_find_bounds_1): Remove gcc_unreachable.

gcc/testsuite/ChangeLog:

2017-03-06  Martin Liska  

PR ipa/79761
* g++.dg/pr79761.C: New test.
---
 gcc/testsuite/g++.dg/pr79761.C | 34 ++
 gcc/tree-chkp.c|  3 +--
 2 files changed, 35 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/pr79761.C

diff --git a/gcc/testsuite/g++.dg/pr79761.C b/gcc/testsuite/g++.dg/pr79761.C
new file mode 100644
index 000..b1f92d2b036
--- /dev/null
+++ b/gcc/testsuite/g++.dg/pr79761.C
@@ -0,0 +1,34 @@
+/* { dg-do compile { target { ! x32 } } } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -mabi=ms" } */
+
+struct Foo
+{
+  Foo() : a(1), b(1), c('a') {}
+  int a;
+  int b;
+  char c;
+};
+
+static Foo copy_foo(Foo) __attribute__((noinline, noclone));
+
+static Foo copy_foo(Foo A)
+{
+  return A;
+}
+
+struct Bar : Foo
+{
+  Bar(Foo t) : Foo(copy_foo(t)) {}
+};
+
+Foo F;
+
+int main (void)
+{
+  Bar B (F);
+
+  if (B.a != 1 || B.b != 1 || B.c != 'a')
+__builtin_abort ();
+
+  return 0;
+}
diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index 3d497f51ed8..d5683b1b9cf 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -2353,7 +2353,7 @@ chkp_get_next_bounds_parm (tree parm)
 static tree
 chkp_get_bound_for_parm (tree parm)
 {
-  tree decl = SSA_NAME_VAR (parm);
+  tree decl = TREE_CODE (parm) == PARM_DECL ? parm : SSA_NAME_VAR (parm);
   tree bounds;

   gcc_assert (TREE_CODE (decl) == PARM_DECL);
@@ -3602,7 +3602,6 @@ chkp_find_bounds_1 (tree ptr, tree ptr_src, 
gimple_stmt_iterator *iter)
   break;

 case PARM_DECL:
-  gcc_unreachable ();
   bounds = chkp_get_bound_for_parm (ptr_src);

But this is just useless work ... just do

  case PARM_DECL:
 /* Handled above but failed.  */
 break;

Ok, let's return invalid bounds. Please see updated patch.

Martin


the SSA_NAME case is similarly redundantly calling chkp_get_registered_bounds.

Richard.


   break;

--
2.11.1




0002-Get-bounds-for-a-PARM_DECL-PR-ipa-79761-v3.patch


From feb00580b4f084ccd376a548d1121b1718a4806e Mon Sep 17 00:00:00 2001
From: marxin 
Date: Thu, 2 Mar 2017 18:06:39 +0100
Subject: [PATCH 2/5] Get bounds for a PARM_DECL (PR ipa/79761).

gcc/ChangeLog:

2017-03-06  Martin Liska  

PR ipa/79761
* tree-chkp.c (chkp_get_bound_for_parm): Get bounds for a param.
(chkp_find_bounds_1): Remove gcc_unreachable.

gcc/testsuite/ChangeLog:

2017-03-06  Martin Liska  

PR ipa/79761
* g++.dg/pr79761.C: New test.
OK.  Sadly, I don't think any of these patches fix the P1 regressions we 
have for MPX.

jeff



Re: [PATCH] PR ada/66205 gnatbind generates invalid code when finalization is enabled in restricted runtime

2017-03-07 Thread Simon Wright
On 19 Dec 2015, at 22:05, Simon Wright  wrote:
> 
> On 12 Nov 2015, at 10:02, Arnaud Charlet  wrote:
>> 
 This situation arises, for example, with an embedded RTS that
 incorporates the
 Ada 2012 generalized container iterators.
>>> 
>>> I should add, this PR is the ???other half??? of PR ada/66242, which is 
>>> fixed
>>> in GCC 6; so please can it be reviewed?
>> 
>> The proper patch for PR ada/66242 hasn't been committed yet (it's pending),
>> so I'd rather review the situation once PR ada/66242 is dealt with.
>> 
>> I'm not convinced at all that your patch is the way to go, so I'd rather
>> consider it only after PR ada/66242 is solved properly.
> 
> Looks as though PR ada/66242 has been sorted out.
> 
> Since we can now *compile* code that is built with finalization enabled in a 
> restricted runtime, but we can't *bind* it, could we take another look at 
> this? the patch I provided in this thread still applies at snapshot 20151213 
> with minor offsets (8).

Same problem exists in gcc version 7.0.1 20170302 (experimental) (GCC).

Note, what may not have been clear before and is now relevant given AdaCore's 
-full- embedded runtimes, the problem occurs when the runtime doesn't support 
exception propagation but does support finalization. As far as gnatbind is 
concerned, "runtime does not support exception propagation" appears to be 
indicated by "Suppress_Standard_Library_On_Target" rather than 
"Cumulative_Restrictions.Set (No_Exception_Propagation)" - the latter is 
partition-wide, so could be used instead maybe?

I attach an updated patch. I've tested the new gnatbind against gcc version 
7.0.1 20170302 (experimental) (GCC) on native x86_64-apple-darwin16 by running 
'make check-ada', and for --target=arm-eabi by successfully making and running 
builds for an STM32F4 target without exception propagation but with and without 
finalization.

I used the same gnatbind for both targets - renamed to arm-eabi-gnatbind for 
those builds - seeing there's no target dependence in gnatbind itself.


gcc/ada/Changelog:

2017-03-07  Simon Wright 

  PR ada/66205
  * bindgen.adb: If the restriction No_Finalization is absent (i.e. 
finalization
is supported) but Suppress_Standard_Library_On_Target is true, then 
- don't import __gnat_initialize or __gnat_finalize (as Initialize, 
Finalize rsp).
- don't call Initialize or Finalize.
- don't generate or call adafinal.



gcc-ada-bindgen.adb.diff
Description: Binary data



Re: [PATCH 4/5] Disable -fcheck-pointer-bounds with sanitizers.

2017-03-07 Thread Jakub Jelinek
On Mon, Mar 06, 2017 at 02:07:37PM +0100, marxin wrote:
>   PR target/65705
>   PR target/69804
>   * toplev.c (process_options): Disable -fcheck-pointer-bounds with
>   sanitizers.

I can understand why it is disabled for -fsanitize=address or
-fsanitize=bounds, perhaps -fsanitize=threads too,
but don't understand why e.g. -fsanitize=shift or -fsanitize=unreachable
or -fsanitize=signed-integer-overflow or -fsanitize=leak (which is purely
a linking option) should affect it.

> +  const char *sanitizer_names[] = { "Address", "Undefined Behavior",
> + "Leak", "Thread" };
> +  const int sanitizer_flags[] = { SANITIZE_ADDRESS, SANITIZE_UNDEFINED,
> + SANITIZE_LEAK, SANITIZE_THREAD };

Even if there is a reason for that, there is also
SANITIZE_NONDEFAULT that is part of UB sanitizer, so if you can't
-fcheck-pointer-bounds with any parts of -fsanitize=undefined, then
likely it applies to others too.
For -fsanitize=bounds-stricts it surely applies though, if -fsanitize=bounds
can't be MPX instrumented.

> +  for (unsigned i = 0; i < sizeof (sanitizer_flags) / sizeof (int); i++)
> + if (flag_sanitize & sanitizer_flags[i])
> +   {
> + error_at (UNKNOWN_LOCATION,
> +   "-fcheck-pointer-bounds is not supported with "
> +   "%s Sanitizer", sanitizer_names[i]);

This is not i18n friendly, I think you just want to unroll the loop
by hand and use 4 (or just 3?) different error_at calls.

Jakub


Re: i386-unknown-freebsd -> i586-unknown-freebsd

2017-03-07 Thread Jeff Law

On 03/04/2017 09:44 AM, Gerald Pfeifer wrote:

On Tue, 24 May 2016, Richard Biener wrote:

Can we update to a non-marketing name then, like i586-unknown-freebsd
please? config.gcc accepts i[34567]86-*-freebsd*.  It at least confused
me.


Of course, once I hacked config.gcc, I realized that the simple
patch below is all you actually may have had in mind. ;-)

Applied.

But let's still consider the config.guess change for GCC 7 as
well, or people might not be _appearing_ to use it, even if it
is practically the same?
No strong opinions here.  Certainly fixing the triplet on the critera 
page is a good thing.


Jeff



Re: [PATCH] Increment value instead of a pointer in ADA macro processing.

2017-03-07 Thread Jeff Law

On 03/07/2017 03:30 AM, Martin Liška wrote:

Hello.

Looks there's real issues spotted by -Wchkp:

../../gcc/c-family/c-ada-spec.c: In function ‘void print_ada_macros.chkp(pretty_printer*, 
\xe2\x80\x98pointer_bounds_typ\xe2\x80\x99 not supported by dump_type#, 
cpp_hashnode**, \xe2\x80\x98pointer_bounds_typ\xe2\x80\x99 not supported by 
dump_type#, int, void, ...)’:
../../gcc/c-family/c-ada-spec.c:80:15: error: memory access check always fail 
[-Werror=chkp]
*param_len += NODE_LEN (param);
~~~^~~~
../../gcc/c-family/c-ada-spec.c:80:15: error: memory access check always fail 
[-Werror=chkp]
../../gcc/c-family/c-ada-spec.c:84:19: error: memory access check always fail 
[-Werror=chkp]
*param_len += 2;  /* ", " */
~~~^~~~
../../gcc/c-family/c-ada-spec.c:84:19: error: memory access check always fail 
[-Werror=chkp]
../../gcc/c-family/c-ada-spec.c:92:18: error: memory access check always fail 
[-Werror=chkp]
   *param_len += 2;  /* ")\0" */
   ~~~^~~~
../../gcc/c-family/c-ada-spec.c:92:18: error: memory access check always fail 
[-Werror=chkp]

I prepared quite obvious fix for that and tested make check -k 
RUNTESTFLAGS="dg.exp=dump-ada-spec-*"
on x86_64-linux-gnu.

Ready to be installed?
Martin


0001-Increment-value-instead-of-a-pointer-in-ADA-macro-pr.patch


From 9137ddcf413585f557c4ef263d731bf457cb79f4 Mon Sep 17 00:00:00 2001
From: marxin 
Date: Tue, 7 Mar 2017 11:10:30 +0100
Subject: [PATCH] Increment value instead of a pointer in ADA macro processing.

gcc/c-family/ChangeLog:

2017-03-07  Martin Liska  

* c-ada-spec.c (macro_length): Increment value instead of a pointer.

OK.

Jeff



Re: [PATCH] Fix ICE with -Walloca-larger-than=[>INT_MAX] (PR middle-end/79809)

2017-03-07 Thread Jeff Law

On 03/02/2017 05:32 AM, Marek Polacek wrote:

As demonstrated by this test, we can crash on the assert in alloca_call_type:
gcc_assert (is_vla || warn_alloca_limit > 0);
when -Walloca-larger-than= receives an argument greater than INT_MAX.  Even
though warn_vla_limit is marked as UInteger in c.opt, those are still
represented as ints; opt-functions.awk has

202 else if (flag_set_p("UInteger", flags))
203 return "int "
...
213 if (flag_set_p("UInteger", flags))
214 return "int "

So 4207115063 is converted to int which is some negative value.

It's probably too late to change opt-functions.awk now, so the following
is a badn aid fix.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2017-03-02  Marek Polacek  

PR middle-end/79809
* gimple-ssa-warn-alloca.c (pass_walloca::gate): Use HOST_WIDE_INT.
(alloca_call_type): Likewise.

* g++.dg/Walloca1.C: New test.

OK.
jeff



Re: i386-unknown-freebsd -> i586-unknown-freebsd

2017-03-07 Thread Jeff Law

On 03/04/2017 09:40 AM, Gerald Pfeifer wrote:

On Tue, 24 May 2016, Richard Biener wrote:

As Jeff noted, i386 actually is the "marketing" name used for the
platform, GCC has been defaulting to i486 for ages, and I upgraded
to i586 last year:

2015-11-15  Gerald Pfeifer  

* config/i386/freebsd.h (SUBTARGET32_DEFAULT_CPU): Change to i586.
Remove support for FreeBSD 5 and earlier.

Can we update to a non-marketing name then, like i586-unknown-freebsd please?
config.gcc accepts i[34567]86-*-freebsd*.  It at least confused me.


Sooo, I finally got to submitting the patch below to the config.guess
maintainers.

When/if this has been accepted, is it okay to pull the latest config.guess
into GCC even at this stage of the release process?  (We're only looking
at this change and the addition of nsx-tandem compared to what we have
right now.)

If it's just those, I'd think it'd be reasonable.

jeff



Re: C PATCH to fix ICE with old-style parameter declarations with initializers (PR sanitizer/79757)

2017-03-07 Thread Jeff Law

On 03/06/2017 02:44 PM, Marek Polacek wrote:

This is an ICE with -fsanitize=undefined on invalid code involving old-style
parameter declarations and nested functions.  Ugh.

Old-style parameter declarations cannot have initializers, and start_decl
errors when it sees that something's trying to initialize a PARM_DECL, but
nonetheless, we still attempt to parse the initializer, eventually arriving in
build_binary_op, which means we will instrument the bogus initializer.

This causes a crash in ubsan_encode_value -> create_tmp_var -> declare_vars: it
thinks it's processing a nested function, but the body of the function is null,
leading to the crash.

I suppose the best fix is to avoid instrumenting such bogus initializers.  In
c_parser_declaration_or_fndef it's easy to determine if we're initializing a
PARM_DECL -- just check DECL's code, but with __auto_type that's not possible,
because start_decl is called *after* parsing the initializer.  So instead of
DECL's code I'm checking nested && !empty_ok.

But we still want to instrument variables with initializers in nested
functions, so I've added two run-time tests for that.

Bootstrapped/regtested on x86_64-linux, ok for trunk?

2017-03-06  Marek Polacek  

PR sanitizer/79757
* c-parser.c (c_parser_declaration_or_fndef): Don't sanitize old-style
parameter declarations with initializers.

* gcc.dg/ubsan/pr79757-1.c: New test.
* gcc.dg/ubsan/pr79757-2.c: New test.
* gcc.dg/ubsan/pr79757-3.c: New test.
* gcc.dg/ubsan/pr79757-4.c: New test.
* gcc.dg/ubsan/pr79757-5.c: New test.
This isn't marked as a regression, but it clearly is a regression given 
we didn't ICE prior to r205714.


OK for the trunk.

Thanks for adding tests that verify we are instrumenting initializers in 
nested functions.


jeff




C++ PATCH to fix ICE in replace_placeholders_r (PR c++/79937)

2017-03-07 Thread Marek Polacek
In this testcase we have
C c = bar (X{1});
which store_init_value sees as
c = TARGET_EXPR )->i}>)>
i.e. we're initializing "c" with a TARGET_EXPR.  We call replace_placeholders
that walks the whole tree to substitute the placeholders.  Eventually we find
the nested  but that's for another object, so we
crash.  Seems that we shouldn't have stepped into the second TARGET_EXPR at
all; it has nothing to with "c", it's bar's argument.

It occurred to me that we shouldn't step into CALL_EXPRs and leave the
placeholders in function arguments to cp_gimplify_init_expr which calls
replace_placeholders for constructors.  Not sure if it's enough to handle
CALL_EXPRs like this, anything else?

Bootstrapped/regtested on x86_64-linux, ok for trunk and 6?

2017-03-07  Marek Polacek  

PR c++/79937 - ICE in replace_placeholders_r
* tree.c (replace_placeholders_r): Don't walk into CALL_EXPRs.

* g++.dg/cpp1y/nsdmi-aggr7.C: New test.

diff --git gcc/cp/tree.c gcc/cp/tree.c
index d3c63b8..6a4f065 100644
--- gcc/cp/tree.c
+++ gcc/cp/tree.c
@@ -2751,6 +2751,11 @@ replace_placeholders_r (tree* t, int* walk_subtrees, 
void* data_)
 
   switch (TREE_CODE (*t))
 {
+case CALL_EXPR:
+  /* Don't mess with placeholders in an unrelated object.  */
+  *walk_subtrees = false;
+  break;
+
 case PLACEHOLDER_EXPR:
   {
tree x = obj;
diff --git gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr7.C 
gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr7.C
index e69de29..c2fd404 100644
--- gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr7.C
+++ gcc/testsuite/g++.dg/cpp1y/nsdmi-aggr7.C
@@ -0,0 +1,21 @@
+// PR c++/79937
+// { dg-do compile { target c++14 } }
+
+struct C {};
+
+struct X {
+  unsigned i;
+  unsigned n = i;
+};
+
+C
+bar (X)
+{
+  return {};
+}
+
+void
+foo ()
+{
+  C c = bar (X{1});
+}

Marek


Re: [PATCH] Fix PR79345, better uninit warnings for memory

2017-03-07 Thread Jeff Law

On 03/01/2017 07:03 AM, Richard Biener wrote:


The following addresses a regression in uninit warnings that happens
because clobber stmts preclude the very simple-minded support we have
for memory.  The patch fixes this by instead implementing uninit
warnings for memory properly, using the alias oracle walk_aliased_vdefs
helper.

The patch adds better limiting to that interface and fixes one
false positive in fixed-value.c.  Two other false positives are
fixed by the wide-int.h patch posted a few hours ago and a patch
to genemit from Jakub.

Bootstrap and regtest running on x86_64-unknown-linux-gnu with those
prerequesites included.

One issue with the patch is duplicate warnings as TREE_NO_WARNING
doesn't work very well on tcc_reference trees which are not
shared.  A followup could use some sort of hash table to mitigate
this a bit.  OTOH for maybe-uninit uses multiple locations may
be in need to be fixed to silence the warning.  Another thing is
that we walk the function in random (BB) order and thus the
alias oracle walk limiting may result in warnings popping up
and going away in less predictable order (and also be reported
in odd order, like not all must-uninits first).

Comments?  I realize this may introduce (a lot of?) false positives
quite late in the game, more aggressive limiting, like to 2
disambiguations, could solve the testcase in the PR and give up
most of the times while preserving the non-walking case of the
old code.
I'm all for it.  Even if it triggers some false positives, improved 
detection of uninit memory at compile time is a big win in my mind.


jeff




[PATCH] Fix up avx512bwintrin.h with -O0 (PR target/79932)

2017-03-07 Thread Jakub Jelinek
Hi!

As mentioned in the PR, 6 intrinsics were only defined in section
guarded with #ifdef __OPTIMIZE__ (unnecessarily, because the intrinsics
don't have any immediate argument that must be constant) and without
#defines for -O0.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2017-03-07  Jakub Jelinek  

PR target/79932
* config/i386/avx512bwintrin.h (_mm512_packs_epi32,
_mm512_maskz_packs_epi32, _mm512_mask_packs_epi32,
_mm512_packus_epi32, _mm512_maskz_packus_epi32,
_mm512_mask_packus_epi32): Move definitions outside of __OPTIMIZE__
guarded section.

* gcc.target/i386/pr79932-1.c: New test.

--- gcc/config/i386/avx512bwintrin.h.jj 2017-01-23 18:09:48.0 +0100
+++ gcc/config/i386/avx512bwintrin.h2017-03-07 07:47:28.900049849 +0100
@@ -2656,6 +2656,72 @@ _mm512_cmple_epi16_mask (__m512i __X, __
  (__mmask32) -1);
 }
 
+extern __inline __m512i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_packs_epi32 (__m512i __A, __m512i __B)
+{
+  return (__m512i) __builtin_ia32_packssdw512_mask ((__v16si) __A,
+   (__v16si) __B,
+   (__v32hi)
+   _mm512_setzero_si512 (),
+   (__mmask32) -1);
+}
+
+extern __inline __m512i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_packs_epi32 (__mmask32 __M, __m512i __A, __m512i __B)
+{
+  return (__m512i) __builtin_ia32_packssdw512_mask ((__v16si) __A,
+   (__v16si) __B,
+   (__v32hi)
+   _mm512_setzero_si512 (),
+   __M);
+}
+
+extern __inline __m512i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_packs_epi32 (__m512i __W, __mmask32 __M, __m512i __A,
+__m512i __B)
+{
+  return (__m512i) __builtin_ia32_packssdw512_mask ((__v16si) __A,
+   (__v16si) __B,
+   (__v32hi) __W,
+   __M);
+}
+
+extern __inline __m512i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_packus_epi32 (__m512i __A, __m512i __B)
+{
+  return (__m512i) __builtin_ia32_packusdw512_mask ((__v16si) __A,
+   (__v16si) __B,
+   (__v32hi)
+   _mm512_setzero_si512 (),
+   (__mmask32) -1);
+}
+
+extern __inline __m512i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_maskz_packus_epi32 (__mmask32 __M, __m512i __A, __m512i __B)
+{
+  return (__m512i) __builtin_ia32_packusdw512_mask ((__v16si) __A,
+   (__v16si) __B,
+   (__v32hi)
+   _mm512_setzero_si512 (),
+   __M);
+}
+
+extern __inline __m512i
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm512_mask_packus_epi32 (__m512i __W, __mmask32 __M, __m512i __A,
+ __m512i __B)
+{
+  return (__m512i) __builtin_ia32_packusdw512_mask ((__v16si) __A,
+   (__v16si) __B,
+   (__v32hi) __W,
+   __M);
+}
+
 #ifdef __OPTIMIZE__
 extern __inline __mmask32
 __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
@@ -3012,72 +3078,6 @@ _mm512_cmp_epu8_mask (__m512i __X, __m51
 }
 
 extern __inline __m512i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_packs_epi32 (__m512i __A, __m512i __B)
-{
-  return (__m512i) __builtin_ia32_packssdw512_mask ((__v16si) __A,
-   (__v16si) __B,
-   (__v32hi)
-   _mm512_setzero_si512 (),
-   (__mmask32) -1);
-}
-
-extern __inline __m512i
-__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
-_mm512_maskz_packs_epi32 (__mmask32 __M, __m512i __A, __m512i __B)
-{
-  return (__m512i) __builtin_ia32_packssdw512_mask ((__v16si) __A,
-   (__v16si) __B,
-   (__v32hi)
- 

[PATCH] Fix up avx512vlintrin.h with -O0 (PR target/79932)

2017-03-07 Thread Jakub Jelinek
Hi!

I've preprocessed x86intrin.h with -O0 and -O2, both with -E -dD,
and gathered all _mm starting inline function names at column zero
and #define _mm macro names and compared them.
This revealed that 64 intrinsics have similar bug in avx512vlintrin.h,
no other problems found.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2017-03-07  Jakub Jelinek  

PR target/79932
* config/i386/avx512vlintrin.h (_mm256_cmpge_epi32_mask,
_mm256_cmpge_epi64_mask, _mm256_cmpge_epu32_mask,
_mm256_cmpge_epu64_mask, _mm256_cmple_epi32_mask,
_mm256_cmple_epi64_mask, _mm256_cmple_epu32_mask,
_mm256_cmple_epu64_mask, _mm256_cmplt_epi32_mask,
_mm256_cmplt_epi64_mask, _mm256_cmplt_epu32_mask,
_mm256_cmplt_epu64_mask, _mm256_cmpneq_epi32_mask,
_mm256_cmpneq_epi64_mask, _mm256_cmpneq_epu32_mask,
_mm256_cmpneq_epu64_mask, _mm256_mask_cmpge_epi32_mask,
_mm256_mask_cmpge_epi64_mask, _mm256_mask_cmpge_epu32_mask,
_mm256_mask_cmpge_epu64_mask, _mm256_mask_cmple_epi32_mask,
_mm256_mask_cmple_epi64_mask, _mm256_mask_cmple_epu32_mask,
_mm256_mask_cmple_epu64_mask, _mm256_mask_cmplt_epi32_mask,
_mm256_mask_cmplt_epi64_mask, _mm256_mask_cmplt_epu32_mask,
_mm256_mask_cmplt_epu64_mask, _mm256_mask_cmpneq_epi32_mask,
_mm256_mask_cmpneq_epi64_mask, _mm256_mask_cmpneq_epu32_mask,
_mm256_mask_cmpneq_epu64_mask, _mm_cmpge_epi32_mask,
_mm_cmpge_epi64_mask, _mm_cmpge_epu32_mask, _mm_cmpge_epu64_mask,
_mm_cmple_epi32_mask, _mm_cmple_epi64_mask, _mm_cmple_epu32_mask,
_mm_cmple_epu64_mask, _mm_cmplt_epi32_mask, _mm_cmplt_epi64_mask,
_mm_cmplt_epu32_mask, _mm_cmplt_epu64_mask, _mm_cmpneq_epi32_mask,
_mm_cmpneq_epi64_mask, _mm_cmpneq_epu32_mask, _mm_cmpneq_epu64_mask,
_mm_mask_cmpge_epi32_mask, _mm_mask_cmpge_epi64_mask,
_mm_mask_cmpge_epu32_mask, _mm_mask_cmpge_epu64_mask,
_mm_mask_cmple_epi32_mask, _mm_mask_cmple_epi64_mask,
_mm_mask_cmple_epu32_mask, _mm_mask_cmple_epu64_mask,
_mm_mask_cmplt_epi32_mask, _mm_mask_cmplt_epi64_mask,
_mm_mask_cmplt_epu32_mask, _mm_mask_cmplt_epu64_mask,
_mm_mask_cmpneq_epi32_mask, _mm_mask_cmpneq_epi64_mask,
_mm_mask_cmpneq_epu32_mask, _mm_mask_cmpneq_epu64_mask): Move
definitions outside of __OPTIMIZE__ guarded section.

* gcc.target/i386/pr79932-2.c: New test.

--- gcc/config/i386/avx512vlintrin.h.jj 2017-01-17 18:40:59.0 +0100
+++ gcc/config/i386/avx512vlintrin.h2017-03-07 08:27:31.071641043 +0100
@@ -9172,6 +9172,582 @@ _mm256_mask_permutexvar_epi32 (__m256i _
 __M);
 }
 
+extern __inline __mmask8
+  __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_cmpneq_epu32_mask (__mmask8 __M, __m256i __X, __m256i __Y)
+{
+  return (__mmask8) __builtin_ia32_ucmpd256_mask ((__v8si) __X,
+ (__v8si) __Y, 4,
+ (__mmask8) __M);
+}
+
+extern __inline __mmask8
+  __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_cmpneq_epu32_mask (__m256i __X, __m256i __Y)
+{
+  return (__mmask8) __builtin_ia32_ucmpd256_mask ((__v8si) __X,
+ (__v8si) __Y, 4,
+ (__mmask8) -1);
+}
+
+extern __inline __mmask8
+  __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_cmplt_epu32_mask (__mmask8 __M, __m256i __X, __m256i __Y)
+{
+  return (__mmask8) __builtin_ia32_ucmpd256_mask ((__v8si) __X,
+ (__v8si) __Y, 1,
+ (__mmask8) __M);
+}
+
+extern __inline __mmask8
+  __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_cmplt_epu32_mask (__m256i __X, __m256i __Y)
+{
+  return (__mmask8) __builtin_ia32_ucmpd256_mask ((__v8si) __X,
+ (__v8si) __Y, 1,
+ (__mmask8) -1);
+}
+
+extern __inline __mmask8
+  __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_mask_cmpge_epu32_mask (__mmask8 __M, __m256i __X, __m256i __Y)
+{
+  return (__mmask8) __builtin_ia32_ucmpd256_mask ((__v8si) __X,
+ (__v8si) __Y, 5,
+ (__mmask8) __M);
+}
+
+extern __inline __mmask8
+  __attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+_mm256_cmpge_epu32_mask (__m256i __X, __m256i __Y)
+{
+  return (__mmask8) __builtin_ia32_ucmpd256_mask ((__v8si) __X,
+ (__v8si) __Y, 5,
+ (__mmask8) -1);
+}
+
+extern __inline __mmask8
+  __attribute__ ((__gnu_

[PATCH] Small ubsan vector arith optimization to fix one testcase from PR sanitizer/79904

2017-03-07 Thread Jakub Jelinek
Hi!

If any of the operands of the UBSAN_{ADD,SUB,MUL}_OVERFLOW ifn with
vector operand is a uniform vector, expanding it as VCE on the VECTOR_CST
followed by ARRAY_REF with variable index in the loop is unnecessarily
expensive and nothing fixes it afterwards.
This works around ICE on s390 at least for the uniform vectors.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2017-03-07  Jakub Jelinek  

PR sanitizer/79904
* internal-fn.c (expand_vector_ubsan_overflow): If arg0 or arg1
is a uniform vector, use uniform_vector_p return value instead of
building ARRAY_REF on folded VIEW_CONVERT_EXPR to array type.

* gcc.dg/ubsan/pr79904.c: New test.

--- gcc/internal-fn.c.jj2017-02-23 08:48:40.0 +0100
+++ gcc/internal-fn.c   2017-03-07 11:55:56.261465702 +0100
@@ -1869,12 +1869,20 @@ expand_vector_ubsan_overflow (location_t
   if (cnt > 4)
{
  tree atype = build_array_type_nelts (eltype, cnt);
- op0 = fold_build1_loc (loc, VIEW_CONVERT_EXPR, atype, arg0);
- op0 = build4_loc (loc, ARRAY_REF, eltype, op0, cntv,
-   NULL_TREE, NULL_TREE);
- op1 = fold_build1_loc (loc, VIEW_CONVERT_EXPR, atype, arg1);
- op1 = build4_loc (loc, ARRAY_REF, eltype, op1, cntv,
-   NULL_TREE, NULL_TREE);
+ op0 = uniform_vector_p (arg0);
+ if (op0 == NULL_TREE)
+   {
+ op0 = fold_build1_loc (loc, VIEW_CONVERT_EXPR, atype, arg0);
+ op0 = build4_loc (loc, ARRAY_REF, eltype, op0, cntv,
+   NULL_TREE, NULL_TREE);
+   }
+ op1 = uniform_vector_p (arg1);
+ if (op1 == NULL_TREE)
+   {
+ op1 = fold_build1_loc (loc, VIEW_CONVERT_EXPR, atype, arg1);
+ op1 = build4_loc (loc, ARRAY_REF, eltype, op1, cntv,
+   NULL_TREE, NULL_TREE);
+   }
  if (resv)
{
  res = fold_build1_loc (loc, VIEW_CONVERT_EXPR, atype, resv);
--- gcc/testsuite/gcc.dg/ubsan/pr79904.c.jj 2017-03-07 11:58:53.266120958 
+0100
+++ gcc/testsuite/gcc.dg/ubsan/pr79904.c2017-03-07 11:58:46.0 
+0100
@@ -0,0 +1,11 @@
+/* PR sanitizer/79904 */
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=signed-integer-overflow -Wno-psabi" } */
+
+typedef signed char V __attribute__((vector_size (8))); 
+
+void
+foo (V *a) 
+{ 
+  *a = *a * 3; 
+}

Jakub


[C++ PATCH] Fix error-recovery for invalid enumerators (PR c++/79896)

2017-03-07 Thread Jakub Jelinek
Hi!

Doing copy_node on error_mark_node doesn't work too well, lots of spots
in the compiler assume there is just a single error_mark_node and compare
it using pointer comparison, rather than checking for TREE_CODE () ==
ERROR_MARK.  The testcase ICEs in particular during gimplification,
the CONST_DECL's DECL_INITIAL is not error_mark_node, but some other
ERROR_MARK and gimplify_expr doesn't like that.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2017-03-07  Jakub Jelinek  

PR c++/79896
* decl.c (finish_enum_value_list): If value is error_mark_node,
don't copy it and change its type.
* init.c (constant_value_1): Return error_mark_node if DECL_INITIAL
of CONST_DECL is error_mark_node.

* g++.dg/ext/int128-5.C: New test.

--- gcc/cp/decl.c.jj2017-03-01 09:31:48.0 +0100
+++ gcc/cp/decl.c   2017-03-07 12:31:23.055294773 +0100
@@ -14323,9 +14323,12 @@ finish_enum_value_list (tree enumtype)
   input_location = saved_location;
 
   /* Do not clobber shared ints.  */
-  value = copy_node (value);
+  if (value != error_mark_node)
+   {
+ value = copy_node (value);
 
-  TREE_TYPE (value) = enumtype;
+ TREE_TYPE (value) = enumtype;
+   }
   DECL_INITIAL (decl) = value;
 }
 
--- gcc/cp/init.c.jj2017-03-02 22:30:24.0 +0100
+++ gcc/cp/init.c   2017-03-07 12:41:08.724540062 +0100
@@ -2162,7 +2162,8 @@ constant_value_1 (tree decl, bool strict
   init = DECL_INITIAL (decl);
   if (init == error_mark_node)
{
- if (DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl))
+ if (TREE_CODE (decl) == CONST_DECL
+ || DECL_INITIALIZED_BY_CONSTANT_EXPRESSION_P (decl))
/* Treat the error as a constant to avoid cascading errors on
   excessively recursive template instantiation (c++/9335).  */
return init;
--- gcc/testsuite/g++.dg/ext/int128-5.C.jj  2017-03-07 12:36:24.617301861 
+0100
+++ gcc/testsuite/g++.dg/ext/int128-5.C 2017-03-07 12:36:49.388973865 +0100
@@ -0,0 +1,10 @@
+// PR c++/79896
+// { dg-do compile { target { ilp32 && { ! int128 } } } }
+// { dg-options "" }
+
+enum E
+{
+  e1 = 0xULL,
+  e2,  // { dg-error "overflow in enumeration values" }
+  e3
+} e = e3;

Jakub


[C++ PATCH] Fix error-recovery in maybe_thunk_body (PR c++/79899)

2017-03-07 Thread Jakub Jelinek
Hi!

Apparently in error recovery, populate_clone_array can't return fns
with all NULLs.  maybe_thunk_body used to handle that fine, but
the newly added ctor_omit_inherited_parms call ICEs.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
trunk?

2017-03-07  Jakub Jelinek  

PR c++/79899
* optimize.c (maybe_thunk_body): Don't ICE if fns[0] is NULL.
Use XALLOCAVEC macro.

* g++.dg/other/friend7.C: New test.

--- gcc/cp/optimize.c.jj2017-02-04 08:43:15.0 +0100
+++ gcc/cp/optimize.c   2017-03-07 13:21:52.280184213 +0100
@@ -262,7 +262,7 @@ maybe_thunk_body (tree fn, bool force)
   populate_clone_array (fn, fns);
 
   /* Don't use thunks if the base clone omits inherited parameters.  */
-  if (ctor_omit_inherited_parms (fns[0]))
+  if (fns[0] && ctor_omit_inherited_parms (fns[0]))
 return 0;
 
   DECL_ABSTRACT_P (fn) = false;
@@ -324,7 +324,7 @@ maybe_thunk_body (tree fn, bool force)
   if (length > max_parms)
 max_parms = length;
 }
-  args = (tree *) alloca (max_parms * sizeof (tree));
+  args = XALLOCAVEC (tree, max_parms);
 
   /* We know that any clones immediately follow FN in TYPE_METHODS.  */
   FOR_EACH_CLONE (clone, fn)
--- gcc/testsuite/g++.dg/other/friend7.C.jj 2017-03-07 13:22:44.814487619 
+0100
+++ gcc/testsuite/g++.dg/other/friend7.C2017-03-07 13:23:16.793063590 
+0100
@@ -0,0 +1,9 @@
+// PR c++/79899
+
+// { dg-do compile }
+// { dg-options "-Os" }
+
+struct A
+{
+  friend A::~A() {} // { dg-error "implicitly friends of their class" }
+};

Jakub


[committed] OpenMP/OpenACC invalid pragma location diagnostics (PR c/79834)

2017-03-07 Thread Jakub Jelinek
Hi!

This patch should make life easier for the translators by emitting
just one translatable message about pragmas only allowed in compound
statements, instead of 13 different ones.  In addition to that
it stops using c*_parser_error for that, both so that the msgid
can use %s and to avoid nonsensical printing pragma ... may only be used in
compound statements before _Pragma
Lastly, PRAGMA_OACC_WAIT used to print acc enter data in C.

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

2017-03-07  Jakub Jelinek  

PR c/79834
c/
* c-parser.c (c_parser_pragma): Use error_at instead of c_parser_error
for "may only be used in compound statements" diagnostics, change it
such that the same translatable string is used for all pragmas.  For
PRAGMA_OACC_WAIT use "acc wait" rather than "acc enter data" in the
diagnostics.
(c_parser_omp_cancellation_point, c_parser_omp_target_update,
c_parser_omp_target_enter_data, c_parser_omp_target_exit_data): Change
"may only be used in compound statements" diagnostics, such that the
same translatable string is used for all pragmas.
cp/
* parser.c (cp_parser_omp_cancellation_point,
cp_parser_omp_target_enter_data, cp_parser_omp_target_exit_data,
cp_parser_omp_target_update): Change "may only be used in compound
statements" diagnostics, such that the same translatable string is
used for all pragmas.
(cp_parser_pragma): Likewise.  Use error_at instead of
cp_parser_error for that diagnostics.
testsuite/
* c-c++-common/goacc/pragma_context.c (f2): Adjust expected
diagnostics.

--- gcc/c/c-parser.c.jj 2017-03-03 21:13:35.0 +0100
+++ gcc/c/c-parser.c2017-03-07 15:16:47.904751884 +0100
@@ -10157,6 +10157,7 @@ static bool
 c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p)
 {
   unsigned int id;
+  const char *construct = NULL;
 
   id = c_parser_peek_token (parser)->pragma_kind;
   gcc_assert (id != PRAGMA_NONE);
@@ -10170,9 +10171,16 @@ c_parser_pragma (c_parser *parser, enum
 case PRAGMA_OACC_ENTER_DATA:
   if (context != pragma_compound)
{
+ construct = "acc enter data";
+   in_compound:
  if (context == pragma_stmt)
-   c_parser_error (parser, "%<#pragma acc enter data%> may only be "
-   "used in compound statements");
+   {
+ error_at (c_parser_peek_token (parser)->location,
+   "%<#pragma %s%> may only be used in compound "
+   "statements", construct);
+ c_parser_skip_until_found (parser, CPP_PRAGMA_EOL, NULL);
+ return false;
+   }
  goto bad_stmt;
}
   c_parser_oacc_enter_exit_data (parser, true);
@@ -10181,10 +10189,8 @@ c_parser_pragma (c_parser *parser, enum
 case PRAGMA_OACC_EXIT_DATA:
   if (context != pragma_compound)
{
- if (context == pragma_stmt)
-   c_parser_error (parser, "%<#pragma acc exit data%> may only be "
-   "used in compound statements");
- goto bad_stmt;
+ construct = "acc exit data";
+ goto in_compound;
}
   c_parser_oacc_enter_exit_data (parser, false);
   return false;
@@ -10203,10 +10209,8 @@ c_parser_pragma (c_parser *parser, enum
 case PRAGMA_OACC_UPDATE:
   if (context != pragma_compound)
{
- if (context == pragma_stmt)
-   c_parser_error (parser, "%<#pragma acc update%> may only be "
-   "used in compound statements");
- goto bad_stmt;
+ construct = "acc update";
+ goto in_compound;
}
   c_parser_oacc_update (parser);
   return false;
@@ -10214,10 +10218,8 @@ c_parser_pragma (c_parser *parser, enum
 case PRAGMA_OMP_BARRIER:
   if (context != pragma_compound)
{
- if (context == pragma_stmt)
-   c_parser_error (parser, "%<#pragma omp barrier%> may only be "
-   "used in compound statements");
- goto bad_stmt;
+ construct = "omp barrier";
+ goto in_compound;
}
   c_parser_omp_barrier (parser);
   return false;
@@ -10225,10 +10227,8 @@ c_parser_pragma (c_parser *parser, enum
 case PRAGMA_OMP_FLUSH:
   if (context != pragma_compound)
{
- if (context == pragma_stmt)
-   c_parser_error (parser, "%<#pragma omp flush%> may only be "
-   "used in compound statements");
- goto bad_stmt;
+ construct = "omp flush";
+ goto in_compound;
}
   c_parser_omp_flush (parser);
   return false;
@@ -10236,10 +10236,8 @@ c_parser_pragma (c_parser *parser, enum
 case PRAGMA_OMP_TASKWAIT:
   if (context != pragma_compound)
{
- if (context == pragma_stmt)
-   c_parser

[PATCH] Don't ICE if the Fortran FE calls some stor-layout.c etc. function that emits warning, -Wpadded fixes (PR fortran/79886)

2017-03-07 Thread Jakub Jelinek
Hi!

The Fortran FE registers its own format decoder, overriding the default
one that handles what the middle-end can emit, e.g.
warning (OPT_Wpadded, "padding struct to align %q+D", field);
The C/C++ FEs are the only other ones that override the decoder, but they
do handle all the specs the generic decoder handles.

This patch chains the default decoder if the spec is not Fortran specific.

Another fix is to avoid -Wpadded warnings on every single TU when building
the IO artificial data structures.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2017-03-07  Jakub Jelinek  

PR fortran/79886
* tree-diagnostic.c (default_tree_printer): No longer static.
* tree-diagnostic.h (default_tree_printer): New prototype.
fortran/
* error.c (gfc_format_decoder): Rename plus argument to set_locus,
remove ATTRIBUTE_UNUSED from all arguments, call default_tree_printer
if not a Fortran specific spec.
* trans-io.c: Include options.h.
(gfc_build_st_parameter): Temporarily disable -Wpadded around layout
of artificial IO data structures.
testsuite/
* gfortran.dg/pr79886.f90: New test.

--- gcc/tree-diagnostic.c.jj2017-01-01 12:45:35.0 +0100
+++ gcc/tree-diagnostic.c   2017-03-07 15:53:32.318241647 +0100
@@ -243,7 +243,7 @@ virt_loc_aware_diagnostic_finalizer (dia
 }
 
 /* Default tree printer.   Handles declarations only.  */
-static bool
+bool
 default_tree_printer (pretty_printer *pp, text_info *text, const char *spec,
  int precision, bool wide, bool set_locus, bool hash)
 {
--- gcc/tree-diagnostic.h.jj2017-01-01 12:45:37.0 +0100
+++ gcc/tree-diagnostic.h   2017-03-07 15:54:18.748626307 +0100
@@ -54,4 +54,7 @@ void virt_loc_aware_diagnostic_finalizer
  diagnostic_info *);
 
 void tree_diagnostics_defaults (diagnostic_context *context);
+bool default_tree_printer (pretty_printer *, text_info *, const char *,
+  int, bool, bool, bool);
+
 #endif /* ! GCC_TREE_DIAGNOSTIC_H */
--- gcc/fortran/error.c.jj  2017-01-21 11:30:17.0 +0100
+++ gcc/fortran/error.c 2017-03-07 15:57:23.107159872 +0100
@@ -916,10 +916,8 @@ gfc_notify_std (int std, const char *gms
%L  Takes locus argument
 */
 static bool
-gfc_format_decoder (pretty_printer *pp,
-   text_info *text, const char *spec,
-   int precision ATTRIBUTE_UNUSED, bool wide ATTRIBUTE_UNUSED,
-   bool plus ATTRIBUTE_UNUSED, bool hash ATTRIBUTE_UNUSED)
+gfc_format_decoder (pretty_printer *pp, text_info *text, const char *spec,
+   int precision, bool wide, bool set_locus, bool hash)
 {
   switch (*spec)
 {
@@ -946,7 +944,11 @@ gfc_format_decoder (pretty_printer *pp,
return true;
   }
 default:
-  return false;
+  /* Fall through info the middle-end decoder, as e.g. stor-layout.c
+etc. diagnostics can use the FE printer while the FE is still
+active.  */
+  return default_tree_printer (pp, text, spec, precision, wide,
+  set_locus, hash);
 }
 }
 
--- gcc/fortran/trans-io.c.jj   2017-01-16 12:28:34.0 +0100
+++ gcc/fortran/trans-io.c  2017-03-07 16:06:03.818151237 +0100
@@ -32,6 +32,7 @@ along with GCC; see the file COPYING3.
 #include "trans-array.h"
 #include "trans-types.h"
 #include "trans-const.h"
+#include "options.h"
 
 /* Members of the ioparm structure.  */
 
@@ -219,7 +220,12 @@ gfc_build_st_parameter (enum ioparam_typ
  gcc_unreachable ();
}
 
+  /* -Wpadded warnings on these artificially created structures are not
+ helpful; suppress them. */
+  int save_warn_padded = warn_padded;
+  warn_padded = 0;
   gfc_finish_type (t);
+  warn_padded = save_warn_padded;
   st_parameter[ptype].type = t;
 }
 
--- gcc/testsuite/gfortran.dg/pr79886.f90.jj2017-03-07 16:09:29.880416741 
+0100
+++ gcc/testsuite/gfortran.dg/pr79886.f90   2017-03-07 16:09:05.0 
+0100
@@ -0,0 +1,17 @@
+! PR fortran/79886
+! { dg-do compile }
+! { dg-options "-Wpadded" }
+
+subroutine pr79886
+  type :: foo
+integer (kind=1) :: a
+integer (kind=8) :: b  ! { dg-warning "padding struct to align" }
+integer (kind=1) :: c
+integer (kind=8) :: d  ! { dg-warning "padding struct to align" }
+  end type
+  type (foo) :: f
+  f%a = 1
+  f%b = 2
+  f%c = 3
+  f%d = 4
+end subroutine

Jakub


Updating config.guess (was: i386-unknown-freebsd -> i586-unknown-freebsd)

2017-03-07 Thread Gerald Pfeifer
On Tue, 7 Mar 2017, Jeff Law wrote:
>> When/if this has been accepted, is it okay to pull the latest config.guess
>> into GCC even at this stage of the release process?  (We're only looking
>> at this change and the addition of nsx-tandem compared to what we have
>> right now.)
> If it's just those, I'd think it'd be reasonable.

Here is the entire difference between the config.guess we have
and upstream.

Aye? :-)

Gerald

--- /home/gp/src/gcc/config.guess   2016-12-10 13:37:44.536966833 +0100
+++ ./config.guess  2017-03-04 16:07:52.863302161 +0100
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright 1992-2016 Free Software Foundation, Inc.
+#   Copyright 1992-2017 Free Software Foundation, Inc.
 
-timestamp='2016-10-02'
+timestamp='2017-03-04'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -50,7 +50,7 @@
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright 1992-2016 Free Software Foundation, Inc.
+Copyright 1992-2017 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -837,10 +837,11 @@
UNAME_PROCESSOR=`/usr/bin/uname -p`
case ${UNAME_PROCESSOR} in
amd64)
-   echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 
's/[-(].*//'` ;;
-   *)
-   echo ${UNAME_PROCESSOR}-unknown-freebsd`echo 
${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+   UNAME_PROCESSOR=x86_64 ;;
+   i386)
+   UNAME_PROCESSOR=i586 ;;
esac
+   echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 
's/[-(].*//'`
exit ;;
 i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin
@@ -1343,6 +1344,9 @@
 NSR-?:NONSTOP_KERNEL:*:*)
echo nsr-tandem-nsk${UNAME_RELEASE}
exit ;;
+NSX-?:NONSTOP_KERNEL:*:*)
+   echo nsx-tandem-nsk${UNAME_RELEASE}
+   exit ;;
 *:NonStop-UX:*:*)
echo mips-compaq-nonstopux
exit ;;


[PATCH] [PATCH, rs6000] Fix pr79941

2017-03-07 Thread Will Schmidt
Hi,
Per PR79941, we are folding the vec_mul{e,o}* operations improperly. Those
entries were added to the intrinsics-to-be-folded list where the generic
multiplies should have been instead.  Test coverage in place was for the
generic multiplies, and this was missed by my testing.

Thusly, remove those entries from the folding list.  At the same time, I
am adding a testcase to provide some basic coverage for those ops.

Functional gimple folding for those operations will be showing up at
a later time.

OK for trunk?
regtest is currently running on ppc64*.


gcc:
2017-03-07  Will Schmidt 

 PR middle-end/79941
 * config/rs6000/rs6000.c (gimplify_init_constructor): Remove multiply
 even and multiply odd (vmule/vmulo) intrinsics from the multiply folding
 sequence.

testsuite:
2017-03-07  Will Schmidt 

 PR middle-end/79941
 * gcc.target/powerpc/fold-vec-mult-even_odd_misc.c: New test.
---
 gcc/config/rs6000/rs6000.c |   31 ---
 .../powerpc/fold-vec-mult-even_odd_misc.c  |   58 
 2 files changed, 58 insertions(+), 31 deletions(-)
 create mode 100644 
gcc/testsuite/gcc.target/powerpc/fold-vec-mult-even_odd_misc.c

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 25b10f1..ce0ece5 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -16852,37 +16852,6 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator *gsi)
gsi_replace (gsi, g, true);
return true;
   }
-/* Even element flavors of vec_mul (signed). */
-case ALTIVEC_BUILTIN_VMULESB:
-case ALTIVEC_BUILTIN_VMULESH:
-/* Even element flavors of vec_mul (unsigned).  */
-case ALTIVEC_BUILTIN_VMULEUB:
-case ALTIVEC_BUILTIN_VMULEUH:
-  {
-   arg0 = gimple_call_arg (stmt, 0);
-   arg1 = gimple_call_arg (stmt, 1);
-   lhs = gimple_call_lhs (stmt);
-   gimple *g = gimple_build_assign (lhs, VEC_WIDEN_MULT_EVEN_EXPR, arg0, 
arg1);
-   gimple_set_location (g, gimple_location (stmt));
-   gsi_replace (gsi, g, true);
-   return true;
-  }
-/* Odd element flavors of vec_mul (signed).  */
-case ALTIVEC_BUILTIN_VMULOSB:
-case ALTIVEC_BUILTIN_VMULOSH:
-/* Odd element flavors of vec_mul (unsigned). */
-case ALTIVEC_BUILTIN_VMULOUB:
-case ALTIVEC_BUILTIN_VMULOUH:
-  {
-   arg0 = gimple_call_arg (stmt, 0);
-   arg1 = gimple_call_arg (stmt, 1);
-   lhs = gimple_call_lhs (stmt);
-   gimple *g = gimple_build_assign (lhs, VEC_WIDEN_MULT_ODD_EXPR, arg0, 
arg1);
-   gimple_set_location (g, gimple_location (stmt));
-   gsi_replace (gsi, g, true);
-   return true;
-  }
-
 default:
   break;
 }
diff --git a/gcc/testsuite/gcc.target/powerpc/fold-vec-mult-even_odd_misc.c 
b/gcc/testsuite/gcc.target/powerpc/fold-vec-mult-even_odd_misc.c
new file mode 100644
index 000..583539e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/fold-vec-mult-even_odd_misc.c
@@ -0,0 +1,58 @@
+
+/* { dg-do run } */
+/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-options "-maltivec -mvsx -O2 -save-temps" } */
+
+#include 
+
+__attribute__((noinline)) void 
+test_eub_char ()
+{
+  vector unsigned char v0 = {1, 0, 0, 0, 0, 0, 0, 0};
+  vector unsigned char v1 = {0xff, 0, 0, 0, 0, 0, 0, 0};
+  vector unsigned short res = vec_vmuleub (v0, v1);
+  if (res[0] != (unsigned short)v0[0] * (unsigned short)v1[0])
+__builtin_abort ();
+}
+__attribute__((noinline)) void 
+test_oub_char ()
+{
+  vector unsigned char v0 = {0, 1, 0, 0, 0, 0, 0, 0};
+  vector unsigned char v1 = {0, 0xff, 0, 0, 0, 0, 0, 0};
+  vector unsigned short res = vec_vmuloub (v0, v1);
+  if (res[0] != (unsigned short)v0[1] * (unsigned short)v1[1])
+__builtin_abort ();
+}
+
+__attribute__((noinline)) void 
+test_euh_short ()
+{
+  vector unsigned short v0 = {1, 0, 0, 0};
+  vector unsigned short v1 = {0xff, 0, 0, 0};
+  vector unsigned int res = vec_vmuleuh (v0, v1);
+  if (res[0] != (unsigned int)v0[0] * (unsigned int)v1[0])
+__builtin_abort ();
+}
+__attribute__((noinline)) void 
+test_ouh_short ()
+{
+  vector unsigned short v0 = {0, 1, 0, 0};
+  vector unsigned short v1 = {0, 0xff, 0, 0};
+  vector unsigned int res = vec_vmulouh (v0, v1);
+  if (res[0] != (unsigned int)v0[1] * (unsigned int)v1[1])
+__builtin_abort ();
+}
+
+int main ()
+{
+  test_eub_char();
+  test_oub_char();
+  test_euh_short();
+  test_ouh_short();
+}
+
+/* { dg-final { scan-assembler-times "vmuleub" 1 } } */
+/* { dg-final { scan-assembler-times "vmuloub" 1 } } */
+/* { dg-final { scan-assembler-times "vmuleuh" 1 } } */
+/* { dg-final { scan-assembler-times "vmulouh" 1 } } */
+



Re: [PATCH] [PATCH, rs6000] Fix pr79941

2017-03-07 Thread Jakub Jelinek
On Tue, Mar 07, 2017 at 03:36:38PM -0600, Will Schmidt wrote:
> Per PR79941, we are folding the vec_mul{e,o}* operations improperly. Those
> entries were added to the intrinsics-to-be-folded list where the generic
> multiplies should have been instead.  Test coverage in place was for the
> generic multiplies, and this was missed by my testing.
> 
> Thusly, remove those entries from the folding list.  At the same time, I
> am adding a testcase to provide some basic coverage for those ops.
> 
> Functional gimple folding for those operations will be showing up at
> a later time.
> 
> OK for trunk?
> regtest is currently running on ppc64*.
> 
> 
> gcc:
> 2017-03-07  Will Schmidt 
> 
>  PR middle-end/79941
>  * config/rs6000/rs6000.c (gimplify_init_constructor): Remove multiply
>  even and multiply odd (vmule/vmulo) intrinsics from the multiply folding
>  sequence.
> 
> testsuite:
> 2017-03-07  Will Schmidt 
> 
>  PR middle-end/79941
>  * gcc.target/powerpc/fold-vec-mult-even_odd_misc.c: New test.
> ---
>  gcc/config/rs6000/rs6000.c |   31 ---
>  .../powerpc/fold-vec-mult-even_odd_misc.c  |   58 
> 
>  2 files changed, 58 insertions(+), 31 deletions(-)
>  create mode 100644 
> gcc/testsuite/gcc.target/powerpc/fold-vec-mult-even_odd_misc.c
> 
> diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
> index 25b10f1..ce0ece5 100644
> --- a/gcc/config/rs6000/rs6000.c
> +++ b/gcc/config/rs6000/rs6000.c
> @@ -16852,37 +16852,6 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator 
> *gsi)
>   gsi_replace (gsi, g, true);
>   return true;
>}

Doesn't the ALTIVEC_BUILTIN_VMUL[EO]S[BH] folding work properly already?
Perhaps you could just comment out the VMUL[EO]U[BH] folding for now,
or depending on whether there is S or U set uns flag and punt if TYPE_SIGN 
(TREE_TYPE
(TREE_TYPE (arg0))) is not equal to that (similarly for arg1 and lhs).
Or VIEW_CONVERT_EXPR it if not the right sign.  Or tweak the builtin
prototype for VMUL[EO]U[BH] so that it uses unsigned vector arguments and
result.

> -/* Even element flavors of vec_mul (signed). */
> -case ALTIVEC_BUILTIN_VMULESB:
> -case ALTIVEC_BUILTIN_VMULESH:
> -/* Even element flavors of vec_mul (unsigned).  */
> -case ALTIVEC_BUILTIN_VMULEUB:
> -case ALTIVEC_BUILTIN_VMULEUH:
> -  {
> - arg0 = gimple_call_arg (stmt, 0);
> - arg1 = gimple_call_arg (stmt, 1);
> - lhs = gimple_call_lhs (stmt);
> - gimple *g = gimple_build_assign (lhs, VEC_WIDEN_MULT_EVEN_EXPR, arg0, 
> arg1);
> - gimple_set_location (g, gimple_location (stmt));
> - gsi_replace (gsi, g, true);
> - return true;
> -  }
> -/* Odd element flavors of vec_mul (signed).  */
> -case ALTIVEC_BUILTIN_VMULOSB:
> -case ALTIVEC_BUILTIN_VMULOSH:
> -/* Odd element flavors of vec_mul (unsigned). */
> -case ALTIVEC_BUILTIN_VMULOUB:
> -case ALTIVEC_BUILTIN_VMULOUH:
> -  {
> - arg0 = gimple_call_arg (stmt, 0);
> - arg1 = gimple_call_arg (stmt, 1);
> - lhs = gimple_call_lhs (stmt);
> - gimple *g = gimple_build_assign (lhs, VEC_WIDEN_MULT_ODD_EXPR, arg0, 
> arg1);
> - gimple_set_location (g, gimple_location (stmt));
> - gsi_replace (gsi, g, true);
> - return true;
> -  }
> -
>  default:
>break;
>  }

Jakub


Re: [PATCH] For broken exception handling in GDB on AIX platform

2017-03-07 Thread Bernhard Reutner-Fischer
On 7 March 2017 13:43:00 CET, Nitish Kumar Mishra  
wrote:
>Hi,
>
>I have update the patch according to some comments from GDB community.
>Please find the attachments.

If it is AIX specific, you probably should not remove fuchsia support.
And since we most likely do not link host_tools statically into AIX toolchain 
binaries, I suggest you don't remove texinfo too.

thanks,


Re: [PATCH] [PATCH, rs6000] Fix pr79941

2017-03-07 Thread Will Schmidt
On Tue, 2017-03-07 at 22:52 +0100, Jakub Jelinek wrote:
> On Tue, Mar 07, 2017 at 03:36:38PM -0600, Will Schmidt wrote:
> > Per PR79941, we are folding the vec_mul{e,o}* operations improperly. Those
> > entries were added to the intrinsics-to-be-folded list where the generic
> > multiplies should have been instead.  Test coverage in place was for the
> > generic multiplies, and this was missed by my testing.
> > 
> > Thusly, remove those entries from the folding list.  At the same time, I
> > am adding a testcase to provide some basic coverage for those ops.
> > 
> > Functional gimple folding for those operations will be showing up at
> > a later time.
> > 
> > OK for trunk?
> > regtest is currently running on ppc64*.
> > 
> > 
> > gcc:
> > 2017-03-07  Will Schmidt 
> > 
> >  PR middle-end/79941
> >  * config/rs6000/rs6000.c (gimplify_init_constructor): Remove multiply
> >  even and multiply odd (vmule/vmulo) intrinsics from the multiply 
> > folding
> >  sequence.
> > 
> > testsuite:
> > 2017-03-07  Will Schmidt 
> > 
> >  PR middle-end/79941
> >  * gcc.target/powerpc/fold-vec-mult-even_odd_misc.c: New test.
> > ---
> >  gcc/config/rs6000/rs6000.c |   31 ---
> >  .../powerpc/fold-vec-mult-even_odd_misc.c  |   58 
> > 
> >  2 files changed, 58 insertions(+), 31 deletions(-)
> >  create mode 100644 
> > gcc/testsuite/gcc.target/powerpc/fold-vec-mult-even_odd_misc.c
> > 
> > diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
> > index 25b10f1..ce0ece5 100644
> > --- a/gcc/config/rs6000/rs6000.c
> > +++ b/gcc/config/rs6000/rs6000.c
> > @@ -16852,37 +16852,6 @@ rs6000_gimple_fold_builtin (gimple_stmt_iterator 
> > *gsi)
> > gsi_replace (gsi, g, true);
> > return true;
> >}
> 

Hi Jakub, 

> Doesn't the ALTIVEC_BUILTIN_VMUL[EO]S[BH] folding work properly already?

Perhaps by accident.  :-)

I have yet to review the generated assembly for the mul[eo] code, so I
don't have a good feel for the health of the generated code at the
moment.

And I freely admit that I am still learning this code, and the VMUL[EO]*
bits were only upstreamed due to error on my part.


If there is any time pressure at all, I would prefer reverting this
chunk entirely.  Doing those intrinsics properly is in my queue, but may
or may not end up being during stage4.

> Perhaps you could just comment out the VMUL[EO]U[BH] folding for now,
> or depending on whether there is S or U set uns flag and punt if TYPE_SIGN 
> (TREE_TYPE
> (TREE_TYPE (arg0))) is not equal to that (similarly for arg1 and lhs).
> Or VIEW_CONVERT_EXPR it if not the right sign.  Or tweak the builtin
> prototype for VMUL[EO]U[BH] so that it uses unsigned vector arguments and
> result.

Thanks for this analysis... this will help..  :-) 

Thanks,
-Will

> 
> > -/* Even element flavors of vec_mul (signed). */
> > -case ALTIVEC_BUILTIN_VMULESB:
> > -case ALTIVEC_BUILTIN_VMULESH:
> > -/* Even element flavors of vec_mul (unsigned).  */
> > -case ALTIVEC_BUILTIN_VMULEUB:
> > -case ALTIVEC_BUILTIN_VMULEUH:
> > -  {
> > -   arg0 = gimple_call_arg (stmt, 0);
> > -   arg1 = gimple_call_arg (stmt, 1);
> > -   lhs = gimple_call_lhs (stmt);
> > -   gimple *g = gimple_build_assign (lhs, VEC_WIDEN_MULT_EVEN_EXPR, arg0, 
> > arg1);
> > -   gimple_set_location (g, gimple_location (stmt));
> > -   gsi_replace (gsi, g, true);
> > -   return true;
> > -  }
> > -/* Odd element flavors of vec_mul (signed).  */
> > -case ALTIVEC_BUILTIN_VMULOSB:
> > -case ALTIVEC_BUILTIN_VMULOSH:
> > -/* Odd element flavors of vec_mul (unsigned). */
> > -case ALTIVEC_BUILTIN_VMULOUB:
> > -case ALTIVEC_BUILTIN_VMULOUH:
> > -  {
> > -   arg0 = gimple_call_arg (stmt, 0);
> > -   arg1 = gimple_call_arg (stmt, 1);
> > -   lhs = gimple_call_lhs (stmt);
> > -   gimple *g = gimple_build_assign (lhs, VEC_WIDEN_MULT_ODD_EXPR, arg0, 
> > arg1);
> > -   gimple_set_location (g, gimple_location (stmt));
> > -   gsi_replace (gsi, g, true);
> > -   return true;
> > -  }
> > -
> >  default:
> >break;
> >  }
> 
>   Jakub
> 




stabilize store merging

2017-03-07 Thread Alexandre Oliva
Don't let pointer randomization change the order in which we process
store chains.  This may cause SSA_NAMEs to be released in different
order, and if they're reused later, they may cause differences in SSA
partitioning, leading to differences in expand, and ultimately to
different code.

bootstrap-debug-lean (-fcompare-debug) on i686-linux-gnu has failed in
haifa-sched.c since r245196 exposed the latent ordering problem in
store merging.  In this case, the IR differences (different SSA names
selected for copies in out-of-SSA, resulting in some off-by-one
differences in pseudos) were not significant enough to be visible in
the compiler output.

Regstrapped on x86_64-linux-gnu and i686-linux-gnu.  Ok to install?

for  gcc/ChangeLog

* gimple-ssa-store-merging.c (INCLUDE_MAP): Define.
(struct imm_store_chain_info): Add seqno field and ctor parm.
(class pass_store_merging): Add m_store_seq field.
(pass_store_merging::terminate_and_process_all_chains):
Iterate over m_store_seq.
(pass_store_merging::terminate_all_aliasing_chains):
Likewise.
(pass_store_merging::terminate_and_release_chain):
Erase the m_store_seq entry.
(pass_store_merging::execute): Check for debug stmts first.
Compute seqno, add the m_store_seq entry.
---
 gcc/gimple-ssa-store-merging.c |   58 +---
 1 file changed, 42 insertions(+), 16 deletions(-)

diff --git a/gcc/gimple-ssa-store-merging.c b/gcc/gimple-ssa-store-merging.c
index 17ac94a..0bf7d89 100644
--- a/gcc/gimple-ssa-store-merging.c
+++ b/gcc/gimple-ssa-store-merging.c
@@ -103,6 +103,7 @@
   [p + 4B] (16-bit) := 0xabcd; //  val & 0x;  */
 
 #include "config.h"
+#define INCLUDE_MAP
 #include "system.h"
 #include "coretypes.h"
 #include "backend.h"
@@ -675,11 +676,12 @@ merged_store_group::apply_stores ()
 
 struct imm_store_chain_info
 {
+  unsigned seqno;
   tree base_addr;
   auto_vec m_store_info;
   auto_vec m_merged_store_groups;
 
-  imm_store_chain_info (tree b_a) : base_addr (b_a) {}
+  imm_store_chain_info (unsigned seq, tree b_a) : seqno (seq), base_addr (b_a) 
{}
   bool terminate_and_process_chain ();
   bool coalesce_immediate_stores ();
   bool output_merged_store (merged_store_group *);
@@ -718,6 +720,18 @@ public:
 private:
   hash_map m_stores;
 
+  /* Use m_store_seq to order elements in m_stores, and iterate over
+ them in a predictable way.  It maps sequence numbers to the base
+ addresses stored as keys in m_stores.  Using this order avoids
+ extraneous differences in the compiler output just because of
+ tree pointer variations (e.g. different chains end up in
+ different positions of m_stores, so they are handled in different
+ orders, so they allocate or release SSA names in different
+ orders, and when they get reused, subsequent passes end up
+ getting different SSA names, which may ultimately change
+ decisions when going out of SSA).  */
+  std::map m_store_seq;
+
   bool terminate_and_process_all_chains ();
   bool terminate_all_aliasing_chains (imm_store_chain_info **,
  bool, gimple *);
@@ -730,11 +744,16 @@ private:
 bool
 pass_store_merging::terminate_and_process_all_chains ()
 {
-  hash_map::iterator iter
-= m_stores.begin ();
   bool ret = false;
-  for (; iter != m_stores.end (); ++iter)
-ret |= terminate_and_release_chain ((*iter).second);
+  for (std::map::iterator next = m_store_seq.begin (),
+iter = next; iter != m_store_seq.end (); iter = next)
+{
+  next++;
+  tree base_addr = (*iter).second;
+  ret |= terminate_and_release_chain (*m_stores.get (base_addr));
+}
+  gcc_assert (m_stores.elements () == 0);
+  gcc_assert (m_store_seq.empty ());
 
   return ret;
 }
@@ -799,15 +818,17 @@ pass_store_merging::terminate_all_aliasing_chains 
(imm_store_chain_info
}
 }
 
-  hash_map::iterator iter
-= m_stores.begin ();
-
   /* Check for aliasing with all other store chains.  */
-  for (; iter != m_stores.end (); ++iter)
+  for (std::map::iterator next = m_store_seq.begin (),
+iter = next; iter != m_store_seq.end (); iter = next)
 {
+  next++;
+  unsigned seqno = (*iter).first;
+  tree base_addr = (*iter).second;
+
   /* We already checked all the stores in chain_info and terminated the
 chain if necessary.  Skip it here.  */
-  if (chain_info && (*chain_info) == (*iter).second)
+  if (chain_info && (*chain_info)->seqno == seqno)
continue;
 
   /* We can't use the base object here as that does not reliably exist.
@@ -815,11 +836,11 @@ pass_store_merging::terminate_all_aliasing_chains 
(imm_store_chain_info
 minimum and maximum offset and the maximum size we could improve
 things here).  */
   ao_ref chain_ref;
-  ao_ref_init_from_ptr_and_size (&chain_ref, (*iter).first, NULL_TREE);
+  ao_ref_init_from_ptr_and_size (

[PATCH] fix error spelling in nds32.c (PR 79928)

2017-03-07 Thread Martin Sebor

The following one-line patch corrects the spelling of the error
message in the nds32 back end pointed out by a translator.  I'll
go ahead and commit it as trivial unless there are objections in
the next day or so.

Martin

2017-03-07  Martin Sebor  

* gcc/config/nds32/nds32.c (nds32_option_override): Fix spelling
of error message.

diff --git a/gcc/config/nds32/nds32.c b/gcc/config/nds32/nds32.c
index 9313712..705d223 100644
--- a/gcc/config/nds32/nds32.c
+++ b/gcc/config/nds32/nds32.c
@@ -2704,7 +2704,7 @@ nds32_option_override (void)

   /* Currently, we don't support PIC code generation yet.  */
   if (flag_pic)
-sorry ("not support -fpic");
+sorry ("position-independent code not supported");
 }


[PATCH] add calls.c to GTFILES in Makefile.in

2017-03-07 Thread Martin Sebor

In bug 79936 - ICE with -Walloc-size-larger-than=32767 the reporter
encountered an ICE on x86_64-apple-darwin10.8.0 caused by GCC source
file that implements the warning accessing a global tree without
having included the file in GTFILES make variable.  (Thanks again
to David Malcolm who helped me root cause this bug.)

The attached patch fixes this by adding calls.c to the variable and
by including the requisite generated header, gt-calls.h, at the end
of the source.

Martin
PR c/79936 - [7 Regression] ICE with -Walloc-size-larger-than=32767

gcc/ChangeLog:

	PR c/79936
	* Makefile.in (GTFILES): Add calls.c.
	* calls.c (must_pass_in_stack_var_size_or_pad): Include "gt-calls.h".

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 8648d68..481515a 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2517,6 +2517,7 @@ GTFILES = $(CPP_ID_DATA_H) $(srcdir)/input.h $(srcdir)/coretypes.h \
   $(srcdir)/ipa-devirt.c \
   $(srcdir)/internal-fn.h \
   $(srcdir)/hsa-common.c \
+  $(srcdir)/calls.c \
   @all_gtfiles@
 
 # Compute the list of GT header files from the corresponding C sources,
diff --git a/gcc/calls.c b/gcc/calls.c
index 6d5ef4e..61caf4c 100644
--- a/gcc/calls.c
+++ b/gcc/calls.c
@@ -5649,3 +5649,6 @@ must_pass_in_stack_var_size_or_pad (machine_mode mode, const_tree type)
 
   return false;
 }
+
+/* Tell the garbage collector about GTY markers in this source file.  */
+#include "gt-calls.h"


Re: [PATCH] fix error spelling in nds32.c (PR 79928)

2017-03-07 Thread Chung-Ju Wu

Martin Sebor on 2017/3/8 08:09 wrote:

The following one-line patch corrects the spelling of the error
message in the nds32 back end pointed out by a translator.  I'll
go ahead and commit it as trivial unless there are objections in
the next day or so.

Martin

2017-03-07  Martin Sebor  

* gcc/config/nds32/nds32.c (nds32_option_override): Fix spelling
of error message.

diff --git a/gcc/config/nds32/nds32.c b/gcc/config/nds32/nds32.c
index 9313712..705d223 100644
--- a/gcc/config/nds32/nds32.c
+++ b/gcc/config/nds32/nds32.c
@@ -2704,7 +2704,7 @@ nds32_option_override (void)

   /* Currently, we don't support PIC code generation yet.  */
   if (flag_pic)
-sorry ("not support -fpic");
+sorry ("position-independent code not supported");
 }


Hi, Martin,

The patch is OK.  Thank you so much. :)


Best regards,
jasonwucj



Re: [PATCH] libbacktrace: Fix compile warning building testcase

2017-03-07 Thread Ian Lance Taylor via gcc-patches
On Fri, Mar 3, 2017 at 6:46 AM, Sam Thursfield
 wrote:
>
> I hit this compile warning running `make check` on AIX. Since -Werror is
> enabled by default here it causes a build failure.
>
> Tested on powerpc-ibm-aix7.2.0.0
>
> This my first patch submission for GCC, so please let me know if I need to
> do anything differently.

Thanks.  The patch submission is fine but 1) you didn't see which
version of GCC you are using; 2) I don't understand why it works.  If
BACKTRACE_SUPPORTED is 0, then I would expect that you would see a
warning for test1, test2, test3, and test4.  Your patch doesn't fix
those, so it sounds like you are only seeing the warning for test5, so
BACKTRACE_SUPPORTED must be 1..  test5 is not compiled if
BACKTRACE_SUPPORTS_DATA is 0, so BACKTRACE_SUPPORTS_DATA must be 1.
So both BACKTRACE_SUPPORTED and BACKTRACE_SUPPORTS_DATA must be 1, so
I don't understand what your patch fixes.

Ian