[AliasAnalysis/NewPassManager] Invalidate AAManager less often.

Summary:
This is a redo of D60914.

The objective is to not invalidate AAManager, which is stateless, unless
there is an explicit invalidate in one of the AAResults.

To achieve this, this patch adds an API to PAC, to check precisely this:
is this analysis not invalidated explicitly == is this analysis not abandoned == is this analysis stateless, so preserved without explicitly being marked as preserved by everyone

Reviewers: chandlerc

Subscribers: mehdi_amini, jlebar, george.burgess.iv, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D61284

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@359622 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Alina Sbirlea
2019-04-30 22:15:47 +00:00
parent 0b378026ac
commit ddcc2ba101
6 changed files with 23 additions and 11 deletions
+8 -4
View File
@@ -79,12 +79,16 @@ AAResults::~AAResults() {
bool AAResults::invalidate(Function &F, const PreservedAnalyses &PA,
FunctionAnalysisManager::Invalidator &Inv) {
// Check if the AA manager itself has been invalidated.
// AAResults preserves the AAManager by default, due to the stateless nature
// of AliasAnalysis. There is no need to check whether it has been preserved
// explicitly. Check if any module dependency was invalidated and caused the
// AAManager to be invalidated. Invalidate ourselves in that case.
auto PAC = PA.getChecker<AAManager>();
if (!PAC.preserved() && !PAC.preservedSet<AllAnalysesOn<Function>>())
return true; // The manager needs to be blown away, clear everything.
if (!PAC.preservedWhenStateless())
return true;
// Check all of the dependencies registered.
// Check if any of the function dependencies were invalidated, and invalidate
// ourselves in that case.
for (AnalysisKey *ID : AADeps)
if (Inv.invalidate(ID, F, PA))
return true;