[llvm] a5d6851 - LoopReroll::isLoopControlIV - use cast<> instead of dyn_cast<> to avoid dereference of nullptr
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 11 02:19:51 PST 2022
Author: Simon Pilgrim
Date: 2022-02-11T10:19:25Z
New Revision: a5d6851489c7a4bfa3422a2fb3de40b9ea958833
URL: https://github.com/llvm/llvm-project/commit/a5d6851489c7a4bfa3422a2fb3de40b9ea958833
DIFF: https://github.com/llvm/llvm-project/commit/a5d6851489c7a4bfa3422a2fb3de40b9ea958833.diff
LOG: LoopReroll::isLoopControlIV - use cast<> instead of dyn_cast<> to avoid dereference of nullptr
The pointer is always dereferenced by isCompareUsedByBranch, so assert the cast is correct instead of returning nullptr
Added:
Modified:
llvm/lib/Transforms/Scalar/LoopRerollPass.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/LoopRerollPass.cpp b/llvm/lib/Transforms/Scalar/LoopRerollPass.cpp
index 9d22eceb987f6..0fc3b94d9f6a4 100644
--- a/llvm/lib/Transforms/Scalar/LoopRerollPass.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopRerollPass.cpp
@@ -559,12 +559,12 @@ bool LoopReroll::isLoopControlIV(Loop *L, Instruction *IV) {
}
// Must be a CMP or an ext (of a value with nsw) then CMP
else {
- Instruction *UUser = dyn_cast<Instruction>(UU);
+ auto *UUser = cast<Instruction>(UU);
// Skip SExt if we are extending an nsw value
// TODO: Allow ZExt too
- if (BO->hasNoSignedWrap() && UUser && UUser->hasOneUse() &&
+ if (BO->hasNoSignedWrap() && UUser->hasOneUse() &&
isa<SExtInst>(UUser))
- UUser = dyn_cast<Instruction>(*(UUser->user_begin()));
+ UUser = cast<Instruction>(*(UUser->user_begin()));
if (!isCompareUsedByBranch(UUser))
return false;
}
More information about the llvm-commits
mailing list