feat(llvm): Phase 131-11-H/12 - ループキャリアPHI型修正 & vmap snapshot SSOT
## Phase 131-11-H: ループキャリアPHI型修正 - PHI生成時に初期値(entry block)の型のみ使用 - backedge の値を型推論に使わない(循環依存回避) - NYASH_CARRIER_PHI_DEBUG=1 でトレース ## Phase 131-12-P0: def_blocks 登録 & STRICT エラー化 - safe_vmap_write() で PHI 上書き保護 - resolver miss を STRICT でエラー化(フォールバック 0 禁止) - def_blocks 自動登録 ## Phase 131-12-P1: vmap_cur スナップショット実装 - DeferredTerminator 構造体(block, term_ops, vmap_snapshot) - Pass A で vmap_cur をスナップショット - Pass C でスナップショット復元(try-finally) - STRICT モード assert ## 結果 - ✅ MIR PHI型: Integer(正しい) - ✅ VM: Result: 3 - ✅ vmap snapshot 機構: 動作確認 - ⚠️ LLVM: Result: 0(別のバグ、次Phase で調査) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -1,61 +1,48 @@
|
||||
# 調査ログ・根本原因分析
|
||||
# Investigations Folder
|
||||
|
||||
このフォルダは、バグ修正・最適化の過程で発見した根本原因分析・調査プロセスを保管します。
|
||||
This folder contains investigation notes and analysis for debugging sessions.
|
||||
|
||||
## 参照方法
|
||||
## Active Investigations
|
||||
|
||||
1. **「このバグの根本原因は?」** → investigations/ で検索
|
||||
2. **「この設計決定の背景は?」** → [../20-Decisions.md](../20-Decisions.md) で確認
|
||||
3. **「実装の詳細は?」** → [../phases/](../phases/README.md) で確認
|
||||
### Phase 131-12: LLVM Wrong Result (Case C)
|
||||
|
||||
## 命名規則
|
||||
**Status**: ✅ Root cause identified
|
||||
**Problem**: LLVM backend returns wrong results for loop exit values
|
||||
**Root Cause**: vmap object identity mismatch between Pass A and Pass C
|
||||
|
||||
- **形式**: `<topic>-investigation-YYYY-MM-DD.md` または `<topic>-root-cause-analysis.md`
|
||||
- **目的**: 時系列が分かる形、または主題ごとに整理
|
||||
**Key Documents**:
|
||||
1. [phase131-12-case-c-llvm-wrong-result.md](phase131-12-case-c-llvm-wrong-result.md) - Initial investigation scope
|
||||
2. [phase131-12-p1-vmap-identity-analysis.md](phase131-12-p1-vmap-identity-analysis.md) - Detailed trace analysis
|
||||
3. [phase131-12-p1-trace-summary.md](phase131-12-p1-trace-summary.md) - Executive summary with fix recommendations
|
||||
|
||||
## 最新調査
|
||||
**Quick Summary**:
|
||||
- **Bug**: Pass A deletes `_current_vmap` before Pass C runs
|
||||
- **Impact**: Terminators use wrong vmap object, missing all Pass A writes
|
||||
- **Fix**: Store vmap_cur in deferred_terminators tuple (Option 3)
|
||||
|
||||
- `python-resolver-investigation.md` - Python LLVM バックエンド resolver.is_stringish() 調査
|
||||
- `phase131-11-root-cause-analysis.md` - PHI 型推論循環依存分析
|
||||
**Next Steps**:
|
||||
1. Implement Option 3 fix in block_lower.py
|
||||
2. Add Fail-Fast check in instruction_lower.py
|
||||
3. Verify with NYASH_LLVM_VMAP_TRACE=1
|
||||
4. Run full test suite
|
||||
|
||||
## 作成ルール(SSOT)
|
||||
## Trace Environment Variables
|
||||
|
||||
詳しくは [../DOCS_LAYOUT.md](../DOCS_LAYOUT.md) を参照。
|
||||
|
||||
- ✅ **置き場所**: `investigations/` 配下のみ
|
||||
- ✅ **内容**: 詳細な根本原因分析、デバッグプロセス、試行錯誤の記録
|
||||
- ✅ **結論反映**: 調査結果の結論は以下に反映
|
||||
- [../10-Now.md](../10-Now.md) - 現在の進行状況サマリー
|
||||
- [../20-Decisions.md](../20-Decisions.md) - 設計決定記録
|
||||
- [../design/](../design/README.md) - アーキテクチャ設計書(必要な場合)
|
||||
- ❌ **避けるべき**: 調査ログそのものを SSOT にしない
|
||||
|
||||
## 使用例
|
||||
|
||||
### 調査ログ作成時
|
||||
```markdown
|
||||
# Python LLVM バックエンド resolver.is_stringish() 調査
|
||||
|
||||
**日時**: 2025-12-14
|
||||
**担当**: taskちゃん
|
||||
**目的**: Case C で Result: 0 が出力される原因特定
|
||||
|
||||
## 調査フロー
|
||||
1. ...
|
||||
2. ...
|
||||
|
||||
## 根本原因
|
||||
### Phase 131-12-P1 Traces
|
||||
```bash
|
||||
NYASH_LLVM_VMAP_TRACE=1 # Object identity and vmap keys tracing
|
||||
NYASH_LLVM_USE_HARNESS=1 # Enable llvmlite harness
|
||||
NYASH_LLVM_DUMP_IR=<path> # Save LLVM IR to file
|
||||
```
|
||||
|
||||
### 結論反映時(10-Now.md)
|
||||
```markdown
|
||||
## 🔍 Phase 131-11-E: TypeFacts/TypeDemands 分離
|
||||
## Investigation Workflow
|
||||
|
||||
**根本原因**: MIR Builder の後方伝播型推論
|
||||
- **詳細**: [investigations/python-resolver-investigation.md](investigations/python-resolver-investigation.md)
|
||||
- **修正**: PhiTypeResolver が TypeFacts のみ参照
|
||||
```
|
||||
1. **Scope** - Define problem and test case (phase131-12-case-c-*.md)
|
||||
2. **Trace** - Add instrumentation and collect data (phase131-12-p1-vmap-identity-*.md)
|
||||
3. **Analysis** - Identify root cause with evidence (phase131-12-p1-trace-summary.md)
|
||||
4. **Fix** - Implement solution with validation
|
||||
5. **Document** - Update investigation notes with results
|
||||
|
||||
---
|
||||
## Archive
|
||||
|
||||
**最終更新**: 2025-12-14
|
||||
Completed investigations are kept for reference and pattern recognition.
|
||||
|
||||
Reference in New Issue
Block a user