Skip to content

llvmlite opaque pointer support #900

Open
@folded

Description

@folded

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 if self is a global value.
  • Type._get_ll_pointer_type becomes Type._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 replace get_pointee_abi_alignment
  • (with deprecation schedule) remove LLVMPY_GetElementType, LLVMPY_ABISizeOfElementType and LLVMPY_ABIAlignmentOfElementType and associated python code.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionAn issue requiring discussionneedtriageNeeds to be triaged further

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions