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

fix: #128855 Ensure Guard's drop method is removed at opt-level=s for `… #128862

Merged
merged 2 commits into from
Aug 12, 2024

Conversation

cblh
Copy link
Contributor

@cblh cblh commented Aug 9, 2024

fix: #128855

…Copy` types

Added #[inline] to the drop method in the Guard implementation to ensure that the method is removed by the compiler at optimization level opt-level=s for Copy types. This change aims to align the method's behavior with optimization expectations and ensure it does not affect performance.

r​? @scottmcm

…Copy` types

Added `#[inline]` to the `drop` method in the `Guard` implementation to ensure that the method is removed by the compiler at optimization level `opt-level=s` for `Copy` types. This change aims to align the method's behavior with optimization expectations and ensure it does not affect performance.
@rustbot
Copy link
Collaborator

rustbot commented Aug 9, 2024

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @tgross35 (or someone else) some time within the next two weeks.

Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (S-waiting-on-review and S-waiting-on-author) stays updated, invoking these commands when appropriate:

  • @rustbot author: the review is finished, PR author should check the comments and take action accordingly
  • @rustbot review: the author is ready for a review, this PR will be queued again in the reviewer's queue

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 9, 2024
Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

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

This PR needs a test to actually demonstrate that it has the right effect.

@tgross35
Copy link
Contributor

tgross35 commented Aug 9, 2024

Looks like rustbot missed the assignment request

r​? @scottmcm

@tgross35
Copy link
Contributor

tgross35 commented Aug 9, 2024

Helloooooo rustbot

@tgross35 tgross35 assigned scottmcm and unassigned tgross35 Aug 9, 2024
@compiler-errors compiler-errors 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 Aug 10, 2024
This commit adds a new test file 'array-from_fn.rs' to the codegen test suite.
The test checks the behavior of std::array::from_fn under different optimization levels:

1. At opt-level=0 (debug build), it verifies that the core::array::Guard
   is present in the generated code.
2. At opt-level=s (size optimization), it ensures that the Guard is
   optimized out.

This test helps ensure that the compiler correctly optimizes array::from_fn
calls in release builds while maintaining safety checks in debug builds.
@cblh cblh requested a review from compiler-errors August 10, 2024 02:45
@scottmcm
Copy link
Member

Thanks!

@bors r+ rollup=iffy (hopefully fine since it ran in CI, but new codegen tests are always scary for weird targets)

@bors
Copy link
Collaborator

bors commented Aug 10, 2024

📌 Commit 3dc083d has been approved by scottmcm

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 Aug 10, 2024
@bors
Copy link
Collaborator

bors commented Aug 12, 2024

⌛ Testing commit 3dc083d with merge 1d8f135...

@bors
Copy link
Collaborator

bors commented Aug 12, 2024

☀️ Test successful - checks-actions
Approved by: scottmcm
Pushing 1d8f135 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 12, 2024
@bors bors merged commit 1d8f135 into rust-lang:master Aug 12, 2024
7 checks passed
@rustbot rustbot added this to the 1.82.0 milestone Aug 12, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (1d8f135): comparison URL.

Overall result: ❌✅ regressions and 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
Regressions ❌
(secondary)
1.3% [1.3%, 1.3%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-1.0% [-1.0%, -1.0%] 1
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (primary 2.4%)

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)
2.4% [2.4%, 2.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 2.4% [2.4%, 2.4%] 1

Cycles

Results (secondary -5.6%)

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
Improvements ✅
(secondary)
-5.6% [-7.6%, -2.2%] 3
All ❌✅ (primary) - - 0

Binary size

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

Bootstrap: 752.51s -> 753.683s (0.16%)
Artifact size: 339.31 MiB -> 339.37 MiB (0.02%)

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-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

array::Guard's drop isn't removed in opt-level=s for Copy types
7 participants