Skip to content

Commit a406eb4

Browse files
LuoYuankeYuanke Luo
andauthored
[CUDA] Remove CUDAAllowVariadicFunctions option and its sema check (#161350)
Variadic argument for NVPTX has been support in 486d00e We can remove `CUDAAllowVariadicFunctions` option and its sema check. The CC1 option `fcuda_allow_variadic_functions` is retained to not break the existing code building. --------- Co-authored-by: Yuanke Luo <[email protected]>
1 parent bea0225 commit a406eb4

File tree

4 files changed

+6
-34
lines changed

4 files changed

+6
-34
lines changed

clang/include/clang/Basic/LangOptions.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ LANGOPT(HLSLStrictAvailability, 1, 0, NotCompatible,
245245
LANGOPT(HLSLSpvUseUnknownImageFormat, 1, 0, NotCompatible, "For storage images and texel buffers, sets the default format to 'Unknown' when not specified via the `vk::image_format` attribute. If this option is not used, the format is inferred from the resource's data type.")
246246

247247
LANGOPT(CUDAIsDevice , 1, 0, NotCompatible, "compiling for CUDA device")
248-
LANGOPT(CUDAAllowVariadicFunctions, 1, 0, NotCompatible, "allowing variadic functions in CUDA device code")
249248
LANGOPT(CUDAHostDeviceConstexpr, 1, 1, NotCompatible, "treating unattributed constexpr functions as __host__ __device__")
250249
LANGOPT(GPUDeviceApproxTranscendentals, 1, 0, NotCompatible, "using approximate transcendental functions")
251250
LANGOPT(GPURelocatableDeviceCode, 1, 0, NotCompatible, "generate relocatable device code")

clang/include/clang/Driver/Options.td

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8733,8 +8733,7 @@ def fcuda_include_gpubinary : Separate<["-"], "fcuda-include-gpubinary">,
87338733
HelpText<"Incorporate CUDA device-side binary into host object file.">,
87348734
MarshallingInfoString<CodeGenOpts<"CudaGpuBinaryFileName">>;
87358735
def fcuda_allow_variadic_functions : Flag<["-"], "fcuda-allow-variadic-functions">,
8736-
HelpText<"Allow variadic functions in CUDA device code.">,
8737-
MarshallingInfoFlag<LangOpts<"CUDAAllowVariadicFunctions">>;
8736+
HelpText<"Deprecated; Allow variadic functions in CUDA device code.">;
87388737
def fno_cuda_host_device_constexpr : Flag<["-"], "fno-cuda-host-device-constexpr">,
87398738
HelpText<"Don't treat unattributed constexpr functions as __host__ __device__.">,
87408739
MarshallingInfoNegativeFlag<LangOpts<"CUDAHostDeviceConstexpr">>;

clang/lib/Sema/SemaDecl.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11041,17 +11041,6 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
1104111041
<< CUDA().getConfigureFuncName();
1104211042
Context.setcudaConfigureCallDecl(NewFD);
1104311043
}
11044-
11045-
// Variadic functions, other than a *declaration* of printf, are not allowed
11046-
// in device-side CUDA code, unless someone passed
11047-
// -fcuda-allow-variadic-functions.
11048-
if (!getLangOpts().CUDAAllowVariadicFunctions && NewFD->isVariadic() &&
11049-
(NewFD->hasAttr<CUDADeviceAttr>() ||
11050-
NewFD->hasAttr<CUDAGlobalAttr>()) &&
11051-
!(II && II->isStr("printf") && NewFD->isExternC() &&
11052-
!D.isFunctionDefinition())) {
11053-
Diag(NewFD->getLocation(), diag::err_variadic_device_fn);
11054-
}
1105511044
}
1105611045

1105711046
MarkUnusedFileScopedDecl(NewFD);

clang/test/SemaCUDA/vararg.cu

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
// REQUIRES: x86-registered-target
22
// REQUIRES: nvptx-registered-target
33
// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only \
4-
// RUN: -verify -DEXPECT_VA_ARG_ERR -DEXPECT_VARARG_ERR %s
4+
// RUN: -verify -DEXPECT_VA_ARG_ERR %s
55
// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only \
66
// RUN: -fcuda-allow-variadic-functions -verify -DEXPECT_VA_ARG_ERR %s
7-
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify \
8-
// RUN: -DEXPECT_VARARG_ERR %s
97

108
#include <stdarg.h>
119
#include "Inputs/cuda.h"
@@ -30,28 +28,15 @@ __device__ void baz() {
3028
#endif
3129
}
3230

33-
__device__ void vararg(const char* x, ...) {}
34-
#ifdef EXPECT_VARARG_ERR
35-
// expected-error@-2 {{CUDA device code does not support variadic functions}}
36-
#endif
31+
__device__ void vararg(const char* x, ...) {} // OK
3732

3833
template <typename T>
39-
__device__ void vararg(T t, ...) {}
40-
#ifdef EXPECT_VARARG_ERR
41-
// expected-error@-2 {{CUDA device code does not support variadic functions}}
42-
#endif
34+
__device__ void vararg(T t, ...) {} // OK
4335

4436
extern "C" __device__ int printf(const char* fmt, ...); // OK, special case.
4537

46-
// Definition of printf not allowed.
47-
extern "C" __device__ int printf(const char* fmt, ...) { return 0; }
48-
#ifdef EXPECT_VARARG_ERR
49-
// expected-error@-2 {{CUDA device code does not support variadic functions}}
50-
#endif
38+
extern "C" __device__ int printf(const char* fmt, ...) { return 0; } // OK
5139

5240
namespace ns {
53-
__device__ int printf(const char* fmt, ...);
54-
#ifdef EXPECT_VARARG_ERR
55-
// expected-error@-2 {{CUDA device code does not support variadic functions}}
56-
#endif
41+
__device__ int printf(const char* fmt, ...); // OK
5742
}

0 commit comments

Comments
 (0)