Skip to content

Commit f80db12

Browse files
committed
Adjust to recent compiler changes
1 parent 4045157 commit f80db12

File tree

5 files changed

+42
-48
lines changed

5 files changed

+42
-48
lines changed

Manifest.toml

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/analysis/compiler.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,9 @@ function dae_result_for_inst(interp, inst::CC.Instruction)
442442
info = inst[:info]
443443
stmt = inst[:stmt]
444444
mi = stmt.args[1]
445+
if isa(info, Diffractor.FRuleCallInfo) && info.frule_call.rt === Const(nothing)
446+
info = info.info
447+
end
445448
if isa(info, CC.ConstCallInfo)
446449
if length(info.results) != 1
447450
# TODO: When does this happen? Union split?

src/analysis/interpreter.jl

Lines changed: 18 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using Core: CodeInfo, MethodInstance, CodeInstance, SimpleVector, MethodMatch, MethodTable
55
using .CC: AbstractInterpreter, NativeInterpreter, InferenceParams, OptimizationParams,
66
InferenceResult, InferenceState, OptimizationState, WorldRange, WorldView, ArgInfo,
7-
StmtInfo, MethodCallResult, ConstCallResults, ConstPropResult, MethodTableView,
7+
StmtInfo, MethodCallResult, ConstCallResult, ConstPropResult, MethodTableView,
88
CachedMethodTable, InternalMethodTable, OverlayMethodTable, CallMeta, CallInfo,
99
IRCode, LazyDomtree, IRInterpretationState, set_inlineable!, block_for_inst,
1010
BitSetBoundedMinPrioritySet, AbsIntState, Future
@@ -117,7 +117,7 @@ struct DAEInterpreter <: AbstractInterpreter
117117
ipo_analysis_mode::Bool = false,
118118
in_analysis::Bool = false)
119119
if code_cache === nothing
120-
code_cache = get_code_cache(method_table, ipo_analysis_mode)
120+
code_cache = get_code_cache(world, method_table, ipo_analysis_mode)
121121
end
122122
if method_table !== nothing
123123
method_table = CachedMethodTable(OverlayMethodTable(world, method_table))
@@ -315,13 +315,10 @@ end
315315
return Future{MethodCallResult}(mret, interp, sv) do ret, interp, sv
316316
edge = ret.edge
317317
if edge !== nothing
318-
cache = CC.get(CC.code_cache(interp), edge, nothing)
319-
if cache !== nothing
320-
src = @atomic :monotonic cache.inferred
321-
if isa(src, DAECache)
322-
info = src.info
323-
merge_daeinfo!(interp, sv.result, info)
324-
end
318+
src = @atomic :monotonic edge.inferred
319+
if isa(src, DAECache)
320+
info = src.info
321+
merge_daeinfo!(interp, sv.result, info)
325322
end
326323
end
327324
return ret
@@ -330,11 +327,11 @@ end
330327

331328
@override function CC.const_prop_call(interp::DAEInterpreter,
332329
mi::MethodInstance, result::MethodCallResult, arginfo::ArgInfo,
333-
sv::InferenceState, concrete_eval_result::Union{Nothing,ConstCallResults})
330+
sv::InferenceState, concrete_eval_result::Union{Nothing,ConstCallResult})
334331
ret = @invoke CC.const_prop_call(interp::AbstractInterpreter,
335332
mi::MethodInstance, result::MethodCallResult, arginfo::ArgInfo,
336-
sv::InferenceState, concrete_eval_result::Union{Nothing,ConstCallResults})
337-
if isa(ret, ConstCallResults)
333+
sv::InferenceState, concrete_eval_result::Union{Nothing,ConstCallResult})
334+
if isa(ret, ConstCallResult)
338335
const_result = ret.const_result::ConstPropResult
339336
info = interp.dae_cache[const_result.result]
340337
merge_daeinfo!(interp, sv.result, info)
@@ -353,26 +350,20 @@ struct DAECache
353350
new(inferred, ir, info)
354351
end
355352

356-
@override CC.transform_result_for_cache(interp::DAEInterpreter,
357-
mi::MethodInstance, valid_worlds::WorldRange, result::InferenceResult, cond::Bool) =
358-
_transform_result_for_cache(interp, mi, valid_worlds, result, cond)
359-
360-
function _transform_result_for_cache(interp::DAEInterpreter,
361-
mi::MethodInstance, valid_worlds::WorldRange, result::InferenceResult, cond::Bool=false)
353+
function CC.transform_result_for_cache(interp::DAEInterpreter, result::InferenceResult)
362354
src = result.src
363355
if isa(src, DAECache)
364356
return src
365357
end
366-
inferred = @invoke CC.transform_result_for_cache(interp::AbstractInterpreter,
367-
mi::MethodInstance, valid_worlds::WorldRange, result::InferenceResult, cond::Bool)
358+
inferred = @invoke CC.transform_result_for_cache(interp::AbstractInterpreter, result)
368359
return DAECache(inferred, nothing, interp.dae_cache[result])
369360
end
370361

