<div dir="ltr">Hello Jonas,<br><br>This commit broke one of our builders:<br><a href="http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/18383">http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/18383</a><br>. . . <br>Failing Tests (1):<br>    LLVM :: MC/ELF/debug-prefix-map.s<br><br>Please have a look?<br>The builder was already red and did not send notifications.<br><br>Also at least one more builder is affected:<br><a href="http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/10902">http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/10902</a><br><br>Thanks<br><br>Galina<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 11, 2018 at 5:30 AM, Jonas Devlieghere via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: jdevlieghere<br>
Date: Wed Jul 11 05:30:35 2018<br>
New Revision: 336793<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=336793&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=336793&view=rev</a><br>
Log:<br>
Use debug-prefix-map for AT_NAME<br>
<br>
AT_NAME was being emitted before the directory paths were remapped. This<br>
ensures that all paths are remapped before anything is emitted.<br>
<br>
An additional test case has been added.<br>
<br>
Note that this only works if the replacement string is an absolute path.<br>
If not, then AT_decl_file believes the new path is a relative path, and<br>
joins that path with the compilation directory. I do not know of a good<br>
way to resolve this.<br>
<br>
Patch by: Siddhartha Bagaria (starsid)<br>
<br>
Differential revision: <a href="https://reviews.llvm.org/D49169" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D49169</a><br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/MC/<wbr>MCContext.h<br>
    llvm/trunk/include/llvm/MC/<wbr>MCDwarf.h<br>
    llvm/trunk/lib/MC/MCContext.<wbr>cpp<br>
    llvm/trunk/lib/MC/MCDwarf.cpp<br>
    llvm/trunk/lib/MC/<wbr>MCObjectStreamer.cpp<br>
    llvm/trunk/test/MC/ELF/debug-<wbr>prefix-map.s<br>
<br>
Modified: llvm/trunk/include/llvm/MC/<wbr>MCContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=336793&r1=336792&r2=336793&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/MC/MCContext.h?rev=<wbr>336793&r1=336792&r2=336793&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/MC/<wbr>MCContext.h (original)<br>
+++ llvm/trunk/include/llvm/MC/<wbr>MCContext.h Wed Jul 11 05:30:35 2018<br>
@@ -502,11 +502,8 @@ namespace llvm {<br>
     /// Add an entry to the debug prefix map.<br>
     void addDebugPrefixMapEntry(const std::string &From, const std::string &To);<br>
<br>
-    // Remaps the given path in-place as per the debug prefix map.<br>
-    void RemapDebugPath(std::string *Path);<br>
-<br>
-    // Remaps the compilation dir as per the debug prefix map.<br>
-    void RemapCompilationDir();<br>
+    // Remaps all debug directory paths in-place as per the debug prefix map.<br>
+    void RemapDebugPaths();<br>
<br>
     /// Get the main file name for use in error messages and debug<br>
     /// info. This can be set to ensure we've got the correct file name<br>
<br>
Modified: llvm/trunk/include/llvm/MC/<wbr>MCDwarf.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCDwarf.h?rev=336793&r1=336792&r2=336793&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/include/<wbr>llvm/MC/MCDwarf.h?rev=336793&<wbr>r1=336792&r2=336793&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/include/llvm/MC/<wbr>MCDwarf.h (original)<br>
+++ llvm/trunk/include/llvm/MC/<wbr>MCDwarf.h Wed Jul 11 05:30:35 2018<br>
@@ -301,8 +301,6 @@ public:<br>
                                FileNumber));<br>
   }<br>
