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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
authors = ["Valentin Churavy <v.churavy@gmail.com> and contributors"]
name = "Cthulhu"
uuid = "f68482b8-f384-11e8-15f7-abe071a5a75f"
version = "2.17.2"
version = "2.17.3"

[compat]
CodeTracking = "0.5, 1"
Expand Down
30 changes: 21 additions & 9 deletions src/interpreter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,6 @@ function InferredSource(state::InferenceState)
exct)
end

function cthulhu_finish(@specialize(finishfunc), state::InferenceState, interp::CthulhuInterpreter, cycleid::Int)
res = @invoke finishfunc(state::InferenceState, interp::AbstractInterpreter, cycleid::Int)
key = get_inference_key(state)
if key !== nothing
interp.unopt[key] = InferredSource(state)
end
return res
end

function create_cthulhu_source(result::InferenceResult, effects::Effects)
isa(result.src, OptimizationState) || return result.src
opt = result.src
Expand All @@ -135,7 +126,28 @@ function set_cthulhu_source!(result::InferenceResult)
result.src = create_cthulhu_source(result, result.ipo_effects)
end

@static if VERSION ≥ v"1.13-"
CC.finishinfer!(state::InferenceState, interp::CthulhuInterpreter, cycleid::Int, opt_cache::IdDict{MethodInstance, CodeInstance}) = cthulhu_finish(CC.finishinfer!, state, interp, cycleid, opt_cache)
function cthulhu_finish(@specialize(finishfunc), state::InferenceState, interp::CthulhuInterpreter, cycleid::Int, opt_cache::IdDict{MethodInstance, CodeInstance})
res = @invoke finishfunc(state::InferenceState, interp::AbstractInterpreter, cycleid::Int, opt_cache::IdDict{MethodInstance, CodeInstance})
key = get_inference_key(state)
if key !== nothing
interp.unopt[key] = InferredSource(state)
end
return res
end
else
function cthulhu_finish(@specialize(finishfunc), state::InferenceState, interp::CthulhuInterpreter, cycleid::Int)
res = @invoke finishfunc(state::InferenceState, interp::AbstractInterpreter, cycleid::Int)
key = get_inference_key(state)
if key !== nothing
interp.unopt[key] = InferredSource(state)
end
return res
end
CC.finishinfer!(state::InferenceState, interp::CthulhuInterpreter, cycleid::Int) = cthulhu_finish(CC.finishinfer!, state, interp, cycleid)
end

function CC.finish!(interp::CthulhuInterpreter, caller::InferenceState, validation_world::UInt, time_before::UInt64)
set_cthulhu_source!(caller.result)
return @invoke CC.finish!(interp::AbstractInterpreter, caller::InferenceState, validation_world::UInt, time_before::UInt64)
Expand Down