diff options
Diffstat (limited to 'lib/CodeGen/ResetMachineFunctionPass.cpp')
-rw-r--r-- | lib/CodeGen/ResetMachineFunctionPass.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/CodeGen/ResetMachineFunctionPass.cpp b/lib/CodeGen/ResetMachineFunctionPass.cpp index f1885aa74285..a02302e6ff99 100644 --- a/lib/CodeGen/ResetMachineFunctionPass.cpp +++ b/lib/CodeGen/ResetMachineFunctionPass.cpp @@ -13,9 +13,12 @@ /// happen is that the MachineFunction has the FailedISel property. //===----------------------------------------------------------------------===// +#include "llvm/ADT/ScopeExit.h" #include "llvm/ADT/Statistic.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/CodeGen/StackProtector.h" #include "llvm/CodeGen/Passes.h" #include "llvm/IR/DiagnosticInfo.h" #include "llvm/Support/Debug.h" @@ -42,12 +45,23 @@ namespace { StringRef getPassName() const override { return "ResetMachineFunction"; } + void getAnalysisUsage(AnalysisUsage &AU) const override { + AU.addPreserved<StackProtector>(); + MachineFunctionPass::getAnalysisUsage(AU); + } + bool runOnMachineFunction(MachineFunction &MF) override { + // No matter what happened, whether we successfully selected the function + // or not, nothing is going to use the vreg types after us. Make sure they + // disappear. + auto ClearVRegTypesOnReturn = + make_scope_exit([&MF]() { MF.getRegInfo().clearVirtRegTypes(); }); + if (MF.getProperties().hasProperty( MachineFunctionProperties::Property::FailedISel)) { if (AbortOnFailedISel) report_fatal_error("Instruction selection failed"); - DEBUG(dbgs() << "Reseting: " << MF.getName() << '\n'); + LLVM_DEBUG(dbgs() << "Resetting: " << MF.getName() << '\n'); ++NumFunctionsReset; MF.reset(); if (EmitFallbackDiag) { @@ -65,7 +79,7 @@ namespace { char ResetMachineFunction::ID = 0; INITIALIZE_PASS(ResetMachineFunction, DEBUG_TYPE, - "reset machine function if ISel failed", false, false) + "Reset machine function if ISel failed", false, false) MachineFunctionPass * llvm::createResetMachineFunctionPass(bool EmitFallbackDiag = false, |