diff --git a/src/execution.jl b/src/execution.jl index e501216e..2add70e9 100644 --- a/src/execution.jl +++ b/src/execution.jl @@ -114,7 +114,7 @@ end obj = nothing # fast path: find an applicable CodeInstance and see if we have compiled it before - ci = ci_cache_lookup(ci_cache(job), src, world, world)::Union{Nothing,CodeInstance} + ci = ci_cache_lookup(ci_cache(job), src, world, world; allow_uninferred=true)::Union{Nothing,CodeInstance} if ci !== nothing && haskey(cache, ci) obj = cache[ci] end @@ -130,7 +130,7 @@ end end obj = linker(job, asm) - ci = ci_cache_lookup(ci_cache(job), src, world, world)::CodeInstance + ci = ci_cache_lookup(ci_cache(job), src, world, world; allow_uninferred=true)::CodeInstance cache[ci] = obj end diff --git a/src/jlgen.jl b/src/jlgen.jl index 2a54c038..13d2c75a 100644 --- a/src/jlgen.jl +++ b/src/jlgen.jl @@ -376,12 +376,6 @@ function CC.getindex(wvc::WorldView{CodeCache}, mi::MethodInstance) end function CC.setindex!(wvc::WorldView{CodeCache}, ci::CodeInstance, mi::MethodInstance) - src = if ci.inferred isa Vector{UInt8} - ccall(:jl_uncompress_ir, Any, (Any, Ptr{Cvoid}, Any), - mi.def, C_NULL, ci.inferred) - else - ci.inferred - end CC.setindex!(wvc.cache, ci, mi) end @@ -410,10 +404,10 @@ function ci_cache_populate(interp, cache, mi, min_world, max_world) return ci end -function ci_cache_lookup(cache, mi, min_world, max_world) +function ci_cache_lookup(cache, mi, min_world, max_world; allow_uninferred=false) wvc = WorldView(cache, min_world, max_world) ci = CC.get(wvc, mi, nothing) - if ci !== nothing && ci.inferred === nothing + if ci !== nothing && (!allow_uninferred && ci.inferred === nothing) # if for some reason we did end up with a codeinfo without inferred source, e.g., # because of calling `Base.return_types` which only sets rettyp, pretend we didn't # run inference so that we re-infer now and not during codegen (which is disallowed) @@ -613,5 +607,15 @@ function compile_method_instance(@nospecialize(job::CompilerJob)) end end + if job.config.kernel + # Don't cache the top-level inference result. + ci = compiled[job.source].ci +@static if VERSION < v"1.9.0" + ci.inferred = nothing +else + Base.@atomic :release ci.inferred = nothing +end + end + return llvm_mod, compiled end