Files
hakorune/src/mir/builder/origin/phi.rs
nyash-codex dda65b94b7 Phase 21.7 normalization: optimization pre-work + bench harness expansion
- Add opt-in optimizations (defaults OFF)
  - Ret purity verifier: NYASH_VERIFY_RET_PURITY=1
  - strlen FAST enhancement for const handles
  - FAST_INT gate for same-BB SSA optimization
  - length cache for string literals in llvmlite
- Expand bench harness (tools/perf/microbench.sh)
  - Add branch/call/stringchain/arraymap/chip8/kilo cases
  - Auto-calculate ratio vs C reference
  - Document in benchmarks/README.md
- Compiler health improvements
  - Unify PHI insertion to insert_phi_at_head()
  - Add NYASH_LLVM_SKIP_BUILD=1 for build reuse
- Runtime & safety enhancements
  - Clarify Rust/Hako ownership boundaries
  - Strengthen receiver localization (LocalSSA/pin/after-PHIs)
  - Stop excessive PluginInvoke→BoxCall rewrites
- Update CURRENT_TASK.md, docs, and canaries

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-13 16:40:58 +09:00

39 lines
1.5 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

use super::super::{MirBuilder, MirType, ValueId, BasicBlockId};
/// Lightweight propagation at PHI when all inputs agree型/起源)。
/// 仕様は不変: 一致時のみ dst にコピーする(不一致/未知は何もしない)。
pub(crate) fn propagate_phi_meta(
builder: &mut MirBuilder,
dst: ValueId,
inputs: &Vec<(BasicBlockId, ValueId)>,
) {
// Type一致のときだけコピー
let mut common_ty: Option<MirType> = None;
let mut ty_agree = true;
for (_bb, v) in inputs.iter() {
if let Some(t) = builder.value_types.get(v).cloned() {
match &common_ty {
None => common_ty = Some(t),
Some(ct) => {
if ct != &t { ty_agree = false; break; }
}
}
} else { ty_agree = false; break; }
}
if ty_agree {
if let Some(ct) = common_ty { builder.value_types.insert(dst, ct); }
}
// Origin一致のときだけコピー
let mut common_cls: Option<String> = None;
let mut cls_agree = true;
for (_bb, v) in inputs.iter() {
if let Some(c) = builder.value_origin_newbox.get(v).cloned() {
match &common_cls {
None => common_cls = Some(c),
Some(cc) => { if cc != &c { cls_agree = false; break; } }
}
} else { cls_agree = false; break; }
}
if cls_agree { if let Some(cc) = common_cls { builder.value_origin_newbox.insert(dst, cc); } }
}