From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2136) id 4F64A384B110; Fri, 3 Sep 2021 13:31:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4F64A384B110 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Aldy Hernandez To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-3329] Skip statements with no BB in ranger. X-Act-Checkin: gcc X-Git-Author: Aldy Hernandez X-Git-Refname: refs/heads/master X-Git-Oldrev: bccf4b88e184e925ee2d7931e4cf09704f1c3932 X-Git-Newrev: 5db93cd083890b29262ab93bc8e692990b781002 Message-Id: <20210903133135.4F64A384B110@sourceware.org> Date: Fri, 3 Sep 2021 13:31:35 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Sep 2021 13:31:35 -0000 https://gcc.gnu.org/g:5db93cd083890b29262ab93bc8e692990b781002 commit r12-3329-g5db93cd083890b29262ab93bc8e692990b781002 Author: Aldy Hernandez Date: Fri Sep 3 10:42:37 2021 +0200 Skip statements with no BB in ranger. The function postfold_gcond_edges() registers relations coming out of a GIMPLE_COND. With upcoming changes, we may be called with statements not in the IL (for example, dummy statements created by the forward threader). This patch avoids breakage by exiting if the statement does not have a defining basic block. There is a similar change to the path solver. Tested on x86-64 Linux. gcc/ChangeLog: * gimple-range-fold.cc (fold_using_range::postfold_gcond_edges): Skip statements with no defining BB. * gimple-range-path.cc (path_range_query::range_defined_in_block): Do not get confused by statements with no defining BB. Diff: --- gcc/gimple-range-fold.cc | 4 ++++ gcc/gimple-range-path.cc | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gcc/gimple-range-fold.cc b/gcc/gimple-range-fold.cc index 8be6d473f82..7cf8830fc5d 100644 --- a/gcc/gimple-range-fold.cc +++ b/gcc/gimple-range-fold.cc @@ -1360,6 +1360,10 @@ fold_using_range::postfold_gcond_edges (gcond *s, irange& lhs_range, 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; + edge e0 = EDGE_SUCC (bb, 0); if (!single_pred_p (e0->dest)) e0 = NULL; diff --git a/gcc/gimple-range-path.cc b/gcc/gimple-range-path.cc index a8226a6810f..77b823e7bd5 100644 --- a/gcc/gimple-range-path.cc +++ b/gcc/gimple-range-path.cc @@ -221,14 +221,19 @@ path_range_query::range_defined_in_block (irange &r, tree name, basic_block bb) else if (!fold_range (r, def_stmt, this)) r.set_varying (TREE_TYPE (name)); - if (DEBUG_SOLVER) + if (DEBUG_SOLVER && (bb || !r.varying_p ())) { - fprintf (dump_file, "range_defined_in_block (BB%d) for ", bb->index); + fprintf (dump_file, "range_defined_in_block (BB%d) for ", bb ? bb->index : -1); print_generic_expr (dump_file, name, TDF_SLIM); fprintf (dump_file, " is "); r.dump (dump_file); fprintf (dump_file, "\n"); } + + // We may have an artificial statement not in the IL. + if (!bb && r.varying_p ()) + return false; + return true; }