[llvm] b11eaf5 - [DSE] Don't dereference a dyn_cast<> result - use cast<> instead. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 8 05:08:02 PST 2020
Author: Simon Pilgrim
Date: 2020-11-08T13:07:45Z
New Revision: b11eaf561714969cc119bd7cdaf72bd8c5f56158
URL: https://github.com/llvm/llvm-project/commit/b11eaf561714969cc119bd7cdaf72bd8c5f56158
DIFF: https://github.com/llvm/llvm-project/commit/b11eaf561714969cc119bd7cdaf72bd8c5f56158.diff
LOG: [DSE] Don't dereference a dyn_cast<> result - use cast<> instead. NFCI.
We were relying on the dyn_cast<> succeeding - better use cast<> and have it assert that its the correct type than dereference a null result.
Added:
Modified:
llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 5ec732cff5c3..bc561ae0065c 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -2569,7 +2569,7 @@ bool eliminateDeadStoresMemorySSA(Function &F, AliasAnalysis &AA,
}
continue;
}
- MemoryDef *NextDef = dyn_cast<MemoryDef>(EarlierAccess);
+ auto *NextDef = cast<MemoryDef>(EarlierAccess);
Instruction *NI = NextDef->getMemoryInst();
LLVM_DEBUG(dbgs() << " (" << *NI << ")\n");
ToCheck.insert(NextDef->getDefiningAccess());
More information about the llvm-commits
mailing list