Files
rust/compiler/rustc_codegen_ssa
Jacob Pratt 447d1efe4a Rollup merge of #163567 - BorrowSanitizer:codegen-retag-fix-loop, r=saethlin
Use a loop to avoid emitting long sequences of retags.

See MCP [#958](https://github.com/rust-lang/compiler-team/issues/958) for context on `-Zcodegen-emit-retag`.

If we need to retag an array of references, then we will retag every element of the array. This does not scale for large arrays. For example:
```rust
const N: usize = 100_000;

fn example(array: [&u32; N]) {}

fn main() {
    example([&0; N]);
}
```
This program will cause `rustc` to hang at `-O0` with `-Zcodegen-emit-retag`. In the body of `example`, we need to ensure that every element of `array` receives a function-entry retag, so we emit 100,000 retag function calls within a single basic block!

This PR fixes this issue by adjusting how we retag the contents of arrays. Instead of retagging ever element in succession, we emit a loop that applies a single retag call to every element of the array. I have tested it on BorrowSanitizer's test suite.

Also, I saw the new `#FIXME` comment about supporting `repr(simd)` types. Some of the changes that I made here will be helpful for fixing that issue in a subsequent PR.

cc: @mojeanmac
r? @saethlin
2026-10-04 23:46:31 -04:00
..
…

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