diff options
| author | bors <bors@rust-lang.org> | 2024-04-11 11:21:44 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-04-11 11:21:44 +0000 |
| commit | 62cffeedcf353d8d5bd78cff9898c3def3e3cb84 (patch) | |
| tree | 70b732be5a22d9be6adf7a4a83fb1ab3b1c0efcc /compiler/rustc_codegen_cranelift/src/base.rs | |
| parent | 241fc135fc706cb8adf487b288d7944f5faeb084 (diff) | |
| parent | 2ab4334a9601ecb2e47fe5a90ec985fe745a2a23 (diff) | |
Auto merge of #123785 - bjorn3:sync_cg_clif-2024-04-11, r=bjorn3
Subtree sync for rustc_codegen_cranelift This fixes an ICE for unreachable blocks. r? `@ghost` `@rustbot` label +A-codegen +A-cranelift +T-compiler
Diffstat (limited to 'compiler/rustc_codegen_cranelift/src/base.rs')
| -rw-r--r-- | compiler/rustc_codegen_cranelift/src/base.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs index 771e5b21958..f07421431da 100644 --- a/compiler/rustc_codegen_cranelift/src/base.rs +++ b/compiler/rustc_codegen_cranelift/src/base.rs @@ -267,10 +267,19 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) { .generic_activity("codegen prelude") .run(|| crate::abi::codegen_fn_prelude(fx, start_block)); - for (bb, bb_data) in traversal::mono_reachable(fx.mir, fx.tcx, fx.instance) { + let reachable_blocks = traversal::mono_reachable_as_bitset(fx.mir, fx.tcx, fx.instance); + + for (bb, bb_data) in fx.mir.basic_blocks.iter_enumerated() { let block = fx.get_block(bb); fx.bcx.switch_to_block(block); + if !reachable_blocks.contains(bb) { + // We want to skip this block, because it's not reachable. But we still create + // the block so terminators in other blocks can reference it. + fx.bcx.ins().trap(TrapCode::UnreachableCodeReached); + continue; + } + if bb_data.is_cleanup { // Unwinding after panicking is not supported continue; |
