Skip to content

Cleanup codegen_llvm/back - #54864

Merged
bors merged 10 commits into
rust-lang:masterfrom
ljedrz:cleanup_codegen_llvm_back
Nov 11, 2018
Merged

Cleanup codegen_llvm/back#54864
bors merged 10 commits into
rust-lang:masterfrom
ljedrz:cleanup_codegen_llvm_back

Conversation

@ljedrz

Copy link
Copy Markdown
Contributor
  • 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 returns
  • whitespace & formatting fixes

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @pnkfelix

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 6, 2018

@pnkfelixpnkfelix left a comment

Copy link
Copy Markdown
Contributor

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...

@ljedrz

ljedrz commented Oct 9, 2018

Copy link
Copy Markdown
ContributorAuthor

@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.

@ljedrz

Copy link
Copy Markdown
ContributorAuthor

It seems @pnkfelix is busy with NLL; r? @Mark-Simulacrum

@Mark-SimulacrumMark-Simulacrum left a comment

Copy link
Copy Markdown
Member

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

Comment threadsrc/librustc_codegen_llvm/back/bytecode.rs Outdated
Comment threadsrc/librustc_codegen_llvm/back/link.rs Outdated
Comment threadsrc/librustc_codegen_llvm/back/link.rs Outdated
Comment threadsrc/librustc_codegen_llvm/back/link.rs Outdated
Comment threadsrc/librustc_codegen_llvm/back/linker.rs Outdated
Comment threadsrc/librustc_codegen_llvm/back/linker.rs Outdated
Comment threadsrc/librustc_codegen_llvm/back/lto.rs Outdated
@ljedrz
ljedrzforce-pushed the cleanup_codegen_llvm_back branch from a544455 to 60e123dCompareOctober 16, 2018 17:58
@ljedrz

Copy link
Copy Markdown
ContributorAuthor

@Mark-Simulacrum thanks for the thorough review! I think I addressed all the issues.

@ljedrz
ljedrzforce-pushed the cleanup_codegen_llvm_back branch from 60e123d to ec65cffCompareOctober 16, 2018 20:19
@ljedrz

Copy link
Copy Markdown
ContributorAuthor

@Mark-Simulacrum r? I won't be able to rebase for the next few days.

Comment threadsrc/librustc_codegen_llvm/back/link.rs Outdated
@ljedrzljedrz closed this Oct 19, 2018
@ljedrz
ljedrz deleted the cleanup_codegen_llvm_back branch October 19, 2018 12:36
@ljedrz
ljedrz restored the cleanup_codegen_llvm_back branch October 19, 2018 13:27
@ljedrzljedrz reopened this Oct 19, 2018
@ljedrz

Copy link
Copy Markdown
ContributorAuthor

The deletion was an accident. Travis should still be happy.

@ljedrz
ljedrzforce-pushed the cleanup_codegen_llvm_back branch from ec65cff to d2f2446CompareOctober 29, 2018 09:20
@ljedrz

Copy link
Copy Markdown
ContributorAuthor

Included the suggestion by @sinkuu.

@bors

bors commented Nov 4, 2018

Copy link
Copy Markdown
Collaborator

☔ The latest upstream changes (presumably #55349) made this pull request unmergeable. Please resolve the merge conflicts.

@ljedrz
ljedrzforce-pushed the cleanup_codegen_llvm_back branch from d2f2446 to b74c9d6CompareNovember 5, 2018 12:57
@ljedrz

Copy link
Copy Markdown
ContributorAuthor

Rebased.

@Mark-Simulacrum

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Nov 5, 2018

Copy link
Copy Markdown
Collaborator

📌 Commit b74c9d60bf23b7d975dc87f5efeadd5fe937f605 has been approved by Mark-Simulacrum

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 5, 2018
@bors

bors commented Nov 5, 2018

Copy link
Copy Markdown
Collaborator

⌛ Testing commit b74c9d60bf23b7d975dc87f5efeadd5fe937f605 with merge f0097bd6148de603f9f56d906f5a286d568be711...

@borsbors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 10, 2018
@ljedrz
ljedrzforce-pushed the cleanup_codegen_llvm_back branch from 50c7e80 to 2f99d09CompareNovember 10, 2018 18:25
@ljedrz

Copy link
Copy Markdown
ContributorAuthor

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.

@nagisa

Copy link
Copy Markdown
Member

@bors r=Mark-Simulacrum

@bors

bors commented Nov 10, 2018

Copy link
Copy Markdown
Collaborator

📌 Commit 2f99d09 has been approved by Mark-Simulacrum

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 10, 2018
@bors

bors commented Nov 10, 2018

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 2f99d09 with merge 6408162...

bors added a commit that referenced this pull request Nov 10, 2018
…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
@bors

bors commented Nov 11, 2018

Copy link
Copy Markdown
Collaborator

☀️ Test successful - status-appveyor, status-travis
Approved by: Mark-Simulacrum
Pushing 6408162 to master...

@bors
bors merged commit 2f99d09 into rust-lang:masterNov 11, 2018
@ljedrz
ljedrz deleted the cleanup_codegen_llvm_back branch November 11, 2018 07:05
bors added a commit that referenced this pull request Nov 11, 2018
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.
bors added a commit that referenced this pull request Dec 4, 2018
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.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@ljedrz@rust-highfive@bors@Mark-Simulacrum@kennytm@nagisa@pnkfelix@sinkuu