Repository navigation
Move loop_hint_attrs from Terminator into TerminatorKind::Goto - #163931
Conversation
This will make it easier to move them in a subsequent commit, since `UnrollAttr` implements `PartialEq`. If, in the future, we add more kinds of loop hints, this can become a small enum wrapping only those attr types.
|
Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri This PR changes MIR cc @oli-obk, @RalfJung, @JakobDegen, @vakaras Some changes occurred in coverage instrumentation. cc @Zalathar
cc @bjorn3 Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred to the CTFE machinery This PR changes rustc_public |
|
r? @TaKO8Ki rustbot has assigned @TaKO8Ki. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
…try> Move `loop_hint_attrs` from `Terminator` into `TerminatorKind::Goto`
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (e5d77f0): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking means the PR may be perf-sensitive. Consider adding rollup=never if this change is not fit for rolling up. @rustbot label: -S-waiting-on-perf -perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (secondary -1.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -1.5%, secondary -0.9%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary -0.1%, secondary -0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 489.893s -> 486.175s (-0.76%) |
|
@saethlin has talked about wanting to add a loop vectorization attribute, I think it's intended to live in I guess my question is: if that change would require undoing basically everything here there's not much point in doing this. |
|
I was looking into this before as well and left it alone because I expected there's an intent to use it for other attributes later. I really don't like that the array is there, though, I'd merge this even if just for the metadata size reductions. It feels very wasteful to keep a field that is almost always empty for a feature that's almost never used (and actually doesn't even exist atm 😄) |
|
I saw one mention of adding loop vectorization hints, but I would expect those to go on Goto as well. When that happens, I expect the second commit to be largely unchanged, and the first to change from UnrollAttr to LoopHintAttr, an enum containing variants for Unroll and Vectorize. @saethlin, does that sound right? |
35ba562 to
eaf968e
Compare
This comment has been minimized.
This comment has been minimized.
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.
eaf968e to
ec45ecf
Compare
|
Oh yeah I should really get around to adding vectorization hints... Given the difficulty that we have had with name collisions with r? saethlin |
…n-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.
…n-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.
…n-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.
…uwer Rollup of 10 pull requests Successful merges: - #162741 (codegen: tell LLVM that the discriminant is a power of two) - #162758 (Split PassMode::IndirectUnsized out of PassMode::Indirect) - #163931 (Move `loop_hint_attrs` from `Terminator` into `TerminatorKind::Goto`) - #163028 (autodiff: fix sysroot candidates in libEnzyme not found error) - #163538 (Add `rustc::missing_generic_type_visitable` lint) - #163841 ([rustdoc] Fix more `incoherent_impl` linking) - #163908 (Update Enzyme submodule) - #163935 (Use BasicBlock::start_location and Location::START) - #163949 (disable next-solver with higher-ranked-assumptions) - #163951 (relax_elf_relocations is x86-only)
…uwer Rollup of 11 pull requests Successful merges: - #162741 (codegen: tell LLVM that the discriminant is a power of two) - #162758 (Split PassMode::IndirectUnsized out of PassMode::Indirect) - #163931 (Move `loop_hint_attrs` from `Terminator` into `TerminatorKind::Goto`) - #163028 (autodiff: fix sysroot candidates in libEnzyme not found error) - #163257 (abby DSL: sanity checks on forall where clauses) - #163841 ([rustdoc] Fix more `incoherent_impl` linking) - #163908 (Update Enzyme submodule) - #163935 (Use BasicBlock::start_location and Location::START) - #163949 (disable next-solver with higher-ranked-assumptions) - #163951 (relax_elf_relocations is x86-only) - #163968 (Remove needs-triage label from relnotes issues)
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.
…uwer Rollup of 11 pull requests Successful merges: - rust-lang/rust#162741 (codegen: tell LLVM that the discriminant is a power of two) - rust-lang/rust#162758 (Split PassMode::IndirectUnsized out of PassMode::Indirect) - rust-lang/rust#163931 (Move `loop_hint_attrs` from `Terminator` into `TerminatorKind::Goto`) - rust-lang/rust#163028 (autodiff: fix sysroot candidates in libEnzyme not found error) - rust-lang/rust#163257 (abby DSL: sanity checks on forall where clauses) - rust-lang/rust#163841 ([rustdoc] Fix more `incoherent_impl` linking) - rust-lang/rust#163908 (Update Enzyme submodule) - rust-lang/rust#163935 (Use BasicBlock::start_location and Location::START) - rust-lang/rust#163949 (disable next-solver with higher-ranked-assumptions) - rust-lang/rust#163951 (relax_elf_relocations is x86-only) - rust-lang/rust#163968 (Remove needs-triage label from relnotes issues)
- `loop_hint_attrs` moved from `mir::Terminator` into `TerminatorKind::Goto` (rust-lang/rust#163931). - `rustc_abi::Float` gained `PpcF128` (rust-lang/rust#162156), PowerPC's double-double `long double`. It only exists on PowerPC targets, which Kani doesn't support, so report it as unsupported like `F16B`. - rustc's diagnostic for `ui/ice-size-overflow` now also prints the enclosing `SizedTypeProperties` trait line; update the expected output.
Only the
Gotovariant usesloop_hint_attrs, so other variants shouldn't pay the cost. This shrinksTerminatorand thusBasicBlockDataby 8 bytes, and also simplifies many users ofTerminator.Every byte saved from
BasicBlockDatamakes 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::gotohelper 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.rsactually uses the moved hints.compiler/rustc_middle/src/mir/mod.rsupdates the size assertions.compiler/rustc_mir_build/src/builder/cfg.rsadds/updates helpers.compiler/rustc_mir_build/src/builder/expr/into.rshas the one place that creates aGotowith non-empty hints.I have several more potential improvements to basic block sizes, but this one was an easy starting point.