<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Thanks for letting me know. I'll see if I can come up with an alternative implementation that retains this invariant.<div class=""><br class=""></div><div class="">-- adrian<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Dec 4, 2018, at 7:40 AM, Ilya Biryukov <<a href="mailto:ibiryukov@google.com" class="">ibiryukov@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi Adrian,<div class=""><br class=""></div><div class="">After this change, the .gcno produced by clang store all the paths as absolute (adding the working directory).</div><div class="">We rely on them being relative internally to produce code coverage.</div><div class=""><br class=""></div><div class="">I'm afraid I'll have to revert this change (and prior changes that broke compiler-rt) to unbreak our integrate.</div><div class="">Sorry for the inconvenience.</div></div><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Mon, Dec 3, 2018 at 11:40 PM Adrian Prantl via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: adrian<br class="">
Date: Mon Dec  3 14:37:48 2018<br class="">
New Revision: 348203<br class="">
<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=348203&view=rev" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project?rev=348203&view=rev</a><br class="">
Log:<br class="">
Adapt gcov to changes in CFE.<br class="">
<br class="">
The clang frontend no longer emits the current working directory for<br class="">
DIFiles containing an absolute path in the filename: and will move the<br class="">
common prefix between current working directory and the file into the<br class="">
directory: component.<br class="">
<br class="">
This fixes the GCOV tests in compiler-rt that were broken by the Clang<br class="">
change.<br class="">
<br class="">
Modified:<br class="">
    llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp<br class="">
<br class="">
Modified: llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp<br class="">
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=348203&r1=348202&r2=348203&view=diff" rel="noreferrer" target="_blank" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp?rev=348203&r1=348202&r2=348203&view=diff</a><br class="">
==============================================================================<br class="">
--- llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp (original)<br class="">
+++ llvm/trunk/lib/Transforms/Instrumentation/GCOVProfiling.cpp Mon Dec  3 14:37:48 2018<br class="">
@@ -180,6 +180,12 @@ static StringRef getFunctionName(const D<br class="">
   return SP->getName();<br class="">
 }<br class="">
<br class="">
+template<class DINode> SmallString<128> getFilename(const DINode *N) {<br class="">
+  SmallString<128> Path;<br class="">
+  sys::path::append(Path, N->getDirectory(), N->getFilename());<br class="">
+  return Path;<br class="">
+}<br class="">
+<br class="">
 namespace {<br class="">
   class GCOVRecord {<br class="">
    protected:<br class="">
@@ -256,7 +262,7 @@ namespace {<br class="">
     }<br class="">
<br class="">
    private:<br class="">
-    StringRef Filename;<br class="">
+    std::string Filename;<br class="">
     SmallVector<uint32_t, 32> Lines;<br class="">
   };<br class="">
<br class="">
@@ -377,8 +383,9 @@ namespace {<br class="">
<br class="">
     void writeOut() {<br class="">
       writeBytes(FunctionTag, 4);<br class="">
+      SmallString<128> Filename = getFilename(SP);<br class="">
       uint32_t BlockLen = 1 + 1 + 1 + lengthOfGCOVString(getFunctionName(SP)) +<br class="">
-                          1 + lengthOfGCOVString(SP->getFilename()) + 1;<br class="">
+                          1 + lengthOfGCOVString(Filename) + 1;<br class="">
       if (UseCfgChecksum)<br class="">
         ++BlockLen;<br class="">
       write(BlockLen);<br class="">
@@ -387,7 +394,7 @@ namespace {<br class="">
       if (UseCfgChecksum)<br class="">
         write(CfgChecksum);<br class="">
       writeGCOVString(getFunctionName(SP));<br class="">
-      writeGCOVString(SP->getFilename());<br class="">
+      writeGCOVString(Filename);<br class="">
       write(SP->getLine());<br class="">
<br class="">
       // Emit count of blocks.<br class="">
@@ -466,7 +473,7 @@ bool GCOVProfiler::isFunctionInstrumente<br class="">
   if (FilterRe.empty() && ExcludeRe.empty()) {<br class="">
     return true;<br class="">
   }<br class="">
-  const StringRef Filename = F.getSubprogram()->getFilename();<br class="">
+  SmallString<128> Filename = getFilename(F.getSubprogram());<br class="">
   auto It = InstrumentedFiles.find(Filename);<br class="">
   if (It != InstrumentedFiles.end()) {<br class="">
     return It->second;<br class="">
@@ -531,7 +538,7 @@ std::string GCOVProfiler::mangleName(con<br class="">
     }<br class="">
   }<br class="">
<br class="">
-  SmallString<128> Filename = CU->getFilename();<br class="">
+  SmallString<128> Filename = getFilename(CU);<br class="">
   sys::path::replace_extension(Filename, Notes ? "gcno" : "gcda");<br class="">
   StringRef FName = sys::path::filename(Filename);<br class="">
   SmallString<128> CurPath;<br class="">
@@ -688,7 +695,8 @@ void GCOVProfiler::emitProfileNotes() {<br class="">
       // Add the function line number to the lines of the entry block<br class="">
       // to have a counter for the function definition.<br class="">
       uint32_t Line = SP->getLine();<br class="">
-      Func.getBlock(&EntryBlock).getFile(SP->getFilename()).addLine(Line);<br class="">
+      auto Filename = getFilename(SP);<br class="">
+      Func.getBlock(&EntryBlock).getFile(Filename).addLine(Line);<br class="">
<br class="">
       for (auto &BB : F) {<br class="">
         GCOVBlock &Block = Func.getBlock(&BB);<br class="">
@@ -719,7 +727,7 @@ void GCOVProfiler::emitProfileNotes() {<br class="">
           if (SP != getDISubprogram(Loc.getScope()))<br class="">
             continue;<br class="">
<br class="">
-          GCOVLines &Lines = Block.getFile(SP->getFilename());<br class="">
+          GCOVLines &Lines = Block.getFile(Filename);<br class="">
           Lines.addLine(Loc.getLine());<br class="">
         }<br class="">
         Line = 0;<br class="">
<br class="">
<br class="">
_______________________________________________<br class="">
llvm-commits mailing list<br class="">
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank" class="">llvm-commits@lists.llvm.org</a><br class="">
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br class="">
</blockquote></div><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div dir="ltr" class="m_7122119258351036958gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class=""><div class=""><div dir="ltr" class=""><div class="">Regards,</div><div class="">Ilya Biryukov</div></div></div></div></div>
</div></blockquote></div><br class=""></div></body></html>