docs(llvm/vm): 静的Box(self)規約を明文化 + Bridgeトグル追記; Gate‑C/Core 現状反映; CURRENT_TASK 更新。\n\n- 新規: docs/development/architecture/llvm/static_box_singleton.md\n- 追記: lang/src/vm/README.md に self 先頭規約/互換トグルを明記\n- 追記: CURRENT_TASK に本更新を記録\n- phase-20.33/CHECKLIST にドキュメント完了チェックを追加\n- bak フォルダはリポジトリ直下に存在せず(削除対象なし)\n\n併せて未コミット差分をスナップショット(Rust 層の前作業含む)
This commit is contained in:
@ -40,6 +40,14 @@ pub trait LoopPhiOps {
|
||||
fn update_var(&mut self, name: String, value: ValueId);
|
||||
fn get_variable_at_block(&mut self, name: &str, block: BasicBlockId) -> Option<ValueId>;
|
||||
fn debug_verify_phi_inputs(&mut self, _merge_bb: BasicBlockId, _inputs: &[(BasicBlockId, ValueId)]) {}
|
||||
|
||||
/// PHI UseBeforeDef修正: preheaderブロックでCopy命令を先行生成
|
||||
fn emit_copy_at_preheader(
|
||||
&mut self,
|
||||
preheader_id: BasicBlockId,
|
||||
dst: ValueId,
|
||||
src: ValueId,
|
||||
) -> Result<(), String>;
|
||||
}
|
||||
|
||||
/// Finalize PHIs at loop exit (merge of break points and header fall-through).
|
||||
@ -130,15 +138,31 @@ pub fn prepare_loop_variables_with<O: LoopPhiOps>(
|
||||
preheader_id: BasicBlockId,
|
||||
current_vars: &std::collections::HashMap<String, ValueId>,
|
||||
) -> Result<Vec<IncompletePhi>, String> {
|
||||
// 🎯 修正: current_varsをpreheader時点の値のみに限定(header blockで定義された値を除外)
|
||||
// これにより、UseBeforeDef(PHI inputsにheader内で定義された値が含まれる)を防ぐ
|
||||
|
||||
let mut incomplete_phis: Vec<IncompletePhi> = Vec::new();
|
||||
for (var_name, &value_before) in current_vars.iter() {
|
||||
// Skip pinned variables (internal compiler temporaries)
|
||||
if var_name.starts_with("__pin$") {
|
||||
// Pinned variables are materialized via entry-phi in loop body, skip here
|
||||
continue;
|
||||
}
|
||||
|
||||
// Materialize the incoming value at preheader to satisfy UseBeforeDef constraints
|
||||
// even when `value_before` was defined in a different block (e.g., previous loop header).
|
||||
let pre_copy = ops.new_value();
|
||||
ops.emit_copy_at_preheader(preheader_id, pre_copy, value_before)?;
|
||||
|
||||
let phi_id = ops.new_value();
|
||||
let inc = IncompletePhi {
|
||||
phi_id,
|
||||
var_name: var_name.clone(),
|
||||
known_inputs: vec![(preheader_id, value_before)],
|
||||
known_inputs: vec![(preheader_id, pre_copy)], // ensure def at preheader
|
||||
};
|
||||
incomplete_phis.push(inc);
|
||||
// 変数マップを即座に更新して、条件式評価時にPHI IDを使用する
|
||||
// これにより、DCEがPHI命令を削除することを防ぐ
|
||||
ops.update_var(var_name.clone(), phi_id);
|
||||
}
|
||||
Ok(incomplete_phis)
|
||||
|
||||
Reference in New Issue
Block a user