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:
@ -59,11 +59,11 @@ box MirJsonBuilderMin {
|
||||
if arr_text == null { return out }
|
||||
local s = "" + arr_text
|
||||
local i = 0
|
||||
loop (i < s.size()) {
|
||||
loop (i < s.length()) {
|
||||
local ch = s.substring(i, i+1)
|
||||
if ch >= "0" && ch <= "9" {
|
||||
local j = i
|
||||
loop (j < s.size()) {
|
||||
loop (j < s.length()) {
|
||||
local cj = s.substring(j, j+1)
|
||||
if !(cj >= "0" && cj <= "9") { break }
|
||||
j = j + 1
|
||||
@ -104,9 +104,9 @@ box MirJsonBuilderMin {
|
||||
start_block(id) {
|
||||
me.phase = 3
|
||||
me.first_inst = 1
|
||||
local blk = map({ id: id, instructions: new ArrayBox() })
|
||||
local blk = { id: id, instructions: new ArrayBox() }
|
||||
me.blocks.push(blk)
|
||||
me.cur_block_index = me.blocks.size() - 1
|
||||
me.cur_block_index = me.blocks.length() - 1
|
||||
local b = "{\"id\":" + me._int_to_str(id) + ",\"instructions\":["
|
||||
return me._append(b)
|
||||
}
|
||||
@ -399,7 +399,7 @@ box MirJsonBuilderMin {
|
||||
|
||||
get_function_structure() {
|
||||
local blks = me.get_blocks_array()
|
||||
return map({ name: me.fn_name, params: new ArrayBox(), blocks: blks })
|
||||
return { name: me.fn_name, params: new ArrayBox(), blocks: blks }
|
||||
}
|
||||
|
||||
emit_to_string() { return me.to_string() }
|
||||
@ -412,7 +412,7 @@ box MirJsonBuilderMin {
|
||||
local blks_size_str = "null"
|
||||
local blks_len = BoxHelpers.array_len(blks)
|
||||
if blks_len >= 0 { blks_size_str = me._int_to_str(blks_len) }
|
||||
print("[DEBUG rebuild] fn_name=" + name + " blks.size()=" + blks_size_str)
|
||||
print("[DEBUG rebuild] fn_name=" + name + " blks.length()=" + blks_size_str)
|
||||
local out = "{\"functions\":[{\"name\":" + me._quote(name) + ",\"params\":[],\"blocks\":["
|
||||
local n = blks_len
|
||||
print("[DEBUG rebuild] n=" + me._int_to_str(n))
|
||||
|
||||
Reference in New Issue
Block a user