Project

General

Profile

Revision 3c48346d

View differences:

src/liveness.ml
84 84
   The death table is a mapping: ident -> Set(ident) such that:
85 85
   death x is the set of local variables which get dead (i.e. unused) 
86 86
   before x is evaluated, but were until live.
87
   If death x is not defined, then x is useless.
87 88
*)
88 89
let death_table node g sort =
89 90
  let non_locals = node_non_locals node in
......
93 94
    while (!sort <> [])
94 95
    do
95 96
      let head = List.hd !sort in
96
      let dead =
97
      (* If current var is not already dead, i.e. useless *)
98
      if IdentDepGraph.mem_vertex g head then
97 99
	begin
98 100
	  IdentDepGraph.iter_succ (IdentDepGraph.remove_edge g head) g head;
99
	  remove_local_roots non_locals g
100
	end in
101
      Hashtbl.add death head dead;
101
	  let dead = remove_local_roots non_locals g in
102
	  Hashtbl.add death head dead
103
	end;
102 104
      sort := List.tl !sort
103 105
    done;
104 106
    IdentDepGraph.clear g;
......
118 120

  
119 121
(* Replaces [v] by [v'] in death table [death] *)
120 122
let replace_in_death_table death v v' =
121
 Hashtbl.iter (fun k dead -> Hashtbl.add death k (replace_in_set dead v v')) death
123
 Hashtbl.iter (fun k dead -> Hashtbl.replace death k (replace_in_set dead v v')) death
122 124

  
123 125
let find_compatible_local node var dead =
126
 Format.eprintf "find_compatible_local %s %s@." node.node_id var;
124 127
  let typ = (Corelang.node_var var node).var_type in
125 128
  try
126 129
    Some ((List.find (fun v -> ISet.mem v.var_id dead && Typing.eq_ground typ v.var_type) node.node_locals).var_id)
......
133 136
  while !sort <> []
134 137
  do
135 138
    let head = List.hd !sort in
136
    dead := ISet.union (Hashtbl.find death head) !dead;
139
    if Hashtbl.mem death head then
140
      begin
141
	dead := ISet.union (Hashtbl.find death head) !dead;
142
      end;
137 143
    (match find_compatible_local node head !dead with
138 144
    | None   -> ()
139 145
    | Some l -> replace_in_death_table death head l; Hashtbl.add policy head l);
src/scheduling.ml
108 108
      with Not_found -> false in
109 109
    let n', g = global_dependency n in
110 110
    Log.report ~level:5 (fun fmt -> Format.eprintf "dependency graph for node %s: %a" n'.node_id pp_dep_graph g);
111
(*    let gg = IdentDepGraph.copy g in *)
111
    let gg = IdentDepGraph.copy g in
112 112
    let sort = topological_sort eq_equiv g in
113
(*
113

  
114 114
    let death = Liveness.death_table n gg sort in
115 115
    Log.report ~level:5 (fun fmt -> Format.eprintf "death table for node %s: %a" n'.node_id Liveness.pp_death_table death);
116
(*
116 117
    let reuse = Liveness.reuse_policy n sort death in
117 118
    Log.report ~level:5 (fun fmt -> Format.eprintf "reuse policy for node %s: %a" n'.node_id Liveness.pp_reuse_policy reuse);
118 119
*)

Also available in: Unified diff