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

Set writable and dead_on_unwind attributes for sret arguments #121298

Merged
merged 3 commits into from
Apr 25, 2024

Conversation

nikic
Copy link
Contributor

@nikic nikic commented Feb 19, 2024

Set the writable and dead_on_unwind attributes for sret arguments. This allows call slot optimization to remove more memcpy's.

See https://llvm.org/docs/LangRef.html#parameter-attributes for the specification of these attributes. In short, the statement we're making here is that:

  • The return slot is writable.
  • The return slot will not be read if the function unwinds.

Fixes #90595.

@rustbot
Copy link
Collaborator

rustbot commented Feb 19, 2024

r? @estebank

rustbot has assigned @estebank.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 19, 2024
@nikic nikic force-pushed the writable branch 2 times, most recently from ce4d7ea to 5c66f83 Compare February 19, 2024 14:16
@nikic
Copy link
Contributor Author

nikic commented Feb 19, 2024

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Feb 19, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 19, 2024
Set writable and dead_on_unwind attributes for sret arguments

Set the `writable` and `dead_on_unwind` attributes for `sret` arguments. This allows call slot optimization to remove more memcpy's.

See https://llvm.org/docs/LangRef.html#parameter-attributes for the specification of these attributes.

Fixes rust-lang#90595.
@bors
Copy link
Contributor

bors commented Feb 19, 2024

⌛ Trying commit 5c66f83 with merge b47488b...

@bors
Copy link
Contributor

bors commented Feb 19, 2024

☀️ Try build successful - checks-actions
Build commit: b47488b (b47488b90dd6a20d00a1d40779a009b874c67255)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (b47488b): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.4% [0.3%, 0.5%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-4.4% [-26.5%, -0.3%] 8
Improvements ✅
(secondary)
-1.4% [-3.8%, -0.3%] 9
All ❌✅ (primary) -3.4% [-26.5%, 0.5%] 10

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.5% [1.5%, 1.5%] 1
Regressions ❌
(secondary)
2.6% [2.6%, 2.6%] 1
Improvements ✅
(primary)
-0.7% [-0.7%, -0.7%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.4% [-0.7%, 1.5%] 2

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-5.1% [-27.8%, -0.9%] 7
Improvements ✅
(secondary)
-3.3% [-4.6%, -2.4%] 11
All ❌✅ (primary) -5.1% [-27.8%, -0.9%] 7

Binary size

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.2% [-0.5%, -0.1%] 16
Improvements ✅
(secondary)
-0.2% [-0.8%, -0.0%] 16
All ❌✅ (primary) -0.2% [-0.5%, -0.1%] 16

Bootstrap: 641.758s -> 639.466s (-0.36%)
Artifact size: 308.80 MiB -> 308.59 MiB (-0.07%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Feb 19, 2024
@bors
Copy link
Contributor

bors commented Mar 11, 2024

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

@nikic
Copy link
Contributor Author

nikic commented Mar 11, 2024

Rebase & ping

@nikic
Copy link
Contributor Author

nikic commented Apr 8, 2024

r? @cuviper

@rustbot rustbot assigned cuviper and unassigned estebank Apr 8, 2024
@cuviper
Copy link
Member

cuviper commented Apr 8, 2024

Sound good! And for reference, I also found that you added this to Clang in llvm/llvm-project#77116.

@bors r+

@bors
Copy link
Contributor

bors commented Apr 8, 2024

📌 Commit e2b946e has been approved by cuviper

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 Apr 8, 2024
@bors
Copy link
Contributor

bors commented Apr 8, 2024

⌛ Testing commit e2b946e with merge cf9a460...

@nikic
Copy link
Contributor Author

nikic commented Apr 9, 2024

The problem on AArch64 is that SROA raises the alignment of an alloca when rewriting it: https://llvm.godbolt.org/z/szb1soPYs Because of that, we later no longer know that replacing the alloca with the (lower-aligned) sret parameter is legal.

In this case the rewrite done by SROA is pretty spurious, and I think #122053 is going to avoid the issue by dint of directly using the type it rewrites to.

I do wonder whether SROA really ought to be raising the alignment here...

@nikic
Copy link
Contributor Author

nikic commented Apr 24, 2024

Let's try this again now that #122053 has landed...

@bors r=cuviper

@bors
Copy link
Contributor

bors commented Apr 24, 2024

📌 Commit 9cdc44b has been approved by cuviper

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 Apr 24, 2024
@bors
Copy link
Contributor

bors commented Apr 24, 2024

⌛ Testing commit 9cdc44b with merge 0702ea6...

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 24, 2024
Set writable and dead_on_unwind attributes for sret arguments

Set the `writable` and `dead_on_unwind` attributes for `sret` arguments. This allows call slot optimization to remove more memcpy's.

See https://llvm.org/docs/LangRef.html#parameter-attributes for the specification of these attributes. In short, the statement we're making here is that:

 * The return slot is writable.
 * The return slot will not be read if the function unwinds.

Fixes rust-lang#90595.
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Apr 24, 2024

💔 Test failed - checks-actions

@bors bors 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 Apr 24, 2024
@matthiaskrgr
Copy link
Member

@bors r-

@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-review Status: Awaiting review from the assignee but also interested parties. labels Apr 24, 2024
nikic added 3 commits April 25, 2024 11:43
When compiled with -C panic=abort we'd generate an extra
panic_cannot_unwind shim in the variant calling C-unwind.
@nikic
Copy link
Contributor Author

nikic commented Apr 25, 2024

Added missing needs-unwind annotation to the codegen test.

@bors r=cuviper

@bors
Copy link
Contributor

bors commented Apr 25, 2024

📌 Commit 976267b has been approved by cuviper

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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 25, 2024
@bors
Copy link
Contributor

bors commented Apr 25, 2024

⌛ Testing commit 976267b with merge 284f94f...

@bors
Copy link
Contributor

bors commented Apr 25, 2024

☀️ Test successful - checks-actions
Approved by: cuviper
Pushing 284f94f to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 25, 2024
@bors bors merged commit 284f94f into rust-lang:master Apr 25, 2024
11 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Apr 25, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (284f94f): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.5% [0.5%, 0.5%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-3.1% [-26.0%, -0.3%] 12
Improvements ✅
(secondary)
-1.6% [-4.4%, -0.5%] 11
All ❌✅ (primary) -2.8% [-26.0%, 0.5%] 13

Max RSS (memory usage)

This benchmark run did not return any relevant results for this metric.

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.7% [2.7%, 2.7%] 1
Improvements ✅
(primary)
-7.9% [-27.3%, -1.0%] 4
Improvements ✅
(secondary)
-4.1% [-6.3%, -2.5%] 12
All ❌✅ (primary) -7.9% [-27.3%, -1.0%] 4

Binary size

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.1% [0.1%, 0.1%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.2% [-0.5%, -0.0%] 16
Improvements ✅
(secondary)
-0.8% [-0.8%, -0.8%] 5
All ❌✅ (primary) -0.2% [-0.5%, 0.1%] 17

Bootstrap: 673.228s -> 670.551s (-0.40%)
Artifact size: 315.45 MiB -> 315.96 MiB (0.16%)

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.

MaybeUninit seems to prevent RVO in even the most trivial cases.
8 participants