Allow enum and union literals to also create SSA values#138759
Merged
bors merged 2 commits intorust-lang:masterfrom Jul 5, 2025
Merged
Allow enum and union literals to also create SSA values#138759bors merged 2 commits intorust-lang:masterfrom
enum and union literals to also create SSA values#138759bors merged 2 commits intorust-lang:masterfrom
Conversation
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.
Today,
Some(x)always goes through analloca, even in trivial cases where the niching means the constructor doesn't even change the value.For example, https://rust.godbolt.org/z/6KG6PqoYz
currently emits the IR
but with this PR it becomes just
(Of course the optimizer can clean that up, but it'd be nice if it didn't have to -- especially in debug where it doesn't run. This is like #123886, but that only handled non-simd
structs -- this PR generalizes it to all non-simd ADTs.)Doing this means handing variants other than
FIRST_VARIANT, handling the active field for unions, refactoring the discriminant code so the Place and Operand parts can share the calculation, etc.Other PRs that led up to this one:
tag_fieldtoFieldIdxinVariants::Multiple#142005InterpCx::project_fieldto takeFieldIdx#142103FunctionCxfrom some codegen methods #142324try-job: aarch64-gnu