Skip to content

Commit 4f09f80

Browse files
authored
Rollup merge of #116239 - cjgillot:issue-116212, r=WaffleLapkin
Only visit reachable nodes in SsaLocals. Fixes #116212
2 parents 1ed00fe + 3816c15 commit 4f09f80

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

compiler/rustc_mir_transform/src/ssa.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,10 @@ impl SsaLocals {
7878
visitor.assignments[local] = Set1::One(LocationExtended::Arg);
7979
}
8080

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

9187
for var_debug_info in &body.var_debug_info {
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Regression test for issue #116212.
2+
3+
#![feature(never_type)]
4+
5+
use std::mem::MaybeUninit;
6+
7+
struct Foo {
8+
x: u8,
9+
y: !,
10+
}
11+
12+
fn main() {
13+
let foo = unsafe { MaybeUninit::<Foo>::uninit().assume_init() };
14+
}

0 commit comments

Comments
 (0)