Skip to content

Commit 4d814bf

Browse files
authored
[SYCL][DebugInfo] Reinstate source locations for some kernel instructions (#2527)
Now that the source location of the kernel caller function is being assigned to the initialization code in the kernel body, stop clearing the source locations for some other instructions (e.g. call to operator() and the return instruction). Signed-off-by: Steve Merritt <[email protected]>
1 parent 81deb7c commit 4d814bf

File tree

2 files changed

+7
-21
lines changed

2 files changed

+7
-21
lines changed

clang/lib/Sema/SemaSYCL.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -582,22 +582,12 @@ class KernelBodyTransform : public TreeTransform<KernelBodyTransform> {
582582
auto NewDecl = MappingPair.second;
583583
return DeclRefExpr::Create(
584584
SemaRef.getASTContext(), DRE->getQualifierLoc(),
585-
DRE->getTemplateKeywordLoc(), NewDecl, false,
586-
DeclarationNameInfo(DRE->getNameInfo().getName(), SourceLocation(),
587-
DRE->getNameInfo().getInfo()),
585+
DRE->getTemplateKeywordLoc(), NewDecl, false, DRE->getNameInfo(),
588586
NewDecl->getType(), DRE->getValueKind());
589587
}
590588
return DRE;
591589
}
592590

593-
StmtResult RebuildCompoundStmt(SourceLocation LBraceLoc,
594-
MultiStmtArg Statements,
595-
SourceLocation RBraceLoc, bool IsStmtExpr) {
596-
// Build a new compound statement but clear the source locations.
597-
return getSema().ActOnCompoundStmt(SourceLocation(), SourceLocation(),
598-
Statements, IsStmtExpr);
599-
}
600-
601591
private:
602592
std::pair<DeclaratorDecl *, DeclaratorDecl *> MappingPair;
603593
Sema &SemaRef;

clang/test/CodeGenSYCL/debug-info-srcpos-kernel.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %clang -fsycl-device-only %s -S -emit-llvm -O0 -g -o - | FileCheck %s
22
//
3-
// Verify the SYCL kernel routine is marked artificial and has no source
4-
// correlation.
3+
// Verify the SYCL kernel routine is marked artificial and has the
4+
// expected source correlation.
55
//
66
// In order to placate the profiling tools, which can't cope with instructions
77
// mapped to line 0, we've made the change so that the artificial code in a
@@ -28,17 +28,13 @@ int main() {
2828
// CHECK: getelementptr inbounds %"class.{{.*}}.anon"{{.*}} !dbg [[LINE_A0:![0-9]+]]
2929
// CHECK: call spir_func void {{.*}}6__init{{.*}} !dbg [[LINE_A0]]
3030
// CHECK: call spir_func void @"_ZZ4mainENK3$_0clEv"{{.*}} !dbg [[LINE_B0:![0-9]+]]
31-
// CHECK: ret void
31+
// CHECK: ret void, !dbg [[LINE_C0:![0-9]+]]
3232
// CHECK: [[FILE:![0-9]+]] = !DIFile(filename: "{{.*}}debug-info-srcpos-kernel.cpp"{{.*}})
3333
// CHECK: [[KERNEL]] = {{.*}}!DISubprogram(name: "{{.*}}19use_kernel_for_test"
3434
// CHECK-SAME: scope: [[FILE]]
3535
// CHECK-SAME: file: [[FILE]]
3636
// CHECK-SAME: flags: DIFlagArtificial | DIFlagPrototyped
3737
// CHECK: [[LINE_A0]] = !DILocation(line: 15,{{.*}}scope: [[KERNEL]]
38-
// CHECK: [[LINE_B0]] = !DILocation(line: 0
39-
40-
// TODO: [[LINE_B0]] should be mapped to line 15 as well. That said,
41-
// this 'line 0' assignment is less problematic as the lambda function
42-
// call would be inlined in most cases.
43-
// TODO: SYCL specific fail - analyze and enable
44-
// XFAIL: windows-msvc
38+
// CHECK: [[LINE_B0]] = !DILocation(line: 16,{{.*}}scope: [[BLOCK:![0-9]+]]
39+
// CHECK: [[BLOCK]] = distinct !DILexicalBlock(scope: [[KERNEL]]
40+
// CHECK: [[LINE_C0]] = !DILocation(line: 17,{{.*}}scope: [[KERNEL]]

0 commit comments

Comments
 (0)