This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Backport to GCC6


Hello.

I would like to backport following set of revisions to GCC6:

r246345
r246321
r246316
r246276
r246275
r246129
r246120
r246098
r246027
r245998
r245997
r245993
r245992
r245870
r245869
r245868
r245531
r245532
r237353

Survives bootstrap on ppc64le-linux-gnu and x86_64-linux-gnu and the series was run against regress
tests.

Ready for the branch?
Thanks,
Martin
>From 273d0ab1c03889b43945cfd62a346caeea8682a7 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 13 Jun 2016 07:17:16 +0000
Subject: [PATCH 01/19] Backport r237353

gcc/ChangeLog:

2016-06-13  Martin Liska  <mliska@suse.cz>

	PR sanitizer/71458
	* toplev.c (process_options): Do not enable -fcheck-pointer-bounds
	w/ -fsanitize=bounds.

gcc/testsuite/ChangeLog:

2016-06-13  Martin Liska  <mliska@suse.cz>

	* gcc.target/i386/pr71458.c: New test.
---
 gcc/testsuite/gcc.target/i386/pr71458.c | 7 +++++++
 gcc/toplev.c                            | 9 +++++++++
 2 files changed, 16 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/i386/pr71458.c

diff --git a/gcc/testsuite/gcc.target/i386/pr71458.c b/gcc/testsuite/gcc.target/i386/pr71458.c
new file mode 100644
index 00000000000..27e7764b5a0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr71458.c
@@ -0,0 +1,7 @@
+/* { 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 } */
+
+enum {} a[0];
+void fn1(int);
+void fn2() { fn1(a[-1]); }
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 8979d263426..85e203403dd 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1274,6 +1274,15 @@ process_options (void)
 		    "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;
+	}
+
     }
 
   /* One region RA really helps to decrease the code size.  */
-- 
2.12.0

>From 6ed5359ec70aa7bf98a53346882dae955d79d683 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 17 Feb 2017 14:47:08 +0000
Subject: [PATCH 02/19] Backport r245532

gcc/ChangeLog:

2017-02-17  Martin Liska  <mliska@suse.cz>
	PR rtl-optimization/79577
	* params.def (selsched-max-sched-times): Increase minimum to 1.
---
 gcc/params.def | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/params.def b/gcc/params.def
