@ -79,16 +79,7 @@ let model_satisfies ~f tenv pname =
InvariantModels . ProcName . dispatch tenv pname | > Option . exists ~ f
InvariantModels . ProcName . dispatch tenv pname | > Option . exists ~ f
let get_issue_to_report tenv Call . ( { pname ; node ; params } ) integer_type_widths inferbo_invariant_map
let is_call_expensive Call . ( { pname ; node ; params } ) integer_type_widths inferbo_invariant_map =
=
(* If a function is modeled as variant for hoisting ( like
List . size or _ _ cast ) , we don't want to report it * )
let is_variant_for_hoisting =
model_satisfies ~ f : InvariantModels . is_variant_for_hoisting tenv pname
in
let report_invariant =
( ( not is_variant_for_hoisting ) && not Config . hoisting_report_only_expensive )
| |
(* only report if function call has expensive/symbolic cost *)
(* only report if function call has expensive/symbolic cost *)
match Ondemand . analyze_proc_name pname with
match Ondemand . analyze_proc_name pname with
| Some ( { Summary . payloads = { Payloads . cost = Some { CostDomain . post = cost_record } } } as summary )
| Some ( { Summary . payloads = { Payloads . cost = Some { CostDomain . post = cost_record } } } as summary )
@ -102,13 +93,26 @@ let get_issue_to_report tenv Call.({pname; node; params}) integer_type_widths in
let callee_formals = Summary . get_proc_desc summary | > Procdesc . get_pvar_formals in
let callee_formals = Summary . get_proc_desc summary | > Procdesc . get_pvar_formals in
let loc = InstrCFG . Node . loc last_node in
let loc = InstrCFG . Node . loc last_node in
(* get the cost of the function call *)
(* get the cost of the function call *)
Cost . instantiate_cost integer_type_widths ~ inferbo_caller_mem : inferbo_mem
Cost . instantiate_cost integer_type_widths ~ inferbo_caller_mem : inferbo_mem ~ callee_pname : pname
~ callee_pname : pname ~ callee_formals ~ params
~ callee_formals ~ params
~ callee_cost : ( CostDomain . get_operation_cost cost_record )
~ callee_cost : ( CostDomain . get_operation_cost cost_record )
~ loc
~ loc
| > CostDomain . BasicCost . is_symbolic
| > CostDomain . BasicCost . is_symbolic
| _ ->
| _ ->
false
false
let get_issue_to_report tenv ( Call . ( { pname } ) as call ) integer_type_widths inferbo_invariant_map =
let report_invariant =
if Config . hoisting_report_only_expensive then
is_call_expensive call integer_type_widths inferbo_invariant_map
else
(* If a function is modeled as variant for hoisting ( like
List . size or _ _ cast ) , we don't want to report it * )
let is_variant_for_hoisting =
model_satisfies ~ f : InvariantModels . is_variant_for_hoisting tenv pname
in
not is_variant_for_hoisting
in
in
if report_invariant then
if report_invariant then
if model_satisfies ~ f : InvariantModels . is_invariant tenv pname then
if model_satisfies ~ f : InvariantModels . is_invariant tenv pname then