From 8281c9ff0dd4ddda463b4014969882e266f7f48d Mon Sep 17 00:00:00 2001 From: Steve Merritt Date: Tue, 22 Sep 2020 16:22:56 -0400 Subject: [PATCH 1/2] [SYCL][DebugInfo] Reinstate source locations for some kernel instructions 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 --- clang/lib/Sema/SemaSYCL.cpp | 12 +----------- clang/test/CodeGenSYCL/debug-info-srcpos-kernel.cpp | 13 ++++++------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/clang/lib/Sema/SemaSYCL.cpp b/clang/lib/Sema/SemaSYCL.cpp index 11efd7577a2e9..4feb23f1c78f5 100644 --- a/clang/lib/Sema/SemaSYCL.cpp +++ b/clang/lib/Sema/SemaSYCL.cpp @@ -582,22 +582,12 @@ class KernelBodyTransform : public TreeTransform { 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 MappingPair; Sema &SemaRef; diff --git a/clang/test/CodeGenSYCL/debug-info-srcpos-kernel.cpp b/clang/test/CodeGenSYCL/debug-info-srcpos-kernel.cpp index 9aa1f4e3da80e..189fdc6a89843 100644 --- a/clang/test/CodeGenSYCL/debug-info-srcpos-kernel.cpp +++ b/clang/test/CodeGenSYCL/debug-info-srcpos-kernel.cpp @@ -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 @@ -28,17 +28,16 @@ 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 +// CHECK: [[LINE_B0]] = !DILocation(line: 16,{{.*}}scope: [[BLOCK:![0-9]+]] +// CHECK: [[BLOCK]] = distinct !DILexicalBlock(scope: [[KERNEL]] +// CHECK: [[LINE_C0]] = !DILocation(line: 17,{{.*}}scope: [[KERNEL]] -// 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 From 5dbec79942ad584aa64484070766623eb6a89d4e Mon Sep 17 00:00:00 2001 From: Alexey Bader Date: Thu, 24 Sep 2020 09:41:24 +0300 Subject: [PATCH 2/2] Update clang/test/CodeGenSYCL/debug-info-srcpos-kernel.cpp --- clang/test/CodeGenSYCL/debug-info-srcpos-kernel.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/clang/test/CodeGenSYCL/debug-info-srcpos-kernel.cpp b/clang/test/CodeGenSYCL/debug-info-srcpos-kernel.cpp index 189fdc6a89843..9c2300075f152 100644 --- a/clang/test/CodeGenSYCL/debug-info-srcpos-kernel.cpp +++ b/clang/test/CodeGenSYCL/debug-info-srcpos-kernel.cpp @@ -38,6 +38,3 @@ int main() { // CHECK: [[LINE_B0]] = !DILocation(line: 16,{{.*}}scope: [[BLOCK:![0-9]+]] // CHECK: [[BLOCK]] = distinct !DILexicalBlock(scope: [[KERNEL]] // CHECK: [[LINE_C0]] = !DILocation(line: 17,{{.*}}scope: [[KERNEL]] - -// TODO: SYCL specific fail - analyze and enable -// XFAIL: windows-msvc