[PM] Teach MemDep to invalidate its result object when its cached

analysis handles become invalid.

Add a test case for its invalidation logic.

llvm-svn: 290620
This commit is contained in:
Chandler Carruth
2016-12-27 19:33:04 +00:00
parent c9ed514632
commit e14524ca30
3 changed files with 98 additions and 0 deletions

View File

@@ -1683,6 +1683,24 @@ void MemoryDependenceWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
AU.addRequiredTransitive<TargetLibraryInfoWrapperPass>();
}
bool MemoryDependenceResults::invalidate(Function &F, const PreservedAnalyses &PA,
FunctionAnalysisManager::Invalidator &Inv) {
// Check whether our analysis is preserved.
auto PAC = PA.getChecker<MemoryDependenceAnalysis>();
if (!PAC.preserved() && !PAC.preservedSet<AllAnalysesOn<Function>>())
// If not, give up now.
return true;
// Check whether the analyses we depend on became invalid for any reason.
if (Inv.invalidate<AAManager>(F, PA) ||
Inv.invalidate<AssumptionAnalysis>(F, PA) ||
Inv.invalidate<DominatorTreeAnalysis>(F, PA))
return true;
// Otherwise this analysis result remains valid.
return false;
}
unsigned MemoryDependenceResults::getDefaultBlockScanLimit() const {
return BlockScanLimit;
}