@@ -40,7 +40,6 @@ module Info = struct
40
40
; info_known_origins : Code.Var.Set .t Code.Var.Tbl .t
41
41
; info_maybe_unknown : bool Code.Var.Tbl .t
42
42
; info_possibly_mutable : Var.ISet .t
43
- ; info_blocks : Code .block Addr.Map .t
44
43
}
45
44
46
45
let def t x =
@@ -431,7 +430,7 @@ let direct_approx (info : Info.t) x =
431
430
y
432
431
| _ -> None
433
432
434
- let rec the_shape_of ~pure info x =
433
+ let rec the_shape_of ~return_values ~ pure info x =
435
434
let rec merge (u : Shape.t ) (v : Shape.t ) =
436
435
match u, v with
437
436
| ( Function { arity = a1; pure = p1; res = r1 }
@@ -455,30 +454,28 @@ let rec the_shape_of ~pure info x =
455
454
| None -> (
456
455
match info.info_defs.(Var. idx x) with
457
456
| Expr (Block (_ , a , _ , Immutable)) ->
458
- Shape. Block (List. map ~f: (the_shape_of ~pure info) (Array. to_list a))
459
- | Expr (Closure (l , (pc , _ ))) ->
457
+ Shape. Block
458
+ (List. map ~f: (the_shape_of ~return_values ~pure info) (Array. to_list a))
459
+ | Expr (Closure (l , _ )) ->
460
460
let pure = Code.Var.Set. mem x pure in
461
- let blocks = info.info_blocks in
462
461
let res =
463
- Code. traverse
464
- { fold = fold_children }
465
- (fun pc res ->
466
- let block = Addr.Map. find pc blocks in
467
- match block.branch with
468
- | Return x -> (
469
- let s2 = loop info x acc in
470
- match res with
471
- | None -> Some s2
472
- | Some s1 -> Some (merge s1 s2))
473
- | _ -> res)
474
- pc
475
- blocks
476
- None
477
- in
478
- let res : Shape.t =
479
- match res with
480
- | None -> Top " no return"
481
- | Some res -> res
462
+ match Var.Map. find x return_values with
463
+ | exception Not_found -> Shape. Top " not return_values found"
464
+ | set -> (
465
+ match
466
+ Var.Set. fold
467
+ (fun x res ->
468
+ let s2 = loop info x acc in
469
+ match res with
470
+ | None -> Some s2
471
+ | Some s1 -> Some (merge s1 s2))
472
+ set
473
+ None
474
+ with
475
+ | None ->
476
+ assert (Var.Set. is_empty set);
477
+ Shape. Top " no return"
478
+ | Some res -> res)
482
479
in
483
480
Shape. Function { arity = List. length l; pure; res }
484
481
| Expr (Special (Alias_prim name )) -> (
@@ -565,7 +562,6 @@ let f ?skip_param p =
565
562
; info_known_origins = known_origins
566
563
; info_maybe_unknown = maybe_unknown
567
564
; info_possibly_mutable = possibly_mutable
568
- ; info_blocks = p.blocks
569
565
}
570
566
in
571
567
let s = build_subst info vars in
0 commit comments