Skip to content

Conversation

cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Sep 9, 2025

Supporting union values is not very hard, and allows to const-prop them.

r? @ghost for perf

@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 Sep 9, 2025
@cjgillot
Copy link
Contributor Author

cjgillot commented Sep 9, 2025

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

rust-bors bot added a commit that referenced this pull request Sep 9, 2025
@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 Sep 9, 2025
@rust-bors
Copy link

rust-bors bot commented Sep 9, 2025

☀️ Try build successful (CI)
Build commit: 366a987 (366a9875a4c25a2e49bf4797159bb426a8ffd701, parent: 9c27f27ea3bab79a2fec827ef3ae0009959d60f4)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (366a987): comparison URL.

Overall result: ❌✅ regressions and improvements - 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

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

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

Max RSS (memory usage)

Results (primary 2.9%, secondary 2.5%)

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

mean range count
Regressions ❌
(primary)
2.9% [2.9%, 2.9%] 1
Regressions ❌
(secondary)
3.6% [0.7%, 5.2%] 10
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.9% [-2.9%, -2.8%] 2
All ❌✅ (primary) 2.9% [2.9%, 2.9%] 1

Cycles

Results (secondary 2.8%)

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

Binary size

Results (primary 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.1%, 0.2%] 5
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.2% [-0.2%, -0.2%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [-0.2%, 0.2%] 6

Bootstrap: 467.433s -> 467.12s (-0.07%)
Artifact size: 387.54 MiB -> 387.87 MiB (0.08%)

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 9, 2025
@cjgillot cjgillot marked this pull request as ready for review September 14, 2025 21:40
@rustbot
Copy link
Collaborator

rustbot commented Sep 14, 2025

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@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 Sep 14, 2025
@cjgillot cjgillot added A-mir-opt Area: MIR optimizations A-mir-opt-GVN Area: MIR opt Global Value Numbering (GVN) labels Sep 14, 2025
@cjgillot
Copy link
Contributor Author

r? compiler

@jackh726
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 26, 2025

📌 Commit 6fba73e has been approved by jackh726

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 Sep 26, 2025
bors added a commit that referenced this pull request Sep 26, 2025
GVN: Support unions. Supporting union values is not very hard, and allows to const-prop them. r? `@ghost` for perf
@bors
Copy link
Collaborator

bors commented Sep 26, 2025

⌛ Testing commit 6fba73e with merge df8b765...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Sep 26, 2025

💔 Test failed - checks-actions

@bors bors removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Sep 26, 2025
@cjgillot
Copy link
Contributor Author

Oops, that was a delayed error message.
@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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 27, 2025
@rustbot

This comment has been minimized.

@cjgillot
Copy link
Contributor Author

cjgillot commented Oct 6, 2025

@bors r=jackh726

@bors
Copy link
Collaborator

bors commented Oct 6, 2025

📌 Commit 8c1dfbb has been approved by jackh726

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

rustbot commented Oct 6, 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

cjgillot commented Oct 6, 2025

Rebase after #144477
@bors r=jackh726

@bors
Copy link
Collaborator

bors commented Oct 6, 2025

📌 Commit 96c3978 has been approved by jackh726

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Oct 7, 2025

⌛ Testing commit 96c3978 with merge ff5be13...

@bors
Copy link
Collaborator

bors commented Oct 7, 2025

☀️ Test successful - checks-actions
Approved by: jackh726
Pushing ff5be13 to master...

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

github-actions bot commented Oct 7, 2025

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 68ad253 (parent) -> ff5be13 (this PR)

Test differences

Show 6 test diffs

Stage 1

  • [mir-opt] tests/mir-opt/const_prop/union.rs: [missing] -> pass (J0)
  • [mir-opt] tests/mir-opt/dest-prop/union.rs: pass -> [missing] (J0)

Stage 2

  • [mir-opt] tests/mir-opt/const_prop/union.rs: [missing] -> pass (J1)
  • [mir-opt] tests/mir-opt/dest-prop/union.rs: pass -> [missing] (J1)

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

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \ test-dashboard ff5be13e2d9f398c38215958021e4c7970f88914 --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. x86_64-rust-for-linux: 2464.4s -> 3106.3s (26.0%)
  2. dist-apple-various: 3450.2s -> 4119.6s (19.4%)
  3. tidy: 214.5s -> 190.5s (-11.2%)
  4. dist-aarch64-apple: 8034.2s -> 7225.1s (-10.1%)
  5. armhf-gnu: 5165.4s -> 4700.4s (-9.0%)
  6. i686-msvc-2: 7228.1s -> 7875.4s (9.0%)
  7. dist-powerpc64le-linux-gnu: 5238.5s -> 5702.6s (8.9%)
  8. aarch64-gnu-llvm-20-1: 3906.9s -> 3606.2s (-7.7%)
  9. dist-various-1: 3665.3s -> 3935.4s (7.4%)
  10. aarch64-msvc-2: 5104.5s -> 4738.0s (-7.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 (ff5be13): comparison URL.

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

Max RSS (memory usage)

Results (primary -2.4%, secondary -0.3%)

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)
2.3% [2.1%, 2.6%] 3
Improvements ✅
(primary)
-2.4% [-2.4%, -2.4%] 1
Improvements ✅
(secondary)
-2.2% [-3.3%, -0.6%] 4
All ❌✅ (primary) -2.4% [-2.4%, -2.4%] 1

Cycles

Results (secondary 1.9%)

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

Binary size

Results (primary 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.3% [0.2%, 0.3%] 2
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.0% [-0.0%, -0.0%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.1% [-0.0%, 0.3%] 5

Bootstrap: 473.761s -> 473.87s (0.02%)
Artifact size: 388.37 MiB -> 388.40 MiB (0.01%)

@cjgillot cjgillot deleted the gvn-union branch October 7, 2025 10:14
@RalfJung
Copy link
Member

RalfJung commented Oct 9, 2025

What exactly does this assume about unions? I see something involving an "active field" and my alarm bells go off; unions in Rust do not have a notion of active field, they are basically just syntactic sugar for transmutes.

@cjgillot
Copy link
Contributor Author

cjgillot commented Oct 9, 2025

The two simplifications we perform are:

  • constant folding, which may introduce constants with undef bytes, more often than transmutes;
  • Union { x: foo }.x simplified to foo.

We do no assume any behaviour if the projection field is not the construction field.

For the "active" terminology, I saw it inside rustc, so I thought it ok.

@RalfJung
Copy link
Member

RalfJung commented Oct 9, 2025 via email

Comment on lines +216 to +217
/// A union aggregate value.
Union(FieldIdx, VnIndex),
Copy link
Member

Choose a reason for hiding this comment

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

cc @saethlin -- I wonder if you can use this to solve your uninit-array problem now that GVN tracks unions?

Copy link
Member

Choose a reason for hiding this comment

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

Yes. Working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-mir-opt Area: MIR optimizations A-mir-opt-GVN Area: MIR opt Global Value Numbering (GVN) 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.

9 participants