fix(joinir): Use BTreeMap for MirModule.functions deterministic iteration

HashMap iteration order is non-deterministic due to HashDoS protection.
This caused merge_joinir_mir_blocks to sometimes process functions in
wrong order, leading to incorrect block remapping.

Changed:
- MirModule.functions: HashMap → BTreeMap
- MirInterpreter.functions: HashMap → BTreeMap
- IfLoweringDryRunner.scan_module: HashMap → BTreeMap parameter

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-05 17:22:14 +09:00
parent 1c89befdac
commit c4c0814fd6
3 changed files with 9 additions and 9 deletions

View File

@ -11,7 +11,7 @@
use crate::mir::join_ir::JoinInst;
use crate::mir::{MirFunction, MirInstruction};
use std::collections::HashMap;
use std::collections::BTreeMap;
use std::time::{Duration, Instant};
/// If lowering dry-run スキャナー
@ -42,7 +42,7 @@ impl IfLoweringDryRunner {
/// - 各 Branch ブロックで try_lower_if_to_joinir() 試行
/// - パフォーマンス計測(マイクロ秒レベル)
/// - 統計情報収集Select/IfMerge分類
pub fn scan_module(&self, functions: &HashMap<String, MirFunction>) -> DryRunStats {
pub fn scan_module(&self, functions: &BTreeMap<String, MirFunction>) -> DryRunStats {
let mut total_branches = 0;
let mut lowered_count = 0;
let mut select_count = 0;