Skip to content

Commit abb4cdd

Browse files
committed
run abstract interpretation over deferred code
1 parent d30ceb0 commit abb4cdd

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

src/jlgen.jl

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,27 @@ function CC.concrete_eval_eligible(interp::GPUInterpreter,
435435
return ret
436436
end
437437

438+
struct DeferredCallInfo <: CC.CallInfo
439+
rt::DataType
440+
info::CC.CallInfo
441+
end
442+
438443
function CC.abstract_call_known(interp::GPUInterpreter, @nospecialize(f),
439444
arginfo::CC.ArgInfo, si::CC.StmtInfo, sv::CC.AbsIntState,
440445
max_methods::Int = CC.get_max_methods(interp, f, sv))
441-
if f === var"gpuc.deferred" ||
442-
f === var"gpuc.lookup"
443-
return CC.CallMeta(Ptr{Cvoid}, Union{}, CC.Effects(), CC.NoCallInfo())
446+
(; fargs, argtypes) = arginfo
447+
if f === var"gpuc.deferred"
448+
argvec = argtypes[2:end]
449+
call = CC.abstract_call(interp, CC.ArgInfo(nothing, argvec), si, sv, max_methods)
450+
callinfo = DeferredCallInfo(call.rt, call.info)
451+
@static if VERSION < v"1.11.0-"
452+
return CC.CallMeta(Ptr{Cvoid}, CC.Effects(), callinfo)
453+
else
454+
return CC.CallMeta(Ptr{Cvoid}, Union{}, CC.Effects(), callinfo)
455+
end
456+
end
457+
if f === var"gpuc.lookup"
458+
error("Unimplemented")
444459
end
445460
return @invoke CC.abstract_call_known(interp::CC.AbstractInterpreter, f,
446461
arginfo::CC.ArgInfo, si::CC.StmtInfo, sv::CC.AbsIntState,

test/native_tests.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,20 @@ end
162162
ir = fetch(t)
163163
@test contains(ir, r"add i64 %\d+, 3")
164164
end
165+
166+
@testset "deferred" begin
167+
@gensym child kernel unrelated
168+
@eval @noinline $child(i) = i
169+
@eval $kernel(i) = GPUCompiler.var"gpuc.deferred"($child, i)
170+
171+
# smoke test
172+
job, _ = Native.create_job(eval(kernel), (Int64,))
173+
174+
ci, rt = only(GPUCompiler.code_typed(job))
175+
@test rt === Ptr{Cvoid}
176+
177+
ir = sprint(io->GPUCompiler.code_llvm(io, job))
178+
end
165179
end
166180

167181
############################################################################################

0 commit comments

Comments
 (0)