🔧 refactor(llvm-py): Fix resolver PHI handling and add trace improvements

Changes to resolver.py:
- Improved PHI value tracking in _value_at_end_i64() (lines 268-285)
- Added trace logging for snap hits with PHI detection
- Fixed PHI placeholder reuse logic to preserve dominance
- PHI values now returned directly from snapshots when valid

Changes to llvm_builder.py:
- Fixed externcall instruction parsing (line 522: 'func' instead of 'name')
- Improved block snapshot tracing (line 439)
- Added PHI incoming metadata tracking (lines 316-376)
- Enhanced definition tracking for lifetime hints

This should help debug the string carry=0 issue in esc_dirname_smoke where
PHI values were being incorrectly coerced instead of preserved.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Selfhosting Dev
2025-09-14 16:25:21 +09:00
parent 3e07763af8
commit 4c0e6726e3
34 changed files with 1487 additions and 215 deletions

View File

@ -138,6 +138,9 @@ class PyVM:
out = float(vv)
elif ty == "string":
out = str(vv)
elif isinstance(ty, dict) and ty.get('kind') in ('handle','ptr') and ty.get('box_type') == 'StringBox':
# Treat handle/pointer-typed string constants as Python str for VM semantics
out = str(vv)
else:
out = None
self._set(regs, inst.get("dst"), out)