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:
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
use super::{BasicBlock, BasicBlockId, EffectMask, MirInstruction, MirType, ValueId};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::fmt;
|
||||
|
||||
/// Function signature for MIR functions
|
||||
@ -381,8 +381,8 @@ pub struct MirModule {
|
||||
/// Module name
|
||||
pub name: String,
|
||||
|
||||
/// Functions in this module
|
||||
pub functions: HashMap<String, MirFunction>,
|
||||
/// Functions in this module (BTreeMap for deterministic iteration order)
|
||||
pub functions: BTreeMap<String, MirFunction>,
|
||||
|
||||
/// Global constants/statics
|
||||
pub globals: HashMap<String, super::ConstValue>,
|
||||
@ -416,7 +416,7 @@ impl MirModule {
|
||||
pub fn new(name: String) -> Self {
|
||||
Self {
|
||||
name,
|
||||
functions: HashMap::new(),
|
||||
functions: BTreeMap::new(),
|
||||
globals: HashMap::new(),
|
||||
metadata: ModuleMetadata::default(),
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user