index 6190e984f81..76308cdfcdb 100644
--- a/gcc/params.def
+++ b/gcc/params.def
@@ -634,7 +634,7 @@ DEFPARAM(PARAM_SELSCHED_MAX_LOOKAHEAD,
 DEFPARAM(PARAM_SELSCHED_MAX_SCHED_TIMES,
          "selsched-max-sched-times",
          "Maximum number of times that an insn could be scheduled.",
-         2, 0, 0)
+         2, 1, 0)
 
 DEFPARAM(PARAM_SELSCHED_INSNS_TO_RENAME,
          "selsched-insns-to-rename",
-- 
2.12.0

>From 41aaa157cb11c8b99d555d501cc4321bfcc22492 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 17 Feb 2017 14:46:14 +0000
Subject: [PATCH 03/19] Backport r245531

gcc/ChangeLog:

2017-02-17  Martin Liska  <mliska@suse.cz>
	PR rtl-optimization/79574
	* gcse.c (want_to_gcse_p): Prevent integer overflow.

gcc/testsuite/ChangeLog:

2017-02-17  Martin Liska  <mliska@suse.cz>

	PR rtl-optimization/79574
	* gcc.dg/pr79574.c: New test.
---
 gcc/gcse.c                     |  5 +++--
 gcc/testsuite/gcc.dg/pr79574.c | 10 ++++++++++
 2 files changed, 13 insertions(+), 2 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr79574.c

diff --git a/gcc/gcse.c b/gcc/gcse.c
index a3a7dc31353..3c300f371bc 100644
--- a/gcc/gcse.c
+++ b/gcc/gcse.c
@@ -789,7 +789,7 @@ want_to_gcse_p (rtx x, machine_mode mode, int *max_distance_ptr)
 	/* PRE doesn't implement max_distance restriction.  */
 	{
 	  int cost;
-	  int max_distance;
+	  HOST_WIDE_INT max_distance;
 
 	  gcc_assert (!optimize_function_for_speed_p (cfun)
 		      && optimize_function_for_size_p (cfun));
@@ -797,7 +797,8 @@ want_to_gcse_p (rtx x, machine_mode mode, int *max_distance_ptr)
 
 	  if (cost < COSTS_N_INSNS (GCSE_UNRESTRICTED_COST))
 	    {
-	      max_distance = (GCSE_COST_DISTANCE_RATIO * cost) / 10;
+	      max_distance
+		= ((HOST_WIDE_INT)GCSE_COST_DISTANCE_RATIO * cost) / 10;
 	      if (max_distance == 0)
 		return 0;
 
diff --git a/gcc/testsuite/gcc.dg/pr79574.c b/gcc/testsuite/gcc.dg/pr79574.c
new file mode 100644
index 00000000000..1b666e20d21
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr79574.c
@@ -0,0 +1,10 @@
+/* PR rtl-optimization/79574 */
+/* { dg-do compile } */
+/* { dg-options "-Os --param gcse-cost-distance-ratio=2147483647" } */
+
+void a (void)
+{
+  volatile int b;
+  for (;; b)
+    ;
+}
-- 
2.12.0

>From 4104f8d9ec99905e65e451cfe1a26f89002d0c29 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 3 Mar 2017 11:53:14 +0000
Subject: [PATCH 04/19] Backport r245868

gcc/ChangeLog:

2017-03-03  Martin Liska  <mliska@suse.cz>

	PR rtl-optimization/79574
	* gcse.c (struct gcse_expr): Use HOST_WIDE_INT instead of int.
	(hash_scan_set): Likewise.
	(dump_hash_table): Likewise.
	(hoist_code): Likewise.

gcc/testsuite/ChangeLog:

2017-03-03  Martin Liska  <mliska@suse.cz>

	PR rtl-optimization/79574
	* gcc.dg/pr79574-2.c: New test.
---
 gcc/gcse.c                       | 27 ++++++++++++++++-----------
 gcc/testsuite/gcc.dg/pr79574-2.c | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 11 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr79574-2.c

diff --git a/gcc/gcse.c b/gcc/gcse.c
index 3c300f371bc..5b2c96ecb5a 100644
--- a/gcc/gcse.c
+++ b/gcc/gcse.c
@@ -279,7 +279,7 @@ struct gcse_expr
      to keep register pressure under control.
      A value of "0" removes restrictions on how far the expression can
      travel.  */
-  int max_distance;
+  HOST_WIDE_INT max_distance;
 };
 
 /* Occurrence of an expression.
@@ -457,7 +457,7 @@ static int oprs_unchanged_p (const_rtx, const rtx_insn *, int);
 static int oprs_anticipatable_p (const_rtx, const rtx_insn *);
 static int oprs_available_p (const_rtx, const rtx_insn *);
 static void insert_expr_in_table (rtx, machine_mode, rtx_insn *, int, int,
-				  int, struct gcse_hash_table_d *);
+				  HOST_WIDE_INT, struct gcse_hash_table_d *);
 static unsigned int hash_expr (const_rtx, machine_mode, int *, int);
 static void record_last_reg_set_info (rtx_insn *, int);
 static void record_last_mem_set_info (rtx_insn *);
@@ -487,8 +487,10 @@ static void alloc_code_hoist_mem (int, int);
 static void free_code_hoist_mem (void);
 static void compute_code_hoist_vbeinout (void);
 static void compute_code_hoist_data (void);
-static int should_hoist_expr_to_dom (basic_block, struct gcse_expr *, basic_block,
-				     sbitmap, int, int *, enum reg_class,
+static int should_hoist_expr_to_dom (basic_block, struct gcse_expr *,
+				     basic_block,
+				     sbitmap, HOST_WIDE_INT, int *,
+				     enum reg_class,
 				     int *, bitmap, rtx_insn *);
 static int hoist_code (void);
 static enum reg_class get_regno_pressure_class (int regno, int *nregs);
@@ -742,7 +744,7 @@ static basic_block current_bb;
    GCSE.  */
 
 static int
-want_to_gcse_p (rtx x, machine_mode mode, int *max_distance_ptr)
+want_to_gcse_p (rtx x, machine_mode mode, HOST_WIDE_INT *max_distance_ptr)
 {
 #ifdef STACK_REGS
   /* On register stack architectures, don't GCSE constants from the
@@ -1114,7 +1116,8 @@ expr_equiv_p (const_rtx x, const_rtx y)
 static void
 insert_expr_in_table (rtx x, machine_mode mode, rtx_insn *insn,
 		      int antic_p,
-		      int avail_p, int max_distance, struct gcse_hash_table_d *table)
+		      int avail_p, HOST_WIDE_INT max_distance,
+		      struct gcse_hash_table_d *table)
 {
   int found, do_not_record_p;
   unsigned int hash;
@@ -1230,7 +1233,7 @@ hash_scan_set (rtx set, rtx_insn *insn, struct gcse_hash_table_d *table)
   else if (REG_P (dest))
     {
       unsigned int regno = REGNO (dest);
-      int max_distance = 0;
+      HOST_WIDE_INT max_distance = 0;
 
       /* See if a REG_EQUAL note shows this equivalent to a simpler expression.
 
@@ -1299,7 +1302,7 @@ hash_scan_set (rtx set, rtx_insn *insn, struct gcse_hash_table_d *table)
   else if (flag_gcse_las && REG_P (src) && MEM_P (dest))
     {
       unsigned int regno = REGNO (src);
-      int max_distance = 0;
+      HOST_WIDE_INT max_distance = 0;
 
       /* Only record sets of pseudo-regs in the hash table.  */
       if (regno >= FIRST_PSEUDO_REGISTER
@@ -1411,7 +1414,8 @@ dump_hash_table (FILE *file, const char *name, struct gcse_hash_table_d *table)
     if (flat_table[i] != 0)
       {
 	expr = flat_table[i];
-	fprintf (file, "Index %d (hash value %d; max distance %d)\n  ",
+	fprintf (file, "Index %d (hash value %d; max distance "
+		 HOST_WIDE_INT_PRINT_DEC ")\n  ",
 		 expr->bitmap_index, hash_val[i], expr->max_distance);
 	print_rtl (file, expr->expr);
 	fprintf (file, "\n");
@@ -2875,7 +2879,8 @@ update_bb_reg_pressure (basic_block bb, rtx_insn *from)
 
 static int
 should_hoist_expr_to_dom (basic_block expr_bb, struct gcse_expr *expr,
-			  basic_block bb, sbitmap visited, int distance,
+			  basic_block bb, sbitmap visited,
+			  HOST_WIDE_INT distance,
 			  int *bb_size, enum reg_class pressure_class,
 			  int *nregs, bitmap hoisted_bbs, rtx_insn *from)
 {
@@ -3152,7 +3157,7 @@ hoist_code (void)
 		 computes the expression.  */
 	      FOR_EACH_VEC_ELT (domby, j, dominated)
 		{
-		  int max_distance;
+		  HOST_WIDE_INT max_distance;
 
 		  /* Ignore self dominance.  */
 		  if (bb == dominated)
diff --git a/gcc/testsuite/gcc.dg/pr79574-2.c b/gcc/testsuite/gcc.dg/pr79574-2.c
new file mode 100644
index 00000000000..995dff40174
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr79574-2.c
@@ -0,0 +1,33 @@
+/* PR rtl-optimization/79574 */
+/* { dg-do compile } */
+/* { dg-options "-Os --param gcse-cost-distance-ratio=2147483647" } */
+
+#include "stdarg.h"
+
+int buf[100];
+int buf1[10];
+
+int rd (int *pppp, int n, ...)
+{
+  va_list argp;
+  int *p;
+  int i;
+  int res;
+
+  va_start (argp, n);
+  for (; n > 0; n--)
+    va_arg (argp, double);
+  p = va_arg (argp, int *);
+  i = va_arg (argp, int);
+
+  res = p[i];
+  __builtin_printf ("%d\n", res);
+
+  return res;
+}
+
+int mpx_test (int argc, const char **argv)
+{
+  rd (buf1, 2, 10.0d, 10.0d, buf, 100, buf1);
+  return 0;
+}
-- 
2.12.0

>From c393cdccc45ac5d75df4a63740d150254d898dbc Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 3 Mar 2017 11:53:56 +0000
Subject: [PATCH 05/19] Backport r245869

gcc/ChangeLog:

2017-03-03  Martin Liska  <mliska@suse.cz>
	PR tree-optimization/79803
	* tree-ssa-loop-prefetch.c (tree_ssa_prefetch_arrays): Remove
	assert.
	(pass_loop_prefetch::execute): Disabled optimization if an
	assumption about L1 cache size is not met.

gcc/testsuite/ChangeLog:

2017-03-03  Martin Liska  <mliska@suse.cz>
	PR tree-optimization/79803
	* gcc.dg/tree-ssa/pr79803.c: New test.
---
 gcc/testsuite/gcc.dg/tree-ssa/pr79803.c | 60 +++++++++++++++++++++++++++++++++
 gcc/tree-ssa-loop-prefetch.c            | 20 ++++++++---
 2 files changed, 76 insertions(+), 4 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr79803.c

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr79803.c b/gcc/testsuite/gcc.dg/tree-ssa/pr79803.c
new file mode 100644
index 00000000000..51b245d4d5b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr79803.c
@@ -0,0 +1,60 @@
+/* { dg-do compile { target { x86_64-*-* } } } */
+/* { dg-options "-march=opteron-sse3 -Ofast --param l1-cache-line-size=3 -Wdisabled-optimization" } */
+/* { dg-require-effective-target indirect_jumps } */
+
+#include <setjmp.h>
+
+extern void abort (void);
+
+jmp_buf buf;
+
+void raise0(void)
+{
+  __builtin_longjmp (buf, 1);
+}
+
+int execute(int cmd) /* { dg-warning "'l1-cache-size' parameter is not a power of two 3" } */
+{
+  int last = 0;
+
+  if (__builtin_setjmp (buf) == 0)
+    while (1)
+      {
+	last = 1;
+	raise0 ();
+      }
+
+  if (last == 0)
+    return 0;
+  else
+    return cmd;
+}
+
+int execute2(int cmd, int cmd2)
+{
+  int last = 0;
+
+  if (__builtin_setjmp (buf) == 0)
+    while (1)
+      {
+	last = 1;
+	raise0 ();
+      }
+
+  if (last == 0)
+    return 0;
+  else
+    return cmd;
+}
+
+
+int main(void)
+{
+  if (execute (1) == 0)
+    abort ();
+
+  if (execute2 (1, 2) == 0)
+    abort ();
+
+  return 0;
+}
diff --git a/gcc/tree-ssa-loop-prefetch.c b/gcc/tree-ssa-loop-prefetch.c
index c054c60203c..9fbff21f765 100644
--- a/gcc/tree-ssa-loop-prefetch.c
+++ b/gcc/tree-ssa-loop-prefetch.c
@@ -46,6 +46,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "langhooks.h"
 #include "tree-inline.h"
 #include "tree-data-ref.h"
+#include "diagnostic-core.h"
 
 
 /* FIXME: Needed for optabs, but this should all be moved to a TBD interface
@@ -1965,10 +1966,6 @@ tree_ssa_prefetch_arrays (void)
       set_builtin_decl (BUILT_IN_PREFETCH, decl, false);
     }
 
-  /* We assume that size of cache line is a power of two, so verify this
-     here.  */
-  gcc_assert ((PREFETCH_BLOCK & (PREFETCH_BLOCK - 1)) == 0);
-
   FOR_EACH_LOOP (loop, LI_FROM_INNERMOST)
     {
       if (dump_file && (dump_flags & TDF_DETAILS))
@@ -2026,6 +2023,21 @@ pass_loop_prefetch::execute (function *fun)
   if (number_of_loops (fun) <= 1)
     return 0;
 
+  bool warned_p = false;
+  if ((PREFETCH_BLOCK & (PREFETCH_BLOCK - 1)) != 0)
+    {
+      static bool warned = false;
+
+      if (!warned)
+	{
+	  warning (OPT_Wdisabled_optimization,
+		   "%<l1-cache-size%> parameter is not a power of two %d",
+		   PREFETCH_BLOCK);
+	  warned = true;
+	}
+      return 0;
+    }
+
   return tree_ssa_prefetch_arrays ();
 }
 
-- 
2.12.0

>From 11cf02a799132c886c3649fde10a78e5796bd961 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 3 Mar 2017 11:58:03 +0000
Subject: [PATCH 06/19] Backport r245870

gcc/ChangeLog:

2017-03-03  Jan Hubicka  <jh@suse.cz>

	PR lto/79760
	* ipa-devirt.c (maybe_record_node): Properly handle
	__cxa_pure_virtual visibility.
---
 gcc/ipa-devirt.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index 2cf018bdf39..981fabf6dc6 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -2462,10 +2462,19 @@ maybe_record_node (vec <cgraph_node *> &nodes,
 	  nodes.safe_push (target_node);
 	}
     }
-  else if (completep
-	   && (!type_in_anonymous_namespace_p
-		 (DECL_CONTEXT (target))
-	       || flag_ltrans))
+  else if (!completep)
+    ;
+  /* We have definition of __cxa_pure_virtual that is not accessible (it is
+     optimized out or partitioned to other unit) so we can not add it.  When
+     not sanitizing, there is nothing to do.
+     Otherwise declare the list incomplete.  */
+  else if (pure_virtual)
+    {
+      if (flag_sanitize & SANITIZE_UNREACHABLE)
+	*completep = false;
+    }
+  else if (flag_ltrans
+	   || !type_in_anonymous_namespace_p (DECL_CONTEXT (target)))
     *completep = false;
 }
 
-- 
2.12.0

>From 2f97d9fbc66ba5cd0f02fcbee5d9481040bb2b09 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 9 Mar 2017 09:20:59 +0000
Subject: [PATCH 07/19] Backport r245992

gcc/c-family/ChangeLog:

2017-03-09  Martin Liska  <mliska@suse.cz>

	* 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 75a25ccbc63..d6aa78a7952 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.12.0

>From f6b455583f8d99f71d006467bb9bd66967e136d9 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 9 Mar 2017 09:22:29 +0000
Subject: [PATCH 08/19] Backport r245993

gcc/ChangeLog:

2017-03-09  Martin Liska  <mliska@suse.cz>

	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-09  Martin Liska  <mliska@suse.cz>

	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 00000000000..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 4ca2d34607c..1d1013d01b6 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -3599,8 +3599,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.12.0

>From c92d5136248115ce1f1a4b877178861c628b7a44 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 9 Mar 2017 10:04:50 +0000
Subject: [PATCH 09/19] Backport r245997

gcc/ChangeLog:

2017-03-09  Martin Liska  <mliska@suse.cz>

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

gcc/testsuite/ChangeLog:

2017-03-09  Martin Liska  <mliska@suse.cz>

	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                            | 32 ++++++++++++++++++++------------
 2 files changed, 21 insertions(+), 13 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 85e203403dd..edaae19ec1e 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1267,22 +1267,30 @@ process_options (void)
 	  flag_check_pointer_bounds = 0;
 	}
 
-      if (flag_sanitize & SANITIZE_ADDRESS)
+      if (flag_sanitize)
 	{
-	  error_at (UNKNOWN_LOCATION,
-		    "-fcheck-pointer-bounds is not supported with "
-		    "Address Sanitizer");
-	  flag_check_pointer_bounds = 0;
-	}
+	  if (flag_sanitize & SANITIZE_ADDRESS)
+	    error_at (UNKNOWN_LOCATION,
+		      "-fcheck-pointer-bounds is not supported with "
+		      "Address Sanitizer");
+
+	  if (flag_sanitize & (SANITIZE_UNDEFINED | SANITIZE_NONDEFAULT))
+	    error_at (UNKNOWN_LOCATION,
+		      "-fcheck-pointer-bounds is not supported with "
+		      "Undefined Behavior Sanitizer");
+
+	  if (flag_sanitize & SANITIZE_LEAK)
+	    error_at (UNKNOWN_LOCATION,
+		      "-fcheck-pointer-bounds is not supported with "
+		      "Leak Sanitizer");
+
+	  if (flag_sanitize & SANITIZE_THREAD)
+	    error_at (UNKNOWN_LOCATION,
+		      "-fcheck-pointer-bounds is not supported with "
+		      "Thread Sanitizer");
 
-      if (flag_sanitize & SANITIZE_BOUNDS)
-	{
-	  error_at (UNKNOWN_LOCATION,
-		    "-fcheck-pointer-bounds is not supported with "
-		    "-fsanitize=bounds");
 	  flag_check_pointer_bounds = 0;
 	}
-
     }
 
   /* One region RA really helps to decrease the code size.  */
-- 
2.12.0

>From 0ca1ed216fa75264267b4dad382690eefe31ca12 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 9 Mar 2017 10:10:02 +0000
Subject: [PATCH 10/19] Backport r245998

gcc/ChangeLog:

2017-03-09  Martin Liska  <mliska@suse.cz>
	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-09  Martin Liska  <mliska@suse.cz>
	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                         |  4 +++-
 2 files changed, 18 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 00000000000..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 52d127c26f9..7beaac96d2b 100644
--- a/gcc/tree-chkp-opt.c
+++ b/gcc/tree-chkp-opt.c
@@ -239,9 +239,11 @@ chkp_is_constant_addr (const address_t &addr, int *sign)
     return false;
   else if (addr.pol[0].var)
     return false;
+  else if (TREE_CODE (addr.pol[0].cst) != INTEGER_CST)
+    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_int_cst_sign_bit (addr.pol[0].cst))
     *sign = -1;
   else
     *sign = 1;
-- 
2.12.0

>From 5c67de11093249111b5163134ad74e3b33d6e606 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 10 Mar 2017 13:24:45 +0000
Subject: [PATCH 11/19] Backport r246027

gcc/ChangeLog:

2017-03-10  Martin Liska  <mliska@suse.cz>

        PR target/65705
        PR target/69804
	* toplev.c (process_options): Enable MPX with LSAN and UBSAN.
	* tree-chkp.c (chkp_walk_pointer_assignments): Verify that
	FIELD != NULL.
---
 gcc/testsuite/gcc.target/i386/pr71458.c |  2 +-
 gcc/toplev.c                            | 50 +++++++++++++++++++--------------
 gcc/tree-chkp.c                         |  2 +-
 3 files changed, 31 insertions(+), 23 deletions(-)

diff --git a/gcc/testsuite/gcc.target/i386/pr71458.c b/gcc/testsuite/gcc.target/i386/pr71458.c
index 2faf6bb9391..d36b61cbe02 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 Undefined Behavior Sanitizer" "" { target *-*-* } 0 } */
+/* { dg-error "'-fcheck-pointer-bounds' is not supported with '-fsanitize=bounds'" "" { target *-*-* } 0 } */
 
 enum {} a[0];
 void fn1(int);
diff --git a/gcc/toplev.c b/gcc/toplev.c
index edaae19ec1e..59604e56195 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -1263,31 +1263,39 @@ process_options (void)
       if (targetm.chkp_bound_mode () == VOIDmode)
 	{
 	  error_at (UNKNOWN_LOCATION,
-		    "-fcheck-pointer-bounds is not supported for this target");
+		    "%<-fcheck-pointer-bounds%> is not supported for this "
+		    "target");
 	  flag_check_pointer_bounds = 0;
 	}
 
-      if (flag_sanitize)
+      if (flag_sanitize & SANITIZE_BOUNDS_STRICT)
 	{
-	  if (flag_sanitize & SANITIZE_ADDRESS)
-	    error_at (UNKNOWN_LOCATION,
-		      "-fcheck-pointer-bounds is not supported with "
-		      "Address Sanitizer");
-
-	  if (flag_sanitize & (SANITIZE_UNDEFINED | SANITIZE_NONDEFAULT))
-	    error_at (UNKNOWN_LOCATION,
-		      "-fcheck-pointer-bounds is not supported with "
-		      "Undefined Behavior Sanitizer");
-
-	  if (flag_sanitize & SANITIZE_LEAK)
-	    error_at (UNKNOWN_LOCATION,
-		      "-fcheck-pointer-bounds is not supported with "
-		      "Leak Sanitizer");
-
-	  if (flag_sanitize & SANITIZE_THREAD)
-	    error_at (UNKNOWN_LOCATION,
-		      "-fcheck-pointer-bounds is not supported with "
-		      "Thread Sanitizer");
+	  error_at (UNKNOWN_LOCATION,
+		    "%<-fcheck-pointer-bounds%> is not supported with "
+		    "%<-fsanitize=bounds-strict%>");
+	  flag_check_pointer_bounds = 0;
+	}
+      else if (flag_sanitize & SANITIZE_BOUNDS)
+	{
+	  error_at (UNKNOWN_LOCATION,
+		    "%<-fcheck-pointer-bounds%> is not supported with "
+		    "%<-fsanitize=bounds%>");
+	  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_THREAD)
+	{
+	  error_at (UNKNOWN_LOCATION,
+		    "%<-fcheck-pointer-bounds%> is not supported with "
+		    "Thread Sanitizer");
 
 	  flag_check_pointer_bounds = 0;
 	}
diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index 1d1013d01b6..9ab47b8adaf 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -3734,7 +3734,7 @@ chkp_walk_pointer_assignments (tree lhs, tree rhs, void *arg,
 
 	  FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (rhs), cnt, field, val)
 	    {
-	      if (chkp_type_has_pointer (TREE_TYPE (field)))
+	      if (field && chkp_type_has_pointer (TREE_TYPE (field)))
 		{
 		  tree lhs_field = chkp_build_component_ref (lhs, field);
 		  chkp_walk_pointer_assignments (lhs_field, val, arg, handler);
-- 
2.12.0

>From 7c66c3cb67d51537adcd621daa2e56db09c37543 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 13 Mar 2017 15:30:17 +0000
Subject: [PATCH 12/19] Backport r246098

gcc/ChangeLog:

2017-03-13  Martin Liska  <mliska@suse.cz>

	PR middle-end/78339
	* ipa-pure-const.c (warn_function_noreturn): If the declarations
	is a CHKP clone, use original declaration.

gcc/testsuite/ChangeLog:

2017-03-13  Martin Liska  <mliska@suse.cz>

	PR middle-end/78339
	* gcc.target/i386/mpx/pr78339.c: New test.
---
 gcc/ipa-pure-const.c                        | 8 +++++++-
 gcc/testsuite/gcc.target/i386/mpx/pr78339.c | 5 +++++
 2 files changed, 12 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/mpx/pr78339.c

diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c
index 5421ee31268..75d3ddf91cc 100644
--- a/gcc/ipa-pure-const.c
+++ b/gcc/ipa-pure-const.c
@@ -218,11 +218,17 @@ warn_function_const (tree decl, bool known_finite)
 static void
 warn_function_noreturn (tree decl)
 {
+  tree original_decl = decl;
+
+  cgraph_node *node = cgraph_node::get (decl);
+  if (node->instrumentation_clone)
+    decl = node->instrumented_version->decl;
+
   static hash_set<tree> *warned_about;
   if (!lang_hooks.missing_noreturn_ok_p (decl)
       && targetm.warn_func_return (decl))
     warned_about 
-      = suggest_attribute (OPT_Wsuggest_attribute_noreturn, decl,
+      = suggest_attribute (OPT_Wsuggest_attribute_noreturn, original_decl,
 			   true, warned_about, "noreturn");
 }
 
diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr78339.c b/gcc/testsuite/gcc.target/i386/mpx/pr78339.c
new file mode 100644
index 00000000000..3dd04240e8c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/mpx/pr78339.c
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -Wsuggest-attribute=noreturn" } */
+
+extern _Noreturn void exit (int);
+int main (void) { exit (1); }
-- 
2.12.0

>From 6c7fe1916f75330d662fba0096b51ecc3cb36b1c Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 14 Mar 2017 12:05:29 +0000
Subject: [PATCH 13/19] Backport r246120

gcc/ChangeLog:

2017-03-14  Martin Liska  <mliska@suse.cz>
	PR target/79892
	* multiple_target.c (create_dispatcher_calls): Check that
	a target can create a function dispatcher.
---
 gcc/multiple_target.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gcc/multiple_target.c b/gcc/multiple_target.c
index 59880a390d0..5edd8bb2ced 100644
--- a/gcc/multiple_target.c
+++ b/gcc/multiple_target.c
@@ -68,6 +68,13 @@ create_dispatcher_calls (struct cgraph_node *node)
 		    " supported by this target");
 	  break;
 	}
+      else if (!targetm.get_function_versions_dispatcher)
+	{
+	  error_at (gimple_location (call),
+		    "target does not support function version dispatcher");
+	  break;
+	}
+
       e_next = e->next_caller;
       idecl = targetm.get_function_versions_dispatcher (decl);
       if (!idecl)
-- 
2.12.0

>From 502e3af0ce8fefbbe23dee01e56d6f25459f6497 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 14 Mar 2017 15:31:53 +0000
Subject: [PATCH 14/19] Backport r246129

gcc/ChangeLog:

2017-03-14  Martin Liska  <mliska@suse.cz>
	PR middle-end/79831
	* doc/invoke.texi (-Wchkp): Document the option.
---
 gcc/doc/invoke.texi | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index e003ccaa353..dca9d7c7db6 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -256,7 +256,7 @@ Objective-C and Objective-C++ Dialects}.
 -Wno-attributes -Wbool-compare -Wno-builtin-macro-redefined @gol
 -Wc90-c99-compat -Wc99-c11-compat @gol
 -Wc++-compat -Wc++11-compat -Wc++14-compat -Wcast-align  -Wcast-qual  @gol
--Wchar-subscripts -Wclobbered  -Wcomment -Wconditionally-supported  @gol
+-Wchar-subscripts -Wchkp -Wclobbered  -Wcomment -Wconditionally-supported  @gol
 -Wconversion -Wcoverage-mismatch -Wno-cpp -Wdate-time -Wdelete-incomplete @gol
 -Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init @gol
 -Wdisabled-optimization @gol
@@ -3650,6 +3650,11 @@ Warn whenever a comment-start sequence @samp{/*} appears in a @samp{/*}
 comment, or whenever a Backslash-Newline appears in a @samp{//} comment.
 This warning is enabled by @option{-Wall}.
 
+@item -Wchkp
+@opindex Wchkp
+Warn about an invalid memory access that is found by Pointer Bounds Checker
+(@option{-fcheck-pointer-bounds}).
+
 @item -Wno-coverage-mismatch
 @opindex Wno-coverage-mismatch
 Warn if feedback profiles do not match when using the
-- 
2.12.0

>From 663507a0231a44c3f0441e75c468cb05e8ae0418 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 20 Mar 2017 10:04:06 +0000
Subject: [PATCH 15/19] Backport r246275

gcc/ChangeLog:

2017-03-20  Martin Liska  <mliska@suse.cz>

	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-20  Martin Liska  <mliska@suse.cz>

	PR target/79769
	PR target/79770
	* g++.dg/pr79769.C: New test.
	* gcc.target/i386/mpx/pr79770.c: New test.
---
 gcc/testsuite/g++.dg/pr79769.C              |  4 ++++
 gcc/testsuite/gcc.target/i386/mpx/pr79770.c | 19 +++++++++++++++++++
 gcc/tree-chkp.c                             |  2 ++
 3 files changed, 25 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/pr79769.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 00000000000..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/pr79770.c b/gcc/testsuite/gcc.target/i386/mpx/pr79770.c
new file mode 100644
index 00000000000..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 9ab47b8adaf..c9c4b4fc8e0 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -3662,6 +3662,8 @@ chkp_find_bounds_1 (tree ptr, tree ptr_src, gimple_stmt_iterator *iter)
       break;
 
     case INTEGER_CST:
+    case COMPLEX_CST:
+    case VECTOR_CST:
       if (integer_zerop (ptr_src))
 	bounds = chkp_get_none_bounds ();
       else
-- 
2.12.0

>From 2032dbf616595d4e398bfec2946cae3050020b31 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 20 Mar 2017 10:06:00 +0000
Subject: [PATCH 16/19] Backport r246276

gcc/ChangeLog:

2017-03-20  Martin Liska  <mliska@suse.cz>
	PR middle-end/79753
	* tree-chkp.c (chkp_build_returned_bound): Do not build
	returned bounds for a LHS that's not a BOUNDED_P type.

gcc/testsuite/ChangeLog:

2017-03-20  Martin Liska  <mliska@suse.cz>
	PR middle-end/79753
	* gcc.target/i386/mpx/pr79753.c: New test.
---
 gcc/testsuite/gcc.target/i386/mpx/pr79753.c | 14 ++++++++++++++
 gcc/tree-chkp.c                             | 11 ++++++-----
 2 files changed, 20 insertions(+), 5 deletions(-)
 create mode 100644 gcc/testsuite/gcc.target/i386/mpx/pr79753.c

diff --git a/gcc/testsuite/gcc.target/i386/mpx/pr79753.c b/gcc/testsuite/gcc.target/i386/mpx/pr79753.c
new file mode 100644
index 00000000000..9b7bc52e1ed
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/mpx/pr79753.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-fcheck-pointer-bounds -mmpx -O2" } */
+
+int
+foo (void)
+{
+  return 0;
+}
+
+void
+bar (int **p)
+{
+  *p = (int *) (__UINTPTR_TYPE__) foo ();
+}
diff --git a/gcc/tree-chkp.c b/gcc/tree-chkp.c
index c9c4b4fc8e0..2901e8b354d 100644
--- a/gcc/tree-chkp.c
+++ b/gcc/tree-chkp.c
@@ -2215,6 +2215,7 @@ chkp_build_returned_bound (gcall *call)
   gimple *stmt;
   tree fndecl = gimple_call_fndecl (call);
   unsigned int retflags;
+  tree lhs = gimple_call_lhs (call);
 
   /* To avoid fixing alloca expands in targets we handle
      it separately.  */
@@ -2224,9 +2225,8 @@ chkp_build_returned_bound (gcall *call)
 	  || DECL_FUNCTION_CODE (fndecl) == BUILT_IN_ALLOCA_WITH_ALIGN))
     {
       tree size = gimple_call_arg (call, 0);
-      tree lb = gimple_call_lhs (call);
       gimple_stmt_iterator iter = gsi_for_stmt (call);
-      bounds = chkp_make_bounds (lb, size, &iter, true);
+      bounds = chkp_make_bounds (lhs, size, &iter, true);
     }
   /* We know bounds returned by set_bounds builtin call.  */
   else if (fndecl
@@ -2279,9 +2279,10 @@ chkp_build_returned_bound (gcall *call)
 
       bounds = chkp_find_bounds (gimple_call_arg (call, argno), &iter);
     }
-  else if (chkp_call_returns_bounds_p (call))
+  else if (chkp_call_returns_bounds_p (call)
+	   && BOUNDED_P (lhs))
     {
-      gcc_assert (TREE_CODE (gimple_call_lhs (call)) == SSA_NAME);
+      gcc_assert (TREE_CODE (lhs) == SSA_NAME);
 
       /* In general case build checker builtin call to
 	 obtain returned bounds.  */
@@ -2308,7 +2309,7 @@ chkp_build_returned_bound (gcall *call)
       print_gimple_stmt (dump_file, call, 0, TDF_VOPS|TDF_MEMSYMS);
     }
 
-  bounds = chkp_maybe_copy_and_register_bounds (gimple_call_lhs (call), bounds);
+  bounds = chkp_maybe_copy_and_register_bounds (lhs, bounds);
 
   return bounds;
 }
