From df6921384938a1dc0b979396642b56eb117cc7fe Mon Sep 17 00:00:00 2001 From: pjh456 <147148383@qq.com> Date: Fri, 7 Aug 2026 17:40:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20builtin=20=E6=A7=BD=20vreg=20=E9=A2=84?= =?UTF-8?q?=E7=9D=80=E8=89=B2=E6=81=92=E7=AD=89=E6=8E=92=E9=99=A4=E5=87=BA?= =?UTF-8?q?=E5=8F=AF=E5=88=86=E9=85=8D=E9=9B=86=E9=98=B2=20prologue=20?= =?UTF-8?q?=E8=A6=86=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/oxide_regalloc/src/graph.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/crates/oxide_regalloc/src/graph.rs b/crates/oxide_regalloc/src/graph.rs index 8cb8829b..41335ead 100644 --- a/crates/oxide_regalloc/src/graph.rs +++ b/crates/oxide_regalloc/src/graph.rs @@ -101,6 +101,19 @@ pub(super) fn build( // 自己的 vreg 参与染色而移走 → 子模块读错物理槽。分界线 = param_layout.base // (emit 的 inherited_reg_start 继承机制:子模块 vreg ≥ base,父槽引用 < base)。 collect_own_escaped(f, &mut pre_colors, &mut escaped_colors); + // builtin 槽:VM 帧推入时写 regs[slot]=全局值(无指令 def 却活到入口), + // 物理号必须恒等并排除出可分配集。否则 prologue 死定义临时(如解构 + // FOR_OF_DONE 结果)与它同色,在 builtin use 前执行写入 → 覆写全局值 + // (B021:解构参数后 builtin 调用读到 false/undefined)。 + for (_, reg) in &f.builtin_reg_map { + let v = *reg; + if real.contains(&v) { + pre_colors.entry(v).or_insert(v); + if !escaped_colors.contains(&v) { + escaped_colors.push(v); + } + } + } // ── 可分配色集 ── let max_nargs = f