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:
@ -81,7 +81,8 @@ impl LoopFormOps for LoopFormJsonOps<'_> {
|
||||
fn get_block_predecessors(
|
||||
&self,
|
||||
block: BasicBlockId,
|
||||
) -> std::collections::HashSet<BasicBlockId> {
|
||||
) -> std::collections::BTreeSet<BasicBlockId> {
|
||||
// Phase 69-3: Changed to BTreeSet for determinism
|
||||
self.f
|
||||
.blocks
|
||||
.get(&block)
|
||||
|
||||
@ -273,7 +273,7 @@ pub fn try_parse_v1_to_module(json: &str) -> Result<Option<MirModule>, String> {
|
||||
block_ref.add_instruction(MirInstruction::Phi {
|
||||
dst: ValueId::new(dst),
|
||||
inputs: pairs,
|
||||
type_hint: None, // Phase 63-6
|
||||
type_hint: None, // Phase 63-6
|
||||
});
|
||||
max_value_id = max_value_id.max(dst + 1);
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ pub fn parse_mir_v0_to_module(json: &str) -> Result<MirModule, String> {
|
||||
block_ref.add_instruction(MirInstruction::Phi {
|
||||
dst: ValueId::new(dst),
|
||||
inputs: pairs,
|
||||
type_hint: None, // Phase 63-6
|
||||
type_hint: None, // Phase 63-6
|
||||
});
|
||||
max_value_id = max_value_id.max(dst + 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user