-- 
2.12.0

>From 999b421634fbb5b1708efad955e75e1af5e2a443 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 21 Mar 2017 12:01:40 +0000
Subject: [PATCH 17/19] Backport r246316

gcc/testsuite/ChangeLog:

2017-03-21  Martin Liska  <mliska@suse.cz>

	* gcc.target/i386/pr65044.c: Add '.' in order to catch
	apostrophes.
---
 gcc/testsuite/gcc.target/i386/pr65044.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.target/i386/pr65044.c b/gcc/testsuite/gcc.target/i386/pr65044.c
index 9b0636339e5..d5cfecd15a9 100644
--- a/gcc/testsuite/gcc.target/i386/pr65044.c
+++ b/gcc/testsuite/gcc.target/i386/pr65044.c
@@ -1,6 +1,6 @@
 /* { dg-do compile { target { ! x32 } } } */
 /* { dg-options "-fcheck-pointer-bounds -mmpx -fsanitize=address" } */
-/* { dg-error "-fcheck-pointer-bounds is not supported with Address Sanitizer" "" { target *-*-* } 0 } */
+/* { dg-error ".-fcheck-pointer-bounds. is not supported with Address Sanitizer" "" { target *-*-* } 0 } */
 
 extern int x[];
 
-- 
2.12.0

