@ -121,7 +121,7 @@ let sexp_of_func {name; params; freturn; fthrow; locals; entry; cfg} =
let compare_block x y = Int . compare x . sort_index y . sort_index
let compare_block x y = Int . compare x . sort_index y . sort_index
let equal_block x y = Int . equal x . sort_index y . sort_index
let equal_block x y = Int . equal x . sort_index y . sort_index
type functions = func Var. Map .t [ @@ deriving sexp_of ]
type functions = func Map. M ( String ) .t [ @@ deriving sexp_of ]
type t = { globals : Global . t vector ; functions : functions }
type t = { globals : Global . t vector ; functions : functions }
[ @@ deriving sexp_of ]
[ @@ deriving sexp_of ]
@ -551,7 +551,9 @@ let set_derived_metadata functions =
jump els
jump els
| Iswitch { tbl ; _ } -> Vector . iter tbl ~ f : jump
| Iswitch { tbl ; _ } -> Vector . iter tbl ~ f : jump
| Call ( { callee ; return ; throw ; _ } as call ) ->
| Call ( { callee ; return ; throw ; _ } as call ) ->
( match Var . of_exp callee > > = Func . find functions with
( match
Var . of_exp callee > > | Var . name > > = Func . find functions
with
| Some func ->
| Some func ->
if Set . mem ancestors func . entry then call . recursive <- true
if Set . mem ancestors func . entry then call . recursive <- true
else visit ancestors func func . entry
else visit ancestors func func . entry
@ -579,8 +581,10 @@ let set_derived_metadata functions =
( Vector . to_array cfg ) )
( Vector . to_array cfg ) )
in
in
let functions =
let functions =
List . fold functions ~ init : Var . Map . empty ~ f : ( fun m func ->
List . fold functions
Map . add_exn m ~ key : func . name . var ~ data : func )
~ init : ( Map . empty ( module String ) )
~ f : ( fun m func ->
Map . add_exn m ~ key : ( Var . name func . name . var ) ~ data : func )
in
in
let roots = compute_roots functions in
let roots = compute_roots functions in
let tips_to_roots = topsort functions roots in
let tips_to_roots = topsort functions roots in