-
Notifications
You must be signed in to change notification settings - Fork 787
[SYCL] Fix debug info generation when integration footer is present #6774
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
Changes from all commits
aa090b2
e595273
8ab8763
4506b33
cfc331d
316f47c
85f22a6
2cc31bb
42e9b68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5438,8 +5438,20 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, | |
// Set the main file name, so that debug info works even with | ||
// -save-temps. | ||
CmdArgs.push_back("-main-file-name"); | ||
CmdArgs.push_back(getBaseInputName(Args, Input)); | ||
if (!IsSYCL || Args.hasArg(options::OPT_fno_sycl_use_footer)) { | ||
CmdArgs.push_back(getBaseInputName(Args, Input)); | ||
} else { | ||
SmallString<256> AbsPath = llvm::StringRef(Input.getBaseInput()); | ||
D.getVFS().makeAbsolute(AbsPath); | ||
CmdArgs.push_back( | ||
Args.MakeArgString(llvm::sys::path::filename(Input.getBaseInput()))); | ||
CmdArgs.push_back("-fsycl-use-main-file-name"); | ||
} | ||
|
||
if (IsSYCL || Args.hasArg(options::OPT_fsycl_footer_path_EQ)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the IsSYCL check needed here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure. Does Args.hasArg(options::OPT_fsycl_footer_path_EQ) == true implies IsSYCL? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I talked to Mike Rice and it looks like OpenMP doesn't use footers. So I can presumably just check for the option and not test for IsSycl. |
||
CmdArgs.push_back("-full-main-file-name"); | ||
CmdArgs.push_back(Input.getBaseInput()); | ||
} | ||
// Some flags which affect the language (via preprocessor | ||
// defines). | ||
if (Args.hasArg(options::OPT_static)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
int main() { | ||
int x = 0; | ||
return x + 1; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include "Inputs/sycl.hpp" | ||
|
||
int main() { | ||
sycl::sampler Sampler; | ||
sycl::kernel_single_task<class use_kernel_for_test>([=]() { | ||
Sampler.use(); | ||
}); | ||
return 0; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// This file attempts to emulate content of a file, which is passed to host | ||
// compiler when integration footer is used: this file is considered to be a | ||
// main file and Inputs/debug-info-checksum.cpp serves as integration footer. | ||
// | ||
// The file is specifically named debug-info-checksum-temp-name.cpp to emulate | ||
// the temporary file name, which is generated by the compiler driver for the | ||
// host .cpp file after appending footer to it. | ||
// | ||
// The command line executed is based on what is actually invoked by the | ||
// compiler driver and we explicitly pass 'Inputs/debug-info-checksum.cpp' as | ||
// a main file name to ensure that we can instruct the compiler to emit the | ||
// correct debug info (paths and checksums), even though the input file is not | ||
// exactly what user specified on the command line. | ||
// | ||
// RUN: %clang_cc1 -fsycl-is-host -I %S %S/Inputs/debug-info-checksum.cpp \ | ||
// RUN: -triple x86_64-unknown-linux-gpu \ | ||
// RUN: -main-file-name "%S/Inputs/debug-info-checksum.cpp" \ | ||
// RUN: -full-main-file-name "%S/Inputs/debug-info-checksum.cpp" \ | ||
// RUN: -fsycl-use-main-file-name -dwarf-version=5 -S -emit-llvm \ | ||
// RUN: -O0 -debug-info-kind=constructor -o - | FileCheck %s | ||
// | ||
// Verify that DICompileUnit points to a correct file and that checksum is also | ||
// correct. | ||
// | ||
// CHECK: !DICompileUnit({{.*}} file: ![[#FILE:]] | ||
// CHECK: ![[#FILE]] = !DIFile(filename: "{{.*}}clang{{.+}}test{{.+}}CodeGenSYCL{{.+}}Inputs{{.+}}debug-info-checksum.cpp" | ||
// CHECK-SAME: checksumkind: CSK_MD5, checksum: "f1fb5d68350b47d90a53968ac8c40529" | ||
|
||
#include "Inputs/debug-info-checksum.cpp" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// This test checks that a checksum is created correctly for the compiled file, | ||
// and that the same checksum is generated for host and target compilation. | ||
// It also checks that DICompileUnit in host and target compilation is referring | ||
// to the original source file name (not the temporary file created by the | ||
// compilation process) . | ||
|
||
// RUN: %clang_cc1 -triple spir64-unknown-unknown -fsycl-is-device \ | ||
zahiraam marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// RUN: -fsycl-int-header=%t.header.h -fsycl-int-footer=%t.footer.h \ | ||
// RUN: -main-file-name %S/Inputs/checksum.cpp -fsycl-use-main-file-name \ | ||
// RUN: -full-main-file-name "%S/Inputs/checksum.cpp" \ | ||
// RUN: -gcodeview -debug-info-kind=limited -emit-llvm -O0 -o - "%S/Inputs/checksum.cpp" \ | ||
// RUN: | FileCheck %s -check-prefix=COMP1 | ||
|
||
// RUN: append-file "%S/Inputs/checksum.cpp" \ | ||
// RUN: --append=%t.footer.h \ | ||
// RUN: --orig-filename="%S/Inputs/checksum.cpp" \ | ||
// RUN: --output=%t.checksum.cpp --use-include | ||
|
||
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsycl-is-host \ | ||
// RUN: -include %t.header.h -dependency-filter %t.header.h \ | ||
// RUN: -main-file-name %S/Inputs/checksum.cpp -fsycl-use-main-file-name \ | ||
// RUN: -full-main-file-name %S/Inputs/checksum.cpp \ | ||
// RUN: -gcodeview -debug-info-kind=limited -emit-llvm -O0 -o - \ | ||
// RUN: %t.checksum.cpp \ | ||
// RUN: | FileCheck %s -check-prefix=COMP2 | ||
|
||
// COMP1: !DICompileUnit({{.*}} file: ![[#FILE1:]] | ||
// COMP1: ![[#FILE1]] = !DIFile(filename: "{{.*}}clang{{.+}}test{{.+}}CodeGenSYCL{{.+}}checksum.cpp" | ||
// COMP1-SAME: checksumkind: CSK_MD5, checksum: "259269f735d83ec32c46a11352458493") | ||
|
||
// COMP2: !DICompileUnit({{.*}} file: ![[#FILE2:]] | ||
// COMP2: ![[#FILE2]] = !DIFile(filename: "{{.*}}clang{{.+}}test{{.+}}CodeGenSYCL{{.+}}checksum.cpp" | ||
// COMP2-SAME: checksumkind: CSK_MD5, checksum: "259269f735d83ec32c46a11352458493") |
Uh oh!
There was an error while loading. Please reload this page.