<div dir="auto">We're there ever times previously where we would avoid reading the section contents due to delaying the content hash?<div dir="auto"><br></div><div dir="auto">-- Sean Silva</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Oct 1, 2017 6:22 PM, "Rui Ueyama via llvm-commits" <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ruiu<br>
Date: Sun Oct  1 18:21:07 2017<br>
New Revision: 314644<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=314644&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=314644&view=rev</a><br>
Log:<br>
[ICF] Include section contents in section hash values.<br>
<br>
Computing section content hashes early seems like a win in terms of<br>
performance. It increases a chance that two different sections will get<br>
different class IDs from the beginning.<br>
<br>
Without threads, this patch improves Chromium link time by about 0.3<br>
seconds. With threads, by 0.1 seconds. That's less than 1% time saving<br>
but not bad for a small patch.<br>
<br>
Modified:<br>
    lld/trunk/COFF/ICF.cpp<br>
    lld/trunk/ELF/ICF.cpp<br>
<br>
Modified: lld/trunk/COFF/ICF.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/ICF.cpp?rev=314644&r1=314643&r2=314644&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/COFF/ICF.<wbr>cpp?rev=314644&r1=314643&r2=<wbr>314644&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/COFF/ICF.cpp (original)<br>
+++ lld/trunk/COFF/ICF.cpp Sun Oct  1 18:21:07 2017<br>
@@ -61,9 +61,9 @@ private:<br>
<br>
 // Returns a hash value for S.<br>
 uint32_t ICF::getHash(SectionChunk *C) {<br>
-  return hash_combine(C-><wbr>getPermissions(), hash_value(C->SectionName),<br>
-                      C->NumRelocs, C->Alignment,<br>
-                      uint32_t(C->Header-><wbr>SizeOfRawData), C->Checksum);<br>
+  return hash_combine(C-><wbr>getPermissions(), C->SectionName, C->NumRelocs,<br>
+                      C->Alignment, uint32_t(C->Header-><wbr>SizeOfRawData),<br>
+                      C->Checksum, C->getContents());<br>
 }<br>
<br>
 // Returns true if section S is subject of ICF.<br>
@@ -210,9 +210,10 @@ void ICF::run(const std::vector<Chunk *><br>
   }<br>
<br>
   // Initially, we use hash values to partition sections.<br>
-  for (SectionChunk *SC : Chunks)<br>
+  for_each(parallel::par, Chunks.begin(), Chunks.end(), [&](SectionChunk *SC) {<br>
     // Set MSB to 1 to avoid collisions with non-hash classs.<br>
     SC->Class[0] = getHash(SC) | (1 << 31);<br>
+  });<br>
<br>
   // From now on, sections in Chunks are ordered so that sections in<br>
   // the same group are consecutive in the vector.<br>
<br>
Modified: lld/trunk/ELF/ICF.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ICF.cpp?rev=314644&r1=314643&r2=314644&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/ICF.cpp?<wbr>rev=314644&r1=314643&r2=<wbr>314644&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/ICF.cpp (original)<br>
+++ lld/trunk/ELF/ICF.cpp Sun Oct  1 18:21:07 2017<br>
@@ -155,7 +155,7 @@ private:<br>
 // Returns a hash value for S. Note that the information about<br>
 // relocation targets is not included in the hash value.<br>
 template <class ELFT> static uint32_t getHash(InputSection *S) {<br>
-  return hash_combine(S->Flags, S->getSize(), S->NumRelocations);<br>
+  return hash_combine(S->Flags, S->getSize(), S->NumRelocations, S->Data);<br>
 }<br>
<br>
 // Returns true if section S is subject of ICF.<br>
@@ -394,9 +394,10 @@ template <class ELFT> void ICF<ELFT>::ru<br>
         Sections.push_back(S);<br>
<br>
   // Initially, we use hash values to partition sections.<br>
-  for (InputSection *S : Sections)<br>
+  parallelForEach(Sections, [&](InputSection *S) {<br>
     // Set MSB to 1 to avoid collisions with non-hash IDs.<br>
     S->Class[0] = getHash<ELFT>(S) | (1 << 31);<br>
+  });<br>
<br>
   // From now on, sections in Sections vector are ordered so that sections<br>
   // in the same equivalence class are consecutive in the vector.<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>