@@ -352,13 +352,13 @@ type instr =
352
352
| Array_set of Var .t * Var .t * Var .t * loc
353
353
354
354
type last =
355
- | Return of Var .t
356
- | Raise of Var .t * [ `Normal | `Notrace | `Reraise ]
357
- | Stop
355
+ | Return of Var .t * loc
356
+ | Raise of Var .t * [ `Normal | `Notrace | `Reraise ] * loc
357
+ | Stop of loc
358
358
| Branch of cont
359
- | Cond of Var .t * cont * cont
360
- | Switch of Var .t * cont array * cont array
361
- | Pushtrap of cont * Var .t * cont * Addr.Set .t
359
+ | Cond of Var .t * cont * cont * loc
360
+ | Switch of Var .t * cont array * cont array * loc
361
+ | Pushtrap of cont * Var .t * cont * Addr.Set .t * loc
362
362
| Poptrap of cont
363
363
364
364
type block =
@@ -491,20 +491,20 @@ module Print = struct
491
491
492
492
let last f l =
493
493
match l with
494
- | Return x -> Format. fprintf f " return %a" Var. print x
495
- | Raise (x , `Normal) -> Format. fprintf f " raise %a" Var. print x
496
- | Raise (x , `Reraise) -> Format. fprintf f " reraise %a" Var. print x
497
- | Raise (x , `Notrace) -> Format. fprintf f " raise_notrace %a" Var. print x
498
- | Stop -> Format. fprintf f " stop"
494
+ | Return ( x , _ ) -> Format. fprintf f " return %a" Var. print x
495
+ | Raise (x , `Normal, _ ) -> Format. fprintf f " raise %a" Var. print x
496
+ | Raise (x , `Reraise, _ ) -> Format. fprintf f " reraise %a" Var. print x
497
+ | Raise (x , `Notrace, _ ) -> Format. fprintf f " raise_notrace %a" Var. print x
498
+ | Stop _ -> Format. fprintf f " stop"
499
499
| Branch c -> Format. fprintf f " branch %a" cont c
500
- | Cond (x , cont1 , cont2 ) ->
500
+ | Cond (x , cont1 , cont2 , _ ) ->
501
501
Format. fprintf f " if %a then %a else %a" Var. print x cont cont1 cont cont2
502
- | Switch (x , a1 , a2 ) ->
502
+ | Switch (x , a1 , a2 , _ ) ->
503
503
Format. fprintf f " switch %a {" Var. print x;
504
504
Array. iteri a1 ~f: (fun i c -> Format. fprintf f " int %d -> %a; " i cont c);
505
505
Array. iteri a2 ~f: (fun i c -> Format. fprintf f " tag %d -> %a; " i cont c);
506
506
Format. fprintf f " }"
507
- | Pushtrap (cont1 , x , cont2 , pcs ) ->
507
+ | Pushtrap (cont1 , x , cont2 , pcs , _ ) ->
508
508
Format. fprintf
509
509
f
510
510
" pushtrap %a handler %a => %a continuation %s"
@@ -559,12 +559,12 @@ let prepend ({ start; blocks; free_pc } as p) body =
559
559
| exception Not_found ->
560
560
let new_start = free_pc in
561
561
let blocks =
562
- Addr.Map. add new_start { params = [] ; body; branch = Stop } blocks
562
+ Addr.Map. add new_start { params = [] ; body; branch = Stop ( - 1 ) } blocks
563
563
in
564
564
let free_pc = free_pc + 1 in
565
565
{ start = new_start; blocks; free_pc })
566
566
567
- let empty_block = { params = [] ; body = [] ; branch = Stop }
567
+ let empty_block = { params = [] ; body = [] ; branch = Stop ( - 1 ) }
568
568
569
569
let empty =
570
570
let start = 0 in
@@ -577,7 +577,7 @@ let is_empty p =
577
577
| 1 -> (
578
578
let _, v = Addr.Map. choose p.blocks in
579
579
match v with
580
- | { body; branch = Stop ; params = _ } -> (
580
+ | { body; branch = Stop _ ; params = _ } -> (
581
581
match body with
582
582
| ([] | [ Let (_, Prim (Extern " caml_get_global_data" , _), _) ]) when true ->
583
583
true
@@ -588,17 +588,17 @@ let is_empty p =
588
588
let fold_children blocks pc f accu =
589
589
let block = Addr.Map. find pc blocks in
590
590
match block.branch with
591
- | Return _ | Raise _ | Stop -> accu
591
+ | Return _ | Raise _ | Stop _ -> accu
592
592
| Branch (pc' , _ ) | Poptrap (pc' , _ ) -> f pc' accu
593
- | Pushtrap ((pc' , _ ), _ , (pc_h , _ ), _ ) ->
593
+ | Pushtrap ((pc' , _ ), _ , (pc_h , _ ), _ , _ ) ->
594
594
let accu = f pc' accu in
595
595
let accu = f pc_h accu in
596
596
accu
597
- | Cond (_ , (pc1 , _ ), (pc2 , _ )) ->
597
+ | Cond (_ , (pc1 , _ ), (pc2 , _ ), _ ) ->
598
598
let accu = f pc1 accu in
599
599
let accu = f pc2 accu in
600
600
accu
601
- | Switch (_ , a1 , a2 ) ->
601
+ | Switch (_ , a1 , a2 , _ ) ->
602
602
let accu = Array. fold_right ~init: accu ~f: (fun (pc , _ ) accu -> f pc accu) a1 in
603
603
let accu = Array. fold_right ~init: accu ~f: (fun (pc , _ ) accu -> f pc accu) a2 in
604
604
accu
@@ -719,15 +719,15 @@ let invariant { blocks; start; _ } =
719
719
let check_last = function
720
720
| Return _ -> ()
721
721
| Raise _ -> ()
722
- | Stop -> ()
722
+ | Stop _ -> ()
723
723
| Branch cont -> check_cont cont
724
- | Cond (_x , cont1 , cont2 ) ->
724
+ | Cond (_x , cont1 , cont2 , _ ) ->
725
725
check_cont cont1;
726
726
check_cont cont2
727
- | Switch (_x , a1 , a2 ) ->
727
+ | Switch (_x , a1 , a2 , _ ) ->
728
728
Array. iteri a1 ~f: (fun _ cont -> check_cont cont);
729
729
Array. iteri a2 ~f: (fun _ cont -> check_cont cont)
730
- | Pushtrap (cont1 , _x , cont2 , _pcs ) ->
730
+ | Pushtrap (cont1 , _x , cont2 , _pcs , _ ) ->
731
731
check_cont cont1;
732
732
check_cont cont2
733
733
| Poptrap cont -> check_cont cont
0 commit comments