From 98a0104014e9bb6ed89c2572f615351fd526674a Mon Sep 17 00:00:00 2001 From: Evan Cheng Date: Fri, 14 Aug 2009 20:48:13 +0000 Subject: [PATCH] Leaf functions which do not save CSRs can be frameless even with -disable-fp-elim. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79039 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/ARM/ARMBaseRegisterInfo.cpp | 9 ++++++++- lib/Target/ARM/ARMBaseRegisterInfo.h | 2 ++ test/CodeGen/Thumb2/frameless.ll | 6 ++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 test/CodeGen/Thumb2/frameless.ll diff --git a/lib/Target/ARM/ARMBaseRegisterInfo.cpp b/lib/Target/ARM/ARMBaseRegisterInfo.cpp index 309a5c6eb5d..12fbb5dc03e 100644 --- a/lib/Target/ARM/ARMBaseRegisterInfo.cpp +++ b/lib/Target/ARM/ARMBaseRegisterInfo.cpp @@ -440,6 +440,13 @@ bool ARMBaseRegisterInfo::hasFP(const MachineFunction &MF) const { MFI->isFrameAddressTaken()); } +bool ARMBaseRegisterInfo::hasStackFrame(const MachineFunction &MF) const { + const MachineFrameInfo *MFI = MF.getFrameInfo(); + if (NoFramePointerElim && MFI->hasCalls()) + return true; + return MFI->hasVarSizedObjects() || MFI->isFrameAddressTaken(); +} + /// estimateStackSize - Estimate and return the size of the frame. static unsigned estimateStackSize(MachineFunction &MF, MachineFrameInfo *MFI) { const MachineFrameInfo *FFI = MF.getFrameInfo(); @@ -589,7 +596,7 @@ ARMBaseRegisterInfo::processFunctionBeforeCalleeSavedScan(MachineFunction &MF, } bool ExtraCSSpill = false; - if (!CanEliminateFrame || hasFP(MF)) { + if (!CanEliminateFrame || hasStackFrame(MF)) { AFI->setHasStackFrame(true); // If LR is not spilled, but at least one of R4, R5, R6, and R7 is spilled. diff --git a/lib/Target/ARM/ARMBaseRegisterInfo.h b/lib/Target/ARM/ARMBaseRegisterInfo.h index 92dbb8435d5..c242489fdb8 100644 --- a/lib/Target/ARM/ARMBaseRegisterInfo.h +++ b/lib/Target/ARM/ARMBaseRegisterInfo.h @@ -89,6 +89,8 @@ public: bool hasFP(const MachineFunction &MF) const; + bool hasStackFrame(const MachineFunction &MF) const; + void processFunctionBeforeCalleeSavedScan(MachineFunction &MF, RegScavenger *RS = NULL) const; diff --git a/test/CodeGen/Thumb2/frameless.ll b/test/CodeGen/Thumb2/frameless.ll new file mode 100644 index 00000000000..1b6bb62d14e --- /dev/null +++ b/test/CodeGen/Thumb2/frameless.ll @@ -0,0 +1,6 @@ +; RUN: llvm-as < %s | llc -mtriple=thumbv7-apple-darwin -disable-fp-elim | not grep mov +; RUN: llvm-as < %s | llc -mtriple=thumbv7-linux -disable-fp-elim | not grep mov + +define arm_apcscc void @t() nounwind readnone { + ret void +}