Skip to content

Commit 668046a

Browse files
committed
Add assertions to catch failures earlier.
1 parent 3c1bc65 commit 668046a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/irgen.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ function irgen(@nospecialize(job::CompilerJob))
77
else
88
entry_fn = compiled[job.source].func
99
end
10+
@assert entry_fn !== nothing
1011
entry = functions(mod)[entry_fn]
1112

1213
# clean up incompatibilities

src/jlgen.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ function compile_method_instance(@nospecialize(job::CompilerJob))
582582
if ci_cache_lookup(cache, job.source, job.world, job.world) === nothing
583583
ci_cache_populate(interp, cache, job.source, job.world, job.world)
584584
end
585+
@assert ci_cache_lookup(cache, job.source, job.world, job.world) !== nothing
585586

586587
# create a callback to look-up function in our cache,
587588
# and keep track of the method instances we needed.
@@ -698,9 +699,10 @@ function compile_method_instance(@nospecialize(job::CompilerJob))
698699
ccall(:jl_get_function_id, Nothing,
699700
(Ptr{Cvoid}, Any, Ptr{Int32}, Ptr{Int32}),
700701
native_code, ci, llvm_func_idx, llvm_specfunc_idx)
702+
@assert llvm_func_idx[] != -1 || llvm_specfunc_idx[] != -1 "Static compilation failed"
701703

702704
# get the function
703-
llvm_func = if llvm_func_idx[] >= 1
705+
llvm_func = if llvm_func_idx[] >= 1
704706
llvm_func_ref = ccall(:jl_get_llvm_function, LLVM.API.LLVMValueRef,
705707
(Ptr{Cvoid}, UInt32), native_code, llvm_func_idx[]-1)
706708
@assert llvm_func_ref != C_NULL
@@ -709,7 +711,7 @@ function compile_method_instance(@nospecialize(job::CompilerJob))
709711
nothing
710712
end
711713

712-
llvm_specfunc = if llvm_specfunc_idx[] >= 1
714+
llvm_specfunc = if llvm_specfunc_idx[] >= 1
713715
llvm_specfunc_ref = ccall(:jl_get_llvm_function, LLVM.API.LLVMValueRef,
714716
(Ptr{Cvoid}, UInt32), native_code, llvm_specfunc_idx[]-1)
715717
@assert llvm_specfunc_ref != C_NULL

0 commit comments

Comments
 (0)