@@ -72,16 +72,22 @@ function Compiler.add_remark!(interp::CthulhuInterpreter, sv::InferenceState, ms
72
72
end
73
73
74
74
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 (
77
78
copy (state. src),
78
79
copy (state. stmt_info),
79
80
state. result. result)
80
- return r
81
+ return res
81
82
end
82
83
83
84
function Compiler. transform_result_for_cache (interp:: CthulhuInterpreter , linfo:: MethodInstance ,
84
85
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)
85
91
if isa (inferred_result, OptimizationState)
86
92
opt = inferred_result
87
93
ir = opt. ir
@@ -90,6 +96,7 @@ function Compiler.transform_result_for_cache(interp::CthulhuInterpreter, linfo::
90
96
end
91
97
end
92
98
return inferred_result
99
+ end # @static if isdefined(Compiler, :transform_optresult_for_cache)
93
100
end
94
101
95
102
# branch on https://github.com/JuliaLang/julia/pull/41328
@@ -119,6 +126,17 @@ function Compiler.inlining_policy(interp::CthulhuInterpreter)
119
126
end
120
127
end # @static if isdefined(Compiler, :is_stmt_inline)
121
128
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
+
122
140
function Compiler. finish! (interp:: CthulhuInterpreter , caller:: InferenceResult )
123
141
src = caller. src
124
142
if isa (src, OptimizationState)
@@ -129,3 +147,5 @@ function Compiler.finish!(interp::CthulhuInterpreter, caller::InferenceResult)
129
147
end
130
148
end
131
149
end
150
+
151
+ end # @static if isdefined(Compiler, :transform_optresult_for_cache)
0 commit comments