Skip to content

Commit 3b06d7b

Browse files
committed
[SYCL] Propagate attributes from redeclarations to SYCL kernel
- Fix bug that propagates attributes from only canoncial declaration - Add a test
1 parent bc8f0a4 commit 3b06d7b

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ class MarkDeviceFunction : public RecursiveASTVisitor<MarkDeviceFunction> {
554554

555555
for (const CallGraphNode *CI : *N) {
556556
if (auto *Callee = dyn_cast<FunctionDecl>(CI->getDecl())) {
557-
Callee = Callee->getCanonicalDecl();
557+
Callee = Callee->getMostRecentDecl();
558558
if (!Visited.count(Callee))
559559
WorkList.push_back({Callee, FD});
560560
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// RUN: %clang %s -fsyntax-only -Xclang -ast-dump -fsycl-device-only | FileCheck %s
2+
3+
[[intelfpga::no_global_work_offset]] // expected-no-diagnostics
4+
void
5+
func();
6+
7+
[[intelfpga::max_work_group_size(8, 8, 8)]] // expected-no-diagnostics
8+
void
9+
func();
10+
11+
[[cl::reqd_work_group_size(4, 4, 4)]] // expected-no-diagnostics
12+
void
13+
func() {}
14+
15+
template <typename Name, typename Type>
16+
[[clang::sycl_kernel]] void __my_kernel__(Type bar) {
17+
bar();
18+
func();
19+
}
20+
21+
template <typename Name, typename Type>
22+
void parallel_for(Type func) {
23+
__my_kernel__<Name>(func);
24+
}
25+
26+
void invoke_foo2() {
27+
// CHECK-LABEL: FunctionDecl {{.*}} invoke_foo2 'void ()'
28+
// CHECK: `-FunctionDecl {{.*}} _ZTSZ11invoke_foo2vE10KernelName 'void ()'
29+
// CHECK: -SYCLIntelMaxWorkGroupSizeAttr {{.*}} Inherited 8 8 8
30+
// CHECK: -SYCLIntelNoGlobalWorkOffsetAttr {{.*}} Inherited Enabled
31+
// CHECK: `-ReqdWorkGroupSizeAttr {{.*}} 4 4 4
32+
parallel_for<class KernelName>([]() {});
33+
}

0 commit comments

Comments
 (0)