Skip to content

Commit

Permalink
Unrolled build for rust-lang#116239
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#116239 - cjgillot:issue-116212, r=WaffleLapkin

Only visit reachable nodes in SsaLocals.

Fixes rust-lang#116212
  • Loading branch information
rust-timer authored Sep 29, 2023
2 parents b8536c1 + 3816c15 commit 191dc88
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
12 changes: 4 additions & 8 deletions compiler/rustc_mir_transform/src/ssa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,10 @@ impl SsaLocals {
visitor.assignments[local] = Set1::One(LocationExtended::Arg);
}

if body.basic_blocks.len() > 2 {
for (bb, data) in traversal::reverse_postorder(body) {
visitor.visit_basic_block_data(bb, data);
}
} else {
for (bb, data) in body.basic_blocks.iter_enumerated() {
visitor.visit_basic_block_data(bb, data);
}
// For SSA assignments, a RPO visit will see the assignment before it sees any use.
// We only visit reachable nodes: computing `dominates` on an unreachable node ICEs.
for (bb, data) in traversal::reverse_postorder(body) {
visitor.visit_basic_block_data(bb, data);
}

for var_debug_info in &body.var_debug_info {
Expand Down
14 changes: 14 additions & 0 deletions tests/mir-opt/ssa_unreachable_116212.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Regression test for issue #116212.

#![feature(never_type)]

use std::mem::MaybeUninit;

struct Foo {
x: u8,
y: !,
}

fn main() {
let foo = unsafe { MaybeUninit::<Foo>::uninit().assume_init() };
}

0 comments on commit 191dc88

Please sign in to comment.