public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Do not keep SFTs with their parent var GCed in referenced  vars
@ 2007-11-05 15:54 Richard Guenther
  0 siblings, 0 replies; only message in thread
From: Richard Guenther @ 2007-11-05 15:54 UTC (permalink / raw)
  To: gcc-patches


We currently do never remove MTAGs from the referenced_vars hashtable, but
happily remove variables that have subvars (which includes ggc_freeing
their variable annotation which hold on the SFTs).  This leads to the
interesting situation where the referenced_vars hashtable contains SFTs
that have GCed SFT_PARENT_VARs.  Not good.

The solution is to also remove all SFTs from the referenced_vars hashtable
whenever removing the parent var.

Bootstrapped and tested on x86_64-unknown-linux-gnu.  I'll apply this 
later if there are no objections.

Richard.

2007-11-05  Richard Guenther  <rguenther@suse.de>

	* tree-dfa.c (remove_referenced_var): If removing a
	variable which has subvars, also remove those from
	the referenced vars.  Do not create a variable annotation.

Index: gcc/tree-dfa.c
===================================================================
--- gcc/tree-dfa.c	(revision 129884)
+++ gcc/tree-dfa.c	(working copy)
@@ -751,10 +751,22 @@ remove_referenced_var (tree var)
   struct tree_decl_minimal in;
   void **loc;
   unsigned int uid = DECL_UID (var);
+  subvar_t sv;
+
+  /* If we remove a var, we should also remove its subvars, as we kill
+     their parent var and its annotation.  */
+  if (var_can_have_subvars (var)
+      && (sv = get_subvars_for_var (var)))
+    {
+      unsigned int i;
+      tree subvar;
+      for (i = 0; VEC_iterate (tree, sv, i, subvar); ++i)
+        remove_referenced_var (subvar);
+    }
 
   clear_call_clobbered (var);
-  v_ann = get_var_ann (var);
-  ggc_free (v_ann);
+  if ((v_ann = var_ann (var)))
+    ggc_free (v_ann);
   var->base.ann = NULL;
   gcc_assert (DECL_P (var));
   in.uid = uid;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-11-05 15:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-05 15:54 [PATCH] Do not keep SFTs with their parent var GCed in referenced vars Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).