>From 98685b7ee251968b908aed75d9ca3295ab0f187d Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 21 Mar 2017 14:41:11 +0000
Subject: [PATCH 18/19] Backport r246321

gcc/ChangeLog:

2017-03-21  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/80081
	* Makefile.in: Add gcov-dump and fix installation of gcov-tool.
	* doc/gcc.texi: Include gcov-dump stuff.
	* doc/gcov-dump.texi: New file.
---
 gcc/Makefile.in        | 11 ++++--
 gcc/doc/gcc.texi       |  3 ++
 gcc/doc/gcov-dump.texi | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 105 insertions(+), 2 deletions(-)
 create mode 100644 gcc/doc/gcov-dump.texi

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index ec0e88c202c..a200fd86132 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2977,7 +2977,7 @@ TEXI_GCC_FILES = gcc.texi gcc-common.texi gcc-vers.texi frontends.texi	\
 	 gcov.texi trouble.texi bugreport.texi service.texi		\
 	 contribute.texi compat.texi funding.texi gnu.texi gpl_v3.texi	\
 	 fdl.texi contrib.texi cppenv.texi cppopts.texi avr-mmcu.texi	\
-	 implement-c.texi implement-cxx.texi gcov-tool.texi
+	 implement-c.texi implement-cxx.texi gcov-tool.texi gcov-dump.texi
 
 # we explicitly use $(srcdir)/doc/tm.texi here to avoid confusion with
 # the generated tm.texi; the latter might have a more recent timestamp,
