Skip to content

Commit ab557b8

Browse files
authored
Disconnect blocks with exceptional successors (#49)
Allow the deletion of blocks with exceptional successors.
1 parent 5d56f06 commit ab557b8

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

backend/cfg/disconnect_block.ml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ let disconnect cfg_with_layout label =
4343
(* CR-someday gyorsh: if trap handlers can be eliminated, remove this
4444
label from block.exn of other blocks. *)
4545
Misc.fatal_error "Removing trap handler blocks is not supported";
46-
let successors = C.successor_labels ~normal:true ~exn:true cfg block in
46+
let successors = C.successor_labels ~normal:true ~exn:false cfg block in
4747
let has_predecessors = not (Label.Set.is_empty block.predecessors) in
4848
let n = Label.Set.cardinal successors in
4949
let has_more_than_one_successor = n > 1 in
@@ -65,6 +65,12 @@ let disconnect cfg_with_layout label =
6565
(Label.Set.remove label succ_block.predecessors)
6666
block.predecessors)
6767
successors;
68+
Label.Set.iter
69+
(fun succ ->
70+
let succ_block = C.get_block_exn cfg succ in
71+
assert (Label.Set.mem label succ_block.predecessors);
72+
succ_block.predecessors <- Label.Set.remove label succ_block.predecessors)
73+
(C.successor_labels ~normal:false ~exn:true cfg block);
6874
(* Update predecessor blocks. *)
6975
if n = 1 then
7076
let target_label = Label.Set.min_elt successors in

0 commit comments

Comments
 (0)