aboutsummaryrefslogtreecommitdiff
path: root/clang/lib
diff options
context:
space:
mode:
authorAlexander Shaposhnikov <ashaposhnikov@google.com>2024-11-19 13:14:45 -0800
committerGitHub <noreply@github.com>2024-11-19 13:14:45 -0800
commitdf13acf344a4233777789d0052b3d09bec6a5180 (patch)
tree3c1ed1c931802d7774ee81151305c0e8ea845ec0 /clang/lib
parent174899f738b31216750ac59562475966b0b0be42 (diff)
downloadllvm-df13acf344a4233777789d0052b3d09bec6a5180.zip
llvm-df13acf344a4233777789d0052b3d09bec6a5180.tar.gz
llvm-df13acf344a4233777789d0052b3d09bec6a5180.tar.bz2
[CudaSPIRV] Add support for optional spir-v attributes (#116589)
Add support for optional spir-v attributes. Test plan: ninja check-all
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp6
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp4
2 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index e2437d1..ef6bb4f 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -635,7 +635,9 @@ void CodeGenFunction::EmitKernelMetadata(const FunctionDecl *FD,
CGM.GenKernelArgMetadata(Fn, FD, this);
- if (!getLangOpts().OpenCL)
+ if (!(getLangOpts().OpenCL ||
+ (getLangOpts().CUDA &&
+ getContext().getTargetInfo().getTriple().isSPIRV())))
return;
if (const VecTypeHintAttr *A = FD->getAttr<VecTypeHintAttr>()) {
@@ -1022,6 +1024,8 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
}
if (FD && (getLangOpts().OpenCL ||
+ (getLangOpts().CUDA &&
+ getContext().getTargetInfo().getTriple().isSPIRV()) ||
((getLangOpts().HIP || getLangOpts().OffloadViaLLVM) &&
getLangOpts().CUDAIsDevice))) {
// Add metadata for a kernel function.
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 0f5baa1..146d9c8 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -7368,7 +7368,9 @@ void Sema::ProcessDeclAttributeList(
// good to have a way to specify "these attributes must appear as a group",
// for these. Additionally, it would be good to have a way to specify "these
// attribute must never appear as a group" for attributes like cold and hot.
- if (!D->hasAttr<OpenCLKernelAttr>()) {
+ if (!(D->hasAttr<OpenCLKernelAttr>() ||
+ (D->hasAttr<CUDAGlobalAttr>() &&
+ Context.getTargetInfo().getTriple().isSPIRV()))) {
// These attributes cannot be applied to a non-kernel function.
if (const auto *A = D->getAttr<ReqdWorkGroupSizeAttr>()) {
// FIXME: This emits a different error message than