[PATCH] D45320: [MemDep] Fixed handling of invariant.group
Piotr Padlewski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 8 06:04:50 PDT 2018
Prazek updated this revision to Diff 141536.
Prazek added a comment.
Herald added a subscriber: hiraditya.
Removed ValueMap, use removeCachedNonLocalPointerDependency
Repository:
rL LLVM
https://reviews.llvm.org/D45320
Files:
llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h
llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
Index: llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ llvm/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -919,9 +919,7 @@
"Can't get pointer deps of a non-pointer!");
Result.clear();
{
- // Check if there is cached Def with invariant.group. FIXME: cache might be
- // invalid if cached instruction would be removed between call to
- // getPointerDependencyFrom and this function.
+ // Check if there is cached Def with invariant.group.
auto NonLocalDefIt = NonLocalDefsCache.find(QueryInst);
if (NonLocalDefIt != NonLocalDefsCache.end()) {
Result.push_back(std::move(NonLocalDefIt->second));
@@ -1459,9 +1457,23 @@
return true;
}
-/// If P exists in CachedNonLocalPointerInfo, remove it.
+/// If P exists in CachedNonLocalPointerInfo or NonLocalDefsCache, remove it.
void MemoryDependenceResults::RemoveCachedNonLocalPointerDependencies(
ValueIsLoadPair P) {
+
+ // Most of the time this cache is empty.
+ if (!NonLocalDefsCache.empty()) {
+ NonLocalDefsCache.erase(P.getPointer());
+ SmallVector<const Value *, 4> KeysToDelete;
+
+ // This cache should always be very small, thus it should be fast.
+ for (const auto &entry : NonLocalDefsCache)
+ if (entry.second.getAddress() == P.getPointer())
+ KeysToDelete.push_back(entry.first);
+ for (const auto *Key : KeysToDelete)
+ NonLocalDefsCache.erase(Key);
+ }
+
CachedNonLocalPointerInfo::iterator It = NonLocalPointerDeps.find(P);
if (It == NonLocalPointerDeps.end())
return;
Index: llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h
===================================================================
--- llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h
+++ llvm/include/llvm/Analysis/MemoryDependenceAnalysis.h
@@ -32,6 +32,7 @@
#include <cstdint>
#include <utility>
#include <vector>
+#include <llvm/IR/ValueHandle.h>
namespace llvm {
@@ -314,7 +315,7 @@
/// Cache storing single nonlocal def for the instruction.
/// It is set when nonlocal def would be found in function returning only
/// local dependencies.
- DenseMap<Instruction *, NonLocalDepResult> NonLocalDefsCache;
+ DenseMap<AssertingVH<const Value>, NonLocalDepResult> NonLocalDefsCache;
/// This map stores the cached results of doing a pointer lookup at the
/// bottom of a block.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45320.141536.patch
Type: text/x-patch
Size: 2461 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180408/060fe203/attachment.bin>
More information about the llvm-commits
mailing list