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

@ -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(),
}