diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2013-11-21 10:53:05 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2013-11-21 10:53:05 +0000 |
commit | 2846e9ef1529debcffcb7b10a5c289f00cd35c9f (patch) | |
tree | a71896f7692509cab54403e35887775cbb484f7b /llvm/lib/IR/PassManager.cpp | |
parent | 05c091455edf41709a7eeb9b3b7cdc2a644d884a (diff) | |
download | bcm5719-llvm-2846e9ef1529debcffcb7b10a5c289f00cd35c9f.tar.gz bcm5719-llvm-2846e9ef1529debcffcb7b10a5c289f00cd35c9f.zip |
[PM] Widen the interface for invalidate on an analysis result now that
it is completely optional, and sink the logic for handling the preserved
analysis set into it.
This allows us to implement the delegation logic desired in the proxy
module analysis for the function analysis manager where if the proxy
itself is preserved we assume the set of functions hasn't changed and we
do a fine grained invalidation by walking the functions in the module
and running the invalidate for them all at the manager level and letting
it try to invalidate any passes.
This in turn makes it blindingly obvious why we should hoist the
invalidate trait and have two collections of results. That allows
handling invalidation for almost all analyses without indirect calls and
it allows short circuiting when the preserved set is all.
llvm-svn: 195338
Diffstat (limited to 'llvm/lib/IR/PassManager.cpp')
-rw-r--r-- | llvm/lib/IR/PassManager.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/llvm/lib/IR/PassManager.cpp b/llvm/lib/IR/PassManager.cpp index 50ace5880a5..18388dc0c5a 100644 --- a/llvm/lib/IR/PassManager.cpp +++ b/llvm/lib/IR/PassManager.cpp @@ -29,7 +29,7 @@ void ModuleAnalysisManager::invalidate(Module *M, const PreservedAnalyses &PA) { for (ModuleAnalysisResultMapT::iterator I = ModuleAnalysisResults.begin(), E = ModuleAnalysisResults.end(); I != E; ++I) - if (!PA.preserved(I->first) && I->second->invalidate(M)) + if (I->second->invalidate(M, PA)) ModuleAnalysisResults.erase(I); } @@ -76,7 +76,7 @@ void FunctionAnalysisManager::invalidate(Function *F, const PreservedAnalyses &P for (FunctionAnalysisResultListT::iterator I = ResultsList.begin(), E = ResultsList.end(); I != E;) - if (!PA.preserved(I->first) && I->second->invalidate(F)) { + if (I->second->invalidate(F, PA)) { InvalidatedPassIDs.push_back(I->first); I = ResultsList.erase(I); } else { @@ -145,11 +145,19 @@ FunctionAnalysisModuleProxy::Result::~Result() { FAM.clear(); } -bool FunctionAnalysisModuleProxy::Result::invalidate(Module *M) { - // FIXME: We should pull the preserved analysis set into the invalidation - // handler so that we can detect when there is no need to clear the entire - // function analysis manager. - FAM.clear(); +bool FunctionAnalysisModuleProxy::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())) { + 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; |