@@ -3100,7 +3100,7 @@ $(build_htmldir)/gccinstall/index.html: $(TEXI_GCCINSTALL_FILES)
 	$(SHELL) $(srcdir)/doc/install.texi2html
 
 MANFILES = doc/gcov.1 doc/cpp.1 doc/gcc.1 doc/gfdl.7 doc/gpl.7 \
-           doc/fsf-funding.7 doc/gcov-tool.1
+           doc/fsf-funding.7 doc/gcov-tool.1 doc/gcov-dump.1
 
 generated-manpages: man
 
@@ -3501,6 +3501,8 @@ install-man: lang.install-man \
 	$(DESTDIR)$(man1dir)/$(GCC_INSTALL_NAME)$(man1ext) \
 	$(DESTDIR)$(man1dir)/$(CPP_INSTALL_NAME)$(man1ext) \
 	$(DESTDIR)$(man1dir)/$(GCOV_INSTALL_NAME)$(man1ext) \
+	$(DESTDIR)$(man1dir)/$(GCOV_TOOL_INSTALL_NAME)$(man1ext) \
+	$(DESTDIR)$(man1dir)/$(GCOV_DUMP_INSTALL_NAME)$(man1ext) \
 	$(DESTDIR)$(man7dir)/fsf-funding$(man7ext) \
 	$(DESTDIR)$(man7dir)/gfdl$(man7ext) \
 	$(DESTDIR)$(man7dir)/gpl$(man7ext)
