Skip to content

Commit b345adc

Browse files
committed
add a simple test
1 parent 38d96d7 commit b345adc

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

llvm/include/llvm/Passes/MachinePassRegistry.def

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ MACHINE_FUNCTION_PASS("dead-mi-elimination", DeadMachineInstructionElimPass())
127127
// MACHINE_FUNCTION_PASS("free-machine-function", FreeMachineFunctionPass())
128128
MACHINE_FUNCTION_PASS("no-op-machine-function", NoOpMachineFunctionPass())
129129
MACHINE_FUNCTION_PASS("print", PrintMIRPass())
130+
MACHINE_FUNCTION_PASS("require-all-machine-function-properties",
131+
RequireAllMachineFunctionPropertiesPass())
130132
#undef MACHINE_FUNCTION_PASS
131133

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

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,34 @@ class TriggerVerifierErrorPass
365365
static StringRef name() { return "TriggerVerifierErrorPass"; }
366366
};
367367

368+
// A pass requires all MachineFunctionProperties.
369+
// DO NOT USE THIS EXCEPT FOR TESTING!
370+
class RequireAllMachineFunctionPropertiesPass
371+
: public MachinePassInfoMixin<RequireAllMachineFunctionPropertiesPass> {
372+
public:
373+
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &) {
374+
PropertyChanger PC(MF);
375+
return PreservedAnalyses::none();
376+
}
377+
378+
static MachineFunctionProperties getRequiredProperties() {
379+
MachineFunctionProperties MFProps;
380+
MFProps.set(MachineFunctionProperties::Property::FailedISel);
381+
MFProps.set(MachineFunctionProperties::Property::FailsVerification);
382+
MFProps.set(MachineFunctionProperties::Property::IsSSA);
383+
MFProps.set(MachineFunctionProperties::Property::Legalized);
384+
MFProps.set(MachineFunctionProperties::Property::NoPHIs);
385+
MFProps.set(MachineFunctionProperties::Property::NoVRegs);
386+
MFProps.set(MachineFunctionProperties::Property::RegBankSelected);
387+
MFProps.set(MachineFunctionProperties::Property::Selected);
388+
MFProps.set(MachineFunctionProperties::Property::TiedOpsRewritten);
389+
MFProps.set(MachineFunctionProperties::Property::TracksDebugUserValues);
390+
MFProps.set(MachineFunctionProperties::Property::TracksLiveness);
391+
return MFProps;
392+
}
393+
static StringRef name() { return "RequireAllMachineFunctionPropertiesPass"; }
394+
};
395+
368396
} // namespace
369397

370398
PassBuilder::PassBuilder(TargetMachine *TM, PipelineTuningOptions PTO,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# REQUIRES: asserts
2+
# RUN: not --crash llc -mtriple=x86_64-pc-linux-gnu -passes=require-all-machine-function-properties -filetype=null %s 2>&1 | FileCheck %s
3+
4+
# CHECK: MachineFunctionProperties required by RequireAllMachineFunctionPropertiesPass pass are not met by function f.
5+
6+
---
7+
name: f
8+
selected: false
9+
body: |
10+
bb.0:
11+
RET 0
12+
...

0 commit comments

Comments
 (0)