diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2015-01-05 12:21:44 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2015-01-05 12:21:44 +0000 |
commit | e5e8fb3bf625ba14740b002687a5df581701ee83 (patch) | |
tree | d012b0dd167fb0300ab73ff4e55ffe4a18cc0711 /llvm/lib/IR/PassManager.cpp | |
parent | 77ef2be2e492df693c532d7adcf2864ad346c824 (diff) | |
download | bcm5719-llvm-e5e8fb3bf625ba14740b002687a5df581701ee83.tar.gz bcm5719-llvm-e5e8fb3bf625ba14740b002687a5df581701ee83.zip |
[PM] Add names and debug logging for analysis passes to the new pass
manager.
This starts to allow us to test analyses more easily, but it's really
only the beginning. Some of the code here is still untestable without
manual changes to create analysis passes, but I wanted to factor it into
a small of chunks as possible.
Next up in order to be able to test things are, in no particular order:
- No-op analyses passes so we don't have to use real ones to exercise
the pass maneger itself.
- Automatic way of generating dummy passes that require an analysis be
run, including a variant that calls a 'print' method on a pass to make
it even easier to print out the results of an analysis.
- Dummy passes that invalidate all analyses for their IR unit so we can
test invalidation and re-runs.
- Automatic way to print each analysis pass as it is re-run.
- Automatic but optional verification of analysis passes everywhere
possible.
I'm not claiming I'll get to all of these immediately, but that's what
is in the pipeline at some stage. I'm fleshing out exactly what I need
and what to prioritize by working on converting analyses and then trying
to test the conversion. =]
llvm-svn: 225162
Diffstat (limited to 'llvm/lib/IR/PassManager.cpp')
-rw-r--r-- | llvm/lib/IR/PassManager.cpp | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/llvm/lib/IR/PassManager.cpp b/llvm/lib/IR/PassManager.cpp index 121ec001fd1..c7638bb7fce 100644 --- a/llvm/lib/IR/PassManager.cpp +++ b/llvm/lib/IR/PassManager.cpp @@ -52,8 +52,12 @@ ModuleAnalysisManager::getResultImpl(void *PassID, Module &M) { // If we don't have a cached result for this module, look up the pass and run // it to produce a result, which we then add to the cache. - if (Inserted) - RI->second = lookupPass(PassID).run(M, this); + if (Inserted) { + auto &P = lookupPass(PassID); + if (DebugPM) + dbgs() << "Running module analysis: " << P.name() << "\n"; + RI->second = P.run(M, this); + } return *RI->second; } @@ -66,18 +70,30 @@ ModuleAnalysisManager::getCachedResultImpl(void *PassID, Module &M) const { } void ModuleAnalysisManager::invalidateImpl(void *PassID, Module &M) { + if (DebugPM) + dbgs() << "Invalidating module analysis: " << lookupPass(PassID).name() + << "\n"; ModuleAnalysisResults.erase(PassID); } void ModuleAnalysisManager::invalidateImpl(Module &M, const PreservedAnalyses &PA) { + if (DebugPM) + dbgs() << "Invalidating all non-preserved analyses for module: " + << M.getModuleIdentifier() << "\n"; + // FIXME: This is a total hack based on the fact that erasure doesn't // invalidate iteration for DenseMap. for (ModuleAnalysisResultMapT::iterator I = ModuleAnalysisResults.begin(), E = ModuleAnalysisResults.end(); I != E; ++I) - if (I->second->invalidate(M, PA)) + if (I->second->invalidate(M, PA)) { + if (DebugPM) + dbgs() << "Invalidating module analysis: " + << lookupPass(I->first).name() << "\n"; + ModuleAnalysisResults.erase(I); + } } PreservedAnalyses FunctionPassManager::run(Function &F, @@ -128,8 +144,11 @@ FunctionAnalysisManager::getResultImpl(void *PassID, Function &F) { // If we don't have a cached result for this function, look up the pass and // run it to produce a result, which we then add to the cache. if (Inserted) { + auto &P = lookupPass(PassID); + if (DebugPM) + dbgs() << "Running function analysis: " << P.name() << "\n"; FunctionAnalysisResultListT &ResultList = FunctionAnalysisResultLists[&F]; - ResultList.emplace_back(PassID, lookupPass(PassID).run(F, this)); + ResultList.emplace_back(PassID, P.run(F, this)); RI->second = std::prev(ResultList.end()); } @@ -149,11 +168,18 @@ void FunctionAnalysisManager::invalidateImpl(void *PassID, Function &F) { if (RI == FunctionAnalysisResults.end()) return; + if (DebugPM) + dbgs() << "Invalidating function analysis: " << lookupPass(PassID).name() + << "\n"; FunctionAnalysisResultLists[&F].erase(RI->second); } void FunctionAnalysisManager::invalidateImpl(Function &F, const PreservedAnalyses &PA) { + if (DebugPM) + dbgs() << "Invalidating all non-preserved analyses for function: " + << F.getName() << "\n"; + // Clear all the invalidated results associated specifically with this // function. SmallVector<void *, 8> InvalidatedPassIDs; @@ -162,6 +188,10 @@ void FunctionAnalysisManager::invalidateImpl(Function &F, E = ResultsList.end(); I != E;) if (I->second->invalidate(F, PA)) { + if (DebugPM) + dbgs() << "Invalidating function analysis: " + << lookupPass(I->first).name() << "\n"; + InvalidatedPassIDs.push_back(I->first); I = ResultsList.erase(I); } else { |