feat(mir): Phase 69-3 Fix MIR non-determinism with BTreeSet

Replace HashSet with BTreeSet for CFG predecessors/successors:
- BasicBlock.predecessors: HashSet → BTreeSet
- BasicBlock.successors: HashSet → BTreeSet
- LoopFormOps.get_block_predecessors(): returns BTreeSet
- BasicBlock.dominates(): takes &[BTreeSet<BasicBlockId>]

This ensures deterministic PHI generation and test stability.

Test results:
- loop_with_continue_and_break tests: now deterministic (3/3 same output)
- loopform tests: 14/14 PASS (no regressions)
- merge_exit_with_classification tests: 3/3 PASS

Technical changes (6 files):
- basic_block.rs: BTreeSet types + new() initialization
- loopform_builder.rs: trait signature + 2 mock implementations
- phi_ops.rs: return type
- json_v0_bridge/loop_.rs: return type

Same pattern as Phase 25.1 (MirFunction.blocks HashMap → BTreeMap).

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-11-30 09:38:28 +09:00
parent 3387d9c1dc
commit 7de192aa6b
18 changed files with 286 additions and 1315 deletions

View File

@ -869,10 +869,11 @@ pub trait LoopFormOps {
/// 📦 Get actual CFG predecessors for a block (Hotfix 6: PHI input validation)
/// Returns the set of blocks that actually branch to this block in the CFG.
/// Used to validate exit PHI inputs against actual control flow.
/// Phase 69-3: Changed to BTreeSet for determinism
fn get_block_predecessors(
&self,
block: BasicBlockId,
) -> std::collections::HashSet<BasicBlockId>;
) -> std::collections::BTreeSet<BasicBlockId>;
/// Phase 26-A-4: ValueIdベースのパラメータ判定型安全化
///
@ -1029,9 +1030,10 @@ mod tests {
fn get_block_predecessors(
&self,
_block: BasicBlockId,
) -> std::collections::HashSet<BasicBlockId> {
) -> std::collections::BTreeSet<BasicBlockId> {
// MockOps: return empty set (no CFG in test)
std::collections::HashSet::new()
// Phase 69-3: Changed to BTreeSet for determinism
std::collections::BTreeSet::new()
}
/// Phase 26-A-4: ValueIdベースのパラメータ判定Mock版
@ -1197,8 +1199,9 @@ mod tests {
fn get_block_predecessors(
&self,
_block: BasicBlockId,
) -> std::collections::HashSet<BasicBlockId> {
std::collections::HashSet::new()
) -> std::collections::BTreeSet<BasicBlockId> {
// Phase 69-3: Changed to BTreeSet for determinism
std::collections::BTreeSet::new()
}
/// Phase 26-A-4: ValueIdベースのパラメータ判定Mock版・パラメータなし