@@ -5679,7 +5679,7 @@ static void handleLaunchBoundsAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
56795679static std::pair<Expr *, int >
56805680makeClusterDimsArgExpr (Sema &S, Expr *E, const CUDAClusterDimsAttr &AL,
56815681 const unsigned Idx) {
5682- if (S.DiagnoseUnexpandedParameterPack (E))
5682+ if (!E || S.DiagnoseUnexpandedParameterPack (E))
56835683 return {};
56845684
56855685 // Accept template arguments for now as they depend on something else.
@@ -5712,26 +5712,13 @@ CUDAClusterDimsAttr *Sema::createClusterDimsAttr(const AttributeCommonInfo &CI,
57125712 Expr *X, Expr *Y, Expr *Z) {
57135713 CUDAClusterDimsAttr TmpAttr (Context, CI, X, Y, Z);
57145714
5715- int ValX = 1 ;
5716- int ValY = 1 ;
5717- int ValZ = 1 ;
5715+ auto [NewX, ValX] = makeClusterDimsArgExpr (* this , X, TmpAttr, /* Idx= */ 0 ) ;
5716+ auto [NewY, ValY] = makeClusterDimsArgExpr (* this , Y, TmpAttr, /* Idx= */ 1 ) ;
5717+ auto [NewZ, ValZ] = makeClusterDimsArgExpr (* this , Z, TmpAttr, /* Idx= */ 2 ) ;
57185718
5719- std::tie (X, ValX) = makeClusterDimsArgExpr (*this , X, TmpAttr, /* Idx=*/ 0 );
5720- if (!X)
5719+ if (!NewX || (Y && !NewY) || (Z && !NewZ))
57215720 return nullptr ;
57225721
5723- if (Y) {
5724- std::tie (Y, ValY) = makeClusterDimsArgExpr (*this , Y, TmpAttr, /* Idx=*/ 1 );
5725- if (!Y)
5726- return nullptr ;
5727- }
5728-
5729- if (Z) {
5730- std::tie (Z, ValZ) = makeClusterDimsArgExpr (*this , Z, TmpAttr, /* Idx=*/ 2 );
5731- if (!Z)
5732- return nullptr ;
5733- }
5734-
57355722 int FlatDim = ValX * ValY * ValZ;
57365723 const llvm::Triple TT =
57375724 (!Context.getLangOpts ().CUDAIsDevice && Context.getAuxTargetInfo ())
@@ -5748,12 +5735,11 @@ CUDAClusterDimsAttr *Sema::createClusterDimsAttr(const AttributeCommonInfo &CI,
57485735 // A maximum of 8 thread blocks in a cluster is supported as a portable
57495736 // cluster size in CUDA. The number is 16 for AMDGPU.
57505737 if (FlatDim > MaxDim) {
5751- Diag (CI.getLoc (), diag::err_cuda_cluster_dims_too_large)
5752- << MaxDim << FlatDim;
5738+ Diag (CI.getLoc (), diag::err_cluster_dims_too_large) << MaxDim << FlatDim;
57535739 return nullptr ;
57545740 }
57555741
5756- return CUDAClusterDimsAttr::Create (Context, X, Y, Z , CI);
5742+ return CUDAClusterDimsAttr::Create (Context, NewX, NewY, NewZ , CI);
57575743}
57585744
57595745void Sema::addClusterDimsAttr (Decl *D, const AttributeCommonInfo &CI, Expr *X,
@@ -5772,7 +5758,7 @@ static void handleClusterDimsAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
57725758 if ((TTI.getTriple ().isNVPTX () && Arch < clang::OffloadArch::SM_90) ||
57735759 (TTI.getTriple ().isAMDGPU () &&
57745760 !TTI.hasFeatureEnabled (TTI.getTargetOpts ().FeatureMap , " clusters" ))) {
5775- S.Diag (AL.getLoc (), diag::err_cuda_cluster_attr_not_supported )
5761+ S.Diag (AL.getLoc (), diag::err_cluster_attr_not_supported )
57765762 << " __cluster_dims__" ;
57775763 return ;
57785764 }
@@ -5792,7 +5778,7 @@ static void handleNoClusterAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
57925778 if ((TTI.getTriple ().isNVPTX () && Arch < clang::OffloadArch::SM_90) ||
57935779 (TTI.getTriple ().isAMDGPU () &&
57945780 !TTI.hasFeatureEnabled (TTI.getTargetOpts ().FeatureMap , " clusters" ))) {
5795- S.Diag (AL.getLoc (), diag::err_cuda_cluster_attr_not_supported )
5781+ S.Diag (AL.getLoc (), diag::err_cluster_attr_not_supported )
57965782 << " __no_cluster__" ;
57975783 return ;
57985784 }
0 commit comments