Files
rust/compiler/rustc_codegen_ssa
Jonathan Brouwer 2818434167 Rollup merge of #163931 - joshtriplett:mir-loop-hint-attrs-in-goto, r=saethlin
Move `loop_hint_attrs` from `Terminator` into `TerminatorKind::Goto`

Only the `Goto` variant uses `loop_hint_attrs`, so other variants shouldn't pay the cost. This shrinks `Terminator` and thus `BasicBlockData` by 8 bytes, and also simplifies many users of `Terminator`.

Every byte saved from `BasicBlockData` makes a big difference in max-rss. For aws-sdk-ec2 full check, this saves 34.1 MiB (~0.62% of its peak RSS)

Add a `TerminatorKind::goto` helper function for convenient construction with a target and no hints. With that helper available, most of this commit is simple, straightforward, mechanical translations of construction or pattern matching. The only notable changes are:

- `compiler/rustc_codegen_ssa/src/mir/block.rs` actually uses the moved hints.
- `compiler/rustc_middle/src/mir/mod.rs` updates the size assertions.
- `compiler/rustc_mir_build/src/builder/cfg.rs` adds/updates helpers.
- `compiler/rustc_mir_build/src/builder/expr/into.rs` has the one place that creates a `Goto` with non-empty hints.

---

I have several more potential improvements to basic block sizes, but this one was an easy starting point.
2026-10-08 08:55:37 +02:00
..
…

Please read the rustc-dev-guide chapter on Backend Agnostic Codegen.