Skip to content

Commit 56df2ad

Browse files
MrSidimsjsji
authored andcommitted
Use native for the system separator for source path string (#3157)
Previously it used posix, causing strange behaviour like reported in KhronosGroup/SPIRV-LLVM-Translator#3126 It's NFC change for the translator-based tool chains. Yet if SPIR-V consumer is not llvm-spirv - the fix should help. Note, the patch is not attempting to guess separators depending on the user's IR input, so for the linux <-> windows cross compilation the result will be odd (like it was before). Signed-off-by: Sidorov, Dmitry <[email protected]> Original commit: KhronosGroup/SPIRV-LLVM-Translator@c59f0f48ac98325
1 parent c7e3dd4 commit 56df2ad

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

llvm-spirv/lib/SPIRV/OCLUtil.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,11 +461,12 @@ SmallVector<unsigned, 3> decodeMDNode(MDNode *N);
461461
template <typename T> std::string getFullPath(const T *Scope) {
462462
if (!Scope)
463463
return std::string();
464-
std::string Filename = Scope->getFilename().str();
465-
if (sys::path::is_absolute(Filename))
466-
return Filename;
464+
StringRef Filename = Scope->getFilename();
465+
auto Style = sys::path::Style::native;
466+
if (sys::path::is_absolute(Filename, Style))
467+
return Filename.str();
467468
SmallString<16> DirName = Scope->getDirectory();
468-
sys::path::append(DirName, sys::path::Style::posix, Filename);
469+
sys::path::append(DirName, Style, Filename.str());
469470
return DirName.str().str();
470471
}
471472

llvm-spirv/test/DebugInfo/LocalAddressSpace.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
; CHECK: DW_TAG_variable
2323
; CHECK-NEXT: DW_AT_name {{.*}} = "a")
2424
; CHECK-NEXT: DW_AT_type {{.*}} "int")
25-
; CHECK-NEXT: DW_AT_decl_file {{.*}} ("/work/tmp{{[/\\]}}tmp.cl")
25+
; CHECK-NEXT: DW_AT_decl_file {{.*}} ("/work{{[/\\]}}tmp{{[/\\]}}tmp.cl")
2626
; CHECK-NEXT: DW_AT_decl_line {{.*}} (2)
2727
; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc] (DW_OP_addr 0x0)
2828

llvm-spirv/test/RelativeSrcPath.ll renamed to llvm-spirv/test/DebugInfo/RelativeSrcPath.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ attributes #0 = { convergent noinline nounwind optnone "correctly-rounded-divide
4949
!6 = !{i32 1, i32 2}
5050
!7 = !{!"clang version 8.0.0 (cfe/trunk)"}
5151
!8 = distinct !DISubprogram(name: "foo", scope: !9, file: !9, line: 1, type: !10, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
52-
; CHECK: String [[ID:[0-9]+]] "/tmp/RelativeSrcPath.cl"
52+
; CHECK: String [[ID:[0-9]+]] "/tmp{{[/\\]}}RelativeSrcPath.cl"
5353
; CHECK: Line [[ID]]
5454
!9 = !DIFile(filename: "RelativeSrcPath.cl", directory: "/tmp")
5555
!10 = !DISubroutineType(types: !2)

0 commit comments

Comments
 (0)