From 15c1f816dc41db536f09e707af3b5f1988ab12ef Mon Sep 17 00:00:00 2001 From: Sungkeun Cho Date: Thu, 29 Oct 2020 03:06:58 -0700 Subject: [PATCH] [cost] Check if callee is actually defined Summary: The autorelease pool size checker increases the size when an non-arc-compiled function calls arc-compiled function. However, if the callee is declared in arc-compiled code and its body is not actually captured or compiled, we should not increase the autorelease pool size. Reviewed By: ezgicicek Differential Revision: D24569661 fbshipit-source-id: 2fd707096 --- infer/src/cost/cost.ml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/infer/src/cost/cost.ml b/infer/src/cost/cost.ml index c32d7631d..38877648b 100644 --- a/infer/src/cost/cost.ml +++ b/infer/src/cost/cost.ml @@ -23,6 +23,7 @@ type extras_WorstCaseCost = ; get_node_nb_exec: Node.t -> BasicCost.t ; get_summary: Procname.t -> CostDomain.summary option ; get_formals: Procname.t -> (Pvar.t * Typ.t) list option + ; get_proc_desc: Procname.t -> Procdesc.t option ; proc_resolve_attributes: Procname.t -> ProcAttributes.t option } let instantiate_cost ?get_closure_callee_cost ~default_closure_cost integer_type_widths @@ -54,10 +55,11 @@ module InstrBasicCostWithReason = struct List.exists prefixes ~f:(fun prefix -> String.is_prefix method_name ~prefix) - let is_objc_call_from_no_arc_to_arc {proc_resolve_attributes} caller_pdesc callee_pname = - (not (Procdesc.is_objc_arc_on caller_pdesc)) - && Option.exists (proc_resolve_attributes callee_pname) - ~f:(fun {ProcAttributes.is_objc_arc_on} -> is_objc_arc_on) + let is_objc_call_from_no_arc_to_arc {get_proc_desc} caller_pdesc callee_pname = + Option.exists (get_proc_desc callee_pname) ~f:(fun callee_pdesc -> + Procdesc.is_defined callee_pdesc + && (not (Procdesc.is_objc_arc_on caller_pdesc)) + && Procdesc.is_objc_arc_on callee_pdesc ) let dispatch_operation tenv callee_pname callee_cost_opt fun_arg_list model_env ret inferbo_mem = @@ -400,6 +402,7 @@ let checker ({InterproceduralAnalysis.proc_desc; exe_env; analyze_dependency} as ; get_node_nb_exec ; get_summary ; get_formals + ; get_proc_desc= AnalysisCallbacks.get_proc_desc ; proc_resolve_attributes= AnalysisCallbacks.proc_resolve_attributes } in AnalysisCallbacks.html_debug_new_node_session (NodeCFG.start_node node_cfg)