Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only visit reachable nodes in SsaLocals. #116239

Merged
merged 2 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
WaffleLapkin marked this conversation as resolved.
Show resolved Hide resolved
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() };
}
Loading