From 91d917489f6f55e57bdccdf991277dcdba41a45e Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Tue, 21 Oct 2025 08:40:33 -0700 Subject: [PATCH 1/5] [SYCL][clang] Implement merging of add_ir_attributes_* attributes This commit adds the implementation logic for merging __sycl_detail__::add_ir_attributes_* attributes, which will enable the ability to apply multiple of the same attribute to the same declaration/definition, as long as the values associated to the same names in the attributes do not conflict. This is needed for SYCL free function support as the way SYCL properties are applied are through macros expanding to __sycl_detail__::add_ir_attributes_* with a single name-value-pair. Signed-off-by: Larsen, Steffen --- clang/lib/Sema/SemaSYCLDeclAttr.cpp | 157 +++++- .../AST/ast-attr-add-ir-attributes-merge.cpp | 494 +++++++++++++++++- .../SemaSYCL/attr-add-ir-attributes-merge.cpp | 100 +++- 3 files changed, 696 insertions(+), 55 deletions(-) diff --git a/clang/lib/Sema/SemaSYCLDeclAttr.cpp b/clang/lib/Sema/SemaSYCLDeclAttr.cpp index 58ee6e81534b..66de9897d57d 100644 --- a/clang/lib/Sema/SemaSYCLDeclAttr.cpp +++ b/clang/lib/Sema/SemaSYCLDeclAttr.cpp @@ -1537,6 +1537,24 @@ void SemaSYCL::addSYCLAddIRAttributesFunctionAttr( if (evaluateAddIRAttributesArgs(Attr->args_begin(), Attr->args_size(), *this, CI)) return; + + // There could be multiple of the same attribute applied to the same + // declaration. If so, we want to merge them. + // If there are still dependent expressions in the attribute, we delay merging + // till after instantiation. + if (!hasDependentExpr(Attr->args_begin(), Attr->args_size()) && + D->hasAttr()) { + Attr = mergeSYCLAddIRAttributesFunctionAttr(D, *Attr); + + // If null is returned, the attribute did not change after merge and we can + // exit. + if (!Attr) + return; + + // Otherwise, drop the old attribute so the new attribute can take its + // place. + D->dropAttr(); + } D->addAttr(Attr); // There are compile-time SYCL properties which we would like to turn into @@ -1574,6 +1592,24 @@ void SemaSYCL::addSYCLAddIRAttributesKernelParameterAttr( if (evaluateAddIRAttributesArgs(Attr->args_begin(), Attr->args_size(), *this, CI)) return; + + // There could be multiple of the same attribute applied to the same argument. + // If so, we want to merge them. + // If there are still dependent expressions in the attribute, we delay merging + // till after instantiation. + if (!hasDependentExpr(Attr->args_begin(), Attr->args_size()) && + D->hasAttr()) { + Attr = mergeSYCLAddIRAttributesKernelParameterAttr(D, *Attr); + + // If null is returned, the attribute did not change after merge and we can + // exit. + if (!Attr) + return; + + // Otherwise, drop the old attribute so the new attribute can take its + // place. + D->dropAttr(); + } D->addAttr(Attr); } @@ -1585,6 +1621,24 @@ void SemaSYCL::addSYCLAddIRAttributesGlobalVariableAttr( if (evaluateAddIRAttributesArgs(Attr->args_begin(), Attr->args_size(), *this, CI)) return; + + // There could be multiple of the same attribute applied to the same global + // variable. If so, we want to merge them. + // If there are still dependent expressions in the attribute, we delay merging + // till after instantiation. + if (!hasDependentExpr(Attr->args_begin(), Attr->args_size()) && + D->hasAttr()) { + Attr = mergeSYCLAddIRAttributesGlobalVariableAttr(D, *Attr); + + // If null is returned, the attribute did not change after merge and we can + // exit. + if (!Attr) + return; + + // Otherwise, drop the old attribute so the new attribute can take its + // place. + D->dropAttr(); + } D->addAttr(Attr); } @@ -2559,14 +2613,19 @@ void SemaSYCL::handleSYCLAddIRAttributesFunctionAttr(Decl *D, addSYCLAddIRAttributesFunctionAttr(D, A, Args); } -static bool hasSameSYCLAddIRAttributes( +static bool hasConflictingSYCLAddIRAttributes( const SmallVector, 4> &LAttrs, const SmallVector, 4> &RAttrs) { - std::set> LNameValSet{LAttrs.begin(), - LAttrs.end()}; - std::set> RNameValSet{RAttrs.begin(), - RAttrs.end()}; - return LNameValSet == RNameValSet; + std::unordered_map LNameValMap; + for (const std::pair &NameValuePair : LAttrs) + LNameValMap[NameValuePair.first] = NameValuePair.second; + + return std::any_of( + RAttrs.begin(), RAttrs.end(), + [&](const std::pair &NameValuePair) { + auto It = LNameValMap.find(NameValuePair.first); + return It != LNameValMap.end() && NameValuePair.second != It->second; + }); } template @@ -2574,15 +2633,19 @@ static bool checkSYCLAddIRAttributesMergeability(const AddIRAttrT &NewAttr, const AddIRAttrT &ExistingAttr, SemaSYCL &S) { ASTContext &Context = S.getASTContext(); - // If there are no dependent argument expressions and the filters or the - // attributes are different, then fail due to differing duplicates. - if (!S.hasDependentExpr(NewAttr.args_begin(), NewAttr.args_size()) && - !S.hasDependentExpr(ExistingAttr.args_begin(), - ExistingAttr.args_size()) && - (NewAttr.getAttributeFilter() != ExistingAttr.getAttributeFilter() || - !hasSameSYCLAddIRAttributes( - NewAttr.getAttributeNameValuePairs(Context), - ExistingAttr.getAttributeNameValuePairs(Context)))) { + + // If there are dependent argument expressions, then merging cannot be done + // yet. In that case, it is deferred till after instantiation. + if (S.hasDependentExpr(NewAttr.args_begin(), NewAttr.args_size()) || + S.hasDependentExpr(ExistingAttr.args_begin(), ExistingAttr.args_size())) + return true; + + // If the filters differ or the attributes are conflict, then fail due to + // differing duplicates. + if (NewAttr.getAttributeFilter() != ExistingAttr.getAttributeFilter() || + hasConflictingSYCLAddIRAttributes( + NewAttr.getAttributeNameValuePairs(Context), + ExistingAttr.getAttributeNameValuePairs(Context))) { S.Diag(ExistingAttr.getLoc(), diag::err_duplicate_attribute) << &NewAttr; S.Diag(NewAttr.getLoc(), diag::note_conflicting_attribute); return true; @@ -2590,12 +2653,58 @@ static bool checkSYCLAddIRAttributesMergeability(const AddIRAttrT &NewAttr, return false; } +template +static AddIRAttrT *getMergedSYCLAddIRAttribute(const AddIRAttrT &Attr1, + const AddIRAttrT &Attr2, + SemaSYCL &S) { + ASTContext &Context = S.getASTContext(); + bool AttrHasFilterList = Attr1.hasFilterList(); + + // Get the vectors of name-value-pairs here so we can create string references + // to them for the map. + llvm::SmallVector, 4> Attr1NVPairs = + Attr1.getAttributeNameValuePairs(Context); + llvm::SmallVector, 4> Attr2NVPairs = + Attr2.getAttributeNameValuePairs(Context); + + // Collect all the unique attribute names and their corresponding values. This + // relies on the uniqueness having been confirmed first and that the + // attributes appear in the same order as in the name-value-pairs. + llvm::SmallMapVector, 4> AttrExprByName; + for (const auto &[Attr, NVPairs] : {std::make_pair(Attr1, Attr1NVPairs), + std::make_pair(Attr2, Attr2NVPairs)}) { + for (size_t I = 0; I < NVPairs.size(); ++I) { + AttrExprByName[NVPairs[I].first] = std::make_pair( + (Attr.args_begin() + AttrHasFilterList)[I], + (Attr.args_begin() + AttrHasFilterList + (Attr.args_size() / 2))[I]); + } + } + + // Create a list of new arguments, starting with the filter if present. + llvm::SmallVector NewArgs; + NewArgs.resize(AttrExprByName.size() * 2 + AttrHasFilterList); + if (AttrHasFilterList) + NewArgs[0] = *Attr1.args_begin(); + + // Then insert all the unique attributes found previously. + for (size_t I = 0; I < AttrExprByName.size(); ++I) { + const std::pair &Exprs = AttrExprByName.begin()[I].second; + NewArgs[I + AttrHasFilterList] = Exprs.first; + NewArgs[I + AttrExprByName.size() + AttrHasFilterList] = Exprs.second; + } + + return AddIRAttrT::Create(Context, NewArgs.data(), NewArgs.size(), Attr1); +} + SYCLAddIRAttributesFunctionAttr *SemaSYCL::mergeSYCLAddIRAttributesFunctionAttr( Decl *D, const SYCLAddIRAttributesFunctionAttr &A) { if (const auto *ExistingAttr = D->getAttr()) { - checkSYCLAddIRAttributesMergeability(A, *ExistingAttr, *this); - return nullptr; + if (checkSYCLAddIRAttributesMergeability(A, *ExistingAttr, *this)) + return nullptr; + + D->dropAttr(); + return getMergedSYCLAddIRAttribute(A, *ExistingAttr, *this); } ASTContext &Context = getASTContext(); return A.clone(Context); @@ -2618,8 +2727,11 @@ SemaSYCL::mergeSYCLAddIRAttributesKernelParameterAttr( Decl *D, const SYCLAddIRAttributesKernelParameterAttr &A) { if (const auto *ExistingAttr = D->getAttr()) { - checkSYCLAddIRAttributesMergeability(A, *ExistingAttr, *this); - return nullptr; + if (checkSYCLAddIRAttributesMergeability(A, *ExistingAttr, *this)) + return nullptr; + + D->dropAttr(); + return getMergedSYCLAddIRAttribute(A, *ExistingAttr, *this); } ASTContext &Context = getASTContext(); return A.clone(Context); @@ -2642,8 +2754,11 @@ SemaSYCL::mergeSYCLAddIRAttributesGlobalVariableAttr( Decl *D, const SYCLAddIRAttributesGlobalVariableAttr &A) { if (const auto *ExistingAttr = D->getAttr()) { - checkSYCLAddIRAttributesMergeability(A, *ExistingAttr, *this); - return nullptr; + if (checkSYCLAddIRAttributesMergeability(A, *ExistingAttr, *this)) + return nullptr; + + D->dropAttr(); + return getMergedSYCLAddIRAttribute(A, *ExistingAttr, *this); } ASTContext &Context = getASTContext(); return A.clone(Context); diff --git a/clang/test/AST/ast-attr-add-ir-attributes-merge.cpp b/clang/test/AST/ast-attr-add-ir-attributes-merge.cpp index 235eb34b3c66..9b74f4cf4286 100644 --- a/clang/test/AST/ast-attr-add-ir-attributes-merge.cpp +++ b/clang/test/AST/ast-attr-add-ir-attributes-merge.cpp @@ -36,16 +36,16 @@ // CHECK-NEXT: SYCLAddIRAttributesFunctionAttr // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" // CHECK-NEXT: ConstantExpr {{.*}} 'int' // CHECK-NEXT: value: Int 1 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true // CHECK-NEXT: FunctionDecl [[FunctionRedecl1ID5:0x[0-9a-f]+]] prev [[FunctionRedecl1ID4]] {{.*}} FunctionRedecl1 'void ()' // CHECK-NEXT: SYCLAddIRAttributesFunctionAttr // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue @@ -65,7 +65,19 @@ // CHECK-NEXT: SYCLAddIRAttributesFunctionAttr // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue // CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" +// CHECK-NEXT: ConstantExpr {{.*}} 'int' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 0 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false // CHECK-NEXT: ConstantExpr {{.*}} 'bool' // CHECK-NEXT: value: Int 0 // CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false @@ -149,21 +161,21 @@ void FunctionRedecl2(); // CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" // CHECK-NEXT: ConstantExpr {{.*}} 'int' // CHECK-NEXT: value: Int 1 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true // CHECK-NEXT: FunctionDecl [[FunctionRedecl3ID5:0x[0-9a-f]+]] prev [[FunctionRedecl3ID4]] {{.*}} FunctionRedecl3 'void ()' // CHECK-NEXT: SYCLAddIRAttributesFunctionAttr // CHECK-NEXT: InitListExpr {{.*}} 'void' -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" // CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue // CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" @@ -233,6 +245,158 @@ void FunctionRedecl3(); [[__sycl_detail__::add_ir_attributes_function({"Attr1"}, "Attr1", "Attr2", 1, true)]] void FunctionRedecl3(); [[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] void FunctionRedecl3(){}; +// CHECK: FunctionDecl [[FunctionRedecl4ID1:0x[0-9a-f]+]] {{.*}} FunctionRedecl4 'void ()' +// CHECK-NEXT: FunctionDecl [[FunctionRedecl4ID2:0x[0-9a-f]+]] prev [[FunctionRedecl4ID1]] {{.*}} FunctionRedecl4 'void ()' +// CHECK-NEXT: SYCLAddIRAttributesFunctionAttr +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: ConstantExpr {{.*}} 'int' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +// CHECK-NEXT: FunctionDecl [[FunctionRedecl4ID3:0x[0-9a-f]+]] prev [[FunctionRedecl4ID2]] {{.*}} FunctionRedecl4 'void ()' +// CHECK-NEXT: SYCLAddIRAttributesFunctionAttr +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: ConstantExpr {{.*}} 'int' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +// CHECK-NEXT: FunctionDecl [[FunctionRedecl4ID4:0x[0-9a-f]+]] prev [[FunctionRedecl4ID3]] {{.*}} FunctionRedecl4 'void ()' +// CHECK-NEXT: SYCLAddIRAttributesFunctionAttr +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: ConstantExpr {{.*}} 'int' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +// CHECK-NEXT: FunctionDecl {{.*}} prev [[FunctionRedecl4ID4]] {{.*}} FunctionRedecl4 'void ()' +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: SYCLAddIRAttributesFunctionAttr +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" +// CHECK-NEXT: ConstantExpr {{.*}} 'int' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 0 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false +void FunctionRedecl4(); +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] void FunctionRedecl4(); +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] void FunctionRedecl4(); +[[__sycl_detail__::add_ir_attributes_function("Attr2", "Attr1", true, 1)]] void FunctionRedecl4(); +[[__sycl_detail__::add_ir_attributes_function("Attr3", false)]] void FunctionRedecl4(){}; + +// CHECK: FunctionDecl {{.*}} FunctionDecl1 'void ()' +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: SYCLAddIRAttributesFunctionAttr +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 0 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +// CHECK-NEXT: ConstantExpr {{.*}} 'int' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_function("Attr2", "Attr1", true, 1)]] // expected-error {{attribute '__sycl_detail__::add_ir_attributes_function' is already applied with different arguments}} +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, false)]] // expected-note {{conflicting attribute is here}} +[[__sycl_detail__::add_ir_attributes_function("Attr3", false)]] +void FunctionDecl1(){}; + +// CHECK: FunctionDecl {{.*}} FunctionDecl2 'void ()' +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: SYCLAddIRAttributesFunctionAttr +// CHECK-NEXT: InitListExpr {{.*}} 'void' +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: ConstantExpr {{.*}} 'int' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr2", "Attr1", true, 1)]] +[[__sycl_detail__::add_ir_attributes_function({"Attr3", "Attr1"}, "Attr1", "Attr2", 1, true)]] // expected-error 3{{attribute '__sycl_detail__::add_ir_attributes_function' is already applied with different arguments}} +[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, false)]] // expected-note {{conflicting attribute is here}} +[[__sycl_detail__::add_ir_attributes_function({"Attr1"}, "Attr1", "Attr2", 1, true)]] // expected-note {{conflicting attribute is here}} +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] // expected-note {{conflicting attribute is here}} +void FunctionDecl2(){}; + +// CHECK: FunctionDecl {{.*}} FunctionDecl3 'void ()' +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: SYCLAddIRAttributesFunctionAttr +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 0 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +// CHECK-NEXT: ConstantExpr {{.*}} 'int' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_function("Attr2", "Attr1", true, 1)]] +[[__sycl_detail__::add_ir_attributes_function("Attr3", false)]] +void FunctionDecl3(){}; + // CHECK: CXXRecordDecl [[GlobalVarStructRedecl1ID1:0x[0-9a-f]+]] {{.*}} struct GlobalVarStructRedecl1 // CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl1ID2:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl1ID1]] {{.*}} struct GlobalVarStructRedecl1 // CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr @@ -266,16 +430,16 @@ void FunctionRedecl3(); // CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" // CHECK-NEXT: ConstantExpr {{.*}} 'int' // CHECK-NEXT: value: Int 1 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true // CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl1ID5:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl1ID4]] {{.*}} struct GlobalVarStructRedecl1 // CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue @@ -301,7 +465,19 @@ void FunctionRedecl3(); // CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue // CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" +// CHECK-NEXT: ConstantExpr {{.*}} 'int' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 0 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false // CHECK-NEXT: ConstantExpr {{.*}} 'bool' // CHECK-NEXT: value: Int 0 // CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false @@ -386,21 +562,21 @@ struct GlobalVarStructRedecl2; // CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" // CHECK-NEXT: ConstantExpr {{.*}} 'int' // CHECK-NEXT: value: Int 1 // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true // CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl3ID5:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl3ID4]] {{.*}} struct GlobalVarStructRedecl3 // CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr // CHECK-NEXT: InitListExpr {{.*}} 'void' -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" // CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue // CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" @@ -477,6 +653,189 @@ struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1"}, "Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3; struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3{}; +// CHECK: CXXRecordDecl [[GlobalVarStructRedecl4ID1:0x[0-9a-f]+]] {{.*}} struct GlobalVarStructRedecl4 +// CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl4ID2:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl4ID1]] {{.*}} struct GlobalVarStructRedecl4 +// CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: ConstantExpr {{.*}} 'int' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +// CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl4ID3:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl4ID2]] {{.*}} struct GlobalVarStructRedecl4 +// CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: ConstantExpr {{.*}} 'int' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +// CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl4ID4:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl4ID3]] {{.*}} struct GlobalVarStructRedecl4 +// CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: ConstantExpr {{.*}} 'int' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +// CHECK-NEXT: CXXRecordDecl {{.*}} prev [[GlobalVarStructRedecl4ID4]] {{.*}} struct GlobalVarStructRedecl4 definition +// CHECK-NEXT: DefinitionData +// CHECK-NEXT: DefaultConstructor +// CHECK-NEXT: CopyConstructor +// CHECK-NEXT: MoveConstructor +// CHECK-NEXT: CopyAssignment +// CHECK-NEXT: MoveAssignment +// CHECK-NEXT: Destructor +// CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" +// CHECK-NEXT: ConstantExpr {{.*}} 'int' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 0 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false +// CHECK-NEXT: CXXRecordDecl {{.*}} implicit struct GlobalVarStructRedecl4 +struct GlobalVarStructRedecl4; +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl4; +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl4; +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr2", "Attr1", true, 1)]] GlobalVarStructRedecl4; +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr3", false)]] GlobalVarStructRedecl4{}; + +// CHECK: CXXRecordDecl {{.*}} struct GlobalVarStructDecl1 definition +// CHECK-NEXT: DefinitionData +// CHECK-NEXT: DefaultConstructor +// CHECK-NEXT: CopyConstructor +// CHECK-NEXT: MoveConstructor +// CHECK-NEXT: CopyAssignment +// CHECK-NEXT: MoveAssignment +// CHECK-NEXT: Destructor +// CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 0 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +// CHECK-NEXT: ConstantExpr {{.*}} 'int' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: CXXRecordDecl {{.*}} implicit struct GlobalVarStructDecl1 +struct +[[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_global_variable("Attr2", "Attr1", true, 1)]] // expected-error {{attribute '__sycl_detail__::add_ir_attributes_global_variable' is already applied with different arguments}} +[[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, false)]] // expected-note {{conflicting attribute is here}} +[[__sycl_detail__::add_ir_attributes_global_variable("Attr3", false)]] +GlobalVarStructDecl1{}; + +// CHECK: CXXRecordDecl {{.*}} struct GlobalVarStructDecl2 definition +// CHECK-NEXT: DefinitionData +// CHECK-NEXT: DefaultConstructor +// CHECK-NEXT: CopyConstructor +// CHECK-NEXT: MoveConstructor +// CHECK-NEXT: CopyAssignment +// CHECK-NEXT: MoveAssignment +// CHECK-NEXT: Destructor +// CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr +// CHECK-NEXT: InitListExpr {{.*}} 'void' +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: ConstantExpr {{.*}} 'int' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +// CHECK-NEXT: CXXRecordDecl {{.*}} implicit struct GlobalVarStructDecl2 +struct +[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr2", "Attr1", true, 1)]] +[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] // expected-error 3{{attribute '__sycl_detail__::add_ir_attributes_global_variable' is already applied with different arguments}} +[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, false)]] // expected-note {{conflicting attribute is here}} +[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1"}, "Attr1", "Attr2", 1, true)]] // expected-note {{conflicting attribute is here}} +[[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] // expected-note {{conflicting attribute is here}} +GlobalVarStructDecl2{}; + +// CHECK: CXXRecordDecl {{.*}} struct GlobalVarStructDecl3 definition +// CHECK-NEXT: DefinitionData +// CHECK-NEXT: DefaultConstructor +// CHECK-NEXT: CopyConstructor +// CHECK-NEXT: MoveConstructor +// CHECK-NEXT: CopyAssignment +// CHECK-NEXT: MoveAssignment +// CHECK-NEXT: Destructor +// CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 0 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +// CHECK-NEXT: ConstantExpr {{.*}} 'int' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: CXXRecordDecl {{.*}} implicit struct GlobalVarStructDecl3 +struct +[[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_global_variable("Attr2", "Attr1", true, 1)]] +[[__sycl_detail__::add_ir_attributes_global_variable("Attr3", false)]] +GlobalVarStructDecl3{}; + // CHECK: CXXRecordDecl {{.*}} referenced struct GlobalVarStructBase definition // CHECK-NEXT: DefinitionData // CHECK-NEXT: DefaultConstructor @@ -630,3 +989,94 @@ struct __attribute__((sycl_special_class)) SpecialClassStructInherit1 : SpecialC struct __attribute__((sycl_special_class)) SpecialClassStructInherit2 : SpecialClassStructInherit1 { void __init([[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr3", false)]] int x) override {} }; + +// CHECK: CXXRecordDecl {{.*}} struct SpecialClassStruct1 definition +// CHECK-NEXT: DefinitionData +// CHECK-NEXT: DefaultConstructor +// CHECK-NEXT: CopyConstructor +// CHECK-NEXT: MoveConstructor +// CHECK-NEXT: CopyAssignment +// CHECK-NEXT: MoveAssignment +// CHECK-NEXT: Destructor +// CHECK-NEXT: SYCLSpecialClassAttr +// CHECK-NEXT: CXXRecordDecl {{.*}} implicit struct SpecialClassStruct1 +// CHECK-NEXT: CXXMethodDecl {{.*}} __init 'void (int)' +// CHECK-NEXT: ParmVarDecl {{.*}} x 'int' +// CHECK-NEXT: SYCLAddIRAttributesKernelParameterAttr +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 0 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +// CHECK-NEXT: ConstantExpr {{.*}} 'int' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: CXXMethodDecl {{.*}} implicit operator= 'SpecialClassStruct1 &(const SpecialClassStruct1 &)' +// CHECK-NEXT: ParmVarDecl {{.*}} 'const SpecialClassStruct1 &' +// CHECK-NEXT: CXXMethodDecl {{.*}} implicit operator= 'SpecialClassStruct1 &(SpecialClassStruct1 &&)' +// CHECK-NEXT: ParmVarDecl {{.*}} 'SpecialClassStruct1 &&' +// CHECK-NEXT: CXXDestructorDecl {{.*}} implicit ~SpecialClassStruct1 'void ()' +struct __attribute__((sycl_special_class)) SpecialClassStruct1 { + virtual void __init( + [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr1", "Attr2", 1, true)]] + [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr2", "Attr1", true, 1)]] // expected-error {{attribute '__sycl_detail__::add_ir_attributes_kernel_parameter' is already applied with different arguments}} + [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr1", "Attr2", 1, false)]] // expected-note {{conflicting attribute is here}} + [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr3", false)]] + int x) {} +}; + +// CHECK: CXXRecordDecl {{.*}} struct SpecialClassStruct2 definition +// CHECK-NEXT: DefinitionData +// CHECK-NEXT: DefaultConstructor +// CHECK-NEXT: CopyConstructor +// CHECK-NEXT: MoveConstructor +// CHECK-NEXT: CopyAssignment +// CHECK-NEXT: MoveAssignment +// CHECK-NEXT: Destructor +// CHECK-NEXT: SYCLSpecialClassAttr +// CHECK-NEXT: CXXRecordDecl {{.*}} implicit struct SpecialClassStruct2 +// CHECK-NEXT: CXXMethodDecl {{.*}} __init 'void (int)' +// CHECK-NEXT: ParmVarDecl {{.*}} x 'int' +// CHECK-NEXT: SYCLAddIRAttributesKernelParameterAttr +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 0 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +// CHECK-NEXT: ConstantExpr {{.*}} 'int' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: CXXMethodDecl {{.*}} implicit operator= 'SpecialClassStruct2 &(const SpecialClassStruct2 &)' +// CHECK-NEXT: ParmVarDecl {{.*}} 'const SpecialClassStruct2 &' +// CHECK-NEXT: CXXMethodDecl {{.*}} implicit operator= 'SpecialClassStruct2 &(SpecialClassStruct2 &&)' +// CHECK-NEXT: ParmVarDecl {{.*}} 'SpecialClassStruct2 &&' +// CHECK-NEXT: CXXDestructorDecl {{.*}} implicit ~SpecialClassStruct2 'void ()' +struct __attribute__((sycl_special_class)) SpecialClassStruct2 { + virtual void __init( + [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr1", "Attr2", 1, true)]] + [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr2", "Attr1", true, 1)]] + [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr3", false)]] + int x) {} +}; diff --git a/clang/test/SemaSYCL/attr-add-ir-attributes-merge.cpp b/clang/test/SemaSYCL/attr-add-ir-attributes-merge.cpp index 05d355afe3ff..ec0a527f2031 100644 --- a/clang/test/SemaSYCL/attr-add-ir-attributes-merge.cpp +++ b/clang/test/SemaSYCL/attr-add-ir-attributes-merge.cpp @@ -4,43 +4,102 @@ // attributes to generate are the same. void FunctionRedecl1(); +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] void FunctionRedecl1(); // expected-note {{conflicting attribute is here}} [[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] void FunctionRedecl1(); -[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] void FunctionRedecl1(); -[[__sycl_detail__::add_ir_attributes_function("Attr2", "Attr1", true, 1)]] void FunctionRedecl1(); // expected-note {{conflicting attribute is here}} -[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, false)]] void FunctionRedecl1(); // expected-error {{attribute '__sycl_detail__::add_ir_attributes_function' is already applied with different arguments}} expected-note {{conflicting attribute is here}} -[[__sycl_detail__::add_ir_attributes_function("Attr3", false)]] void FunctionRedecl1(){}; // expected-error {{attribute '__sycl_detail__::add_ir_attributes_function' is already applied with different arguments}} +[[__sycl_detail__::add_ir_attributes_function("Attr2", "Attr1", true, 1)]] void FunctionRedecl1(); +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, false)]] void FunctionRedecl1(); // expected-error {{attribute '__sycl_detail__::add_ir_attributes_function' is already applied with different arguments}} +[[__sycl_detail__::add_ir_attributes_function("Attr3", false)]] void FunctionRedecl1(){}; [[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] void FunctionRedecl2(); void FunctionRedecl2(); void FunctionRedecl3(); -[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] void FunctionRedecl3(); +[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] void FunctionRedecl3(); // expected-note {{conflicting attribute is here}} [[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] void FunctionRedecl3(); [[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr2", "Attr1", true, 1)]] void FunctionRedecl3(); -[[__sycl_detail__::add_ir_attributes_function({"Attr3", "Attr1"}, "Attr1", "Attr2", 1, true)]] void FunctionRedecl3(); // expected-note {{conflicting attribute is here}} +[[__sycl_detail__::add_ir_attributes_function({"Attr3", "Attr1"}, "Attr1", "Attr2", 1, true)]] void FunctionRedecl3(); [[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, false)]] void FunctionRedecl3(); // expected-error {{attribute '__sycl_detail__::add_ir_attributes_function' is already applied with different arguments}} expected-note {{conflicting attribute is here}} [[__sycl_detail__::add_ir_attributes_function({"Attr1"}, "Attr1", "Attr2", 1, true)]] void FunctionRedecl3(); // expected-error {{attribute '__sycl_detail__::add_ir_attributes_function' is already applied with different arguments}} expected-note {{conflicting attribute is here}} [[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] void FunctionRedecl3(){}; // expected-error {{attribute '__sycl_detail__::add_ir_attributes_function' is already applied with different arguments}} +void FunctionRedecl4(); +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] void FunctionRedecl4(); +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] void FunctionRedecl4(); +[[__sycl_detail__::add_ir_attributes_function("Attr2", "Attr1", true, 1)]] void FunctionRedecl4(); +[[__sycl_detail__::add_ir_attributes_function("Attr3", false)]] void FunctionRedecl4(){}; + +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_function("Attr2", "Attr1", true, 1)]] // expected-error {{attribute '__sycl_detail__::add_ir_attributes_function' is already applied with different arguments}} +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, false)]] // expected-note {{conflicting attribute is here}} +[[__sycl_detail__::add_ir_attributes_function("Attr3", false)]] +void FunctionDecl1(){}; + +[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr2", "Attr1", true, 1)]] +[[__sycl_detail__::add_ir_attributes_function({"Attr3", "Attr1"}, "Attr1", "Attr2", 1, true)]] // expected-error 3{{attribute '__sycl_detail__::add_ir_attributes_function' is already applied with different arguments}} +[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, false)]] // expected-note {{conflicting attribute is here}} +[[__sycl_detail__::add_ir_attributes_function({"Attr1"}, "Attr1", "Attr2", 1, true)]] // expected-note {{conflicting attribute is here}} +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] // expected-note {{conflicting attribute is here}} +void FunctionDecl2(){}; + +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_function("Attr2", "Attr1", true, 1)]] +[[__sycl_detail__::add_ir_attributes_function("Attr3", false)]] +void FunctionDecl3(){}; + struct GlobalVarStructRedecl1; +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl1; // expected-note {{conflicting attribute is here}} struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl1; -struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl1; -struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr2", "Attr1", true, 1)]] GlobalVarStructRedecl1; // expected-note {{conflicting attribute is here}} -struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, false)]] GlobalVarStructRedecl1; // expected-error {{attribute '__sycl_detail__::add_ir_attributes_global_variable' is already applied with different arguments}} expected-note {{conflicting attribute is here}} -struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr3", false)]] GlobalVarStructRedecl1{}; // expected-error {{attribute '__sycl_detail__::add_ir_attributes_global_variable' is already applied with different arguments}} +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr2", "Attr1", true, 1)]] GlobalVarStructRedecl1; +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, false)]] GlobalVarStructRedecl1; // expected-error {{attribute '__sycl_detail__::add_ir_attributes_global_variable' is already applied with different arguments}} +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr3", false)]] GlobalVarStructRedecl1{}; struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl2; struct GlobalVarStructRedecl2; struct GlobalVarStructRedecl3; -struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3; +struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3; // expected-note {{conflicting attribute is here}} struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3; struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr2", "Attr1", true, 1)]] GlobalVarStructRedecl3; -struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3; // expected-note {{conflicting attribute is here}} +struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3; struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, false)]] GlobalVarStructRedecl3; // expected-error {{attribute '__sycl_detail__::add_ir_attributes_global_variable' is already applied with different arguments}} expected-note {{conflicting attribute is here}} struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1"}, "Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3; // expected-error {{attribute '__sycl_detail__::add_ir_attributes_global_variable' is already applied with different arguments}} expected-note {{conflicting attribute is here}} struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3{}; // expected-error {{attribute '__sycl_detail__::add_ir_attributes_global_variable' is already applied with different arguments}} +struct GlobalVarStructRedecl4; +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl4; +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl4; +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr2", "Attr1", true, 1)]] GlobalVarStructRedecl4; +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr3", false)]] GlobalVarStructRedecl4{}; + +struct +[[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_global_variable("Attr2", "Attr1", true, 1)]] // expected-error {{attribute '__sycl_detail__::add_ir_attributes_global_variable' is already applied with different arguments}} +[[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, false)]] // expected-note {{conflicting attribute is here}} +[[__sycl_detail__::add_ir_attributes_global_variable("Attr3", false)]] +GlobalVarStructDecl1{}; + +struct +[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr2", "Attr1", true, 1)]] +[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] // expected-error 3{{attribute '__sycl_detail__::add_ir_attributes_global_variable' is already applied with different arguments}} +[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, false)]] // expected-note {{conflicting attribute is here}} +[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1"}, "Attr1", "Attr2", 1, true)]] // expected-note {{conflicting attribute is here}} +[[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] // expected-note {{conflicting attribute is here}} +GlobalVarStructDecl2{}; + +struct +[[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_global_variable("Attr2", "Attr1", true, 1)]] +[[__sycl_detail__::add_ir_attributes_global_variable("Attr3", false)]] +GlobalVarStructDecl3{}; + struct GlobalVarStructBase {}; struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructInherit1 : GlobalVarStructBase{}; struct GlobalVarStructInherit2 : GlobalVarStructInherit1 {}; @@ -55,3 +114,20 @@ struct __attribute__((sycl_special_class)) SpecialClassStructInherit1 : SpecialC struct __attribute__((sycl_special_class)) SpecialClassStructInherit2 : SpecialClassStructInherit1 { void __init([[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr3", false)]] int x) override {} }; + +struct __attribute__((sycl_special_class)) SpecialClassStruct1 { + virtual void __init( + [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr1", "Attr2", 1, true)]] + [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr2", "Attr1", true, 1)]] // expected-error {{attribute '__sycl_detail__::add_ir_attributes_kernel_parameter' is already applied with different arguments}} + [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr1", "Attr2", 1, false)]] // expected-note {{conflicting attribute is here}} + [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr3", false)]] + int x) {} +}; + +struct __attribute__((sycl_special_class)) SpecialClassStruct2 { + virtual void __init( + [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr1", "Attr2", 1, true)]] + [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr2", "Attr1", true, 1)]] + [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr3", false)]] + int x) {} +}; From 12423f59f727ae2065c79c6ca48e4bc919cdfc5b Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Thu, 23 Oct 2025 02:18:41 -0700 Subject: [PATCH 2/5] Remove expected errors in ast tests and fix comment Signed-off-by: Larsen, Steffen --- clang/lib/Sema/SemaSYCLDeclAttr.cpp | 2 +- .../AST/ast-attr-add-ir-attributes-merge.cpp | 28 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/clang/lib/Sema/SemaSYCLDeclAttr.cpp b/clang/lib/Sema/SemaSYCLDeclAttr.cpp index 66de9897d57d..a05a704ec9f3 100644 --- a/clang/lib/Sema/SemaSYCLDeclAttr.cpp +++ b/clang/lib/Sema/SemaSYCLDeclAttr.cpp @@ -2640,7 +2640,7 @@ static bool checkSYCLAddIRAttributesMergeability(const AddIRAttrT &NewAttr, S.hasDependentExpr(ExistingAttr.args_begin(), ExistingAttr.args_size())) return true; - // If the filters differ or the attributes are conflict, then fail due to + // If the filters differ or the attributes are conflicting, then fail due to // differing duplicates. if (NewAttr.getAttributeFilter() != ExistingAttr.getAttributeFilter() || hasConflictingSYCLAddIRAttributes( diff --git a/clang/test/AST/ast-attr-add-ir-attributes-merge.cpp b/clang/test/AST/ast-attr-add-ir-attributes-merge.cpp index 9b74f4cf4286..a36b8123ff5e 100644 --- a/clang/test/AST/ast-attr-add-ir-attributes-merge.cpp +++ b/clang/test/AST/ast-attr-add-ir-attributes-merge.cpp @@ -338,8 +338,8 @@ void FunctionRedecl4(); // CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 [[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] [[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] -[[__sycl_detail__::add_ir_attributes_function("Attr2", "Attr1", true, 1)]] // expected-error {{attribute '__sycl_detail__::add_ir_attributes_function' is already applied with different arguments}} -[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, false)]] // expected-note {{conflicting attribute is here}} +[[__sycl_detail__::add_ir_attributes_function("Attr2", "Attr1", true, 1)]] +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, false)]] [[__sycl_detail__::add_ir_attributes_function("Attr3", false)]] void FunctionDecl1(){}; @@ -364,10 +364,10 @@ void FunctionDecl1(){}; [[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] [[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] [[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr2", "Attr1", true, 1)]] -[[__sycl_detail__::add_ir_attributes_function({"Attr3", "Attr1"}, "Attr1", "Attr2", 1, true)]] // expected-error 3{{attribute '__sycl_detail__::add_ir_attributes_function' is already applied with different arguments}} -[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, false)]] // expected-note {{conflicting attribute is here}} -[[__sycl_detail__::add_ir_attributes_function({"Attr1"}, "Attr1", "Attr2", 1, true)]] // expected-note {{conflicting attribute is here}} -[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] // expected-note {{conflicting attribute is here}} +[[__sycl_detail__::add_ir_attributes_function({"Attr3", "Attr1"}, "Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, false)]] +[[__sycl_detail__::add_ir_attributes_function({"Attr1"}, "Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] void FunctionDecl2(){}; // CHECK: FunctionDecl {{.*}} FunctionDecl3 'void ()' @@ -761,8 +761,8 @@ struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr3", false)]] Gl struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] -[[__sycl_detail__::add_ir_attributes_global_variable("Attr2", "Attr1", true, 1)]] // expected-error {{attribute '__sycl_detail__::add_ir_attributes_global_variable' is already applied with different arguments}} -[[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, false)]] // expected-note {{conflicting attribute is here}} +[[__sycl_detail__::add_ir_attributes_global_variable("Attr2", "Attr1", true, 1)]] +[[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, false)]] [[__sycl_detail__::add_ir_attributes_global_variable("Attr3", false)]] GlobalVarStructDecl1{}; @@ -795,10 +795,10 @@ struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr2", "Attr1", true, 1)]] -[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] // expected-error 3{{attribute '__sycl_detail__::add_ir_attributes_global_variable' is already applied with different arguments}} -[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, false)]] // expected-note {{conflicting attribute is here}} -[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1"}, "Attr1", "Attr2", 1, true)]] // expected-note {{conflicting attribute is here}} -[[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] // expected-note {{conflicting attribute is here}} +[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, false)]] +[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1"}, "Attr1", "Attr2", 1, true)]] +[[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructDecl2{}; // CHECK: CXXRecordDecl {{.*}} struct GlobalVarStructDecl3 definition @@ -1030,8 +1030,8 @@ struct __attribute__((sycl_special_class)) SpecialClassStructInherit2 : SpecialC struct __attribute__((sycl_special_class)) SpecialClassStruct1 { virtual void __init( [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr1", "Attr2", 1, true)]] - [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr2", "Attr1", true, 1)]] // expected-error {{attribute '__sycl_detail__::add_ir_attributes_kernel_parameter' is already applied with different arguments}} - [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr1", "Attr2", 1, false)]] // expected-note {{conflicting attribute is here}} + [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr2", "Attr1", true, 1)]] + [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr1", "Attr2", 1, false)]] [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr3", false)]] int x) {} }; From 2d5890c7f98c8f51143627968fa9a53eddec8f71 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Thu, 23 Oct 2025 02:21:52 -0700 Subject: [PATCH 3/5] Remove redundant attribute removal Signed-off-by: Larsen, Steffen --- clang/lib/Sema/SemaSYCLDeclAttr.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/clang/lib/Sema/SemaSYCLDeclAttr.cpp b/clang/lib/Sema/SemaSYCLDeclAttr.cpp index a05a704ec9f3..22b72b89133d 100644 --- a/clang/lib/Sema/SemaSYCLDeclAttr.cpp +++ b/clang/lib/Sema/SemaSYCLDeclAttr.cpp @@ -1550,10 +1550,6 @@ void SemaSYCL::addSYCLAddIRAttributesFunctionAttr( // exit. if (!Attr) return; - - // Otherwise, drop the old attribute so the new attribute can take its - // place. - D->dropAttr(); } D->addAttr(Attr); @@ -1605,10 +1601,6 @@ void SemaSYCL::addSYCLAddIRAttributesKernelParameterAttr( // exit. if (!Attr) return; - - // Otherwise, drop the old attribute so the new attribute can take its - // place. - D->dropAttr(); } D->addAttr(Attr); } @@ -1634,10 +1626,6 @@ void SemaSYCL::addSYCLAddIRAttributesGlobalVariableAttr( // exit. if (!Attr) return; - - // Otherwise, drop the old attribute so the new attribute can take its - // place. - D->dropAttr(); } D->addAttr(Attr); } From 1f7c8a2d9d94fb98b64a93c71452d9e519658c6f Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Tue, 28 Oct 2025 08:11:15 -0700 Subject: [PATCH 4/5] Remove invalid AST cases Signed-off-by: Larsen, Steffen --- .../AST/ast-attr-add-ir-attributes-merge.cpp | 457 +----------------- 1 file changed, 13 insertions(+), 444 deletions(-) diff --git a/clang/test/AST/ast-attr-add-ir-attributes-merge.cpp b/clang/test/AST/ast-attr-add-ir-attributes-merge.cpp index a36b8123ff5e..f39e3011b9e7 100644 --- a/clang/test/AST/ast-attr-add-ir-attributes-merge.cpp +++ b/clang/test/AST/ast-attr-add-ir-attributes-merge.cpp @@ -122,9 +122,6 @@ void FunctionRedecl2(); // CHECK: FunctionDecl [[FunctionRedecl3ID1:0x[0-9a-f]+]] {{.*}} FunctionRedecl3 'void ()' // CHECK-NEXT: FunctionDecl [[FunctionRedecl3ID2:0x[0-9a-f]+]] prev [[FunctionRedecl3ID1]] {{.*}} FunctionRedecl3 'void ()' // CHECK-NEXT: SYCLAddIRAttributesFunctionAttr -// CHECK-NEXT: InitListExpr {{.*}} 'void' -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue // CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" @@ -139,9 +136,6 @@ void FunctionRedecl2(); // CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true // CHECK-NEXT: FunctionDecl [[FunctionRedecl3ID3:0x[0-9a-f]+]] prev [[FunctionRedecl3ID2]] {{.*}} FunctionRedecl3 'void ()' // CHECK-NEXT: SYCLAddIRAttributesFunctionAttr -// CHECK-NEXT: InitListExpr {{.*}} 'void' -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue // CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" @@ -156,59 +150,6 @@ void FunctionRedecl2(); // CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true // CHECK-NEXT: FunctionDecl [[FunctionRedecl3ID4:0x[0-9a-f]+]] prev [[FunctionRedecl3ID3]] {{.*}} FunctionRedecl3 'void ()' // CHECK-NEXT: SYCLAddIRAttributesFunctionAttr -// CHECK-NEXT: InitListExpr {{.*}} 'void' -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" -// CHECK-NEXT: ConstantExpr {{.*}} 'int' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -// CHECK-NEXT: FunctionDecl [[FunctionRedecl3ID5:0x[0-9a-f]+]] prev [[FunctionRedecl3ID4]] {{.*}} FunctionRedecl3 'void ()' -// CHECK-NEXT: SYCLAddIRAttributesFunctionAttr -// CHECK-NEXT: InitListExpr {{.*}} 'void' -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" -// CHECK-NEXT: ConstantExpr {{.*}} 'int' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -// CHECK-NEXT: FunctionDecl [[FunctionRedecl3ID6:0x[0-9a-f]+]] prev [[FunctionRedecl3ID5]] {{.*}} FunctionRedecl3 'void ()' -// CHECK-NEXT: SYCLAddIRAttributesFunctionAttr -// CHECK-NEXT: InitListExpr {{.*}} 'void' -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" -// CHECK-NEXT: ConstantExpr {{.*}} 'int' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 0 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false -// CHECK-NEXT: FunctionDecl [[FunctionRedecl3ID7:0x[0-9a-f]+]] prev [[FunctionRedecl3ID6]] {{.*}} FunctionRedecl3 'void ()' -// CHECK-NEXT: SYCLAddIRAttributesFunctionAttr -// CHECK-NEXT: InitListExpr {{.*}} 'void' -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue // CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" @@ -221,74 +162,7 @@ void FunctionRedecl2(); // CHECK-NEXT: ConstantExpr {{.*}} 'bool' // CHECK-NEXT: value: Int 1 // CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -// CHECK-NEXT: FunctionDecl {{.*}} prev [[FunctionRedecl3ID7]] {{.*}} FunctionRedecl3 'void ()' -// CHECK-NEXT: CompoundStmt -// CHECK-NEXT: SYCLAddIRAttributesFunctionAttr -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" -// CHECK-NEXT: ConstantExpr {{.*}} 'int' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -void FunctionRedecl3(); -[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] void FunctionRedecl3(); -[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] void FunctionRedecl3(); -[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr2", "Attr1", true, 1)]] void FunctionRedecl3(); -[[__sycl_detail__::add_ir_attributes_function({"Attr3", "Attr1"}, "Attr1", "Attr2", 1, true)]] void FunctionRedecl3(); -[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, false)]] void FunctionRedecl3(); -[[__sycl_detail__::add_ir_attributes_function({"Attr1"}, "Attr1", "Attr2", 1, true)]] void FunctionRedecl3(); -[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] void FunctionRedecl3(){}; - -// CHECK: FunctionDecl [[FunctionRedecl4ID1:0x[0-9a-f]+]] {{.*}} FunctionRedecl4 'void ()' -// CHECK-NEXT: FunctionDecl [[FunctionRedecl4ID2:0x[0-9a-f]+]] prev [[FunctionRedecl4ID1]] {{.*}} FunctionRedecl4 'void ()' -// CHECK-NEXT: SYCLAddIRAttributesFunctionAttr -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" -// CHECK-NEXT: ConstantExpr {{.*}} 'int' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -// CHECK-NEXT: FunctionDecl [[FunctionRedecl4ID3:0x[0-9a-f]+]] prev [[FunctionRedecl4ID2]] {{.*}} FunctionRedecl4 'void ()' -// CHECK-NEXT: SYCLAddIRAttributesFunctionAttr -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" -// CHECK-NEXT: ConstantExpr {{.*}} 'int' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -// CHECK-NEXT: FunctionDecl [[FunctionRedecl4ID4:0x[0-9a-f]+]] prev [[FunctionRedecl4ID3]] {{.*}} FunctionRedecl4 'void ()' -// CHECK-NEXT: SYCLAddIRAttributesFunctionAttr -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" -// CHECK-NEXT: ConstantExpr {{.*}} 'int' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -// CHECK-NEXT: FunctionDecl {{.*}} prev [[FunctionRedecl4ID4]] {{.*}} FunctionRedecl4 'void ()' +// CHECK-NEXT: FunctionDecl {{.*}} prev [[FunctionRedecl3ID4]] {{.*}} FunctionRedecl3 'void ()' // CHECK-NEXT: CompoundStmt // CHECK-NEXT: SYCLAddIRAttributesFunctionAttr // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue @@ -309,11 +183,11 @@ void FunctionRedecl3(); // CHECK-NEXT: ConstantExpr {{.*}} 'bool' // CHECK-NEXT: value: Int 0 // CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false -void FunctionRedecl4(); -[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] void FunctionRedecl4(); -[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] void FunctionRedecl4(); -[[__sycl_detail__::add_ir_attributes_function("Attr2", "Attr1", true, 1)]] void FunctionRedecl4(); -[[__sycl_detail__::add_ir_attributes_function("Attr3", false)]] void FunctionRedecl4(){}; +void FunctionRedecl3(); +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] void FunctionRedecl3(); +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] void FunctionRedecl3(); +[[__sycl_detail__::add_ir_attributes_function("Attr2", "Attr1", true, 1)]] void FunctionRedecl3(); +[[__sycl_detail__::add_ir_attributes_function("Attr3", false)]] void FunctionRedecl3(){}; // CHECK: FunctionDecl {{.*}} FunctionDecl1 'void ()' // CHECK-NEXT: CompoundStmt @@ -339,64 +213,9 @@ void FunctionRedecl4(); [[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] [[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] [[__sycl_detail__::add_ir_attributes_function("Attr2", "Attr1", true, 1)]] -[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, false)]] [[__sycl_detail__::add_ir_attributes_function("Attr3", false)]] void FunctionDecl1(){}; -// CHECK: FunctionDecl {{.*}} FunctionDecl2 'void ()' -// CHECK-NEXT: CompoundStmt -// CHECK-NEXT: SYCLAddIRAttributesFunctionAttr -// CHECK-NEXT: InitListExpr {{.*}} 'void' -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" -// CHECK-NEXT: ConstantExpr {{.*}} 'int' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] -[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] -[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr2", "Attr1", true, 1)]] -[[__sycl_detail__::add_ir_attributes_function({"Attr3", "Attr1"}, "Attr1", "Attr2", 1, true)]] -[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, false)]] -[[__sycl_detail__::add_ir_attributes_function({"Attr1"}, "Attr1", "Attr2", 1, true)]] -[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] -void FunctionDecl2(){}; - -// CHECK: FunctionDecl {{.*}} FunctionDecl3 'void ()' -// CHECK-NEXT: CompoundStmt -// CHECK-NEXT: SYCLAddIRAttributesFunctionAttr -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 0 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -// CHECK-NEXT: ConstantExpr {{.*}} 'int' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 -[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] -[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] -[[__sycl_detail__::add_ir_attributes_function("Attr2", "Attr1", true, 1)]] -[[__sycl_detail__::add_ir_attributes_function("Attr3", false)]] -void FunctionDecl3(){}; - // CHECK: CXXRecordDecl [[GlobalVarStructRedecl1ID1:0x[0-9a-f]+]] {{.*}} struct GlobalVarStructRedecl1 // CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl1ID2:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl1ID1]] {{.*}} struct GlobalVarStructRedecl1 // CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr @@ -523,9 +342,6 @@ struct GlobalVarStructRedecl2; // CHECK: CXXRecordDecl [[GlobalVarStructRedecl3ID1:0x[0-9a-f]+]] {{.*}} struct GlobalVarStructRedecl3 // CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl3ID2:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl3ID1]] {{.*}} struct GlobalVarStructRedecl3 // CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr -// CHECK-NEXT: InitListExpr {{.*}} 'void' -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue // CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" @@ -540,9 +356,6 @@ struct GlobalVarStructRedecl2; // CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true // CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl3ID3:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl3ID2]] {{.*}} struct GlobalVarStructRedecl3 // CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr -// CHECK-NEXT: InitListExpr {{.*}} 'void' -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue // CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" @@ -557,26 +370,6 @@ struct GlobalVarStructRedecl2; // CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true // CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl3ID4:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl3ID3]] {{.*}} struct GlobalVarStructRedecl3 // CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr -// CHECK-NEXT: InitListExpr {{.*}} 'void' -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" -// CHECK-NEXT: ConstantExpr {{.*}} 'int' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -// CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl3ID5:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl3ID4]] {{.*}} struct GlobalVarStructRedecl3 -// CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr -// CHECK-NEXT: InitListExpr {{.*}} 'void' -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue // CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" @@ -589,114 +382,7 @@ struct GlobalVarStructRedecl2; // CHECK-NEXT: ConstantExpr {{.*}} 'bool' // CHECK-NEXT: value: Int 1 // CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -// CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl3ID6:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl3ID5]] {{.*}} struct GlobalVarStructRedecl3 -// CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr -// CHECK-NEXT: InitListExpr {{.*}} 'void' -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" -// CHECK-NEXT: ConstantExpr {{.*}} 'int' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 0 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false -// CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl3ID7:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl3ID6]] {{.*}} struct GlobalVarStructRedecl3 -// CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr -// CHECK-NEXT: InitListExpr {{.*}} 'void' -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" -// CHECK-NEXT: ConstantExpr {{.*}} 'int' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -// CHECK-NEXT: CXXRecordDecl {{.*}} prev [[GlobalVarStructRedecl3ID7]] {{.*}} struct GlobalVarStructRedecl3 definition -// CHECK-NEXT: DefinitionData -// CHECK-NEXT: DefaultConstructor -// CHECK-NEXT: CopyConstructor -// CHECK-NEXT: MoveConstructor -// CHECK-NEXT: CopyAssignment -// CHECK-NEXT: MoveAssignment -// CHECK-NEXT: Destructor -// CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" -// CHECK-NEXT: ConstantExpr {{.*}} 'int' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -// CHECK-NEXT: CXXRecordDecl {{.*}} implicit struct GlobalVarStructRedecl3 -struct GlobalVarStructRedecl3; -struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3; -struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3; -struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr2", "Attr1", true, 1)]] GlobalVarStructRedecl3; -struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr3", "Attr1"}, "Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3; -struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, false)]] GlobalVarStructRedecl3; -struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1"}, "Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3; -struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3{}; - -// CHECK: CXXRecordDecl [[GlobalVarStructRedecl4ID1:0x[0-9a-f]+]] {{.*}} struct GlobalVarStructRedecl4 -// CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl4ID2:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl4ID1]] {{.*}} struct GlobalVarStructRedecl4 -// CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" -// CHECK-NEXT: ConstantExpr {{.*}} 'int' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -// CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl4ID3:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl4ID2]] {{.*}} struct GlobalVarStructRedecl4 -// CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" -// CHECK-NEXT: ConstantExpr {{.*}} 'int' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -// CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl4ID4:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl4ID3]] {{.*}} struct GlobalVarStructRedecl4 -// CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" -// CHECK-NEXT: ConstantExpr {{.*}} 'int' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -// CHECK-NEXT: CXXRecordDecl {{.*}} prev [[GlobalVarStructRedecl4ID4]] {{.*}} struct GlobalVarStructRedecl4 definition +// CHECK-NEXT: CXXRecordDecl {{.*}} prev [[GlobalVarStructRedecl3ID4]] {{.*}} struct GlobalVarStructRedecl3 definition // CHECK-NEXT: DefinitionData // CHECK-NEXT: DefaultConstructor // CHECK-NEXT: CopyConstructor @@ -723,12 +409,12 @@ struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, // CHECK-NEXT: ConstantExpr {{.*}} 'bool' // CHECK-NEXT: value: Int 0 // CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false -// CHECK-NEXT: CXXRecordDecl {{.*}} implicit struct GlobalVarStructRedecl4 -struct GlobalVarStructRedecl4; -struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl4; -struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl4; -struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr2", "Attr1", true, 1)]] GlobalVarStructRedecl4; -struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr3", false)]] GlobalVarStructRedecl4{}; +// CHECK-NEXT: CXXRecordDecl {{.*}} implicit struct GlobalVarStructRedecl3 +struct GlobalVarStructRedecl3; +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3; +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3; +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr2", "Attr1", true, 1)]] GlobalVarStructRedecl3; +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr3", false)]] GlobalVarStructRedecl3{}; // CHECK: CXXRecordDecl {{.*}} struct GlobalVarStructDecl1 definition // CHECK-NEXT: DefinitionData @@ -762,80 +448,9 @@ struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] [[__sycl_detail__::add_ir_attributes_global_variable("Attr2", "Attr1", true, 1)]] -[[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, false)]] [[__sycl_detail__::add_ir_attributes_global_variable("Attr3", false)]] GlobalVarStructDecl1{}; -// CHECK: CXXRecordDecl {{.*}} struct GlobalVarStructDecl2 definition -// CHECK-NEXT: DefinitionData -// CHECK-NEXT: DefaultConstructor -// CHECK-NEXT: CopyConstructor -// CHECK-NEXT: MoveConstructor -// CHECK-NEXT: CopyAssignment -// CHECK-NEXT: MoveAssignment -// CHECK-NEXT: Destructor -// CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr -// CHECK-NEXT: InitListExpr {{.*}} 'void' -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" -// CHECK-NEXT: ConstantExpr {{.*}} 'int' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -// CHECK-NEXT: CXXRecordDecl {{.*}} implicit struct GlobalVarStructDecl2 -struct -[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] -[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] -[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr2", "Attr1", true, 1)]] -[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] -[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, false)]] -[[__sycl_detail__::add_ir_attributes_global_variable({"Attr1"}, "Attr1", "Attr2", 1, true)]] -[[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] -GlobalVarStructDecl2{}; - -// CHECK: CXXRecordDecl {{.*}} struct GlobalVarStructDecl3 definition -// CHECK-NEXT: DefinitionData -// CHECK-NEXT: DefaultConstructor -// CHECK-NEXT: CopyConstructor -// CHECK-NEXT: MoveConstructor -// CHECK-NEXT: CopyAssignment -// CHECK-NEXT: MoveAssignment -// CHECK-NEXT: Destructor -// CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 0 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -// CHECK-NEXT: ConstantExpr {{.*}} 'int' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 -// CHECK-NEXT: CXXRecordDecl {{.*}} implicit struct GlobalVarStructDecl3 -struct -[[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] -[[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] -[[__sycl_detail__::add_ir_attributes_global_variable("Attr2", "Attr1", true, 1)]] -[[__sycl_detail__::add_ir_attributes_global_variable("Attr3", false)]] -GlobalVarStructDecl3{}; - // CHECK: CXXRecordDecl {{.*}} referenced struct GlobalVarStructBase definition // CHECK-NEXT: DefinitionData // CHECK-NEXT: DefaultConstructor @@ -1028,52 +643,6 @@ struct __attribute__((sycl_special_class)) SpecialClassStructInherit2 : SpecialC // CHECK-NEXT: ParmVarDecl {{.*}} 'SpecialClassStruct1 &&' // CHECK-NEXT: CXXDestructorDecl {{.*}} implicit ~SpecialClassStruct1 'void ()' struct __attribute__((sycl_special_class)) SpecialClassStruct1 { - virtual void __init( - [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr1", "Attr2", 1, true)]] - [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr2", "Attr1", true, 1)]] - [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr1", "Attr2", 1, false)]] - [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr3", false)]] - int x) {} -}; - -// CHECK: CXXRecordDecl {{.*}} struct SpecialClassStruct2 definition -// CHECK-NEXT: DefinitionData -// CHECK-NEXT: DefaultConstructor -// CHECK-NEXT: CopyConstructor -// CHECK-NEXT: MoveConstructor -// CHECK-NEXT: CopyAssignment -// CHECK-NEXT: MoveAssignment -// CHECK-NEXT: Destructor -// CHECK-NEXT: SYCLSpecialClassAttr -// CHECK-NEXT: CXXRecordDecl {{.*}} implicit struct SpecialClassStruct2 -// CHECK-NEXT: CXXMethodDecl {{.*}} __init 'void (int)' -// CHECK-NEXT: ParmVarDecl {{.*}} x 'int' -// CHECK-NEXT: SYCLAddIRAttributesKernelParameterAttr -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" -// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue -// CHECK-NEXT: value: LValue -// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 0 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false -// CHECK-NEXT: ConstantExpr {{.*}} 'bool' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -// CHECK-NEXT: ConstantExpr {{.*}} 'int' -// CHECK-NEXT: value: Int 1 -// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 -// CHECK-NEXT: CompoundStmt -// CHECK-NEXT: CXXMethodDecl {{.*}} implicit operator= 'SpecialClassStruct2 &(const SpecialClassStruct2 &)' -// CHECK-NEXT: ParmVarDecl {{.*}} 'const SpecialClassStruct2 &' -// CHECK-NEXT: CXXMethodDecl {{.*}} implicit operator= 'SpecialClassStruct2 &(SpecialClassStruct2 &&)' -// CHECK-NEXT: ParmVarDecl {{.*}} 'SpecialClassStruct2 &&' -// CHECK-NEXT: CXXDestructorDecl {{.*}} implicit ~SpecialClassStruct2 'void ()' -struct __attribute__((sycl_special_class)) SpecialClassStruct2 { virtual void __init( [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr1", "Attr2", 1, true)]] [[__sycl_detail__::add_ir_attributes_kernel_parameter("Attr2", "Attr1", true, 1)]] From 67129673ec67f3552c350c956deda9c9150f26e1 Mon Sep 17 00:00:00 2001 From: "Larsen, Steffen" Date: Tue, 28 Oct 2025 08:15:37 -0700 Subject: [PATCH 5/5] Regenerate old cases Signed-off-by: Larsen, Steffen --- .../AST/ast-attr-add-ir-attributes-merge.cpp | 93 ++++++++++++++++--- 1 file changed, 81 insertions(+), 12 deletions(-) diff --git a/clang/test/AST/ast-attr-add-ir-attributes-merge.cpp b/clang/test/AST/ast-attr-add-ir-attributes-merge.cpp index f39e3011b9e7..abd041deed78 100644 --- a/clang/test/AST/ast-attr-add-ir-attributes-merge.cpp +++ b/clang/test/AST/ast-attr-add-ir-attributes-merge.cpp @@ -194,6 +194,37 @@ void FunctionRedecl3(); // CHECK-NEXT: SYCLAddIRAttributesFunctionAttr // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: ConstantExpr {{.*}} 'int' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 0 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +void FunctionRedecl3(); +[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] void FunctionRedecl3(); +[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] void FunctionRedecl3(); +[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr2", "Attr1", true, 1)]] void FunctionRedecl3(); +[[__sycl_detail__::add_ir_attributes_function({"Attr3", "Attr1"}, "Attr1", "Attr2", 1, true)]] void FunctionRedecl3(); +[[__sycl_detail__::add_ir_attributes_function({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, false)]] void FunctionRedecl3(); +[[__sycl_detail__::add_ir_attributes_function({"Attr1"}, "Attr1", "Attr2", 1, true)]] void FunctionRedecl3(); +[[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] void FunctionRedecl3(){}; + +// CHECK: FunctionDecl {{.*}} FunctionDecl2 'void ()' +// CHECK-NEXT: CompoundStmt +// CHECK-NEXT: SYCLAddIRAttributesFunctionAttr +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue // CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue @@ -214,7 +245,7 @@ void FunctionRedecl3(); [[__sycl_detail__::add_ir_attributes_function("Attr1", "Attr2", 1, true)]] [[__sycl_detail__::add_ir_attributes_function("Attr2", "Attr1", true, 1)]] [[__sycl_detail__::add_ir_attributes_function("Attr3", false)]] -void FunctionDecl1(){}; +void FunctionDecl2(){}; // CHECK: CXXRecordDecl [[GlobalVarStructRedecl1ID1:0x[0-9a-f]+]] {{.*}} struct GlobalVarStructRedecl1 // CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl1ID2:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl1ID1]] {{.*}} struct GlobalVarStructRedecl1 @@ -339,8 +370,46 @@ struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr3", false)]] Gl struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl2; struct GlobalVarStructRedecl2; -// CHECK: CXXRecordDecl [[GlobalVarStructRedecl3ID1:0x[0-9a-f]+]] {{.*}} struct GlobalVarStructRedecl3 -// CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl3ID2:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl3ID1]] {{.*}} struct GlobalVarStructRedecl3 +// CHECK: CXXRecordDecl {{.*}} struct GlobalVarStructDecl1 definition +// CHECK-NEXT: DefinitionData +// CHECK-NEXT: DefaultConstructor +// CHECK-NEXT: CopyConstructor +// CHECK-NEXT: MoveConstructor +// CHECK-NEXT: CopyAssignment +// CHECK-NEXT: MoveAssignment +// CHECK-NEXT: Destructor +// CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr3" +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr2" +// CHECK-NEXT: ConstantExpr {{.*}} 'int' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: IntegerLiteral {{.*}} 'int' 1 +// CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue +// CHECK-NEXT: value: LValue +// CHECK-NEXT: StringLiteral {{.*}} 'const char[6]' lvalue "Attr1" +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 0 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false +// CHECK-NEXT: ConstantExpr {{.*}} 'bool' +// CHECK-NEXT: value: Int 1 +// CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true +// CHECK-NEXT: CXXRecordDecl {{.*}} implicit struct GlobalVarStructRedecl3 +struct GlobalVarStructRedecl3; +struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3; +struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3; +struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr2", "Attr1", true, 1)]] GlobalVarStructRedecl3; +struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr3", "Attr1"}, "Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3; +struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1", "Attr3"}, "Attr1", "Attr2", 1, false)]] GlobalVarStructRedecl3; +struct [[__sycl_detail__::add_ir_attributes_global_variable({"Attr1"}, "Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3; +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3{}; + +// CHECK: CXXRecordDecl [[GlobalVarStructRedecl4ID1:0x[0-9a-f]+]] {{.*}} struct GlobalVarStructRedecl4 +// CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl4ID2:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl4ID1]] {{.*}} struct GlobalVarStructRedecl4 // CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue @@ -354,7 +423,7 @@ struct GlobalVarStructRedecl2; // CHECK-NEXT: ConstantExpr {{.*}} 'bool' // CHECK-NEXT: value: Int 1 // CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -// CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl3ID3:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl3ID2]] {{.*}} struct GlobalVarStructRedecl3 +// CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl4ID3:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl4ID2]] {{.*}} struct GlobalVarStructRedecl4 // CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue @@ -368,7 +437,7 @@ struct GlobalVarStructRedecl2; // CHECK-NEXT: ConstantExpr {{.*}} 'bool' // CHECK-NEXT: value: Int 1 // CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -// CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl3ID4:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl3ID3]] {{.*}} struct GlobalVarStructRedecl3 +// CHECK-NEXT: CXXRecordDecl [[GlobalVarStructRedecl4ID4:0x[0-9a-f]+]] prev [[GlobalVarStructRedecl4ID3]] {{.*}} struct GlobalVarStructRedecl4 // CHECK-NEXT: SYCLAddIRAttributesGlobalVariableAttr // CHECK-NEXT: ConstantExpr {{.*}} 'const char[6]' lvalue // CHECK-NEXT: value: LValue @@ -382,7 +451,7 @@ struct GlobalVarStructRedecl2; // CHECK-NEXT: ConstantExpr {{.*}} 'bool' // CHECK-NEXT: value: Int 1 // CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' true -// CHECK-NEXT: CXXRecordDecl {{.*}} prev [[GlobalVarStructRedecl3ID4]] {{.*}} struct GlobalVarStructRedecl3 definition +// CHECK-NEXT: CXXRecordDecl {{.*}} prev [[GlobalVarStructRedecl4ID4]] {{.*}} struct GlobalVarStructRedecl4 definition // CHECK-NEXT: DefinitionData // CHECK-NEXT: DefaultConstructor // CHECK-NEXT: CopyConstructor @@ -409,12 +478,12 @@ struct GlobalVarStructRedecl2; // CHECK-NEXT: ConstantExpr {{.*}} 'bool' // CHECK-NEXT: value: Int 0 // CHECK-NEXT: CXXBoolLiteralExpr {{.*}} 'bool' false -// CHECK-NEXT: CXXRecordDecl {{.*}} implicit struct GlobalVarStructRedecl3 -struct GlobalVarStructRedecl3; -struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3; -struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl3; -struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr2", "Attr1", true, 1)]] GlobalVarStructRedecl3; -struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr3", false)]] GlobalVarStructRedecl3{}; +// CHECK-NEXT: CXXRecordDecl {{.*}} implicit struct GlobalVarStructRedecl4 +struct GlobalVarStructRedecl4; +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl4; +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr1", "Attr2", 1, true)]] GlobalVarStructRedecl4; +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr2", "Attr1", true, 1)]] GlobalVarStructRedecl4; +struct [[__sycl_detail__::add_ir_attributes_global_variable("Attr3", false)]] GlobalVarStructRedecl4{}; // CHECK: CXXRecordDecl {{.*}} struct GlobalVarStructDecl1 definition // CHECK-NEXT: DefinitionData