Implement feature for disabling opaque pointers on LLVM 15 and 16 #570
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request implements support for using typed pointers in LLVM 15. This is implemented by several steps:
typed-pointers
to distinguish APIs for typed vs opaque pointersContext
creationtyped-pointers
feature dependency on all LLVM versions that only have typed pointer support (i.e. LLVM 4-14)#[cfg(...)]
blocks to usefeature = "typed-pointers"
instead of version guards for pointer-related APIslib.rs
to ensure that thetyped-pointers
feature can only be enabled in LLVM 15-16Note that previous defaults are still present - LLVM 15 and 16 still uses opaque pointers by default, and will only switch to typed pointers if the
typed-pointers
feature is enabled.Some points of note or for discussion with regards to the current implementation:
Builder::build_load
, where the typed pointer version of this API callsLLVMBuildLoad
while the opaque pointer version callsLLVMBuildLoad2
.13-1615-16, although only LLVM 15 officially supports both. Should I also expand the scope of this PR to includeopt-in into opaque pointers in LLVM 13-14, as well asopt-out out of opaque pointers in LLVM 16?LLVMContextSetOpaquePointers
is only available in LLVM 15-16, so please disregard my message regarding LLVM 13-14.Related Issue
#489
How This Has Been Tested
This PR is tested using:
AFAICT all tests (including doctests) pass with LLVM 15 and 16 under both opaque pointer and typed pointer modes.
Checklist