diff mbox series

middle-end/98638 - avoid SSA reference to stmts after SSA deconstruction

Message ID nycvar.YFH.7.76.2101191431540.16635@elmra.sevgm.obk
State New
Headers show
Series middle-end/98638 - avoid SSA reference to stmts after SSA deconstruction | expand

Commit Message

Richard Biener Jan. 19, 2021, 1:32 p.m. UTC
Since SSA names do leak into global tree data structures like
TYPE_SIZE or in this case GFC_DECL_SAVED_DESCRIPTOR because of
frontend bugs we have to be careful to wipe references to the
CFG when we deconstruct SSA form because we now do ggc_free that.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

2021-01-19  Richard Biener  <rguenther@suse.de>

	PR middle-end/98638
	* tree-ssanames.c (fini_ssanames): Zero SSA_NAME_DEF_STMT.
---
 gcc/tree-ssanames.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/gcc/tree-ssanames.c b/gcc/tree-ssanames.c
index c293cc44189..51a26d2fce1 100644
--- a/gcc/tree-ssanames.c
+++ b/gcc/tree-ssanames.c
@@ -102,6 +102,14 @@  init_ssanames (struct function *fn, int size)
 void
 fini_ssanames (struct function *fn)
 {
+  unsigned i;
+  tree name;
+  /* Some SSA names leak into global tree data structures so we can't simply
+     ggc_free them.  But make sure to clear references to stmts since we now
+     ggc_free the CFG itself.  */
+  FOR_EACH_VEC_SAFE_ELT (SSANAMES (fn), i, name)
+    if (name)
+      SSA_NAME_DEF_STMT (name) = NULL;
   vec_free (SSANAMES (fn));
   vec_free (FREE_SSANAMES (fn));
   vec_free (FREE_SSANAMES_QUEUE (fn));