Skip to content

Commit 3e64587

Browse files
bwymavladimirlaz
authored andcommitted
[SYCL] Fix incorrect line information in SYCL device code debug info
Mark the SYCL kernel as artificial to avoid inheriting the source correlation from the surrounding code. Signed-off-by: Wyma, Brock <[email protected]> Signed-off-by: Vladimir Lazarev <[email protected]>
1 parent 3ce5091 commit 3e64587

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,8 @@ static FunctionDecl *CreateSYCLKernelFunction(ASTContext &Context,
393393
SYCLKernel->addAttr(SYCLDeviceAttr::CreateImplicit(Context));
394394
SYCLKernel->addAttr(OpenCLKernelAttr::CreateImplicit(Context));
395395
SYCLKernel->addAttr(AsmLabelAttr::CreateImplicit(Context, Name));
396+
SYCLKernel->addAttr(ArtificialAttr::CreateImplicit(Context));
397+
396398
// To see kernel in AST-dump.
397399
DC->addDecl(SYCLKernel);
398400
return SYCLKernel;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %clang --sycl %s -S -emit-llvm -g -o - | FileCheck %s
2+
//
3+
// Verify the SYCL kernel routine is marked artificial.
4+
//
5+
// Since it has no source correlation of its own, the SYCL kernel needs to be
6+
// marked artificial or it will inherit source correlation from the surrounding
7+
// code.
8+
//
9+
10+
template <typename Name, typename Func>
11+
__attribute__((sycl_kernel)) void kernel_single_task(Func kernelFunc) {
12+
kernelFunc();
13+
}
14+
15+
int main() {
16+
int value = 0;
17+
int* captured = &value;
18+
kernel_single_task<class kernel_function>([=]() {
19+
*captured = 1;
20+
});
21+
return 0;
22+
}
23+
24+
// CHECK: define{{.*}} spir_kernel {{.*}}void @_ZTSZ4mainE15kernel_function(i32*{{.*}}){{.*}} !dbg [[KERNEL:![0-9]+]] {{.*}}{
25+
// CHECK: [[FILE:![0-9]+]] = !DIFile(filename: "{{.*}}debug-info-srcpos-kernel.cpp"{{.*}})
26+
// CHECK: [[KERNEL]] = {{.*}}!DISubprogram(name: "_ZTSZ4mainE15kernel_function"
27+
// CHECK-SAME: scope: [[FILE]]
28+
// CHECK-SAME: file: [[FILE]]
29+
// CHECK-SAME: flags: DIFlagArtificial | DIFlagPrototyped

0 commit comments

Comments
 (0)