GlobalVariable class missing 'attributes' parameter
The GlobalVariable class in llvmlite does not support setting attributes on global variables, which is a feature available in LLVM IR.
The GlobalVariable class constructor and instance do not have an attributes parameter or property currently:
https://github.com/numba/llvmlite/blob/7c0e103ffeab6d8d877d8c90cde5fd0aa7be890c/llvmlite/ir/values.py#L789
Thanks for the feature request! This seems like a good feature to be able to use. We would like to implement it, but probably won't have the time to do so in time for the next release; I'm putting it in the 0.47 milestone, with the aim of implementing this after the next release.
Leaving note for implementor:
We should try to model the python API like the LLVM C-API
Attribute insertion: https://llvm.org/doxygen/group__LLVMCCoreValueFunction.html
LLVM_C_ABI void LLVMAddAttributeAtIndex (LLVMValueRef F, LLVMAttributeIndex Idx, LLVMAttributeRef A)
LLVM_C_ABI unsigned LLVMGetAttributeCountAtIndex (LLVMValueRef F, LLVMAttributeIndex Idx)
LLVM_C_ABI void LLVMGetAttributesAtIndex (LLVMValueRef F, LLVMAttributeIndex Idx, LLVMAttributeRef *Attrs)
LLVM_C_ABI LLVMAttributeRef LLVMGetEnumAttributeAtIndex (LLVMValueRef F, LLVMAttributeIndex Idx, unsigned KindID)
LLVM_C_ABI LLVMAttributeRef LLVMGetStringAttributeAtIndex (LLVMValueRef F, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
LLVM_C_ABI void LLVMRemoveEnumAttributeAtIndex (LLVMValueRef F, LLVMAttributeIndex Idx, unsigned KindID)
LLVM_C_ABI void LLVMRemoveStringAttributeAtIndex (LLVMValueRef F, LLVMAttributeIndex Idx, const char *K, unsigned KLen)
LLVM_C_ABI void LLVMAddTargetDependentFunctionAttr (LLVMValueRef Fn, const char *A, const char *V)
Attribute creation: https://llvm.org/doxygen/group__LLVMCCoreContext.html
LLVM_C_ABI unsigned LLVMGetEnumAttributeKindForName (const char *Name, size_t SLen)
LLVM_C_ABI unsigned LLVMGetLastEnumAttributeKind (void)
LLVM_C_ABI LLVMAttributeRef LLVMCreateEnumAttribute (LLVMContextRef C, unsigned KindID, uint64_t Val)
LLVM_C_ABI unsigned LLVMGetEnumAttributeKind (LLVMAttributeRef A)
LLVM_C_ABI uint64_t LLVMGetEnumAttributeValue (LLVMAttributeRef A)
LLVM_C_ABI LLVMAttributeRef LLVMCreateTypeAttribute (LLVMContextRef C, unsigned KindID, LLVMTypeRef type_ref)
LLVM_C_ABI LLVMTypeRef LLVMGetTypeAttributeValue (LLVMAttributeRef A)
LLVM_C_ABI LLVMAttributeRef LLVMCreateConstantRangeAttribute (LLVMContextRef C, unsigned KindID, unsigned NumBits, const uint64_t LowerWords[], const uint64_t UpperWords[])
LLVM_C_ABI LLVMAttributeRef LLVMCreateStringAttribute (LLVMContextRef C, const char *K, unsigned KLength, const char *V, unsigned VLength)
LLVM_C_ABI const char * LLVMGetStringAttributeKind (LLVMAttributeRef A, unsigned *Length)
LLVM_C_ABI const char * LLVMGetStringAttributeValue (LLVMAttributeRef A, unsigned *Length)
LLVM_C_ABI LLVMBool LLVMIsEnumAttribute (LLVMAttributeRef A)
LLVM_C_ABI LLVMBool LLVMIsStringAttribute (LLVMAttributeRef A)