Skip to content

Commit

Permalink
Handle PhiNode with edge==0 (#46388)
Browse files Browse the repository at this point in the history
(cherry picked from commit fd66c30)
  • Loading branch information
martinholters authored and KristofferC committed Dec 21, 2022
1 parent 3e919c8 commit 187177d
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 @@ -59,7 +59,7 @@ function replace_code_newstyle!(ci::CodeInfo, ir::IRCode, nargs::Int)
elseif isa(stmt, GotoIfNot)
stmt = GotoIfNot(stmt.cond, first(ir.cfg.blocks[stmt.dest].stmts))
elseif isa(stmt, PhiNode)
stmt = PhiNode(Int32[last(ir.cfg.blocks[edge].stmts) for edge in stmt.edges], stmt.values)
stmt = PhiNode(Int32[edge == 0 ? 0 : last(ir.cfg.blocks[edge].stmts) for edge in stmt.edges], stmt.values)
elseif isa(stmt, Expr) && stmt.head === :enter
stmt.args[1] = first(ir.cfg.blocks[stmt.args[1]::Int].stmts)
end
Expand Down
12 changes: 12 additions & 0 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3090,3 +3090,15 @@ end
f41908(x::Complex{T}) where {String<:T<:String} = 1
g41908() = f41908(Any[1][1])
@test only(Base.return_types(g41908, ())) <: Int

# 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 187177d

Please sign in to comment.