This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Fix leaks on ipa_transform_to_apply, struct function and gimple bodies
> > + /* Struct function hangs a lot of data that would leak if we didn't
> > + removed all pointers to it. */
> > + ggc_free (DECL_STRUCT_FUNCTION (node->decl));
> > + DECL_STRUCT_FUNCTION (node->decl) = NULL;
>
> I don't think it is safe to call gcc_free here since other data structure
> may point to it.
There should be precisely one pointer to struct function or we have
quite important memory leak (as I tried to explain in the comment just
before the call). The struct function will keep alive the whole
functionbody.
In this case it is template instantiation copying whole declaration
keeping DECL_STRUCT_FUNCTION shared that might have quite interesting
effects elsewhere too. This is what I am testing and will commit as
obvious if it passes.
Index: cp/pt.c
===================================================================
--- cp/pt.c (revision 140324)
+++ cp/pt.c (working copy)
@@ -8179,6 +8179,7 @@ tsubst_decl (tree t, tree args, tsubst_f
DECL_PENDING_INLINE_INFO (r) = 0;
DECL_PENDING_INLINE_P (r) = 0;
DECL_SAVED_TREE (r) = NULL_TREE;
+ DECL_STRUCT_FUNCTION (r) = NULL;
TREE_USED (r) = 0;
if (DECL_CLONED_FUNCTION (r))
{
>
> --
> H.J.