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
This commit is contained in:
Rui Ueyama 2016-12-02 18:40:43 +00:00
parent 612d24badf
commit 5419861a52

View File

@ -235,19 +235,12 @@ bool ICF<ELFT>::variableEq(const InputSection<ELFT> *A, ArrayRef<RelTy> 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);