<div dir="ltr">I think this can be easily fixed by just using a single constant index in the no-thread case, i.e. `(Config->Threads ? Cnt : 0)` or something like that.<div><br></div><div>-- Sean Silva</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Dec 2, 2016 at 10:40 AM, Rui Ueyama via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ruiu<br>
Date: Fri Dec  2 12:40:43 2016<br>
New Revision: 288527<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=288527&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=288527&view=rev</a><br>
Log:<br>
Remove a wrong performance optimization.<br>
<br>
This is a hack for single thread execution. We are using Color[0] and<br>
Color[1] alternately on each iteration. This optimization is to look<br>
at the next slot as opposted to the current slot to get recent results<br>
early. Turns out that the assumption is wrong, because the other slots<br>
are not always have the most recent values, but instead it may have<br>
stale values of the previous iteration. This patch removes that<br>
performance hack.<br>
<br>
Modified:<br>
    lld/trunk/ELF/ICF.cpp<br>
<br>
Modified: lld/trunk/ELF/ICF.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/ICF.cpp?rev=288527&r1=288526&r2=288527&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/ICF.cpp?<wbr>rev=288527&r1=288526&r2=<wbr>288527&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/ICF.cpp (original)<br>
+++ lld/trunk/ELF/ICF.cpp Fri Dec  2 12:40:43 2016<br>
@@ -235,19 +235,12 @@ bool ICF<ELFT>::variableEq(const InputSe<br>
     if (!X || !Y)<br>
       return false;<br>
<br>
-    // Performance hack for single-thread. If no other threads are<br>
-    // running, we can safely read next colors as there is no race<br>
-    // condition. This optimization may reduce the number of<br>
-    // iterations of the main loop because we can see results of the<br>
-    // same iteration.<br>
-    size_t Idx = (Config->Threads ? Cnt : Cnt + 1) % 2;<br>
-<br>
     // Ineligible sections have the special color 0.<br>
     // They can never be the same in terms of section colors.<br>
-    if (X->Color[Idx] == 0)<br>
+    if (X->Color[Cnt % 2] == 0)<br>
       return false;<br>
<br>
-    return X->Color[Idx] == Y->Color[Idx];<br>
+    return X->Color[Cnt % 2] == Y->Color[Cnt % 2];<br>
   };<br>
<br>
   return std::equal(RelsA.begin(), RelsA.end(), RelsB.begin(), Eq);<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>