371362
# inlining
372363
# --------
373364

374365
function dae_inlining_policy(@nospecialize(src), @nospecialize(info::CallInfo), raise::Bool=true)
375-
if isa(info, Diffractor.FRuleCallInfo)
366+
if isa(info, Diffractor.FRuleCallInfo) && info.frule_call.rt !== Const(nothing)
376367
return nothing
377368
end
378369
osrc = src
@@ -502,13 +493,10 @@ end
502493
result::MethodCallResult, si::StmtInfo, sv::InferenceState, force::Bool)
503494
edge = result.edge
504495
if edge !== nothing
505-
cache = CC.get(CC.code_cache(interp), edge, nothing)
506-
if cache !== nothing
507-
src = @atomic :monotonic cache.inferred
508-
if isa(src, DAECache)
509-
src.info.has_dae_intrinsics && return true
510-
src.info.has_scoperead && return true
511-
end
496+
src = @atomic :monotonic edge.inferred
497+
if isa(src, DAECache)
498+
src.info.has_dae_intrinsics && return true
499+
src.info.has_scoperead && return true
512500
end
513501
end
514502
return @invoke CC.const_prop_rettype_heuristic(interp::AbstractInterpreter,
@@ -1052,7 +1040,7 @@ end
10521040
using Cthulhu
10531041

10541042
function Cthulhu.get_optimized_codeinst(interp::DAEInterpreter, curs::Cthulhu.CthulhuCursor)
1055-
interp.code_cache.cache[curs.mi]
1043+
CC.getindex(CC.code_cache(interp), curs.mi)
10561044
end
10571045

10581046
function Cthulhu.lookup(interp::DAEInterpreter, curs::Cthulhu.CthulhuCursor, optimize::Bool)
@@ -1109,7 +1097,7 @@ function lookup_optimized(interp::DAEInterpreter, mi::MethodInstance, allow_no_s
11091097
end
11101098

11111099
Cthulhu.can_descend(interp::DAEInterpreter, @nospecialize(key), optimize::Bool) =
1112-
haskey(optimize ? interp.code_cache.cache : interp.unopt, key)
1100+
optimize ? CC.haskey(CC.code_cache(interp), key) : haskey(interp.unopt, key)
11131101

11141102
# TODO: Why does Cthulhu have this separately from the lookup logic, which already
11151103
# returns effects

src/transform/common.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,16 @@ end
5151
function remap_info(remap_ir!, info)
5252
# TODO: This is pretty aweful, but it works for now.
5353
# It'll go away when we switch to IPO.
54+
if isa(info, Diffractor.FRuleCallInfo) && info.frule_call.rt === Const(nothing)
55+
info = info.info
56+
end
5457
isa(info, CC.ConstCallInfo) || return info
5558
results = map(info.results) do result
5659
result === nothing && return result
5760
if isa(result, CC.SemiConcreteResult)
5861
let ir = copy(result.ir)
5962
remap_ir!(ir)
60-
CC.SemiConcreteResult(result.mi, ir, result.effects, result.spec_info)
63+
CC.SemiConcreteResult(result.edge, ir, result.effects, result.spec_info)
6164
end
6265
elseif isa(result, CC.ConstPropResult)
6366
if isa(result.result.src, DAECache)
@@ -76,10 +79,9 @@ function widen_extra_info!(ir)
7679
for i = 1:length(ir.stmts)
7780
info = ir.stmts[i][:info]
7881
if isa(info, Diffractor.FRuleCallInfo)
79-
ir.stmts[i][:info] = info.info
80-
else
81-
ir.stmts[i][:info] = remap_info(widen_extra_info!, info)
82+
info = info.info
8283
end
84+
ir.stmts[i][:info] = remap_info(widen_extra_info!, info)
8385
inst = ir.stmts[i][:inst]
8486
if isa(inst, PiNode)
8587
ir.stmts[i][:inst] = PiNode(inst.val, widenconst(inst.typ))

test/ipo.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module ipo
33
using Test
44
using DAECompiler
55
using DAECompiler.Intrinsics
6+
using DAECompiler.Intrinsics: state_ddt
67
using SciMLBase, OrdinaryDiffEq, Sundials
78

89
include(joinpath(Base.pkgdir(DAECompiler), "test", "testutils.jl"))

0 commit comments

Comments
 (0)