Skip to content
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

Adapt opaque pointer determination for LLVM 16. #379

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions test/interop_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@
using LLVM.Interop
using InteractiveUtils

# many of these tests don't use explicit contexts, as they rely on high-level functionality.
# that functionality should be using default context options, so query those here.
supports_typed_ptrs = @dispose ctx=Context() begin
supports_typed_pointers(ctx)
# the tests below use Julia's JIT, so check whether it uses opaque pointers or not.
# note that the default context used in generated functions may behave differently,
# but that does not matter (as typed IR can be linked with opaque IR).
supports_typed_ptrs = let
ir = sprint(io->code_llvm(io, unsafe_load, Tuple{Ptr{Int}}))
if occursin(r"load i64, i64\* .+, align 1", ir)
true
elseif occursin(r"load i64, ptr .+, align 1", ir)
false
else
error("could not determine whether Julia uses typed pointers")
end
end

@testset "base" begin
Expand Down
15 changes: 15 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ end
using InteractiveUtils
@info "System information:\n" * sprint(io->versioninfo(io))

ctx_typed_pointers = Context() do ctx
supports_typed_pointers(ctx)
end
julia_typed_pointers = let
ir = sprint(io->code_llvm(io, unsafe_load, Tuple{Ptr{Int}}))
if occursin(r"load i64, i64\* .+, align 1", ir)
true
elseif occursin(r"load i64, ptr .+, align 1", ir)
false
else
error("could not determine whether Julia uses typed pointers")
end
end
@info "Pointer settings: Julia uses $(julia_typed_pointers ? "typed" : "opaque") pointers, default contexts use $(ctx_typed_pointers ? "typed" : "opaque") pointers"

worker_init_expr = quote
using LLVM

Expand Down
Loading