[PATCH] D103165: Threading: use independent llvm::thread implementation on Apple platforms to increase stack size

Tim Northover via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 1 06:33:49 PDT 2021


t.p.northover updated this revision to Diff 348958.
t.p.northover added a comment.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, hiraditya.
Herald added a project: clang-tools-extra.

- Add `llvm::thread` for all potential platforms, allowing stack size to be specified.
- `llvm::thread` based on the `Threading.inc` where possible, else `std::thread`, else in-thread synchronous execution (with progressively more failures).
- Remove `llvm_execute_on_thread*` in favour of this new `llvm::thread`.

I've managed to test it on all 3 major platforms, and the fallbacks by fiddling `#if`s. So it should at least compile everywhere.

> Also this way llvm::thread users that don't need full-sized stacks can continue getting the Darwin default of smaller pages.

I'm not sure I've implemented this, since I've just made 8MB the Darwin default here. The case I care about is LTOBackend via `ThreadPool`. Would you prefer me to push an optional `StackSize` argument into `ThreadPool` too and make LTOBackend specify it?

I kind of think this has come up often enough (it's at least the second time I've had to fix it somewhere), and 8MB is small enough for anything running Clang that it's better to make sure it doesn't happen again.


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

https://reviews.llvm.org/D103165

Files:
  clang-tools-extra/clangd/support/Threading.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/Support/CrashRecoveryContext.h
  llvm/include/llvm/Support/Threading.h
  llvm/include/llvm/Support/thread.h
  llvm/lib/Support/CrashRecoveryContext.cpp
  llvm/lib/Support/Threading.cpp
  llvm/lib/Support/Unix/Threading.inc
  llvm/lib/Support/Windows/Threading.inc
  llvm/unittests/Support/Threading.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103165.348958.patch
Type: text/x-patch
Size: 20138 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210601/799ca436/attachment-0001.bin>


More information about the cfe-commits mailing list