Skip to content

Commit

Permalink
Fix deletion of return (#2073)
Browse files Browse the repository at this point in the history
* Fix deletion of return

* Update optimize.jl
  • Loading branch information
wsmoses authored Nov 8, 2024
1 parent 1c09430 commit ae171bf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/compiler/optimize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1942,7 +1942,7 @@ function propagate_returned!(mod::LLVM.Module)
un = LLVM.user(u)
push!(next, LLVM.name(LLVM.parent(LLVM.parent(un))))
end
delete_writes_into_removed_args(fn, toremove)
delete_writes_into_removed_args(fn, toremove, keepret)
nm = LLVM.name(fn)
#try
nfn = LLVM.Function(
Expand Down Expand Up @@ -1988,7 +1988,7 @@ function propagate_returned!(mod::LLVM.Module)
end
end

function delete_writes_into_removed_args(fn::LLVM.Function, toremove)
function delete_writes_into_removed_args(fn::LLVM.Function, toremove, keepret::Bool)
args = collect(parameters(fn))
for tr in toremove
tr = tr + 1
Expand Down Expand Up @@ -2032,6 +2032,9 @@ function delete_writes_into_removed_args(fn::LLVM.Function, toremove)
end
end
end
if !keepret && LLVM.API.LLVMIsAReturnInst(cur) != C_NULL
LLVM.API.LLVMSetOperand(cur, 0, LLVM.UndefValue(value_type(cval)))
end
throw(AssertionError("Deleting argument with an unknown dependency, $(string(cur)) uses $(string(cval))"))
end
end
Expand Down

0 comments on commit ae171bf

Please sign in to comment.