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

adjust to JuliaLang/julia#53953 #289

Merged
merged 1 commit into from
Apr 9, 2024
Merged
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
25 changes: 5 additions & 20 deletions src/stage2/interpreter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,13 @@ Cthulhu.get_cursor(c::ADCursor, cs::Cthulhu.Callsite) = Cthulhu.get_cursor(c, cs
Cthulhu.get_cursor(c::ADCursor, callinfo) = ADCursor(c.level, Cthulhu.get_mi(callinfo))
=#


struct ADGraph
code::OffsetVector{Dict{MethodInstance, Any}}
msgs::Vector{Tuple{Int, MethodInstance, Int, String}}
entry_mi::MethodInstance
end
entrypoint(graph::ADGraph) = ADCursor(0, graph.entry_mi)

#=
Compiler3.has_codeinfo(graph::ADGraph, cursor::ADCursor) =
lastindex(graph.code) >= cursor.level && haskey(graph.code[cursor.level], cursor.mi)
function Compiler3.get_codeinstance(graph::ADGraph, cursor::ADCursor)
return graph.code[cursor.level][cursor.mi]
end
=#

using Core: MethodInstance, CodeInstance
using .CC: AbstractInterpreter, ArgInfo, Effects, InferenceResult, InferenceState,
IRInterpretationState, NativeInterpreter, OptimizationState, StmtInfo, WorldRange
Expand Down Expand Up @@ -275,23 +266,17 @@ CC.may_compress(ei::ADInterpreter) = false
CC.may_discard_trees(ei::ADInterpreter) = false

function CC.add_remark!(interp::ADInterpreter, sv::InferenceState, msg)
key = CC.any(sv.result.overridden_by_const) ? sv.result : sv.linfo
key = (@static VERSION v"1.12.0-DEV.317" ? CC.is_constproped(sv) : CC.any(sv.result.overridden_by_const)) ? sv.result : sv.linfo
push!(get!(Cthulhu.PC2Remarks, interp.remarks[interp.current_level], key), sv.currpc=>msg)
end

# TODO: `get_remarks` should get a cursor?
Cthulhu.get_remarks(interp::ADInterpreter, key::Union{MethodInstance,InferenceResult}) = get(interp.remarks[interp.current_level], key, nothing)

#=
function CC.const_prop_heuristic(interp::AbstractInterpreter, method::Method, mi::MethodInstance)
return true
end
=#

function CC.finish(state::InferenceState, interp::ADInterpreter)
res = @invoke CC.finish(state::InferenceState, interp::AbstractInterpreter)
key = CC.any(state.result.overridden_by_const) ? state.result : state.linfo
interp.unopt[interp.current_level][key] = Cthulhu.InferredSource(state)
function CC.finish(sv::InferenceState, interp::ADInterpreter)
res = @invoke CC.finish(sv::InferenceState, interp::AbstractInterpreter)
key = (@static VERSION v"1.12.0-DEV.317" ? CC.is_constproped(sv) : CC.any(sv.result.overridden_by_const)) ? sv.result : sv.linfo
interp.unopt[interp.current_level][key] = Cthulhu.InferredSource(sv)
return res
end

Expand Down
Loading