File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -316,15 +316,16 @@ const __llvm_initialized = Ref(false)
316
316
end
317
317
318
318
@timeit_debug to " IR post-processing" begin
319
- # mark the entry-point function (optimization may need it)
320
- if deferred_codegen
321
- # IDEA: save other parts of the CompileJob (so that we can reconstruct it
322
- # instead of setting it globally, which is incompatible with threading)?
319
+ # mark the kernel entry-point functions (optimization may need it)
320
+ if job. source. kernel
323
321
# XXX : we want to save the actual function here, but due to our passes rewriting
324
322
# functions, and the inability to RAUW values with a different type, that
325
323
# metadata gets lost. So instead we save the function name. See also:
326
324
# https://discourse.llvm.org/t/replacing-module-metadata-uses-of-function/62431
327
- push! (metadata (ir)[" julia.entry" ], MDNode ([MDString (LLVM. name (entry); ctx)]; ctx))
325
+ push! (metadata (ir)[" julia.kernel" ], MDNode ([MDString (LLVM. name (entry); ctx)]; ctx))
326
+
327
+ # IDEA: save all jobs, not only top-level kernels, and save other attributes
328
+ # so that we can reconstruct the CompileJob instead of setting it globally
328
329
end
329
330
330
331
if optimize
Original file line number Diff line number Diff line change @@ -551,16 +551,19 @@ function add_kernel_state!(mod::LLVM.Module)
551
551
# this is both for extern uses, and to make this transformation a two-step process.
552
552
state_intr = kernel_state_intr (mod, T_state)
553
553
554
- entry_md = operands (metadata (mod)[" julia.entry" ])[1 ]
555
- entry_fn = string (operands (entry_md)[1 ])
556
- entry = functions (mod)[entry_fn]
554
+ kernels = []
555
+ kernels_md = metadata (mod)[" julia.kernel" ]
556
+ for kernel_md in operands (kernels_md)
557
+ kernel_fn = string (operands (kernel_md)[1 ])
558
+ push! (kernels, functions (mod)[kernel_fn])
559
+ end
557
560
558
561
# determine which functions need a kernel state argument
559
562
#
560
563
# previously, we add the argument to every function and relied on unused arg elim to
561
564
# clean-up the IR. however, some libraries do Funny Stuff, e.g., libdevice bitcasting
562
565
# function pointers. such IR is hard to rewrite, so instead be more conservative.
563
- worklist = Set {LLVM.Function} ([entry, state_intr ])
566
+ worklist = Set {LLVM.Function} ([state_intr, kernels ... ])
564
567
worklist_length = 0
565
568
while worklist_length != length (worklist)
566
569
# iteratively discover functions that use the intrinsic or any function calling it
You can’t perform that action at this time.
0 commit comments