re PR middle-end/81897 (spurious -Wmaybe-uninitialized warning)
authorAldy Hernandez <aldyh@redhat.com>
Wed, 10 Jan 2018 21:39:20 +0000 (21:39 +0000)
committerAldy Hernandez <aldyh@gcc.gnu.org>
Wed, 10 Jan 2018 21:39:20 +0000 (21:39 +0000)
PR middle-end/81897
* tree-ssa-uninit.c (convert_control_dep_chain_into_preds): Skip
empty blocks.

From-SVN: r256456

gcc/ChangeLog
gcc/testsuite/gcc.dg/uninit-pr81897-2.c [new file with mode: 0644]
gcc/tree-ssa-uninit.c

index 413f24cf860ab3bc2fbc8041eaaaecee03be139e..ba1a84475174fefa8b15cacba7a5e13ba6358450 100644 (file)
@@ -1,3 +1,9 @@
+2018-01-10  Aldy Hernandez  <aldyh@redhat.com>
+
+       PR middle-end/81897
+       * tree-ssa-uninit.c (convert_control_dep_chain_into_preds): Skip
+       empty blocks.
+
 2018-01-10  Eric Botcazou  <ebotcazou@adacore.com>
 
        * dwarf2out.c (dwarf2out_var_location): Do not pass NULL to fprintf.
diff --git a/gcc/testsuite/gcc.dg/uninit-pr81897-2.c b/gcc/testsuite/gcc.dg/uninit-pr81897-2.c
new file mode 100644 (file)
index 0000000..3960af4
--- /dev/null
@@ -0,0 +1,35 @@
+/* { dg-do compile }  */
+/* { dg-options "-O1 -fno-tree-ccp -Wmaybe-uninitialized" } */
+
+int oo;
+
+void
+pc (int *tt)
+{
+  int cf = 0;
+
+  if (*tt != 0)
+    {
+      if (0)
+        {
+          int *qg;
+          int uj = 0;
+
+ t6:
+          tt = &cf;
+          if (oo != 0)
+            {
+              ++uj; /* { dg-warning "may be used uninit" } */
+              *qg = !!oo && !!uj; /* { dg-warning "may be used uninit" } */
+            }
+        }
+      cf = 0;
+      goto t6;
+    }
+
+  if (oo != 0)
+    {
+      *tt = 1;
+      goto t6;
+    }
+}
index 382394762865f14b8834dcafa9fd8c801448a006..8ccbc85970a412552571a1ba65f15bd12cb00036 100644 (file)
@@ -669,9 +669,16 @@ convert_control_dep_chain_into_preds (vec<edge> *dep_chains,
          e = one_cd_chain[j];
          guard_bb = e->src;
          gsi = gsi_last_bb (guard_bb);
-         /* Ignore empty BBs as they're basically forwarder blocks.  */
+         /* Ignore empty forwarder blocks.  */
          if (empty_block_p (guard_bb) && single_succ_p (guard_bb))
            continue;
+         /* An empty basic block here is likely a PHI, and is not one
+            of the cases we handle below.  */
+         if (gsi_end_p (gsi))
+           {
+             has_valid_pred = false;
+             break;
+           }
          cond_stmt = gsi_stmt (gsi);
          if (is_gimple_call (cond_stmt) && EDGE_COUNT (e->src->succs) >= 2)
            /* Ignore EH edge.  Can add assertion on the other edge's flag.  */