<br>
-  void RemapDwarfDirs(MCContext &Context);<br>
-<br>
   void setRootFile(StringRef Directory, StringRef FileName,<br>
                    MD5::MD5Result *Checksum, Optional<StringRef> Source) {<br>
     Header.CompilationDir = Directory;<br>
<br>
Modified: llvm/trunk/lib/MC/MCContext.<wbr>cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=336793&r1=336792&r2=336793&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/MC/<wbr>MCContext.cpp?rev=336793&r1=<wbr>336792&r2=336793&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/MC/MCContext.<wbr>cpp (original)<br>
+++ llvm/trunk/lib/MC/MCContext.<wbr>cpp Wed Jul 11 05:30:35 2018<br>
@@ -540,19 +540,26 @@ void MCContext::<wbr>addDebugPrefixMapEntry(c<br>
   DebugPrefixMap.insert(std::<wbr>make_pair(From, To));<br>
 }<br>
<br>
-void MCContext::RemapDebugPath(std:<wbr>:string *Path) {<br>
-  for (const auto &Entry : DebugPrefixMap)<br>
-    if (StringRef(*Path).startswith(<wbr>Entry.first)) {<br>
-      std::string RemappedPath =<br>
-          (Twine(Entry.second) + Path->substr(Entry.first.size(<wbr>))).str();<br>
-      Path->swap(RemappedPath);<br>
-    }<br>
-}<br>
+void MCContext::RemapDebugPaths() {<br>
+  const auto &DebugPrefixMap = this->DebugPrefixMap;<br>
+  const auto RemapDebugPath = [&DebugPrefixMap](std::string &Path) {<br>
+    for (const auto &Entry : DebugPrefixMap)<br>
+      if (StringRef(Path).startswith(<wbr>Entry.first)) {<br>
+        std::string RemappedPath =<br>
+            (Twine(Entry.second) + Path.substr(Entry.first.size()<wbr>)).str();<br>
+        Path.swap(RemappedPath);<br>
+      }<br>
+  };<br>
<br>
-void MCContext::<wbr>RemapCompilationDir() {<br>
+  // Remap compilation directory.<br>
   std::string CompDir = CompilationDir.str();<br>
-  RemapDebugPath(&CompDir);<br>
+  RemapDebugPath(CompDir);<br>
   CompilationDir = CompDir;<br>
+<br>
+  // Remap MCDwarfDirs in all compilation units.<br>
+  for (auto &CUIDTablePair : MCDwarfLineTablesCUMap)<br>
+    for (auto &Dir : CUIDTablePair.second.<wbr>getMCDwarfDirs())<br>
+      RemapDebugPath(Dir);<br>
 }<br>
<br>
 //===-------------------------<wbr>------------------------------<wbr>---------------===//<br>
<br>
Modified: llvm/trunk/lib/MC/MCDwarf.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDwarf.cpp?rev=336793&r1=336792&r2=336793&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/MC/<wbr>MCDwarf.cpp?rev=336793&r1=<wbr>336792&r2=336793&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/MC/MCDwarf.cpp (original)<br>
+++ llvm/trunk/lib/MC/MCDwarf.cpp Wed Jul 11 05:30:35 2018<br>
@@ -251,9 +251,7 @@ void MCDwarfLineTable::Emit(<wbr>MCObjectStre<br>
<br>
   // Handle the rest of the Compile Units.<br>
   for (const auto &CUIDTablePair : LineTables) {<br>
-    auto &LineTable = context.getMCDwarfLineTable(<wbr>CUIDTablePair.first);<br>
-    LineTable.RemapDwarfDirs(MCOS-<wbr>>getContext());<br>
-    LineTable.EmitCU(MCOS, Params, LineStr);<br>
+    CUIDTablePair.second.EmitCU(<wbr>MCOS, Params, LineStr);<br>
   }<br>
<br>
   if (LineStr)<br>
@@ -634,11 +632,6 @@ MCDwarfLineTableHeader::<wbr>tryGetFile(Strin<br>
   return FileNumber;<br>
 }<br>
<br>
-void MCDwarfLineTable::<wbr>RemapDwarfDirs(MCContext &Context) {<br>
-  for (auto &Dir : Header.MCDwarfDirs)<br>
-    Context.RemapDebugPath(&Dir);<br>
-}<br>
-<br>
 /// Utility function to emit the encoding to a streamer.<br>
 void MCDwarfLineAddr::Emit(<wbr>MCStreamer *MCOS, MCDwarfLineTableParams Params,<br>
                            int64_t LineDelta, uint64_t AddrDelta) {<br>
<br>
Modified: llvm/trunk/lib/MC/<wbr>MCObjectStreamer.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=336793&r1=336792&r2=336793&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/MC/<wbr>MCObjectStreamer.cpp?rev=<wbr>336793&r1=336792&r2=336793&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/MC/<wbr>MCObjectStreamer.cpp (original)<br>
+++ llvm/trunk/lib/MC/<wbr>MCObjectStreamer.cpp Wed Jul 11 05:30:35 2018<br>
@@ -661,8 +661,7 @@ void MCObjectStreamer::<wbr>EmitFileDirective<br>
 }<br>
<br>
 void MCObjectStreamer::FinishImpl() {<br>
-  // Remap the compilation directory before emitting.<br>
-  getContext().<wbr>RemapCompilationDir();<br>
+  getContext().RemapDebugPaths()<wbr>;<br>
<br>
   // If we are generating dwarf for assembly source files dump out the sections.<br>
   if (getContext().<wbr>getGenDwarfForAssembly())<br>
<br>
Modified: llvm/trunk/test/MC/ELF/debug-<wbr>prefix-map.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/debug-prefix-map.s?rev=336793&r1=336792&r2=336793&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/test/MC/<wbr>ELF/debug-prefix-map.s?rev=<wbr>336793&r1=336792&r2=336793&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/test/MC/ELF/debug-<wbr>prefix-map.s (original)<br>
+++ llvm/trunk/test/MC/ELF/debug-<wbr>prefix-map.s Wed Jul 11 05:30:35 2018<br>
@@ -4,9 +4,13 @@<br>
<br>
 // RUN: llvm-mc -triple=x86_64-linux-unknown -g src.s -filetype=obj -o out.o<br>
 // RUN: llvm-dwarfdump -v -debug-info out.o | FileCheck --check-prefix=NO_MAP %s<br>
+<br>
 // RUN: llvm-mc -triple=x86_64-linux-unknown -g src.s -filetype=obj -o out.o -fdebug-prefix-map=%t.foo=src_<wbr>root<br>
 // RUN: llvm-dwarfdump -v -debug-info out.o | FileCheck --check-prefix=MAP --implicit-check-not ".foo" %s<br>
<br>
+// RUN: llvm-mc -triple=x86_64-linux-unknown -g %t.foo/src.s -filetype=obj -o out.o -fdebug-prefix-map=%t.foo=/<wbr>src_root<br>
+// RUN: llvm-dwarfdump -v -debug-info out.o | FileCheck --check-prefix=MAP_ABS --implicit-check-not ".foo" %s<br>
+<br>
 f:<br>
   nop<br>
<br>
@@ -15,3 +19,7 @@ f:<br>
 // MAP: DW_AT_name [DW_FORM_string] ("src.s")<br>
 // MAP: DW_AT_comp_dir [DW_FORM_string] ("src_root")<br>
 // MAP: DW_AT_decl_file [DW_FORM_data4] ("src_root{{(/|\\)}}src.s")<br>
+<br>
+// MAP_ABS: DW_AT_name [DW_FORM_string] ("{{/|\\}}src_root{{(/|\\)}}<wbr>src.s")<br>
+// MAP_ABS: DW_AT_comp_dir [DW_FORM_string] ("{{/|\\}}src_root")<br>
+// MAP_ABS: DW_AT_decl_file [DW_FORM_data4] ("{{/|\\}}src_root{{(/|\\)}}<wbr>src.s")<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>