@@ -76,15 +76,28 @@ function Compiler.add_remark!(interp::CthulhuInterpreter, sv::InferenceState, ms
76
76
end
77
77
78
78
function Compiler. finish (state:: InferenceState , interp:: CthulhuInterpreter )
79
- r = @invoke Compiler. finish (state:: InferenceState , interp:: AbstractInterpreter )
80
- interp. unopt[Core. Compiler. any (state. result. overridden_by_const) ? state. result : state. linfo] = InferredSource (
79
+ res = @invoke Compiler. finish (state:: InferenceState , interp:: AbstractInterpreter )
80
+ key = Core. Compiler. any (state. result. overridden_by_const) ? state. result : state. linfo
81
+ interp. unopt[key] = InferredSource (
81
82
copy (state. src),
82
83
copy (state. stmt_info),
83
84
isdefined (Core. Compiler, :Effects ) ? state. ipo_effects : nothing ,
84
85
state. result. result)
85
- return r
86
+ return res
86
87
end
87
88
89
+ # branch on https://github.com/JuliaLang/julia/pull/43994
90
+ const AFTER_43994 = isdefined (Compiler, :transform_optresult_for_cache )
91
+
92
+ @static if AFTER_43994
93
+ function Compiler. transform_result_for_cache (interp:: CthulhuInterpreter , linfo:: MethodInstance ,
94
+ valid_worlds:: WorldRange , result:: InferenceResult )
95
+ inferred_result = result. src
96
+ return isa (inferred_result, OptimizedSource) ? inferred_result :
97
+ isa (inferred_result, Compiler. ConstAPI) ? inferred_result :
98
+ nothing
99
+ end
100
+ else # @static if AFTER_43994
88
101
function Compiler. transform_result_for_cache (interp:: CthulhuInterpreter , linfo:: MethodInstance ,
89
102
valid_worlds:: WorldRange , @nospecialize (inferred_result))
90
103
if isa (inferred_result, OptimizationState)
@@ -96,6 +109,7 @@ function Compiler.transform_result_for_cache(interp::CthulhuInterpreter, linfo::
96
109
end
97
110
return inferred_result
98
111
end
112
+ end # @static if AFTER_43994
99
113
100
114
# branch on https://github.com/JuliaLang/julia/pull/41328
101
115
@static if isdefined (Compiler, :is_stmt_inline )
@@ -124,6 +138,13 @@ function Compiler.inlining_policy(interp::CthulhuInterpreter)
124
138
end
125
139
end # @static if isdefined(Compiler, :is_stmt_inline)
126
140
141
+ @static if AFTER_43994
142
+ function Compiler. transform_optresult_for_cache (interp:: CthulhuInterpreter ,
143
+ opt:: OptimizationState , ir:: IRCode , @nospecialize (newresult))
144
+ isa (newresult, Compiler. ConstAPI) && return newresult
145
+ return OptimizedSource (ir, opt. src, opt. src. inlineable)
146
+ end
147
+ else # @static if AFTER_43994
127
148
function Compiler. finish! (interp:: CthulhuInterpreter , caller:: InferenceResult )
128
149
src = caller. src
129
150
if isa (src, OptimizationState)
@@ -134,3 +155,4 @@ function Compiler.finish!(interp::CthulhuInterpreter, caller::InferenceResult)
134
155
end
135
156
end
136
157
end
158
+ end # @static if AFTER_43994
0 commit comments