james woodyatt
2010-Dec-21 06:58 UTC
[LLVMdev] the optional function return attribute and the llvm-c bindings
everyone-- Is it my imagination, or is there no way in LLVM 2.8 (or current trunk) to use the facilities defined in <llvm-c/Core.h> to get or set the optional return parameter attribute on a function value? All the functions in the "Operations on parameters" parameters section actually seem to work only on the function arguments and not the return parameter. Is this intentional? What should I do if I need to get or set the return parameter attributes of a function from OCaml? — j h woodyatt <jhw at conjury.org> http://jhw.dreamwidth.org/
Duncan Sands
2010-Dec-21 08:43 UTC
[LLVMdev] the optional function return attribute and the llvm-c bindings
Hi James,> Is it my imagination, or is there no way in LLVM 2.8 (or current trunk) to use the facilities defined in<llvm-c/Core.h> to get or set the optional return parameter attribute on a function value? > > All the functions in the "Operations on parameters" parameters section actually seem to work only on the function arguments and not the return parameter. Is this intentional? What should I do if I need to get or set the return parameter attributes of a function from OCaml?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. Ciao, Duncan.
james woodyatt
2010-Dec-21 19:33 UTC
[LLVMdev] the optional function return attribute and the llvm-c bindings
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/
Apparently Analagous Threads
- [LLVMdev] the optional function return attribute and the llvm-c bindings
- [LLVMdev] the optional function return attribute and the llvm-c bindings
- [LLVMdev] the optional function return attribute and the llvm-c bindings
- [LLVMdev] git Status
- [LLVMdev] ocaml bindings