[clang] [Clang] Fix sema checks thinking kernels aren't kernels (PR #104460)
Joseph Huber via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 15 11:57:51 PDT 2024
================
@@ -7163,24 +7163,27 @@ void Sema::ProcessDeclAttributeList(
} else if (const auto *A = D->getAttr<OpenCLIntelReqdSubGroupSizeAttr>()) {
Diag(D->getLocation(), diag::err_opencl_kernel_attr) << A;
D->setInvalidDecl();
- } else if (!D->hasAttr<CUDAGlobalAttr>()) {
- if (const auto *A = D->getAttr<AMDGPUFlatWorkGroupSizeAttr>()) {
- Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
- << A << A->isRegularKeywordAttribute() << ExpectedKernelFunction;
- D->setInvalidDecl();
- } else if (const auto *A = D->getAttr<AMDGPUWavesPerEUAttr>()) {
- Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
- << A << A->isRegularKeywordAttribute() << ExpectedKernelFunction;
- D->setInvalidDecl();
- } else if (const auto *A = D->getAttr<AMDGPUNumSGPRAttr>()) {
- Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
- << A << A->isRegularKeywordAttribute() << ExpectedKernelFunction;
- D->setInvalidDecl();
- } else if (const auto *A = D->getAttr<AMDGPUNumVGPRAttr>()) {
- Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
- << A << A->isRegularKeywordAttribute() << ExpectedKernelFunction;
- D->setInvalidDecl();
- }
+ }
+ }
+ const FunctionType *FnTy = D->getFunctionType();
+ if (!D->hasAttr<CUDAGlobalAttr>() && !D->hasAttr<OpenCLKernelAttr>() &&
+ FnTy && FnTy->getCallConv() != CallingConv::CC_AMDGPUKernelCall) {
+ if (const auto *A = D->getAttr<AMDGPUFlatWorkGroupSizeAttr>()) {
+ Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
+ << A << A->isRegularKeywordAttribute() << ExpectedKernelFunction;
+ D->setInvalidDecl();
+ } else if (const auto *A = D->getAttr<AMDGPUWavesPerEUAttr>()) {
+ Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
+ << A << A->isRegularKeywordAttribute() << ExpectedKernelFunction;
+ D->setInvalidDecl();
+ } else if (const auto *A = D->getAttr<AMDGPUNumSGPRAttr>()) {
+ Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
+ << A << A->isRegularKeywordAttribute() << ExpectedKernelFunction;
+ D->setInvalidDecl();
+ } else if (const auto *A = D->getAttr<AMDGPUNumVGPRAttr>()) {
+ Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
+ << A << A->isRegularKeywordAttribute() << ExpectedKernelFunction;
+ D->setInvalidDecl();
----------------
jhuber6 wrote:
Nevermind, fails in practice because to put it in a uniform container we need to erase them all to `Attr *` which then seems to cause some unfortunate side effects.
https://github.com/llvm/llvm-project/pull/104460
More information about the cfe-commits
mailing list