@@ -183,14 +183,16 @@ function optimize!(code::CodeInfo, scope)
183
183
arg1 = stmt. args[1 ]
184
184
if (arg1 === :llvmcall || lookup_stmt (code. code, arg1) === Base. llvmcall) && isempty (sparams) && scope isa Method
185
185
nargs = length (stmt. args)- 4
186
- delete_idx = build_compiled_call! (stmt, Base. llvmcall, code, idx, nargs, sparams, evalmod)
186
+ # Call via `invokelatest` to avoid compiling it until we need it
187
+ delete_idx = Base. invokelatest (build_compiled_call!, stmt, Base. llvmcall, code, idx, nargs, sparams, evalmod)
187
188
delete_idx === nothing && error (" llvmcall must be compiled, but exited early from build_compiled_call!" )
188
189
push! (foreigncalls_idx, idx)
189
190
append! (delete_idxs, delete_idx)
190
191
end
191
192
elseif stmt. head === :foreigncall && scope isa Method
192
193
nargs = foreigncall_version == 0 ? stmt. args[5 ]:: Int : length (stmt. args[3 ]:: SimpleVector )
193
- delete_idx = build_compiled_call! (stmt, :ccall , code, idx, nargs, sparams, evalmod)
194
+ # Call via `invokelatest` to avoid compiling it until we need it
195
+ delete_idx = Base. invokelatest (build_compiled_call!, stmt, :ccall , code, idx, nargs, sparams, evalmod)
194
196
if delete_idx != = nothing
195
197
push! (foreigncalls_idx, idx)
196
198
append! (delete_idxs, delete_idx)
0 commit comments