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

Allow to disable thinLTO buffer to support lto-embed-bitcode lld feature #98162

Merged
merged 1 commit into from
Jul 21, 2022

Conversation

darkness-ai
Copy link
Contributor

@darkness-ai darkness-ai commented Jun 16, 2022

Hello
This change is to fix issue (#84395) in which passing "-lto-embed-bitcode=optimized" to lld when linking rust code via linker-plugin-lto doesn't produce the expected result.

Instead of emitting a single unified module into a llvmbc section of the linked elf, it emits multiple submodules.
This is caused because rustc emits the BC modules after running llvm createWriteThinLTOBitcodePass pass.
Which in turn triggers a thinLTO linkage and causes the said issue.

This patch allows via compiler flag (-Cemit-thin-lto=) to select between running createWriteThinLTOBitcodePass and createBitcodeWriterPass.
Note this pattern of selecting between those 2 passes is common inside of LLVM code.
The default is to match the old behavior.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 16, 2022
@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @lcnr (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 16, 2022
@lcnr
Copy link
Contributor

lcnr commented Jun 28, 2022

seems like i missed the notification for this PR 😅 sorry

r? rust-lang/compiler

@rust-highfive rust-highfive assigned davidtwco and unassigned lcnr Jun 28, 2022
compiler/rustc_session/src/options.rs Outdated Show resolved Hide resolved
@davidtwco davidtwco added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 28, 2022
@rust-log-analyzer

This comment has been minimized.

@darkness-ai
Copy link
Contributor Author

@rustbot label -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 3, 2022
@darkness-ai
Copy link
Contributor Author

@rustbot label -S-waiting-on-review +S-waiting-on-author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 3, 2022
@rust-log-analyzer

This comment has been minimized.

@darkness-ai
Copy link
Contributor Author

@rustbot label -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 3, 2022
@bors

This comment was marked as resolved.

Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think you could add a test case that uses this and -lto-embed-bitcode=optimized to confirm that it fixes the issue?

@davidtwco davidtwco removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 4, 2022
@bors bors 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 Jul 6, 2022
@bors

This comment was marked as resolved.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 9, 2022
@darkness-ai
Copy link
Contributor Author

@rustbot label -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 9, 2022
@bors
Copy link
Contributor

bors commented Jul 10, 2022

@darkness-ai: 🔑 Insufficient privileges: Not in reviewers

@davidtwco
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jul 11, 2022

📌 Commit 3858cddaec9a7480b94bfa8432c9ed4df13b0478 has been approved by davidtwco

It is now in the queue for this repository.

@bors bors 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 Jul 11, 2022
Adding the option to control from rustc CLI
if the resulted ".o" bitcode module files are with
thinLTO info or regular LTO info.

Allows using "-lto-embed-bitcode=optimized" during linkage
correctly.

Signed-off-by: Ziv Dunkelman <ziv.dunkelman@nextsilicon.com>
@darkness-ai
Copy link
Contributor Author

@davidtwco saw PRs conflicting with this one got merged into master.
Pushed fixes for the mismatch.

@davidtwco
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jul 15, 2022

📌 Commit 724c912 has been approved by davidtwco

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jul 21, 2022

⌛ Testing commit 724c912 with merge 74f600b...

@bors
Copy link
Contributor

bors commented Jul 21, 2022

☀️ Test successful - checks-actions
Approved by: davidtwco
Pushing 74f600b to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 21, 2022
@bors bors merged commit 74f600b into rust-lang:master Jul 21, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 21, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (74f600b): comparison url.

Instruction count

  • Primary benchmarks: 🎉 relevant improvements found
  • Secondary benchmarks: no relevant changes found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
-0.4% -0.4% 2
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) -0.4% -0.4% 2

Max RSS (memory usage)

Results
  • Primary benchmarks: 🎉 relevant improvement found
  • Secondary benchmarks: 😿 relevant regression found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
5.7% 5.7% 1
Improvements 🎉
(primary)
-2.2% -2.2% 1
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) -2.2% -2.2% 1

Cycles

Results
  • Primary benchmarks: 😿 relevant regression found
  • Secondary benchmarks: 🎉 relevant improvement found
mean1 max count2
Regressions 😿
(primary)
1.8% 1.8% 1
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
-2.5% -2.5% 1
All 😿🎉 (primary) 1.8% 1.8% 1

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@darkness-ai darkness-ai deleted the support_lto_embed_bitcode branch July 26, 2022 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants