@@ -2953,7 +2953,7 @@ struct
2953
2953
module AddrPairSet = Set. Make (AddrPair )
2954
2954
2955
2955
(* * In the given local state, from the start state, find the addresses that correspond to the goals *)
2956
- let collect_targets_with_graph ctx (graph : Graph.t ) (args : exp list ) (params : varinfo list ) (goal : AD.t ) =
2956
+ let collect_targets_with_graph ctx (graph : Graph.t ) (args : exp list ) (params : varinfo list ) (globals : varinfo list ) ( goal : AD.t ) =
2957
2957
let ask = Analyses. ask_of_ctx ctx in
2958
2958
2959
2959
(* TODO: !! Pass addresses instead of params, or, alternatively, pass global variables separetely, as they should be !! *)
@@ -2994,6 +2994,16 @@ struct
2994
2994
) dir_reachable_abs;
2995
2995
) combined;
2996
2996
2997
+ (* Add globals *)
2998
+ let add_global_to_queue (g : varinfo ) =
2999
+ let a_c = Addr. of_var ~is_modular: false g in
3000
+ let a = Addr. of_var ~is_modular: true g in
3001
+
3002
+ Queue. add (a_c, a) queue;
3003
+ visited := AddrPairSet. add (a_c, a) ! visited;
3004
+ in
3005
+ List. iter add_global_to_queue globals;
3006
+
2997
3007
(* M.tracel "modular_combine" "Initalized conc: %a\n" (d_list ", " ADOffsetMap.pretty) (List.map Tuple2.first combined);
2998
3008
M.tracel "modular_combine" "Initalized abs: %a\n" (d_list ", " ADOffsetMap.pretty) (List.map Tuple2.second combined);
2999
3009
M.tracel "modular_combine" "graph: %a\n" Graph.pretty graph; *)
@@ -3021,14 +3031,15 @@ struct
3021
3031
let combine_env_modular ctx lval fexp f args fc au (f_ask : Queries.ask ) =
3022
3032
let ask = Analyses. ask_of_ctx ctx in
3023
3033
let glob_fun = modular_glob_fun ctx in
3024
- let callee_globals_exp = UsedGlobals. get_used_globals f_ask in
3034
+ (* let callee_globals_exp = UsedGlobals.get_used_globals f_ask in *)
3025
3035
let callee_globals = UsedGlobals. get_used_globals f_ask in
3026
- let callee_globals = List. map (fun v -> Lval (Var v, NoOffset )) callee_globals in
3036
+ (* let callee_globals = List.map (fun v -> Lval (Var v, NoOffset)) callee_globals in *)
3027
3037
3028
- let effective_params = f.sformals @ callee_globals_exp in
3029
- let effective_args = args @ callee_globals in
3038
+ let params = f.sformals in
3039
+ (* let effective_params = params in
3040
+ let effective_args = args in *)
3030
3041
3031
- M. tracel " modular_combine" " effective_params: %a\n effective_args: %a\n " (d_list " , " CilType.Varinfo. pretty) effective_params (d_list " , " CilType.Exp. pretty) effective_args;
3042
+ (* M.tracel "modular_combine" "effective_params: %a\n effective_args: %a\n" (d_list ", " Addr. pretty) params (d_list ", " CilType.Exp.pretty) effective_args; *)
3032
3043
(* TODO: Use information from Read and Written graphs to determine subset of reachable that is reachable via arguments like provided in the graph. *)
3033
3044
(*
3034
3045
let reachable = collect_funargs ask ~warn:false glob_fun ctx.local effective_args in
@@ -3043,12 +3054,9 @@ struct
3043
3054
else
3044
3055
(* TODO: Use information from Read and Written graphs to determine subset of reachable that is reachable via arguments like provided in the graph. *)
3045
3056
let write_graph = ask.f (WriteGraph f) in
3046
- let read_graph = ask.f (ReadGraph f) in
3047
-
3048
- let write_graph = Graph. join write_graph read_graph in
3049
3057
3050
3058
(* TODO: pass goal, use goal in collect_targets_with_graph function*)
3051
- let reachable = collect_targets_with_graph ctx write_graph effective_args effective_params (AD. bot () ) in
3059
+ let reachable = collect_targets_with_graph ctx write_graph args params callee_globals (AD. bot () ) in
3052
3060
3053
3061
M. tracel " modular_combine_reachable" " reachable: %a\n " AD. pretty reachable;
3054
3062
let vars_to_writes : value_map VarMap.t =
@@ -3106,17 +3114,12 @@ struct
3106
3114
combine_env_regular ctx lval fexp f args fc au f_ask
3107
3115
3108
3116
let translate_callee_value_back ctx f f_ask (args : exp list ) (value : VD.t ): VD.t =
3109
- let glob_fun = modular_glob_fun ctx in
3110
3117
let ask = Analyses. ask_of_ctx ctx in
3111
-
3112
- (* TODO: Is write-graph for return value computation? *)
3113
3118
let write_graph = ask.f (WriteGraph f) in
3114
- let read_graph = ask.f (ReadGraph f) in
3115
- let write_graph = Graph. join write_graph read_graph in
3116
3119
(* TODO: pass goal, use goal in collect_targets_with_graph function*)
3117
3120
let callee_globals = UsedGlobals. get_used_globals f_ask in
3118
- let effective_params = f.sformals @ callee_globals in
3119
- let reachable = collect_targets_with_graph ctx write_graph args effective_params (AD. bot () ) in
3121
+ let params = f.sformals in
3122
+ let reachable = collect_targets_with_graph ctx write_graph args params callee_globals (AD. bot () ) in
3120
3123
let value = ModularUtil.ValueDomainExtension. map_back value ~reachable in
3121
3124
value
3122
3125
@@ -3129,10 +3132,7 @@ struct
3129
3132
else VD. top ()
3130
3133
in
3131
3134
let return_val = if is_callee_modular ~ask: (Analyses. ask_of_ctx ctx) ~callee: f then
3132
- let callee_globals = UsedGlobals. get_used_globals_exps f_ask in
3133
- (* let effective_args = args @ callee_globals in *)
3134
- let effective_args = args @ callee_globals in
3135
- translate_callee_value_back ctx f f_ask effective_args return_val
3135
+ translate_callee_value_back ctx f f_ask args return_val
3136
3136
else
3137
3137
return_val
3138
3138
in
0 commit comments