@@ -3530,6 +3532,11 @@ $(DESTDIR)$(man1dir)/$(GCOV_TOOL_INSTALL_NAME)$(man1ext): doc/gcov-tool.1 instal
 	-$(INSTALL_DATA) $< $@
 	-chmod a-x $@
 
+$(DESTDIR)$(man1dir)/$(GCOV_DUMP_INSTALL_NAME)$(man1ext): doc/gcov-dump.1 installdirs
+	-rm -f $@
+	-$(INSTALL_DATA) $< $@
+	-chmod a-x $@
+
 # Install all the header files built in the include subdirectory.
 install-headers: $(INSTALL_HEADERS_DIR)
 # Fix symlinks to absolute paths in the installed include directory to
diff --git a/gcc/doc/gcc.texi b/gcc/doc/gcc.texi
index 629365aeb12..b5a93764806 100644
--- a/gcc/doc/gcc.texi
+++ b/gcc/doc/gcc.texi
@@ -67,6 +67,7 @@ Texts being (a) (see below), and with the Back-Cover Texts being (b)
 * g++: (gcc).                  The GNU C++ compiler.
 * gcov: (gcc) Gcov.            @command{gcov}---a test coverage program.
 * gcov-tool: (gcc) Gcov-tool.  @command{gcov-tool}---an offline gcda profile processing program.
