diff options
author | Geoff Berry <gberry@codeaurora.org> | 2016-04-22 14:44:10 +0000 |
---|---|---|
committer | Geoff Berry <gberry@codeaurora.org> | 2016-04-22 14:44:10 +0000 |
commit | 9fe26e6dc90ce203f3be0a8ee0abf400668bde13 (patch) | |
tree | a79577f018ce77eefc4a32f47852d9eaea2e0fe7 /llvm/lib/Transforms/Utils | |
parent | ee34680bb0fcf23818c2baa0a62c9e4aa3011adb (diff) | |
download | bcm5719-llvm-9fe26e6dc90ce203f3be0a8ee0abf400668bde13.tar.gz bcm5719-llvm-9fe26e6dc90ce203f3be0a8ee0abf400668bde13.zip |
[MemorySSA] Fix bug in CachingMemorySSAWalker::invalidateInfo
Summary:
CachingMemorySSAWalker::invalidateInfo was using IsCall to determine
which cache map needed to be cleared of entries referring to the invalidated
MemoryAccess, but there could also be entries referring to it in the
other cache map (value entries, not key entries). This change just
clears both tables to be conservatively correct.
Also add a verifyRemoved() function, called when expensive
checks (i.e. XDEBUG) are enabled to verify that the invalidated
MemoryAccess object is not referenced in any of the caches.
Reviewers: dberlin, george.burgess.iv
Subscribers: mcrosier, llvm-commits
Differential Revision: http://reviews.llvm.org/D19388
llvm-svn: 267157
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r-- | llvm/lib/Transforms/Utils/MemorySSA.cpp | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Utils/MemorySSA.cpp b/llvm/lib/Transforms/Utils/MemorySSA.cpp index e873c9e4c04..90c23e1e144 100644 --- a/llvm/lib/Transforms/Utils/MemorySSA.cpp +++ b/llvm/lib/Transforms/Utils/MemorySSA.cpp @@ -799,19 +799,16 @@ void CachingMemorySSAWalker::invalidateInfo(MemoryAccess *MA) { if (!Q.IsCall) Q.StartingLoc = MemoryLocation::get(I); doCacheRemove(MA, Q, Q.StartingLoc); - return; - } - // If it is not a use, the best we can do right now is destroy the cache. - bool IsCall = false; - - if (auto *MUD = dyn_cast<MemoryUseOrDef>(MA)) { - Instruction *I = MUD->getMemoryInst(); - IsCall = bool(ImmutableCallSite(I)); - } - if (IsCall) + } else { + // If it is not a use, the best we can do right now is destroy the cache. CachedUpwardsClobberingCall.clear(); - else CachedUpwardsClobberingAccess.clear(); + } + +#ifdef XDEBUG + // Run this only when expensive checks are enabled. + verifyRemoved(MA); +#endif } void CachingMemorySSAWalker::doCacheRemove(const MemoryAccess *M, @@ -1081,6 +1078,18 @@ CachingMemorySSAWalker::getClobberingMemoryAccess(const Instruction *I) { return Result; } +// Verify that MA doesn't exist in any of the caches. +void CachingMemorySSAWalker::verifyRemoved(MemoryAccess *MA) { +#ifndef NDEBUG + for (auto &P : CachedUpwardsClobberingAccess) + assert(P.first.first != MA && P.second != MA && + "Found removed MemoryAccess in cache."); + for (auto &P : CachedUpwardsClobberingCall) + assert(P.first != MA && P.second != MA && + "Found removed MemoryAccess in cache."); +#endif // !NDEBUG +} + MemoryAccess * DoNothingMemorySSAWalker::getClobberingMemoryAccess(const Instruction *I) { MemoryAccess *MA = MSSA->getMemoryAccess(I); |