Skip to content
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

Support running LLVM backend in a separate thread #21068

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

antlilja
Copy link
Contributor

Closes #20635

@jacobly0

Most changes are quite straightforward, I did however have to move some Compilation mutex locking from Compilation.zig into PerThread.zig in order to fix a race condition on Zcu.import_tables. This seemed like the most reasonable solution as it's accessed all over the place in Sema.zig, but maybe it goes against some overarching locking strategy?

@jacobly0
Copy link
Member

Backends should never be calling importPkg, another solution to this will need to be found before enabling llvm backend threading.

@antlilja antlilja force-pushed the llvm-seperate-thread branch from c0adbb9 to 61b53d0 Compare August 16, 2024 14:58
@antlilja
Copy link
Contributor Author

The only caller of importPkg seems to be getStackTraceType which is used when lowering function types. I threw together a bit of a hacky fix which stores the stack trace type inside the Zcu to test it if works.

@andrewrk
Copy link
Member

What makes it "hacky" and what would a non "hacky" fix do differently?

@antlilja
Copy link
Contributor Author

antlilja commented Aug 16, 2024

What makes it "hacky" and what would a non "hacky" fix do differently?

Checking the value every time at the end of finishFunc feels a bit unnecessary, but maybe this it's a reasonable solution. I just wanted to point it out in case someone reviewing with more experience of the codebase had encountered something similar and had a better solution to initializing Zcu state.

@antlilja antlilja force-pushed the llvm-seperate-thread branch from 61b53d0 to f9a38de Compare September 1, 2024 15:45
@antlilja antlilja force-pushed the llvm-seperate-thread branch from f9a38de to bc9cc55 Compare October 28, 2024 23:48
@antlilja antlilja force-pushed the llvm-seperate-thread branch from bc9cc55 to 6f9c4ee Compare December 26, 2024 19:18
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.

llvm: support the backend being run in a separate thread
3 participants