[llvm-dev] How do set 'nest' addribute in an indirect call?

Rodney M. Bates via llvm-dev llvm-dev at lists.llvm.org
Thu Aug 24 18:57:18 PDT 2017



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


More information about the llvm-dev mailing list