@@ -1545,7 +1545,6 @@ int ir_build_dominators_tree(ir_ctx *ctx)
1545
1545
/* In rare cases, LOOP_BEGIN.op1 may be a back-edge. Skip back-edges. */
1546
1546
ctx -> flags2 &= ~IR_NO_LOOPS ;
1547
1547
IR_ASSERT (k > 1 );
1548
- IR_ASSERT (blocks [idom ].successors_count == 1 );
1549
1548
ir_list_push (& worklist , idom );
1550
1549
while (1 ) {
1551
1550
k -- ;
@@ -1555,7 +1554,6 @@ int ir_build_dominators_tree(ir_ctx *ctx)
1555
1554
break ;
1556
1555
}
1557
1556
IR_ASSERT (k > 0 );
1558
- IR_ASSERT (blocks [idom ].successors_count == 1 );
1559
1557
ir_list_push (& worklist , idom );
1560
1558
}
1561
1559
}
@@ -1578,7 +1576,6 @@ int ir_build_dominators_tree(ir_ctx *ctx)
1578
1576
} else {
1579
1577
ctx -> flags2 &= ~IR_NO_LOOPS ;
1580
1578
IR_ASSERT (bb -> predecessors_count > 1 );
1581
- IR_ASSERT (blocks [pred_b ].successors_count == 1 );
1582
1579
ir_list_push (& worklist , pred_b );
1583
1580
}
1584
1581
}
@@ -1616,8 +1613,16 @@ int ir_build_dominators_tree(ir_ctx *ctx)
1616
1613
do {
1617
1614
b = ir_list_pop (& worklist );
1618
1615
bb = & blocks [b ];
1619
- IR_ASSERT (bb -> successors_count == 1 );
1620
1616
succ_b = ctx -> cfg_edges [bb -> successors ];
1617
+ if (bb -> successors_count != 1 ) {
1618
+ /* LOOP_END/END may be linked with the following ENTRY by a fake edge */
1619
+ IR_ASSERT (bb -> successors_count == 2 );
1620
+ if (blocks [succ_b ].flags & IR_BB_ENTRY ) {
1621
+ succ_b = ctx -> cfg_edges [bb -> successors + 1 ];
1622
+ } else {
1623
+ IR_ASSERT (blocks [ctx -> cfg_edges [bb -> successors + 1 ]].flags & IR_BB_ENTRY );
1624
+ }
1625
+ }
1621
1626
dom_depth = blocks [succ_b ].dom_depth ;;
1622
1627
while (bb -> dom_depth > dom_depth ) {
1623
1628
b = bb -> dom_parent ;
0 commit comments