Skip to content

Commit bcb653a

Browse files
committed
Deferred kernels: eagerly convert indirect calls to direct ones.
Also get rid of unused metadata during argument conversions so that we only have to handle instructions.
1 parent 33273fe commit bcb653a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/driver.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,19 @@ const __llvm_initialized = Ref(false)
282282
erase!(call)
283283
end
284284
end
285+
286+
# minimal optimization to convert the inttoptr/call into a direct call
287+
@dispose pb=NewPMPassBuilder() begin
288+
add!(pb, NewPMFunctionPassManager()) do fpm
289+
add!(fpm, InstCombinePass())
290+
end
291+
run!(pb, ir, llvm_machine(job.config.target))
292+
end
293+
## XXX: LLVM often leaves behind unused constant expressions containing function
294+
## pointer bitcasts we just optimized away, so prune those manually.
295+
for f in functions(ir)
296+
prune_constexpr_uses!(f)
297+
end
285298
end
286299

287300
# all deferred compilations should have been resolved

0 commit comments

Comments
 (0)