diff options
Diffstat (limited to 'ELF/ICF.cpp')
-rw-r--r-- | ELF/ICF.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/ELF/ICF.cpp b/ELF/ICF.cpp index 3f326fa33..7c07a42a8 100644 --- a/ELF/ICF.cpp +++ b/ELF/ICF.cpp @@ -425,16 +425,17 @@ void ICF<ELFT>::forEachClass(llvm::function_ref<void(size_t, size_t)> Fn) { // Combine the hashes of the sections referenced by the given section into its // hash. template <class ELFT, class RelTy> -static void combineRelocHashes(InputSection *IS, ArrayRef<RelTy> Rels) { - uint32_t Hash = IS->Class[1]; +static void combineRelocHashes(unsigned Cnt, InputSection *IS, + ArrayRef<RelTy> Rels) { + uint32_t Hash = IS->Class[Cnt % 2]; for (RelTy Rel : Rels) { 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[Cnt % 2]; } // Set MSB to 1 to avoid collisions with non-hash IDs. - IS->Class[0] = Hash | (1U << 31); + IS->Class[(Cnt + 1) % 2] = Hash | (1U << 31); } static void print(const Twine &S) { @@ -452,15 +453,17 @@ template <class ELFT> void ICF<ELFT>::run() { // Initially, we use hash values to partition sections. parallelForEach(Sections, [&](InputSection *S) { - S->Class[1] = xxHash64(S->data()); + S->Class[0] = xxHash64(S->data()); }); - parallelForEach(Sections, [&](InputSection *S) { - if (S->AreRelocsRela) - combineRelocHashes<ELFT>(S, S->template relas<ELFT>()); - else - combineRelocHashes<ELFT>(S, S->template rels<ELFT>()); - }); + for (unsigned Cnt = 0; Cnt != 2; ++Cnt) { + parallelForEach(Sections, [&](InputSection *S) { + if (S->AreRelocsRela) + combineRelocHashes<ELFT>(Cnt, S, S->template relas<ELFT>()); + else + combineRelocHashes<ELFT>(Cnt, S, S->template rels<ELFT>()); + }); + } // From now on, sections in Sections vector are ordered so that sections // in the same equivalence class are consecutive in the vector. |