Skip to content

GVN: Don't assume nested shared references are read-only. - #157346

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
dianqk:gvn-nest-ref
Jun 21, 2026
Merged

GVN: Don't assume nested shared references are read-only.#157346
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
dianqk:gvn-nest-ref

Conversation

@dianqk

@dianqkdianqk commented Jun 3, 2026

Copy link
Copy Markdown
Member

Fixes#155884.

#150485 only checks the type, whether it is a reference, which is not enough. The PR extends to other types.

cc @RalfJung@saethlin

r? @cjgillot

@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

@rustbotrustbot 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 Jun 3, 2026
@dianqk

Copy link
Copy Markdown
MemberAuthor

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbotrustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 3, 2026
rust-borsBot pushed a commit that referenced this pull request Jun 3, 2026
 GVN: Don't assume nested shared references are read-only.
@rust-bors

rust-borsBot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 0eeeb18 (0eeeb181f41359e276c1dae9eec938e457300cec, parent: d595fce01043347bf7f80e85b76dcc41b59a3e6e)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (0eeeb18): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@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.

meanrangecount
Regressions ❌
(primary)
0.3%[0.1%, 1.0%]12
Regressions ❌
(secondary)
0.3%[0.0%, 0.5%]36
Improvements ✅
(primary)
-0.3%[-0.3%, -0.2%]12
Improvements ✅
(secondary)
-0.3%[-1.0%, -0.0%]12
All ❌✅ (primary)0.0%[-0.3%, 1.0%]24

Max RSS (memory usage)

Results (primary 3.6%)

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

meanrangecount
Regressions ❌
(primary)
4.9%[1.8%, 10.4%]6
Regressions ❌
(secondary)
--0
Improvements ✅
(primary)
-3.9%[-3.9%, -3.9%]1
Improvements ✅
(secondary)
--0
All ❌✅ (primary)3.6%[-3.9%, 10.4%]7

Cycles

Results (secondary -0.4%)

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

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
7.2%[5.0%, 10.8%]3
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
-3.7%[-6.2%, -2.4%]7
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.

meanrangecount
Regressions ❌
(primary)
0.1%[0.0%, 0.6%]19
Regressions ❌
(secondary)
0.1%[0.0%, 0.6%]16
Improvements ✅
(primary)
-0.4%[-1.1%, -0.1%]8
Improvements ✅
(secondary)
-0.1%[-0.1%, -0.1%]1
All ❌✅ (primary)-0.0%[-1.1%, 0.6%]27

Bootstrap: 509.701s -> 512.229s (0.50%)
Artifact size: 400.67 MiB -> 398.49 MiB (-0.55%)

@rustbotrustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 3, 2026
Comment on lines 837 to 839
// DO NOT reason the pointer value that has references.
// We cannot unify two pointers that dereference same local, because they may
// have different lifetimes.

@RalfJungRalfJungJun 3, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This isn't quite grammatical. Maybe you mean "do not reason about ..."? But even then I'm a bit confused about what the comment is trying to say.

This should definitely mention that nested shared references are not read-only and have a link to the issue.

View changes since the review

