<div class="gmail_quote">On 17 October 2011 14:00, Devang Patel <span dir="ltr"><<a href="mailto:dpatel@apple.com">dpatel@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div style="word-wrap:break-word"><br><div><div>On Oct 14, 2011, at 7:10 PM, Nick Lewycky wrote:</div><br><blockquote type="cite"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-color:rgb(204, 204, 204);border-left-style:solid;padding-left:1ex">

<div class="gmail_quote"><div><br></div><div>Please review!</div></div></blockquote></div></blockquote><br></div><blockquote type="cite"><br>Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>===================================================================<br>

--- lib/CodeGen/AsmPrinter/DwarfDebug.cpp<span style="white-space:pre-wrap">    </span>(revision 142035)<br>+++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp<span style="white-space:pre-wrap">    </span>(working copy)<br>@@ -442,23 +442,21 @@<br>

   if (FileName.empty())<br>     return GetOrCreateSourceID("<stdin>", StringRef());<br> <br>-  // MCStream expects full path name as filename.<br>-  if (!DirName.empty() && !sys::path::is_absolute(FileName)) {<br>

-    SmallString<128> FullPathName = DirName;<br>-    sys::path::append(FullPathName, FileName);<br>-    // Here FullPathName will be copied into StringMap by GetOrCreateSourceID.<br>-    return GetOrCreateSourceID(StringRef(FullPathName), StringRef());<br>

-  }<br>+  unsigned SrcId = SourceIdMap.size()+1;<br>+  std::pair<std::string, std::string> SourceName =<br>+      std::make_pair(FileName, DirName);<br>+  std::pair<std::pair<std::string, std::string>, unsigned> Entry =<br>

+      make_pair(SourceName, SrcId);<br> <br>-  StringMapEntry<unsigned> &Entry = SourceIdMap.GetOrCreateValue(FileName);<br>-  if (Entry.getValue())<br>-    return Entry.getValue();<br>+  std::map<std::pair<std::string, std::string>, unsigned>::iterator I;<br>

+  bool NewlyInserted;<br>+  tie(I, NewlyInserted) = SourceIdMap.insert(Entry);<br>+  if (!NewlyInserted)<br>+    return I->second;<br> <br>-  unsigned SrcId = SourceIdMap.size();<br>-  Entry.setValue(SrcId);<br>-<br>
   // Print out a .file directive to specify files for .loc directives.<br>
-  Asm->OutStreamer.EmitDwarfFileDirective(SrcId, Entry.getKey());<br>+  Asm->OutStreamer.EmitDwarfFileDirective(SrcId, Entry.first.second,<br>+                                          Entry.first.first);<br> <br>
   return SrcId;<br>
 }<br>Index: lib/CodeGen/AsmPrinter/DwarfDebug.h<br>===================================================================<br>--- lib/CodeGen/AsmPrinter/DwarfDebug.h<span style="white-space:pre-wrap"> </span>(revision 142035)<br>

+++ lib/CodeGen/AsmPrinter/DwarfDebug.h<span style="white-space:pre-wrap">      </span>(working copy)<br>@@ -26,6 +26,7 @@<br> #include "llvm/ADT/UniqueVector.h"<br> #include "llvm/Support/Allocator.h"<br>
 #include "llvm/Support/DebugLoc.h"<br>
+#include <map><br> <br> namespace llvm {<br> <br>@@ -207,9 +208,9 @@<br>   ///<br>   std::vector<DIEAbbrev *> Abbreviations;<br> <br>-  /// SourceIdMap - Source id map, i.e. pair of directory id and source file<br>

-  /// id mapped to a unique id.<br>-  StringMap<unsigned> SourceIdMap;<br>+  /// SourceIdMap - Source id map, i.e. pair of source filename and directory<br>+  /// mapped to a unique id.<br>+  std::map<std::pair<std::string, std::string>, unsigned> SourceIdMap;<br>

 <br>   /// StringPool - A String->Symbol mapping of strings used by indirect<br><div><div>   /// references.</div></div></blockquote><div></div><div><div><br></div></div>Why do you need this change in DwarfDebug ? Why can't MCAsmStreamer split file and directly ?</div>

</blockquote><div><br></div><div>It can, but that's missing the point :) Clang emits separate file and directory, the .bc has the separate file and directory, we currently join them again here so that the asm stream can split them again. I'm removing that extra join+split pair.</div>

<div><br></div><div>Going forward, the split could produce different results. I want to encode "clang -isystem foo/bar" + "#include <x/y.h>" into</div><div>  directory entry: foo/bar</div><div>  file entry: x/y.h</div>

<div>and there's no way that the resplitting could know that as opposed to "foo" + "bar/x/y.h" and "foo/bar/x" + "y.h".</div><div><br></div><div>Also, this more closely represents what really goes into the debug info, there's a dir entry with the dirname and a file entry which has the filename and the dir entry number.</div>

<div><br></div><div>Nick</div><div><br></div></div>