@@ -3095,21 +3095,6 @@ static bool checkWorkGroupSizeValues(Sema &S, Decl *D, const ParsedAttr &AL) {
3095
3095
return Result;
3096
3096
}
3097
3097
3098
- static Expr *checkWorkSizeAttrExpr (Sema &S, const ParsedAttr &CI, Expr *E) {
3099
- assert (E && " Attribute must have an argument." );
3100
-
3101
- if (!E->isInstantiationDependent ()) {
3102
- llvm::APSInt ArgVal;
3103
- ExprResult ICE = S.VerifyIntegerConstantExpression (E, &ArgVal);
3104
-
3105
- if (ICE.isInvalid ())
3106
- return nullptr ;
3107
-
3108
- E = ICE.get ();
3109
- }
3110
- return E;
3111
- }
3112
-
3113
3098
// Handles reqd_work_group_size and max_work_group_size.
3114
3099
template <typename WorkGroupAttr>
3115
3100
static void handleWorkGroupSize (Sema &S, Decl *D, const ParsedAttr &AL) {
@@ -3149,50 +3134,45 @@ static void handleWorkGroupSize(Sema &S, Decl *D, const ParsedAttr &AL) {
3149
3134
3150
3135
if (!XDimExpr->isValueDependent () && !YDimExpr->isValueDependent () &&
3151
3136
!ZDimExpr->isValueDependent ()) {
3152
- Optional<llvm::APSInt> XDimVal = XDimExpr->getIntegerConstantExpr (Ctx);
3153
- Optional<llvm::APSInt> YDimVal = YDimExpr->getIntegerConstantExpr (Ctx);
3154
- Optional<llvm::APSInt> ZDimVal = ZDimExpr->getIntegerConstantExpr (Ctx);
3155
-
3156
- XDimExpr = checkWorkSizeAttrExpr (S, AL, XDimExpr);
3157
- YDimExpr = checkWorkSizeAttrExpr (S, AL, YDimExpr);
3158
- ZDimExpr = checkWorkSizeAttrExpr (S, AL, ZDimExpr);
3137
+ llvm::APSInt XDimVal, YDimVal, ZDimVal;
3138
+ ExprResult XDim = S.VerifyIntegerConstantExpression (XDimExpr, &XDimVal);
3139
+ ExprResult YDim = S.VerifyIntegerConstantExpression (YDimExpr, &YDimVal);
3140
+ ExprResult ZDim = S.VerifyIntegerConstantExpression (ZDimExpr, &ZDimVal);
3159
3141
3160
- if (!XDimExpr || !YDimExpr || !ZDimExpr )
3142
+ if (XDim. isInvalid () )
3161
3143
return ;
3144
+ XDimExpr = XDim.get ();
3162
3145
3163
- // Skip SEMA if we're in a template, this will be diagnosed later.
3164
- if (S.getCurLexicalContext ()->isDependentContext ())
3146
+ if (YDim.isInvalid ())
3165
3147
return ;
3148
+ YDimExpr = YDim.get ();
3166
3149
3167
- if (AL.getKind () == ParsedAttr::AT_ReqdWorkGroupSize) {
3168
- if (const auto *A = D->getAttr <SYCLIntelNumSimdWorkItemsAttr>()) {
3169
- int64_t NumSimdWorkItems =
3170
- A->getValue ()->getIntegerConstantExpr (Ctx)->getSExtValue ();
3171
-
3172
- if (!(XDimVal->getZExtValue () % NumSimdWorkItems == 0 ||
3173
- YDimVal->getZExtValue () % NumSimdWorkItems == 0 ||
3174
- ZDimVal->getZExtValue () % NumSimdWorkItems == 0 )) {
3175
- S.Diag (A->getLocation (), diag::err_sycl_num_kernel_wrong_reqd_wg_size)
3176
- << A << AL;
3177
- S.Diag (AL.getLoc (), diag::note_conflicting_attribute);
3178
- return ;
3179
- }
3150
+ if (ZDim.isInvalid ())
3151
+ return ;
3152
+ ZDimExpr = ZDim.get ();
3153
+
3154
+ if (const auto *A = D->getAttr <SYCLIntelNumSimdWorkItemsAttr>()) {
3155
+ int64_t NumSimdWorkItems =
3156
+ A->getValue ()->getIntegerConstantExpr (Ctx)->getSExtValue ();
3157
+
3158
+ if (!(XDimVal.getZExtValue () % NumSimdWorkItems == 0 ||
3159
+ YDimVal.getZExtValue () % NumSimdWorkItems == 0 ||
3160
+ ZDimVal.getZExtValue () % NumSimdWorkItems == 0 )) {
3161
+ S.Diag (A->getLocation (), diag::err_sycl_num_kernel_wrong_reqd_wg_size)
3162
+ << A << AL;
3163
+ S.Diag (AL.getLoc (), diag::note_conflicting_attribute);
3164
+ return ;
3180
3165
}
3181
3166
}
3182
-
3183
- if (WorkGroupAttr *ExistingAttr = D->getAttr <WorkGroupAttr>()) {
3184
- Optional<llvm::APSInt> ExistingXDimVal = ExistingAttr->getXDimVal (Ctx);
3185
- Optional<llvm::APSInt> ExistingYDimVal = ExistingAttr->getYDimVal (Ctx);
3186
- Optional<llvm::APSInt> ExistingZDimVal = ExistingAttr->getZDimVal (Ctx);
3187
-
3167
+ if (const auto *ExistingAttr = D->getAttr <WorkGroupAttr>()) {
3188
3168
// Compare attribute arguments value and warn for a mismatch.
3189
- if (ExistingXDimVal != XDimVal || ExistingYDimVal != YDimVal ||
3190
- ExistingZDimVal != ZDimVal) {
3169
+ if (ExistingAttr->getXDimVal (Ctx) != XDimVal ||
3170
+ ExistingAttr->getYDimVal (Ctx) != YDimVal ||
3171
+ ExistingAttr->getZDimVal (Ctx) != ZDimVal) {
3191
3172
S.Diag (AL.getLoc (), diag::warn_duplicate_attribute) << AL;
3192
3173
S.Diag (ExistingAttr->getLocation (), diag::note_conflicting_attribute);
3193
3174
}
3194
3175
}
3195
-
3196
3176
if (!checkWorkGroupSizeValues (S, D, AL))
3197
3177
return ;
3198
3178
}
@@ -3255,7 +3235,7 @@ static void handleNumSimdWorkItemsAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
3255
3235
3256
3236
S.CheckDeprecatedSYCLAttributeSpelling (AL);
3257
3237
3258
- if (!E->isValueDependent () || !E-> isInstantiationDependent () ) {
3238
+ if (!E->isValueDependent ()) {
3259
3239
ASTContext &Ctx = S.getASTContext ();
3260
3240
llvm::APSInt ArgVal;
3261
3241
ExprResult ICE = S.VerifyIntegerConstantExpression (E, &ArgVal);
0 commit comments