llvm.org GIT mirror llvm / 669e297
GlobalISel: Abort in ResetMachineFunctionPass if fallback isn't enabled When GlobalISel is configured to abort rather than fallback the only thing that resetting the machine function does is make things harder to debug. If we ever get to this point in the abort configuration it indicates that we've already hit a bug, so this changes the behaviour to abort instead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291977 91177308-0d34-0410-b5e6-96231b3b80d8 Justin Bogner 3 years ago
3 changed file(s) with 16 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
5959 /// as if it was just created.
6060 /// If EmitFallbackDiag is true, the pass will emit a
6161 /// DiagnosticInfoISelFallback for every MachineFunction it resets.
62 MachineFunctionPass *createResetMachineFunctionPass(bool EmitFallbackDiag);
62 /// If AbortOnFailedISel is true, abort compilation instead of resetting.
63 MachineFunctionPass *createResetMachineFunctionPass(bool EmitFallbackDiag,
64 bool AbortOnFailedISel);
6365
6466 /// createCodeGenPreparePass - Transform the code to expose more pattern
6567 /// matching during instruction selection.
171171
172172 // Pass to reset the MachineFunction if the ISel failed.
173173 PM.add(createResetMachineFunctionPass(
174 PassConfig->reportDiagnosticWhenGlobalISelFallback()));
174 PassConfig->reportDiagnosticWhenGlobalISelFallback(),
175 PassConfig->isGlobalISelAbortEnabled()));
175176
176177 // Provide a fallback path when we do not want to abort on
177178 // not-yet-supported input.
2929 /// Tells whether or not this pass should emit a fallback
3030 /// diagnostic when it resets a function.
3131 bool EmitFallbackDiag;
32 /// Whether we should abort immediately instead of resetting the function.
33 bool AbortOnFailedISel;
3234
3335 public:
3436 static char ID; // Pass identification, replacement for typeid
35 ResetMachineFunction(bool EmitFallbackDiag = false)
36 : MachineFunctionPass(ID), EmitFallbackDiag(EmitFallbackDiag) {}
37 ResetMachineFunction(bool EmitFallbackDiag = false,
38 bool AbortOnFailedISel = false)
39 : MachineFunctionPass(ID), EmitFallbackDiag(EmitFallbackDiag),
40 AbortOnFailedISel(AbortOnFailedISel) {}
3741
3842 StringRef getPassName() const override { return "ResetMachineFunction"; }
3943
4044 bool runOnMachineFunction(MachineFunction &MF) override {
4145 if (MF.getProperties().hasProperty(
4246 MachineFunctionProperties::Property::FailedISel)) {
47 if (AbortOnFailedISel)
48 report_fatal_error("Instruction selection failed");
4349 DEBUG(dbgs() << "Reseting: " << MF.getName() << '\n');
4450 ++NumFunctionsReset;
4551 MF.reset();
6167 "reset machine function if ISel failed", false, false)
6268
6369 MachineFunctionPass *
64 llvm::createResetMachineFunctionPass(bool EmitFallbackDiag = false) {
65 return new ResetMachineFunction(EmitFallbackDiag);
70 llvm::createResetMachineFunctionPass(bool EmitFallbackDiag = false,
71 bool AbortOnFailedISel = false) {
72 return new ResetMachineFunction(EmitFallbackDiag, AbortOnFailedISel);
6673 }