mirror of
https://github.com/allankoechke/rust.git
synced 2026-11-30 11:05:36 +00:00
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
Please read the rustc-dev-guide chapter on Backend Agnostic Codegen.