[backend] expose underlying Procdesc.Node from ProcCFG nodes

Reviewed By: jeremydubreil

Differential Revision: D4432566

fbshipit-source-id: 00530b9
master
Sam Blackshear 8 years ago committed by Facebook Github Bot
parent d9ed75cc08
commit 2f69191c7e

@ -115,7 +115,7 @@ module NullifyTransferFunctions = struct
type extras = LivenessAnalysis.invariant_map
let postprocess ((reaching_defs, _) as astate) node { ProcData.extras; } =
let node_id = (CFG.underlying_id node), ProcCfg.Node_index in
let node_id = Procdesc.Node.get_id (CFG.underlying_node node), ProcCfg.Node_index in
match LivenessAnalysis.extract_state node_id extras with
(* note: because the analysis is backward, post and pre are reversed *)
| Some { AbstractInterpreter.post = live_before; pre = live_after; } ->

@ -24,7 +24,7 @@ module type Node = sig
val kind : t -> Procdesc.Node.nodekind
val id : t -> id
val loc : t -> Location.t
val underlying_id : t -> Procdesc.Node.id
val underlying_node : t -> Procdesc.Node.t
val compare_id : id -> id -> int
val pp_id : F.formatter -> id -> unit
end
@ -36,7 +36,7 @@ module DefaultNode = struct
let kind = Procdesc.Node.get_kind
let id = Procdesc.Node.get_id
let loc = Procdesc.Node.get_loc
let underlying_id = id
let underlying_node t = t
let compare_id = Procdesc.Node.compare_id
let pp_id = Procdesc.Node.pp_id
end
@ -47,9 +47,9 @@ module InstrNode = struct
let kind = Procdesc.Node.get_kind
let underlying_id t = Procdesc.Node.get_id t
let underlying_node t = t
let id t = underlying_id t, Node_index
let id t = Procdesc.Node.get_id (underlying_node t), Node_index
let loc t = Procdesc.Node.get_loc t

@ -22,7 +22,7 @@ module type Node = sig
val kind : t -> Procdesc.Node.nodekind
val id : t -> id
val loc : t -> Location.t
val underlying_id : t -> Procdesc.Node.id
val underlying_node : t -> Procdesc.Node.t
val compare_id : id -> id -> int
val pp_id : Format.formatter -> id -> unit
end

@ -95,8 +95,8 @@ let tests =
| _ -> assert_failure "Expected exactly two instructions with correct indices"
end;
assert_bool
"underlying_id should return id of underlying CFG type"
(BackwardInstrCfg.underlying_id n1 = BackwardCfg.id n1) in
"underlying_node should return node of underlying CFG type"
(Procdesc.Node.get_id (BackwardInstrCfg.underlying_node n1) = BackwardCfg.id n1) in
"instr_test">::instr_test_ in
let graph_tests = [

@ -23,7 +23,7 @@ module MockNode = struct
let to_instr_nodes _ = assert false
let id n = n
let loc _ = assert false
let underlying_id _ = assert false
let underlying_node _ = assert false
let kind _ = Procdesc.Node.Stmt_node ""
let compare_id = Int.compare
let pp_id fmt i =

Loading…
Cancel
Save