chore: Phase 25.1 完了 - LoopForm v2/Stage1 CLI/環境変数削減 + Phase 26-D からの変更
Phase 25.1 完了成果: - ✅ LoopForm v2 テスト・ドキュメント・コメント完備 - 4ケース(A/B/C/D)完全テストカバレッジ - 最小再現ケース作成(SSAバグ調査用) - SSOT文書作成(loopform_ssot.md) - 全ソースに [LoopForm] コメントタグ追加 - ✅ Stage-1 CLI デバッグ環境構築 - stage1_cli.hako 実装 - stage1_bridge.rs ブリッジ実装 - デバッグツール作成(stage1_debug.sh/stage1_minimal.sh) - アーキテクチャ改善提案文書 - ✅ 環境変数削減計画策定 - 25変数の完全調査・分類 - 6段階削減ロードマップ(25→5、80%削減) - 即時削除可能変数特定(NYASH_CONFIG/NYASH_DEBUG) Phase 26-D からの累積変更: - PHI実装改善(ExitPhiBuilder/HeaderPhiBuilder等) - MIRビルダーリファクタリング - 型伝播・最適化パス改善 - その他約300ファイルの累積変更 🎯 技術的成果: - SSAバグ根本原因特定(条件分岐内loop変数変更) - Region+next_iパターン適用完了(UsingCollectorBox等) - LoopFormパターン文書化・テスト化完了 - セルフホスティング基盤強化 Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: ChatGPT <noreply@openai.com> Co-Authored-By: Task Assistant <task@anthropic.com>
This commit is contained in:
@ -41,7 +41,7 @@ pub fn diagnose_unlowered_type_ops(
|
||||
if let Some(b) = function.blocks.get(&bb) {
|
||||
if idx < b.instructions.len() {
|
||||
if let MirInstruction::Const {
|
||||
value: crate::mir::ConstValue::String(s),
|
||||
value: crate::mir::ConstValue::String(s),
|
||||
..
|
||||
} = &b.instructions[idx]
|
||||
{
|
||||
|
||||
@ -2,5 +2,5 @@ pub mod boxfield;
|
||||
pub mod diagnostics;
|
||||
pub mod intrinsics;
|
||||
pub mod normalize;
|
||||
pub mod reorder;
|
||||
pub mod normalize_core13_pure;
|
||||
pub mod reorder;
|
||||
|
||||
@ -26,9 +26,14 @@ pub fn force_plugin_invoke(_opt: &mut MirOptimizer, module: &mut MirModule) -> O
|
||||
for fname in func_names {
|
||||
if idemp_enabled() {
|
||||
let key = idemp_key(pass_name, &fname);
|
||||
if idemp_already_done(module, &key) { continue; }
|
||||
if idemp_already_done(module, &key) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
let function = match module.functions.get_mut(&fname) { Some(f) => f, None => continue };
|
||||
let function = match module.functions.get_mut(&fname) {
|
||||
Some(f) => f,
|
||||
None => continue,
|
||||
};
|
||||
for (_bb, block) in &mut function.blocks {
|
||||
for inst in &mut block.instructions {
|
||||
if let I::BoxCall {
|
||||
@ -51,7 +56,10 @@ pub fn force_plugin_invoke(_opt: &mut MirOptimizer, module: &mut MirModule) -> O
|
||||
}
|
||||
}
|
||||
}
|
||||
if idemp_enabled() { let key = idemp_key(pass_name, &fname); idemp_mark(module, key); }
|
||||
if idemp_enabled() {
|
||||
let key = idemp_key(pass_name, &fname);
|
||||
idemp_mark(module, key);
|
||||
}
|
||||
}
|
||||
stats
|
||||
}
|
||||
@ -67,9 +75,14 @@ pub fn normalize_python_helper_calls(
|
||||
for fname in func_names {
|
||||
if idemp_enabled() {
|
||||
let key = idemp_key(pass_name, &fname);
|
||||
if idemp_already_done(module, &key) { continue; }
|
||||
if idemp_already_done(module, &key) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
let function = match module.functions.get_mut(&fname) { Some(f) => f, None => continue };
|
||||
let function = match module.functions.get_mut(&fname) {
|
||||
Some(f) => f,
|
||||
None => continue,
|
||||
};
|
||||
for (_bb, block) in &mut function.blocks {
|
||||
for inst in &mut block.instructions {
|
||||
if let I::PluginInvoke {
|
||||
@ -93,7 +106,10 @@ pub fn normalize_python_helper_calls(
|
||||
}
|
||||
}
|
||||
}
|
||||
if idemp_enabled() { let key = idemp_key(pass_name, &fname); idemp_mark(module, key); }
|
||||
if idemp_enabled() {
|
||||
let key = idemp_key(pass_name, &fname);
|
||||
idemp_mark(module, key);
|
||||
}
|
||||
}
|
||||
stats
|
||||
}
|
||||
@ -117,9 +133,14 @@ pub fn normalize_legacy_instructions(
|
||||
for fname in func_names {
|
||||
if idemp_enabled() {
|
||||
let key = idemp_key(pass_name, &fname);
|
||||
if idemp_already_done(module, &key) { continue; }
|
||||
if idemp_already_done(module, &key) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
let function = match module.functions.get_mut(&fname) { Some(f) => f, None => continue };
|
||||
let function = match module.functions.get_mut(&fname) {
|
||||
Some(f) => f,
|
||||
None => continue,
|
||||
};
|
||||
for (_bb, block) in &mut function.blocks {
|
||||
for inst in &mut block.instructions {
|
||||
match inst {
|
||||
@ -384,7 +405,10 @@ pub fn normalize_legacy_instructions(
|
||||
}
|
||||
}
|
||||
}
|
||||
if idemp_enabled() { let key = idemp_key(pass_name, &fname); idemp_mark(module, key); }
|
||||
if idemp_enabled() {
|
||||
let key = idemp_key(pass_name, &fname);
|
||||
idemp_mark(module, key);
|
||||
}
|
||||
}
|
||||
stats
|
||||
}
|
||||
@ -400,9 +424,14 @@ pub fn normalize_ref_field_access(
|
||||
for fname in func_names {
|
||||
if idemp_enabled() {
|
||||
let key = idemp_key(pass_name, &fname);
|
||||
if idemp_already_done(module, &key) { continue; }
|
||||
if idemp_already_done(module, &key) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
let function = match module.functions.get_mut(&fname) { Some(f) => f, None => continue };
|
||||
let function = match module.functions.get_mut(&fname) {
|
||||
Some(f) => f,
|
||||
None => continue,
|
||||
};
|
||||
for (_bb, block) in &mut function.blocks {
|
||||
let mut out: Vec<I> = Vec::with_capacity(block.instructions.len() + 2);
|
||||
let old = std::mem::take(&mut block.instructions);
|
||||
@ -509,7 +538,10 @@ pub fn normalize_ref_field_access(
|
||||
});
|
||||
}
|
||||
}
|
||||
if idemp_enabled() { let key = idemp_key(pass_name, &fname); idemp_mark(module, key); }
|
||||
if idemp_enabled() {
|
||||
let key = idemp_key(pass_name, &fname);
|
||||
idemp_mark(module, key);
|
||||
}
|
||||
}
|
||||
stats
|
||||
}
|
||||
|
||||
@ -39,11 +39,18 @@ pub fn normalize_pure_core13(_opt: &mut MirOptimizer, module: &mut MirModule) ->
|
||||
});
|
||||
stats.intrinsic_optimizations += 1;
|
||||
}
|
||||
I::NewBox { dst, box_type, mut args } => {
|
||||
I::NewBox {
|
||||
dst,
|
||||
box_type,
|
||||
mut args,
|
||||
} => {
|
||||
// prepend type name as Const String
|
||||
let ty_id = ValueId::new(function.next_value_id);
|
||||
function.next_value_id += 1;
|
||||
out.push(I::Const { dst: ty_id, value: crate::mir::ConstValue::String(box_type) });
|
||||
out.push(I::Const {
|
||||
dst: ty_id,
|
||||
value: crate::mir::ConstValue::String(box_type),
|
||||
});
|
||||
let mut call_args = Vec::with_capacity(1 + args.len());
|
||||
call_args.push(ty_id);
|
||||
call_args.append(&mut args);
|
||||
@ -61,20 +68,44 @@ pub fn normalize_pure_core13(_opt: &mut MirOptimizer, module: &mut MirModule) ->
|
||||
crate::mir::UnaryOp::Neg => {
|
||||
let zero = ValueId::new(function.next_value_id);
|
||||
function.next_value_id += 1;
|
||||
out.push(I::Const { dst: zero, value: crate::mir::ConstValue::Integer(0) });
|
||||
out.push(I::BinOp { dst, op: BinaryOp::Sub, lhs: zero, rhs: operand });
|
||||
out.push(I::Const {
|
||||
dst: zero,
|
||||
value: crate::mir::ConstValue::Integer(0),
|
||||
});
|
||||
out.push(I::BinOp {
|
||||
dst,
|
||||
op: BinaryOp::Sub,
|
||||
lhs: zero,
|
||||
rhs: operand,
|
||||
});
|
||||
}
|
||||
crate::mir::UnaryOp::Not => {
|
||||
let f = ValueId::new(function.next_value_id);
|
||||
function.next_value_id += 1;
|
||||
out.push(I::Const { dst: f, value: crate::mir::ConstValue::Bool(false) });
|
||||
out.push(I::Compare { dst, op: CompareOp::Eq, lhs: operand, rhs: f });
|
||||
out.push(I::Const {
|
||||
dst: f,
|
||||
value: crate::mir::ConstValue::Bool(false),
|
||||
});
|
||||
out.push(I::Compare {
|
||||
dst,
|
||||
op: CompareOp::Eq,
|
||||
lhs: operand,
|
||||
rhs: f,
|
||||
});
|
||||
}
|
||||
crate::mir::UnaryOp::BitNot => {
|
||||
let all1 = ValueId::new(function.next_value_id);
|
||||
function.next_value_id += 1;
|
||||
out.push(I::Const { dst: all1, value: crate::mir::ConstValue::Integer(-1) });
|
||||
out.push(I::BinOp { dst, op: BinaryOp::BitXor, lhs: operand, rhs: all1 });
|
||||
out.push(I::Const {
|
||||
dst: all1,
|
||||
value: crate::mir::ConstValue::Integer(-1),
|
||||
});
|
||||
out.push(I::BinOp {
|
||||
dst,
|
||||
op: BinaryOp::BitXor,
|
||||
lhs: operand,
|
||||
rhs: all1,
|
||||
});
|
||||
}
|
||||
}
|
||||
stats.intrinsic_optimizations += 1;
|
||||
@ -100,10 +131,17 @@ pub fn normalize_pure_core13(_opt: &mut MirOptimizer, module: &mut MirModule) ->
|
||||
args: vec![ptr, value],
|
||||
effects: EffectMask::WRITE,
|
||||
},
|
||||
I::NewBox { dst, box_type, mut args } => {
|
||||
I::NewBox {
|
||||
dst,
|
||||
box_type,
|
||||
mut args,
|
||||
} => {
|
||||
let ty_id = ValueId::new(function.next_value_id);
|
||||
function.next_value_id += 1;
|
||||
block.instructions.push(I::Const { dst: ty_id, value: ConstValue::String(box_type) });
|
||||
block.instructions.push(I::Const {
|
||||
dst: ty_id,
|
||||
value: ConstValue::String(box_type),
|
||||
});
|
||||
let mut call_args = Vec::with_capacity(1 + args.len());
|
||||
call_args.push(ty_id);
|
||||
call_args.append(&mut args);
|
||||
@ -119,20 +157,44 @@ pub fn normalize_pure_core13(_opt: &mut MirOptimizer, module: &mut MirModule) ->
|
||||
crate::mir::UnaryOp::Neg => {
|
||||
let zero = ValueId::new(function.next_value_id);
|
||||
function.next_value_id += 1;
|
||||
block.instructions.push(I::Const { dst: zero, value: ConstValue::Integer(0) });
|
||||
I::BinOp { dst, op: BinaryOp::Sub, lhs: zero, rhs: operand }
|
||||
block.instructions.push(I::Const {
|
||||
dst: zero,
|
||||
value: ConstValue::Integer(0),
|
||||
});
|
||||
I::BinOp {
|
||||
dst,
|
||||
op: BinaryOp::Sub,
|
||||
lhs: zero,
|
||||
rhs: operand,
|
||||
}
|
||||
}
|
||||
crate::mir::UnaryOp::Not => {
|
||||
let f = ValueId::new(function.next_value_id);
|
||||
function.next_value_id += 1;
|
||||
block.instructions.push(I::Const { dst: f, value: ConstValue::Bool(false) });
|
||||
I::Compare { dst, op: CompareOp::Eq, lhs: operand, rhs: f }
|
||||
block.instructions.push(I::Const {
|
||||
dst: f,
|
||||
value: ConstValue::Bool(false),
|
||||
});
|
||||
I::Compare {
|
||||
dst,
|
||||
op: CompareOp::Eq,
|
||||
lhs: operand,
|
||||
rhs: f,
|
||||
}
|
||||
}
|
||||
crate::mir::UnaryOp::BitNot => {
|
||||
let all1 = ValueId::new(function.next_value_id);
|
||||
function.next_value_id += 1;
|
||||
block.instructions.push(I::Const { dst: all1, value: ConstValue::Integer(-1) });
|
||||
I::BinOp { dst, op: BinaryOp::BitXor, lhs: operand, rhs: all1 }
|
||||
block.instructions.push(I::Const {
|
||||
dst: all1,
|
||||
value: ConstValue::Integer(-1),
|
||||
});
|
||||
I::BinOp {
|
||||
dst,
|
||||
op: BinaryOp::BitXor,
|
||||
lhs: operand,
|
||||
rhs: all1,
|
||||
}
|
||||
}
|
||||
},
|
||||
other => other,
|
||||
|
||||
Reference in New Issue
Block a user