On Thu, May 19, 2016 at 12:44 PM, marxin <mli...@suse.cz> wrote: > Leak can be seen e.g. here: > gcc i386/mvc6.c -fno-diagnostics-show-caret -fdiagnostics-color=never -O3
Ok. Richard. > gcc/ChangeLog: > > 2016-05-18 Martin Liska <mli...@suse.cz> > > * ipa-pure-const.c (set_function_state): Remove an existing > funct_state. > (remove_node_data): Do not free it as it's released > in set_function_state. > --- > gcc/ipa-pure-const.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/gcc/ipa-pure-const.c b/gcc/ipa-pure-const.c > index ba76275..a9570e4 100644 > --- a/gcc/ipa-pure-const.c > +++ b/gcc/ipa-pure-const.c > @@ -258,6 +258,13 @@ set_function_state (struct cgraph_node *node, > funct_state s) > if (!funct_state_vec.exists () > || funct_state_vec.length () <= (unsigned int)node->uid) > funct_state_vec.safe_grow_cleared (node->uid + 1); > + > + /* If funct_state_vec already contains a funct_state, we have to release > + it before it's going to be ovewritten. */ > + if (funct_state_vec[node->uid] != NULL > + && funct_state_vec[node->uid] != &varying_state) > + free (funct_state_vec[node->uid]); > + > funct_state_vec[node->uid] = s; > } > > @@ -956,12 +963,7 @@ static void > remove_node_data (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED) > { > if (has_function_state (node)) > - { > - funct_state l = get_function_state (node); > - if (l != &varying_state) > - free (l); > - set_function_state (node, NULL); > - } > + set_function_state (node, NULL); > } > > > -- > 2.8.2 > >