[lld] r248106 - COFF: Fix race condition.

Sean Silva via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 20 18:32:00 PDT 2015


It seems unfortunate for us to need any synchronization at all just to
generate a unique ID. Can we just have a bunch of counters, one per thread,
then initialize them to `ThreadIndex << 50` or something? (make sure they
are each on their own cache line)

-- Sean Silva

On Sat, Sep 19, 2015 at 6:44 PM, Rui Ueyama via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: ruiu
> Date: Sat Sep 19 20:44:44 2015
> New Revision: 248106
>
> URL: http://llvm.org/viewvc/llvm-project?rev=248106&view=rev
> Log:
> COFF: Fix race condition.
>
> NextID is updated inside parallel_for_each, so it needs mutual exclusion.
>
> Modified:
>     lld/trunk/COFF/ICF.cpp
>
> Modified: lld/trunk/COFF/ICF.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/ICF.cpp?rev=248106&r1=248105&r2=248106&view=diff
>
> ==============================================================================
> --- lld/trunk/COFF/ICF.cpp (original)
> +++ lld/trunk/COFF/ICF.cpp Sat Sep 19 20:44:44 2015
> @@ -73,7 +73,7 @@ private:
>    bool forEachGroup(std::vector<SectionChunk *> &Chunks, Comparator Eq);
>    bool partition(ChunkIterator Begin, ChunkIterator End, Comparator Eq);
>
> -  uint64_t NextID = 1;
> +  std::atomic<uint64_t> NextID = { 1 };
>  };
>
>  // Entry point to ICF.
>
>
> _______________________________________________
> 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/20150920/36fd70db/attachment.html>


More information about the llvm-commits mailing list