<div dir="ltr">Reverted in r338110 to unbreak the integrate.</div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jul 27, 2018 at 10:46 AM Ilya Biryukov <<a href="mailto:ibiryukov@google.com">ibiryukov@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">The results depend on the compiler flags, specifically setting '-funsigned-char' produces different results.</div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jul 27, 2018 at 9:46 AM Ilya Biryukov <<a href="mailto:ibiryukov@google.com" target="_blank">ibiryukov@google.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This seems to break our integrate, the order of sections in the test seems different. Any ideas what could cause this?</div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jul 27, 2018 at 1:34 AM Peter Collingbourne via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: pcc<br>
Date: Thu Jul 26 16:34:35 2018<br>
New Revision: 338088<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=338088&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=338088&view=rev</a><br>
Log:<br>
ELF: Make --print-icf-sections output deterministic.<br>
<br>
The icf-safe.s test currently fails on 32-bit platforms because it uses<br>
the --print-icf-sections flag and depends on the output appearing in<br>
a specific order. However, this flag causes the output to depend on<br>
the order of the sections in the Sections array, which depends on the<br>
hash values returned from hash_combine, which happen to be different<br>
for that test between 32-bit and 64-bit platforms.<br>
<br>
This change makes the output deterministic by using xxHash64 instead of<br>
hash_combine.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D49877" rel="noreferrer" target="_blank">https://reviews.llvm.org/D49877</a><br>
<br>
Modified:<br>
    lld/trunk/ELF/ICF.cpp<br>
    lld/trunk/test/ELF/icf-safe.s<br>
<br>
Modified: lld/trunk/ELF/ICF.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ICF.cpp?rev=338088&r1=338087&r2=338088&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ICF.cpp?rev=338088&r1=338087&r2=338088&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/ELF/ICF.cpp (original)<br>
+++ lld/trunk/ELF/ICF.cpp Thu Jul 26 16:34:35 2018<br>
@@ -80,9 +80,10 @@<br>
 #include "SyntheticSections.h"<br>
 #include "Writer.h"<br>
 #include "lld/Common/Threads.h"<br>
-#include "llvm/ADT/Hashing.h"<br>
+#include "llvm/ADT/StringExtras.h"<br>
 #include "llvm/BinaryFormat/ELF.h"<br>
 #include "llvm/Object/ELF.h"<br>
+#include "llvm/Support/xxhash.h"<br>
 #include <algorithm><br>
 #include <atomic><br>
<br>
@@ -155,12 +156,6 @@ private:<br>
 };<br>
 }<br>
<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, S->Data);<br>
-}<br>
-<br>
 // Returns true if section S is subject of ICF.<br>
 static bool isEligible(InputSection *S) {<br>
   if (!S->Live || S->KeepUnique || !(S->Flags & SHF_ALLOC))<br>
@@ -441,7 +436,7 @@ template <class ELFT> void ICF<ELFT>::ru<br>
   // Initially, we use hash values to partition 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) | (1U << 31);<br>
+    S->Class[0] = xxHash64(toStringRef(S->Data)) | (1U << 31);<br>
   });<br>
<br>
   // From now on, sections in Sections vector are ordered so that sections<br>
<br>
Modified: lld/trunk/test/ELF/icf-safe.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/icf-safe.s?rev=338088&r1=338087&r2=338088&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/icf-safe.s?rev=338088&r1=338087&r2=338088&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/test/ELF/icf-safe.s (original)<br>
+++ lld/trunk/test/ELF/icf-safe.s Thu Jul 26 16:34:35 2018<br>
@@ -10,10 +10,6 @@<br>
 # RUN: ld.lld %t1.o %t2.o -o %t2 --icf=all --print-icf-sections --export-dynamic | FileCheck --check-prefix=ALL-EXPORT %s<br>
 # RUN: ld.lld %t1copy.o -o %t4 --icf=safe 2>&1 | FileCheck --check-prefix=OBJCOPY %s<br>
<br>
-# CHECK-NOT: selected section {{.*}}:(.rodata.l1)<br>
-# CHECK: selected section {{.*}}:(.rodata.l3)<br>
-# CHECK:   removing identical section {{.*}}:(.rodata.l4)<br>
-<br>
 # CHECK-NOT: selected section {{.*}}:(.text.f1)<br>
 # CHECK: selected section {{.*}}:(.text.f3)<br>
 # CHECK:   removing identical section {{.*}}:(.text.f4)<br>
@@ -22,6 +18,10 @@<br>
 # CHECK: selected section {{.*}}:(.rodata.h3)<br>
 # CHECK:   removing identical section {{.*}}:(.rodata.h4)<br>
<br>
+# CHECK-NOT: selected section {{.*}}:(.rodata.l1)<br>
+# CHECK: selected section {{.*}}:(.rodata.l3)<br>
+# CHECK:   removing identical section {{.*}}:(.rodata.l4)<br>
+<br>
 # CHECK-NOT: selected section {{.*}}:(.rodata.g1)<br>
 # CHECK: selected section {{.*}}:(.rodata.g3)<br>
 # CHECK:   removing identical section {{.*}}:(.rodata.g4)<br>
