[COMMITTED] Check for BB before calling register_outgoing_edges.

Message ID 20210922113207.482939-2-aldyh@redhat.com
State Committed
Commit fec75ab8c02be904de2963c0adb6d1e940a59761
Headers
Series [COMMITTED] Check for BB before calling register_outgoing_edges. |

Commit Message

Aldy Hernandez Sept. 22, 2021, 11:32 a.m. UTC
  We may be asked to fold an artificial statement not in the CFG.  Since
there are no outgoing edges from those, avoid calling
register_outgoing_edges.

Tested on x86-64 Linux.

gcc/ChangeLog:

	* gimple-range-fold.cc (fold_using_range::range_of_range_op):
	Move check for non-empty BB here.
	(fur_source::register_outgoing_edges): ...from here.
---
 gcc/gimple-range-fold.cc | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
  

Patch

diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc
index d7fa0f2c86e..1da1befa9a2 100644
--- a/gcc/gimple-range-fold.cc
+++ b/gcc/gimple-range-fold.cc
@@ -650,7 +650,9 @@  fold_using_range::range_of_range_op (irange &r, gimple *s, fur_source &src)
 		    src.register_relation (s, rel, lhs, op2);
 		}
 	    }
-	  else if (is_a<gcond *> (s))
+	  // Check for an existing BB, as we maybe asked to fold an
+	  // artificial statement not in the CFG.
+	  else if (is_a<gcond *> (s) && gimple_bb (s))
 	    {
 	      basic_block bb = gimple_bb (s);
 	      edge e0 = EDGE_SUCC (bb, 0);
@@ -1404,10 +1406,6 @@  fur_source::register_outgoing_edges (gcond *s, irange &lhs_range, edge e0, edge
   range_operator *handler;
   basic_block bb = gimple_bb (s);
 
-  // We may get asked to fold an artificial statement not in the CFG.
-  if (!bb)
-    return;
-
   if (e0)
     {
       // If this edge is never taken, ignore it.