refactor(llvm): Phase 131-12-P2 - block_end_values SSOT 化(WIP)

## 実装内容
- get_end_values() API 追加
- _value_at_end_i64() を snapshot-only に変更
- def_blocks 即時更新
- PHI incoming を snapshot から取得

## 発見された問題
- 同一ブロック内の def→use が predecessor snapshot を見てしまう
- これは次フェーズで resolve_cur / resolve_incoming 分離で修正

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-14 21:55:44 +09:00
parent 7dfd6ff1d9
commit eb70dfc5bb
4 changed files with 75 additions and 67 deletions

View File

@ -245,6 +245,12 @@ def lower_blocks(builder, func: ir.Function, block_by_id: Dict[int, Dict[str, An
vmap_cur[dst] = _gval
if dst not in created_ids and dst in vmap_cur:
created_ids.append(dst)
# P0-1.5: Update def_blocks IMMEDIATELY after instruction lowering
# This ensures resolver can detect defined_here for same-block uses
try:
builder.def_blocks.setdefault(dst, set()).add(block_data.get("id", 0))
except Exception:
pass
except Exception:
pass
# Phase 131-4 Pass A: DEFER terminators until after PHI finalization