@@ -30,21 +30,21 @@<br>
<br>
 # With --icf=all address-significance implies keep-unique only for rodata, not<br>
 # text.<br>
-# ALL-NOT: selected section {{.*}}:(.rodata.l1)<br>
-# ALL: selected section {{.*}}:(.rodata.l3)<br>
-# ALL:   removing identical section {{.*}}:(.rodata.l4)<br>
-<br>
 # ALL: selected section {{.*}}:(.text.f3)<br>
 # ALL:   removing identical section {{.*}}:(.text.f4)<br>
<br>
+# ALL-NOT: selected section {{.*}}:(.rodata.h1)<br>
+# ALL: selected section {{.*}}:(.rodata.h3)<br>
+# ALL:   removing identical section {{.*}}:(.rodata.h4)<br>
+<br>
 # ALL: selected section {{.*}}:(.text.f1)<br>
 # ALL:   removing identical section {{.*}}:(.text.f2)<br>
 # ALL:   removing identical section {{.*}}:(.text.non_addrsig1)<br>
 # ALL:   removing identical section {{.*}}:(.text.non_addrsig2)<br>
<br>
-# ALL-NOT: selected section {{.*}}:(.rodata.h1)<br>
-# ALL: selected section {{.*}}:(.rodata.h3)<br>
-# ALL:   removing identical section {{.*}}:(.rodata.h4)<br>
+# ALL-NOT: selected section {{.*}}:(.rodata.l1)<br>
+# ALL: selected section {{.*}}:(.rodata.l3)<br>
+# ALL:   removing identical section {{.*}}:(.rodata.l4)<br>
<br>
 # ALL-NOT: selected section {{.*}}:(.rodata.g1)<br>
 # ALL: selected section {{.*}}:(.rodata.g3)<br>
@@ -58,36 +58,36 @@<br>
 # STB_LOCAL or STV_HIDDEN symbols. The dynsym entries should have prevented<br>
 # anything else from being merged.<br>
 # EXPORT-NOT: selected section<br>
-# EXPORT: selected section {{.*}}:(.rodata.l3)<br>
-# EXPORT:   removing identical section {{.*}}:(.rodata.l4)<br>
-# EXPORT-NOT: selected section<br>
 # EXPORT: selected section {{.*}}:(.rodata.h3)<br>
 # EXPORT:   removing identical section {{.*}}:(.rodata.h4)<br>
 # EXPORT-NOT: selected section<br>
 # EXPORT: selected section {{.*}}:(.text)<br>
 # EXPORT:   removing identical section {{.*}}:(.text)<br>
 # EXPORT-NOT: selected section<br>
+# EXPORT: selected section {{.*}}:(.rodata.l3)<br>
+# EXPORT:   removing identical section {{.*}}:(.rodata.l4)<br>
+# EXPORT-NOT: selected section<br>
<br>
 # If --icf=all is specified when exporting we can also merge the exported text<br>
 # sections, but not the exported rodata.<br>
 # ALL-EXPORT-NOT: selected section<br>
-# ALL-EXPORT: selected section {{.*}}:(.rodata.l3)<br>
-# ALL-EXPORT:   removing identical section {{.*}}:(.rodata.l4)<br>
-# ALL-EXPORT-NOT: selected section<br>
 # ALL-EXPORT: selected section {{.*}}:(.text.f3)<br>
 # ALL-EXPORT:   removing identical section {{.*}}:(.text.f4)<br>
 # ALL-EXPORT-NOT: selected section<br>
+# ALL-EXPORT: selected section {{.*}}:(.rodata.h3)<br>
+# ALL-EXPORT:   removing identical section {{.*}}:(.rodata.h4)<br>
+# ALL-EXPORT-NOT: selected section<br>
 # ALL-EXPORT: selected section {{.*}}:(.text.f1)<br>
 # ALL-EXPORT:   removing identical section {{.*}}:(.text.f2)<br>
 # ALL-EXPORT:   removing identical section {{.*}}:(.text.non_addrsig1)<br>
 # ALL-EXPORT:   removing identical section {{.*}}:(.text.non_addrsig2)<br>
 # ALL-EXPORT-NOT: selected section<br>
-# ALL-EXPORT: selected section {{.*}}:(.rodata.h3)<br>
-# ALL-EXPORT:   removing identical section {{.*}}:(.rodata.h4)<br>
-# ALL-EXPORT-NOT: selected section<br>
 # ALL-EXPORT: selected section {{.*}}:(.text)<br>
 # ALL-EXPORT:   removing identical section {{.*}}:(.text)<br>
 # ALL-EXPORT-NOT: selected section<br>
+# ALL-EXPORT: selected section {{.*}}:(.rodata.l3)<br>
+# ALL-EXPORT:   removing identical section {{.*}}:(.rodata.l4)<br>
+# ALL-EXPORT-NOT: selected section<br>
<br>
 # OBJCOPY: --icf=safe is incompatible with object files created using objcopy or ld -r<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">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/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_-7627967387398909166m_-3522041273458229186gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Regards,</div><div>Ilya Biryukov</div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_-7627967387398909166gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Regards,</div><div>Ilya Biryukov</div></div></div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Regards,</div><div>Ilya Biryukov</div></div></div></div></div>