diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2016-12-27 10:30:45 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2016-12-27 10:30:45 +0000 |
commit | aa35167578cef55f2bdb78c14a662fffdf31bc51 (patch) | |
tree | 0efb0ce70a61dc0d129fbe9ae8989790b6b4b70a /llvm/lib/Analysis/BasicAliasAnalysis.cpp | |
parent | 687d4024b59cd0cb39c278ad9d1b239c3afa8599 (diff) | |
download | bcm5719-llvm-aa35167578cef55f2bdb78c14a662fffdf31bc51.tar.gz bcm5719-llvm-aa35167578cef55f2bdb78c14a662fffdf31bc51.zip |
[PM] Teach BasicAA how to invalidate its result object.
This requires custom handling because BasicAA caches handles to other
analyses and so it needs to trigger indirect invalidation.
This fixes one of the common crashes when using the new PM in real
pipelines. I've also tweaked a regression test to check that we are at
least handling the most immediate case.
I'm going to work at re-structuring this test some to both scale better
(rather than all being in one file) and check more invalidation paths in
a follow-up commit, but I wanted to get the basic bug fix in place.
llvm-svn: 290603
Diffstat (limited to 'llvm/lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/BasicAliasAnalysis.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp index 14d9abfbdac..406f2744e56 100644 --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -63,6 +63,24 @@ const unsigned MaxNumPhiBBsValueReachabilityCheck = 20; // depth otherwise the algorithm in aliasGEP will assert. static const unsigned MaxLookupSearchDepth = 6; +bool BasicAAResult::invalidate(Function &F, const PreservedAnalyses &PA, + FunctionAnalysisManager::Invalidator &Inv) { + if (PA.areAllPreserved()) + return false; // Nothing to do, everything is still valid. + + // We don't care if this analysis itself is preserved, it has no state. But + // we need to check that the analyses it depends on have been. Note that we + // may be created without handles to some analyses and in that case don't + // depend on them. + if (Inv.invalidate<AssumptionAnalysis>(F, PA) || + (DT && Inv.invalidate<DominatorTreeAnalysis>(F, PA)) || + (LI && Inv.invalidate<LoopAnalysis>(F, PA))) + return true; + + // Otherwise this analysis result remains valid. + return false; +} + //===----------------------------------------------------------------------===// // Useful predicates //===----------------------------------------------------------------------===// |