[PATCH] D119674: [BOLT] Make BinaryFunction::eraseInvalidBBs() thread-safe

Vladislav Khmelevsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 14 10:54:59 PST 2022


yota9 added inline comments.


================
Comment at: bolt/lib/Core/BinaryFunction.cpp:352
+      if (BB->size()) {
+        std::unique_lock<std::shared_timed_mutex> Lock(BC.CtxMutex);
+        Bytes += BB->estimateSize();
----------------
Amir wrote:
> yota9 wrote:
> > Maybe move lock under estimateSize()? 
> BB->estimateSize is called from two more places:
> - ExtTSPReorderAlgorithm
> - ReorderAlgorithm
> which operate with an IndependentCodeEmitter and don't need locks.
Than it might be lock under condition. I just feel that it is not the best place. The estimateSize might be used in other places, e.g. the passes like golang support and longjmp. And we will need to think about locking each time in each place. Anyway I don't insist on this :) 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119674



More information about the llvm-commits mailing list