Skip to content

Commit fd93cd1

Browse files
committed
New attributes appended instead of set to wrapper; other minor changes.
1 parent 75c5f9d commit fd93cd1

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -312,15 +312,15 @@ static void collectSYCLAttributes(Sema &S, FunctionDecl *FD,
312312
bool DirectlyCalled = true) {
313313
if (!FD->hasAttrs())
314314
return;
315-
for (Attr *A : FD->getAttrs()) {
316-
if (isa<IntelReqdSubGroupSizeAttr, ReqdWorkGroupSizeAttr,
317-
SYCLIntelKernelArgsRestrictAttr, SYCLIntelNumSimdWorkItemsAttr,
318-
SYCLIntelSchedulerTargetFmaxMhzAttr, SYCLIntelMaxWorkGroupSizeAttr,
319-
SYCLIntelMaxGlobalWorkDimAttr, SYCLIntelNoGlobalWorkOffsetAttr,
320-
SYCLSimdAttr>(A)) {
321-
Attrs.push_back(A);
322-
}
323-
}
315+
316+
llvm::copy_if(FD->getAttrs(), std::back_inserter(Attrs), [](Attr *A) {
317+
return isa<IntelReqdSubGroupSizeAttr, ReqdWorkGroupSizeAttr,
318+
SYCLIntelKernelArgsRestrictAttr, SYCLIntelNumSimdWorkItemsAttr,
319+
SYCLIntelSchedulerTargetFmaxMhzAttr,
320+
SYCLIntelMaxWorkGroupSizeAttr, SYCLIntelMaxGlobalWorkDimAttr,
321+
SYCLIntelNoGlobalWorkOffsetAttr, SYCLSimdAttr>(A);
322+
});
323+
324324
// Allow the kernel attribute "use_stall_enable_clusters" only on lambda
325325
// functions and function objects called directly from a kernel.
326326
// For all other cases, emit a warning and ignore.
@@ -542,9 +542,9 @@ class MarkDeviceFunction : public RecursiveASTVisitor<MarkDeviceFunction> {
542542
continue; // We've already seen this Decl
543543

544544
// Gather all attributes of FD that are SYCL related.
545-
// Some attributes are allowed only on lambda
546-
// functions and function objects called directly from a kernel
547-
// (i.e. the one passed to the single_task or parallel_for functions).
545+
// Some attributes are allowed only on lambda functions and function
546+
// objects called directly from a kernel (i.e. the one passed to the
547+
// single_task or parallel_for functions).
548548
bool DirectlyCalled = (ParentFD == SYCLKernel);
549549
collectSYCLAttributes(SemaRef, FD, Attrs, DirectlyCalled);
550550

@@ -3197,7 +3197,7 @@ void Sema::copySYCLKernelAttrs(const CXXRecordDecl *KernelObj) {
31973197
llvm::SmallVector<Attr *, 4> Attrs;
31983198
collectSYCLAttributes(*this, KernelBody, Attrs);
31993199
if (!Attrs.empty())
3200-
OpParens->setAttrs(Attrs);
3200+
llvm::for_each(Attrs, [OpParens](Attr *A) { OpParens->addAttr(A); });
32013201
}
32023202
}
32033203

sycl/test/kernel_param/attr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clangxx -fsycl-device-only -Xclang -fsycl-is-device -emit-llvm %s -S -o %t.ll -I %sycl_include -Wno-sycl-strict -Xclang -verify-ignore-unexpected=note,warning -Xclang -disable-llvm-passes -D__ENABLE_USM_ADDR_SPACE__
1+
// RUN: %clangxx -fsycl-device-only -Xclang -fsycl-is-device -emit-llvm %s -S -o %t.ll -I %sycl_include
22
// RUN: FileCheck %s --input-file %t.ll
33

44
// Check copying of parallel_for kernel attributes to wrapper kernel.
@@ -19,4 +19,4 @@ int main() {
1919
return 0;
2020
}
2121

22-
// CHECK: define {{.*}}spir_kernel void @{{.*}}__pf_kernel_wrapper{{.*}}reqd_work_group_size
22+
// CHECK: define {{.*}}spir_kernel void @{{.*}}__pf_kernel_wrapper{{.*}}reqd_work_group_size

0 commit comments

Comments
 (0)