Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR picks up where #159245 left off by adding support for retagging
repr(simd)types. On the current nightly, the body of the functionexampleis empty when-Zcodegen-emit-retagis enabled. With these changes, the parameter_valwill receive a function-entry retag.We create a temporary allocation to hold the value. Then, we retag it indirectly, using
__rust_retag_memEarlier in #163567, we switched to emitting retags in a loop. In this PR, I set a lower bound for emitting a loop at 2 retags. Otherwise, looping is just going to increase the amount of IR that we add in the typical case of a small array. This is somewhat arbitrary, so if there's a better choice, then I'm all for it.
This also fixes an issue with retagging enums. If a value has multiple variants and its discriminant is a constant, then we downcast to the corresponding variant instead of branching. We were using the discriminant's value as the variant index.
If we have a constant value
Ref::Mut, then we will end up retagging it asRef::Shrinstead, triggering a false positive frozen write in this program:This PR correctly maps the discriminant to the corresponding variant index. This bug was pointed out to me by an LLM, but all fixes here are human-written :)
This passes BorrowSanitizer's test suite, and we've been using a version of Rust with these changes on our experimental branch for the past few weeks.
r? @saethlin