Skip to content

Commit dd0858e

Browse files
committed
update with JuliaLang/#43994
1 parent ccf7234 commit dd0858e

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/interpreter.jl

+23-3
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,22 @@ function Compiler.add_remark!(interp::CthulhuInterpreter, sv::InferenceState, ms
7272
end
7373

7474
function Compiler.finish(state::InferenceState, interp::CthulhuInterpreter)
75-
r = @invoke Compiler.finish(state::InferenceState, interp::AbstractInterpreter)
76-
interp.unopt[Core.Compiler.any(state.result.overridden_by_const) ? state.result : state.linfo] = InferredSource(
75+
res = @invoke Compiler.finish(state::InferenceState, interp::AbstractInterpreter)
76+
key = Core.Compiler.any(state.result.overridden_by_const) ? state.result : state.linfo
77+
interp.unopt[key] = InferredSource(
7778
copy(state.src),
7879
copy(state.stmt_info),
7980
state.result.result)
80-
return r
81+
return res
8182
end
8283

8384
function Compiler.transform_result_for_cache(interp::CthulhuInterpreter, linfo::MethodInstance,
8485
valid_worlds::WorldRange, @nospecialize(inferred_result))
86+
@static if isdefined(Compiler, :transform_optresult_for_cache)
87+
return isa(inferred_result, OptimizedSource) ? inferred_result :
88+
isa(inferred_result, Compiler.ConstAPI) ? inferred_result :
89+
nothing
90+
else # @static if isdefined(Compiler, :transform_optresult_for_cache)
8591
if isa(inferred_result, OptimizationState)
8692
opt = inferred_result
8793
ir = opt.ir
@@ -90,6 +96,7 @@ function Compiler.transform_result_for_cache(interp::CthulhuInterpreter, linfo::
9096
end
9197
end
9298
return inferred_result
99+
end # @static if isdefined(Compiler, :transform_optresult_for_cache)
93100
end
94101

95102
# branch on https://github.com/JuliaLang/julia/pull/41328
@@ -119,6 +126,17 @@ function Compiler.inlining_policy(interp::CthulhuInterpreter)
119126
end
120127
end # @static if isdefined(Compiler, :is_stmt_inline)
121128

129+
# branch on https://github.com/JuliaLang/julia/pull/43994
130+
@static if isdefined(Compiler, :transform_optresult_for_cache)
131+
132+
function Compiler.transform_optresult_for_cache(interp::CthulhuInterpreter,
133+
opt::OptimizationState, ir::IRCode, @nospecialize(analyzed))
134+
isa(analyzed, Compiler.ConstAPI) && return analyzed
135+
return OptimizedSource(ir, opt.src, opt.src.inlineable)
136+
end
137+
138+
else # @static if isdefined(Compiler, :transform_optresult_for_cache)
139+
122140
function Compiler.finish!(interp::CthulhuInterpreter, caller::InferenceResult)
123141
src = caller.src
124142
if isa(src, OptimizationState)
@@ -129,3 +147,5 @@ function Compiler.finish!(interp::CthulhuInterpreter, caller::InferenceResult)
129147
end
130148
end
131149
end
150+
151+
end # @static if isdefined(Compiler, :transform_optresult_for_cache)

test/utils.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ function strip_base_linenums(s)
2626
end
2727

2828
function irshow_filename(optimize, debuginfo, iswarn, hide_type_stable, inline_cost, type_annotations)
29-
return "test_output/foo-$(optimize ? :opt : :unopt)-$(debuginfo)-$(iswarn ? :warn : :nowarn)\
29+
p = "test_output/foo-$(optimize ? :opt : :unopt)-$(debuginfo)-$(iswarn ? :warn : :nowarn)\
3030
-$(hide_type_stable ? :hide_type_stable : :show_type_stable)-$(inline_cost ? :inline_cost : :nocost)\
3131
-$(type_annotations ? :types : :notypes)"
32+
return normpath(@__DIR__, p)
3233
end
3334

3435
# to generate test cases for IRShow tests

0 commit comments

Comments
 (0)