llvm.org GIT mirror llvm / d8f69a7
Rename llvm.recoverframeallocation to llvm.framerecover This name is less descriptive, but it sort of puts things in the 'llvm.frame...' namespace, relating it to frameallocate and frameaddress. It also avoids using "allocate" and "allocation" together. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225752 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Kleckner 4 years ago
8 changed file(s) with 24 addition(s) and 24 deletion(s). Raw diff Collapse all Expand all
72807280 other aggressive transformations, so the value returned may not be that
72817281 of the obvious source-language caller.
72827282
7283 '``llvm.frameallocate``' and '``llvm.recoverframeallocation``' Intrinsics
7283 '``llvm.frameallocate``' and '``llvm.framerecover``' Intrinsics
72847284 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
72857285
72867286 Syntax:
72897289 ::
72907290
72917291 declare i8* @llvm.frameallocate(i32 %size)
7292 declare i8* @llvm.recoverframeallocation(i8* %func, i8* %fp)
7292 declare i8* @llvm.framerecover(i8* %func, i8* %fp)
72937293
72947294 Overview:
72957295 """""""""
72967296
72977297 The '``llvm.frameallocate``' intrinsic allocates stack memory at some fixed
7298 offset from the frame pointer, and the '``llvm.recoverframeallocation``'
7298 offset from the frame pointer, and the '``llvm.framerecover``'
72997299 intrinsic applies that offset to a live frame pointer to recover the address of
73007300 the allocation. The offset is computed during frame layout of the caller of
73017301 ``llvm.frameallocate``.
73077307 indicating the amount of stack memory to allocate. As with allocas, allocating
73087308 zero bytes is legal, but the result is undefined.
73097309
7310 The ``func`` argument to '``llvm.recoverframeallocation``' must be a constant
7310 The ``func`` argument to '``llvm.framerecover``' must be a constant
73117311 bitcasted pointer to a function defined in the current module. The code
73127312 generator cannot determine the frame allocation offset of functions defined in
73137313 other modules.
73147314
7315 The ``fp`` argument to '``llvm.recoverframeallocation``' must be a frame
7315 The ``fp`` argument to '``llvm.framerecover``' must be a frame
73167316 pointer of a call frame that is currently live. The return value of
73177317 '``llvm.frameaddress``' is one way to produce such a value, but most platforms
73187318 also expose the frame pointer through stack unwinding mechanisms.
73277327 only call '``llvm.frameallocate``' one or zero times from the function entry
73287328 block. The frame allocation intrinsic inhibits inlining, as any frame
73297329 allocations in the inlined function frame are likely to be at a different
7330 offset from the one used by '``llvm.recoverframeallocation``' called with the
7330 offset from the one used by '``llvm.framerecover``' called with the
73317331 uninlined function.
73327332
73337333 .. _int_read_register:
7171 /// the parent's frame or return address, and so on.
7272 FRAMEADDR, RETURNADDR,
7373
74 /// RECOVER_FRAME_ALLOC - Represents the llvm.recoverframeallocation
74 /// FRAME_ALLOC_RECOVER - Represents the llvm.framerecover
7575 /// intrinsic. Materializes the offset from the frame pointer of another
7676 /// function to the result of llvm.frameallocate.
77 RECOVER_FRAME_ALLOC,
77 FRAME_ALLOC_RECOVER,
7878
7979 /// READ_REGISTER, WRITE_REGISTER - This node represents llvm.register on
8080 /// the DAG, which implements the named register global variables extension.
259259 def int_returnaddress : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty], [IntrNoMem]>;
260260 def int_frameaddress : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty], [IntrNoMem]>;
261261 def int_frameallocate : Intrinsic<[llvm_ptr_ty], [llvm_i32_ty]>;
262 def int_recoverframeallocation : Intrinsic<[llvm_ptr_ty],
262 def int_framerecover : Intrinsic<[llvm_ptr_ty],
263263 [llvm_ptr_ty, llvm_ptr_ty],
264264 [IntrNoMem]>;
265265 def int_read_register : Intrinsic<[llvm_anyint_ty], [llvm_metadata_ty],
56075607 return nullptr;
56085608 }
56095609
5610 case Intrinsic::recoverframeallocation: {
5611 // i8* @llvm.recoverframeallocation(i8* %fn, i8* %fp)
5610 case Intrinsic::framerecover: {
5611 // i8* @llvm.framerecover(i8* %fn, i8* %fp)
56125612 MachineFunction &MF = DAG.getMachineFunction();
56135613 MVT PtrVT = TLI.getPointerTy(0);
56145614
56235623 assert(Name.size() == strlen(Name.data()) && "not null terminated");
56245624 SDValue OffsetSym = DAG.getTargetExternalSymbol(Name.data(), PtrVT);
56255625 SDValue OffsetVal =
5626 DAG.getNode(ISD::RECOVER_FRAME_ALLOC, sdl, PtrVT, OffsetSym);
5626 DAG.getNode(ISD::FRAME_ALLOC_RECOVER, sdl, PtrVT, OffsetSym);
56275627
56285628 // Add the offset to the FP.
56295629 Value *FP = I.getArgOperand(1);
26162616 "llvm.frameallocate argument must be constant integer size", &CI);
26172617 break;
26182618 }
2619 case Intrinsic::recoverframeallocation: {
2619 case Intrinsic::framerecover: {
26202620 Value *FnArg = CI.getArgOperand(0)->stripPointerCasts();
26212621 Function *Fn = dyn_cast(FnArg);
2622 Assert1(Fn && !Fn->isDeclaration(), "llvm.recoverframeallocation first "
2622 Assert1(Fn && !Fn->isDeclaration(), "llvm.framerecover first "
26232623 "argument must be function defined in this module", &CI);
26242624 break;
26252625 }
193193 def X86Wrapper : SDNode<"X86ISD::Wrapper", SDTX86Wrapper>;
194194 def X86WrapperRIP : SDNode<"X86ISD::WrapperRIP", SDTX86Wrapper>;
195195
196 def X86RecoverFrameAlloc : SDNode<"ISD::RECOVER_FRAME_ALLOC",
196 def X86RecoverFrameAlloc : SDNode<"ISD::FRAME_ALLOC_RECOVER",
197197 SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>,
198198 SDTCisInt<1>]>>;
199199
11
22 declare i8* @llvm.frameallocate(i32)
33 declare i8* @llvm.frameaddress(i32)
4 declare i8* @llvm.recoverframeallocation(i8*, i8*)
4 declare i8* @llvm.framerecover(i8*, i8*)
55 declare i32 @printf(i8*, ...)
66
77 @str = internal constant [10 x i8] c"asdf: %d\0A\00"
88
99 define void @print_framealloc_from_fp(i8* %fp) {
10 %alloc = call i8* @llvm.recoverframeallocation(i8* bitcast (void(i32*, i32*)* @alloc_func to i8*), i8* %fp)
10 %alloc = call i8* @llvm.framerecover(i8* bitcast (void(i32*, i32*)* @alloc_func to i8*), i8* %fp)
1111 %alloc_i32 = bitcast i8* %alloc to i32*
1212 %r = load i32* %alloc_i32
1313 call i32 (i8*, ...)* @printf(i8* getelementptr ([10 x i8]* @str, i32 0, i32 0), i32 %r)
0 ; RUN: not llvm-as %s -o /dev/null 2>&1 | FileCheck %s
11
22 declare i8* @llvm.frameallocate(i32)
3 declare i8* @llvm.recoverframeallocation(i8*, i8*)
3 declare i8* @llvm.framerecover(i8*, i8*)
44
55 define internal void @f() {
66 call i8* @llvm.frameallocate(i32 4)
2525 ; CHECK: llvm.frameallocate used outside of entry block
2626
2727 define internal void @h() {
28 call i8* @llvm.recoverframeallocation(i8* null, i8* null)
28 call i8* @llvm.framerecover(i8* null, i8* null)
2929 ret void
3030 }
31 ; CHECK: llvm.recoverframeallocation first argument must be function defined in this module
31 ; CHECK: llvm.framerecover first argument must be function defined in this module
3232
3333 @global = constant i8 0
3434
3535 declare void @declaration()
3636
3737 define internal void @i() {
38 call i8* @llvm.recoverframeallocation(i8* @global, i8* null)
38 call i8* @llvm.framerecover(i8* @global, i8* null)
3939 ret void
4040 }
41 ; CHECK: llvm.recoverframeallocation first argument must be function defined in this module
41 ; CHECK: llvm.framerecover first argument must be function defined in this module
4242
4343 define internal void @j() {
44 call i8* @llvm.recoverframeallocation(i8* bitcast(void()* @declaration to i8*), i8* null)
44 call i8* @llvm.framerecover(i8* bitcast(void()* @declaration to i8*), i8* null)
4545 ret void
4646 }
47 ; CHECK: llvm.recoverframeallocation first argument must be function defined in this module
47 ; CHECK: llvm.framerecover first argument must be function defined in this module