Skip to content

Make terminator not optional in BasicBlockData - #166248

Merged
rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
panstromek:remove-option-terminator
Nov 26, 2026
Merged

rust-bors[bot] merged 3 commits into
rust-lang:mainfrom
panstromek:remove-option-terminator

Conversation

@panstromek

@panstromek panstromek commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

This is the final PR for changing Option<Terminator> to Terminator in BasicBlockData. More info in this thread.

At this point there should never be a case where the terminator is None. All usages of None were replaced in preceding PR. This PR should practically be a no-op.

First 2 commits remove dead code, the final commit replaces the Option. This PR does try to do only minimal necessary changes to avoid conflicts - i.e. we don't remove terminator() and terminator_mut() methods or any other cleanups.

This should be reviewable commit by commit. For some changes that are just removing ifs, it's useful to hide whitespace changes.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue. labels Nov 20, 2026
@panstromek

Copy link
Copy Markdown
Contributor Author

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@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 Nov 20, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 20, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-bors

rust-bors Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 0a666e4 (0a666e4aea703a8e0818ac892e742ed40e27042b)
Base parent: ec65cd5 (ec65cd52bba13d491ff65c9d218b39753755c84a)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown

Finished benchmarking commit (0a666e4): 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 rustc-perf
@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.9% [0.8%, 0.9%] 6
Improvements ✅
(primary)
-0.3% [-0.4%, -0.2%] 13
Improvements ✅
(secondary)
-0.3% [-0.4%, -0.0%] 22
All ❌✅ (primary) -0.3% [-0.4%, -0.2%] 13

Max RSS (memory usage)

Results (primary 1.9%, secondary 1.3%)

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

mean range count
Regressions ❌
(primary)
1.9% [1.1%, 2.4%] 3
Regressions ❌
(secondary)
2.0% [0.4%, 4.2%] 6
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.3% [-3.3%, -3.3%] 1
All ❌✅ (primary) 1.9% [1.1%, 2.4%] 3

Cycles

