Skip to content

Commit ef2deea

Browse files
committed
Propagate attributes from transitive calls to kernel
- Remove the (incorrect) distinction between direct and transitive calls for the propagation of attributes to kernel - Add a test showing propagation of attributes from transitive call to kernel
1 parent 3857f54 commit ef2deea

File tree

2 files changed

+18
-44
lines changed

2 files changed

+18
-44
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 17 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -514,51 +514,25 @@ class MarkDeviceFunction : public RecursiveASTVisitor<MarkDeviceFunction> {
514514

515515
if (auto *A = FD->getAttr<IntelReqdSubGroupSizeAttr>())
516516
Attrs.insert(A);
517+
517518
if (auto *A = FD->getAttr<ReqdWorkGroupSizeAttr>())
518519
Attrs.insert(A);
519-
// Allow the following kernel attributes only on lambdas, functions and
520-
// function objects that are called directly from a kernel.
521-
// For all other cases, emit a warning and ignore.
522-
if (auto *A = FD->getAttr<SYCLIntelKernelArgsRestrictAttr>()) {
523-
if (ParentFD == SYCLKernel) {
524-
Attrs.insert(A);
525-
} else {
526-
SemaRef.Diag(A->getLocation(), diag::warn_attribute_ignored) << A;
527-
FD->dropAttr<SYCLIntelKernelArgsRestrictAttr>();
528-
}
529-
}
530-
if (auto *A = FD->getAttr<SYCLIntelNumSimdWorkItemsAttr>()) {
531-
if (ParentFD == SYCLKernel) {
532-
Attrs.insert(A);
533-
} else {
534-
SemaRef.Diag(A->getLocation(), diag::warn_attribute_ignored) << A;
535-
FD->dropAttr<SYCLIntelNumSimdWorkItemsAttr>();
536-
}
537-
}
538-
if (auto *A = FD->getAttr<SYCLIntelMaxWorkGroupSizeAttr>()) {
539-
if (ParentFD == SYCLKernel) {
540-
Attrs.insert(A);
541-
} else {
542-
SemaRef.Diag(A->getLocation(), diag::warn_attribute_ignored) << A;
543-
FD->dropAttr<SYCLIntelMaxWorkGroupSizeAttr>();
544-
}
545-
}
546-
if (auto *A = FD->getAttr<SYCLIntelMaxGlobalWorkDimAttr>()) {
547-
if (ParentFD == SYCLKernel) {
548-
Attrs.insert(A);
549-
} else {
550-
SemaRef.Diag(A->getLocation(), diag::warn_attribute_ignored) << A;
551-
FD->dropAttr<SYCLIntelMaxGlobalWorkDimAttr>();
552-
}
553-
}
554-
if (auto *A = FD->getAttr<SYCLIntelNoGlobalWorkOffsetAttr>()) {
555-
if (ParentFD == SYCLKernel) {
556-
Attrs.insert(A);
557-
} else {
558-
SemaRef.Diag(A->getLocation(), diag::warn_attribute_ignored) << A;
559-
FD->dropAttr<SYCLIntelNoGlobalWorkOffsetAttr>();
560-
}
561-
}
520+
521+
if (auto *A = FD->getAttr<SYCLIntelKernelArgsRestrictAttr>())
522+
Attrs.insert(A);
523+
524+
if (auto *A = FD->getAttr<SYCLIntelNumSimdWorkItemsAttr>())
525+
Attrs.insert(A);
526+
527+
if (auto *A = FD->getAttr<SYCLIntelMaxWorkGroupSizeAttr>())
528+
Attrs.insert(A);
529+
530+
if (auto *A = FD->getAttr<SYCLIntelMaxGlobalWorkDimAttr>())
531+
Attrs.insert(A);
532+
533+
if (auto *A = FD->getAttr<SYCLIntelNoGlobalWorkOffsetAttr>())
534+
Attrs.insert(A);
535+
562536
if (auto *A = FD->getAttr<SYCLSimdAttr>())
563537
Attrs.insert(A);
564538
// Propagate the explicit SIMD attribute through call graph - it is used

clang/test/SemaSYCL/check-notdirect-attribute-propagation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fsycl -fsycl-is-device -verify %s
22

3-
[[intelfpga::no_global_work_offset]] void not_direct() {} //expected-warning {{'no_global_work_offset' attribute ignored}}
3+
[[intelfpga::no_global_work_offset]] void not_direct() {} // expected-no-warning
44

55
void func() { not_direct(); }
66

0 commit comments

Comments
 (0)