[llvm] 2537120 - Follow-up to D105207, only salvage affine SCEVs to avoid a crash

Jeremy Morse via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 29 03:48:48 PDT 2021


Author: Jeremy Morse
Date: 2021-07-29T11:48:08+01:00
New Revision: 2537120c870c04893636f171f553024f378c2de8

URL: https://github.com/llvm/llvm-project/commit/2537120c870c04893636f171f553024f378c2de8
DIFF: https://github.com/llvm/llvm-project/commit/2537120c870c04893636f171f553024f378c2de8.diff

LOG: Follow-up to D105207, only salvage affine SCEVs to avoid a crash

SCEVToIterCountExpr only expects to be fed affine expressions, but
DbgRewriteSalvageableDVIs is feeding it non-affine induction variables.
Following this up with an obvious fix, will add test coverage too if
this avoids D105207 being reverted.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index b591c8244628..2da102d736c7 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -6162,6 +6162,9 @@ DbgRewriteSalvageableDVIs(llvm::Loop *L, ScalarEvolution &SE,
   bool Changed = false;
   if (const SCEVAddRecExpr *IVAddRec =
           dyn_cast<SCEVAddRecExpr>(SCEVInductionVar)) {
+    if (!IVAddRec->isAffine())
+      return false;
+
     SCEVDbgValueBuilder IterCountExpr;
     IterCountExpr.pushValue(LSRInductionVar);
     if (!IterCountExpr.SCEVToIterCountExpr(*IVAddRec, SE))


        


More information about the llvm-commits mailing list