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

large_assignments: Lint on specific large args passed to functions #116520

Merged
merged 3 commits into from
Jan 16, 2024

Conversation

Enselic
Copy link
Member

@Enselic Enselic commented Oct 7, 2023

@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 Oct 7, 2023
@rustbot
Copy link
Collaborator

rustbot commented Oct 7, 2023

This PR changes MIR

cc @oli-obk, @RalfJung, @JakobDegen, @davidtwco, @celinval, @vakaras

This PR changes Stable MIR

cc @oli-obk, @celinval, @spastorino

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

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

I only reviewed the first commit. I don't understand why you needed to change HIR types to be !Copy. Is that a leftover from previous experimentation adding such a Vec to the HIR?

compiler/rustc_middle/src/thir.rs Outdated Show resolved Hide resolved
compiler/rustc_middle/src/mir/syntax.rs Outdated Show resolved Hide resolved
@Enselic Enselic force-pushed the large-copy-into-fn branch 2 times, most recently from b4384b9 to 1f1bc69 Compare October 7, 2023 22:18
@Enselic Enselic 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 Oct 8, 2023
@Enselic Enselic force-pushed the large-copy-into-fn branch 2 times, most recently from 748ed9c to f43309d Compare October 13, 2023 21:30
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@Enselic
Copy link
Member Author

Enselic commented Oct 14, 2023

Looks like I need to bless 309 mir-opt tests to make CI pass. To not make the diff too noisy, would you mind doing a code review of the first commit before I bless tests? Am I on the right track?

@rustbot ready

@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 Oct 14, 2023
Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

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

I did write a review last night but seem to have fallen asleep while doing so.

None of this is important or even nits you must address, pick what you like

I like how it works now

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs Outdated Show resolved Hide resolved
compiler/rustc_codegen_ssa/src/mir/block.rs Outdated Show resolved Hide resolved
compiler/rustc_borrowck/src/lib.rs Show resolved Hide resolved
@rust-log-analyzer

This comment has been minimized.

@oli-obk
Copy link
Contributor

oli-obk commented Oct 14, 2023

Ah, I think we shouldn't bless the mir opt tests. Instead change the mir printing logic to skip the Spanned and directly print the Operand

@Enselic
Copy link
Member Author

Enselic commented Oct 14, 2023

@RalfJung Do you think this (Spanned<Operand>>) looks good? If both you and @oli-obk likes it, wouldn't it be nice to later make a PR that changes TerminatorKind::Drop from

func: Operand<'tcx>,
fn_span: Span,
...

to

func: Spanned<Operand<'tcx>>,
...

? I would be happy to do that later if you want it done.

@Enselic
Copy link
Member Author

Enselic commented Oct 14, 2023

Instead change the mir printing logic to skip the Spanned and directly print the Operand

Done!

@RalfJung
Copy link
Member

The change in compiler/rustc_middle/src/mir/syntax.rs LGTM, assuming this doesn't cost too much perf. We should do a perf run before landing. Let me know when you're ready for that, I can tell the bots to do it.

wouldn't it be nice to later make a PR that changes TerminatorKind::Drop

No strong opinion, but sure, why not. :)
We can even almost make ConstOperand just a Spanned<Const>, but sadly there's this user_ty field getting in the way...

@Enselic
Copy link
Member Author

Enselic commented Jan 16, 2024

👍 @bors r=@oli-obk

@bors
Copy link
Contributor

bors commented Jan 16, 2024

📌 Commit 8f440f0 has been approved by oli-obk

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-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). labels Jan 16, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 16, 2024
large_assignments: Lint on specific large args passed to functions

Requires lowering function call arg spans down to MIR, which is done in the second commit.

Part of rust-lang#83518

Also see
* https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/arg.20Spans.20for.20TerminatorKind.3A.3ACall.3F
* https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/move_size_limit.20lint

r? `@oli-obk` (E-mentor)
@bors
Copy link
Contributor

bors commented Jan 16, 2024

⌛ Testing commit 8f440f0 with merge 7d98bab...

@bors
Copy link
Contributor

bors commented Jan 16, 2024

💥 Test timed out

@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 Jan 16, 2024
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@oli-obk
Copy link
Contributor

oli-obk commented Jan 16, 2024

@bors retry apple timeout

@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 Jan 16, 2024
@bors
Copy link
Contributor

bors commented Jan 16, 2024

⌛ Testing commit 8f440f0 with merge 92f2e0a...

@bors
Copy link
Contributor

bors commented Jan 16, 2024

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 92f2e0a to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jan 16, 2024
@bors bors merged commit 92f2e0a into rust-lang:master Jan 16, 2024
12 checks passed
@rustbot rustbot added this to the 1.77.0 milestone Jan 16, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (92f2e0a): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

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.2%, 0.8%] 45
Regressions ❌
(secondary)
0.6% [0.2%, 2.1%] 8
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-6.0% [-6.0%, -6.0%] 1
All ❌✅ (primary) 0.4% [0.2%, 0.8%] 45

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.6% [1.1%, 2.1%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.4% [-2.4%, -2.3%] 2
Improvements ✅
(secondary)
-3.0% [-4.5%, -1.8%] 4
All ❌✅ (primary) -0.0% [-2.4%, 2.1%] 5

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

Binary size

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

Bootstrap: 663.55s -> 663.149s (-0.06%)
Artifact size: 308.22 MiB -> 308.26 MiB (0.01%)

@oli-obk
Copy link
Contributor

oli-obk commented Jan 17, 2024

This regression is expected.

We are tracking more spans in order to be able to produce correct diagnostics. We expect to be using this information more now that we have it. I do expect some improvements to be possible in borrowck errors and const prop lints

@rustbot label: +perf-regression-triaged

@rustbot rustbot added the perf-regression-triaged The performance regression has been triaged. label Jan 17, 2024
feliperodri pushed a commit to model-checking/kani that referenced this pull request Jan 18, 2024
Fixes were done to address the following upstream changes:

- rust-lang/rust#119606
- rust-lang/rust#119751
- rust-lang/rust#120025
- rust-lang/rust#116520

Resolves #2971 

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 18, 2024
Make `TerminatorKind::Call::func` `Spanned` and remove `::fn_span`

To get structural symmetry between `TerminatorKind::Call::func` and `TerminatorKind::Call::args`, make `func` `Spanned`, since `args` already is `Spanned`. This way we can remove the separate `fn_span` field.

Doing this was briefly discussed [here](rust-lang#116520 (comment)).

For easier review, this PR is split into two commits. The first commit is the actual change. The second commit just makes the code build again and is very repetitive.

Can someone start a perf run of this change please?
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. perf-regression Performance regression. perf-regression-triaged The performance regression has been triaged. 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.