[lld] r288527 - Remove a wrong performance optimization.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 4 08:43:53 PST 2016
Yeah, that was actually easy. Done in r288620. Thank you for the suggestion!
On Sun, Dec 4, 2016 at 1:36 AM, Sean Silva <chisophugis at gmail.com> wrote:
> 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.
>
> -- Sean Silva
>
> On Fri, Dec 2, 2016 at 10:40 AM, Rui Ueyama via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> 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?re
>> v=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);
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161204/653b9133/attachment.html>
More information about the llvm-commits
mailing list