diff options
| author | Chandler Carruth <chandlerc@gmail.com> | 2016-06-27 23:26:08 +0000 |
|---|---|---|
| committer | Chandler Carruth <chandlerc@gmail.com> | 2016-06-27 23:26:08 +0000 |
| commit | dca834089a88ab6c8aef2cdb496e1260906e7462 (patch) | |
| tree | d0290e31c0edd78cd4a2676bc891a236305960ed /llvm/lib | |
| parent | 3d2c1e6a7c13536f9481cc844e116510f85f6205 (diff) | |
| download | bcm5719-llvm-dca834089a88ab6c8aef2cdb496e1260906e7462.tar.gz bcm5719-llvm-dca834089a88ab6c8aef2cdb496e1260906e7462.zip | |
[PM] Improve the debugging and logging facilities of the CGSCC bits of
the new pass manager.
This adds operator<< overloads for the various bits of the
LazyCallGraph, dump methods for use from the debugger, and debug logging
using them to the CGSCC pass manager.
Having this was essential for debugging the call graph update patch, and
I've extracted what I could from that patch here to minimize the delta.
llvm-svn: 273961
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Analysis/LazyCallGraph.cpp | 53 | ||||
| -rw-r--r-- | llvm/lib/Passes/PassBuilder.cpp | 9 |
2 files changed, 58 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/LazyCallGraph.cpp b/llvm/lib/Analysis/LazyCallGraph.cpp index a153333e79a..2d34a243f47 100644 --- a/llvm/lib/Analysis/LazyCallGraph.cpp +++ b/llvm/lib/Analysis/LazyCallGraph.cpp @@ -120,6 +120,14 @@ void LazyCallGraph::Node::removeEdgeInternal(Function &Target) { EdgeIndexMap.erase(IndexMapI); } +raw_ostream &llvm::operator<<(raw_ostream &OS, const LazyCallGraph::Node &N) { + return OS << N.F.getName(); +} + +void LazyCallGraph::Node::dump() const { + dbgs() << *this << '\n'; +} + LazyCallGraph::LazyCallGraph(Module &M) : NextDFSNumber(0) { DEBUG(dbgs() << "Building CG for module: " << M.getModuleIdentifier() << "\n"); @@ -173,6 +181,28 @@ LazyCallGraph &LazyCallGraph::operator=(LazyCallGraph &&G) { return *this; } +raw_ostream &llvm::operator<<(raw_ostream &OS, const LazyCallGraph::SCC &C) { + OS << '('; + int i = 0; + for (LazyCallGraph::Node &N : C) { + if (i > 0) + OS << ", "; + // Elide the inner elements if there are too many. + if (i > 8) { + OS << "..., " << *C.Nodes.back(); + break; + } + OS << N; + ++i; + } + OS << ')'; + return OS; +} + +void LazyCallGraph::SCC::dump() const { + dbgs() << *this << '\n'; +} + #ifndef NDEBUG void LazyCallGraph::SCC::verify() { assert(OuterRefSCC && "Can't have a null RefSCC!"); @@ -194,6 +224,29 @@ void LazyCallGraph::SCC::verify() { LazyCallGraph::RefSCC::RefSCC(LazyCallGraph &G) : G(&G) {} +raw_ostream &llvm::operator<<(raw_ostream &OS, + const LazyCallGraph::RefSCC &RC) { + OS << '['; + int i = 0; + for (LazyCallGraph::SCC &C : RC) { + if (i > 0) + OS << ", "; + // Elide the inner elements if there are too many. + if (i > 4) { + OS << "..., " << *RC.SCCs.back(); + break; + } + OS << C; + ++i; + } + OS << ']'; + return OS; +} + +void LazyCallGraph::RefSCC::dump() const { + dbgs() << *this << '\n'; +} + #ifndef NDEBUG void LazyCallGraph::RefSCC::verify() { assert(G && "Can't have a null graph!"); diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 362bd13d03d..5f617455022 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -561,7 +561,8 @@ bool PassBuilder::parseCGSCCPassPipeline(CGSCCPassManager &CGPM, PipelineText = PipelineText.substr(1); // Add the nested pass manager with the appropriate adaptor. - CGPM.addPass(createCGSCCToFunctionPassAdaptor(std::move(NestedFPM))); + CGPM.addPass( + createCGSCCToFunctionPassAdaptor(std::move(NestedFPM), DebugLogging)); } else { // Otherwise try to parse a pass name. size_t End = PipelineText.find_first_of(",)"); @@ -627,8 +628,8 @@ bool PassBuilder::parseModulePassPipeline(ModulePassManager &MPM, PipelineText = PipelineText.substr(1); // Add the nested pass manager with the appropriate adaptor. - MPM.addPass( - createModuleToPostOrderCGSCCPassAdaptor(std::move(NestedCGPM))); + MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(NestedCGPM), + DebugLogging)); } else if (PipelineText.startswith("function(")) { FunctionPassManager NestedFPM(DebugLogging); @@ -689,7 +690,7 @@ bool PassBuilder::parsePassPipeline(ModulePassManager &MPM, DebugLogging) || !PipelineText.empty()) return false; - MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM))); + MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(std::move(CGPM), DebugLogging)); return true; } |

