From bceeb22905627a53c9fdcb7f3096154e6dc40f2b Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Fri, 22 Nov 2013 23:38:07 +0000 Subject: [PM] Switch the downward invalidation to be incremental where only the one function's analyses are invalidated at a time. Also switch the preservation of the proxy to *fully* preserve the lower (function) analyses. Combined, this gets both upward and downward analysis invalidation to a point I'm happy with: - A function pass invalidates its function analyses, and its parent's module analyses. - A module pass invalidates all of its functions' analyses including the set of which functions are in the module. - A function pass can preserve a module analysis pass. - If all function passes preserve a module analysis pass, that preservation persists. If any doesn't the module analysis is invalidated. - A module pass can opt into managing *all* function analysis invalidation itself or *none*. - The conservative default is none, and the proxy takes the maximally conservative approach that works even if the set of functions has changed. - If a module pass opts into managing function analysis invalidation it has to propagate the invalidation itself, the proxy just does nothing. The only thing really missing is a way to query for a cached analysis or nothing at all. With this, function passes can more safely request a cached module analysis pass without fear of it accidentally running part way through. llvm-svn: 195519 --- llvm/lib/IR/PassManager.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'llvm/lib/IR/PassManager.cpp') diff --git a/llvm/lib/IR/PassManager.cpp b/llvm/lib/IR/PassManager.cpp index fe16adcaeb3..76210a31ed7 100644 --- a/llvm/lib/IR/PassManager.cpp +++ b/llvm/lib/IR/PassManager.cpp @@ -147,18 +147,12 @@ FunctionAnalysisManagerModuleProxy::Result::~Result() { bool FunctionAnalysisManagerModuleProxy::Result::invalidate( Module *M, const PreservedAnalyses &PA) { - // If this proxy isn't marked as preserved, then it is has an invalid set of - // Function objects in the cache making it impossible to incrementally - // preserve them. Just clear the entire manager. - if (!PA.preserved(ID())) { + // If this proxy isn't marked as preserved, then we can't even invalidate + // individual function analyses, there may be an invalid set of Function + // objects in the cache making it impossible to incrementally preserve them. + // Just clear the entire manager. + if (!PA.preserved(ID())) FAM.clear(); - return false; - } - - // The set of functions was preserved some how, so just directly invalidate - // any analysis results not preserved. - for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) - FAM.invalidate(I, PA); // Return false to indicate that this result is still a valid proxy. return false; -- cgit v1.2.3