summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtem Belevich <tra@google.com>2023-05-16 12:30:22 -0700
committerArtem Belevich <tra@google.com>2023-05-17 12:51:01 -0700
commita825f3754b3ca1591068cf99bc224af30a311e63 (patch)
treeddf9c6d8b62dd891a6eb7fb6fbc024216fda30b6
parenta07b135ce0c0111bd83450b5dc29ef0381cdbc39 (diff)
downloadllvm-a825f3754b3ca1591068cf99bc224af30a311e63.tar.gz
[CUDA] Relax restrictions on GPU-side variadic functions
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 Differential Revision: https://reviews.llvm.org/D150718
-rw-r--r--clang/lib/Driver/ToolChains/Cuda.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp
index 37b0b9c2ed05..eae5ebdc192b 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -800,6 +800,13 @@ void CudaToolChain::addClangTargetOptions(
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))