Ranger cache dominator queries should ignore backedges.
When querying dominators for cache values, ignore back edges in read-only mode. PR tree-optimization/109238 gcc/ * gimple-range-cache.cc (ranger_cache::resolve_dom): Ignore predecessors which this block dominates. gcc/testsuite/ * gcc.dg/pr109238.c: New.
This commit is contained in:
parent
ed626f18b1
commit
0409aa5a2d
2 changed files with 21 additions and 0 deletions
|
@ -1404,6 +1404,11 @@ ranger_cache::resolve_dom (vrange &r, tree name, basic_block bb)
|
|||
Value_Range er (TREE_TYPE (name));
|
||||
FOR_EACH_EDGE (e, ei, bb->preds)
|
||||
{
|
||||
// If the predecessor is dominated by this block, then there is a back
|
||||
// edge, and won't provide anything useful. We'll actually end up with
|
||||
// VARYING as we will not resolve this node.
|
||||
if (dominated_by_p (CDI_DOMINATORS, e->src, bb))
|
||||
continue;
|
||||
edge_range (er, e, name, RFD_READ_ONLY);
|
||||
r.union_ (er);
|
||||
}
|
||||
|
|
16
gcc/testsuite/gcc.dg/pr109238.c
Normal file
16
gcc/testsuite/gcc.dg/pr109238.c
Normal file
|
@ -0,0 +1,16 @@
|
|||
/* PR tree-optimization/109238 */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O2 -Wall" } */
|
||||
|
||||
void foo (void *) __attribute__((noreturn));
|
||||
void bar (void *);
|
||||
|
||||
void
|
||||
baz (void *p)
|
||||
{
|
||||
void *c = __builtin_realloc (p, 16);
|
||||
if (c)
|
||||
foo (c);
|
||||
for (;;)
|
||||
bar (__builtin_realloc (p, 8)); /* { dg-bogus "pointer 'p' may be used after '__builtin_realloc'" } */
|
||||
}
|
Loading…
Add table
Reference in a new issue