From 5660b85df72e154b1d2ddb6092ab5c32afe1b81d Mon Sep 17 00:00:00 2001 From: Ian Atol Date: Wed, 30 Mar 2022 15:48:20 -0700 Subject: [PATCH] Get Cthulhu working --- base/compiler/abstractinterpretation.jl | 2 +- base/compiler/ssair/irinterp.jl | 12 +++++++----- base/compiler/typeinfer.jl | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/base/compiler/abstractinterpretation.jl b/base/compiler/abstractinterpretation.jl index 36f0fda3248d6..87c66878dd825 100644 --- a/base/compiler/abstractinterpretation.jl +++ b/base/compiler/abstractinterpretation.jl @@ -806,7 +806,7 @@ function abstract_call_method_with_const_args(interp::AbstractInterpreter, resul code = get(mi_cache, mi, nothing) if code !== nothing ir = codeinst_to_ir(interp, code) - if ir !== nothing + if isa(ir, IRCode) T = ir_abstract_constant_propagation(interp, mi_cache, sv, mi, ir, arginfo.argtypes) if !isa(T, Type) || typeintersect(T, Bool) === Union{} return ConstCallResults(T, SemiConcreteResult(mi, ir, result.edge_effects), result.edge_effects) diff --git a/base/compiler/ssair/irinterp.jl b/base/compiler/ssair/irinterp.jl index 76ccc942851e0..cfda4e579b12d 100644 --- a/base/compiler/ssair/irinterp.jl +++ b/base/compiler/ssair/irinterp.jl @@ -3,9 +3,9 @@ function codeinst_to_ir(interp::AbstractInterpreter, code::CodeInstance) src = code.inferred mi = code.def - src === nothing && return src + isa(src, Union{CodeInfo, Vector{UInt8}}) || return src - if !isa(src, CodeInfo) + if isa(src, Vector{UInt8}) src = ccall(:jl_uncompress_ir, Any, (Any, Ptr{Cvoid}, Any), mi.def, C_NULL, src::Vector{UInt8})::CodeInfo end @@ -83,8 +83,10 @@ function complete!(tpdum::TwoPhaseDefUseMap) end function TwoPhaseDefUseMap(nssas::Int) - TwoPhaseDefUseMap(zeros(Int, nssas), - Int[], false) + ssa_uses = zeros(Int, nssas) + data = Int[] + complete = false + return TwoPhaseDefUseMap(ssa_uses, data, complete) end function count!(tpdum::TwoPhaseDefUseMap, arg::SSAValue) @@ -100,7 +102,7 @@ function kill_def_use!(tpdum::TwoPhaseDefUseMap, def::Int, use::Int) end end kill_def_use!(tpdum::TwoPhaseDefUseMap, def::SSAValue, use::Int) = - kill_def_use!(tpdum::TwoPhaseDefUseMap, def.id, use) + kill_def_use!(tpdum, def.id, use) function getindex(tpdum::TwoPhaseDefUseMap, idx::Int) @assert tpdum.complete diff --git a/base/compiler/typeinfer.jl b/base/compiler/typeinfer.jl index bce4b4702b5c7..fea3145b05d35 100644 --- a/base/compiler/typeinfer.jl +++ b/base/compiler/typeinfer.jl @@ -840,7 +840,7 @@ function typeinf_edge(interp::AbstractInterpreter, method::Method, @nospecialize if code isa CodeInstance # return existing rettype if the code is already inferred if code.inferred === nothing && is_stmt_inline(get_curr_ssaflag(caller)) # we already inferred this edge previously and decided to discarded the inferred code - # but the inlinear will request to use it, we re-infer it here and keep it around in the local cache + # but the inliner will request to use it, we re-infer it here and keep it around in the local cache cache = :local else effects = ipo_effects(code)