From b56749c3b7bd3867d5a500b9882decd957244620 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sat, 11 Jan 2014 11:52:05 +0000 Subject: [PM] Add names to passes under the new pass manager, and a debug output mode that can be used to debug the execution of everything. No support for analyses here, that will come later. This already helps show parts of the opt commandline integration that isn't working. Tests of that will start using it as the bugs are fixed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199004 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/PassManager.cpp | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/IR/PassManager.cpp b/lib/IR/PassManager.cpp index 30b46b01c1..70533fef58 100644 --- a/lib/IR/PassManager.cpp +++ b/lib/IR/PassManager.cpp @@ -7,19 +7,36 @@ // //===----------------------------------------------------------------------===// -#include "llvm/IR/PassManager.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/IR/PassManager.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" using namespace llvm; +static cl::opt +DebugPM("debug-pass-manager", cl::Hidden, + cl::desc("Print pass management debugging information")); + PreservedAnalyses ModulePassManager::run(Module *M, ModuleAnalysisManager *AM) { PreservedAnalyses PA = PreservedAnalyses::all(); + + if (DebugPM) + dbgs() << "Starting module pass manager run.\n"; + for (unsigned Idx = 0, Size = Passes.size(); Idx != Size; ++Idx) { + if (DebugPM) + dbgs() << "Running module pass: " << Passes[Idx]->name() << "\n"; + PreservedAnalyses PassPA = Passes[Idx]->run(M, AM); if (AM) AM->invalidate(M, PassPA); PA.intersect(llvm_move(PassPA)); } + + if (DebugPM) + dbgs() << "Finished module pass manager run.\n"; + return PA; } @@ -61,12 +78,23 @@ void ModuleAnalysisManager::invalidateImpl(Module *M, PreservedAnalyses FunctionPassManager::run(Function *F, FunctionAnalysisManager *AM) { PreservedAnalyses PA = PreservedAnalyses::all(); + + if (DebugPM) + dbgs() << "Starting function pass manager run.\n"; + for (unsigned Idx = 0, Size = Passes.size(); Idx != Size; ++Idx) { + if (DebugPM) + dbgs() << "Running function pass: " << Passes[Idx]->name() << "\n"; + PreservedAnalyses PassPA = Passes[Idx]->run(F, AM); if (AM) AM->invalidate(F, PassPA); PA.intersect(llvm_move(PassPA)); } + + if (DebugPM) + dbgs() << "Finished function pass manager run.\n"; + return PA; } -- cgit v1.2.3