]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR rtl-optimization/85167 (shrink-wrap.c:333:15: runtime error with...
authorJakub Jelinek <jakub@redhat.com>
Mon, 25 Jun 2018 17:43:41 +0000 (19:43 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 25 Jun 2018 17:43:41 +0000 (19:43 +0200)
Backported from mainline
2018-04-03  Jakub Jelinek  <jakub@redhat.com>

PR rtl-optimization/85167
* shrink-wrap.c (move_insn_for_shrink_wrap): Don't set bb_uses and
bb_defs if *split_p, instead preinitialize it to NULL.

* gcc.dg/pr85167.c: New test.

From-SVN: r262091

gcc/ChangeLog
gcc/shrink-wrap.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr85167.c [new file with mode: 0644]

index 0227db7dafd8c9ed66713a7d61e5510c44b0ddd0..63e840b5ddf7bf20d58cfb8aab6a6aa3db2ea8e2 100644 (file)
@@ -1,6 +1,12 @@
 2018-06-25  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-04-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR rtl-optimization/85167
+       * shrink-wrap.c (move_insn_for_shrink_wrap): Don't set bb_uses and
+       bb_defs if *split_p, instead preinitialize it to NULL.
+
        2018-03-23  Jakub Jelinek  <jakub@redhat.com>
 
        PR inline-asm/85022
index fe795196709810920b20a4ac2610687e8693149f..8d321b6bfe32b24003690eeddde6f004674da139 100644 (file)
@@ -154,7 +154,7 @@ move_insn_for_shrink_wrap (basic_block bb, rtx_insn *insn,
                           struct dead_debug_local *debug)
 {
   rtx set, src, dest;
-  bitmap live_out, live_in, bb_uses, bb_defs;
+  bitmap live_out, live_in, bb_uses = NULL, bb_defs = NULL;
   unsigned int i, dregno, end_dregno;
   unsigned int sregno = FIRST_PSEUDO_REGISTER;
   unsigned int end_sregno = FIRST_PSEUDO_REGISTER;
@@ -327,8 +327,11 @@ move_insn_for_shrink_wrap (basic_block bb, rtx_insn *insn,
       /* Check whether BB uses DEST or clobbers DEST.  We need to add
         INSN to BB if so.  Either way, DEST is no longer live on entry,
         except for any part that overlaps SRC (next loop).  */
-      bb_uses = &DF_LR_BB_INFO (bb)->use;
-      bb_defs = &DF_LR_BB_INFO (bb)->def;
+      if (!*split_p)
+       {
+         bb_uses = &DF_LR_BB_INFO (bb)->use;
+         bb_defs = &DF_LR_BB_INFO (bb)->def;
+       }
       if (df_live)
        {
          for (i = dregno; i < end_dregno; i++)
index 4d9de83dbcca246c68327e52192fcd55f51085c1..556fb5781b96060483fd1c07e8657443f0689d67 100644 (file)
@@ -3,6 +3,9 @@
        Backported from mainline
        2018-04-03  Jakub Jelinek  <jakub@redhat.com>
 
+       PR rtl-optimization/85167
+       * gcc.dg/pr85167.c: New test.
+
        PR c++/85147
        * g++.dg/cpp0x/pr85147.C: New test.
 
diff --git a/gcc/testsuite/gcc.dg/pr85167.c b/gcc/testsuite/gcc.dg/pr85167.c
new file mode 100644 (file)
index 0000000..e4277e3
--- /dev/null
@@ -0,0 +1,16 @@
+/* PR rtl-optimization/85167 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -w" } */
+
+struct A { long b; };
+int c, d, e;
+int bar (void);
+
+int
+foo (void)
+{
+  long g;
+  for (; g == c ? 0 : (e = 1); g = ((struct A *)g)->b)
+    if (bar ())
+      return d;
+}