From 63cec1d4485a5381981d83b3cac80c0cb8e36d26 Mon Sep 17 00:00:00 2001 From: pjh456 <147148383@qq.com> Date: Thu, 6 Aug 2026 12:16:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=97=A0=E6=9D=A1=E4=BB=B6=20JMP=20?= =?UTF-8?q?=E5=90=8E=E7=BB=A7=E4=BD=8D=E7=BD=AE=E5=88=87=E6=88=90=E5=9D=97?= =?UTF-8?q?=E5=A4=B4=EF=BC=8C=E4=BF=AE=E5=A4=8D=E8=B7=B3=E8=BD=AC=E8=BE=B9?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pass 1 仅对条件跳转切 fallthrough 后继,无条件 JMP 与其后指令 融块导致块尾判定错、Jump 边丢失,DCE 可达性误删 break 出口块 (label 悬空报 'Label not found')。JMP 后继同样置块头。 --- crates/oxide_cfg/src/partition.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/oxide_cfg/src/partition.rs b/crates/oxide_cfg/src/partition.rs index 70798578..b2c3be72 100644 --- a/crates/oxide_cfg/src/partition.rs +++ b/crates/oxide_cfg/src/partition.rs @@ -22,8 +22,13 @@ pub(super) fn partition_blocks(f: &IRFunction) -> Vec { None => debug_assert!(false, "unresolved label {l}"), } } - // 条件跳转的 fallthrough 后继是块头(否则 cond+then 融块、条件边丢失)。 - if matches!(inst.op, OpCode::JMP_IF_TRUE | OpCode::JMP_IF_FALSE | OpCode::JMP_IF_NULLISH) { + // 跳转的 fallthrough 后继是块头:条件跳转否则 cond+then 融块、条件边丢失; + // 无条件 JMP 同样必须切块头——JMP 不 fallthrough,但其后继位置需成块边界, + // 否则 JMP 与后续指令融块、块尾判定错、Jump 边丢失(DCE 可达性误删目标块)。 + if matches!( + inst.op, + OpCode::JMP | OpCode::JMP_IF_TRUE | OpCode::JMP_IF_FALSE | OpCode::JMP_IF_NULLISH + ) { heads[i + 1] = true; } }