From ba48a2c5e856fd4221a0551d3b480a1b7fccac02 Mon Sep 17 00:00:00 2001 From: Alina Sbirlea Date: Tue, 30 Apr 2019 22:15:47 +0000 Subject: [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 llvm-svn: 359622 --- llvm/lib/Analysis/AliasAnalysis.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'llvm/lib/Analysis/AliasAnalysis.cpp') diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp index 06a33f659c1..32241e355eb 100644 --- a/llvm/lib/Analysis/AliasAnalysis.cpp +++ b/llvm/lib/Analysis/AliasAnalysis.cpp @@ -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(); - if (!PAC.preserved() && !PAC.preservedSet>()) - 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; -- cgit v1.2.3