Skip to content

Commit c644081

Browse files
authored
also match ccalls against (lib, function) (#236)
1 parent 9e02cf0 commit c644081

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/optimize.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ function optimize!(code::CodeInfo, scope)
176176
f = string(uuid1(rng))
177177
elseif isexpr(f, :call)
178178
length(f.args) == 3 || continue
179-
f.args[1] === tuple || continue
179+
if !(f.args[1] === tuple || f.args[1] == :($(QuoteNode(tuple))))
180+
continue
181+
end
180182
lib = f.args[3] isa String ? f.args[3] : f.args[3].value
181183
prefix = f.args[2] isa String ? f.args[2] : f.args[2].value
182184
f = Symbol(prefix, '_', lib)

test/interpret.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,3 +463,11 @@ function call_cf()
463463
ccall(cf[1], Int, (Int, Int), 1, 2)
464464
end
465465
@test (@interpret call_cf()) == call_cf()
466+
467+
f() = ccall((:clock, "libc"), Int32, ())
468+
# See that the method gets compiled
469+
try @interpret f()
470+
catch
471+
end
472+
compiled_calls = names(JuliaInterpreter.CompiledCalls; all=true)
473+
@test any(x -> startswith(string(x), "ccall_clock_libc"), compiled_calls)

0 commit comments

Comments
 (0)