[PATCH] D38597: [PEI] Remove required properties and use 'if' instead of std::function
Reid Kleckner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 5 13:43:41 PDT 2017
rnk updated this revision to Diff 117880.
rnk added a comment.
- Try to add the right assert
https://reviews.llvm.org/D38597
Files:
llvm/lib/CodeGen/PrologEpilogInserter.cpp
Index: llvm/lib/CodeGen/PrologEpilogInserter.cpp
===================================================================
--- llvm/lib/CodeGen/PrologEpilogInserter.cpp
+++ llvm/lib/CodeGen/PrologEpilogInserter.cpp
@@ -66,29 +66,12 @@
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,23 +149,10 @@
/// 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();
+ bool UsesCalleeSaves = Fn.getTarget().usesPhysRegsForPEI();
RS = TRI->requiresRegisterScavenging(Fn) ? new RegScavenger() : nullptr;
FrameIndexVirtualScavenging = TRI->requiresFrameIndexScavenging(Fn);
@@ -200,8 +170,9 @@
calculateSaveRestoreBlocks(Fn);
// Handle CSR spilling and restoring, for targets that need it.
- SpillCalleeSavedRegisters(Fn, RS, MinCSFrameIndex, MaxCSFrameIndex,
- SaveBlocks, RestoreBlocks);
+ if (UsesCalleeSaves)
+ doSpillCalleeSavedRegs(Fn, RS, MinCSFrameIndex, MaxCSFrameIndex, SaveBlocks,
+ RestoreBlocks);
// Allow the target machine to make final modifications to the function
// before the frame layout is finalized.
@@ -227,10 +198,11 @@
// post-pass, scavenge the virtual registers that frame index elimination
// inserted.
if (TRI->requiresRegisterScavenging(Fn) && FrameIndexVirtualScavenging) {
- ScavengeFrameVirtualRegs(Fn, *RS);
+ if (UsesCalleeSaves)
+ scavengeFrameVirtualRegs(Fn, *RS);
- // Clear any vregs created by virtual scavenging.
- Fn.getRegInfo().clearVirtRegs();
+ // Clear any vregs created by virtual scavenging.
+ Fn.getRegInfo().clearVirtRegs();
}
// Warn on stack size when we exceeds the given limit.
@@ -517,6 +489,8 @@
unsigned &MaxCSFrameIndex,
const MBBVector &SaveBlocks,
const MBBVector &RestoreBlocks) {
+ assert(Fn.getProperties().hasProperty(
+ MachineFunctionProperties::Property::NoVRegs));
const Function *F = Fn.getFunction();
const TargetFrameLowering *TFI = Fn.getSubtarget().getFrameLowering();
MachineFrameInfo &MFI = Fn.getFrameInfo();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38597.117880.patch
Type: text/x-patch
Size: 3900 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171005/e5c7d6ef/attachment.bin>
More information about the llvm-commits
mailing list