[llvm] 8a0cd23 - Revert "[MemDep][NFCI] Remove redundant dyn_cast, replace with cast"
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 7 13:21:39 PDT 2022
Author: Philip Reames
Date: 2022-06-07T13:21:31-07:00
New Revision: 8a0cd23326050a7b999efa2cf455880772ce9211
URL: https://github.com/llvm/llvm-project/commit/8a0cd23326050a7b999efa2cf455880772ce9211
DIFF: https://github.com/llvm/llvm-project/commit/8a0cd23326050a7b999efa2cf455880772ce9211.diff
LOG: Revert "[MemDep][NFCI] Remove redundant dyn_cast, replace with cast"
This reverts commit 180d3f251d1ad5473705d3f00e6d426b5f8162e6. This commit is simply wrong. IsLoad is set within the same file based on modref state, not whether the instruction is a LoadInst.
This went uncaught because cast<Ty>(X) has been broken. See https://discourse.llvm.org/t/cast-x-is-broken-implications-and-proposal-to-address/63033 for context.
Added:
Modified:
llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
index a3a9f437a93a..78383d5c1af1 100644
--- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -402,8 +402,8 @@ MemDepResult MemoryDependenceResults::getSimplePointerDependencyFrom(
// forwarding, but any mayalias write can be assumed to be noalias.
// Arguably, this logic should be pushed inside AliasAnalysis itself.
if (isLoad && QueryInst) {
- LoadInst *LI = cast<LoadInst>(QueryInst);
- if (LI->hasMetadata(LLVMContext::MD_invariant_load))
+ LoadInst *LI = dyn_cast<LoadInst>(QueryInst);
+ if (LI && LI->hasMetadata(LLVMContext::MD_invariant_load))
isInvariantLoad = true;
}
More information about the llvm-commits
mailing list