Skip to content
Snippets Groups Projects
Commit f6ef864d authored by David Bühler's avatar David Bühler
Browse files

[Eva] Iterator: save results according to [Function_calls.define_analysis_target].

parent f5f06beb
No related branches found
No related tags found
No related merge requests found
...@@ -212,8 +212,8 @@ module Make (Abstract: Abstractions.Eva) = struct ...@@ -212,8 +212,8 @@ module Make (Abstract: Abstractions.Eva) = struct
(* Interprets a [call] at callsite [kinstr] in the state [state] by analyzing (* Interprets a [call] at callsite [kinstr] in the state [state] by analyzing
the body of the called function. *) the body of the called function. *)
let compute_using_body fundec kinstr call state = let compute_using_body fundec ~save_results kinstr call state =
let result = Computer.compute call.kf kinstr state in let result = Computer.compute ~save_results call.kf kinstr state in
Summary.FunctionStats.recompute fundec; Summary.FunctionStats.recompute fundec;
result result
...@@ -246,8 +246,10 @@ module Make (Abstract: Abstractions.Eva) = struct ...@@ -246,8 +246,10 @@ module Make (Abstract: Abstractions.Eva) = struct
let call_stack = Eva_utils.call_stack () in let call_stack = Eva_utils.call_stack () in
let compute, kind = let compute, kind =
match target with match target with
| `Def (fundec, _) -> compute_using_body fundec, `Def | `Def (fundec, save_results) ->
| `Spec funspec -> compute_using_spec funspec, `Spec funspec compute_using_body fundec ~save_results, `Def
| `Spec funspec ->
compute_using_spec funspec, `Spec funspec
in in
Db.Value.Call_Type_Value_Callbacks.apply (kind, cvalue_state, call_stack); Db.Value.Call_Type_Value_Callbacks.apply (kind, cvalue_state, call_stack);
let resulting_states, cacheable = compute kinstr call state in let resulting_states, cacheable = compute kinstr call state in
......
...@@ -25,7 +25,8 @@ open Cil_types ...@@ -25,7 +25,8 @@ open Cil_types
(** What is used for the analysis of a given function: (** What is used for the analysis of a given function:
- a Cvalue builtin (and other domains use the specification) - a Cvalue builtin (and other domains use the specification)
- the function specification - the function specification
- the function body. *) - the function body. The boolean indicates whether the resulting states
must be recorded at each statement of this function. *)
type analysis_target = type analysis_target =
[ `Builtin of string * Builtins.builtin * Eval.cacheable * funspec [ `Builtin of string * Builtins.builtin * Eval.cacheable * funspec
| `Spec of Cil_types.funspec | `Spec of Cil_types.funspec
......
...@@ -667,7 +667,7 @@ module Make_Dataflow ...@@ -667,7 +667,7 @@ module Make_Dataflow
); );
states_after states_after
let merge_results () = let merge_results ~save_results =
let get_merged_states = let get_merged_states =
let merged_states = VertexTable.create control_point_count let merged_states = VertexTable.create control_point_count
and get_smashed_store v = and get_smashed_store v =
...@@ -700,7 +700,7 @@ module Make_Dataflow ...@@ -700,7 +700,7 @@ module Make_Dataflow
let merged_pre_cvalues = lazy (lift_to_cvalues merged_pre_states) let merged_pre_cvalues = lazy (lift_to_cvalues merged_pre_states)
and merged_post_cvalues = lazy (lift_to_cvalues merged_post_states) in and merged_post_cvalues = lazy (lift_to_cvalues merged_post_states) in
let callstack = Eva_utils.call_stack () in let callstack = Eva_utils.call_stack () in
if Mark_noresults.should_memorize_function fundec then begin if save_results then begin
let register_pre = Domain.Store.register_state_before_stmt callstack let register_pre = Domain.Store.register_state_before_stmt callstack
and register_post = Domain.Store.register_state_after_stmt callstack in and register_post = Domain.Store.register_state_after_stmt callstack in
StmtTable.iter register_pre (Lazy.force merged_pre_states); StmtTable.iter register_pre (Lazy.force merged_pre_states);
...@@ -762,7 +762,7 @@ module Computer ...@@ -762,7 +762,7 @@ module Computer
end) end)
= struct = struct
let compute kf call_kinstr state = let compute ~save_results kf call_kinstr state =
let module Dataflow = let module Dataflow =
Make_Dataflow Make_Dataflow
(Abstract) (States) (Transfer) (Init) (Logic) (Spec) (Abstract) (States) (Transfer) (Init) (Logic) (Spec)
...@@ -778,7 +778,7 @@ module Computer ...@@ -778,7 +778,7 @@ module Computer
if Parameters.ValShowProgress.get () then if Parameters.ValShowProgress.get () then
Self.feedback "Recording results for %a" Self.feedback "Recording results for %a"
Kernel_function.pretty kf; Kernel_function.pretty kf;
Dataflow.merge_results (); Dataflow.merge_results ~save_results;
let f = Kernel_function.get_definition kf in let f = Kernel_function.get_definition kf in
if Cil.hasAttribute "noreturn" f.svar.vattr && results <> [] then if Cil.hasAttribute "noreturn" f.svar.vattr && results <> [] then
Eva_utils.warning_once_current Eva_utils.warning_once_current
...@@ -788,7 +788,7 @@ module Computer ...@@ -788,7 +788,7 @@ module Computer
in in
let cleanup () = let cleanup () =
Dataflow.mark_degeneration (); Dataflow.mark_degeneration ();
Dataflow.merge_results () Dataflow.merge_results ~save_results
in in
Eva_utils.protect compute ~cleanup Eva_utils.protect compute ~cleanup
end end
......
...@@ -44,6 +44,7 @@ module Computer ...@@ -44,6 +44,7 @@ module Computer
: sig : sig
val compute: val compute:
save_results:bool ->
kernel_function -> kinstr -> Abstract.Dom.t -> kernel_function -> kinstr -> Abstract.Dom.t ->
(Partition.key * Abstract.Dom.t) list * Eval.cacheable (Partition.key * Abstract.Dom.t) list * Eval.cacheable
......
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