From fec75ab8c02be904de2963c0adb6d1e940a59761 Mon Sep 17 00:00:00 2001 From: Aldy Hernandez Date: Wed, 22 Sep 2021 09:30:21 +0200 Subject: [PATCH] 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. --- gcc/gimple-range-fold.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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. -- 2.7.4