Backport PRs 89135, 89296, 89392, 89572, 89710

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
This commit is contained in:
Richard Biener 2019-09-02 14:14:14 +00:00 committed by Richard Biener
parent 19bb99ceaa
commit 77406e353b
12 changed files with 193 additions and 10 deletions

View 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

View 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

View 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);

View 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

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -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("...");
}
}

View 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;
}

View 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);
}
}

View 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;

View 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 ();