Project

General

Profile

« Previous | Next » 

Revision 9aaee7f9

Added by Xavier Thirioux almost 9 years ago

added warnings for useless variables (at verbose level 1)
- exact definition of 'useless' may be further refined
- display could certainly be improved

View differences:

src/liveness.ml
24 24
open Utils
25 25
open LustreSpec
26 26
open Corelang
27
open Graph
27 28
open Causality
28 29

  
29 30
(* Computes the last dependency
......
57 58
  end
58 59
*)
59 60

  
61

  
62
(* computes the cone of influence of a given [var] wrt a dependency graph [g].
63
*)
64
let cone_of_influence g var =
65
 (*Format.printf "coi: %s@." var;*)
66
 let frontier = ref (ISet.add var ISet.empty) in
67
 let coi = ref ISet.empty in
68
 while not (ISet.is_empty !frontier)
69
 do
70
   let head = ISet.min_elt !frontier in
71
   (*Format.printf "head: %s@." head;*)
72
   frontier := ISet.remove head !frontier;
73
   if ExprDep.is_read_var head then coi := ISet.add (ExprDep.undo_read_var head) !coi;
74
   List.iter (fun s -> frontier := ISet.add s !frontier) (IdentDepGraph.succ g head);
75
 done;
76
 !coi
77

  
78
let compute_unused n g =
79
  let inputs = ExprDep.node_input_variables n in
80
  let mems = ExprDep.node_memory_variables n in
81
  let outputs = ExprDep.node_output_variables n in
82
  ISet.fold
83
    (fun var unused -> ISet.diff unused (cone_of_influence g var))
84
    (ISet.union outputs mems)
85
    (ISet.union inputs mems) 
86

  
60 87
(* Computes the set of (input and) output and mem variables of [node].
61 88
   We try to reuse input variables, due to C parameter copying semantics. *)
62 89
let node_non_locals node =

Also available in: Unified diff