// let c: &T = *a;
// ```
if projection_ty.ty.is_ref() {
// Unifying them can violate Stacked Borrows or Tree Borrows.

@RalfJungRalfJungJun 3, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
// Unifying them can violate Stacked Borrows or Tree Borrows.
// Furthermore, unifying them can also violate Stacked Borrows or Tree Borrows.

View changes since the review

@cjgillot

Copy link
Copy Markdown
Contributor

@bors r+

@rust-bors

rust-borsBot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 0abc695 has been approved by cjgillot

It is now in the queue for this repository.

@rust-borsrust-borsBot 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 Jun 21, 2026
@rust-bors

This comment has been minimized.

@rust-borsrust-borsBot added merged-by-bors This PR was explicitly merged by bors. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 21, 2026
@rust-bors

rust-borsBot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

☀️ Test successful - CI
Approved by: cjgillot
Duration: 3h 14m 8s
Pushing 91fe22d to main...

@rust-bors
rust-borsBot merged commit 91fe22d into rust-lang:mainJun 21, 2026
13 checks passed
@rustbotrustbot added this to the 1.98.0 milestone Jun 21, 2026
@github-actions

Copy link
Copy Markdown
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 d29dae8 (parent) -> 91fe22d (this PR)

Test differences

Show 2 test diffs

Stage 1

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

Stage 2

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

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
test-dashboard 91fe22da8084a1c9e993d78d4a56f22ab8396236 --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-x86_64-msvc-alt: 1h 59m -> 2h 44m (+38.0%)
  2. x86_64-msvc-ext3: 1h 37m -> 1h 3m (-35.0%)
  3. x86_64-gnu-gcc: 48m 29s -> 1h 4m (+32.5%)
  4. i686-gnu-1: 1h 42m -> 2h 11m (+27.9%)
  5. x86_64-msvc-1: 1h 59m -> 2h 32m (+27.7%)
  6. x86_64-gnu: 2h 24m -> 1h 45m (-27.2%)
  7. x86_64-gnu-llvm-21-2: 1h 35m -> 1h 11m (-24.9%)
  8. pr-check-2: 28m 58s -> 35m 42s (+23.2%)
  9. dist-riscv64-linux: 1h 13m -> 1h 29m (+21.8%)
  10. aarch64-apple-macos-26: 2h 27m -> 2h 57m (+20.3%)
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
Copy Markdown
Collaborator

Finished benchmarking commit (91fe22d): comparison URL.

Overall result: ❌✅ regressions and improvements - please read:

Our benchmarks found a performance regression caused by this PR.
This might be an actual regression, but it can also be just noise.

Next Steps:

  • If the regression was expected or you think it can be justified,
    please write a comment with sufficient written justification, and add
    @rustbot label: +perf-regression-triaged to it, to mark the regression as triaged.
  • If you think that you know of a way to resolve the regression, try to create
    a new PR with a fix for the regression.
  • If you do not understand the regression or you think that it is just noise,
    you can ask the @rust-lang/wg-compiler-performance working group for help (members of this group
    were already notified of this PR).

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

Instruction count

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

meanrangecount
Regressions ❌
(primary)
0.3%[0.1%, 0.5%]9
Regressions ❌
(secondary)
0.3%[0.1%, 0.4%]11
Improvements ✅
(primary)
-0.3%[-0.4%, -0.2%]10
Improvements ✅
(secondary)
-0.5%[-1.1%, -0.2%]5
All ❌✅ (primary)0.0%[-0.4%, 0.5%]19

Max RSS (memory usage)

Results (primary 0.1%, secondary -0.6%)

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

meanrangecount
Regressions ❌
(primary)
2.3%[2.3%, 2.3%]1
Regressions ❌
(secondary)
--0
Improvements ✅
(primary)
-2.1%[-2.1%, -2.1%]1
Improvements ✅
(secondary)
-0.6%[-0.6%, -0.6%]1
All ❌✅ (primary)0.1%[-2.1%, 2.3%]2

Cycles

Results (primary -1.9%, secondary 3.2%)

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

meanrangecount
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
3.2%[3.2%, 3.2%]1
Improvements ✅
(primary)
-1.9%[-1.9%, -1.9%]1
Improvements ✅
(secondary)
--0
All ❌✅ (primary)-1.9%[-1.9%, -1.9%]1

Binary size

Results (primary 0.2%, secondary 0.0%)

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

meanrangecount
Regressions ❌
(primary)
0.2%[0.0%, 1.9%]17
Regressions ❌
(secondary)
0.1%[0.0%, 0.6%]15
Improvements ✅
(primary)
-0.5%[-0.6%, -0.3%]2
Improvements ✅
(secondary)
-0.4%[-0.4%, -0.4%]3
All ❌✅ (primary)0.2%[-0.6%, 1.9%]19

Bootstrap: 483.058s -> 480.522s (-0.52%)
Artifact size: 391.26 MiB -> 391.37 MiB (0.03%)

@dianqk
dianqk deleted the gvn-nest-ref branch June 22, 2026 09:10
@Mark-SimulacrumMark-Simulacrum added the perf-regression-triaged The performance regression has been triaged. label Jun 30, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-borsThis PR was explicitly merged by bors.perf-regressionPerformance regression.perf-regression-triagedThe performance regression has been triaged.T-compilerRelevant 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.

GVN assumes nested shared references are read-only

6 participants

@dianqk@rustbot@rust-timer@cjgillot@RalfJung@Mark-Simulacrum