public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Backport to GCC6
@ 2017-04-25 11:49 Martin Liška
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Liška @ 2017-04-25 11:49 UTC (permalink / raw)
  To: GCC Patches; +Cc: Richard Biener

[-- Attachment #1: Type: text/plain, Size: 365 bytes --]

Hello.

There's a series of revisions I would like to install to GCC 6 branch.
When I did the same couple weeks ago, Richi told me to install regression
without asking for a permission. However the series also contains various
fixed for PRs that are present probably from the time a functionality
was added. Thus I'm sending the whole series to ML.

Thanks,
Martin

[-- Attachment #2: 0013-Backport-r247097.patch --]
[-- Type: text/x-patch, Size: 2485 bytes --]

From 6408f98d499ebaf8e4d72ffa43a8471aa2fad8b1 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 24 Apr 2017 13:16:34 +0000
Subject: [PATCH 13/13] Backport r247097

gcc/ChangeLog:

2017-04-24  Jan Hubicka  <hubicka@ucw.cz>

	PR middle-end/79931
	* ipa-devirt.c (dump_possible_polymorphic_call_targets): Fix ICE.

gcc/testsuite/ChangeLog:

2017-04-24  Martin Liska  <mliska@suse.cz>

	PR middle-end/79931
	* g++.dg/ipa/pr79931.C: New test.
---
 gcc/ipa-devirt.c                   |  8 +++++++-
 gcc/testsuite/g++.dg/ipa/pr79931.C | 24 ++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/ipa/pr79931.C

diff --git a/gcc/ipa-devirt.c b/gcc/ipa-devirt.c
index 981fabf6dc6..0332b3ec616 100644
--- a/gcc/ipa-devirt.c
+++ b/gcc/ipa-devirt.c
@@ -3367,7 +3367,13 @@ dump_possible_polymorphic_call_targets (FILE *f,
       fprintf (f, "  Speculative targets:");
       dump_targets (f, targets);
     }
-  gcc_assert (targets.length () <= len);
+  /* Ugly: during callgraph construction the target cache may get populated
+     before all targets are found.  While this is harmless (because all local
+     types are discovered and only in those case we devirtualize fully and we
+     don't do speculative devirtualization before IPA stage) it triggers
+     assert here when dumping at that stage also populates the case with
+     speculative targets.  Quietly ignore this.  */
+  gcc_assert (symtab->state < IPA_SSA || targets.length () <= len);
   fprintf (f, "\n");
 }
 
diff --git a/gcc/testsuite/g++.dg/ipa/pr79931.C b/gcc/testsuite/g++.dg/ipa/pr79931.C
new file mode 100644
index 00000000000..78f6e03c458
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr79931.C
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-all" } */
+
+class DocumentImpl;
+struct NodeImpl
+{
+  virtual DocumentImpl * getOwnerDocument();
+  virtual NodeImpl * getParentNode();
+  virtual NodeImpl * removeChild(NodeImpl *oldChild);
+};
+struct AttrImpl : NodeImpl
+{
+  NodeImpl *insertBefore(NodeImpl *newChild, NodeImpl *refChild);
+};
+struct DocumentImpl : NodeImpl
+{
+  virtual NodeImpl *removeChild(NodeImpl *oldChild);
+  virtual int* getRanges();
+};
+NodeImpl *AttrImpl::insertBefore(NodeImpl *newChild, NodeImpl *refChild) {
+  NodeImpl *oldparent = newChild->getParentNode();
+  oldparent->removeChild(newChild);
+  this->getOwnerDocument()->getRanges();
+}
-- 
2.12.2


[-- Attachment #3: 0012-Backport-r246996.patch --]
[-- Type: text/x-patch, Size: 936 bytes --]

From 052f030a600e1396b29f7f8c63bbe2628ca767e3 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 19 Apr 2017 12:06:35 +0000
Subject: [PATCH 12/13] Backport r246996

gcc/ChangeLog:

2017-04-19  Richard Biener  <rguenther@suse.de>

	PR ipa/65972
	* auto-profile.c (afdo_vpt_for_early_inline): Update SSA
	when needed by AutoPGO.
---
 gcc/auto-profile.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/auto-profile.c b/gcc/auto-profile.c
index cd82ab4932d..94afe6fd2d9 100644
--- a/gcc/auto-profile.c
+++ b/gcc/auto-profile.c
@@ -1437,7 +1437,9 @@ afdo_vpt_for_early_inline (stmt_set *promoted_stmts)
 
   if (has_vpt)
     {
-      optimize_inline_calls (current_function_decl);
+      unsigned todo = optimize_inline_calls (current_function_decl);
+      if (todo & TODO_update_ssa_any)
+       update_ssa (TODO_update_ssa);
       return true;
     }
 
-- 
2.12.2


[-- Attachment #4: 0011-Backport-r246995.patch --]
[-- Type: text/x-patch, Size: 1199 bytes --]

From d6375474d7a4f091044b35cc17d5d603656c8ae2 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Wed, 19 Apr 2017 12:00:47 +0000
Subject: [PATCH 11/13] Backport r246995

gcc/ChangeLog:

2017-04-19  Paulo J. Matos  <paulo@matos-sorge.com>

	PR lto/50345
	* doc/lto.texi: Remove an extra 'that'.
---
 gcc/doc/lto.texi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/doc/lto.texi b/gcc/doc/lto.texi
index 9269e55ca31..970a4d839af 100644
--- a/gcc/doc/lto.texi
+++ b/gcc/doc/lto.texi
@@ -43,7 +43,7 @@ existing build systems, as one can, for instance, produce archives of
 the files.  Additionally, one might be able to ship one set of fat
 objects which could be used both for development and the production of
 optimized builds.  A, perhaps surprising, side effect of this feature
-is that any mistake in the toolchain that leads to LTO information not
+is that any mistake in the toolchain leads to LTO information not
 being used (e.g.@: an older @code{libtool} calling @code{ld} directly).
 This is both an advantage, as the system is more robust, and a
 disadvantage, as the user is not informed that the optimization has
-- 
2.12.2


[-- Attachment #5: 0010-Backport-r246961.patch --]
[-- Type: text/x-patch, Size: 2236 bytes --]

From ea4c4aa982b45c0c97eced7521f7be83a12a0b83 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 18 Apr 2017 07:24:20 +0000
Subject: [PATCH 10/13] Backport r246961

gcc/ChangeLog:

2017-04-18  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/78783
	* gcov-tool.c (gcov_output_files): Validate that destination
	file is either removed by the tool or by a user.

libgcc/ChangeLog:

2017-04-18  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/78783
	* libgcov-driver.c (gcov_get_filename): New function.
---
 gcc/gcov-tool.c         | 9 +++++++++
 libgcc/libgcov-driver.c | 9 +++++++++
 2 files changed, 18 insertions(+)

diff --git a/gcc/gcov-tool.c b/gcc/gcov-tool.c
index f628b603a80..911d9249321 100644
--- a/gcc/gcov-tool.c
+++ b/gcc/gcov-tool.c
@@ -46,6 +46,7 @@ extern int gcov_profile_normalize (struct gcov_info*, gcov_type);
 extern int gcov_profile_scale (struct gcov_info*, float, int, int);
 extern struct gcov_info* gcov_read_profile_dir (const char*, int);
 extern void gcov_do_dump (struct gcov_info *, int);
+extern const char *gcov_get_filename (struct gcov_info *list);
 extern void gcov_set_verbose (void);
 
 /* Set to verbose output mode.  */
@@ -114,6 +115,14 @@ gcov_output_files (const char *out, struct gcov_info *profile)
   if (ret)
     fatal_error (input_location, "Cannot change directory to %s", out);
 
+  /* Verify that output file does not exist (either was removed by
+     unlink_profile_data or removed by user).  */
+  const char *filename = gcov_get_filename (profile);
+
+  if (access (filename, F_OK) != -1)
+    fatal_error (input_location, "output file %s already exists in folder %s",
+		 filename, out);
+
   gcov_do_dump (profile, 0);
 
   ret = chdir (pwd);
diff --git a/libgcc/libgcov-driver.c b/libgcc/libgcov-driver.c
index 9c4eeca0163..ff1a3d656b3 100644
--- a/libgcc/libgcov-driver.c
+++ b/libgcc/libgcov-driver.c
@@ -848,6 +848,15 @@ gcov_do_dump (struct gcov_info *list, int run_counted)
   free (gf.filename);
 }
 
+#if IN_GCOV_TOOL
+const char *
+__attribute__ ((unused))
+gcov_get_filename (struct gcov_info *list)
+{
+  return list->filename;
+}
+#endif
+
 #if !IN_GCOV_TOOL
 void
 __gcov_dump_one (struct gcov_root *root)
-- 
2.12.2


[-- Attachment #6: 0009-Backport-r246903.patch --]
[-- Type: text/x-patch, Size: 939 bytes --]

From 7d3efb80c256a855ce39ad9a863653886dc91151 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 13 Apr 2017 11:51:28 +0000
Subject: [PATCH 09/13] Backport r246903

gcc/ChangeLog:

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

	PR gcov-profile/80413
	* gcov-io.c (gcov_write_string): Copy to buffer just when
	allocated size is greater than zero.
---
 gcc/gcov-io.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/gcov-io.c b/gcc/gcov-io.c
index 17fcae00636..cdd9fa975e3 100644
--- a/gcc/gcov-io.c
+++ b/gcc/gcov-io.c
@@ -372,8 +372,12 @@ gcov_write_string (const char *string)
   buffer = gcov_write_words (1 + alloc);
 
   buffer[0] = alloc;
-  buffer[alloc] = 0;
-  memcpy (&buffer[1], string, length);
+
+  if (alloc > 0)
+    {
+      buffer[alloc] = 0; /* place nul terminators.  */
+      memcpy (&buffer[1], string, length);
+    }
 }
 #endif
 
-- 
2.12.2


[-- Attachment #7: 0008-Backport-r246848.patch --]
[-- Type: text/x-patch, Size: 2305 bytes --]

From 158214056ffc68ad8e04d1ba91d7e26aa3b58c4d Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 11 Apr 2017 16:38:19 +0000
Subject: [PATCH 08/13] Backport r246848

gcc/ChangeLog:

2017-04-11  Martin Liska  <mliska@suse.cz>

	PR ipa/80212
	* cgraph.c (cgraph_node::dump): Dump calls_comdat_local.
	* ipa-split.c (split_function): Create a local comdat symbol
	if caller is in a comdat group.

gcc/testsuite/ChangeLog:

2017-04-11  Martin Liska  <mliska@suse.cz>

	PR ipa/80212
	* g++.dg/ipa/pr80212.C: New test.
---
 gcc/cgraph.c                       |  2 ++
 gcc/ipa-split.c                    |  9 +++++++++
 gcc/testsuite/g++.dg/ipa/pr80212.C | 18 ++++++++++++++++++
 3 files changed, 29 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/ipa/pr80212.C

diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 223c0272f11..6ff8f26ef39 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -2086,6 +2086,8 @@ cgraph_node::dump (FILE *f)
     fprintf (f, " only_called_at_exit");
   if (tm_clone)
     fprintf (f, " tm_clone");
+  if (calls_comdat_local)
+    fprintf (f, " calls_comdat_local");
   if (icf_merged)
     fprintf (f, " icf_merged");
   if (merged_comdat)
diff --git a/gcc/ipa-split.c b/gcc/ipa-split.c
index ac8b4787b10..1262e7e1d13 100644
--- a/gcc/ipa-split.c
+++ b/gcc/ipa-split.c
@@ -1364,6 +1364,15 @@ split_function (basic_block return_bb, struct split_point *split_point,
 
   node->split_part = true;
 
+  if (cur_node->same_comdat_group)
+    {
+      /* TODO: call is versionable if we make sure that all
+	 callers are inside of a comdat group.  */
+      cur_node->calls_comdat_local = 1;
+      node->add_to_same_comdat_group (cur_node);
+    }
+
+
   /* Let's take a time profile for splitted function.  */
   node->tp_first_run = cur_node->tp_first_run + 1;
 
diff --git a/gcc/testsuite/g++.dg/ipa/pr80212.C b/gcc/testsuite/g++.dg/ipa/pr80212.C
new file mode 100644
index 00000000000..60d3b613035
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr80212.C
@@ -0,0 +1,18 @@
+// PR ipa/80212
+// { dg-options "-O2 --param partial-inlining-entry-probability=403796683 -fno-early-inlining" }
+
+struct b
+{
+  virtual b *c () const;
+};
+struct d : virtual b
+{
+};
+struct e : d
+{
+  e *
+  c () const
+  {
+  }
+};
+main () { e a; }
-- 
2.12.2


[-- Attachment #8: 0007-Backport-r246847.patch --]
[-- Type: text/x-patch, Size: 1117 bytes --]

From 6f1336102a7bcfb2d2b4e0806596635a701b121a Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 11 Apr 2017 16:37:31 +0000
Subject: [PATCH 07/13] Backport r246847

gcc/ChangeLog:

2017-04-11  Martin Liska  <mliska@suse.cz>

	PR ipa/80212
	* ipa-cp.c (determine_versionability): Handle calls_comdat_local
	flags.
---
 gcc/ipa-cp.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 5900d4d9158..98bb9514777 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -537,6 +537,12 @@ determine_versionability (struct cgraph_node *node,
      decloned constructors, inlining is always better anyway.  */
   else if (node->comdat_local_p ())
     reason = "comdat-local function";
+  else if (node->calls_comdat_local)
+    {
+      /* TODO: call is versionable if we make sure that all
+	 callers are inside of a comdat group.  */
+      reason = "calls comdat-local function";
+    }
 
   if (reason && dump_file && !node->alias && !node->thunk.thunk_p)
     fprintf (dump_file, "Function %s/%i is not versionable, reason: %s.\n",
-- 
2.12.2


[-- Attachment #9: 0006-Backport-r246837.patch --]
[-- Type: text/x-patch, Size: 1719 bytes --]

From 020413c350d4316e07eab9105c62d3aaf75ffc5d Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 11 Apr 2017 13:08:08 +0000
Subject: [PATCH 06/13] Backport r246837

gcc/ChangeLog:

2017-04-11  Martin Liska  <mliska@suse.cz>

	PR sanitizer/70878
	* ubsan.c (instrument_object_size): Do not instrument register
	variables.

gcc/testsuite/ChangeLog:

2017-04-11  Martin Liska  <mliska@suse.cz>

	PR sanitizer/70878
	* gcc.dg/ubsan/pr70878.c: New test.
---
 gcc/testsuite/gcc.dg/ubsan/pr70878.c | 9 +++++++++
 gcc/ubsan.c                          | 6 +++++-
 2 files changed, 14 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/ubsan/pr70878.c

diff --git a/gcc/testsuite/gcc.dg/ubsan/pr70878.c b/gcc/testsuite/gcc.dg/ubsan/pr70878.c
new file mode 100644
index 00000000000..acd7fb05e4c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ubsan/pr70878.c
@@ -0,0 +1,9 @@
+/* PR sanitizer/80878 */
+/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && lp64 } } } */
+/* { dg-options "-fsanitize=object-size" } */
+
+void * sbrk ()
+{
+ volatile register unsigned int sp_r1 __asm__ ("ebx");
+ return __builtin_strcat ((char*)sp_r1, 0); /* { dg-warning "cast to pointer from integer of different size" } */
+}
diff --git a/gcc/ubsan.c b/gcc/ubsan.c
index 2ee908c490b..fb0ba33e230 100644
--- a/gcc/ubsan.c
+++ b/gcc/ubsan.c
@@ -1794,7 +1794,11 @@ instrument_object_size (gimple_stmt_iterator *gsi, bool is_lhs)
   bool decl_p = DECL_P (inner);
   tree base;
   if (decl_p)
-    base = inner;
+    {
+      if (DECL_REGISTER (inner))
+	return;
+      base = inner;
+    }
   else if (TREE_CODE (inner) == MEM_REF)
     base = TREE_OPERAND (inner, 0);
   else
-- 
2.12.2


[-- Attachment #10: 0005-Backport-r246804.patch --]
[-- Type: text/x-patch, Size: 4448 bytes --]

From 8d00e994aa23dd42bccb6a765f2e46b8d0e37207 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 10 Apr 2017 11:37:14 +0000
Subject: [PATCH 05/13] Backport r246804

gcc/ChangeLog:

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

	PR gcov-profile/80224
	* gcov.c (print_usage): Fix usage string.
	(get_gcov_intermediate_filename): Remove.
	(output_gcov_file): Use both for normal and intermediate format.
	(generate_results): Do not initialize special file for
	intermediate format.
---
 gcc/gcov.c | 63 +++++++-------------------------------------------------------
 1 file changed, 7 insertions(+), 56 deletions(-)

diff --git a/gcc/gcov.c b/gcc/gcov.c
index 50061c7d56e..e60392210bf 100644
--- a/gcc/gcov.c
+++ b/gcc/gcov.c
@@ -469,7 +469,7 @@ print_usage (int error_p)
   FILE *file = error_p ? stderr : stdout;
   int status = error_p ? FATAL_EXIT_CODE : SUCCESS_EXIT_CODE;
 
-  fnotice (file, "Usage: gcov [OPTION]... SOURCE|OBJ...\n\n");
+  fnotice (file, "Usage: gcov [OPTION...] SOURCE|OBJ...\n\n");
   fnotice (file, "Print code coverage information.\n\n");
   fnotice (file, "  -h, --help                      Print this help, then exit\n");
   fnotice (file, "  -a, --all-blocks                Show information for every basic block\n");
@@ -602,31 +602,6 @@ process_args (int argc, char **argv)
   return optind;
 }
 
-/* Get the name of the gcov file.  The return value must be free'd.
-
-   It appends the '.gcov' extension to the *basename* of the file.
-   The resulting file name will be in PWD.
-
-   e.g.,
-   input: foo.da,       output: foo.da.gcov
-   input: a/b/foo.cc,   output: foo.cc.gcov  */
-
-static char *
-get_gcov_intermediate_filename (const char *file_name)
-{
-  const char *gcov = ".gcov";
-  char *result;
-  const char *cptr;
-
-  /* Find the 'basename'.  */
-  cptr = lbasename (file_name);
-
-  result = XNEWVEC (char, strlen (cptr) + strlen (gcov) + 1);
-  sprintf (result, "%s%s", cptr, gcov);
-
-  return result;
-}
-
 /* Output the result in intermediate format used by 'lcov'.
 
 The intermediate format contains a single file named 'foo.cc.gcov',
@@ -792,7 +767,11 @@ output_gcov_file (const char *file_name, source_t *src)
       if (gcov_file)
         {
           fnotice (stdout, "Creating '%s'\n", gcov_file_name);
-          output_lines (gcov_file, src);
+
+	  if (flag_intermediate_format)
+	    output_intermediate_file (gcov_file, src);
+	  else
+	    output_lines (gcov_file, src);
           if (ferror (gcov_file))
             fnotice (stderr, "Error writing output file '%s'\n", gcov_file_name);
           fclose (gcov_file);
@@ -814,8 +793,6 @@ generate_results (const char *file_name)
   unsigned ix;
   source_t *src;
   function_t *fn;
-  FILE *gcov_intermediate_file = NULL;
-  char *gcov_intermediate_filename = NULL;
 
   for (ix = n_sources, src = sources; ix--; src++)
     if (src->num_lines)
@@ -845,20 +822,6 @@ generate_results (const char *file_name)
 	file_name = canonicalize_name (file_name);
     }
 
-  if (flag_gcov_file && flag_intermediate_format)
-    {
-      /* Open the intermediate file.  */
-      gcov_intermediate_filename =
-        get_gcov_intermediate_filename (file_name);
-      gcov_intermediate_file = fopen (gcov_intermediate_filename, "w");
-      if (!gcov_intermediate_file)
-        {
-          fnotice (stderr, "Cannot open intermediate output file %s\n",
-                   gcov_intermediate_filename);
-          return;
-        }
-    }
-
   for (ix = n_sources, src = sources; ix--; src++)
     {
       if (flag_relative_only)
@@ -881,23 +844,11 @@ generate_results (const char *file_name)
       total_executed += src->coverage.lines_executed;
       if (flag_gcov_file)
 	{
-          if (flag_intermediate_format)
-            /* Output the intermediate format without requiring source
-               files.  This outputs a section to a *single* file.  */
-            output_intermediate_file (gcov_intermediate_file, src);
-          else
-            output_gcov_file (file_name, src);
+	  output_gcov_file (file_name, src);
           fnotice (stdout, "\n");
         }
     }
 
-  if (flag_gcov_file && flag_intermediate_format)
-    {
-      /* Now we've finished writing the intermediate file.  */
-      fclose (gcov_intermediate_file);
-      XDELETEVEC (gcov_intermediate_filename);
-    }
-
   if (!file_name)
     executed_summary (total_lines, total_executed);
 }
-- 
2.12.2


[-- Attachment #11: 0004-Backport-r246799.patch --]
[-- Type: text/x-patch, Size: 1889 bytes --]

From e3a3281394241caa845213a86cced31d45cb0e12 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Mon, 10 Apr 2017 07:29:29 +0000
Subject: [PATCH 04/13] Backport r246799

gcc/c-family/ChangeLog:

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

	PR sanitizer/80350
	* c-ubsan.c (ubsan_instrument_shift): Evaluate RHS before
	doing an UBSAN check.

gcc/testsuite/ChangeLog:

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

	PR sanitizer/80350
	* c-c++-common/ubsan/pr80350.c: New test.
---
 gcc/c-family/c-ubsan.c                     |  1 +
 gcc/testsuite/c-c++-common/ubsan/pr80350.c | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)
 create mode 100644 gcc/testsuite/c-c++-common/ubsan/pr80350.c

diff --git a/gcc/c-family/c-ubsan.c b/gcc/c-family/c-ubsan.c
index 4022bdf7963..406c48d01cf 100644
--- a/gcc/c-family/c-ubsan.c
+++ b/gcc/c-family/c-ubsan.c
@@ -169,6 +169,7 @@ ubsan_instrument_shift (location_t loc, enum tree_code code,
   /* In case we have a SAVE_EXPR in a conditional context, we need to
      make sure it gets evaluated before the condition.  */
   t = fold_build2 (COMPOUND_EXPR, TREE_TYPE (t), unshare_expr (op0), t);
+  t = fold_build2 (COMPOUND_EXPR, TREE_TYPE (t), unshare_expr (op1), t);
   t = fold_build2 (TRUTH_OR_EXPR, boolean_type_node, t,
 		   tt ? tt : integer_zero_node);
 
diff --git a/gcc/testsuite/c-c++-common/ubsan/pr80350.c b/gcc/testsuite/c-c++-common/ubsan/pr80350.c
new file mode 100644
index 00000000000..317d2facaf7
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/ubsan/pr80350.c
@@ -0,0 +1,17 @@
+/* PR target/80310 */
+/* { dg-do run } */
+/* { dg-options "-O0 -fsanitize=shift -fno-sanitize-recover=shift" } */
+
+unsigned int x = 1;
+unsigned int y = 0;
+
+void foo() {
+  y = 1 >> (!x * 1111);
+}
+
+int main () {
+    foo ();
+    if (y != 1)
+      __builtin_abort ();
+    return 0;
+}
-- 
2.12.2


[-- Attachment #12: 0003-Backport-r246730.patch --]
[-- Type: text/x-patch, Size: 2184 bytes --]

From 985578dd39c7a8ee71747065a7aec95117d3d2c5 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Thu, 6 Apr 2017 13:42:24 +0000
Subject: [PATCH 03/13] Backport r246730

gcc/testsuite/ChangeLog:

2017-04-06  Martin Liska  <mliska@suse.cz>

	PR sanitizer/80166
	* gcc.dg/asan/pr80166.c: New test.

libsanitizer/ChangeLog:

2017-04-06  Martin Liska  <mliska@suse.cz>

	PR sanitizer/80166
	* sanitizer_common/sanitizer_common_interceptors.inc (INTERCEPTOR):
	Cherry-pick upstream r299036.
---
 gcc/testsuite/gcc.dg/asan/pr80166.c                | 24 ++++++++++++++++++++++
 .../sanitizer_common_interceptors.inc              |  3 ++-
 2 files changed, 26 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/asan/pr80166.c

diff --git a/gcc/testsuite/gcc.dg/asan/pr80166.c b/gcc/testsuite/gcc.dg/asan/pr80166.c
new file mode 100644
index 00000000000..629dd23a31c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asan/pr80166.c
@@ -0,0 +1,24 @@
+/* PR sanitizer/80166 */
+/* { dg-do run } */
+
+#include <sys/types.h>
+#include <unistd.h>
+
+int
+main (int argc, char **argv)
+{
+  gid_t groups;
+  int r = getgroups (0, &groups);
+  if (r < 0)
+    __builtin_abort ();
+
+  r = getgroups (-1, &groups);
+  if (r != -1)
+    __builtin_abort ();
+
+  r = getgroups (-1, NULL);
+  if (r != -1)
+    __builtin_abort ();
+
+  return 0;
+}
diff --git a/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc b/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc
index 8223778cac4..4aab652f536 100644
--- a/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc
@@ -3053,7 +3053,8 @@ INTERCEPTOR(int, getgroups, int size, u32 *lst) {
   // its metadata. See
   // https://code.google.com/p/address-sanitizer/issues/detail?id=321.
   int res = REAL(getgroups)(size, lst);
-  if (res && lst) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, lst, res * sizeof(*lst));
+  if (res >= 0 && lst && size > 0)
+    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, lst, res * sizeof(*lst));
   return res;
 }
 #define INIT_GETGROUPS COMMON_INTERCEPT_FUNCTION(getgroups);
-- 
2.12.2


[-- Attachment #13: 0002-Backport-r246530.patch --]
[-- Type: text/x-patch, Size: 4772 bytes --]

From 8281730193638f513b4a9fe23ecfe6efde72c1ac Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 28 Mar 2017 11:37:22 +0000
Subject: [PATCH 02/13] Backport r246530

gcc/ChangeLog:

2017-03-28  Richard Biener  <rguenther@suse.de>

	PR ipa/80205
	* tree-inline.c (copy_phis_for_bb): Do not create PHI node
	without arguments, generate default definition of a SSA name.

gcc/testsuite/ChangeLog:

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

	PR ipa/80205
	* g++.dg/ipa/pr80205.C: New test.
---
 gcc/testsuite/g++.dg/ipa/pr80205.C | 34 +++++++++++++++
 gcc/tree-inline.c                  | 88 ++++++++++++++++++++------------------
 2 files changed, 81 insertions(+), 41 deletions(-)
 create mode 100644 gcc/testsuite/g++.dg/ipa/pr80205.C

diff --git a/gcc/testsuite/g++.dg/ipa/pr80205.C b/gcc/testsuite/g++.dg/ipa/pr80205.C
new file mode 100644
index 00000000000..460bdcb02ca
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr80205.C
@@ -0,0 +1,34 @@
+// PR ipa/80205
+// { dg-options "-fnon-call-exceptions --param early-inlining-insns=100 -O2" }
+
+class a
+{
+public:
+  virtual ~a ();
+};
+class b
+{
+public:
+  template <typename c> b (c);
+  ~b () { delete d; }
+  void
+  operator= (b e)
+  {
+    b (e).f (*this);
+  }
+  void
+  f (b &e)
+  {
+    a g;
+    d = e.d;
+    e.d = &g;
+  }
+  a *d;
+};
+void
+h ()
+{
+  b i = int();
+  void j ();
+  i = j;
+}
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index ffc14d6c103..508711a3947 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -2336,50 +2336,56 @@ copy_phis_for_bb (basic_block bb, copy_body_data *id)
 	{
 	  walk_tree (&new_res, copy_tree_body_r, id, NULL);
 	  new_phi = create_phi_node (new_res, new_bb);
-	  FOR_EACH_EDGE (new_edge, ei, new_bb->preds)
+	  if (EDGE_COUNT (new_bb->preds) == 0)
 	    {
-	      edge old_edge = find_edge ((basic_block) new_edge->src->aux, bb);
-	      tree arg;
-	      tree new_arg;
-	      edge_iterator ei2;
-	      location_t locus;
-
-	      /* When doing partial cloning, we allow PHIs on the entry block
-		 as long as all the arguments are the same.  Find any input
-		 edge to see argument to copy.  */
-	      if (!old_edge)
-		FOR_EACH_EDGE (old_edge, ei2, bb->preds)
-		  if (!old_edge->src->aux)
-		    break;
+	      /* Technically we'd want a SSA_DEFAULT_DEF here... */
+	      SSA_NAME_DEF_STMT (new_res) = gimple_build_nop ();
+	    }
+	  else
+	    FOR_EACH_EDGE (new_edge, ei, new_bb->preds)
+	      {
+		edge old_edge = find_edge ((basic_block) new_edge->src->aux, bb);
+		tree arg;
+		tree new_arg;
+		edge_iterator ei2;
+		location_t locus;
+
+		/* When doing partial cloning, we allow PHIs on the entry block
+		   as long as all the arguments are the same.  Find any input
+		   edge to see argument to copy.  */
+		if (!old_edge)
+		  FOR_EACH_EDGE (old_edge, ei2, bb->preds)
+		    if (!old_edge->src->aux)
+		      break;
 
-	      arg = PHI_ARG_DEF_FROM_EDGE (phi, old_edge);
-	      new_arg = arg;
-	      walk_tree (&new_arg, copy_tree_body_r, id, NULL);
-	      gcc_assert (new_arg);
-	      /* With return slot optimization we can end up with
-	         non-gimple (foo *)&this->m, fix that here.  */
-	      if (TREE_CODE (new_arg) != SSA_NAME
-		  && TREE_CODE (new_arg) != FUNCTION_DECL
-		  && !is_gimple_val (new_arg))
-		{
-		  gimple_seq stmts = NULL;
-		  new_arg = force_gimple_operand (new_arg, &stmts, true, NULL);
-		  gsi_insert_seq_on_edge (new_edge, stmts);
-		  inserted = true;
-		}
-	      locus = gimple_phi_arg_location_from_edge (phi, old_edge);
-	      if (LOCATION_BLOCK (locus))
-		{
-		  tree *n;
-		  n = id->decl_map->get (LOCATION_BLOCK (locus));
-		  gcc_assert (n);
-		  locus = set_block (locus, *n);
-		}
-	      else
-		locus = LOCATION_LOCUS (locus);
+		arg = PHI_ARG_DEF_FROM_EDGE (phi, old_edge);
+		new_arg = arg;
+		walk_tree (&new_arg, copy_tree_body_r, id, NULL);
+		gcc_assert (new_arg);
+		/* With return slot optimization we can end up with
+		   non-gimple (foo *)&this->m, fix that here.  */
+		if (TREE_CODE (new_arg) != SSA_NAME
+		    && TREE_CODE (new_arg) != FUNCTION_DECL
+		    && !is_gimple_val (new_arg))
+		  {
+		    gimple_seq stmts = NULL;
+		    new_arg = force_gimple_operand (new_arg, &stmts, true, NULL);
+		    gsi_insert_seq_on_edge (new_edge, stmts);
+		    inserted = true;
+		  }
+		locus = gimple_phi_arg_location_from_edge (phi, old_edge);
+		if (LOCATION_BLOCK (locus))
+		  {
+		    tree *n;
+		    n = id->decl_map->get (LOCATION_BLOCK (locus));
+		    gcc_assert (n);
+		    locus = set_block (locus, *n);
+		  }
+		else
+		  locus = LOCATION_LOCUS (locus);
 
-	      add_phi_arg (new_phi, new_arg, new_edge, locus);
-	    }
+		add_phi_arg (new_phi, new_arg, new_edge, locus);
+	      }
 	}
     }
 
-- 
2.12.2


[-- Attachment #14: 0001-Backport-r246525.patch --]
[-- Type: text/x-patch, Size: 1661 bytes --]

From 9a12839d57f2246fa274463d5af99b1b9ee96559 Mon Sep 17 00:00:00 2001
From: marxin <marxin@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Tue, 28 Mar 2017 09:01:57 +0000
Subject: [PATCH 01/13] Backport r246525

gcc/ChangeLog:

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

	PR ipa/80104
	* cgraphunit.c (cgraph_node::expand_thunk): Mark argument of a
	thunk call as DECL_GIMPLE_REG_P when vector or complex type.

gcc/testsuite/ChangeLog:

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

	PR ipa/80104
	* gcc.dg/ipa/pr80104.c: New test.
---
 gcc/cgraphunit.c                   |  4 ++++
 gcc/testsuite/gcc.dg/ipa/pr80104.c | 15 +++++++++++++++
 2 files changed, 19 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/ipa/pr80104.c

diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 71e88be753a..2fe207b7f4e 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -1764,6 +1764,10 @@ cgraph_node::expand_thunk (bool output_asm_thunks, bool force_gimple_thunk)
 	for (; i < nargs; i++, arg = DECL_CHAIN (arg))
 	  {
 	    tree tmp = arg;
+	    if (VECTOR_TYPE_P (TREE_TYPE (arg))
+		|| TREE_CODE (TREE_TYPE (arg)) == COMPLEX_TYPE)
+	      DECL_GIMPLE_REG_P (arg) = 1;
+
 	    if (!is_gimple_val (arg))
 	      {
 		tmp = create_tmp_reg (TYPE_MAIN_VARIANT
diff --git a/gcc/testsuite/gcc.dg/ipa/pr80104.c b/gcc/testsuite/gcc.dg/ipa/pr80104.c
new file mode 100644
index 00000000000..7e75c9907e7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr80104.c
@@ -0,0 +1,15 @@
+/* PR ipa/80104 */
+/* { dg-do compile } */
+/* { dg-options "-fipa-icf" } */
+
+float
+a (_Complex float b)
+{
+  return *&b;
+}
+
+float
+c (_Complex float b)
+{
+  return (&b)[0];
+}
-- 
2.12.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Backport to GCC6
  2017-03-22 10:15 Martin Liška
@ 2017-03-22 10:28 ` Richard Biener
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2017-03-22 10:28 UTC (permalink / raw)
  To: Martin Liška; +Cc: GCC Patches

On Wed, Mar 22, 2017 at 11:15 AM, Martin Liška <mliska@suse.cz> wrote:
> 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?

Works for me (if they are all regressions you don't even have to ask).

Richard.

> Thanks,
> Martin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Backport to GCC6
@ 2017-03-22 10:15 Martin Liška
  2017-03-22 10:28 ` Richard Biener
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Liška @ 2017-03-22 10:15 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 368 bytes --]

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

[-- Attachment #2: 0001-Backport-r237353.patch --]
[-- Type: text/x-patch, Size: 1730 bytes --]

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


[-- Attachment #3: 0002-Backport-r245532.patch --]
[-- Type: text/x-patch, Size: 901 bytes --]

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


[-- Attachment #4: 0003-Backport-r245531.patch --]
[-- Type: text/x-patch, Size: 1847 bytes --]

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


[-- Attachment #5: 0004-Backport-r245868.patch --]
[-- Type: text/x-patch, Size: 5662 bytes --]

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


[-- Attachment #6: 0005-Backport-r245869.patch --]
[-- Type: text/x-patch, Size: 3354 bytes --]

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


[-- Attachment #7: 0006-Backport-r245870.patch --]
[-- Type: text/x-patch, Size: 1346 bytes --]

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


[-- Attachment #8: 0007-Backport-r245992.patch --]
[-- Type: text/x-patch, Size: 870 bytes --]

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


[-- Attachment #9: 0008-Backport-r245993.patch --]
[-- Type: text/x-patch, Size: 1942 bytes --]

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


[-- Attachment #10: 0009-Backport-r245997.patch --]
[-- Type: text/x-patch, Size: 2760 bytes --]

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


[-- Attachment #11: 0010-Backport-r245998.patch --]
[-- Type: text/x-patch, Size: 1971 bytes --]

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


[-- Attachment #12: 0011-Backport-r246027.patch --]
[-- Type: text/x-patch, Size: 3887 bytes --]

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


[-- Attachment #13: 0012-Backport-r246098.patch --]
[-- Type: text/x-patch, Size: 1966 bytes --]

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


[-- Attachment #14: 0013-Backport-r246120.patch --]
[-- Type: text/x-patch, Size: 1044 bytes --]

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


[-- Attachment #15: 0014-Backport-r246129.patch --]
[-- Type: text/x-patch, Size: 1639 bytes --]

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


[-- Attachment #16: 0015-Backport-r246275.patch --]
[-- Type: text/x-patch, Size: 2306 bytes --]

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


[-- Attachment #17: 0016-Backport-r246276.patch --]
[-- Type: text/x-patch, Size: 2893 bytes --]

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


[-- Attachment #18: 0017-Backport-r246316.patch --]
[-- Type: text/x-patch, Size: 1057 bytes --]

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


[-- Attachment #19: 0018-Backport-r246321.patch --]
[-- Type: text/x-patch, Size: 6832 bytes --]

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


[-- Attachment #20: 0019-Backport-r246345.patch --]
[-- Type: text/x-patch, Size: 1449 bytes --]

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-04-25 11:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-25 11:49 Backport to GCC6 Martin Liška
  -- strict thread matches above, loose matches on Subject: below --
2017-03-22 10:15 Martin Liška
2017-03-22 10:28 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).