]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport PRs 89135, 89296, 89392, 89572, 89710
authorRichard Biener <rguenther@suse.de>
Mon, 2 Sep 2019 14:14:14 +0000 (14:14 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 2 Sep 2019 14:14:14 +0000 (14:14 +0000)
2019-09-02  Richard Biener  <rguenther@suse.de>

Backport from mainline
2019-03-14  Richard Biener  <rguenther@suse.de>

PR tree-optimization/89710
* tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Use
safe_dyn_cast.

* gcc.dg/torture/pr89710.c: New testcase.

2019-03-14  Richard Biener  <rguenther@suse.de>

PR middle-end/89572
* tree-scalar-evolution.c (get_loop_exit_condition): Use
safe_dyn_cast.
* tree-ssa-loop-ivcanon.c (canonicalize_loop_induction_variables):
Use gimple_location_safe.

* gcc.dg/torture/pr89572.c: New testcase.

2019-02-18  Richard Biener  <rguenther@suse.de>

PR tree-optimization/89296
* tree-ssa-loop-ch.c (ch_base::copy_headers): Restrict setting
of no-warning flag to cases that might emit the bogus warning.

* gcc.dg/uninit-pr89296.c: New testcase.

2019-02-21  Richard Biener  <rguenther@suse.de>

PR middle-end/89392
cp/
* vtable-class-hierarchy.c (vtv_generate_init_routine): Do not
make symtab process new functions here.

2019-01-31  Richard Biener  <rguenther@suse.de>

PR tree-optimization/89135
* tree-ssa-phiprop.c (pass_phiprop::execute): Skip blocks
with abnormal preds.

* gcc.dg/torture/pr89135.c: New testcase.

From-SVN: r275319

12 files changed:
gcc/ChangeLog
gcc/cp/ChangeLog
gcc/cp/vtable-class-hierarchy.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr89135.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr89572.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr89710.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/uninit-pr89296.c [new file with mode: 0644]
gcc/tree-scalar-evolution.c
gcc/tree-ssa-loop-ch.c
gcc/tree-ssa-loop-ivcanon.c
gcc/tree-ssa-phiprop.c

index 71eb7d18785055a31fba53d88832594d19fc9173..df0d7b2e46be44f4d2a420289c95db91597d9b7d 100644 (file)
@@ -1,3 +1,32 @@
+2019-09-02  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2019-03-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89710
+       * tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Use
+       safe_dyn_cast.
+
+       2019-03-14  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/89572
+       * tree-scalar-evolution.c (get_loop_exit_condition): Use
+       safe_dyn_cast.
+       * tree-ssa-loop-ivcanon.c (canonicalize_loop_induction_variables):
+       Use gimple_location_safe.
+
+       2019-02-18  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89296
+       * tree-ssa-loop-ch.c (ch_base::copy_headers): Restrict setting
+       of no-warning flag to cases that might emit the bogus warning.
+
+       2019-01-31  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89135
+       * tree-ssa-phiprop.c (pass_phiprop::execute): Skip blocks
+       with abnormal preds.
+
 2019-09-02  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
index 4f55803a5dc39c4f2656651cadea0af41e15cf5b..e84b9a2ff7440b874d93592f35f6d2099cff4cc7 100644 (file)
@@ -1,3 +1,12 @@
+2019-09-02  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2019-02-21  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/89392
+       * vtable-class-hierarchy.c (vtv_generate_init_routine): Do not
+       make symtab process new functions here.
+
 2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
index 1162b8ced3fee8f6e067b59af8697d2f13fb6767..80753c6e2fd009d647184e668368a6de2b155ab3 100644 (file)
@@ -1191,8 +1191,6 @@ vtv_generate_init_routine (void)
       gimplify_function_tree (vtv_fndecl);
       cgraph_node::add_new_function (vtv_fndecl, false);
 
-      symtab->process_new_functions ();
-
       if (flag_vtable_verify == VTV_PREINIT_PRIORITY && !TARGET_PECOFF)
         assemble_vtv_preinit_initializer (vtv_fndecl);
 
index 656cf79c7322450822eb5b49be025092687e65d9..dda7adc4e6cade3671fd317f992c4f3e4f0b2bc4 100644 (file)
@@ -1,3 +1,26 @@
+2019-09-02  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2019-03-14  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89710
+       * gcc.dg/torture/pr89710.c: New testcase.
+
+       2019-03-14  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/89572
+       * gcc.dg/torture/pr89572.c: New testcase.
+
+       2019-02-18  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89296
+       * gcc.dg/uninit-pr89296.c: New testcase.
+
+       2019-01-31  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/89135
+       * gcc.dg/torture/pr89135.c: New testcase.
+
 2019-09-02  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
diff --git a/gcc/testsuite/gcc.dg/torture/pr89135.c b/gcc/testsuite/gcc.dg/torture/pr89135.c
new file mode 100644 (file)
index 0000000..278303f
--- /dev/null
@@ -0,0 +1,35 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target indirect_jumps } */
+/* { dg-require-effective-target label_values } */
+
+typedef __INTPTR_TYPE__ intptr_t;
+intptr_t a, b, c, d;
+int foo (void) { return 0; }
+int baz (void);
+
+void
+bar (void)
+{
+  intptr_t g = (intptr_t) &&h;
+  void *i = &&j, *k = &&l;
+j:
+  if (baz ())
+    {
+      intptr_t **n = (intptr_t **) &a;
+l:
+      b = 0;
+      for (; b >= 0;)
+       goto *k;
+h:
+      **n = 0;
+      for (;;)
+       {
+         intptr_t *o = &c;
+         g = foo ();
+         *o = g;
+         if (c)
+           goto *d;
+       }
+    }
+  goto *i;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr89572.c b/gcc/testsuite/gcc.dg/torture/pr89572.c
new file mode 100644 (file)
index 0000000..1c29385
--- /dev/null
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-finline-functions" } */
+
+int vh, it, k1;
+
+void
+vn (void)
+{
+  ++vh;
+  if (vh == 0 && it == 0)
+    k1 = -k1;
+}
+
+__attribute__ ((returns_twice)) void
+ef (int *uw)
+{
+  while (uw != (void *) 0)
+    {
+      vn ();
+      *uw = 0;
+    }
+}
+
+void
+gu (int *uw)
+{
+  ef (uw);
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr89710.c b/gcc/testsuite/gcc.dg/torture/pr89710.c
new file mode 100644 (file)
index 0000000..01e875e
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+
+void
+gm (int *);
+
+__attribute__ ((returns_twice)) void
+jg (void)
+{
+}
+
+void
+eb (void)
+{
+  int r6 = 0;
+
+  if (r6 != 0)
+    gm (&r6);
+}
+
+void
+gm (int *r6)
+{
+  jg ();
+
+  for (;;)
+    {
+      eb ();
+      *r6 = 0;
+    }
+}
diff --git a/gcc/testsuite/gcc.dg/uninit-pr89296.c b/gcc/testsuite/gcc.dg/uninit-pr89296.c
new file mode 100644 (file)
index 0000000..9d81b32
--- /dev/null
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wuninitialized" } */
+
+int get_a_value ();
+void printk(const char *);
+void test_func()
+{
+    int loop;
+    while (!loop) {             /* { dg-warning "is used uninitialized" } */
+       loop = get_a_value();
+       printk("...");
+    }
+}
index 95ad137b02ac3af61e0cbbf7e16c4990e79dc779..799c478a14ff7b5f12542599d13732831476e983 100644 (file)
@@ -867,7 +867,7 @@ get_loop_exit_condition (const struct loop *loop)
       gimple *stmt;
 
       stmt = last_stmt (exit_edge->src);
-      if (gcond *cond_stmt = dyn_cast <gcond *> (stmt))
+      if (gcond *cond_stmt = safe_dyn_cast <gcond *> (stmt))
        res = cond_stmt;
     }
 
index 923efa42a69d9102b812b2272f37e9512caabfd3..23e981a40858af6344892a7aff2db1b6e4ac051c 100644 (file)
@@ -99,7 +99,7 @@ should_duplicate_loop_header_p (basic_block header, struct loop *loop,
     }
 
   last = last_stmt (header);
-  if (gimple_code (last) != GIMPLE_COND)
+  if (!last || gimple_code (last) != GIMPLE_COND)
     {
       if (dump_file && (dump_flags & TDF_DETAILS))
        fprintf (dump_file,
@@ -373,11 +373,23 @@ ch_base::copy_headers (function *fun)
                {
                  gimple *stmt = gsi_stmt (bsi);
                  if (gimple_code (stmt) == GIMPLE_COND)
-                   gimple_set_no_warning (stmt, true);
+                   {
+                     tree lhs = gimple_cond_lhs (stmt);
+                     if (gimple_cond_code (stmt) != EQ_EXPR
+                         && gimple_cond_code (stmt) != NE_EXPR
+                         && INTEGRAL_TYPE_P (TREE_TYPE (lhs))
+                         && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (lhs)))
+                       gimple_set_no_warning (stmt, true);
+                   }
                  else if (is_gimple_assign (stmt))
                    {
                      enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
-                     if (TREE_CODE_CLASS (rhs_code) == tcc_comparison)
+                     tree rhs1 = gimple_assign_rhs1 (stmt);
+                     if (TREE_CODE_CLASS (rhs_code) == tcc_comparison
+                         && rhs_code != EQ_EXPR
+                         && rhs_code != NE_EXPR
+                         && INTEGRAL_TYPE_P (TREE_TYPE (rhs1))
+                         && TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (rhs1)))
                        gimple_set_no_warning (stmt, true);
                    }
                }
index 0c3b0d2a4071b0345e5bf0b4ad7b3dc88fbf0a55..aac1c3bcce882689b22847fa39174d01b4749581 100644 (file)
@@ -1131,7 +1131,7 @@ canonicalize_loop_induction_variables (struct loop *loop,
   niter = number_of_latch_executions (loop);
   exit = single_exit (loop);
   if (TREE_CODE (niter) == INTEGER_CST)
-    locus = gimple_location (last_stmt (exit->src));
+    locus = gimple_location_safe (last_stmt (exit->src));
   else
     {
       /* If the loop has more than one exit, try checking all of them
@@ -1146,7 +1146,7 @@ canonicalize_loop_induction_variables (struct loop *loop,
        niter = find_loop_niter_by_eval (loop, &exit);
 
       if (exit)
-        locus = gimple_location (last_stmt (exit->src));
+        locus = gimple_location_safe (last_stmt (exit->src));
 
       if (TREE_CODE (niter) != INTEGER_CST)
        exit = NULL;
index 97eec627d474b7e554e4699d52f9416d4ec87235..4f5f95df4f1b7ec045710a67fce3dedcf09a6cb6 100644 (file)
@@ -495,8 +495,14 @@ pass_phiprop::execute (function *fun)
   bbs = get_all_dominated_blocks (CDI_DOMINATORS,
                                  single_succ (ENTRY_BLOCK_PTR_FOR_FN (fun)));
   FOR_EACH_VEC_ELT (bbs, i, bb)
-    for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
-      did_something |= propagate_with_phi (bb, gsi.phi (), phivn, n);
+    {
+      /* Since we're going to move dereferences across predecessor
+         edges avoid blocks with abnormal predecessors.  */
+      if (bb_has_abnormal_pred (bb))
+       continue;
+      for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+       did_something |= propagate_with_phi (bb, gsi.phi (), phivn, n);
+    }
 
   if (did_something)
     gsi_commit_edge_inserts ();