Skip to content

Commit

Permalink
inference: follow up JuliaLang#49260, remove no longer necessary func…
Browse files Browse the repository at this point in the history
…tions (JuliaLang#55430)
  • Loading branch information
aviatesk authored and lazarusA committed Aug 17, 2024
1 parent 4e2c775 commit 7c4b40c
Showing 1 changed file with 0 additions and 66 deletions.
66 changes: 0 additions & 66 deletions base/compiler/inferencestate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -517,72 +517,6 @@ function compute_trycatch(code::Vector{Any}, bbs::Union{Vector{BasicBlock},Nothi
return handler_info
end

function is_throw_call(e::Expr, code::Vector{Any})
if e.head === :call
f = e.args[1]
if isa(f, SSAValue)
f = code[f.id]
end
if isa(f, GlobalRef)
ff = abstract_eval_globalref_type(f)
if isa(ff, Const) && ff.val === Core.throw
return true
end
end
end
return false
end

function mark_throw_blocks!(src::CodeInfo, handler_info::Union{Nothing,HandlerInfo})
for stmt in find_throw_blocks(src.code, handler_info)
src.ssaflags[stmt] |= IR_FLAG_THROW_BLOCK
end
return nothing
end

# this utility function is incomplete and won't catch every block that always throws, since:
# - it only recognizes direct calls to `throw` within the target code, so it can't mark
# blocks that deterministically call `throw` internally, like those containing `error`.
# - it just does a reverse linear traverse of statements, there's a chance it might miss
# blocks, particularly when there are reverse control edges.
function find_throw_blocks(code::Vector{Any}, handler_info::Union{Nothing,HandlerInfo})
stmts = BitSet()
n = length(code)
for i in n:-1:1
s = code[i]
if isa(s, Expr)
if s.head === :gotoifnot
if i+1 in stmts && s.args[2]::Int in stmts
push!(stmts, i)
end
elseif s.head === :return
# see `ReturnNode` handling
elseif is_throw_call(s, code)
if handler_info === nothing || handler_info.handler_at[i][1] == 0
push!(stmts, i)
end
elseif i+1 in stmts
push!(stmts, i)
end
elseif isa(s, ReturnNode)
# NOTE: it potentially makes sense to treat unreachable nodes
# (where !isdefined(s, :val)) as `throw` points, but that can cause
# worse codegen around the call site (issue #37558)
elseif isa(s, GotoNode)
if s.label in stmts
push!(stmts, i)
end
elseif isa(s, GotoIfNot)
if i+1 in stmts && s.dest in stmts
push!(stmts, i)
end
elseif i+1 in stmts
push!(stmts, i)
end
end
return stmts
end

# check if coverage mode is enabled
function should_insert_coverage(mod::Module, debuginfo::DebugInfo)
coverage_enabled(mod) && return true
Expand Down

0 comments on commit 7c4b40c

Please sign in to comment.