-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add opaque pointers #468
Add opaque pointers #468
Conversation
Aren't ptrs always opaque in 16(?)+? (the version after whenever they were introduced?) One of your tests seems to confirm this since |
I think this section answers those questions: https://llvm.org/docs/OpaquePointers.html#temporarily-disabling-opaque-pointers Basically, pointers are opaque by default starting in 15+, but this behaviour can be disabled in 15 & 16, at least in |
@xlambein could you please rebase this on master? Thanks |
Not sure if it is relevant to this specific PR, but I think getting the value type of GlobalValues also matters now with opaque pointers. I just started playing with Inkwell, though, so there may be other idioms I am missing. e.g. fn get_value_type<'ctx>(global: GlobalValue<'ctx>) -> AnyTypeEnum<'ctx> {
unsafe {
AnyTypeEnum::new(llvm_sys::core::LLVMGlobalGetValueType(
global.as_value_ref(),
))
}
} |
I'm on holiday until late this month, so I'll finish this PR then :-) @nsumner That seems right, I'll take a closer look later and perhaps add it to the PR. |
05e9375
to
243c489
Compare
Rebased and added |
610607d
to
9f9b777
Compare
Any news? Still waiting for approval. |
Apologies for this taking a while, I am traveling this month and won't have much time to review until April |
Not sure why the build is failing suddenly... |
Ah, I tried updating the PR and it seems I broke something - please take a look and then we can get this merged |
8e2bf9b
to
2f63a42
Compare
@TheDan64 I've rebased and tested locally, seems to work again. |
Looks like this needs to be adjusted to handle other versions |
I've fixed that issue :-) |
@TheDan64 can you have a look? |
This looks pretty good, but needs to be updated for llvm18 |
- Add a `ptr_type` method to `Context` for LLVM >= 15.0 to get an opaque pointer type. - Deprecate the use of `ptr_type` on `*Type`. - Add a `is_opaque` method to `PointerType` to check whether the pointer is opaque (which is always true unless opaque-by-default is disabled). - Change the tests to use the new `ptr_type` method on `Context`.
ab645f3
to
3ebc763
Compare
@TheDan64 Rebased + added the necessary changes for LLVM 18. At the same time, there was a failing doctest for 18 in upstream/master that I fixed (in |
3ebc763
to
cb4cfd2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Description
All changes apply to LLVM >= 15.0.
ptr_type
method toContext
to get an opaque pointer type.ptr_type
on*Type
.is_opaque
method toPointerType
to check whether the pointer is opaque (which is always true unless opaque-by-default is disabled).ptr_type
method onContext
.Note that I haven't found a way in the C API (at least as exposed by
llvm_sys
) to disable the opaque-by-default behaviour. Because of that, I'm unsure it even makes sense to have theis_opaque
method. Because of this I haven't really documented it much, but I can add an example to the doc if needed.Related Issue
#421
How This Has Been Tested
is_opaque
, but in effect the function always returnstrue
.Breaking Changes
None yet. In the future we might want to remove the
ptr_type
method on*Type
for LLVM 17 onward, since only opaque pointers are supported.Checklist