Skip to content

Conversation

@cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Oct 14, 2025

MIR currently contains a ShallowInitBox rvalue. Its principal usage is to allow for in-place initialization of boxes. Having it is necessary for drop elaboration to be correct with that in-place initialization.

As part of analysis->runtime MIR lowering, we canonicalize deref of boxes to use the stored raw pointer. But we did not perform the same change to the construction of the box.

This PR replaces ShallowInitBox by the pointer manipulation it represents.

Alternatives:

  • fully remove ShallowInitBox and implement Box in-place initialization differently;
  • remove the ElaborateBoxDeref pass and keep dereferencing Box in runtime MIR.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 14, 2025
@cjgillot
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Oct 15, 2025
Forbid ShallowInitBox after box deref elaboration.
@rust-bors

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 15, 2025
@rust-bors
Copy link

rust-bors bot commented Oct 15, 2025

☀️ Try build successful (CI)
Build commit: 472fdbf (472fdbff5e8adcc0c5d6905b613add926cbfec40, parent: 235a4c083eb2a2bfe8779d211c3232f39396de00)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (472fdbf): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf.

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

Instruction count

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

Max RSS (memory usage)

Results (primary -0.3%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.1% [1.2%, 3.0%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-5.0% [-5.0%, -5.0%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.3% [-5.0%, 3.0%] 3

Cycles

Results (secondary -2.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.9% [3.9%, 3.9%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-5.0% [-6.0%, -3.9%] 2
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.0%, secondary 0.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.4%] 14
Regressions ❌
(secondary)
0.1% [0.0%, 0.1%] 2
Improvements ✅
(primary)
-0.2% [-0.3%, -0.0%] 9
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [-0.3%, 0.4%] 23

Bootstrap: 474.707s -> 474.445s (-0.06%)
Artifact size: 388.17 MiB -> 388.15 MiB (-0.00%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Oct 15, 2025
@cjgillot cjgillot marked this pull request as ready for review October 16, 2025 19:05
@rustbot
Copy link
Collaborator

rustbot commented Oct 16, 2025

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Some changes occurred in compiler/rustc_codegen_ssa

cc @WaffleLapkin

@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 16, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 16, 2025

r? @nnethercote

rustbot has assigned @nnethercote.
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


#[macro_export]
macro_rules! indexvec {
($expr:expr; $n:expr) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

We also have IndexVec::from_elem_n. Probably doesn't hurt to have this as well, just thought I'd mention it.

@nnethercote
Copy link
Contributor

I don't see anything objectionable here but my knowledge of this part of the code is very thin, so it's a very shallow approval, and I have zero sense of whether this approach is better or worse than the alternatives mentioned in the PR description. So I would be happy if someone who knows more (@bjorn3? @WaffleLapkin?) wants to weigh in.

@bors
Copy link
Collaborator

bors commented Oct 18, 2025

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

@rustbot

This comment has been minimized.

@nnethercote
Copy link
Contributor

Can you squash the 3rd commit into the 1st commit? r=me with that.

@nnethercote nnethercote added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Oct 21, 2025
@rustbot
Copy link
Collaborator

rustbot commented Oct 22, 2025

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@cjgillot
Copy link
Contributor Author

@bors r=nnethercote

@bors
Copy link
Collaborator

bors commented Oct 22, 2025

📌 Commit 0156eaf has been approved by nnethercote

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. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 22, 2025
@bors
Copy link
Collaborator

bors commented Oct 22, 2025

⌛ Testing commit 0156eaf with merge f5e2df7...

@bors
Copy link
Collaborator

bors commented Oct 22, 2025

☀️ Test successful - checks-actions
Approved by: nnethercote
Pushing f5e2df7 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Oct 22, 2025
@bors bors merged commit f5e2df7 into rust-lang:master Oct 22, 2025
12 checks passed
@rustbot rustbot added this to the 1.92.0 milestone Oct 22, 2025
@github-actions
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing b2ee1b3 (parent) -> f5e2df7 (this PR)

Test differences

Show 2 test diffs

2 doctest diffs were found. These are ignored, as they are noisy.

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard f5e2df741b4a9820a7579f0c8eccc951706a8782 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-android: 1202.1s -> 1642.5s (36.6%)
  2. dist-apple-various: 3442.2s -> 4066.8s (18.1%)
  3. dist-aarch64-apple: 7285.9s -> 6113.6s (-16.1%)
  4. aarch64-gnu: 6289.0s -> 7268.6s (15.6%)
  5. dist-armhf-linux: 5092.0s -> 5824.0s (14.4%)
  6. x86_64-rust-for-linux: 2812.9s -> 3172.6s (12.8%)
  7. dist-s390x-linux: 4957.5s -> 5524.0s (11.4%)
  8. dist-x86_64-windows-gnullvm: 5344.9s -> 4850.1s (-9.3%)
  9. x86_64-gnu-llvm-20-3: 6196.9s -> 6722.7s (8.5%)
  10. dist-powerpc64le-linux-gnu: 5722.2s -> 5252.0s (-8.2%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f5e2df7): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

@rustbot label: -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

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

Max RSS (memory usage)

Results (primary 1.4%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.4% [2.1%, 2.9%] 3
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.6% [-1.6%, -1.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.4% [-1.6%, 2.9%] 4

Cycles

Results (secondary -3.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.1% [-3.8%, -2.4%] 2
All ❌✅ (primary) - - 0

Binary size

Results (primary -0.0%, secondary 0.0%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.8%] 11
Regressions ❌
(secondary)
0.0% [0.0%, 0.0%] 2
Improvements ✅
(primary)
-0.2% [-0.3%, -0.0%] 11
Improvements ✅
(secondary)
-0.1% [-0.1%, -0.1%] 1
All ❌✅ (primary) -0.0% [-0.3%, 0.8%] 22

Bootstrap: 472.274s -> 472.978s (0.15%)
Artifact size: 390.70 MiB -> 390.71 MiB (0.00%)

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.

6 participants