+* gcov-dump: (gcc) Gcov-dump.  @command{gcov-dump}---an offline gcda and gcno profile dump tool.
 @end direntry
 This file documents the use of the GNU compilers.
 @sp 1
@@ -140,6 +141,7 @@ Introduction, gccint, GNU Compiler Collection (GCC) Internals}.
 * Compatibility::   Binary Compatibility
 * Gcov::            @command{gcov}---a test coverage program.
 * Gcov-tool::       @command{gcov-tool}---an offline gcda profile processing program.
+* Gcov-dump::       @command{gcov-dump}---an offline gcda and gcno profile dump tool.
 * Trouble::         If you have trouble using GCC.
 * Bugs::            How, why and where to report bugs.
 * Service::         How To Get Help with GCC
@@ -167,6 +169,7 @@ Introduction, gccint, GNU Compiler Collection (GCC) Internals}.
 @include compat.texi
 @include gcov.texi
 @include gcov-tool.texi
+@include gcov-dump.texi
 @include trouble.texi
 @include bugreport.texi
 @include service.texi
diff --git a/gcc/doc/gcov-dump.texi b/gcc/doc/gcov-dump.texi
new file mode 100644
index 00000000000..d7931fd3a19
--- /dev/null
+++ b/gcc/doc/gcov-dump.texi
@@ -0,0 +1,93 @@
+@c Copyright (C) 2017 Free Software Foundation, Inc.
+@c This is part of the GCC manual.
+@c For copying conditions, see the file gcc.texi.
+
+@ignore
+@c man begin COPYRIGHT
+Copyright @copyright{} 2017 Free Software Foundation, Inc.
+
+Permission is granted to copy, distribute and/or modify this document
+under the terms of the GNU Free Documentation License, Version 1.3 or
+any later version published by the Free Software Foundation; with the
+Invariant Sections being ``GNU General Public License'' and ``Funding
+Free Software'', the Front-Cover texts being (a) (see below), and with
+the Back-Cover Texts being (b) (see below).  A copy of the license is
+included in the gfdl(7) man page.
+
+(a) The FSF's Front-Cover Text is:
+
+     A GNU Manual
+
+(b) The FSF's Back-Cover Text is:
+
+     You have freedom to copy and modify this GNU Manual, like GNU
+     software.  Copies published by the Free Software Foundation raise
+     funds for GNU development.
+@c man end
+@c Set file name and title for the man page.
+@setfilename gcov-dump
+@settitle offline gcda and gcno profile dump tool
+@end ignore
+
+@node Gcov-dump
+@chapter @command{gcov-dump}---an Offline Gcda and Gcno Profile Dump Tool
+
+@menu
+* Gcov-dump Intro::             Introduction to gcov-dump.
+* Invoking Gcov-dump::          How to use gcov-dump.
+@end menu
+
+@node Gcov-dump Intro
+@section Introduction to @command{gcov-dump}
+@c man begin DESCRIPTION
+
+@command{gcov-dump} is a tool you can use in conjunction with GCC to
+dump content of gcda and gcno profile files offline.
+
+@c man end
+
+@node Invoking Gcov-dump
+@section Invoking @command{gcov-dump}
+
+@smallexample
+Usage: gcov-dump @r{[}@var{OPTION}@r{]} ... @var{gcovfiles}
+@end smallexample
+
+@command{gcov-dump} accepts the following options:
+
+@ignore
+@c man begin SYNOPSIS
+gcov-dump [@option{-v}|@option{--version}]
+     [@option{-h}|@option{--help}]
+     [@option{-l}|@option{--long}]
+     [@option{-p}|@option{--positions}]
+     [@option{-w}|@option{--working-sets}] @var{gcovfiles}
+@c man end
+@end ignore
+
+@c man begin OPTIONS
+@table @gcctabopt
+@item -h
+@itemx --help
+Display help about using @command{gcov-dump} (on the standard output), and
+exit without doing any further processing.
+
+@item -v
+@itemx --version
+Display the @command{gcov-dump} version number (on the standard output),
+and exit without doing any further processing.
+
+@item -l
+@itemx --long
+Dump content of records.
+
+@item -p
+@itemx --positions
+Dump positions of records.
+
+@item -w
+@itemx --working-sets
+Dump working set computed from summary.
+@end table
+
+@c man end
-- 
2.12.0

