[llvm] r331508 - [IRCE] Fix misuse of dyn_cast which leads to UB
Max Kazantsev via llvm-commits
llvm-commits at lists.llvm.org
Fri May 4 00:34:36 PDT 2018
Author: mkazantsev
Date: Fri May 4 00:34:35 2018
New Revision: 331508
URL: http://llvm.org/viewvc/llvm-project?rev=331508&view=rev
Log:
[IRCE] Fix misuse of dyn_cast which leads to UB
Modified:
llvm/trunk/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp?rev=331508&r1=331507&r2=331508&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp Fri May 4 00:34:35 2018
@@ -925,11 +925,12 @@ LoopStructure::parseLoopStructure(Scalar
return None;
}
const SCEV* StepRec = IndVarBase->getStepRecurrence(SE);
- ConstantInt *StepCI = dyn_cast<SCEVConstant>(StepRec)->getValue();
- if (!StepCI) {
+ if (!isa<SCEVConstant>(StepRec)) {
FailureReason = "LHS in icmp not induction variable";
return None;
}
+ ConstantInt *StepCI = cast<SCEVConstant>(StepRec)->getValue();
+
if (ICI->isEquality() && !HasNoSignedWrap(IndVarBase)) {
FailureReason = "LHS in icmp needs nsw for equality predicates";
return None;
More information about the llvm-commits
mailing list