[PATCH] D142318: [Support] Add PerThreadBumpPtrAllocator class.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 17 10:32:57 PDT 2023


MaskRay added a comment.

> Anyway, I tend to lean towards initializing threadIndex with -1:

This looks good to me to avoid collision between the main thread and the thread pool thread 0. This also fulfills "remove zero initialization." in a comment in D142317 <https://reviews.llvm.org/D142317>.

> It will break this code lld/ELF/Relocations.cpp:



  if (serial)
    fn();   <<<<< called on the main thread, it calls getThreadIndex() inside.
  else
    tg.execute(fn);

Yes. It seems that we need a serial `tg.xxxxx` that makes `getThreadIndex() == 0`, even if `llvm::parallel::strategy` requests more than one threads.

I haven't thought about other changes very clearly. The safeguard changes and discussions can go to another patch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142318/new/

https://reviews.llvm.org/D142318



More information about the llvm-commits mailing list