@@ -40,7 +40,6 @@ module Info = struct
4040 ; info_known_origins : Code.Var.Set .t Code.Var.Tbl .t
4141 ; info_maybe_unknown : bool Code.Var.Tbl .t
4242 ; info_possibly_mutable : Var.ISet .t
43- ; info_blocks : Code .block Addr.Map .t
4443 }
4544
4645 let def t x =
@@ -431,7 +430,7 @@ let direct_approx (info : Info.t) x =
431430 y
432431 | _ -> None
433432
434- let rec the_shape_of ~pure info x =
433+ let rec the_shape_of ~return_values ~ pure info x =
435434 let rec merge (u : Shape.t ) (v : Shape.t ) =
436435 match u, v with
437436 | ( Function { arity = a1; pure = p1; res = r1 }
@@ -455,30 +454,28 @@ let rec the_shape_of ~pure info x =
455454 | None -> (
456455 match info.info_defs.(Var. idx x) with
457456 | 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 , _ )) ->
460460 let pure = Code.Var.Set. mem x pure in
461- let blocks = info.info_blocks in
462461 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)
482479 in
483480 Shape. Function { arity = List. length l; pure; res }
484481 | Expr (Special (Alias_prim name )) -> (
@@ -565,7 +562,6 @@ let f ?skip_param p =
565562 ; info_known_origins = known_origins
566563 ; info_maybe_unknown = maybe_unknown
567564 ; info_possibly_mutable = possibly_mutable
568- ; info_blocks = p.blocks
569565 }
570566 in
571567 let s = build_subst info vars in
0 commit comments