@@ -7,6 +7,21 @@ function lookup_stmt(stmts::Vector{Any}, @nospecialize arg)
7
7
end
8
8
if isa (arg, QuoteNode)
9
9
return arg. value
10
+ elseif isexpr (arg, :call , 3 ) && is_global_ref (arg. args[1 ], Base, :getproperty )
11
+ # Starting with Julia 1.12, llvmcall looks like this:
12
+ # julia> src.code[1:3]
13
+ # 3-element Vector{Any}:
14
+ # :(TheModule.Core) # GlobalRef
15
+ # :(Base.getproperty(%1, :Intrinsics))
16
+ # :(Base.getproperty(%2, :llvmcall))
17
+ q = arg. args[3 ]
18
+ if isa (q, QuoteNode) && isa (q. value, Symbol)
19
+ mod = lookup_stmt (stmts, arg. args[2 ])
20
+ if isa (mod, GlobalRef)
21
+ mod = getproperty (mod. mod, mod. name)
22
+ end
23
+ isa (mod, Module) && return getproperty (mod, q. value)
24
+ end
10
25
end
11
26
return arg
12
27
end
@@ -116,7 +131,8 @@ function optimize!(code::CodeInfo, scope)
116
131
if stmt. head === :call
117
132
# Check for :llvmcall
118
133
arg1 = stmt. args[1 ]
119
- if (arg1 === :llvmcall || lookup_stmt (code. code, arg1) === Base. llvmcall) && isempty (sparams) && scope isa Method
134
+ larg1 = lookup_stmt (code. code, arg1)
135
+ if (arg1 === :llvmcall || larg1 === Base. llvmcall || is_global_ref (larg1, Base, :llvmcall )) && isempty (sparams) && scope isa Method
120
136
# Call via `invokelatest` to avoid compiling it until we need it
121
137
@invokelatest build_compiled_llvmcall! (stmt, code, idx, evalmod)
122
138
methodtables[idx] = Compiled ()
@@ -193,7 +209,7 @@ function build_compiled_foreigncall!(stmt::Expr, code::CodeInfo, sparams::Vector
193
209
TVal = evalmod == Core. Compiler ? Core. Compiler. Val : Val
194
210
cfuncarg = stmt. args[1 ]
195
211
while isa (cfuncarg, SSAValue)
196
- cfuncarg = code. code[ cfuncarg. id]
212
+ cfuncarg = lookup_stmt ( code. code, cfuncarg)
197
213
end
198
214
RetType, ArgType = stmt. args[2 ], stmt. args[3 ]:: SimpleVector
199
215
0 commit comments