[llvm] 2952bc3 - [MachinePass] Run instrumentation before/after module pass (#70919)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 14 02:15:15 PST 2023
Author: paperchalice
Date: 2023-12-14T18:15:10+08:00
New Revision: 2952bc3384412ca67fd1dcd2eac595088d692802
URL: https://github.com/llvm/llvm-project/commit/2952bc3384412ca67fd1dcd2eac595088d692802
DIFF: https://github.com/llvm/llvm-project/commit/2952bc3384412ca67fd1dcd2eac595088d692802.diff
LOG: [MachinePass] Run instrumentation before/after module pass (#70919)
This commit adds `runBeforePass`/`runAfterPass` for machine module pass
so `llc -debug-pass-manager` can e.g., print module pass names.
Part of #69879.
Added:
Modified:
llvm/lib/CodeGen/MachinePassManager.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/MachinePassManager.cpp b/llvm/lib/CodeGen/MachinePassManager.cpp
index a13f820e457766..914e6b19fde9ac 100644
--- a/llvm/lib/CodeGen/MachinePassManager.cpp
+++ b/llvm/lib/CodeGen/MachinePassManager.cpp
@@ -33,10 +33,11 @@ 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.
@@ -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();
More information about the llvm-commits
mailing list