[clang] [clang-repl][CUDA] Move CUDA module registration to beginning of global_ctors (PR #66658)

Vassil Vassilev via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 18 14:06:22 PDT 2023


================
@@ -794,7 +794,7 @@ void CodeGenModule::Release() {
       AddGlobalCtor(ObjCInitFunction);
   if (Context.getLangOpts().CUDA && CUDARuntime) {
     if (llvm::Function *CudaCtorFunction = CUDARuntime->finalizeModule())
-      AddGlobalCtor(CudaCtorFunction);
+      AddGlobalCtor(CudaCtorFunction, /*Priority=*/0);
----------------
vgvassilev wrote:

@Artem-B, I don’t think @argentite is pushing particularly for this solution of the problem. It seems we agree that is a problem and the behavior of clang diverges from the reference implementation. I believe we should figure out how to fix it. 

Rather than changing the priority we can book a slot for the kernel launch declaration respecting the init order.

https://github.com/llvm/llvm-project/pull/66658


More information about the cfe-commits mailing list