Add the llvm.frameallocate and llvm.recoverframeallocation intrinsics

These intrinsics allow multiple functions to share a single stack
allocation from one function's call frame. The function with the
allocation may only perform one allocation, and it must be in the entry
block.

Functions accessing the allocation call llvm.recoverframeallocation with
the function whose frame they are accessing and a frame pointer from an
active call frame of that function.

These intrinsics are very difficult to inline correctly, so the
intention is that they be introduced rarely, or at least very late
during EH preparation.

Reviewers: echristo, andrew.w.kaylor

Differential Revision: http://reviews.llvm.org/D6493

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225746 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Kleckner
2015-01-13 00:48:10 +00:00
parent 698be08c84
commit 221a7075cf
21 changed files with 303 additions and 4 deletions

View File

@@ -7281,6 +7281,56 @@ Note that calling this intrinsic does not prevent function inlining or
other aggressive transformations, so the value returned may not be that
of the obvious source-language caller.
'``llvm.frameallocate``' and '``llvm.recoverframeallocation``' Intrinsics
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Syntax:
"""""""
::
declare i8* @llvm.frameallocate(i32 %size)
declare i8* @llvm.recoverframeallocation(i8* %func, i8* %fp)
Overview:
"""""""""
The '``llvm.frameallocate``' intrinsic allocates stack memory at some fixed
offset from the frame pointer, and the '``llvm.recoverframeallocation``'
intrinsic applies that offset to a live frame pointer to recover the address of
the allocation. The offset is computed during frame layout of the caller of
``llvm.frameallocate``.
Arguments:
""""""""""
The ``size`` argument to '``llvm.frameallocate``' must be a constant integer
indicating the amount of stack memory to allocate. As with allocas, allocating
zero bytes is legal, but the result is undefined.
The ``func`` argument to '``llvm.recoverframeallocation``' must be a constant
bitcasted pointer to a function defined in the current module. The code
generator cannot determine the frame allocation offset of functions defined in
other modules.
The ``fp`` argument to '``llvm.recoverframeallocation``' must be a frame
pointer of a call frame that is currently live. The return value of
'``llvm.frameaddress``' is one way to produce such a value, but most platforms
also expose the frame pointer through stack unwinding mechanisms.
Semantics:
""""""""""
These intrinsics allow a group of functions to access one stack memory
allocation in an ancestor stack frame. The memory returned from
'``llvm.frameallocate``' may be allocated prior to stack realignment, so the
memory is only aligned to the ABI-required stack alignment. Each function may
only call '``llvm.frameallocate``' one or zero times from the function entry
block. The frame allocation intrinsic inhibits inlining, as any frame
allocations in the inlined function frame are likely to be at a different
offset from the one used by '``llvm.recoverframeallocation``' called with the
uninlined function.
.. _int_read_register:
.. _int_write_register: