Check for BB before calling register_outgoing_edges.
authorAldy Hernandez <aldyh@redhat.com>
Wed, 22 Sep 2021 07:30:21 +0000 (09:30 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Wed, 22 Sep 2021 11:28:16 +0000 (13:28 +0200)
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

index d7fa0f2..1da1bef 100644 (file)
@@ -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.