diff --git a/include/llvm/CodeGen/MachineFrameInfo.h b/include/llvm/CodeGen/MachineFrameInfo.h index 363f2063483..6c49eaf88e0 100644 --- a/include/llvm/CodeGen/MachineFrameInfo.h +++ b/include/llvm/CodeGen/MachineFrameInfo.h @@ -118,10 +118,6 @@ class MachineFrameInfo { /// bool HasVarSizedObjects; - /// FrameAddressTaken - This boolean keeps track of whether there is a call - /// to builtin @llvm.frameaddress. - bool FrameAddressTaken; - /// StackSize - The prolog/epilog code inserter calculates the final stack /// offsets for all of the fixed size objects, updating the Objects list /// above. It then updates StackSize to contain the number of bytes that need @@ -178,7 +174,6 @@ public: MachineFrameInfo(const TargetFrameInfo &tfi) : TFI(tfi) { StackSize = NumFixedObjects = OffsetAdjustment = MaxAlignment = 0; HasVarSizedObjects = false; - FrameAddressTaken = false; HasCalls = false; MaxCallFrameSize = 0; MMI = 0; @@ -195,12 +190,6 @@ public: /// bool hasVarSizedObjects() const { return HasVarSizedObjects; } - /// isFrameAddressTaken - This method may be called any time after instruction - /// selection is complete to determine if there is a call to - /// @llvm.frameaddress in this function. - bool isFrameAddressTaken() const { return FrameAddressTaken; } - void setFrameAddressIsTaken(bool T) { FrameAddressTaken = T; } - /// getObjectIndexBegin - Return the minimum frame object index... /// int getObjectIndexBegin() const { return -NumFixedObjects; } diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp index bfda30ee194..76902505bc6 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp @@ -3483,13 +3483,10 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) { setValue(&I, DAG.getNode(ISD::RETURNADDR, TLI.getPointerTy(), getValue(I.getOperand(1)))); return 0; - case Intrinsic::frameaddress: { - MachineFrameInfo *MFI = CurMBB->getParent()->getFrameInfo(); - MFI->setFrameAddressIsTaken(true); + case Intrinsic::frameaddress: setValue(&I, DAG.getNode(ISD::FRAMEADDR, TLI.getPointerTy(), getValue(I.getOperand(1)))); return 0; - } case Intrinsic::setjmp: return "_setjmp"+!TLI.usesUnderscoreSetJmp(); break; diff --git a/lib/Target/ARM/ARMRegisterInfo.cpp b/lib/Target/ARM/ARMRegisterInfo.cpp index d598ef68f1d..7787f43ff61 100644 --- a/lib/Target/ARM/ARMRegisterInfo.cpp +++ b/lib/Target/ARM/ARMRegisterInfo.cpp @@ -209,9 +209,7 @@ ARMRegisterInfo::requiresRegisterScavenging(const MachineFunction &MF) const { /// or if frame pointer elimination is disabled. /// bool ARMRegisterInfo::hasFP(const MachineFunction &MF) const { - const MachineFrameInfo *MFI = MF.getFrameInfo(); - return NoFramePointerElim || MFI->hasVarSizedObjects() || - MFI->isFrameAddressTaken(); + return NoFramePointerElim || MF.getFrameInfo()->hasVarSizedObjects(); } // hasReservedCallFrame - Under normal circumstances, when a frame pointer is diff --git a/lib/Target/Alpha/AlphaRegisterInfo.cpp b/lib/Target/Alpha/AlphaRegisterInfo.cpp index 3cef5957df5..dd8460a0656 100644 --- a/lib/Target/Alpha/AlphaRegisterInfo.cpp +++ b/lib/Target/Alpha/AlphaRegisterInfo.cpp @@ -104,7 +104,7 @@ BitVector AlphaRegisterInfo::getReservedRegs(const MachineFunction &MF) const { // bool AlphaRegisterInfo::hasFP(const MachineFunction &MF) const { const MachineFrameInfo *MFI = MF.getFrameInfo(); - return MFI->hasVarSizedObjects() || MFI->isFrameAddressTaken(); + return MFI->hasVarSizedObjects(); } void AlphaRegisterInfo:: diff --git a/lib/Target/CellSPU/SPURegisterInfo.cpp b/lib/Target/CellSPU/SPURegisterInfo.cpp index 18ca7033f60..882f79f7e18 100644 --- a/lib/Target/CellSPU/SPURegisterInfo.cpp +++ b/lib/Target/CellSPU/SPURegisterInfo.cpp @@ -294,8 +294,7 @@ BitVector SPURegisterInfo::getReservedRegs(const MachineFunction &MF) const { // static bool needsFP(const MachineFunction &MF) { const MachineFrameInfo *MFI = MF.getFrameInfo(); - return NoFramePointerElim || MFI->hasVarSizedObjects() || - MFI->isFrameAddressTaken(); + return NoFramePointerElim || MFI->hasVarSizedObjects(); } //-------------------------------------------------------------------------- diff --git a/lib/Target/IA64/IA64RegisterInfo.cpp b/lib/Target/IA64/IA64RegisterInfo.cpp index 0438de151fe..848eab8ed90 100644 --- a/lib/Target/IA64/IA64RegisterInfo.cpp +++ b/lib/Target/IA64/IA64RegisterInfo.cpp @@ -75,9 +75,7 @@ BitVector IA64RegisterInfo::getReservedRegs(const MachineFunction &MF) const { // if frame pointer elimination is disabled. // bool IA64RegisterInfo::hasFP(const MachineFunction &MF) const { - const MachineFrameInfo *MFI = MF.getFrameInfo(); - return NoFramePointerElim || MFI->hasVarSizedObjects() || - MFI->isFrameAddressTaken(); + return NoFramePointerElim || MF.getFrameInfo()->hasVarSizedObjects(); } void IA64RegisterInfo:: diff --git a/lib/Target/Mips/MipsRegisterInfo.cpp b/lib/Target/Mips/MipsRegisterInfo.cpp index f09d93e04d3..6d75f460d34 100644 --- a/lib/Target/Mips/MipsRegisterInfo.cpp +++ b/lib/Target/Mips/MipsRegisterInfo.cpp @@ -324,9 +324,7 @@ void MipsRegisterInfo::adjustMipsStackFrame(MachineFunction &MF) const // if frame pointer elimination is disabled. bool MipsRegisterInfo:: hasFP(const MachineFunction &MF) const { - const MachineFrameInfo *MFI = MF.getFrameInfo(); - return NoFramePointerElim || MFI->hasVarSizedObjects() || - MFI->isFrameAddressTaken(); + return (NoFramePointerElim || MF.getFrameInfo()->hasVarSizedObjects()); } // This function eliminate ADJCALLSTACKDOWN, diff --git a/lib/Target/PowerPC/PPCRegisterInfo.cpp b/lib/Target/PowerPC/PPCRegisterInfo.cpp index 155932d8d32..014925e1a6d 100644 --- a/lib/Target/PowerPC/PPCRegisterInfo.cpp +++ b/lib/Target/PowerPC/PPCRegisterInfo.cpp @@ -333,7 +333,6 @@ PPCRegisterInfo::getCalleeSavedRegClasses(const MachineFunction *MF) const { static bool needsFP(const MachineFunction &MF) { const MachineFrameInfo *MFI = MF.getFrameInfo(); return NoFramePointerElim || MFI->hasVarSizedObjects() || - MFI->isFrameAddressTaken() || (PerformTailCallOpt && MF.getInfo()->hasFastCall()); } diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 1ef644d54d8..8e8a51a920e 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -5645,13 +5645,13 @@ SDValue X86TargetLowering::LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) { } SDValue X86TargetLowering::LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) { - unsigned Depth = cast(Op.getOperand(0))->getZExtValue(); - unsigned FrameReg = Subtarget->is64Bit() ? X86::RBP : X86::EBP; - SDValue FrameAddr = DAG.getRegister(FrameReg, getPointerTy()); - while (Depth--) - FrameAddr = DAG.getLoad(getPointerTy(), DAG.getEntryNode(), FrameAddr, - NULL, 0); - return FrameAddr; + // Depths > 0 not supported yet! + if (cast(Op.getOperand(0))->getZExtValue() > 0) + return SDValue(); + + SDValue RetAddrFI = getReturnAddressFrameIndex(DAG); + return DAG.getNode(ISD::SUB, getPointerTy(), RetAddrFI, + DAG.getIntPtrConstant(TD->getPointerSize())); } SDValue X86TargetLowering::LowerFRAME_TO_ARGS_OFFSET(SDValue Op, diff --git a/lib/Target/X86/X86RegisterInfo.cpp b/lib/Target/X86/X86RegisterInfo.cpp index d618ffdeb78..49766a8fc74 100644 --- a/lib/Target/X86/X86RegisterInfo.cpp +++ b/lib/Target/X86/X86RegisterInfo.cpp @@ -299,7 +299,6 @@ bool X86RegisterInfo::hasFP(const MachineFunction &MF) const { return (NoFramePointerElim || needsStackRealignment(MF) || MFI->hasVarSizedObjects() || - MFI->isFrameAddressTaken() || MF.getInfo()->getForceFramePointer() || (MMI && MMI->callsUnwindInit())); } diff --git a/test/CodeGen/X86/x86-64-frameaddr.ll b/test/CodeGen/X86/x86-64-frameaddr.ll index 80060996f32..86a238f6ab5 100644 --- a/test/CodeGen/X86/x86-64-frameaddr.ll +++ b/test/CodeGen/X86/x86-64-frameaddr.ll @@ -1,6 +1,7 @@ -; RUN: llvm-as < %s | llc -march=x86-64 | grep movq | grep rbp +; RUN: llvm-as < %s | llc -march=x86-64 | grep {leaq -8(%rsp), %rax} +@llvm.noinline = appending global [1 x i8*] [ i8* bitcast (i64* ()* @stack_end_address to i8*) ], section "llvm.metadata" -define i64* @stack_end_address() nounwind { +define internal i64* @stack_end_address() nounwind { entry: tail call i8* @llvm.frameaddress( i32 0 ) bitcast i8* %0 to i64* diff --git a/test/CodeGen/X86/x86-frameaddr.ll b/test/CodeGen/X86/x86-frameaddr.ll index b9d6d13880b..0707d92d098 100644 --- a/test/CodeGen/X86/x86-frameaddr.ll +++ b/test/CodeGen/X86/x86-frameaddr.ll @@ -1,4 +1,5 @@ ; RUN: llvm-as < %s | llc -march=x86 | grep mov | grep ebp +; XFAIL: * define i8* @t() nounwind { entry: diff --git a/test/CodeGen/X86/x86-frameaddr2.ll b/test/CodeGen/X86/x86-frameaddr2.ll index f50ab072c33..bcb87c549b7 100644 --- a/test/CodeGen/X86/x86-frameaddr2.ll +++ b/test/CodeGen/X86/x86-frameaddr2.ll @@ -1,4 +1,5 @@ ; RUN: llvm-as < %s | llc -march=x86 | grep mov | count 3 +; XFAIL: * define i8* @t() nounwind { entry: