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:
@ -306,7 +306,15 @@ impl<'a> LoopBuilder<'a> {
|
||||
header_id: BasicBlockId,
|
||||
preheader_id: BasicBlockId,
|
||||
) -> Result<(), String> {
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
static CALL_COUNT: AtomicUsize = AtomicUsize::new(0);
|
||||
let count = CALL_COUNT.fetch_add(1, Ordering::SeqCst);
|
||||
|
||||
let current_vars = self.get_current_variable_map();
|
||||
// Debug: print current_vars before prepare
|
||||
eprintln!("[DEBUG] prepare_loop_variables call #{}", count);
|
||||
eprintln!("[DEBUG] current_vars = {:?}", current_vars);
|
||||
eprintln!("[DEBUG] preheader_id = {:?}, header_id = {:?}", preheader_id, header_id);
|
||||
crate::mir::phi_core::loop_phi::save_block_snapshot(
|
||||
&mut self.block_var_maps,
|
||||
preheader_id,
|
||||
@ -409,17 +417,34 @@ impl<'a> LoopBuilder<'a> {
|
||||
dst: ValueId,
|
||||
inputs: Vec<(BasicBlockId, ValueId)>,
|
||||
) -> Result<(), String> {
|
||||
eprintln!("[DEBUG] LoopBuilder::emit_phi_at_block_start: block={}, dst=%{}, inputs={:?}", block_id, dst.0, inputs);
|
||||
// Phi nodeをブロックの先頭に挿入
|
||||
if let Some(ref mut function) = self.parent_builder.current_function {
|
||||
if let Some(block) = function.get_block_mut(block_id) {
|
||||
eprintln!("[DEBUG] Block {} current instructions count: {}", block_id, block.instructions.len());
|
||||
// Phi命令は必ずブロックの先頭に配置
|
||||
let phi_inst = MirInstruction::Phi { dst, inputs };
|
||||
let phi_inst = MirInstruction::Phi { dst, inputs: inputs.clone() };
|
||||
block.instructions.insert(0, phi_inst);
|
||||
eprintln!("[DEBUG] ✅ PHI instruction inserted at position 0");
|
||||
eprintln!("[DEBUG] Block {} after insert instructions count: {}", block_id, block.instructions.len());
|
||||
// Verify PHI is still there
|
||||
if let Some(first_inst) = block.instructions.get(0) {
|
||||
match first_inst {
|
||||
MirInstruction::Phi { dst: phi_dst, .. } => {
|
||||
eprintln!("[DEBUG] Verified: First instruction is PHI dst=%{}", phi_dst.0);
|
||||
}
|
||||
other => {
|
||||
eprintln!("[DEBUG] ⚠️ WARNING: First instruction is NOT PHI! It's {:?}", other);
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
} else {
|
||||
eprintln!("[DEBUG] ❌ Block {} not found!", block_id);
|
||||
Err(format!("Block {} not found", block_id))
|
||||
}
|
||||
} else {
|
||||
eprintln!("[DEBUG] ❌ No current function!");
|
||||
Err("No current function".to_string())
|
||||
}
|
||||
}
|
||||
@ -465,6 +490,7 @@ impl<'a> LoopBuilder<'a> {
|
||||
}
|
||||
|
||||
fn update_variable(&mut self, name: String, value: ValueId) {
|
||||
eprintln!("[DEBUG] LoopBuilder::update_variable: name={}, value=%{}", name, value.0);
|
||||
self.parent_builder.variable_map.insert(name, value);
|
||||
}
|
||||
|
||||
@ -716,4 +742,26 @@ impl crate::mir::phi_core::loop_phi::LoopPhiOps for LoopBuilder<'_> {
|
||||
crate::mir::phi_core::common::debug_verify_phi_inputs(func, merge_bb, inputs);
|
||||
}
|
||||
}
|
||||
|
||||
fn emit_copy_at_preheader(
|
||||
&mut self,
|
||||
preheader_id: BasicBlockId,
|
||||
dst: ValueId,
|
||||
src: ValueId,
|
||||
) -> Result<(), String> {
|
||||
eprintln!("[DEBUG] emit_copy_at_preheader: preheader={}, dst=%{}, src=%{}", preheader_id, dst.0, src.0);
|
||||
if let Some(ref mut function) = self.parent_builder.current_function {
|
||||
if let Some(block) = function.get_block_mut(preheader_id) {
|
||||
eprintln!("[DEBUG] Adding Copy instruction to block {}", preheader_id);
|
||||
block.add_instruction(MirInstruction::Copy { dst, src });
|
||||
Ok(())
|
||||
} else {
|
||||
eprintln!("[DEBUG] ❌ Preheader block {} not found!", preheader_id);
|
||||
Err(format!("Preheader block {} not found", preheader_id))
|
||||
}
|
||||
} else {
|
||||
eprintln!("[DEBUG] ❌ No current function!");
|
||||
Err("No current function".to_string())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user