/// 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);
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);
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),