From 1f9487075c965b53666a478e2d1d505cb18cd9b4 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 17 Mar 2026 15:27:38 +0100 Subject: [PATCH] Fix leak of edge vector in IPA CP The following makes gather_edges_for_value return an auto_vec, simplifying the single caller decide_about_value and fixing the leak of the callers vector upon early return. * ipa-cp.cc (gather_edges_for_value): Return an auto_vec. (decide_about_value): Simplify, fixing leak of callers. --- gcc/ipa-cp.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index 4765ef972b9..e96b1dc8391 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -4454,14 +4454,13 @@ adjust_callers_for_value_intersection (vec &callers, is assumed their number is known and equal to CALLER_COUNT. */ template -static vec +static auto_vec gather_edges_for_value (ipcp_value *val, cgraph_node *dest, int caller_count) { ipcp_value_source *src; - vec ret; + auto_vec ret (caller_count); - ret.create (caller_count); for (src = val->sources; src; src = src->next) { struct cgraph_edge *cs = src->cs; @@ -6005,8 +6004,8 @@ decide_about_value (struct cgraph_node *node, int index, HOST_WIDE_INT offset, fprintf (dump_file, " (caller_count: %i)\n", caller_count); } - vec callers; - callers = gather_edges_for_value (val, node, caller_count); + auto_vec callers + = gather_edges_for_value (val, node, caller_count); ipa_node_params *info = ipa_node_params_sum->get (node); ipa_auto_call_arg_values avals; avals.m_known_vals.safe_grow_cleared (ipa_get_param_count (info), true); @@ -6085,7 +6084,6 @@ decide_about_value (struct cgraph_node *node, int index, HOST_WIDE_INT offset, else update_profiling_info (node, val->spec_node); - callers.release (); overall_size += val->local_size_cost; if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, " overall size reached %li\n",