<p dir="ltr">__builtin_apply is an abomination. Even in GCC it is held to have been a bad idea. </p>
<p dir="ltr">--eric</p>
<div class="gmail_quote">On Oct 1, 2013 10:03 PM, "reed kotler" <<a href="mailto:rkotler@mips.com">rkotler@mips.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF">
why does clang not support builtin_apply?<br>
<br>
<h3>6.5 Constructing Function Calls</h3>
<p style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:start;font-style:normal;font-weight:normal;line-height:normal;text-transform:none;font-size:medium;white-space:normal;font-family:'Times New Roman';word-spacing:0px">
<a name="141778ce48ba00f4_index-constructing-calls-2554"></a><a name="141778ce48ba00f4_index-forwarding-calls-2555"></a>Using the built-in
functions described below, you can record the arguments a function
received, and call another function with the same arguments,
without knowing the number or types of the arguments.</p>
<p style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:start;font-style:normal;font-weight:normal;line-height:normal;text-transform:none;font-size:medium;white-space:normal;font-family:'Times New Roman';word-spacing:0px">
You can also
record the return value of that function call, and later return
that value, without knowing what data type the function tried to
return (as long as your caller expects that data type).</p>
<p style="text-indent:0px;letter-spacing:normal;font-variant:normal;text-align:start;font-style:normal;font-weight:normal;line-height:normal;text-transform:none;font-size:medium;white-space:normal;font-family:'Times New Roman';word-spacing:0px">
However, these
built-in functions may interact badly with some sophisticated
features or other extensions of the language. It is, therefore,
not recommended to use them outside very simple functions acting
as mere forwarders for their arguments.</p>
<div>— Built-in
Function: void *<span> </span><b>__builtin_apply_args</b><span> </span>()<var><a name="141778ce48ba00f4_index-g_t_005f_005fbuiltin_005fapply_005fargs-2556"></a></var><br>
<blockquote>
<p>This built-in function returns a pointer to data describing
how to perform a call with the same arguments as are passed to
the current function.</p>
<p>The function saves the arg pointer register, structure value
address, and all registers that might be used to pass
arguments to a function into a block of memory allocated on
the stack. Then it returns the address of that block.</p>
</blockquote>
</div>
<div>— Built-in
Function: void *<span> </span><b>__builtin_apply</b><span> </span>(<var>void<span> </span></var>(<var>*function</var>)()<var>,
void *arguments, size_t size</var>)<var><a name="141778ce48ba00f4_index-g_t_005f_005fbuiltin_005fapply-2557"></a></var><br>
<blockquote>
<p>This built-in function invokes<span> </span><var>function</var><span> </span>with a copy of the
parameters described by<span> </span><var>arguments</var><span> </span>and<span> </span><var>size</var>.</p>
<p>The value of<span> </span><var>arguments</var><span> </span>should be the value
returned by<span> </span><code>__builtin_apply_args</code>.
The argument<span> </span><var>size</var><span> </span>specifies the size of
the stack argument data, in bytes.</p>
<p>This function returns a pointer to data describing how to
return whatever value is returned by<span> </span><var>function</var>.
The data is saved in a block of memory allocated on the stack.</p>
<p>It is not always simple to compute the proper value for<span> </span><var>size</var>. The
value is used by<span> </span><code>__builtin_apply</code><span> </span>to compute the amount
of data that should be pushed on the stack and copied from the
incoming argument area.</p>
</blockquote>
</div>
<br>
<br>
</div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div>