Treat union fields as aliasing each other in value_analysis - #163425
Open
ojuschugh1 wants to merge 1 commit into
Open
ojuschugh1 wants to merge 1 commit into
ojuschugh1 wants to merge 1 commit into
Conversation
Collaborator
|
Thanks for the pull request, and welcome! The Rust Project has assigned @dingxiangfei2009 (or someone else) to review your changes, you should hear from them (or someone else) within the next two weeks. Please see the contribution instructions and our LLM policy for more information. Why was this reviewer chosen?The reviewer was selected based on:
|
Author
|
Hey @TaKO8Ki @dingxiangfei2009 could you kindly review this PR? Thanks |
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.
Fixes #161898
The problem was that
for_each_aliasing_placeonly considered enum variants and the discriminant as aliasing, so writing to one union field left the state of the other fields alone. JumpThreading then threaded the secondswitchIntonu.ausing the value from beforeu.b = 5, and DataflowConstProp folded the read ofu.ato a stale constant in the same way. Union field places have only been in the map since #127087 began collecting places syntactically; before thatiter_fieldsskipped unions.I made
for_each_aliasing_placeflood everything under a union as soon as the walk reaches it, since all non-ZST union fields start at offset 0 and overlap. The alternative of not registering places below unions would also work but loses threading on union reads with no write in between.Added a mir-opt test for each pass.