aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/MemoryDependenceAnalysis.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-11-10 21:45:11 +0000
committerDan Gohman <gohman@apple.com>2010-11-10 21:45:11 +0000
commit733c54da1e5432d9d64f88ea960121fa7a16076a (patch)
treee893f4490bbfadecde0a9dc6a7652625116cf563 /lib/Analysis/MemoryDependenceAnalysis.cpp
parentbf5be2654ee396710e28d83d2afebd6f22720c52 (diff)
Fully invalidate cached results when a prior query's size or
type is insufficient for, or incompatible with, the current query. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118721 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/MemoryDependenceAnalysis.cpp')
-rw-r--r--lib/Analysis/MemoryDependenceAnalysis.cpp33
1 files changed, 23 insertions, 10 deletions
diff --git a/lib/Analysis/MemoryDependenceAnalysis.cpp b/lib/Analysis/MemoryDependenceAnalysis.cpp
index b4c6d09e4c..97c679ae14 100644
--- a/lib/Analysis/MemoryDependenceAnalysis.cpp
+++ b/lib/Analysis/MemoryDependenceAnalysis.cpp
@@ -756,24 +756,37 @@ getNonLocalPointerDepFromBB(const PHITransAddr &Pointer,
NonLocalPointerDeps.insert(std::make_pair(CacheKey, InitialNLPI));
NonLocalPointerInfo *CacheInfo = &Pair.first->second;
+ // If we already have a cache entry for this CacheKey, we may need to do some
+ // work to reconcile the cache entry and the current query.
if (!Pair.second) {
- // If this query's Size is inconsistent with the cached one, take the
- // maximum size and restart the query.
- if (CacheInfo->Size != Loc.Size) {
- CacheInfo->Size = std::max(CacheInfo->Size, Loc.Size);
+ if (CacheInfo->Size < Loc.Size) {
+ // The query's Size is greater than the cached one. Throw out the
+ // cached data and procede with the query at the greater size.
+ CacheInfo->Pair = BBSkipFirstBlockPair();
+ CacheInfo->Size = Loc.Size;
+ CacheInfo->NonLocalDeps.clear();
+ } else if (CacheInfo->Size > Loc.Size) {
+ // This query's Size is less than the cached one. Conservatively restart
+ // the query using the greater size.
return getNonLocalPointerDepFromBB(Pointer,
Loc.getWithNewSize(CacheInfo->Size),
isLoad, StartBB, Result, Visited,
SkipFirstBlock);
}
- // If this query's TBAATag is inconsistent with the cached one, discard the
- // tag and restart the query.
+ // If the query's TBAATag is inconsistent with the cached one,
+ // conservatively throw out the cached data and restart the query with
+ // no tag if needed.
if (CacheInfo->TBAATag != Loc.TBAATag) {
- CacheInfo->TBAATag = 0;
- return getNonLocalPointerDepFromBB(Pointer, Loc.getWithoutTBAATag(),
- isLoad, StartBB, Result, Visited,
- SkipFirstBlock);
+ if (CacheInfo->TBAATag) {
+ CacheInfo->Pair = BBSkipFirstBlockPair();
+ CacheInfo->TBAATag = 0;
+ CacheInfo->NonLocalDeps.clear();
+ }
+ if (Loc.TBAATag)
+ return getNonLocalPointerDepFromBB(Pointer, Loc.getWithoutTBAATag(),
+ isLoad, StartBB, Result, Visited,
+ SkipFirstBlock);
}
}