aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-12-17 00:07:46 +0000
committerChris Lattner <sabre@nondot.org>2004-12-17 00:07:46 +0000
commit11cf7aa775dece12fbf29c57c1e97eb0c5eb06ad (patch)
tree59c6a3b77c0169e0be367f97c60a0ee7523ef91d
parentacd67824704067c68fed7d7c981afadeb8ea67ad (diff)
Create a stack slot for the return address lazily instead of eagerly. This
save small amounts of time for functions that don't call llvm.returnaddress or llvm.frameaddress (which is almost all functions). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19006 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/X86/X86ISelSimple.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Target/X86/X86ISelSimple.cpp b/lib/Target/X86/X86ISelSimple.cpp
index ed93101ecb..2d77f7e1fc 100644
--- a/lib/Target/X86/X86ISelSimple.cpp
+++ b/lib/Target/X86/X86ISelSimple.cpp
@@ -96,6 +96,9 @@ namespace {
/// the entire function.
///
bool runOnFunction(Function &Fn) {
+ // Lazily create a stack slot for the return address if needed.
+ ReturnAddressIndex = -1;
+
// First pass over the function, lower any unknown intrinsic functions
// with the IntrinsicLowering class.
LowerUnknownIntrinsicFunctionCalls(Fn);
@@ -108,10 +111,6 @@ namespace {
BB = &F->front();
- // Set up a frame object for the return address. This is used by the
- // llvm.returnaddress & llvm.frameaddress intrinisics.
- ReturnAddressIndex = F->getFrameInfo()->CreateFixedObject(4, -4);
-
// Copy incoming arguments off of the stack...
LoadArgumentsToVirtualRegs(Fn);
@@ -1765,6 +1764,11 @@ void X86ISel::visitIntrinsicCall(Intrinsic::ID ID, CallInst &CI) {
case Intrinsic::frameaddress:
TmpReg1 = getReg(CI);
if (cast<Constant>(CI.getOperand(1))->isNullValue()) {
+ if (ReturnAddressIndex == -1) {
+ // Set up a frame object for the return address.
+ ReturnAddressIndex = F->getFrameInfo()->CreateFixedObject(4, -4);
+ }
+
if (ID == Intrinsic::returnaddress) {
// Just load the return address
addFrameReference(BuildMI(BB, X86::MOV32rm, 4, TmpReg1),