[llvm-branch-commits] [lld] r351963 - Merging r351898:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jan 23 08:24:00 PST 2019


Author: hans
Date: Wed Jan 23 08:24:00 2019
New Revision: 351963

URL: http://llvm.org/viewvc/llvm-project?rev=351963&view=rev
Log:
Merging r351898:
------------------------------------------------------------------------
r351898 | pcc | 2019-01-23 00:51:35 +0100 (Wed, 23 Jan 2019) | 13 lines

COFF, ELF: Adjust ICF hash computation to account for self relocations.

It turns out that sections in PGO instrumented object files on Windows
contain a large number of relocations pointing to themselves. With
r347429 this can cause many sections to receive the same hash (usually
zero) as a result of a section's hash being xor'ed with itself.

This patch causes the COFF and ELF linkers to avoid this problem
by adding the hash of the relocated section instead of xor'ing it.
On my machine this causes the regressing test case
provided by Mozilla to terminate in 2m41s.

Differential Revision: https://reviews.llvm.org/D56955
------------------------------------------------------------------------

Modified:
    lld/branches/release_80/   (props changed)
    lld/branches/release_80/COFF/ICF.cpp
    lld/branches/release_80/ELF/ICF.cpp

Propchange: lld/branches/release_80/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Jan 23 08:24:00 2019
@@ -1 +1 @@
-/lld/trunk:351326,351335
+/lld/trunk:351326,351335,351898

Modified: lld/branches/release_80/COFF/ICF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_80/COFF/ICF.cpp?rev=351963&r1=351962&r2=351963&view=diff
==============================================================================
--- lld/branches/release_80/COFF/ICF.cpp (original)
+++ lld/branches/release_80/COFF/ICF.cpp Wed Jan 23 08:24:00 2019
@@ -272,7 +272,7 @@ void ICF::run(ArrayRef<Chunk *> Vec) {
     uint32_t Hash = SC->Class[1];
     for (Symbol *B : SC->symbols())
       if (auto *Sym = dyn_cast_or_null<DefinedRegular>(B))
-        Hash ^= Sym->getChunk()->Class[1];
+        Hash += Sym->getChunk()->Class[1];
     // Set MSB to 1 to avoid collisions with non-hash classs.
     SC->Class[0] = Hash | (1U << 31);
   });

Modified: lld/branches/release_80/ELF/ICF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/branches/release_80/ELF/ICF.cpp?rev=351963&r1=351962&r2=351963&view=diff
==============================================================================
--- lld/branches/release_80/ELF/ICF.cpp (original)
+++ lld/branches/release_80/ELF/ICF.cpp Wed Jan 23 08:24:00 2019
@@ -432,7 +432,7 @@ static void combineRelocHashes(InputSect
     Symbol &S = IS->template getFile<ELFT>()->getRelocTargetSym(Rel);
     if (auto *D = dyn_cast<Defined>(&S))
       if (auto *RelSec = dyn_cast_or_null<InputSection>(D->Section))
-        Hash ^= RelSec->Class[1];
+        Hash += RelSec->Class[1];
   }
   // Set MSB to 1 to avoid collisions with non-hash IDs.
   IS->Class[0] = Hash | (1U << 31);




More information about the llvm-branch-commits mailing list