]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Allow queries on exit block.
authorAndrew MacLeod <amacleod@redhat.com>
Mon, 31 Oct 2022 14:56:25 +0000 (10:56 -0400)
committerAndrew MacLeod <amacleod@redhat.com>
Tue, 1 Nov 2022 13:05:20 +0000 (09:05 -0400)
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.

gcc/gimple-range-cache.cc
gcc/gimple-range.cc

index f279371948a54a19e126a7aacc13c06ead3136cb..89e2403acce3823b14f990990830b3fc43bf3977 100644 (file)
@@ -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);
index 058439733ee05bb23a0268039f418331a3992d5c..110cf57445477e0c5c426bd233825418546f018f 100644 (file)
@@ -167,7 +167,6 @@ void
 gimple_ranger::range_on_exit (vrange &r, basic_block bb, tree name)
 {
   // on-exit from the exit block?
-  gcc_checking_assert (bb != EXIT_BLOCK_PTR_FOR_FN (cfun));
   gcc_checking_assert (gimple_range_ssa_p (name));
 
   unsigned idx;