From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7890) id 72D293851882; Mon, 21 Nov 2022 16:01:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 72D293851882 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669046480; bh=TMx2wxadpT7oxDvFG3Ouzc9mkkhlWJZ54hzk1U4h0bU=; h=From:To:Subject:Date:From; b=Cbd6i3utVz6jOC5GH741Wvof+ElycGk3p+u6+PuLaEEkJbkPSPf1xVixaUK0P7wuT QQJOrc9JIjKbo24s6zq+j5M8Rp86gz+54yeXUgQizEg/jYTC/1MhoZNFRKjJXCQTv2 2LszkxZbxJLH+/0O4Sm6JdCbwSgO1lPfIp8qZTXU= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Andrew Carlotti To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4206] Ensure at_stmt is defined before an early exit X-Act-Checkin: gcc X-Git-Author: Andrew Carlotti X-Git-Refname: refs/heads/master X-Git-Oldrev: 9df85f331fa78ddfdbbe3b0fd5ff3727d2f57333 X-Git-Newrev: f0e4f676aab589e53dbd67610378a1769030f462 Message-Id: <20221121160120.72D293851882@sourceware.org> Date: Mon, 21 Nov 2022 16:01:20 +0000 (GMT) List-Id: https://gcc.gnu.org/g:f0e4f676aab589e53dbd67610378a1769030f462 commit r13-4206-gf0e4f676aab589e53dbd67610378a1769030f462 Author: Andrew Carlotti Date: Thu Oct 6 15:59:15 2022 +0100 Ensure at_stmt is defined before an early exit This prevents a null dereference error when outputing debug information following an early exit from number_of_iterations_exit_assumptions. gcc/ChangeLog: * tree-ssa-loop-niter.cc (number_of_iterations_exit_assumptions): Move at_stmt assignment. Diff: --- gcc/tree-ssa-loop-niter.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gcc/tree-ssa-loop-niter.cc b/gcc/tree-ssa-loop-niter.cc index 3fbbf4367ed..df995a66676 100644 --- a/gcc/tree-ssa-loop-niter.cc +++ b/gcc/tree-ssa-loop-niter.cc @@ -2537,6 +2537,9 @@ number_of_iterations_exit_assumptions (class loop *loop, edge exit, if (!stmt) return false; + if (at_stmt) + *at_stmt = stmt; + /* We want the condition for staying inside loop. */ code = gimple_cond_code (stmt); if (exit->flags & EDGE_TRUE_VALUE) @@ -2642,9 +2645,6 @@ number_of_iterations_exit_assumptions (class loop *loop, edge exit, if (TREE_CODE (niter->niter) == INTEGER_CST) niter->max = wi::to_widest (niter->niter); - if (at_stmt) - *at_stmt = stmt; - return (!integer_zerop (niter->assumptions)); }