[lld] r288527 - Remove a wrong performance optimization.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 2 10:40:43 PST 2016


Author: ruiu
Date: Fri Dec  2 12:40:43 2016
New Revision: 288527

URL: http://llvm.org/viewvc/llvm-project?rev=288527&view=rev
Log:
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.

Modified:
    lld/trunk/ELF/ICF.cpp

Modified: lld/trunk/ELF/ICF.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ICF.cpp?rev=288527&r1=288526&r2=288527&view=diff
==============================================================================
--- lld/trunk/ELF/ICF.cpp (original)
+++ lld/trunk/ELF/ICF.cpp Fri Dec  2 12:40:43 2016
@@ -235,19 +235,12 @@ bool ICF<ELFT>::variableEq(const InputSe
     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);




More information about the llvm-commits mailing list