diff options
author | Tim Northover <tnorthover@apple.com> | 2018-04-05 14:26:06 +0000 |
---|---|---|
committer | Tim Northover <tnorthover@apple.com> | 2018-04-05 14:26:06 +0000 |
commit | b30388bf11aa7f95c8a92585130962d5e434406c (patch) | |
tree | cee4177a649c1af70e14be8d6d95065b0bfba1ce /llvm/lib/Target | |
parent | 62c4805c1f4dbba880fa4fffe85e9e5a4057f798 (diff) | |
download | bcm5719-llvm-b30388bf11aa7f95c8a92585130962d5e434406c.tar.gz bcm5719-llvm-b30388bf11aa7f95c8a92585130962d5e434406c.zip |
ARM: Do not spill CSR to stack on entry to noreturn functions
A noreturn nounwind function can be expected to never return in any way, and by
never returning it will also never have to restore any callee-saved registers
for its caller. This makes it possible to skip spills of those registers during
function entry, saving some stack space and time in the process. This is rather
useful for embedded targets with limited stack space.
Should fix PR9970.
Patch by myeisha (pmb).
llvm-svn: 329287
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r-- | llvm/lib/Target/ARM/ARMFrameLowering.cpp | 11 | ||||
-rw-r--r-- | llvm/lib/Target/ARM/ARMFrameLowering.h | 2 |
2 files changed, 13 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMFrameLowering.cpp b/llvm/lib/Target/ARM/ARMFrameLowering.cpp index d0986a73b70..a83170a1131 100644 --- a/llvm/lib/Target/ARM/ARMFrameLowering.cpp +++ b/llvm/lib/Target/ARM/ARMFrameLowering.cpp @@ -87,6 +87,17 @@ bool ARMFrameLowering::noFramePointerElim(const MachineFunction &MF) const { MF.getSubtarget<ARMSubtarget>().useFastISel(); } +/// Returns true if the target can safely skip saving callee-saved registers +/// for noreturn nounwind functions. +bool ARMFrameLowering::enableCalleeSaveSkip(const MachineFunction &MF) const { + assert(MF.getFunction().hasFnAttribute(Attribute::NoReturn) && + MF.getFunction().hasFnAttribute(Attribute::NoUnwind)); + + // Frame pointer and link register are not treated as normal CSR, thus we + // can always skip CSR saves for nonreturning functions. + return true; +} + /// hasFP - Return true if the specified function should have a dedicated frame /// pointer register. This is true if the function has variable sized allocas /// or if frame pointer elimination is disabled. diff --git a/llvm/lib/Target/ARM/ARMFrameLowering.h b/llvm/lib/Target/ARM/ARMFrameLowering.h index 1f18e2bf80c..e994cab28fe 100644 --- a/llvm/lib/Target/ARM/ARMFrameLowering.h +++ b/llvm/lib/Target/ARM/ARMFrameLowering.h @@ -44,6 +44,8 @@ public: bool noFramePointerElim(const MachineFunction &MF) const override; + bool enableCalleeSaveSkip(const MachineFunction &MF) const override; + bool hasFP(const MachineFunction &MF) const override; bool hasReservedCallFrame(const MachineFunction &MF) const override; bool canSimplifyCallFramePseudos(const MachineFunction &MF) const override; |