Henning Thielemann via llvm-dev
2019-Sep-17 16:03 UTC
[llvm-dev] Attribute C-interface since LLVM-4.0
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>
Henning Thielemann via llvm-dev
2019-Sep-24 17:08 UTC
[llvm-dev] Attribute C-interface since LLVM-4.0
On Tue, 17 Sep 2019, Henning Thielemann wrote:> 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.The solution is: It must be LLVMAddCallSiteAttribute instead of LLVMAddAttributeAtIndex.