From f27cd6f42261e838677dfd0652f09cc0dfd6a42b Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 19 Jan 2021 13:40:39 +0100 Subject: [PATCH] middle-end/98638 - avoid SSA reference to stmts after SSA deconstruction 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. 2021-01-19 Richard Biener 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 --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)); -- 2.30.2