Skip to content

codegen: handle OperandValue::Uninit in codegen_return_terminator#159825

Open
glandium wants to merge 1 commit into
rust-lang:mainfrom
glandium:issue159815
Open

codegen: handle OperandValue::Uninit in codegen_return_terminator#159825
glandium wants to merge 1 commit into
rust-lang:mainfrom
glandium:issue159815

Conversation

@glandium

@glandium glandium commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #159815.

#157797 added OperandValue::Uninit to skip stores for entirely-uninit constants, but 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.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 24, 2026
@rustbot

rustbot commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

r? @tiif

rustbot has assigned @tiif.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 74 candidates
  • Random selection from 18 candidates

@rustbot

This comment has been minimized.

@glandium

Copy link
Copy Markdown
Contributor Author

r? @oli-obk

@rustbot rustbot assigned oli-obk and unassigned tiif Jul 24, 2026
@rustbot

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.
pub fn f() -> MaybeUninit<*const ()> {
// CHECK: start:
// CHECK-NEXT: ret ptr undef
MaybeUninit::uninit()

@tmiasko tmiasko Jul 24, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: const { MaybeUninit::uninit() } would avoid dependency on MIR optimizations, i.e., compile-flags: -Copt-level=2

View changes since the review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ICE]: thread 'rustc' (2584) panicked at ... compiler/rustc_codegen_ssa/src/mir/operand.rs:291:18:

5 participants