feat: topic17 v1.3 regression allocator optimization + scenario analysis + docs - #37
Conversation
🤖 AI Code Review
📁
|
Address verified bugs from PR ScratchV-Compiler#37 AI review: - rename regalloc_linear_v1.3.py -> regalloc_linear_v1_3.py (importable) - fix self-spill clobbering phys_regs[0] (evict farthest instead) - fix _evict_for_reload leaking vregs (SPILL_ demotion, not del rename) - remove redundant define+use branch in compute_live_intervals - hoist machine_types import to module level - rewrite scenario runner for v1.3 dict spill_code API + unique-inst ids Verified: 23/23 scenarios pass (no leak, no reg conflict), 18 unit tests pass.
基于 PR ScratchV-Compiler#37 AI 代码审查再核对, 修复 v1.3.1 未覆盖的真实问题: 分配器 (regalloc_linear_v1_4.py): - Fix 7: 重定义写回路径补全. spilled vreg 被纯重定义或同一 vreg 多次重定义时, 新值未写回栈 (redefine 判据由 rename[d] 前缀改为 d in self._spilled), 后续 reload 读到栈上旧值. - Fix 8: _pick_scratch 增加 busy 参数, 避开同指令内 reload 寄存器冲突. - Fix 9: _evict_for_reload 回退改为复用同指令 reload 寄存器, 不再 静默覆盖存活寄存器. 场景 (topic17_bottleneck_scenarios_v1.4.py): - Fix 10: A01/A02/A03/D01/E03 多源 add 非法指令重构为合法累加链. - Fix 11: D04 螺旋交织 use-before-def 非法输入修复 (99 处), 消除 SPILL_vXX 泄漏进汇编. 文档: 新建 topic17_v1.4开发文档/设计文档, 同步整理 v1.4 修复清单. 验证: 23 场景全通过 (redund D04=1/F04=644 与基线一致), 语义仿真 A-F 全 0 错误, pytest 342 passed (2 失败为 tinyfive 环境无关问题).
Summary
topic17 v1.3 回归分配器优化 + 瓶颈场景分析 + 文档
Changes
Test Plan
Closes #