Rodney M. Bates via llvm-dev
2017-Aug-24 20:43 UTC
[llvm-dev] How do set 'nest' addribute in an indirect call?
On 08/24/2017 09:40 AM, Tim Northover wrote:> On 17 August 2017 at 15:15, Rodney M. Bates via llvm-dev > <llvm-dev at lists.llvm.org> wrote: >> For an indirect call, i.e., on a function whose address is runtime variable, >> I can't find any place/way to attach this attribute. LLVMAddAttribute >> won't take a type. > > In the C++ API you'd add the attribute to the CallInst. I've not used > any of the wrappers, but I think you might get what you want via > LLVMAddCallSiteAttribute.I don't find LLVMAddCallSiteAttribute or anything similar in include/llvm. (I am using 3.6.1) I do see llvm::CallInst::addAttribute /// addAttribute - adds the attribute to the list of attributes. void addAttribute(unsigned i, Attribute::AttrKind attr); Is 'i' the number of the parameter that gets the attribute? This matters for 'nest'. Is it zero-origin numbering, left-to-right? I have an out-of-tree binding already for a small set of things not in Core.h, and it's not hard to add things in ones & twos.> > Cheers. > > Tim. >-- Rodney Bates rodney.m.bates at acm.org
Tim Northover via llvm-dev
2017-Aug-24 20:48 UTC
[llvm-dev] How do set 'nest' addribute in an indirect call?
On 24 August 2017 at 13:43, Rodney M. Bates <rodney_bates at lcwb.coop> wrote:> I don't find LLVMAddCallSiteAttribute or anything similar in include/llvm. > (I am using 3.6.1)It may have been added since then, it definitely exists in trunk.> /// addAttribute - adds the attribute to the list of attributes. > void addAttribute(unsigned i, Attribute::AttrKind attr); > > Is 'i' the number of the parameter that gets the attribute? This matters > for 'nest'. Is it zero-origin numbering, left-to-right?I believe 0 is the return and args start at 1 (see include/llvm/IR/Attributes.h, especially the AttrIndex enum).> I have an out-of-tree binding already for a small set of things not in > Core.h, and it's not hard to add things in ones & twos.Oh good, that'll make using a slightly older version less of a disaster and more an inconvenience. Cheers. Tim.
Rodney M. Bates via llvm-dev
2017-Aug-25 01:57 UTC
[llvm-dev] How do set 'nest' addribute in an indirect call?
On 08/24/2017 03:48 PM, Tim Northover wrote:> On 24 August 2017 at 13:43, Rodney M. Bates <rodney_bates at lcwb.coop> wrote: >> I don't find LLVMAddCallSiteAttribute or anything similar in include/llvm. >> (I am using 3.6.1) > > It may have been added since then, it definitely exists in trunk. >Looking to see how to write a binding for CallInst::addAttr, I came across LLVMAddInstrAttribute. Tried it out and it did want I want. It's a little surprising, because it unwraps its operand to an Instruction, a superclass of CallInstr. But I'm happy to let that go uninvestigated. Thanks for the help. Putting it on starting from the CallInstr instead of directly on a parameter was the breakout info for me.>> /// addAttribute - adds the attribute to the list of attributes. >> void addAttribute(unsigned i, Attribute::AttrKind attr); >> >> Is 'i' the number of the parameter that gets the attribute? This matters >> for 'nest'. Is it zero-origin numbering, left-to-right? > > I believe 0 is the return and args start at 1 (see > include/llvm/IR/Attributes.h, especially the AttrIndex enum). > >> I have an out-of-tree binding already for a small set of things not in >> Core.h, and it's not hard to add things in ones & twos. > > Oh good, that'll make using a slightly older version less of a > disaster and more an inconvenience. > > Cheers. > > Tim. >-- Rodney Bates rodney.m.bates at acm.org