Skip to content

Commit

Permalink
skip verifier if parent function is overdub
Browse files Browse the repository at this point in the history
  • Loading branch information
vchuravy committed Mar 21, 2019
1 parent 9dc167d commit bc74e3b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/compiler/irgen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ function compile_linfo(ctx::CompilerContext, linfo::Core.MethodInstance, world)
end
method_stack = Vector{Core.MethodInstance}()
function hook_emit_function(method_instance, code, world)
skip_verifier = false
if length(method_stack) >= 1
last_method = last(method_stack)
skip_verifier = last_method.def.name === :overdub
end
push!(method_stack, method_instance)

# check for recursion
Expand All @@ -55,6 +60,10 @@ function compile_linfo(ctx::CompilerContext, linfo::Core.MethodInstance, world)
bt=backtrace(ctx, method_stack)))
end

# if last method on stack is overdub skip the Base check
# and trust in Cassette
skip_verifier && return

# check for Base methods that exist in CUDAnative too
# FIXME: this might be too coarse
method = method_instance.def
Expand Down
11 changes: 11 additions & 0 deletions test/codegen.jl
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,17 @@ end
@test occursin(r"\[2\] .+foobar", bt_msg)
end

@testset "do not verify hack for base intrinsics" begin
@noinline overdub(f::F, args...) where F = f(args...)
foobar(i) = overdub(sin, i)

# NOTE: we don't use test_logs in order to test all of the warning (exception, backtrace)
logs, _ = Test.collect_test_logs() do
CUDAnative.code_llvm(devnull, foobar, Tuple{Int})
end
@test length(logs) == 0
end

# some validation happens in `compile`

@testset "non-isbits arguments" begin
Expand Down

0 comments on commit bc74e3b

Please sign in to comment.