Skip to content

Commit 8ab8763

Browse files
committed
Fix setting BP on windows.
Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
1 parent e595273 commit 8ab8763

File tree

6 files changed

+47
-30
lines changed

6 files changed

+47
-30
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,18 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
399399

400400
// Cache the results.
401401
auto It = DIFileCache.find(FileName.data());
402+
if (SM.getFileEntryForID(SM.getMainFileID()) &&
403+
CGM.getCodeGenOpts().SYCLUseMainFileName && FID.isInvalid() &&
404+
llvm::sys::path::is_absolute(FileName)) {
405+
FileID MainFileID = SM.getMainFileID();
406+
auto ExpectedFileRef = SM.getFileManager().getFileRef(FileName);
407+
if (ExpectedFileRef) {
408+
MainFileID = SM.getOrCreateFileID(ExpectedFileRef.get(),
409+
SrcMgr::CharacteristicKind::C_User);
410+
FID = MainFileID;
411+
}
412+
}
413+
402414
if (It != DIFileCache.end()) {
403415
// Verify that the information still exists.
404416
if (llvm::Metadata *V = It->second)
@@ -407,6 +419,17 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
407419

408420
SmallString<32> Checksum;
409421

422+
if (SM.getFileEntryForID(SM.getMainFileID()) &&
423+
CGM.getCodeGenOpts().SYCLUseMainFileName && FID.isInvalid()) {
424+
FileID MainFileID = SM.getMainFileID();
425+
auto ExpectedFileRef = SM.getFileManager().getFileRef(FileName);
426+
if (ExpectedFileRef) {
427+
MainFileID = SM.getOrCreateFileID(ExpectedFileRef.get(),
428+
SrcMgr::CharacteristicKind::C_User);
429+
FID = MainFileID;
430+
}
431+
}
432+
410433
Optional<llvm::DIFile::ChecksumKind> CSKind = computeChecksum(FID, Checksum);
411434
Optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo;
412435
if (CSKind)

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5447,6 +5447,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
54475447
Args.MakeArgString(llvm::sys::path::filename(Input.getBaseInput())));
54485448
CmdArgs.push_back("-fsycl-use-main-file-name");
54495449
}
5450+
54505451
CmdArgs.push_back("-full-main-file-name");
54515452
CmdArgs.push_back(Input.getBaseInput());
54525453

clang/test/CodeGenSYCL/Inputs/checksum-with-footer.cpp

Lines changed: 0 additions & 7 deletions
This file was deleted.

clang/test/CodeGenSYCL/Inputs/footer.h

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
// RUN: %clang_cc1 -fsycl-is-device %S/Inputs/checksum.cpp \
2-
// RUN: -triple spir64-unknown-unknown \
3-
// RUN: -main-file-name "%S/Inputs/checksum.cpp" \
4-
// RUN: -full-main-file-name "%S/Inputs/checksum.cpp" \
5-
// RUN: -fsycl-use-main-file-name -gcodeview -debug-info-kind=constructor \
6-
// RUN: -emit-llvm -O0 -o - | FileCheck %s
1+
// RUN: %clang_cc1 -triple spir64-unknown-unknown -fsycl-is-device \
2+
// RUN: -fsycl-int-header=%t.header.h -fsycl-int-footer=%t.footer.h \
3+
// RUN: -main-file-name checksum.cpp -fsycl-use-main-file-name \
4+
// RUN: -full-main-file-name "%S/checksum.cpp" \
5+
// RUN: -gcodeview -debug-info-kind=limited -emit-llvm -O0 -o - "%S/checksum.cpp" \
6+
// RUN: | FileCheck %s -check-prefix=COMP1
77

8-
// Check that "checksum" is created correctly for the compiled file and
9-
// that the same checksum is generated for the input file appended with
10-
// the footer.
8+
// RUN: append-file "%S/checksum.cpp" \
9+
// RUN: --append=%t.footer.h \
10+
// RUN: --orig-filename="%S/checksum.cpp" \
11+
// RUN: --output=%t.checksum.cpp --use-include
1112

12-
// CHECK: !DICompileUnit({{.*}} file: ![[#FILE:]]
13-
// CHECK: ![[#FILE:]] = !DIFile(filename: "{{.*}}clang{{.+}}test{{.+}}CodeGenSYCL{{.+}}Inputs{{.+}}checksum.cpp"
14-
// CHECK-SAME: checksumkind: CSK_MD5, checksum: "259269f735d83ec32c46a11352458493")
13+
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsycl-is-host \
14+
// RUN: -include %t.header.h -dependency-filter %t.header.h \
15+
// RUN: -main-file-name checksum.cpp -fsycl-use-main-file-name \
16+
// RUN: -full-main-file-name %S/checksum.cpp \
17+
// RUN: -gcodeview -debug-info-kind=limited -emit-llvm -O0 -o - \
18+
// RUN: %t.checksum.cpp \
19+
// RUN: | FileCheck %s -check-prefix=COMP2
1520

16-
// RUN: %clang_cc1 -fsycl-is-host %S/Inputs/checksum-with-footer.cpp \
17-
// RUN: -triple x86_64-pc-windows-msvc \
18-
// RUN: -main-file-name %S/Inputs/checksum.cpp \
19-
// RUN: -full-main-file-name %S/Inputs/checksum.cpp \
20-
// RUN: -fsycl-use-main-file-name -gcodeview -debug-info-kind=constructor \
21-
// RUN: -S -emit-llvm -O0 -o - | FileCheck %s
21+
// COMP1: !DICompileUnit({{.*}} file: ![[#FILE1:]]
22+
// COMP1: ![[#FILE1]] = !DIFile(filename: "{{.*}}clang{{.+}}test{{.+}}CodeGenSYCL{{.+}}checksum.cpp"
23+
// COMP1-SAME: checksumkind: CSK_MD5, checksum: "259269f735d83ec32c46a11352458493")
2224

23-
24-
// CHECKSUM: distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1
25-
// CHECKSUM: !1 = !DIFile(filename: "{{.*}}clang{{.+}}test{{.+}}CodeGenSYCL{{.+}}Inputs{{.+}}checksum.cpp"
26-
// CHECKSUM-SAME: checksumkind: CSK_MD5, checksum: "259269f735d83ec32c46a11352458493")
25+
// COMP2: !DICompileUnit({{.*}} file: ![[#FILE2:]]
26+
// COMP2: ![[#FILE2]] = !DIFile(filename: "{{.*}}clang{{.+}}test{{.+}}CodeGenSYCL{{.+}}checksum.cpp"
27+
// COMP2-SAME: checksumkind: CSK_MD5, checksum: "259269f735d83ec32c46a11352458493")

0 commit comments

Comments
 (0)