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]

[PATCH] Fix PR rtl-optimization/61278


Hi,

The patch fixes PR rtl-optimization/61278. Root cause for issue is
that df_live does not exist at -O1.

Bootstrap and no make check regression on X86-64.

OK for trunk?

Thanks!
-Zhenqiang

ChangeLog:
2014-05-23  Zhenqiang Chen  <zhenqiang.chen@linaro.org>

        PR rtl-optimization/61278
        * shrink-wrap.c (move_insn_for_shrink_wrap): Check df_live.

testsuite/ChangeLog:
2014-05-23  Zhenqiang Chen  <zhenqiang.chen@linaro.org>

        * gcc.dg/lto/pr61278_0.c: New test.
        * gcc.dg/lto/pr61278_1.c: New test.

diff --git a/gcc/shrink-wrap.c b/gcc/shrink-wrap.c
index f09cfe7..be17829 100644
--- a/gcc/shrink-wrap.c
+++ b/gcc/shrink-wrap.c
@@ -204,8 +204,15 @@ move_insn_for_shrink_wrap (basic_block bb, rtx insn,
   /* Create a new basic block on the edge.  */
   if (EDGE_COUNT (next_block->preds) == 2)
     {
+      /* If DF_LIVE doesn't exist, i.e. at -O1, just give up.  */
+      if (!df_live)
+       return false;
+
       next_block = split_edge (live_edge);

+      /* We create a new basic block.  Call df_grow_bb_info to make sure
+        all data structures are allocated.  */
+      df_grow_bb_info (df_live);
       bitmap_copy (df_get_live_in (next_block), df_get_live_out (bb));
       df_set_bb_dirty (next_block);

diff --git a/gcc/testsuite/gcc.dg/lto/pr61278_0.c
b/gcc/testsuite/gcc.dg/lto/pr61278_0.c
new file mode 100644
index 0000000..03a24ae
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr61278_0.c
@@ -0,0 +1,30 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options { { -flto -O0 } } } */
+/* { dg-extra-ld-options " -flto -O1 " } */
+
+static unsigned int
+fn1 (int p1, int p2)
+{
+  return 0;
+}
+
+char a, b, c;
+
+char
+foo (char *p)
+{
+  int i;
+  for (b = 1 ; b > 0; b++)
+    {
+      for (i = 0; i < 2; i++)
+       ;
+      for (a = 1; a > 0; a++)
+       {
+         char d[1] = { 0 };
+         if (*p)
+           break;
+         c ^= fn1 (fn1 (fn1 (0, 0), 0), 0);
+       }
+    }
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr61278_1.c
b/gcc/testsuite/gcc.dg/lto/pr61278_1.c
new file mode 100644
index 0000000..b02c8ac
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr61278_1.c
@@ -0,0 +1,13 @@
+/* { dg-lto-do link } */
+/* { dg-lto-options { { -flto -O1 } } } */
+
+extern char foo (char *);
+
+char d;
+
+int
+main ()
+{
+  foo (&d);
+  return 0;
+}


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