@@ -558,10 +558,11 @@ static void collectSYCLAttributes(Sema &S, FunctionDecl *FD,
558
558
if (!FD->hasAttrs ())
559
559
return ;
560
560
561
- // Attributes that should be propagated from device functions to a kernel
562
- // in SYCL 1.2.1.
563
- if (S.getASTContext ().getLangOpts ().getSYCLVersion () <
564
- LangOptions::SYCL_2020) {
561
+ // In SYCL 1.2.1 mode, the attributes are propagated from the function they
562
+ // are applied to onto the kernel which calls the function.
563
+ // In SYCL 2020 mode, the attributes are not propagated to the kernel.
564
+ if (DirectlyCalled ||
565
+ S.getASTContext ().getLangOpts ().getSYCLVersion () < LangOptions::SYCL_2020) {
565
566
llvm::copy_if (FD->getAttrs (), std::back_inserter (Attrs), [](Attr *A) {
566
567
// FIXME: Make this list self-adapt as new SYCL attributes are added.
567
568
return isa<IntelReqdSubGroupSizeAttr, IntelNamedSubGroupSizeAttr,
@@ -571,19 +572,6 @@ static void collectSYCLAttributes(Sema &S, FunctionDecl *FD,
571
572
SYCLIntelMaxWorkGroupSizeAttr, SYCLIntelMaxGlobalWorkDimAttr,
572
573
SYCLIntelNoGlobalWorkOffsetAttr, SYCLSimdAttr>(A);
573
574
});
574
- } else {
575
- // Attributes that should not be propagated from device functions to a
576
- // kernel in SYCL 2020.
577
- if (DirectlyCalled) {
578
- llvm::copy_if (FD->getAttrs (), std::back_inserter (Attrs), [](Attr *A) {
579
- return isa<IntelReqdSubGroupSizeAttr, IntelNamedSubGroupSizeAttr,
580
- ReqdWorkGroupSizeAttr, SYCLIntelKernelArgsRestrictAttr,
581
- SYCLIntelNumSimdWorkItemsAttr,
582
- SYCLIntelSchedulerTargetFmaxMhzAttr,
583
- SYCLIntelMaxWorkGroupSizeAttr, SYCLIntelMaxGlobalWorkDimAttr,
584
- SYCLIntelNoGlobalWorkOffsetAttr, SYCLSimdAttr>(A);
585
- });
586
- }
587
575
}
588
576
589
577
// Attributes that should not be propagated from device functions to a kernel.
0 commit comments