Skip to content
Snippets Groups Projects
Commit 4c10d0ce authored by Loïc Correnson's avatar Loïc Correnson
Browse files

[kernel] linting interpreted automata

parent 5f7ced90
No related branches found
No related tags found
No related merge requests found
...@@ -47,8 +47,6 @@ ML_LINT_KO+=src/kernel_services/analysis/dataflow2.mli ...@@ -47,8 +47,6 @@ ML_LINT_KO+=src/kernel_services/analysis/dataflow2.mli
ML_LINT_KO+=src/kernel_services/analysis/dataflows.ml ML_LINT_KO+=src/kernel_services/analysis/dataflows.ml
ML_LINT_KO+=src/kernel_services/analysis/dataflows.mli ML_LINT_KO+=src/kernel_services/analysis/dataflows.mli
ML_LINT_KO+=src/kernel_services/analysis/dominators.ml ML_LINT_KO+=src/kernel_services/analysis/dominators.ml
ML_LINT_KO+=src/kernel_services/analysis/interpreted_automata.ml
ML_LINT_KO+=src/kernel_services/analysis/interpreted_automata.mli
ML_LINT_KO+=src/kernel_services/analysis/logic_interp.ml ML_LINT_KO+=src/kernel_services/analysis/logic_interp.ml
ML_LINT_KO+=src/kernel_services/analysis/loop.ml ML_LINT_KO+=src/kernel_services/analysis/loop.ml
ML_LINT_KO+=src/kernel_services/analysis/ordered_stmt.ml ML_LINT_KO+=src/kernel_services/analysis/ordered_stmt.ml
......
...@@ -83,22 +83,22 @@ let dummy_edge = { ...@@ -83,22 +83,22 @@ let dummy_edge = {
} }
module Vertex = Datatype.Make_with_collections module Vertex = Datatype.Make_with_collections
(struct (struct
include Datatype.Serializable_undefined include Datatype.Serializable_undefined
type t = vertex type t = vertex
let reprs = [dummy_vertex] let reprs = [dummy_vertex]
let name = "Interpreted_automata.Vertex" let name = "Interpreted_automata.Vertex"
let copy v = let copy v =
{ v with vertex_key = v.vertex_key } { v with vertex_key = v.vertex_key }
let compare v1 v2 = v1.vertex_key - v2.vertex_key let compare v1 v2 = v1.vertex_key - v2.vertex_key
let hash v = v.vertex_key let hash v = v.vertex_key
let equal v1 v2 = v1.vertex_key = v2.vertex_key let equal v1 v2 = v1.vertex_key = v2.vertex_key
let pretty fmt v = Format.pp_print_int fmt v.vertex_key let pretty fmt v = Format.pp_print_int fmt v.vertex_key
end) end)
module Edge = module Edge =
struct struct
include Datatype.Make_with_collections include Datatype.Make_with_collections
(struct (struct
include Datatype.Serializable_undefined include Datatype.Serializable_undefined
type t = vertex edge type t = vertex edge
...@@ -110,8 +110,8 @@ module Edge = ...@@ -110,8 +110,8 @@ module Edge =
let equal e1 e2 = e1.edge_key = e2.edge_key let equal e1 e2 = e1.edge_key = e2.edge_key
let pretty fmt e = Format.pp_print_int fmt e.edge_key let pretty fmt e = Format.pp_print_int fmt e.edge_key
end) end)
let default = dummy_edge let default = dummy_edge
end end
module G = Graph.Imperative.Digraph.ConcreteBidirectionalLabeled (Vertex) module G = Graph.Imperative.Digraph.ConcreteBidirectionalLabeled (Vertex)
...@@ -133,7 +133,7 @@ type automaton = { ...@@ -133,7 +133,7 @@ type automaton = {
stmt_table : (vertex * vertex) StmtTable.t; stmt_table : (vertex * vertex) StmtTable.t;
} }
(** Each goto statement is referenced during the traversal of the AST so (** Each goto statement is referenced during the traversal of the AST so
that the jumps can be added to the graph afterward using a stmt_table. that the jumps can be added to the graph afterward using a stmt_table.
They are stored as a (vertex,stmt,stmt) tuple, where the vertex is the They are stored as a (vertex,stmt,stmt) tuple, where the vertex is the
origin and the two statements are the origin and the destination of the origin and the two statements are the origin and the destination of the
...@@ -163,24 +163,24 @@ let unknown_loc = ...@@ -163,24 +163,24 @@ let unknown_loc =
let first_loc block = let first_loc block =
let rec f = function let rec f = function
| [] -> | [] ->
raise Not_found raise Not_found
| {skind = Block b} :: l -> | {skind = Block b} :: l ->
(try f b.bstmts with Not_found -> f l) (try f b.bstmts with Not_found -> f l)
| stmt :: _ -> | stmt :: _ ->
stmt_loc stmt stmt_loc stmt
in in
try f block.bstmts try f block.bstmts
with Not_found -> unknown_loc with Not_found -> unknown_loc
let last_loc block = let last_loc block =
let rec f = function let rec f = function
| [] -> | [] ->
raise Not_found raise Not_found
| {skind = Block b} :: l -> | {skind = Block b} :: l ->
(try f (List.rev b.bstmts) with Not_found -> f l) (try f (List.rev b.bstmts) with Not_found -> f l)
| stmt :: _ -> | stmt :: _ ->
stmt_loc stmt stmt_loc stmt
in in
try f (List.rev block.bstmts) try f (List.rev block.bstmts)
with Not_found -> unknown_loc with Not_found -> unknown_loc
...@@ -243,8 +243,7 @@ let build_automaton ~annotations kf = ...@@ -243,8 +243,7 @@ let build_automaton ~annotations kf =
vertex_info = NoneInfo; vertex_info = NoneInfo;
} in } in
incr next_vertex; incr next_vertex;
G.add_vertex g v; G.add_vertex g v; v
v
and add_edge src dest edge_kinstr edge_transition edge_loc = and add_edge src dest edge_kinstr edge_transition edge_loc =
let e = { let e = {
edge_key = !next_edge; edge_key = !next_edge;
...@@ -260,16 +259,16 @@ let build_automaton ~annotations kf = ...@@ -260,16 +259,16 @@ let build_automaton ~annotations kf =
let build_transitions src dest kinstr loc l = let build_transitions src dest kinstr loc l =
(* Add transitions to the graph *) (* Add transitions to the graph *)
let rec fold_transition v1 = function let rec fold_transition v1 = function
| [] -> | [] ->
assert false assert false
| [t] -> | [t] ->
add_edge v1 dest kinstr t loc add_edge v1 dest kinstr t loc
| Skip :: l -> | Skip :: l ->
fold_transition v1 l fold_transition v1 l
| t :: l -> | t :: l ->
let v2 = add_vertex () in let v2 = add_vertex () in
add_edge v1 v2 kinstr t loc; add_edge v1 v2 kinstr t loc;
fold_transition v2 l fold_transition v2 l
in in
fold_transition src l fold_transition src l
in in
...@@ -284,7 +283,7 @@ let build_automaton ~annotations kf = ...@@ -284,7 +283,7 @@ let build_automaton ~annotations kf =
List.map (fun b -> Enter b) entered_blocks List.map (fun b -> Enter b) entered_blocks
and kinstr = Kstmt stmt and kinstr = Kstmt stmt
in in
build_transitions src dest kinstr (stmt_loc stmt) l build_transitions src dest kinstr (stmt_loc stmt) l
in in
let rec do_list do_one control labels = function let rec do_list do_one control labels = function
...@@ -411,31 +410,31 @@ let build_automaton ~annotations kf = ...@@ -411,31 +410,31 @@ let build_automaton ~annotations kf =
begin fun values case_stmt -> begin fun values case_stmt ->
let dest,_ = StmtTable.find table case_stmt in let dest,_ = StmtTable.find table case_stmt in
(* For all cases for this statement *) (* For all cases for this statement *)
List.fold_left List.fold_left
begin fun values -> function begin fun values -> function
| Case (exp2,_) -> | Case (exp2,_) ->
let guard = build_guard exp2 Then in let guard = build_guard exp2 Then in
build_stmt_transition control.src dest stmt case_stmt guard; build_stmt_transition control.src dest stmt case_stmt guard;
exp2 :: values exp2 :: values
| Default (_) -> | Default (_) ->
default_case := Some (dest,case_stmt); default_case := Some (dest,case_stmt);
values values
| Label _ -> values | Label _ -> values
end values case_stmt.Cil_types.labels end values case_stmt.Cil_types.labels
end [] cases end [] cases
in in
(* Finally, link the default case *) (* Finally, link the default case *)
let rec add_default_edge src = function let rec add_default_edge src = function
| [] -> | [] ->
add_last_edge src Skip add_last_edge src Skip
| exp2 :: [] -> | exp2 :: [] ->
let guard = build_guard exp2 Else in let guard = build_guard exp2 Else in
add_last_edge src guard add_last_edge src guard
| exp2 :: l -> | exp2 :: l ->
let point = add_vertex () let point = add_vertex ()
and guard = build_guard exp2 Else in and guard = build_guard exp2 Else in
add_edge src point kinstr guard loc; add_edge src point kinstr guard loc;
add_default_edge point l add_default_edge point l
and add_last_edge src transition = and add_last_edge src transition =
match !default_case with match !default_case with
| None -> | None ->
...@@ -461,7 +460,7 @@ let build_automaton ~annotations kf = ...@@ -461,7 +460,7 @@ let build_automaton ~annotations kf =
loop_head_point.vertex_info <- LoopHead (!loop_level); loop_head_point.vertex_info <- LoopHead (!loop_level);
let labels = let labels =
LabelMap.(add_builtin LoopEntry control.src LabelMap.(add_builtin LoopEntry control.src
(add_builtin LoopCurrent loop_head_point labels)) (add_builtin LoopCurrent loop_head_point labels))
in in
(* for variant to have one point at the end of the loop *) (* for variant to have one point at the end of the loop *)
let loop_end_point = add_vertex () in let loop_end_point = add_vertex () in
...@@ -484,18 +483,18 @@ let build_automaton ~annotations kf = ...@@ -484,18 +483,18 @@ let build_automaton ~annotations kf =
decr loop_level; decr loop_level;
control.dest control.dest
| Block block -> | Block block ->
do_block control kinstr labels block; do_block control kinstr labels block;
control.dest control.dest
| UnspecifiedSequence us -> | UnspecifiedSequence us ->
let block = Cil.block_from_unspecified_sequence us in let block = Cil.block_from_unspecified_sequence us in
do_block control kinstr labels block; do_block control kinstr labels block;
control.dest control.dest
| Throw _ | TryCatch _ | TryFinally _ | TryExcept _ | Throw _ | TryCatch _ | TryFinally _ | TryExcept _
-> Kernel.not_yet_implemented ~source -> Kernel.not_yet_implemented
"[interpreted_automata] exception handling" "[interpreted_automata] exception handling"
in in
(* Update statement table *) (* Update statement table *)
assert (control.src.vertex_start_of = None); assert (control.src.vertex_start_of = None);
...@@ -540,9 +539,9 @@ let build_automaton ~annotations kf = ...@@ -540,9 +539,9 @@ let build_automaton ~annotations kf =
let bind label map = let bind label map =
try try
let vertex = match label with let vertex = match label with
| FormalLabel _ -> raise Not_found | FormalLabel _ -> raise Not_found
| BuiltinLabel _ -> LabelMap.find label annot.labels | BuiltinLabel _ -> LabelMap.find label annot.labels
| StmtLabel stmt -> snd (StmtTable.find table !stmt) | StmtLabel stmt -> snd (StmtTable.find table !stmt)
in in
LabelMap.add label vertex map LabelMap.add label vertex map
with Not_found -> map with Not_found -> map
...@@ -566,32 +565,32 @@ let build_automaton ~annotations kf = ...@@ -566,32 +565,32 @@ let build_automaton ~annotations kf =
(* ---------------------------------------------------------------------- *) (* ---------------------------------------------------------------------- *)
module Automaton = Datatype.Make module Automaton = Datatype.Make
(struct (struct
include Datatype.Serializable_undefined include Datatype.Serializable_undefined
type t = automaton type t = automaton
let reprs = [{ let reprs = [{
graph=G.create (); graph=G.create ();
entry_point=dummy_vertex; entry_point=dummy_vertex;
return_point=dummy_vertex; return_point=dummy_vertex;
stmt_table=StmtTable.create 0; stmt_table=StmtTable.create 0;
}] }]
let name = "Interpreted_automata.Automaton" let name = "Interpreted_automata.Automaton"
let copy automaton = let copy automaton =
{ {
automaton with automaton with
graph = G.copy automaton.graph; graph = G.copy automaton.graph;
stmt_table = StmtTable.copy automaton.stmt_table; stmt_table = StmtTable.copy automaton.stmt_table;
} }
let pretty : t Pretty_utils.formatter = fun fmt g -> let pretty : t Pretty_utils.formatter = fun fmt g ->
Pretty_utils.pp_iter G.iter_vertex ~pre:"@[" ~suf:"@]" ~sep:";@ " Pretty_utils.pp_iter G.iter_vertex ~pre:"@[" ~suf:"@]" ~sep:";@ "
(fun fmt v -> (fun fmt v ->
Format.fprintf fmt "@[<2>@[%a ->@]@ %a@]" Format.fprintf fmt "@[<2>@[%a ->@]@ %a@]"
Vertex.pretty v Vertex.pretty v
(Pretty_utils.pp_iter (fun f -> G.iter_succ f g.graph) ~sep:",@ " Vertex.pretty) (Pretty_utils.pp_iter (fun f -> G.iter_succ f g.graph) ~sep:",@ " Vertex.pretty)
v v
) )
fmt g.graph fmt g.graph
end) end)
(* ---------------------------------------------------------------------- *) (* ---------------------------------------------------------------------- *)
(* --- Weak Topological Order --- *) (* --- Weak Topological Order --- *)
...@@ -610,14 +609,14 @@ let build_wto ~pref {graph; entry_point} = ...@@ -610,14 +609,14 @@ let build_wto ~pref {graph; entry_point} =
module WTO = struct module WTO = struct
include Scheduler include Scheduler
include Datatype.Make include Datatype.Make
(struct (struct
include Datatype.Serializable_undefined include Datatype.Serializable_undefined
type t = wto type t = wto
let reprs = [List.map (fun s -> Wto.Node s) Vertex.reprs] let reprs = [List.map (fun s -> Wto.Node s) Vertex.reprs]
let pretty = Scheduler.pretty_partition let pretty = Scheduler.pretty_partition
let name = "Interpreted_automata.WTO" let name = "Interpreted_automata.WTO"
let copy w = w let copy w = w
end) end)
end end
(* ---------------------------------------------------------------------- *) (* ---------------------------------------------------------------------- *)
...@@ -626,10 +625,10 @@ end ...@@ -626,10 +625,10 @@ end
let exit_strategy graph component = let exit_strategy graph component =
let head, l = match component with let head, l = match component with
| Wto.Component (v, w) -> v, Wto.Node (v) :: w | Wto.Component (v, w) -> v, Wto.Node (v) :: w
| Wto.Node (v) -> v, [component] | Wto.Node (v) -> v, [component]
in in
(* Build a table of vertices that should not be passed through to get (* Build a table of vertices that should not be passed through to get
a path to an exit. At the begining it only contains the component head. *) a path to an exit. At the begining it only contains the component head. *)
let table = Hashtbl.create (G.nb_vertex graph) in let table = Hashtbl.create (G.nb_vertex graph) in
Hashtbl.add table head (); Hashtbl.add table head ();
...@@ -637,19 +636,19 @@ let exit_strategy graph component = ...@@ -637,19 +636,19 @@ let exit_strategy graph component =
let rec f acc = function let rec f acc = function
| [] -> acc | [] -> acc
| Wto.Node v :: l -> | Wto.Node v :: l ->
if List.for_all (Hashtbl.mem table) (G.succ graph v) then if List.for_all (Hashtbl.mem table) (G.succ graph v) then
(Hashtbl.add table v (); f acc l) (Hashtbl.add table v (); f acc l)
else else
f (Wto.Node v :: acc) l f (Wto.Node v :: acc) l
| Wto.Component (v, w) :: l -> | Wto.Component (v, w) :: l ->
let vertices = v :: Wto.flatten w in (* All vertices of the sub wto *) let vertices = v :: Wto.flatten w in (* All vertices of the sub wto *)
List.iter (fun v -> Hashtbl.add table v ()) vertices; (* Temporarilly add them *) List.iter (fun v -> Hashtbl.add table v ()) vertices; (* Temporarilly add them *)
let succs = List.flatten (List.map (G.succ graph) vertices) in let succs = List.flatten (List.map (G.succ graph) vertices) in
if List.for_all (Hashtbl.mem table) succs then if List.for_all (Hashtbl.mem table) succs then
f acc l f acc l
else ( else (
List.iter (Hashtbl.remove table) vertices; (* Undo *) List.iter (Hashtbl.remove table) vertices; (* Undo *)
f (Wto.Component (v, w) :: acc) l) f (Wto.Component (v, w) :: acc) l)
in in
f [] (List.rev l) f [] (List.rev l)
...@@ -670,17 +669,17 @@ let pretty_transition fmt t = ...@@ -670,17 +669,17 @@ let pretty_transition fmt t =
Pretty_utils.pp_list ~sep:", " Printer.pp_varinfo fmt l Pretty_utils.pp_list ~sep:", " Printer.pp_varinfo fmt l
in in
begin match t with begin match t with
| Skip -> () | Skip -> ()
| Return (None,_) -> fprintf fmt "return" | Return (None,_) -> fprintf fmt "return"
| Return (Some exp,_) -> fprintf fmt "return %a" Printer.pp_exp exp | Return (Some exp,_) -> fprintf fmt "return %a" Printer.pp_exp exp
| Guard (exp,Then,_) -> Printer.pp_exp fmt exp | Guard (exp,Then,_) -> Printer.pp_exp fmt exp
| Guard (exp,Else,_) -> fprintf fmt "!(%a)" Printer.pp_exp exp | Guard (exp,Else,_) -> fprintf fmt "!(%a)" Printer.pp_exp exp
| Prop (a,_) -> | Prop (a,_) ->
fprintf fmt "%a: %a" fprintf fmt "%a: %a"
pretty_kind a.kind Printer.pp_identified_predicate a.predicate pretty_kind a.kind Printer.pp_identified_predicate a.predicate
| Instr (instr,_) -> Printer.pp_instr fmt instr | Instr (instr,_) -> Printer.pp_instr fmt instr
| Enter (b) -> fprintf fmt "Enter %a" print_var_list b.blocals | Enter (b) -> fprintf fmt "Enter %a" print_var_list b.blocals
| Leave (b) -> fprintf fmt "Exit %a" print_var_list b.blocals | Leave (b) -> fprintf fmt "Exit %a" print_var_list b.blocals
end end
let pretty_edge fmt t = pretty_transition fmt t.edge_transition let pretty_edge fmt t = pretty_transition fmt t.edge_transition
...@@ -801,7 +800,7 @@ module WTOIndex = ...@@ -801,7 +800,7 @@ module WTOIndex =
let pretty i = let pretty i =
Pretty_utils.pp_list ~sep:"," Vertex.pretty i Pretty_utils.pp_list ~sep:"," Vertex.pretty i
let copy i = i let copy i = i
end) end)
module Compute = struct module Compute = struct
...@@ -870,23 +869,21 @@ end ...@@ -870,23 +869,21 @@ end
(* --- States --- *) (* --- States --- *)
(* ---------------------------------------------------------------------- *) (* ---------------------------------------------------------------------- *)
module AutomatonState = Kernel_function.Make_Table (Automaton) module AutomatonState = Kernel_function.Make_Table (Automaton)
(struct (struct
let size = 97 let size = 97
let name = "Interpreted_automata.AutomatonState" let name = "Interpreted_automata.AutomatonState"
let dependencies = [Ast.self] let dependencies = [Ast.self]
end) end)
let get_automaton = AutomatonState.memo (build_automaton ~annotations:false) let get_automaton = AutomatonState.memo (build_automaton ~annotations:false)
module WTOState = Kernel_function.Make_Table (WTO) module WTOState = Kernel_function.Make_Table (WTO)
(struct (struct
let size = 97 let size = 97
let name = "Interpreted_automata.WTOState" let name = "Interpreted_automata.WTOState"
let dependencies = [Ast.self] let dependencies = [Ast.self]
end) end)
let get_wto = let get_wto =
let build kf = let build kf =
...@@ -910,7 +907,7 @@ module WTOIndexState = ...@@ -910,7 +907,7 @@ module WTOIndexState =
let size = 97 let size = 97
let name = "Interpreted_automata.WTOIndexState" let name = "Interpreted_automata.WTOIndexState"
let dependencies = [Ast.self] let dependencies = [Ast.self]
end) end)
let build_wto_index_table kf = Compute.build_wto_index_table (get_wto kf) let build_wto_index_table kf = Compute.build_wto_index_table (get_wto kf)
...@@ -935,9 +932,9 @@ module UnrollUnnatural = struct ...@@ -935,9 +932,9 @@ module UnrollUnnatural = struct
include Datatype.Make_with_collections(struct include Datatype.Make_with_collections(struct
include Datatype.Undefined include Datatype.Undefined
include Vertex.Set include Vertex.Set
let name = "Interpreted_automata.OnlyHead.Vertex_Set" let name = "Interpreted_automata.OnlyHead.Vertex_Set"
let pretty fmt m = Pretty_utils.pp_iter ~sep:",@ " Vertex.Set.iter Vertex.pretty fmt m let pretty fmt m = Pretty_utils.pp_iter ~sep:",@ "
Vertex.Set.iter Vertex.pretty fmt m
let reprs = [Vertex.Set.empty] let reprs = [Vertex.Set.empty]
end) end)
...@@ -967,18 +964,17 @@ module UnrollUnnatural = struct ...@@ -967,18 +964,17 @@ module UnrollUnnatural = struct
module OldG = G module OldG = G
module G = struct module G = struct
include Graph.Imperative.Digraph.ConcreteBidirectionalLabeled (Version) include
(Edge) Graph.Imperative.Digraph.ConcreteBidirectionalLabeled(Version)(Edge)
let pretty : t Pretty_utils.formatter = fun fmt g -> let pretty : t Pretty_utils.formatter = fun fmt g ->
Pretty_utils.pp_iter iter_vertex ~pre:"@[" ~suf:"@]" ~sep:";@ " Pretty_utils.pp_iter iter_vertex ~pre:"@[" ~suf:"@]" ~sep:";@ "
(fun fmt v -> (fun fmt v ->
Format.fprintf fmt "@[<2>@[%a ->@]@ %a@]" Format.fprintf fmt "@[<2>@[%a ->@]@ %a@]"
Version.pretty v Version.pretty v
(Pretty_utils.pp_iter (fun f -> iter_succ f g) ~sep:",@ " Version.pretty) (Pretty_utils.pp_iter
v (fun f -> iter_succ f g) ~sep:",@ " Version.pretty) v
) ) fmt g
fmt g
end end
module WTO = struct module WTO = struct
...@@ -996,7 +992,10 @@ module UnrollUnnatural = struct ...@@ -996,7 +992,10 @@ module UnrollUnnatural = struct
module GDot = module GDot =
MakeDot(struct include Version let start_of (v,_) = v.vertex_start_of end)(G) MakeDot(struct
include Version
let start_of (v,_) = v.vertex_start_of
end)(G)
let output_to_dot out_channel ?number ?wto g = let output_to_dot out_channel ?number ?wto g =
GDot.output_to_dot out_channel ?number ?wto g GDot.output_to_dot out_channel ?number ?wto g
...@@ -1027,8 +1026,10 @@ module UnrollUnnatural = struct ...@@ -1027,8 +1026,10 @@ module UnrollUnnatural = struct
let labels = LabelMap.map (fun v2 -> let labels = LabelMap.map (fun v2 ->
let v2l = Compute.get_wto_index index v2 in let v2l = Compute.get_wto_index index v2 in
let d1,d2 = Compute.wto_index_diff nl v2l in let d1,d2 = Compute.wto_index_diff nl v2l in
let version2 = List.fold_left (fun acc e -> Vertex.Set.remove e acc) version d1 in let version2 = List.fold_left
let version2 = List.fold_left (fun acc e -> Vertex.Set.add e acc) version2 d2 in (fun acc e -> Vertex.Set.remove e acc) version d1 in
let version2 = List.fold_left
(fun acc e -> Vertex.Set.add e acc) version2 d2 in
let version2 = Vertex.Set.remove v2 version2 in let version2 = Vertex.Set.remove v2 version2 in
(v2,version2) (v2,version2)
) a.labels in ) a.labels in
...@@ -1044,8 +1045,10 @@ module UnrollUnnatural = struct ...@@ -1044,8 +1045,10 @@ module UnrollUnnatural = struct
OldG.iter_succ_e (fun (_,e,v2) -> OldG.iter_succ_e (fun (_,e,v2) ->
let v2l = Compute.get_wto_index index v2 in let v2l = Compute.get_wto_index index v2 in
let d1,d2 = Compute.wto_index_diff nl v2l in let d1,d2 = Compute.wto_index_diff nl v2l in
let version2 = List.fold_left (fun acc e -> Vertex.Set.remove e acc) version d1 in let version2 = List.fold_left
let version2 = List.fold_left (fun acc e -> Vertex.Set.add e acc) version2 d2 in (fun acc e -> Vertex.Set.remove e acc) version d1 in
let version2 = List.fold_left
(fun acc e -> Vertex.Set.add e acc) version2 d2 in
let version2 = Vertex.Set.remove v2 version2 in let version2 = Vertex.Set.remove v2 version2 in
let e = convert_edge nl version e in let e = convert_edge nl version e in
G.add_edge_e g' (n',e,(v2,version2)); G.add_edge_e g' (n',e,(v2,version2));
...@@ -1078,7 +1081,6 @@ module UnrollUnnatural = struct ...@@ -1078,7 +1081,6 @@ module UnrollUnnatural = struct
end end
(* ---------------------------------------------------------------------- *) (* ---------------------------------------------------------------------- *)
(* --- Dataflow computation --- *) (* --- Dataflow computation --- *)
(* ---------------------------------------------------------------------- *) (* ---------------------------------------------------------------------- *)
...@@ -1161,4 +1163,3 @@ struct ...@@ -1161,4 +1163,3 @@ struct
iterate_list wto; iterate_list wto;
results results
end end
...@@ -97,9 +97,9 @@ val pretty_edge: vertex edge Pretty_utils.formatter ...@@ -97,9 +97,9 @@ val pretty_edge: vertex edge Pretty_utils.formatter
module G : Graph.Sig.I module G : Graph.Sig.I
with type V.t = vertex with type V.t = vertex
and type E.t = vertex * vertex edge * vertex and type E.t = vertex * vertex edge * vertex
and type V.label = vertex and type V.label = vertex
and type E.label = vertex edge and type E.label = vertex edge
type graph = G.t type graph = G.t
...@@ -134,7 +134,7 @@ module WTO : sig ...@@ -134,7 +134,7 @@ module WTO : sig
include Datatype.S with type t = wto include Datatype.S with type t = wto
end end
(** Get the interpreted automaton for the given kernel_function without annotations *) (** Get the automaton for the given kernel_function without annotations *)
val get_automaton : Cil_types.kernel_function -> automaton val get_automaton : Cil_types.kernel_function -> automaton
(** Get the wto for the automaton of the given kernel_function *) (** Get the wto for the automaton of the given kernel_function *)
val get_wto : Cil_types.kernel_function -> wto val get_wto : Cil_types.kernel_function -> wto
...@@ -142,10 +142,10 @@ val get_wto : Cil_types.kernel_function -> wto ...@@ -142,10 +142,10 @@ val get_wto : Cil_types.kernel_function -> wto
vertices lead outside the wto without passing through the head. *) vertices lead outside the wto without passing through the head. *)
val exit_strategy : graph -> vertex Wto.component -> wto val exit_strategy : graph -> vertex Wto.component -> wto
(** Output the automaton in dot format *) (** Output the automaton in dot format *)
val output_to_dot : out_channel -> ?number:[`Stmt|`Vertex] -> ?wto:wto -> automaton -> unit val output_to_dot : out_channel -> ?number:[`Stmt|`Vertex] -> ?wto:wto ->
automaton -> unit
(** the position of a statement in a wto given as the list of
(** the position of a statement in a wto given as the list of
component heads *) component heads *)
type wto_index = vertex list type wto_index = vertex list
...@@ -187,7 +187,8 @@ module Compute: sig ...@@ -187,7 +187,8 @@ module Compute: sig
vertices lead outside the wto without passing through the head. *) vertices lead outside the wto without passing through the head. *)
val exit_strategy : graph -> vertex Wto.component -> wto val exit_strategy : graph -> vertex Wto.component -> wto
(** Output the automaton in dot format *) (** Output the automaton in dot format *)
val output_to_dot : out_channel -> ?number:[`Stmt|`Vertex] -> ?wto:wto -> automaton -> unit val output_to_dot : out_channel -> ?number:[`Stmt|`Vertex] -> ?wto:wto ->
automaton -> unit
type wto_index_table type wto_index_table
...@@ -219,9 +220,10 @@ end ...@@ -219,9 +220,10 @@ end
module UnrollUnnatural : sig module UnrollUnnatural : sig
(** Could enter a loop only by head nodes *) (** Could enter a loop only by head nodes *)
module Vertex_Set:
module Vertex_Set : Datatype.S_with_collections with type t = Vertex.Set.t Datatype.S_with_collections with type t = Vertex.Set.t
module Version :Datatype.S_with_collections with type t = Vertex.t * Vertex.Set.t module Version:
Datatype.S_with_collections with type t = Vertex.t * Vertex.Set.t
module G : sig module G : sig
include Graph.Sig.I include Graph.Sig.I
...@@ -277,4 +279,3 @@ module Dataflow (D : Domain) : ...@@ -277,4 +279,3 @@ module Dataflow (D : Domain) :
sig sig
val fixpoint : Cil_types.kernel_function -> D.t -> D.t Vertex.Hashtbl.t val fixpoint : Cil_types.kernel_function -> D.t -> D.t Vertex.Hashtbl.t
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment