-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
codegen_ssa
cleanups
#113879
codegen_ssa
cleanups
#113879
Conversation
d8b1635
to
bbc03e2
Compare
Some changes occurred in compiler/rustc_codegen_gcc cc @antoyo |
I added some more commits. Best reviewed one commit at a time. |
8fbd1a9
to
f7eb0a4
Compare
I added one more small commit. That should be the end of them :) |
☔ The latest upstream changes (presumably #114264) made this pull request unmergeable. Please resolve the merge conflicts. |
It has a single callsite, and provides little value.
And rename the `Compiled` variant as `Finished`, because that name makes it clearer there is nothing left to do, contrasting nicely with the `Needs*` variants.
- Thin and fat LTO can't happen together. - `NeedsLink` and (non-allocator) `Compiled` work item results can't happen together.
It took me some time to understand how the main thread can lend a jobserver token to an LLVM thread. This commit renames a couple of things to make it clearer. - Rename the `LLVMing` variant as `Lending`, because that is a clearer description of what is happening. - Rename `running` as `running_with_own_token`, which makes it clearer that there might be one additional LLVM thread running (with a loaned token). Also add a comment to its definition.
The `Worker` is unnecessary, and just makes it longer than necessary.
This is useful when profiling with a profiler like Samply.
It's no longer used, and `spawn_named_thread` is preferable, because naming threads is helpful when profiling.
Make it match the corresponding comment at the start of the unstable options.
Because it's usefulness wasn't clear to me, and I initially wondered if it could be removed. The text is based on the text in rust-lang#50972, the PR that added the flag.
`CodegenContext` is immutable except for the `worker` field - we clone `CodegenContext` in multiple places, changing the `worker` field each time. It's simpler to move the `worker` field out of `CodegenContext`.
The two functions are alway called together. This commit factors out the repeated code.
This loop condition involves `codegen_state`, `work_items`, and `running_with_own_token`. But the body of the loop cannot modify `codegen_state`, so repeatedly checking it is unnecessary.
The main loop has a *very* complex condition, which includes two mentions of `codegen_state`. The body of the loop then immediately switches on the `codegen_state`. I find it easier to understand if it's a `loop` and we check for exit conditions after switching on `codegen_state`. We end up with a tiny bit of code duplication, but it's clear that (a) we never exit in the `Ongoing` case, (b) we exit in the `Completed` state only if several things are true (and there's interaction with LTO there), and (c) we exit in the `Aborted` state if a couple of things are true. Also, the exit conditions are all simple conjunctions.
It makes things a little clearer.
PR rust-lang#112946 tweaked the naming of LLVM threads, but messed things up slightly, resulting in threads on Windows having names like `optimize module {} regex.f10ba03eb5ec7975-cgu.0`. This commit removes the extraneous `{} `.
This function has some shared code for the thin LTO and fat LTO cases, but those cases have so little in common that it's actually clearer to treat them fully separately.
797e703
to
c17c8dc
Compare
I have rebased. |
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (5082281): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)This benchmark run did not return any relevant results for this metric. CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 652.303s -> 652.574s (0.04%) |
Some clarifications I made when reading this code closely.
r? @tmiasko