@ -397,6 +397,7 @@ module Func = struct
let invariant func =
let invariant func =
Invariant . invariant [ % here ] func [ % sexp_of : t ]
Invariant . invariant [ % here ] func [ % sexp_of : t ]
@@ fun () ->
@@ fun () ->
assert ( func = = func . entry . parent ) ;
let { name = { typ } ; cfg } = func in
let { name = { typ } ; cfg } = func in
match typ with
match typ with
| Pointer _ ->
| Pointer _ ->
@ -416,6 +417,11 @@ module Func = struct
let find functions name = Map . find functions name
let find functions name = Map . find functions name
let mk ~ name ~ entry ~ cfg =
let mk ~ name ~ entry ~ cfg =
let locals =
Vector . fold ~ init : entry . locals cfg ~ f : ( fun locals block ->
Set . union locals block . locals )
in
let entry = { entry with locals } in
let func = { name ; entry ; cfg } in
let func = { name ; entry ; cfg } in
let resolve_parent_and_jumps block =
let resolve_parent_and_jumps block =
block . parent <- func ;
block . parent <- func ;
@ -434,12 +440,8 @@ module Func = struct
| Return _ | Throw _ | Unreachable -> ()
| Return _ | Throw _ | Unreachable -> ()
in
in
resolve_parent_and_jumps entry ;
resolve_parent_and_jumps entry ;
let locals =
Vector . iter cfg ~ f : resolve_parent_and_jumps ;
Vector . fold ~ init : entry . locals cfg ~ f : ( fun locals block ->
func | > check invariant
resolve_parent_and_jumps block ;
Set . union locals block . locals )
in
{ func with entry = { entry with locals } } | > check invariant
let mk_undefined ~ name ~ params =
let mk_undefined ~ name ~ params =
let entry =
let entry =