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