llvmlite
llvmlite copied to clipboard
llvmlite opaque pointer support
The plan of record is that non-opaque pointer support remains in LLVM 16 (with decreasing test coverage) and will be removed in LLVM 17: https://reviews.llvm.org/D140487
The direct breakages I saw when opaque pointers are enabled by default are caused by llvmlite's method of getting ABI size and alignment for values, which it does by creating a module, declaring a global value of the right type, and then interrogating that.
Someone more knowledgeable than me pointed out "A GlobalValue's type is a pointer, but instead of GV->getType()->getElementType(), you can do GV->getValueType().", and implementing this succeeded in getting tests passing again.
I'll prepare a patch for review to close this bug, but I wanted to kick off a discussion here to make sure that what I'm proposing doesn't have other issues that I'm not aware of and maybe haven't been picked up by test cases.
Changes, in summary are:
-
ValueRef
gets@property global_value_type
, which returns the value type ifself
is a global value. -
Type._get_ll_pointer_type
becomesType._get_ll_global_value_type
and usages change like so:
- llty = self._get_ll_pointer_type(target_data, context)
- return target_data.get_pointee_abi_size(llty)
+ llty = self._get_ll_global_value_type(target_data, context)
+ return target_data.get_abi_size(llty)
- expose
LLVMABIAlignmentOfType
binding to replaceget_pointee_abi_alignment
- (with deprecation schedule) remove
LLVMPY_GetElementType
,LLVMPY_ABISizeOfElementType
andLLVMPY_ABIAlignmentOfElementType
and associated python code.