[clang] [CUDA][HIP] warn incompatible redeclare (PR #77359)
Artem Belevich via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 6 14:05:42 PDT 2024
================
@@ -9013,6 +9013,12 @@ def err_cuda_ovl_target : Error<
"cannot overload %select{__device__|__global__|__host__|__host__ __device__}2 function %3">;
def note_cuda_ovl_candidate_target_mismatch : Note<
"candidate template ignored: target attributes do not match">;
+def warn_offload_incompatible_redeclare : Warning<
+ "incompatible host/device attribute with redeclaration: "
+ "new declaration is %select{__device__|__global__|__host__|__host__ __device__}0 function, "
+ "old declaration is %select{__device__|__global__|__host__|__host__ __device__}1 function. "
+ "It will cause warning with nvcc">,
----------------
Artem-B wrote:
It will potentially be a more serious issue, than a mere warning. the source code has both functions, it's possible that the implementation lives in different TUs. With clang, they will be treated as function overloads and things will work. With NVCC, they will end up being treated as GPU functions and that will result in potential ORD violation becaue the user will end up with two different GPU-side functions. It will be a problem during RDC compilation which may link both instances into a single GPU executable.
I'd rephrase it in more general terms. Maybe something along the lines of "Target-attribute based function overloads are not supported by NVCC and will be treated as a function redeclaration". We should tell what we're diagnosing, but make no opinion on whether it will be a problem in any specific case.
https://github.com/llvm/llvm-project/pull/77359
More information about the cfe-commits
mailing list