[llvm] r182108 - [Sparc] Implements hasReservedCallFrame and hasFP.
Venkatraman Govindaraju
venkatra at cs.wisc.edu
Fri May 17 08:14:34 PDT 2013
Author: venkatra
Date: Fri May 17 10:14:34 2013
New Revision: 182108
URL: http://llvm.org/viewvc/llvm-project?rev=182108&view=rev
Log:
[Sparc] Implements hasReservedCallFrame and hasFP.
This is to generate correct framesetup code when the function
has variable sized allocas.
Added:
llvm/trunk/test/CodeGen/SPARC/2013-05-17-CallFrame.ll
Modified:
llvm/trunk/lib/Target/Sparc/SparcFrameLowering.cpp
llvm/trunk/lib/Target/Sparc/SparcFrameLowering.h
Modified: llvm/trunk/lib/Target/Sparc/SparcFrameLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcFrameLowering.cpp?rev=182108&r1=182107&r2=182108&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Sparc/SparcFrameLowering.cpp (original)
+++ llvm/trunk/lib/Target/Sparc/SparcFrameLowering.cpp Fri May 17 10:14:34 2013
@@ -106,3 +106,18 @@ void SparcFrameLowering::emitEpilogue(Ma
BuildMI(MBB, MBBI, dl, TII.get(SP::RESTORErr), SP::G0).addReg(SP::G0)
.addReg(SP::G0);
}
+
+bool SparcFrameLowering::hasReservedCallFrame(const MachineFunction &MF) const {
+ //Reserve call frame if there are no variable sized objects on the stack
+ return !MF.getFrameInfo()->hasVarSizedObjects();
+}
+
+// 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.
+bool SparcFrameLowering::hasFP(const MachineFunction &MF) const {
+ const MachineFrameInfo *MFI = MF.getFrameInfo();
+ return MF.getTarget().Options.DisableFramePointerElim(MF) ||
+ MFI->hasVarSizedObjects() || MFI->isFrameAddressTaken();
+}
+
Modified: llvm/trunk/lib/Target/Sparc/SparcFrameLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/SparcFrameLowering.h?rev=182108&r1=182107&r2=182108&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Sparc/SparcFrameLowering.h (original)
+++ llvm/trunk/lib/Target/Sparc/SparcFrameLowering.h Fri May 17 10:14:34 2013
@@ -38,7 +38,8 @@ public:
MachineBasicBlock &MBB,
MachineBasicBlock::iterator I) const;
- bool hasFP(const MachineFunction &MF) const { return false; }
+ bool hasReservedCallFrame(const MachineFunction &MF) const;
+ bool hasFP(const MachineFunction &MF) const;
};
} // End llvm namespace
Added: llvm/trunk/test/CodeGen/SPARC/2013-05-17-CallFrame.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/SPARC/2013-05-17-CallFrame.ll?rev=182108&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/SPARC/2013-05-17-CallFrame.ll (added)
+++ llvm/trunk/test/CodeGen/SPARC/2013-05-17-CallFrame.ll Fri May 17 10:14:34 2013
@@ -0,0 +1,16 @@
+; RUN: llc -march=sparc < %s | FileCheck %s
+
+; CHECK: variable_alloca_with_adj_call_stack
+; CHECK: save %sp, -96, %sp
+; CHECK: add %sp, -16, %sp
+; CHECK: call foo
+; CHECK: add %sp, 16, %sp
+define void @variable_alloca_with_adj_call_stack(i32 %num) {
+entry:
+ %0 = alloca i8, i32 %num, align 8
+ call void @foo(i8* %0, i8* %0, i8* %0, i8* %0, i8* %0, i8* %0, i8* %0, i8* %0, i8* %0, i8* %0)
+ ret void
+}
+
+
+declare void @foo(i8* , i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*, i8*);
More information about the llvm-commits
mailing list