[LLVMdev] the optional function return attribute and the llvm-c bindings
james woodyatt
jhw at conjury.org
Tue Dec 21 11:33:22 PST 2010
On Dec 21, 2010, at 00:43, Duncan Sands wrote:
>
> IIRC the function return value is considered to be the parameter with index 0.
> The function itself is considered to be the parameter with index ~0U.
Yes, that's what the documentation seems to say is the proper mode for indexing the return parameter, but when I set an attribute on the parameter with index zero, it gets applied to the first function argument and not the return parameter.
I believe the reason for this to be that LLVMGetParams() [and its cognates] all use Function::arg_iterator, which begins with the first function *argument* parameter and not the return parameter. The index argument to LLVMGetParams() is actually incremented by one when it's mapped to the index used for the Function::AttributeList member. There are separate functions for the function attributes, which are at index ~0UL, but no similar functions for handling the function return parameter attribute at index zero.
Is this intentional? What is the correct way to get and set a function return parameter attribute with C-language binding to the LLVM core?
—
j h woodyatt <jhw at conjury.org>
http://jhw.dreamwidth.org/
More information about the llvm-dev
mailing list