llvm.org GIT mirror llvm / 184793f
Re-apply 56683 with fixes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56748 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 11 years ago
10 changed file(s) with 45 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
117117 ///
118118 bool HasVarSizedObjects;
119119
120 /// FrameAddressTaken - This boolean keeps track of whether there is a call
121 /// to builtin @llvm.frameaddress.
122 bool FrameAddressTaken;
123
120124 /// StackSize - The prolog/epilog code inserter calculates the final stack
121125 /// offsets for all of the fixed size objects, updating the Objects list
122126 /// above. It then updates StackSize to contain the number of bytes that need
173177 MachineFrameInfo(const TargetFrameInfo &tfi) : TFI(tfi) {
174178 StackSize = NumFixedObjects = OffsetAdjustment = MaxAlignment = 0;
175179 HasVarSizedObjects = false;
180 FrameAddressTaken = false;
176181 HasCalls = false;
177182 MaxCallFrameSize = 0;
178183 MMI = 0;
188193 /// contains any variable sized objects.
189194 ///
190195 bool hasVarSizedObjects() const { return HasVarSizedObjects; }
196
197 /// isFrameAddressTaken - This method may be called any time after instruction
198 /// selection is complete to determine if there is a call to
199 /// @llvm.frameaddress in this function.
200 bool isFrameAddressTaken() const { return FrameAddressTaken; }
201 void setFrameAddressIsTaken(bool T) { FrameAddressTaken = T; }
191202
192203 /// getObjectIndexBegin - Return the minimum frame object index...
193204 ///
208208 /// or if frame pointer elimination is disabled.
209209 ///
210210 bool ARMRegisterInfo::hasFP(const MachineFunction &MF) const {
211 return NoFramePointerElim || MF.getFrameInfo()->hasVarSizedObjects();
211 const MachineFrameInfo *MFI = MF.getFrameInfo();
212 return NoFramePointerElim || MFI->hasVarSizedObjects();
212213 }
213214
214215 // hasReservedCallFrame - Under normal circumstances, when a frame pointer is
7474 // if frame pointer elimination is disabled.
7575 //
7676 bool IA64RegisterInfo::hasFP(const MachineFunction &MF) const {
77 return NoFramePointerElim || MF.getFrameInfo()->hasVarSizedObjects();
77 const MachineFrameInfo *MFI = MF.getFrameInfo();
78 return NoFramePointerElim || MFI->hasVarSizedObjects();
7879 }
7980
8081 void IA64RegisterInfo::
323323 // if frame pointer elimination is disabled.
324324 bool MipsRegisterInfo::
325325 hasFP(const MachineFunction &MF) const {
326 return (NoFramePointerElim || MF.getFrameInfo()->hasVarSizedObjects());
326 const MachineFrameInfo *MFI = MF.getFrameInfo();
327 return NoFramePointerElim || MFI->hasVarSizedObjects();
327328 }
328329
329330 // This function eliminate ADJCALLSTACKDOWN,
56445644 }
56455645
56465646 SDValue X86TargetLowering::LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) {
5647 // Depths > 0 not supported yet!
5648 if (cast(Op.getOperand(0))->getZExtValue() > 0)
5649 return SDValue();
5650
5651 SDValue RetAddrFI = getReturnAddressFrameIndex(DAG);
5652 return DAG.getNode(ISD::SUB, getPointerTy(), RetAddrFI,
5653 DAG.getIntPtrConstant(TD->getPointerSize()));
5647 MachineFrameInfo *MFI = DAG.getMachineFunction().getFrameInfo();
5648 MFI->setFrameAddressIsTaken(true);
5649 MVT VT = Op.getValueType();
5650 unsigned Depth = cast(Op.getOperand(0))->getZExtValue();
5651 unsigned FrameReg = Subtarget->is64Bit() ? X86::RBP : X86::EBP;
5652 SDValue FrameAddr = DAG.getCopyFromReg(DAG.getEntryNode(), FrameReg, VT);
5653 while (Depth--)
5654 FrameAddr = DAG.getLoad(VT, DAG.getEntryNode(), FrameAddr, NULL, 0);
5655 return FrameAddr;
56545656 }
56555657
56565658 SDValue X86TargetLowering::LowerFRAME_TO_ARGS_OFFSET(SDValue Op,
298298 return (NoFramePointerElim ||
299299 needsStackRealignment(MF) ||
300300 MFI->hasVarSizedObjects() ||
301 MFI->isFrameAddressTaken() ||
301302 MF.getInfo()->getForceFramePointer() ||
302303 (MMI && MMI->callsUnwindInit()));
303304 }
0 ; RUN: llvm-as < %s | llc -mtriple=i386-apple-darwin9
1
2 %struct._Unwind_Context = type { [18 x i8*], i8*, i8*, i8*, %struct.dwarf_eh_bases, i32, i32, i32, [18 x i8] }
3 %struct._Unwind_Exception = type { i64, void (i32, %struct._Unwind_Exception*)*, i32, i32, [3 x i32] }
4 %struct.dwarf_eh_bases = type { i8*, i8*, i8* }
5
6 declare fastcc void @uw_init_context_1(%struct._Unwind_Context*, i8*, i8*)
7
8 declare i8* @llvm.eh.dwarf.cfa(i32) nounwind
9
10 define hidden void @_Unwind_Resume(%struct._Unwind_Exception* %exc) noreturn noreturn {
11 entry:
12 %0 = call i8* @llvm.eh.dwarf.cfa(i32 0) ; [#uses=1]
13 call fastcc void @uw_init_context_1(%struct._Unwind_Context* null, i8* %0, i8* null)
14 unreachable
15 }
None ; RUN: llvm-as < %s | llc -march=x86-64 | grep {leaq -8(%rsp), %rax}
1 @llvm.noinline = appending global [1 x i8*] [ i8* bitcast (i64* ()* @stack_end_address to i8*) ], section "llvm.metadata"
0 ; RUN: llvm-as < %s | llc -march=x86-64 | grep movq | grep rbp
21
3 define internal i64* @stack_end_address() nounwind {
2 define i64* @stack_end_address() nounwind {
43 entry:
54 tail call i8* @llvm.frameaddress( i32 0 )
65 bitcast i8* %0 to i64*
0 ; RUN: llvm-as < %s | llc -march=x86 | grep mov | grep ebp
1 ; XFAIL: *
21
32 define i8* @t() nounwind {
43 entry:
0 ; RUN: llvm-as < %s | llc -march=x86 | grep mov | count 3
1 ; XFAIL: *
21
32 define i8* @t() nounwind {
43 entry: