[Hexagon] Speed up frame lowering when no optimizations are enabled

- Do not optimize stack slots in optnone functions.
- Get aligned-base register from HexagonMachineFunctionInfo instead of
  looking for ALIGNA instruction in the function's body.

llvm-svn: 264580
This commit is contained in:
Krzysztof Parzyszek 2016-03-28 14:42:03 +00:00
parent d0c11cf7ad
commit a34901aae9
2 changed files with 35 additions and 24 deletions

View File

@ -287,6 +287,20 @@ namespace {
return true; return true;
return false; return false;
} }
inline bool isOptNone(const MachineFunction &MF) {
return MF.getFunction()->hasFnAttribute(Attribute::OptimizeNone) ||
MF.getTarget().getOptLevel() == CodeGenOpt::None;
}
inline bool isOptSize(const MachineFunction &MF) {
const Function &F = *MF.getFunction();
return F.optForSize() && !F.optForMinSize();
}
inline bool isMinSize(const MachineFunction &MF) {
return MF.getFunction()->optForMinSize();
}
} }
@ -864,9 +878,8 @@ int HexagonFrameLowering::getFrameIndexReference(const MachineFunction &MF,
bool NoOpt = MF.getTarget().getOptLevel() == CodeGenOpt::None; bool NoOpt = MF.getTarget().getOptLevel() == CodeGenOpt::None;
unsigned SP = HRI.getStackRegister(), FP = HRI.getFrameRegister(); unsigned SP = HRI.getStackRegister(), FP = HRI.getFrameRegister();
unsigned AP = 0; auto &HMFI = *MF.getInfo<HexagonMachineFunctionInfo>();
if (const MachineInstr *AI = getAlignaInstr(MF)) unsigned AP = HMFI.getStackAlignBasePhysReg();
AP = AI->getOperand(0).getReg();
unsigned FrameSize = MFI.getStackSize(); unsigned FrameSize = MFI.getStackSize();
bool UseFP = false, UseAP = false; // Default: use SP (except at -O0). bool UseFP = false, UseAP = false; // Default: use SP (except at -O0).
@ -1089,6 +1102,13 @@ void HexagonFrameLowering::processFunctionBeforeFrameFinalized(
if (A == 0) if (A == 0)
MFI->setLocalFrameMaxAlign(8); MFI->setLocalFrameMaxAlign(8);
MFI->setUseLocalStackAllocationBlock(true); MFI->setUseLocalStackAllocationBlock(true);
// Set the physical aligned-stack base address register.
unsigned AP = 0;
if (const MachineInstr *AI = getAlignaInstr(MF))
AP = AI->getOperand(0).getReg();
auto &HMFI = *MF.getInfo<HexagonMachineFunctionInfo>();
HMFI.setStackAlignBasePhysReg(AP);
} }
/// Returns true if there is no caller saved registers available. /// Returns true if there is no caller saved registers available.
@ -1680,7 +1700,7 @@ void HexagonFrameLowering::determineCalleeSaves(MachineFunction &MF,
// Replace predicate register pseudo spill code. // Replace predicate register pseudo spill code.
SmallVector<unsigned,8> NewRegs; SmallVector<unsigned,8> NewRegs;
expandSpillMacros(MF, NewRegs); expandSpillMacros(MF, NewRegs);
if (OptimizeSpillSlots) if (OptimizeSpillSlots && !isOptNone(MF))
optimizeSpillSlots(MF, NewRegs); optimizeSpillSlots(MF, NewRegs);
// We need to reserve a a spill slot if scavenging could potentially require // We need to reserve a a spill slot if scavenging could potentially require
@ -2145,18 +2165,6 @@ const MachineInstr *HexagonFrameLowering::getAlignaInstr(
} }
// FIXME: Use Function::optForSize().
inline static bool isOptSize(const MachineFunction &MF) {
AttributeSet AF = MF.getFunction()->getAttributes();
return AF.hasAttribute(AttributeSet::FunctionIndex,
Attribute::OptimizeForSize);
}
inline static bool isMinSize(const MachineFunction &MF) {
return MF.getFunction()->optForMinSize();
}
/// Determine whether the callee-saved register saves and restores should /// Determine whether the callee-saved register saves and restores should
/// be generated via inline code. If this function returns "true", inline /// be generated via inline code. If this function returns "true", inline
/// code will be generated. If this function returns "false", additional /// code will be generated. If this function returns "false", additional

View File

@ -27,7 +27,8 @@ class HexagonMachineFunctionInfo : public MachineFunctionInfo {
// returning the value of the returned struct in a register. This field // returning the value of the returned struct in a register. This field
// holds the virtual register into which the sret argument is passed. // holds the virtual register into which the sret argument is passed.
unsigned SRetReturnReg; unsigned SRetReturnReg;
unsigned StackAlignBaseReg; unsigned StackAlignBaseVReg; // Aligned-stack base register (virtual)
unsigned StackAlignBasePhysReg; // (physical)
std::vector<MachineInstr*> AllocaAdjustInsts; std::vector<MachineInstr*> AllocaAdjustInsts;
int VarArgsFrameIndex; int VarArgsFrameIndex;
bool HasClobberLR; bool HasClobberLR;
@ -36,13 +37,12 @@ class HexagonMachineFunctionInfo : public MachineFunctionInfo {
virtual void anchor(); virtual void anchor();
public: public:
HexagonMachineFunctionInfo() : SRetReturnReg(0), StackAlignBaseReg(0), HexagonMachineFunctionInfo() : SRetReturnReg(0), StackAlignBaseVReg(0),
HasClobberLR(0), HasEHReturn(false) {} StackAlignBasePhysReg(0), HasClobberLR(0), HasEHReturn(false) {}
HexagonMachineFunctionInfo(MachineFunction &MF) : SRetReturnReg(0), HexagonMachineFunctionInfo(MachineFunction &MF) : SRetReturnReg(0),
StackAlignBaseReg(0), StackAlignBaseVReg(0), StackAlignBasePhysReg(0), HasClobberLR(0),
HasClobberLR(0), HasEHReturn(false) {}
HasEHReturn(false) {}
unsigned getSRetReturnReg() const { return SRetReturnReg; } unsigned getSRetReturnReg() const { return SRetReturnReg; }
void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; } void setSRetReturnReg(unsigned Reg) { SRetReturnReg = Reg; }
@ -77,8 +77,11 @@ public:
bool hasEHReturn() const { return HasEHReturn; }; bool hasEHReturn() const { return HasEHReturn; };
void setHasEHReturn(bool H = true) { HasEHReturn = H; }; void setHasEHReturn(bool H = true) { HasEHReturn = H; };
void setStackAlignBaseVReg(unsigned R) { StackAlignBaseReg = R; } void setStackAlignBaseVReg(unsigned R) { StackAlignBaseVReg = R; }
unsigned getStackAlignBaseVReg() const { return StackAlignBaseReg; } unsigned getStackAlignBaseVReg() const { return StackAlignBaseVReg; }
void setStackAlignBasePhysReg(unsigned R) { StackAlignBasePhysReg = R; }
unsigned getStackAlignBasePhysReg() const { return StackAlignBasePhysReg; }
}; };
} // End llvm namespace } // End llvm namespace