>From 8052e5f6e616fe3d7686869940b8957ed6dc9f48 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 22 Mar 2017 09:21:56 +0000
Subject: [PATCH 19/19] Backport r246345

gcc/ChangeLog:

2017-03-22  Martin Liska  <mliska@suse.cz>

	PR target/79906
	* config/rs6000/rs6000.c (rs6000_inner_target_options): Show
	error message instead of an ICE.

gcc/testsuite/ChangeLog:

2017-03-22  Martin Liska  <mliska@suse.cz>

	PR target/79906
	* g++.dg/ext/mv8.C: Add power* targets.
---
 gcc/config/rs6000/rs6000.c     | 5 ++++-
 gcc/testsuite/g++.dg/ext/mv8.C | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 4c31bddf9da..1a308d798e4 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -36168,7 +36168,10 @@ rs6000_inner_target_options (tree args, bool attr_p)
     }
 
   else
-    gcc_unreachable ();
+    {
+      error ("attribute %<target%> argument not a string");
+      return false;
+    }
 
   return ret;
 }
diff --git a/gcc/testsuite/g++.dg/ext/mv8.C b/gcc/testsuite/g++.dg/ext/mv8.C
index 2e98dd7ad85..bbf90b5a328 100644
--- a/gcc/testsuite/g++.dg/ext/mv8.C
+++ b/gcc/testsuite/g++.dg/ext/mv8.C
@@ -1,4 +1,4 @@
-// { dg-do compile { target i?86-*-* x86_64-*-* } }
+// { dg-do compile { target i?86-*-* x86_64-*-* powerpc*-*-* } }
 // { dg-options "" }
 
 __attribute__((target (11,12)))
-- 
2.12.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]