diff options
author | Reid Kleckner <rnk@google.com> | 2017-10-06 18:21:19 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2017-10-06 18:21:19 +0000 |
commit | 813c577cc26a4269ee5b20c4421cef9cb2172991 (patch) | |
tree | 7e41870eaa081a148545be385f0f80691f6d78ea /llvm/lib/CodeGen/PrologEpilogInserter.cpp | |
parent | 85255eda913ecdad769c10cf65fcb6e0dd6a8485 (diff) | |
download | bcm5719-llvm-813c577cc26a4269ee5b20c4421cef9cb2172991.tar.gz bcm5719-llvm-813c577cc26a4269ee5b20c4421cef9cb2172991.zip |
[PEI] Remove required properties and use 'if' instead of std::function
Summary:
After r303360, we initialize UsesCalleeSaves in runOnMachineFunction,
which runs after getRequiredProperties. UsesCalleeSaves was initialized
to 'false', so getRequiredProperties would always return an empty set.
We don't have a TargetMachine available early anymore after r303360.
Just removing the requirement of NoVRegs seems to make things work, so
let's do that.
Reviewers: thegameg, dschuff, MatzeB
Subscribers: hiraditya, llvm-commits
Differential Revision: https://reviews.llvm.org/D38597
llvm-svn: 315089
Diffstat (limited to 'llvm/lib/CodeGen/PrologEpilogInserter.cpp')
-rw-r--r-- | llvm/lib/CodeGen/PrologEpilogInserter.cpp | 72 |
1 files changed, 23 insertions, 49 deletions
diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp b/llvm/lib/CodeGen/PrologEpilogInserter.cpp index 032abb441dd..3d7e1c9ecd4 100644 --- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp +++ b/llvm/lib/CodeGen/PrologEpilogInserter.cpp @@ -50,11 +50,11 @@ using namespace llvm; #define DEBUG_TYPE "prologepilog" typedef SmallVector<MachineBasicBlock *, 4> MBBVector; -static void doSpillCalleeSavedRegs(MachineFunction &MF, RegScavenger *RS, - unsigned &MinCSFrameIndex, - unsigned &MaxCXFrameIndex, - const MBBVector &SaveBlocks, - const MBBVector &RestoreBlocks); +static void spillCalleeSavedRegs(MachineFunction &MF, RegScavenger *RS, + unsigned &MinCSFrameIndex, + unsigned &MaxCXFrameIndex, + const MBBVector &SaveBlocks, + const MBBVector &RestoreBlocks); namespace { class PEI : public MachineFunctionPass { @@ -66,29 +66,12 @@ public: void getAnalysisUsage(AnalysisUsage &AU) const override; - MachineFunctionProperties getRequiredProperties() const override { - MachineFunctionProperties MFP; - if (UsesCalleeSaves) - MFP.set(MachineFunctionProperties::Property::NoVRegs); - return MFP; - } - /// runOnMachineFunction - Insert prolog/epilog code and replace abstract /// frame indexes with appropriate references. /// bool runOnMachineFunction(MachineFunction &Fn) override; private: - std::function<void(MachineFunction &MF, RegScavenger *RS, - unsigned &MinCSFrameIndex, unsigned &MaxCSFrameIndex, - const MBBVector &SaveBlocks, - const MBBVector &RestoreBlocks)> - SpillCalleeSavedRegisters; - std::function<void(MachineFunction &MF, RegScavenger &RS)> - ScavengeFrameVirtualRegs; - - bool UsesCalleeSaves = false; - RegScavenger *RS; // MinCSFrameIndex, MaxCSFrameIndex - Keeps the range of callee saved @@ -166,20 +149,6 @@ typedef SmallSetVector<int, 8> StackObjSet; /// frame indexes with appropriate references. /// bool PEI::runOnMachineFunction(MachineFunction &Fn) { - if (!SpillCalleeSavedRegisters) { - const TargetMachine &TM = Fn.getTarget(); - if (!TM.usesPhysRegsForPEI()) { - SpillCalleeSavedRegisters = [](MachineFunction &, RegScavenger *, - unsigned &, unsigned &, const MBBVector &, - const MBBVector &) {}; - ScavengeFrameVirtualRegs = [](MachineFunction &, RegScavenger &) {}; - } else { - SpillCalleeSavedRegisters = doSpillCalleeSavedRegs; - ScavengeFrameVirtualRegs = scavengeFrameVirtualRegs; - UsesCalleeSaves = true; - } - } - const Function* F = Fn.getFunction(); const TargetRegisterInfo *TRI = Fn.getSubtarget().getRegisterInfo(); const TargetFrameLowering *TFI = Fn.getSubtarget().getFrameLowering(); @@ -200,8 +169,9 @@ bool PEI::runOnMachineFunction(MachineFunction &Fn) { calculateSaveRestoreBlocks(Fn); // Handle CSR spilling and restoring, for targets that need it. - SpillCalleeSavedRegisters(Fn, RS, MinCSFrameIndex, MaxCSFrameIndex, - SaveBlocks, RestoreBlocks); + if (Fn.getTarget().usesPhysRegsForPEI()) + spillCalleeSavedRegs(Fn, RS, MinCSFrameIndex, MaxCSFrameIndex, SaveBlocks, + RestoreBlocks); // Allow the target machine to make final modifications to the function // before the frame layout is finalized. @@ -226,12 +196,8 @@ bool PEI::runOnMachineFunction(MachineFunction &Fn) { // If register scavenging is needed, as we've enabled doing it as a // post-pass, scavenge the virtual registers that frame index elimination // inserted. - if (TRI->requiresRegisterScavenging(Fn) && FrameIndexVirtualScavenging) { - ScavengeFrameVirtualRegs(Fn, *RS); - - // Clear any vregs created by virtual scavenging. - Fn.getRegInfo().clearVirtRegs(); - } + if (TRI->requiresRegisterScavenging(Fn) && FrameIndexVirtualScavenging) + scavengeFrameVirtualRegs(Fn, *RS); // Warn on stack size when we exceeds the given limit. MachineFrameInfo &MFI = Fn.getFrameInfo(); @@ -512,11 +478,19 @@ static void insertCSRRestores(MachineBasicBlock &RestoreBlock, } } -static void doSpillCalleeSavedRegs(MachineFunction &Fn, RegScavenger *RS, - unsigned &MinCSFrameIndex, - unsigned &MaxCSFrameIndex, - const MBBVector &SaveBlocks, - const MBBVector &RestoreBlocks) { +static void spillCalleeSavedRegs(MachineFunction &Fn, RegScavenger *RS, + unsigned &MinCSFrameIndex, + unsigned &MaxCSFrameIndex, + const MBBVector &SaveBlocks, + const MBBVector &RestoreBlocks) { + // We can't list this requirement in getRequiredProperties because some + // targets (WebAssembly) use virtual registers past this point, and the pass + // pipeline is set up without giving the passes a chance to look at the + // TargetMachine. + // FIXME: Find a way to express this in getRequiredProperties. + assert(Fn.getProperties().hasProperty( + MachineFunctionProperties::Property::NoVRegs)); + const Function *F = Fn.getFunction(); const TargetFrameLowering *TFI = Fn.getSubtarget().getFrameLowering(); MachineFrameInfo &MFI = Fn.getFrameInfo(); |