[llvm] 6638303 - [LoopFlatten] checkOverflow - use cast<> instead of dyn_cast<> to avoid dereference of nullptr.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 6 06:13:58 PST 2022
Author: Simon Pilgrim
Date: 2022-01-06T14:13:50Z
New Revision: 66383038699d302fd82841d8d68f662f46e8f94b
URL: https://github.com/llvm/llvm-project/commit/66383038699d302fd82841d8d68f662f46e8f94b
DIFF: https://github.com/llvm/llvm-project/commit/66383038699d302fd82841d8d68f662f46e8f94b.diff
LOG: [LoopFlatten] checkOverflow - use cast<> instead of dyn_cast<> to avoid dereference of nullptr.
Fix static analysis warning by using cast<> instead of dyn_cast<> as both isa<> and isGuaranteedToExecuteForEveryIteration expect a non-null Instruction pointer.
Added:
Modified:
llvm/lib/Transforms/Scalar/LoopFlatten.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/LoopFlatten.cpp b/llvm/lib/Transforms/Scalar/LoopFlatten.cpp
index 965d1575518e..303456b16919 100644
--- a/llvm/lib/Transforms/Scalar/LoopFlatten.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopFlatten.cpp
@@ -535,7 +535,7 @@ static OverflowResult checkOverflow(FlattenInfo &FI, DominatorTree *DT,
for (Value *U : V->users()) {
if (auto *GEP = dyn_cast<GetElementPtrInst>(U)) {
for (Value *GEPUser : U->users()) {
- Instruction *GEPUserInst = dyn_cast<Instruction>(GEPUser);
+ auto *GEPUserInst = cast<Instruction>(GEPUser);
if (!isa<LoadInst>(GEPUserInst) &&
!(isa<StoreInst>(GEPUserInst) &&
GEP == GEPUserInst->getOperand(1)))
More information about the llvm-commits
mailing list