Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
Show First 20 Lines • Show All 573 Lines • ▼ Show 20 Lines | static bool windowsRequiresStackProbe(MachineFunction &MF, | ||||
if (F.hasFnAttribute("stack-probe-size")) | if (F.hasFnAttribute("stack-probe-size")) | ||||
F.getFnAttribute("stack-probe-size") | F.getFnAttribute("stack-probe-size") | ||||
.getValueAsString() | .getValueAsString() | ||||
.getAsInteger(0, StackProbeSize); | .getAsInteger(0, StackProbeSize); | ||||
return (StackSizeInBytes >= StackProbeSize) && | return (StackSizeInBytes >= StackProbeSize) && | ||||
!F.hasFnAttribute("no-stack-arg-probe"); | !F.hasFnAttribute("no-stack-arg-probe"); | ||||
} | } | ||||
static bool needsWinCFI(const MachineFunction &MF) { | |||||
const Function &F = MF.getFunction(); | |||||
return MF.getTarget().getMCAsmInfo()->usesWindowsCFI() && | |||||
F.needsUnwindTableEntry(); | |||||
} | |||||
bool AArch64FrameLowering::shouldCombineCSRLocalStackBump( | bool AArch64FrameLowering::shouldCombineCSRLocalStackBump( | ||||
MachineFunction &MF, uint64_t StackBumpBytes) const { | MachineFunction &MF, uint64_t StackBumpBytes) const { | ||||
AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>(); | AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>(); | ||||
const MachineFrameInfo &MFI = MF.getFrameInfo(); | const MachineFrameInfo &MFI = MF.getFrameInfo(); | ||||
const AArch64Subtarget &Subtarget = MF.getSubtarget<AArch64Subtarget>(); | const AArch64Subtarget &Subtarget = MF.getSubtarget<AArch64Subtarget>(); | ||||
const AArch64RegisterInfo *RegInfo = Subtarget.getRegisterInfo(); | const AArch64RegisterInfo *RegInfo = Subtarget.getRegisterInfo(); | ||||
if (AFI->getLocalStackSize() == 0) | if (AFI->getLocalStackSize() == 0) | ||||
return false; | return false; | ||||
// For WinCFI, if optimizing for size, prefer to not combine the stack bump | |||||
// (to force a stp with predecrement) to match the packed unwind format, | |||||
// provided that there actually are any callee saved registers to merge the | |||||
// decrement with. | |||||
// This is potentially marginally slower, but allows using the packed | |||||
// unwind format for functions that both have a local area and callee saved | |||||
// registers. Using the packed unwind format notably reduces the size of | |||||
// the unwind info. | |||||
if (needsWinCFI(MF) && AFI->getCalleeSavedStackSize() > 0 && | |||||
MF.getFunction().hasOptSize()) | |||||
return false; | |||||
// 512 is the maximum immediate for stp/ldp that will be used for | // 512 is the maximum immediate for stp/ldp that will be used for | ||||
// callee-save save/restores | // callee-save save/restores | ||||
if (StackBumpBytes >= 512 || windowsRequiresStackProbe(MF, StackBumpBytes)) | if (StackBumpBytes >= 512 || windowsRequiresStackProbe(MF, StackBumpBytes)) | ||||
return false; | return false; | ||||
if (MFI.hasVarSizedObjects()) | if (MFI.hasVarSizedObjects()) | ||||
return false; | return false; | ||||
▲ Show 20 Lines • Show All 377 Lines • ▼ Show 20 Lines | static void adaptForLdStOpt(MachineBasicBlock &MBB, | ||||
// add sp, sp, #64 | // add sp, sp, #64 | ||||
// | // | ||||
// and the load-store optimizer can merge the last two instructions into: | // and the load-store optimizer can merge the last two instructions into: | ||||
// | // | ||||
// ldp x26, x25, [sp], #64 | // ldp x26, x25, [sp], #64 | ||||
// | // | ||||
} | } | ||||
static bool needsWinCFI(const MachineFunction &MF) { | |||||
const Function &F = MF.getFunction(); | |||||
return MF.getTarget().getMCAsmInfo()->usesWindowsCFI() && | |||||
F.needsUnwindTableEntry(); | |||||
} | |||||
static bool isTargetWindows(const MachineFunction &MF) { | static bool isTargetWindows(const MachineFunction &MF) { | ||||
return MF.getSubtarget<AArch64Subtarget>().isTargetWindows(); | return MF.getSubtarget<AArch64Subtarget>().isTargetWindows(); | ||||
} | } | ||||
// Convenience function to determine whether I is an SVE callee save. | // Convenience function to determine whether I is an SVE callee save. | ||||
static bool IsSVECalleeSave(MachineBasicBlock::iterator I) { | static bool IsSVECalleeSave(MachineBasicBlock::iterator I) { | ||||
switch (I->getOpcode()) { | switch (I->getOpcode()) { | ||||
default: | default: | ||||
▲ Show 20 Lines • Show All 2,285 Lines • Show Last 20 Lines |