Skip to content

Commit 237b57f

Browse files
committed
extend TriggerVerifierErrorPass
1 parent a1b8be3 commit 237b57f

File tree

5 files changed

+18
-7
lines changed

5 files changed

+18
-7
lines changed

llvm/include/llvm/Passes/MachinePassRegistry.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ MACHINE_FUNCTION_PASS("no-op-machine-function", NoOpMachineFunctionPass())
128128
MACHINE_FUNCTION_PASS("print", PrintMIRPass())
129129
MACHINE_FUNCTION_PASS("require-all-machine-function-properties",
130130
RequireAllMachineFunctionPropertiesPass())
131+
MACHINE_FUNCTION_PASS("trigger-verifier-error", TriggerVerifierErrorPass())
131132
#undef MACHINE_FUNCTION_PASS
132133

133134
// After a pass is converted to new pass manager, its entry should be moved from

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@
9393
#include "llvm/CodeGen/MIRPrinter.h"
9494
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
9595
#include "llvm/CodeGen/MachinePassManager.h"
96+
#include "llvm/CodeGen/MachineRegisterInfo.h"
9697
#include "llvm/CodeGen/PreISelIntrinsicLowering.h"
9798
#include "llvm/CodeGen/SafeStack.h"
9899
#include "llvm/CodeGen/SelectOptimize.h"
@@ -363,6 +364,14 @@ class TriggerVerifierErrorPass
363364
return PreservedAnalyses::none();
364365
}
365366

367+
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &) {
368+
// Intentionally create a virtual register and set NoVRegs property.
369+
auto &MRI = MF.getRegInfo();
370+
MRI.createGenericVirtualRegister(LLT::scalar(8));
371+
MF.getProperties().set(MachineFunctionProperties::Property::NoVRegs);
372+
return PreservedAnalyses::all();
373+
}
374+
366375
static StringRef name() { return "TriggerVerifierErrorPass"; }
367376
};
368377

llvm/lib/Passes/StandardInstrumentations.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,10 +1491,11 @@ void VerifyInstrumentation::registerCallbacks(
14911491
if (auto *MF = unwrapIR<MachineFunction>(IR)) {
14921492
if (DebugLogging)
14931493
dbgs() << "Verifying machine function " << MF->getName() << '\n';
1494-
verifyMachineFunction(formatv("Broken module found after pass "
1495-
"\"{0}\", compilation aborted!",
1496-
P),
1497-
*MF);
1494+
verifyMachineFunction(
1495+
formatv("Broken machine function found after pass "
1496+
"\"{0}\", compilation aborted!",
1497+
P),
1498+
*MF);
14981499
}
14991500
}
15001501
});

llvm/test/CodeGen/MIR/X86/machine-verifier.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# RUN: not --crash llc -march=x86-64 -run-pass none -o /dev/null %s 2>&1 | FileCheck %s
2-
# This test ensures that the MIR parser runs the machine verifier after parsing.
2+
# This test ensures that the VerifyInstrumentation works for machine function.
33

44
--- |
55

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# RUN: llc -mtriple=x86_64-pc-linux-gnu -x mir -passes=no-op-machine-function -filetype=null < %s 2>&1 | FileCheck %s
1+
# RUN: not --crash llc -mtriple=x86_64-pc-linux-gnu -debug-pass-manager -passes='module(function(machine-function(trigger-verifier-error)))' -filetype=null %s 2>&1 | FileCheck %s
22

33
# CHECK: Verifying machine function f
4-
4+
# CHECK: Broken machine function found after pass
55
---
66
name: f
77
body: |

0 commit comments

Comments
 (0)