Skip to content

Commit 193411c

Browse files
authored
Don't drop constants while cloning IR. (#319)
By putting the function in the VMap, constants are rewritten properly.
1 parent 8dbfaee commit 193411c

File tree

1 file changed

+0
-20
lines changed

1 file changed

+0
-20
lines changed

src/irgen.jl

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -505,15 +505,6 @@ function lower_byval(@nospecialize(job::CompilerJob), mod::LLVM.Module, f::LLVM.
505505
br!(builder, blocks(new_f)[2])
506506
end
507507

508-
# drop unused constants that may be referring to the old functions
509-
# XXX: can we do this differently?
510-
for use in uses(f)
511-
val = user(use)
512-
if val isa LLVM.ConstantExpr && isempty(uses(val))
513-
LLVM.unsafe_destroy!(val)
514-
end
515-
end
516-
517508
# remove the old function
518509
# NOTE: if we ever have legitimate uses of the old function, create a shim instead
519510
fn = LLVM.name(f)
@@ -621,17 +612,6 @@ function add_kernel_state!(@nospecialize(job::CompilerJob), mod::LLVM.Module,
621612
empty!(f)
622613
end
623614

624-
# drop unused constants that may be referring to the old functions
625-
# XXX: can we do this differently?
626-
for f in worklist
627-
for use in uses(f)
628-
val = user(use)
629-
if val isa LLVM.ConstantExpr && isempty(uses(val))
630-
LLVM.unsafe_destroy!(val)
631-
end
632-
end
633-
end
634-
635615
# update other uses of the old function, modifying call sites to pass the state argument
636616
function rewrite_uses!(f, new_f)
637617
# update uses

0 commit comments

Comments
 (0)