diff options
author | Dan Gohman <gohman@apple.com> | 2010-11-10 21:45:11 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-11-10 21:45:11 +0000 |
commit | 2e8ca44b81a610596168b23086fdbc4acb0e1647 (patch) | |
tree | 5d00c99f2ea0db93e007b33664d1797148546858 /llvm/lib/Analysis/MemoryDependenceAnalysis.cpp | |
parent | ca52411955c18b63e7281062460758b090a014c9 (diff) | |
download | llvm-2e8ca44b81a610596168b23086fdbc4acb0e1647.zip llvm-2e8ca44b81a610596168b23086fdbc4acb0e1647.tar.gz llvm-2e8ca44b81a610596168b23086fdbc4acb0e1647.tar.bz2 |
Fully invalidate cached results when a prior query's size or
type is insufficient for, or incompatible with, the current query.
llvm-svn: 118721
Diffstat (limited to 'llvm/lib/Analysis/MemoryDependenceAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/MemoryDependenceAnalysis.cpp | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp index b4c6d09..97c679a 100644 --- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/llvm/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); } } |