[llvm] r329838 - CodeGen: Don't try to canonicalize Unix-style paths in CodeView debug info.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 11 11:24:03 PDT 2018


Author: pcc
Date: Wed Apr 11 11:24:03 2018
New Revision: 329838

URL: http://llvm.org/viewvc/llvm-project?rev=329838&view=rev
Log:
CodeGen: Don't try to canonicalize Unix-style paths in CodeView debug info.

Most importantly, we should not replace slashes with backslashes
because that would invalidate the path.

Differential Revision: https://reviews.llvm.org/D45473

Modified:
    llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
    llvm/trunk/test/DebugInfo/COFF/enum.ll
    llvm/trunk/test/DebugInfo/COFF/types-array-advanced.ll
    llvm/trunk/test/DebugInfo/COFF/types-non-virtual-methods.ll

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp?rev=329838&r1=329837&r2=329838&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp Wed Apr 11 11:24:03 2018
@@ -114,6 +114,16 @@ StringRef CodeViewDebug::getFullFilepath
 
   StringRef Dir = File->getDirectory(), Filename = File->getFilename();
 
+  // If this is a Unix-style path, just use it as is. Don't try to canonicalize
+  // it textually because one of the path components could be a symlink.
+  if (!Dir.empty() && Dir[0] == '/') {
+    Filepath = Dir;
+    if (Dir.back() != '/')
+      Filepath += '/';
+    Filepath += Filename;
+    return Filepath;
+  }
+
   // Clang emits directory and relative filename info into the IR, but CodeView
   // operates on full paths.  We could change Clang to emit full paths too, but
   // that would increase the IR size and probably not needed for other users.

Modified: llvm/trunk/test/DebugInfo/COFF/enum.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/enum.ll?rev=329838&r1=329837&r2=329838&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/enum.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/enum.ll Wed Apr 11 11:24:03 2018
@@ -26,12 +26,12 @@
 ; CHECK-NEXT:  StringId (0x1002) {
 ; CHECK-NEXT:    TypeLeafKind: LF_STRING_ID (0x1605)
 ; CHECK-NEXT:    Id: 0x0
-; CHECK-NEXT:    StringData: \<stdin>
+; CHECK-NEXT:    StringData: /foo/bar.cpp
 ; CHECK-NEXT:  }
 ; CHECK-NEXT:  UdtSourceLine (0x1003) {
 ; CHECK-NEXT:    TypeLeafKind: LF_UDT_SRC_LINE (0x1606)
 ; CHECK-NEXT:    UDT: E (0x1001)
-; CHECK-NEXT:    SourceFile: \<stdin> (0x1002)
+; CHECK-NEXT:    SourceFile: /foo/bar.cpp (0x1002)
 ; CHECK-NEXT:    LineNumber: 1
 ; CHECK_NEXT  }
 
@@ -51,7 +51,7 @@ target triple = "i686-pc-windows-msvc18.
 !3 = !DIFile(filename: "-", directory: "/")
 !4 = !{!5}
 !5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E", file: !6, line: 1, baseType: !7, size: 32, align: 32, elements: !8)
-!6 = !DIFile(filename: "<stdin>", directory: "/")
+!6 = !DIFile(filename: "bar.cpp", directory: "/foo")
 !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
 !8 = !{!9}
 !9 = !DIEnumerator(name: "BLAH", value: 0)

Modified: llvm/trunk/test/DebugInfo/COFF/types-array-advanced.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/types-array-advanced.ll?rev=329838&r1=329837&r2=329838&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/types-array-advanced.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/types-array-advanced.ll Wed Apr 11 11:24:03 2018
@@ -142,12 +142,12 @@
 ; CHECK:   StringId (0x100D) {
 ; CHECK:     TypeLeafKind: LF_STRING_ID (0x1605)
 ; CHECK:     Id: 0x0
-; CHECK:     StringData: \t.cpp
+; CHECK:     StringData: /t.cpp
 ; CHECK:   }
 ; CHECK:   UdtSourceLine (0x100E) {
 ; CHECK:     TypeLeafKind: LF_UDT_SRC_LINE (0x1606)
 ; CHECK:     UDT: incomplete_struct (0x100C)
-; CHECK:     SourceFile: \t.cpp (0x100D)
+; CHECK:     SourceFile: /t.cpp (0x100D)
 ; CHECK:     LineNumber: 4
 ; CHECK:   }
 ; CHECK:   Modifier (0x100F) {

Modified: llvm/trunk/test/DebugInfo/COFF/types-non-virtual-methods.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/COFF/types-non-virtual-methods.ll?rev=329838&r1=329837&r2=329838&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/COFF/types-non-virtual-methods.ll (original)
+++ llvm/trunk/test/DebugInfo/COFF/types-non-virtual-methods.ll Wed Apr 11 11:24:03 2018
@@ -121,12 +121,12 @@
 ; CHECK:   StringId (0x1008) {
 ; CHECK:     TypeLeafKind: LF_STRING_ID (0x1605)
 ; CHECK:     Id: 0x0
-; CHECK:     StringData: \t.cpp
+; CHECK:     StringData: /t.cpp
 ; CHECK:   }
 ; CHECK:   UdtSourceLine (0x1009) {
 ; CHECK:     TypeLeafKind: LF_UDT_SRC_LINE (0x1606)
 ; CHECK:     UDT: A (0x1007)
-; CHECK:     SourceFile: \t.cpp (0x1008)
+; CHECK:     SourceFile: /t.cpp (0x1008)
 ; CHECK:     LineNumber: 1
 ; CHECK:   }
 ; CHECK:   Class (0x100A) {
@@ -241,7 +241,7 @@
 ; CHECK:   UdtSourceLine (0x1014) {
 ; CHECK:     TypeLeafKind: LF_UDT_SRC_LINE (0x1606)
 ; CHECK:     UDT: B (0x1013)
-; CHECK:     SourceFile: \t.cpp (0x1008)
+; CHECK:     SourceFile: /t.cpp (0x1008)
 ; CHECK:     LineNumber: 11
 ; CHECK:   }
 ; CHECK: ]




More information about the llvm-commits mailing list