-
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
Cleanup codegen_llvm/back #54864
Cleanup codegen_llvm/back #54864
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this commit the result of running rustfmt
? Just curious...
@pnkfelix: you mean the whitespace one? No; those lines were hand-picked after having done all the other changes. I adjusted those spots along the way. |
It seems @pnkfelix is busy with NLL; r? @Mark-Simulacrum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with landing this but some of these seem like they might not actually be improvements
a544455
to
60e123d
Compare
@Mark-Simulacrum thanks for the thorough review! I think I addressed all the issues. |
60e123d
to
ec65cff
Compare
@Mark-Simulacrum r? I won't be able to rebase for the next few days. |
The deletion was an accident. Travis should still be happy. |
ec65cff
to
d2f2446
Compare
Included the suggestion by @sinkuu. |
☔ The latest upstream changes (presumably #55349) made this pull request unmergeable. Please resolve the merge conflicts. |
d2f2446
to
b74c9d6
Compare
Rebased. |
@bors r+ |
📌 Commit b74c9d60bf23b7d975dc87f5efeadd5fe937f605 has been approved by |
⌛ Testing commit b74c9d60bf23b7d975dc87f5efeadd5fe937f605 with merge f0097bd6148de603f9f56d906f5a286d568be711... |
50c7e80
to
2f99d09
Compare
I removed the memory-related commit; maybe I will come up with a solution in the future, but there's no point in holding back the rest of the changes. |
@bors r=Mark-Simulacrum |
📌 Commit 2f99d09 has been approved by |
…acrum Cleanup codegen_llvm/back - improve allocations - use `Cow<'static, str>` where applicable - use `to_owned` instead of `to_string` with string literals - remove a redundant `continue` - possible minor speedup in logic - use `mem::replace` instead of `swap` where more concise - remove `'static` from consts - improve common patterns - remove explicit `return`s - whitespace & formatting fixes
☀️ Test successful - status-appveyor, status-travis |
codegen_llvm_back: improve allocations This commit was split out from #54864. Last time it was causing an LLVM OOM, presumably due to aggressive preallocation strategy in `thin_lto`. This time preallocations are more cautious and there are a few additional memory-related improvements (last 3 points from the list below). - _gently_ preallocate vectors of known length - `extend` instead of `append` where the argument is consumable - turn 2 `push` loops into `extend`s - create a vector from a function producing one instead of using `extend_from_slice` on it - consume `modules` when no longer needed - return an `impl Iterator` from `generate_lto_work` - don't `collect` `globals`, as they are iterated over and consumed right afterwards While I'm hoping it won't cause an OOM anymore, I would still consider this a "high-risk" PR and not roll it up.
codegen_llvm_back: improve allocations This commit was split out from #54864. Last time it was causing an LLVM OOM, which was most probably caused by not collecting the globals. - preallocate vectors of known length - `extend` instead of `append` where the argument is consumable - turn 2 `push` loops into `extend`s - create a vector from a function producing one instead of using `extend_from_slice` on it - consume `modules` when no longer needed - ~~return an `impl Iterator` from `generate_lto_work`~~ - ~~don't `collect` `globals`, as they are iterated over and consumed right afterwards~~ While I'm hoping it won't cause an OOM anymore, I would still consider this a "high-risk" PR and not roll it up.
Cow<'static, str>
where applicableto_owned
instead ofto_string
with string literalscontinue
mem::replace
instead ofswap
where more concise'static
from constsreturn
s