Skip to content

Commit a0e73b7

Browse files
authored
Be more strict about runtime function misuse. (#603)
1 parent 8ed06bf commit a0e73b7

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/rtlib.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,20 @@ function LLVM.call!(builder, rt::Runtime.RuntimeMethodInstance, args=LLVM.Value[
3131
ft = convert(LLVM.FunctionType, rt)
3232
f = LLVM.Function(mod, rt.llvm_name, ft)
3333
end
34+
if !isdeclaration(f) && rt.name !== :gc_pool_alloc
35+
# XXX: uses of the gc_pool_alloc intrinsic can be introduced _after_ the runtime
36+
# is linked, as part of the lower_gc_frame! optimization pass.
37+
error("Calling an intrinsic function that clashes with an existing definition: ",
38+
string(ft), " ", rt.name)
39+
end
3440

3541
# runtime functions are written in Julia, while we're calling from LLVM,
3642
# this often results in argument type mismatches. try to fix some here.
3743
args = LLVM.Value[args...]
44+
if length(args) != length(parameters(ft))
45+
error("Incorrect number of arguments for runtime function: ",
46+
"passing ", length(args), " argument(s) to '", string(ft), " ", rt.name, "'")
47+
end
3848
for (i,arg) in enumerate(args)
3949
if value_type(arg) != parameters(ft)[i]
4050
if (value_type(arg) isa LLVM.PointerType) &&

src/runtime.jl

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ end
5151

5252
const methods = Dict{Symbol,RuntimeMethodInstance}()
5353
function get(name::Symbol)
54-
if !haskey(methods, name)
55-
display(methods)
56-
end
5754
methods[name]
5855
end
5956

0 commit comments

Comments
 (0)