Skip to content

Commit 4c847d2

Browse files
committed
[Instrumentation] Support verifying machine function
1 parent 38067c5 commit 4c847d2

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

llvm/lib/Passes/StandardInstrumentations.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,12 @@ void VerifyInstrumentation::registerCallbacks(
14861486
"\"{0}\", compilation aborted!",
14871487
P));
14881488
}
1489+
1490+
// TODO: Use complete MachineVerifierPass.
1491+
if (auto *MF = unwrapIR<MachineFunction>(IR)) {
1492+
dbgs() << "Verifying machine function " << MF->getName() << '\n';
1493+
verifyMachineFunction("", *MF);
1494+
}
14891495
}
14901496
});
14911497
}

llvm/test/tools/llc/new-pm/verify.mir

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# RUN: llc -mtriple=x86_64-pc-linux-gnu -x mir -passes=no-op-machine-function -filetype=null < %s 2>&1 | FileCheck %s
2+
3+
# CHECK: Verifying machine function f
4+
5+
---
6+
name: f
7+
body: |
8+
bb.0:
9+
RET 0
10+
...

llvm/tools/llc/NewPMDriver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ int llvm::compileModuleWithNewPM(
115115
MachineModuleInfo MMI(&LLVMTM);
116116

117117
PassInstrumentationCallbacks PIC;
118-
StandardInstrumentations SI(Context, Opt.DebugPM);
118+
StandardInstrumentations SI(Context, Opt.DebugPM, !NoVerify);
119119
SI.registerCallbacks(PIC);
120120
registerCodeGenCallback(PIC, LLVMTM);
121121

0 commit comments

Comments
 (0)