Skip to content

Commit

Permalink
dont addrfix offsets of arg11 (#1230)
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses authored Jan 1, 2024
1 parent a8e564c commit 2525cc5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/compiler/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ function nodecayed_phis!(mod::LLVM.Module)
if addrspace(ty) != addr
continue
end
if addr == 11
all_args = true
for (v, _) in LLVM.incoming(inst)
base = get_base_object(v)
if isa(base, LLVM.Argument) && addrspace(value_type(base)) == 11
continue
end
all_args = false
break
end
if all_args
continue
end
end

push!(todo, inst)
nb = IRBuilder()
position!(nb, inst)
Expand Down Expand Up @@ -249,7 +264,7 @@ function nodecayed_phis!(mod::LLVM.Module)
return LLVM.UndefValue(LLVM.PointerType(eltype(value_type(v)),10)), offset, addr == 13
end

if isa(v, LLVM.PHIInst) && !hasload
if isa(v, LLVM.PHIInst) && !hasload && haskey(goffsets, v)
offset = nuwadd!(b, offset, goffsets[v])
nv = nextvs[v]
return nv, offset, addr == 13
Expand All @@ -266,6 +281,7 @@ function nodecayed_phis!(mod::LLVM.Module)

msg = sprint() do io
println(io, "Could not analyze garbage collection behavior of")
println(io, " inst: ", string(inst))
println(io, " v0: ", string(v0))
println(io, " v: ", string(v))
println(io, " offset: ", string(offset))
Expand Down
9 changes: 9 additions & 0 deletions src/compiler/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ end

T_ppjlvalue() = LLVM.PointerType(LLVM.PointerType(LLVM.StructType(LLVMType[])))

@inline function get_base_object(v)
if isa(v, LLVM.AddrSpaceCastInst) || isa(v, LLVM.BitCastInst)
return get_base_object(operands(v)[1])
end
if isa(v, LLVM.GetElementPtrInst)
return get_base_object(operands(v)[1])
end
return v
end

if VERSION < v"1.7.0-DEV.1205"

Expand Down

0 comments on commit 2525cc5

Please sign in to comment.