@@ -33,10 +33,11 @@ Error MachineFunctionPassManager::run(Module &M,
33
33
(void )RequireCodeGenSCCOrder;
34
34
assert (!RequireCodeGenSCCOrder && " not implemented" );
35
35
36
+ // M is unused here
37
+ PassInstrumentation PI = MFAM.getResult <PassInstrumentationAnalysis>(M);
38
+
36
39
// Add a PIC to verify machine functions.
37
40
if (VerifyMachineFunction) {
38
- PassInstrumentation PI = MFAM.getResult <PassInstrumentationAnalysis>(M);
39
-
40
41
// No need to pop this callback later since MIR pipeline is flat which means
41
42
// current pipeline is the top-level pipeline. Callbacks are not used after
42
43
// current pipeline.
@@ -59,8 +60,11 @@ Error MachineFunctionPassManager::run(Module &M,
59
60
do {
60
61
// Run machine module passes
61
62
for (; MachineModulePasses.count (Idx) && Idx != Size ; ++Idx) {
63
+ if (!PI.runBeforePass <Module>(*Passes[Idx], M))
64
+ continue ;
62
65
if (auto Err = MachineModulePasses.at (Idx)(M, MFAM))
63
66
return Err;
67
+ PI.runAfterPass (*Passes[Idx], M, PreservedAnalyses::all ());
64
68
}
65
69
66
70
// Finish running all passes.
@@ -81,7 +85,6 @@ Error MachineFunctionPassManager::run(Module &M,
81
85
continue ;
82
86
83
87
MachineFunction &MF = MMI.getOrCreateMachineFunction (F);
84
- PassInstrumentation PI = MFAM.getResult <PassInstrumentationAnalysis>(MF);
85
88
86
89
for (unsigned I = Begin, E = Idx; I != E; ++I) {
87
90
auto *P = Passes[I].get ();
0 commit comments