fix(mir): PHI検証panic修正 - update_cfg()を検証前に呼び出し
A案実装: debug_verify_phi_inputs呼び出し前にCFG predecessorを更新
修正箇所(7箇所):
- src/mir/builder/phi.rs:50, 73, 132, 143
- src/mir/builder/ops.rs:273, 328, 351
根本原因:
- Branch/Jump命令でsuccessorは即座に更新
- predecessorはupdate_cfg()で遅延再構築
- PHI検証が先に実行されてpredecessor未更新でpanic
解決策:
- 各debug_verify_phi_inputs呼び出し前に
if let Some(func) = self.current_function.as_mut() {
func.update_cfg();
}
を挿入してCFGを同期
影響: if/else文、論理演算子(&&/||)のPHI生成が正常動作
This commit is contained in:
@ -8,6 +8,11 @@ pub fn check_ssa_form(function: &MirFunction) -> Result<(), Vec<VerificationErro
|
||||
let mut errors = Vec::new();
|
||||
let mut definitions: HashMap<ValueId, (crate::mir::BasicBlockId, usize)> = HashMap::new();
|
||||
|
||||
// Treat parameters as defined at the entry block.
|
||||
for pid in &function.params {
|
||||
definitions.insert(*pid, (function.entry_block, 0));
|
||||
}
|
||||
|
||||
for (block_id, block) in &function.blocks {
|
||||
for (inst_idx, instruction) in block.all_instructions().enumerate() {
|
||||
if let Some(dst) = instruction.dst_value() {
|
||||
@ -38,4 +43,3 @@ pub fn check_ssa_form(function: &MirFunction) -> Result<(), Vec<VerificationErro
|
||||
|
||||
if errors.is_empty() { Ok(()) } else { Err(errors) }
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,9 @@ pub fn compute_predecessors(function: &MirFunction) -> HashMap<BasicBlockId, Vec
|
||||
|
||||
pub fn compute_def_blocks(function: &MirFunction) -> HashMap<ValueId, BasicBlockId> {
|
||||
let mut def_block: HashMap<ValueId, BasicBlockId> = HashMap::new();
|
||||
for pid in &function.params {
|
||||
def_block.insert(*pid, function.entry_block);
|
||||
}
|
||||
for (bid, block) in &function.blocks {
|
||||
for inst in block.all_instructions() {
|
||||
if let Some(dst) = inst.dst_value() {
|
||||
|
||||
Reference in New Issue
Block a user