diff options
Diffstat (limited to 'llvm/lib/CodeGen/MachinePassManager.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachinePassManager.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachinePassManager.cpp b/llvm/lib/CodeGen/MachinePassManager.cpp index f5514e4..be81fc8 100644 --- a/llvm/lib/CodeGen/MachinePassManager.cpp +++ b/llvm/lib/CodeGen/MachinePassManager.cpp @@ -11,6 +11,7 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/MachinePassManager.h" +#include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/IR/PassManagerImpl.h" @@ -32,6 +33,22 @@ Error MachineFunctionPassManager::run(Module &M, (void)RequireCodeGenSCCOrder; assert(!RequireCodeGenSCCOrder && "not implemented"); + // Add a PIC to verify machine functions. + if (VerifyMachineFunction) { + PassInstrumentation PI = MFAM.getResult<PassInstrumentationAnalysis>(M); + + // No need to pop this callback later since MIR pipeline is flat which means + // current pipeline is the top-level pipeline. Callbacks are not used after + // current pipeline. + PI.pushBeforeNonSkippedPassCallback([&MFAM](StringRef PassID, Any IR) { + assert(any_isa<const MachineFunction *>(IR)); + const MachineFunction *MF = any_cast<const MachineFunction *>(IR); + assert(MF && "Machine function should be valid for printing"); + std::string Banner = std::string("After ") + std::string(PassID); + verifyMachineFunction(&MFAM, Banner, *MF); + }); + } + if (DebugLogging) { dbgs() << "Starting " << getTypeName<MachineFunction>() << " pass manager run.\n"; |