Skip to content

Commit

Permalink
more fix
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Mar 27, 2024
1 parent 714bc4d commit fc3683d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions base/compiler/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1108,8 +1108,9 @@ function convert_to_ircode(ci::CodeInfo, sv::OptimizationState)
new_edges = Int32[]
new_vals = Any[]
for j = 1:length(expr.edges)
(expr.edges[j] in sv.unreachable) && continue
push!(new_edges, expr.edges[j])
edge = expr.edges[j]
(edge in sv.unreachable || ssavaluetypes[edge] === Union{}) && continue
push!(new_edges, edge)
if isassigned(expr.values, j)
push!(new_vals, expr.values[j])
else
Expand Down
5 changes: 4 additions & 1 deletion test/compiler/ssair.jl
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@ end
end

# Test that things don't break if one branch of the frontend PhiNode becomes unreachable
global global_error_switch::Bool = true
function gen_unreachable_phinode_edge(world::UInt, source, _)
ci = make_codeinfo(Any[
# block 1
Expand All @@ -774,7 +775,9 @@ end
$(Expr(:meta, :generated_only))
#= no body =#
end
global global_error_switch = true
let ir = first(only(Base.code_ircode(f_unreachable_phinode_edge)))
@test !any(@nospecialize(x)->isa(x,PhiNode), ir.stmts.stmt)
end
@test_throws ErrorException f_unreachable_phinode_edge()
global global_error_switch = false
@test f_unreachable_phinode_edge() == 1

0 comments on commit fc3683d

Please sign in to comment.