Skip to content

Commit

Permalink
don't descend into cglobal and llvmcall (#602)
Browse files Browse the repository at this point in the history
fixes #515
  • Loading branch information
simeonschaub authored Oct 11, 2024
1 parent 5a32d8a commit 7c58243
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/reflection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@ function find_callsites(interp::AbstractInterpreter, CI::Union{Core.CodeInfo, IR
if !optimize
args = (ignorelhs(stmt)::Expr).args
end
argtypes = mapany(function (@nospecialize(arg),)
t = argextype(arg, CI, sptypes, slottypes)
return ignorelimited(t)
end, args)
argtypes = Vector{Any}(undef, length(args))
ft = ignorelimited(argextype(args[1], CI, sptypes, slottypes))
f = CC.singleton_type(ft)
f === Core.Intrinsics.llvmcall && continue
f === Core.Intrinsics.cglobal && continue
argtypes[1] = ft
for i = 2:length(args)
t = argextype(args[i], CI, sptypes, slottypes)
argtypes[i] = ignorelimited(t)
end
exct = isnothing(pc2excts) ? nothing : get(pc2excts, id, nothing)
callinfos = process_info(interp, info, argtypes, rt, optimize, exct)
isempty(callinfos) && continue
Expand Down
8 changes: 8 additions & 0 deletions test/test_Cthulhu.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1016,4 +1016,12 @@ let (interp, mi) = Cthulhu.mkinterp((Int,)) do var::Int
@test length(inferred.ir.cfg.blocks) == 1
end

f515() = cglobal((:foo, bar))
@testset "issue #515" begin
let (; interp, src, infos, mi, slottypes) = cthulhu_info(f515)
callsites, _ = Cthulhu.find_callsites(interp, src, infos, mi, slottypes)
@test isempty(callsites)
end
end

end # module test_Cthulhu

0 comments on commit 7c58243

Please sign in to comment.