Skip to content
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
7 changes: 6 additions & 1 deletion src/jlgen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,12 @@ end

CC.may_optimize(interp::GPUInterpreter) = true
CC.may_compress(interp::GPUInterpreter) = true
CC.may_discard_trees(interp::GPUInterpreter) = true
# before Julia 1.12, codegen looks up callees in our cache itself (see
# `compile_method_instance`), and re-infers those whose inferred source was discarded
# (non-inlineable functions with a non-compileable signature, e.g. `@nospecialize` helpers)
# with Julia's native interpreter, bypassing our method tables. keep the source of
# everything we infer there; later versions recover it using our interpreter.
CC.may_discard_trees(interp::GPUInterpreter) = VERSION >= v"1.12.0-DEV.1823"
@static if VERSION <= v"1.12.0-DEV.1531"
CC.verbose_stmt_info(interp::GPUInterpreter) = false
end
Expand Down
26 changes: 8 additions & 18 deletions test/native.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1860,25 +1860,15 @@ end
kernel(a, b) = (unsafe_store!(b, nospecialize_child(a)); return)
end

if VERSION >= v"1.11-"
# Preserve the inferred specialization despite @nospecialize.
@test @filecheck begin
@check_label "define {{.*}} @{{(julia|j)_kernel_[0-9]+}}"
@check_not "jl_invoke"
@check_not "apply_generic"
Native.code_llvm(mod.kernel, Tuple{Int,Ptr{Int}}; dump_module=true)
end
Native.code_execution(mod.kernel, Tuple{Int,Ptr{Int}})
else
# 1.10 still emits a dynamic invoke for this @nospecialize call
@test_throws_message(InvalidIRError,
Native.code_execution(mod.kernel, Tuple{Int,Ptr{Int}})) do msg
occursin("invalid LLVM IR", msg) &&
occursin(GPUCompiler.DYNAMIC_CALL, msg) &&
occursin("call to nospecialize_child", msg) &&
occursin(r"\[\d+\] kernel", msg)
end
# Preserve the inferred specialization despite @nospecialize (on 1.10, this relies on
# keeping the inferred source, see `may_discard_trees`)
@test @filecheck begin
@check_label "define {{.*}} @{{(julia|j)_kernel_[0-9]+}}"
@check_not "jl_invoke"
@check_not "apply_generic"
Native.code_llvm(mod.kernel, Tuple{Int,Ptr{Int}}; dump_module=true)
end
Native.code_execution(mod.kernel, Tuple{Int,Ptr{Int}})
end

@testset "dynamic call (apply)" begin
Expand Down
Loading