Skip to content

[llvm][clang] Allocate a new stack instead of spawning a new thread to get more stack space #10628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

Bigcheese
Copy link

Clang spawns a new thread to avoid running out of stack space. This can make debugging and performance analysis more difficult as how the threads are connected is difficult to recover.

This patch introduces runOnNewStack and applies it in Clang. On platforms that have good support for it this allocates a new stack and moves to it using assembly. Doing split stacks like this actually runs on most platforms, but many debuggers and unwinders reject the large or backwards stack offsets that occur. Apple platforms and tools are known to support this, so this only enables it there for now.

(cherry picked from commit 07deaf8)

@Bigcheese Bigcheese requested a review from a team as a code owner May 6, 2025 23:12
@Bigcheese
Copy link
Author

@swift-ci please test

…o get more stack space

Clang spawns a new thread to avoid running out of stack space. This can
make debugging and performance analysis more difficult as how the
threads are connected is difficult to recover.

This patch introduces `runOnNewStack` and applies it in Clang. On
platforms that have good support for it this allocates a new stack and
moves to it using assembly. Doing split stacks like this actually runs
on most platforms, but many debuggers and unwinders reject the large or
backwards stack offsets that occur. Apple platforms and tools are known
to support this, so this only enables it there for now.

(cherry picked from commit 07deaf8)
@Bigcheese Bigcheese force-pushed the dev/split-stacks-6.2 branch from dcdb166 to 6fc4878 Compare May 6, 2025 23:48
@Bigcheese
Copy link
Author

@swift-ci please test

@Bigcheese
Copy link
Author

@swift-ci please test macos

@Bigcheese Bigcheese requested a review from cyndyishida May 7, 2025 20:21
@cyndyishida cyndyishida merged commit 606a7f3 into swiftlang:swift/release/6.2 May 8, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants