From 5419861a527820cd2f1fe1d10137ead1cd9ff346 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 2 Dec 2016 18:40:43 +0000 Subject: [PATCH] Remove a wrong performance optimization. This is a hack for single thread execution. We are using Color[0] and Color[1] alternately on each iteration. This optimization is to look at the next slot as opposted to the current slot to get recent results early. Turns out that the assumption is wrong, because the other slots are not always have the most recent values, but instead it may have stale values of the previous iteration. This patch removes that performance hack. llvm-svn: 288527 --- lld/ELF/ICF.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lld/ELF/ICF.cpp b/lld/ELF/ICF.cpp index a080605..f2c2409 100644 --- a/lld/ELF/ICF.cpp +++ b/lld/ELF/ICF.cpp @@ -235,19 +235,12 @@ bool ICF::variableEq(const InputSection *A, ArrayRef RelsA, if (!X || !Y) return false; - // Performance hack for single-thread. If no other threads are - // running, we can safely read next colors as there is no race - // condition. This optimization may reduce the number of - // iterations of the main loop because we can see results of the - // same iteration. - size_t Idx = (Config->Threads ? Cnt : Cnt + 1) % 2; - // Ineligible sections have the special color 0. // They can never be the same in terms of section colors. - if (X->Color[Idx] == 0) + if (X->Color[Cnt % 2] == 0) return false; - return X->Color[Idx] == Y->Color[Idx]; + return X->Color[Cnt % 2] == Y->Color[Cnt % 2]; }; return std::equal(RelsA.begin(), RelsA.end(), RelsB.begin(), Eq); -- 2.7.4