Skip to content

Commit 6115c4a

Browse files
martinholtersKristofferC
authored andcommitted
Handle PhiNode with edge==0 (#46388)
(cherry picked from commit fd66c30)
1 parent 87fbfb1 commit 6115c4a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

base/compiler/ssair/legacy.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function replace_code_newstyle!(ci::CodeInfo, ir::IRCode, nargs::Int)
5858
elseif isa(stmt, GotoIfNot)
5959
stmt = GotoIfNot(stmt.cond, first(ir.cfg.blocks[stmt.dest].stmts))
6060
elseif isa(stmt, PhiNode)
61-
stmt = PhiNode(Int32[last(ir.cfg.blocks[edge].stmts) for edge in stmt.edges], stmt.values)
61+
stmt = PhiNode(Int32[edge == 0 ? 0 : last(ir.cfg.blocks[edge].stmts) for edge in stmt.edges], stmt.values)
6262
elseif isa(stmt, Expr) && stmt.head === :enter
6363
stmt.args[1] = first(ir.cfg.blocks[stmt.args[1]::Int].stmts)
6464
end

test/compiler/inference.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4062,3 +4062,15 @@ end
40624062
let t = Core.Compiler.tuple_tfunc(Any[Core.Const(42), Vararg{Any}])
40634063
@test Core.Compiler.issimplertype(t, t)
40644064
end
4065+
4066+
# issue #45600
4067+
@test only(code_typed() do
4068+
while true
4069+
x = try finally end
4070+
end
4071+
end)[2] == Union{}
4072+
@test only(code_typed() do
4073+
while true
4074+
@time 1
4075+
end
4076+
end)[2] == Union{}

0 commit comments

Comments
 (0)