aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-range-cache.cc
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2022-10-31 10:56:25 -0400
committerAndrew MacLeod <amacleod@redhat.com>2022-11-01 09:05:20 -0400
commit592bbe3d7eb3cff656c731e84ad872719a4a9d16 (patch)
treec6ee75816835ec69939ee948ac8edd9fbba2ba72 /gcc/gimple-range-cache.cc
parent7cc2824e39440dd71a9d2832c51ef260bb36d8ca (diff)
downloadgcc-592bbe3d7eb3cff656c731e84ad872719a4a9d16.zip
gcc-592bbe3d7eb3cff656c731e84ad872719a4a9d16.tar.gz
gcc-592bbe3d7eb3cff656c731e84ad872719a4a9d16.tar.bz2
Allow queries on exit block.
Ranger was not allowing the exit block to be queried for range_on_entry or exit. This removes that restriction. * gimple-range-cache.cc (ranger_cache::fill_block_cache): Allow exit block to be specified. (ranger_cache::range_from_dom): If exit block is specified, use the immediate predecessor instead of the dominator to start. * gimple-range.cc (gimple_ranger::range_on_exit): Allow query for exit block.
Diffstat (limited to 'gcc/gimple-range-cache.cc')
-rw-r--r--gcc/gimple-range-cache.cc16
1 files changed, 10 insertions, 6 deletions
diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index f279371..89e2403 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -1193,9 +1193,8 @@ ranger_cache::fill_block_cache (tree name, basic_block bb, basic_block def_bb)
Value_Range block_result (type);
Value_Range undefined (type);
- // At this point we shouldn't be looking at the def, entry or exit block.
- gcc_checking_assert (bb != def_bb && bb != ENTRY_BLOCK_PTR_FOR_FN (cfun) &&
- bb != EXIT_BLOCK_PTR_FOR_FN (cfun));
+ // At this point we shouldn't be looking at the def, entry block.
+ gcc_checking_assert (bb != def_bb && bb != ENTRY_BLOCK_PTR_FOR_FN (cfun));
gcc_checking_assert (m_workback.length () == 0);
// If the block cache is set, then we've already visited this block.
@@ -1434,10 +1433,15 @@ ranger_cache::range_from_dom (vrange &r, tree name, basic_block start_bb,
// Default value is global range.
get_global_range (r, name);
+ // The dominator of EXIT_BLOCK doesn't seem to be set, so at least handle
+ // the common single exit cases.
+ if (start_bb == EXIT_BLOCK_PTR_FOR_FN (cfun) && single_pred_p (start_bb))
+ bb = single_pred_edge (start_bb)->src;
+ else
+ bb = get_immediate_dominator (CDI_DOMINATORS, start_bb);
+
// Search until a value is found, pushing blocks which may need calculating.
- for (bb = get_immediate_dominator (CDI_DOMINATORS, start_bb);
- bb;
- prev_bb = bb, bb = get_immediate_dominator (CDI_DOMINATORS, bb))
+ for ( ; bb; prev_bb = bb, bb = get_immediate_dominator (CDI_DOMINATORS, bb))
{
// Accumulate any block exit inferred ranges.
m_exit.maybe_adjust_range (infer, name, bb);