Results (secondary 1.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)
1.5% [1.1%, 2.7%] 7
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.7% [-0.7%, -0.7%] 1
All ❌✅ (primary) - - 0

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 459.547s -> 486.251s (5.81%)
Artifact size: 405.37 MiB -> 405.44 MiB (0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Nov 20, 2026
@panstromek

panstromek commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor Author

the next-solver-stress regression looks like noise, it's entirely in <rustc_hir_typeck::fn_ctxt::FnCtxt>::coerce, which runs before we ever get to MIR.

@panstromek
panstromek force-pushed the remove-option-terminator branch from 221796e to ff96bcd Compare November 20, 2026 17:15
@rust-bors

This comment has been minimized.

@panstromek
panstromek force-pushed the remove-option-terminator branch from ff96bcd to ea93526 Compare November 25, 2026 19:06
This is dead code now, because terminator is never None. The ice is now triggered sooner in the unwrap in `into_basic_blocks`.
This commit only makes the necessary changes. We don't remove terminator() or terminator_mut() methods to avoid too many changes at once and avoid conflicts.
@panstromek
panstromek force-pushed the remove-option-terminator branch from ea93526 to d923f61 Compare November 26, 2026 06:34
@panstromek panstromek changed the title Remove Option from terminator Make terminator not optional in BasicBlockData Nov 26, 2026
@panstromek
panstromek marked this pull request as ready for review November 26, 2026 06:38
@rustbot

rustbot commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

clippy is developed in its own repository. If possible, consider making this change to rust-lang/rust-clippy instead.

cc @rust-lang/clippy

rustc_codegen_gcc is developed in its own repository. If possible, consider making this change to rust-lang/rustc_codegen_gcc instead.

cc @antoyo, @GuillaumeGomez

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 Nov 26, 2026
@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Nov 26, 2026
@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Nov 26, 2026
Make terminator not optional in BasicBlockData
@rust-bors

rust-bors Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: cbf5dae (cbf5daedc56e5833ffa13d299a28240d692f64d7)
Base parent: 6c709eb (6c709eb428d472a3c3d93681c1ba37d44a1c27cf)

@rust-timer

This comment has been minimized.

@oli-obk oli-obk left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

r=me with perf clean or positive

View changes since this review

@oli-obk oli-obk assigned oli-obk and unassigned folkertdev Nov 26, 2026
@rust-timer

Copy link
Copy Markdown

Finished benchmarking commit (cbf5dae): comparison URL.

Overall result: ✅ improvements - no action needed

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.

@bors rollup=never rustc-perf
@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
Improvements ✅
(primary)
-0.3% [-0.4%, -0.1%] 14
Improvements ✅
(secondary)
-0.3% [-1.2%, -0.1%] 28
All ❌✅ (primary) -0.3% [-0.4%, -0.1%] 14

Max RSS (memory usage)

Results (primary 1.0%, secondary -1.3%)

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

mean range count
Regressions ❌
(primary)
1.8% [0.7%, 4.3%] 5
Regressions ❌
(secondary)
2.1% [2.1%, 2.1%] 1
Improvements ✅
(primary)
-2.6% [-2.6%, -2.6%] 1
Improvements ✅
(secondary)
-2.0% [-2.1%, -1.7%] 5
All ❌✅ (primary) 1.0% [-2.6%, 4.3%] 6

Cycles

Results (primary -2.3%, secondary -2.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)
- - 0
Improvements ✅
(primary)
-2.3% [-2.3%, -2.3%] 1
Improvements ✅
(secondary)
-2.9% [-3.5%, -2.2%] 2
All ❌✅ (primary) -2.3% [-2.3%, -2.3%] 1

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 460.462s -> 458.758s (-0.37%)
Artifact size: 405.59 MiB -> 405.61 MiB (0.00%)

@rustbot rustbot removed S-waiting-on-perf Status: Waiting on a perf run to be completed. perf-regression Performance regression. labels Nov 26, 2026
@panstromek

Copy link
Copy Markdown
Contributor Author

Thanks!

@bors r=oli-obk

@rust-bors

rust-bors Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

📌 Commit d923f61 has been approved by oli-obk

It is now in the queue for this repository.

@rust-bors rust-bors Bot 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 Nov 26, 2026
@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors rollup=iffy
perf-sensitive rollup

JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 26, 2026
…r, r=oli-obk

Make terminator not optional in BasicBlockData

This is the final PR for changing `Option<Terminator>` to `Terminator` in `BasicBlockData`. More info in [this thread](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/vibe.20check.20-.20removing.20Option.20from.20Terminator/with/637588808).

At this point there should never be a case where the terminator is `None`. All usages of `None` were replaced in preceding PR. This PR should practically be a no-op.

First 2 commits remove dead code, the final commit replaces the Option. This PR does try to do only minimal necessary changes to avoid conflicts - i.e. we don't remove `terminator()` and `terminator_mut()` methods or any other cleanups.

This should be reviewable commit by commit. For some changes that are just removing ifs, it's useful to hide whitespace changes.
rust-bors Bot pushed a commit that referenced this pull request Nov 26, 2026
…uwer

Rollup of 4 perf-sensitive pull requests

Successful merges:

 - #165489 (Add two extra early return checks to `is_recursive_terminator`)
 - #166248 (Make terminator not optional in BasicBlockData)
 - #166264 (Perf: Improve looking up previously scanned items in dead-code)
 - #166492 (rustc-lint: avoid allocation and Ident reconstruction in find_duplicated_parameters)
@rust-bors
rust-bors Bot merged commit a75a1e2 into rust-lang:main Nov 26, 2026
15 checks passed
@rustbot rustbot added this to the 1.102.0 milestone Nov 26, 2026
rust-bors Bot pushed a commit that referenced this pull request Nov 26, 2026
Rollup merge of #166248 - panstromek:remove-option-terminator, r=oli-obk

Make terminator not optional in BasicBlockData

This is the final PR for changing `Option<Terminator>` to `Terminator` in `BasicBlockData`. More info in [this thread](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/vibe.20check.20-.20removing.20Option.20from.20Terminator/with/637588808).

At this point there should never be a case where the terminator is `None`. All usages of `None` were replaced in preceding PR. This PR should practically be a no-op.

First 2 commits remove dead code, the final commit replaces the Option. This PR does try to do only minimal necessary changes to avoid conflicts - i.e. we don't remove `terminator()` and `terminator_mut()` methods or any other cleanups.

This should be reviewable commit by commit. For some changes that are just removing ifs, it's useful to hide whitespace changes.
@rust-timer

Copy link
Copy Markdown

Note

This PR was benchmarked as part of triage of its containing rollup: triage URL.

Finished benchmarking commit (4efae3c): comparison URL.

Overall result: ✅ 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
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.3% [-0.4%, -0.1%] 14
Improvements ✅
(secondary)
-0.2% [-0.4%, -0.0%] 22
All ❌✅ (primary) -0.3% [-0.4%, -0.1%] 14

Max RSS (memory usage)

Results (secondary 1.6%)

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

Cycles

Results (primary -1.8%, secondary -2.2%)

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

mean range count
Regressions ❌
(primary)
2.0% [2.0%, 2.0%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.2% [-2.8%, -1.2%] 8
Improvements ✅
(secondary)
-2.2% [-2.2%, -2.2%] 1
All ❌✅ (primary) -1.8% [-2.8%, 2.0%] 9

Binary size

This perf run didn't have relevant results for this metric.

Artifact size: 405.62 MiB -> 405.65 MiB (0.01%)

jhpratt added a commit to jhpratt/rust that referenced this pull request Nov 27, 2026
…-cleanups, r=tmiasko

Remove some outdated comments about None terminator

The option was removed in rust-lang#166248, so those comments are no longer relevant.
rust-bors Bot pushed a commit that referenced this pull request Nov 27, 2026
Rollup merge of #166626 - panstromek:terminator-none-comment-cleanups, r=tmiasko

Remove some outdated comments about None terminator

The option was removed in #166248, so those comments are no longer relevant.
mehmettoplu-rs pushed a commit to mehmettoplu-rs/miri that referenced this pull request Nov 27, 2026
…uwer

Rollup of 4 perf-sensitive pull requests

Successful merges:

 - rust-lang/rust#165489 (Add two extra early return checks to `is_recursive_terminator`)
 - rust-lang/rust#166248 (Make terminator not optional in BasicBlockData)
 - rust-lang/rust#166264 (Perf: Improve looking up previously scanned items in dead-code)
 - rust-lang/rust#166492 (rustc-lint: avoid allocation and Ident reconstruction in find_duplicated_parameters)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-clippy Relevant to the Clippy team. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rust-analyzer Relevant to the rust-analyzer team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants