From: Richard Biener Date: Mon, 2 Sep 2019 14:14:14 +0000 (+0000) Subject: Backport PRs 89135, 89296, 89392, 89572, 89710 X-Git-Tag: releases/gcc-7.5.0~182 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=77406e353b945084642f52fe756b5e4df1eb6746;p=thirdparty%2Fgcc.git Backport PRs 89135, 89296, 89392, 89572, 89710 2019-09-02 Richard Biener Backport from mainline 2019-03-14 Richard Biener 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 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 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 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 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 71eb7d187850..df0d7b2e46be 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,32 @@ +2019-09-02 Richard Biener + + Backport from mainline + 2019-03-14 Richard Biener + + PR tree-optimization/89710 + * tree-ssa-loop-ch.c (should_duplicate_loop_header_p): Use + safe_dyn_cast. + + 2019-03-14 Richard Biener + + 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 + + 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 + + PR tree-optimization/89135 + * tree-ssa-phiprop.c (pass_phiprop::execute): Skip blocks + with abnormal preds. + 2019-09-02 Richard Biener Backport from mainline diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 4f55803a5dc3..e84b9a2ff744 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,12 @@ +2019-09-02 Richard Biener + + Backport from mainline + 2019-02-21 Richard Biener + + 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 Backported from mainline diff --git a/gcc/cp/vtable-class-hierarchy.c b/gcc/cp/vtable-class-hierarchy.c index 1162b8ced3fe..80753c6e2fd0 100644 --- a/gcc/cp/vtable-class-hierarchy.c +++ b/gcc/cp/vtable-class-hierarchy.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 656cf79c7322..dda7adc4e6ca 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,26 @@ +2019-09-02 Richard Biener + + Backport from mainline + 2019-03-14 Richard Biener + + PR tree-optimization/89710 + * gcc.dg/torture/pr89710.c: New testcase. + + 2019-03-14 Richard Biener + + PR middle-end/89572 + * gcc.dg/torture/pr89572.c: New testcase. + + 2019-02-18 Richard Biener + + PR tree-optimization/89296 + * gcc.dg/uninit-pr89296.c: New testcase. + + 2019-01-31 Richard Biener + + PR tree-optimization/89135 + * gcc.dg/torture/pr89135.c: New testcase. + 2019-09-02 Richard Biener 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 index 000000000000..278303f98a6a --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr89135.c @@ -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 index 000000000000..1c293850c110 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr89572.c @@ -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 index 000000000000..01e875e10428 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr89710.c @@ -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 index 000000000000..9d81b32b9792 --- /dev/null +++ b/gcc/testsuite/gcc.dg/uninit-pr89296.c @@ -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("..."); + } +} diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index 95ad137b02ac..799c478a14ff 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -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 (stmt)) + if (gcond *cond_stmt = safe_dyn_cast (stmt)) res = cond_stmt; } diff --git a/gcc/tree-ssa-loop-ch.c b/gcc/tree-ssa-loop-ch.c index 923efa42a69d..23e981a40858 100644 --- a/gcc/tree-ssa-loop-ch.c +++ b/gcc/tree-ssa-loop-ch.c @@ -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); } } diff --git a/gcc/tree-ssa-loop-ivcanon.c b/gcc/tree-ssa-loop-ivcanon.c index 0c3b0d2a4071..aac1c3bcce88 100644 --- a/gcc/tree-ssa-loop-ivcanon.c +++ b/gcc/tree-ssa-loop-ivcanon.c @@ -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; diff --git a/gcc/tree-ssa-phiprop.c b/gcc/tree-ssa-phiprop.c index 97eec627d474..4f5f95df4f1b 100644 --- a/gcc/tree-ssa-phiprop.c +++ b/gcc/tree-ssa-phiprop.c @@ -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 ();