[0/8] middle-end: Ensure at_stmt is defined before an early exit

Message ID Y25QhrM0bMcTmpAn@e124511.cambridge.arm.com
State Repeat Merge
Headers

Checks

Context Check Description
snail/gcc-patch-check warning Git am fail log

Commit Message

Andrew Carlotti Nov. 11, 2022, 1:39 p.m. UTC
  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.


--
  

Comments

Jeff Law Nov. 14, 2022, 2:23 p.m. UTC | #1
On 11/11/22 06:39, Andrew Carlotti via Gcc-patches wrote:
> 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.

OK

jeff
  

Patch

diff --git a/gcc/tree-ssa-loop-niter.cc b/gcc/tree-ssa-loop-niter.cc
index 4ffcef4f4ff2fe182fbe711553c8e4575560ab07..cdbb924216243ebcabe6c695698a4aee71882c49 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));
 }