aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
diff options
context:
space:
mode:
authorFlorian Hahn <flo@fhahn.com>2020-06-17 09:24:56 +0100
committerFlorian Hahn <flo@fhahn.com>2020-06-17 09:36:53 +0100
commite4b58ea8c1ec267bd17a2d56dc08faf904bd9c70 (patch)
tree07970570b2a0019ebc77445b51ae704bcf03ce8e /llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
parent8bc8d2d678a2d5724d097ee2a7d4b6e7ccce4f82 (diff)
downloadllvm-e4b58ea8c1ec267bd17a2d56dc08faf904bd9c70.tar.gz
llvm-e4b58ea8c1ec267bd17a2d56dc08faf904bd9c70.tar.bz2
llvm-e4b58ea8c1ec267bd17a2d56dc08faf904bd9c70.zip
[MemDep] Also remove load instructions from NonLocalDesCache.
Currently load instructions are added to the cache for invariant pointer group dependencies, but only pointer values are removed currently. That leads to dangling AssertingVHs in the test case below, where we delete a load from an invariant pointer group. We should also remove the entries from the cache. Fixes PR46054. Reviewers: efriedma, hfinkel, asbirlea Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D81726
Diffstat (limited to 'llvm/lib/Analysis/MemoryDependenceAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/MemoryDependenceAnalysis.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
index 142c7fe30523..566eba5c54af 100644
--- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -1518,15 +1518,25 @@ void MemoryDependenceResults::removeInstruction(Instruction *RemInst) {
LocalDeps.erase(LocalDepEntry);
}
- // If we have any cached pointer dependencies on this instruction, remove
- // them. If the instruction has non-pointer type, then it can't be a pointer
- // base.
+ // If we have any cached dependencies on this instruction, remove
+ // them.
- // Remove it from both the load info and the store info. The instruction
- // can't be in either of these maps if it is non-pointer.
+ // If the instruction is a pointer, remove it from both the load info and the
+ // store info.
if (RemInst->getType()->isPointerTy()) {
RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair(RemInst, false));
RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair(RemInst, true));
+ } else {
+ // Otherwise, if the instructions is in the map directly, it must be a load.
+ // Remove it.
+ auto toRemoveIt = NonLocalDefsCache.find(RemInst);
+ if (toRemoveIt != NonLocalDefsCache.end()) {
+ assert(isa<LoadInst>(RemInst) &&
+ "only load instructions should be added directly");
+ const Instruction *DepV = toRemoveIt->second.getResult().getInst();
+ ReverseNonLocalDefsCache.find(DepV)->second.erase(RemInst);
+ NonLocalDefsCache.erase(toRemoveIt);
+ }
}
// Loop over all of the things that depend on the instruction we're removing.