Skip to content

[SYCL][DebugInfo] Reinstate source locations for some kernel instruct… #2527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions clang/lib/Sema/SemaSYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,22 +582,12 @@ class KernelBodyTransform : public TreeTransform<KernelBodyTransform> {
auto NewDecl = MappingPair.second;
return DeclRefExpr::Create(
SemaRef.getASTContext(), DRE->getQualifierLoc(),
DRE->getTemplateKeywordLoc(), NewDecl, false,
DeclarationNameInfo(DRE->getNameInfo().getName(), SourceLocation(),
DRE->getNameInfo().getInfo()),
DRE->getTemplateKeywordLoc(), NewDecl, false, DRE->getNameInfo(),
NewDecl->getType(), DRE->getValueKind());
}
return DRE;
}

StmtResult RebuildCompoundStmt(SourceLocation LBraceLoc,
MultiStmtArg Statements,
SourceLocation RBraceLoc, bool IsStmtExpr) {
// Build a new compound statement but clear the source locations.
return getSema().ActOnCompoundStmt(SourceLocation(), SourceLocation(),
Statements, IsStmtExpr);
}

private:
std::pair<DeclaratorDecl *, DeclaratorDecl *> MappingPair;
Sema &SemaRef;
Expand Down
16 changes: 6 additions & 10 deletions clang/test/CodeGenSYCL/debug-info-srcpos-kernel.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %clang -fsycl-device-only %s -S -emit-llvm -O0 -g -o - | FileCheck %s
//
// Verify the SYCL kernel routine is marked artificial and has no source
// correlation.
// Verify the SYCL kernel routine is marked artificial and has the
// expected source correlation.
//
// In order to placate the profiling tools, which can't cope with instructions
// mapped to line 0, we've made the change so that the artificial code in a
Expand All @@ -28,17 +28,13 @@ int main() {
// CHECK: getelementptr inbounds %"class.{{.*}}.anon"{{.*}} !dbg [[LINE_A0:![0-9]+]]
// CHECK: call spir_func void {{.*}}6__init{{.*}} !dbg [[LINE_A0]]
// CHECK: call spir_func void @"_ZZ4mainENK3$_0clEv"{{.*}} !dbg [[LINE_B0:![0-9]+]]
// CHECK: ret void
// CHECK: ret void, !dbg [[LINE_C0:![0-9]+]]
// CHECK: [[FILE:![0-9]+]] = !DIFile(filename: "{{.*}}debug-info-srcpos-kernel.cpp"{{.*}})
// CHECK: [[KERNEL]] = {{.*}}!DISubprogram(name: "{{.*}}19use_kernel_for_test"
// CHECK-SAME: scope: [[FILE]]
// CHECK-SAME: file: [[FILE]]
// CHECK-SAME: flags: DIFlagArtificial | DIFlagPrototyped
// CHECK: [[LINE_A0]] = !DILocation(line: 15,{{.*}}scope: [[KERNEL]]
// CHECK: [[LINE_B0]] = !DILocation(line: 0

// TODO: [[LINE_B0]] should be mapped to line 15 as well. That said,
// this 'line 0' assignment is less problematic as the lambda function
// call would be inlined in most cases.
// TODO: SYCL specific fail - analyze and enable
// XFAIL: windows-msvc
// CHECK: [[LINE_B0]] = !DILocation(line: 16,{{.*}}scope: [[BLOCK:![0-9]+]]
// CHECK: [[BLOCK]] = distinct !DILexicalBlock(scope: [[KERNEL]]
// CHECK: [[LINE_C0]] = !DILocation(line: 17,{{.*}}scope: [[KERNEL]]