tra created this revision.
Herald added subscribers: mattd, carlosgalvezp, bixia, yaxunl.
Herald added a project: All.
tra added reviewers: jlebar, yaxunl.
tra published this revision for review.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Allow parsing GPU-side variadic functions when we're compiling with CUDA-9 or
newer. We still do not allow accessing variadic arguments.

CUDA-9 was the version which introduced PTX-6.0 which allows implementing
variadic functions, so older versions can't have variadics in principle.

This is required for dealing with headers in recent CUDA versions that rely on
variadic function declarations in some of the templated code in libcu++.
E.g. https://github.com/llvm/llvm-project/issues/58410


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150718

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp


Index: clang/lib/Driver/ToolChains/Cuda.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -800,6 +800,13 @@
     if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
                            options::OPT_fno_cuda_approx_transcendentals, 
false))
       CC1Args.push_back("-fcuda-approx-transcendentals");
+
+    // Unsized function arguments used for variadics were introduced in 
CUDA-9.0
+    // We still do not support generating code that actually uses variadic
+    // arguments yet, but we do need to allow parsing them as recent CUDA
+    // headers rely on that. https://github.com/llvm/llvm-project/issues/58410
+    if (CudaInstallation.version() >= CudaVersion::CUDA_90)
+      CC1Args.push_back("-fcuda-allow-variadic-functions");
   }
 
   if (DriverArgs.hasArg(options::OPT_nogpulib))


Index: clang/lib/Driver/ToolChains/Cuda.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -800,6 +800,13 @@
     if (DriverArgs.hasFlag(options::OPT_fcuda_approx_transcendentals,
                            options::OPT_fno_cuda_approx_transcendentals, false))
       CC1Args.push_back("-fcuda-approx-transcendentals");
+
+    // Unsized function arguments used for variadics were introduced in CUDA-9.0
+    // We still do not support generating code that actually uses variadic
+    // arguments yet, but we do need to allow parsing them as recent CUDA
+    // headers rely on that. https://github.com/llvm/llvm-project/issues/58410
+    if (CudaInstallation.version() >= CudaVersion::CUDA_90)
+      CC1Args.push_back("-fcuda-allow-variadic-functions");
   }
 
   if (DriverArgs.hasArg(options::OPT_nogpulib))
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to