diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2023-12-18 20:30:12 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2024-04-19 21:12:03 +0000 |
| commit | c9157d925c489f07ba9c0b2ce47e5149b75969a5 (patch) | |
| tree | 08bc4a3d9cad3f9ebffa558ddf140b9d9257b219 /contrib/llvm-project/llvm/lib/CodeGen/MachinePassManager.cpp | |
| parent | 2a66844f606a35d68ad8a8061f4bea204274b3bc (diff) | |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/CodeGen/MachinePassManager.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/CodeGen/MachinePassManager.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/contrib/llvm-project/llvm/lib/CodeGen/MachinePassManager.cpp b/contrib/llvm-project/llvm/lib/CodeGen/MachinePassManager.cpp index 439ff8babcc6..914e6b19fde9 100644 --- a/contrib/llvm-project/llvm/lib/CodeGen/MachinePassManager.cpp +++ b/contrib/llvm-project/llvm/lib/CodeGen/MachinePassManager.cpp @@ -33,16 +33,17 @@ Error MachineFunctionPassManager::run(Module &M, (void)RequireCodeGenSCCOrder; assert(!RequireCodeGenSCCOrder && "not implemented"); + // M is unused here + PassInstrumentation PI = MFAM.getResult<PassInstrumentationAnalysis>(M); + // 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_cast<const MachineFunction *>(&IR)); - const MachineFunction *MF = any_cast<const MachineFunction *>(IR); + assert(llvm::any_cast<const MachineFunction *>(&IR)); + const MachineFunction *MF = llvm::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); @@ -59,8 +60,11 @@ Error MachineFunctionPassManager::run(Module &M, do { // Run machine module passes for (; MachineModulePasses.count(Idx) && Idx != Size; ++Idx) { + if (!PI.runBeforePass<Module>(*Passes[Idx], M)) + continue; if (auto Err = MachineModulePasses.at(Idx)(M, MFAM)) return Err; + PI.runAfterPass(*Passes[Idx], M, PreservedAnalyses::all()); } // Finish running all passes. @@ -81,7 +85,6 @@ Error MachineFunctionPassManager::run(Module &M, continue; MachineFunction &MF = MMI.getOrCreateMachineFunction(F); - PassInstrumentation PI = MFAM.getResult<PassInstrumentationAnalysis>(MF); for (unsigned I = Begin, E = Idx; I != E; ++I) { auto *P = Passes[I].get(); |
