Skip to content

Commit

Permalink
[Nodecayed phis] handle repeated phi entry (#1127)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses authored and michel2323 committed Nov 7, 2023
1 parent c6b5306 commit c8dec44
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/compiler/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ function nodecayed_phis!(mod::LLVM.Module)
push!(todo, inst)
nb = IRBuilder()
position!(nb, inst)
nphi = phi!(nb, nty)
nphi = phi!(nb, nty, "nodecayed." * LLVM.name(inst))
nextvs[inst] = nphi
anyV = true

goffsets[inst] = phi!(nb, offty)
goffsets[inst] = phi!(nb, offty, "nodecayedoff." * LLVM.name(inst))
end
push!(mtodo, todo)
push!(nonphis, nonphi)
Expand All @@ -144,12 +144,23 @@ function nodecayed_phis!(mod::LLVM.Module)
nvs = Tuple{LLVM.Value, LLVM.BasicBlock}[]
offsets = Tuple{LLVM.Value, LLVM.BasicBlock}[]
for (v, pb) in LLVM.incoming(inst)
done = false
for ((nv, pb0), (offset, pb1)) in zip(nvs, offsets)
if pb0 == pb
push!(nvs, (nv, pb))
push!(offsets, (offset, pb))
done = true
break
end
end
if done
continue
end
b = IRBuilder()
position!(b, terminator(pb))

offset = LLVM.ConstantInt(offty, 0)

done = false
while true
if isa(v, LLVM.AddrSpaceCastInst) || isa(v, LLVM.BitCastInst)
v = operands(v)[1]
Expand Down

0 comments on commit c8dec44

Please sign in to comment.