Skip to content

Commit

Permalink
Handle PhiNode with edge==0 (#46388)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinholters authored Aug 18, 2022
1 parent 6b8e9f9 commit fd66c30
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion base/compiler/ssair/legacy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function replace_code_newstyle!(ci::CodeInfo, ir::IRCode, nargs::Int)
elseif isa(stmt, GotoIfNot)
code[i] = GotoIfNot(stmt.cond, first(ir.cfg.blocks[stmt.dest].stmts))
elseif isa(stmt, PhiNode)
code[i] = PhiNode(Int32[last(ir.cfg.blocks[edge].stmts) for edge in stmt.edges], stmt.values)
code[i] = PhiNode(Int32[edge == 0 ? 0 : last(ir.cfg.blocks[edge].stmts) for edge in stmt.edges], stmt.values)
elseif isexpr(stmt, :enter)
stmt.args[1] = first(ir.cfg.blocks[stmt.args[1]::Int].stmts)
code[i] = stmt
Expand Down
12 changes: 12 additions & 0 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4111,3 +4111,15 @@ struct Issue45780
end
f45780() = Val{Issue45780(@Base.Experimental.opaque ()->1).oc()}()
@test (@inferred f45780()) == Val{1}()

# issue #45600
@test only(code_typed() do
while true
x = try finally end
end
end)[2] == Union{}
@test only(code_typed() do
while true
@time 1
end
end)[2] == Union{}

0 comments on commit fd66c30

Please sign in to comment.