codegen: handle OperandValue::Uninit in codegen_return_terminator#159825
Open
glandium wants to merge 1 commit into
Open
codegen: handle OperandValue::Uninit in codegen_return_terminator#159825glandium wants to merge 1 commit into
glandium wants to merge 1 commit into
Conversation
Collaborator
|
r? @tiif rustbot has assigned @tiif. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
Contributor
Author
|
r? @oli-obk |
This comment has been minimized.
This comment has been minimized.
When adding `OperandValue::Uninit` to skip stores for entirely-uninit constants, we missed the `PassMode::Direct | PassMode::Pair` branch of `codegen_return_terminator`, which called `immediate_or_packed_pair` unconditionally. A function directly returning an all-uninit value (e.g. `MaybeUninit::uninit()`) would hit that branch and ICE in `OperandRef::immediate`, as reported against tokio and reduced by tmiasko.
tmiasko
reviewed
Jul 24, 2026
| pub fn f() -> MaybeUninit<*const ()> { | ||
| // CHECK: start: | ||
| // CHECK-NEXT: ret ptr undef | ||
| MaybeUninit::uninit() |
Contributor
There was a problem hiding this comment.
nit: const { MaybeUninit::uninit() } would avoid dependency on MIR optimizations, i.e., compile-flags: -Copt-level=2
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 #159815.
#157797 added
OperandValue::Uninitto skip stores for entirely-uninit constants, but missed thePassMode::Direct | PassMode::Pairbranch ofcodegen_return_terminator, which calledimmediate_or_packed_pairunconditionally. A function directly returning an all-uninit value (e.g.MaybeUninit::uninit()) would hit that branch and ICE inOperandRef::immediate, as reported against tokio and reduced by tmiasko.