From: Aldy Hernandez Date: Wed, 22 Sep 2021 07:30:21 +0000 (+0200) Subject: Check for BB before calling register_outgoing_edges. X-Git-Tag: upstream/12.2.0~4907 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fec75ab8c02be904de2963c0adb6d1e940a59761;p=platform%2Fupstream%2Fgcc.git Check for BB before calling register_outgoing_edges. 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. --- diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index d7fa0f2..1da1bef 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 (s)) + // Check for an existing BB, as we maybe asked to fold an + // artificial statement not in the CFG. + else if (is_a (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.