Skip to content

Commit 7cb655b

Browse files
committed
Fix phi node value renumbering issue
If a phi node got placed at a position one of its values referenced, that reference wasn't updated.
1 parent 8ab41d6 commit 7cb655b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

base/compiler/ssair/ir.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ function process_phinode_values(old_values::Vector{Any}, late_fixup::Vector{Int}
669669
val = old_values[i]
670670
if isa(val, SSAValue)
671671
if do_rename_ssa
672-
if val.id > processed_idx
672+
if val.id >= processed_idx
673673
push!(late_fixup, result_idx)
674674
val = OldSSAValue(val.id)
675675
else
@@ -679,7 +679,7 @@ function process_phinode_values(old_values::Vector{Any}, late_fixup::Vector{Int}
679679
used_ssas[val.id] += 1
680680
end
681681
elseif isa(val, OldSSAValue)
682-
if val.id > processed_idx
682+
if val.id >= processed_idx
683683
push!(late_fixup, result_idx)
684684
else
685685
# Always renumber these. do_rename_ssa applies only to actual SSAValues

test/goto.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,17 @@ function f15561()
154154
@label crater
155155
end
156156
@test f15561() === nothing
157+
158+
# issue #28077
159+
function foo28077()
160+
s = 0
161+
i = 0
162+
@label L
163+
i += 1
164+
s += i
165+
if i < 10
166+
@goto L
167+
end
168+
return s
169+
end
170+
@test foo28077() == 55

0 commit comments

Comments
 (0)