[llvm-dev] Attribute C-interface since LLVM-4.0

Henning Thielemann via llvm-dev llvm-dev at lists.llvm.org
Tue Sep 17 09:03:58 PDT 2019


I try to guess how the new Attribute C-interface since LLVM-3.9 works, but 
it seems I have not guessed correctly so far. See attached example. First 
file uses the API before LLVM-3.9 and second file uses the API starting 
with LLVM-3.9. Essentially I replaced

   LLVMAddInstrAttribute
     (call_exp, LLVMAttributeFunctionIndex, LLVMReadNoneAttribute);

by

   unsigned attrKind = LLVMGetEnumAttributeKindForName("readnone", 8);
   LLVMContextRef context = LLVMGetGlobalContext();
   LLVMAttributeRef attr = LLVMCreateEnumAttribute (context, attrKind, 0);
   LLVMAddAttributeAtIndex(call_exp, LLVMAttributeFunctionIndex, attr);

But in the generated Bitcode file no "readnone" attribute shows up.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: callattribute.c
Type: text/x-csrc
Size: 1970 bytes
Desc: 
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190917/40525b7f/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: callattribute.c
Type: text/x-csrc
Size: 2126 bytes
Desc: 
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190917/40525b7f/attachment-0001.c>


More information about the llvm-dev mailing list