Skip to content

Commit f5232e4

Browse files
committed
Remove non-interesting functions (for reflection) after optimization.
1 parent 59fd5de commit f5232e4

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/driver.jl

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -246,16 +246,6 @@ const __llvm_initialized = Ref(false)
246246

247247
# some early clean-up to reduce the amount of code to optimize
248248
@timeit_debug to "clean-up" begin
249-
# replace non-entry function definitions with a declaration
250-
if only_entry
251-
for f in functions(ir)
252-
f == entry && continue
253-
isdeclaration(f) && continue
254-
LLVM.isintrinsic(f) && continue
255-
empty!(f)
256-
end
257-
end
258-
259249
ModulePassManager() do pm
260250
# mark everything internal except for the entry and exported global variables.
261251
# this makes sure that the optimizer can, e.g., touch function signatures.
@@ -299,6 +289,18 @@ const __llvm_initialized = Ref(false)
299289
entry = functions(ir)[entry_fn]
300290
end
301291

292+
# replace non-entry function definitions with a declaration
293+
# NOTE: we can't do this before optimization, because the definitions of called
294+
# functions may affect optimization.
295+
if only_entry
296+
for f in functions(ir)
297+
f == entry && continue
298+
isdeclaration(f) && continue
299+
LLVM.isintrinsic(f) && continue
300+
empty!(f)
301+
end
302+
end
303+
302304
# remove the kernel state dummy use
303305
if haskey(functions(ir), "julia.gpu.state_user")
304306
dummy_user = functions(ir)["julia.gpu.state_user"]

0 commit comments

Comments
 (0)