|
|
@ -102,18 +102,28 @@ let get_vars_in_loop loop_nodes =
|
|
|
|
loop_nodes VarsInLoop.empty
|
|
|
|
loop_nodes VarsInLoop.empty
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module ProcessedPair = struct
|
|
|
|
|
|
|
|
type t = Var.t * Procdesc.Node.t [@@deriving compare]
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module ProcessedPairSet = Caml.Set.Make (ProcessedPair)
|
|
|
|
|
|
|
|
|
|
|
|
(* get all the ptr variables (and their dependencies) occurring on the
|
|
|
|
(* get all the ptr variables (and their dependencies) occurring on the
|
|
|
|
RHS of the definition of a given variable. *)
|
|
|
|
RHS of the definition of a given variable. *)
|
|
|
|
let get_ptr_vars_in_defn_path node loop_head var =
|
|
|
|
let get_ptr_vars_in_defn_path node loop_head var =
|
|
|
|
let rec aux node var =
|
|
|
|
let rec aux node var processed_pairs =
|
|
|
|
|
|
|
|
if ProcessedPairSet.mem (var, node) processed_pairs then InvalidatedVars.empty
|
|
|
|
|
|
|
|
else
|
|
|
|
let invalidate_exp exp_rhs init =
|
|
|
|
let invalidate_exp exp_rhs init =
|
|
|
|
|
|
|
|
let node_list =
|
|
|
|
|
|
|
|
node :: (if Procdesc.Node.equal node loop_head then [] else Procdesc.Node.get_preds node)
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
let processed_pairs' = ProcessedPairSet.add (var, node) processed_pairs in
|
|
|
|
Var.get_all_vars_in_exp exp_rhs
|
|
|
|
Var.get_all_vars_in_exp exp_rhs
|
|
|
|
|> Sequence.fold ~init ~f:(fun acc var ->
|
|
|
|
|> Sequence.fold ~init ~f:(fun acc rhs_var ->
|
|
|
|
List.fold_left ~init:(InvalidatedVars.add var acc)
|
|
|
|
List.fold_left ~init:(InvalidatedVars.add rhs_var acc)
|
|
|
|
~f:(fun acc node -> InvalidatedVars.union (aux node var) acc)
|
|
|
|
~f:(fun acc node -> InvalidatedVars.union (aux node rhs_var processed_pairs') acc)
|
|
|
|
( node
|
|
|
|
node_list )
|
|
|
|
:: (if Procdesc.Node.equal node loop_head then [] else Procdesc.Node.get_preds node)
|
|
|
|
|
|
|
|
) )
|
|
|
|
|
|
|
|
in
|
|
|
|
in
|
|
|
|
Procdesc.Node.get_instrs node
|
|
|
|
Procdesc.Node.get_instrs node
|
|
|
|
|> Instrs.fold ~init:InvalidatedVars.empty ~f:(fun acc instr ->
|
|
|
|
|> Instrs.fold ~init:InvalidatedVars.empty ~f:(fun acc instr ->
|
|
|
@ -127,7 +137,7 @@ let get_ptr_vars_in_defn_path node loop_head var =
|
|
|
|
| _ ->
|
|
|
|
| _ ->
|
|
|
|
acc )
|
|
|
|
acc )
|
|
|
|
in
|
|
|
|
in
|
|
|
|
aux node var
|
|
|
|
aux node var ProcessedPairSet.empty
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let get_vars_to_invalidate node loop_head params invalidated_vars : InvalidatedVars.t =
|
|
|
|
let get_vars_to_invalidate node loop_head params invalidated_vars : InvalidatedVars.t =
|
|
|
|