JET.jl icon indicating copy to clipboard operation
JET.jl copied to clipboard

`skip_unoptimized_throw_blocks` does not ignore error exceptions

Open kbarros opened this issue 1 year ago • 0 comments
trafficstars

This is a follow-up to #643. As discussed on that issue, it seems that skip_unoptimized_throw_blocks does not always detect throw blocks. An example is below.

using JET

function g(x)
    error("Please ignore this: $x")
end

@test_opt g(1/3)
Output
[ Info: tracking Base
  ═════ 4 possible errors found ═════
  ┌ g(x::Float64) @ Main ./REPL[2]:2
  │┌ string(::String, ::Float64) @ Base ./strings/io.jl:189
  ││┌ print_to_string(::String, ::Float64) @ Base ./strings/io.jl:150
  │││┌ _unsafe_take!(io::IOBuffer) @ Base ./iobuffer.jl:504
  ││││┌ wrap(::Type{Array}, m::MemoryRef{UInt8}, l::Int64) @ Base ./array.jl:3099
  │││││ failed to optimize due to recursion: Base.wrap(::Type{Array}, ::MemoryRef{UInt8}, ::Int64)
  ││││└────────────────────
  │││┌ print_to_string(::String, ::Vararg{Any}) @ Base ./strings/io.jl:143
  ││││ runtime dispatch detected: Base._str_sizehint(%17::Any)::Int64
  │││└────────────────────
  │││┌ print_to_string(::String, ::Vararg{Any}) @ Base ./strings/io.jl:148
  ││││ runtime dispatch detected: print(%59::IOBuffer, %97::Any)::Any
  │││└────────────────────
  │││┌ string(::String, ::Int64, ::String, ::Tuple{Int64}, ::String, ::Int64, ::String, ::Int64, ::String) @ Base ./strings/io.jl:189
  ││││ failed to optimize due to recursion: string(::String, ::Int64, ::String, ::Tuple{Int64}, ::String, ::Int64, ::String, ::Int64, ::String)
  │││└────────────────────

There was partial progress toward implementing this feature in https://github.com/aviatesk/JET.jl/commit/447c7a3089e0feca70fd9eb533c17890650fe6b7.

kbarros avatar Jul 10 '24 14:07 kbarros