From 0718336a5284dd5b40fd6691a94d6be93a80f279 Mon Sep 17 00:00:00 2001 From: Martin Sebor Date: Mon, 1 Feb 2021 09:08:21 -0700 Subject: Reset front end trees before they make it into the middle end (PR middle-end/97172). gcc/ChangeLog: PR middle-end/97172 * attribs.c (attr_access::free_lang_data): Define new function. * attribs.h (attr_access::free_lang_data): Declare new function. gcc/c/ChangeLog: PR middle-end/97172 * c-decl.c (free_attr_access_data): New function. (c_parse_final_cleanups): Call free_attr_access_data. gcc/testsuite/ChangeLog: PR middle-end/97172 * gcc.dg/pr97172.c: New test. --- gcc/c/c-decl.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'gcc/c') diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index 4ba9477..be95643 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -12146,6 +12146,27 @@ collect_source_refs (void) collect_source_ref (DECL_SOURCE_FILE (decl)); } +/* Free attribute access data that are not needed by the middle end. */ + +static void +free_attr_access_data () +{ + struct cgraph_node *n; + + /* Iterate over all functions declared in the translation unit. */ + FOR_EACH_FUNCTION (n) + { + tree fntype = TREE_TYPE (n->decl); + if (!fntype) + continue; + tree attrs = TYPE_ATTRIBUTES (fntype); + if (!attrs) + continue; + + attr_access::free_lang_data (attrs); + } +} + /* Perform any final parser cleanups and generate initial debugging information. */ @@ -12190,6 +12211,9 @@ c_parse_final_cleanups (void) c_write_global_declarations_1 (BLOCK_VARS (DECL_INITIAL (t))); c_write_global_declarations_1 (BLOCK_VARS (ext_block)); + if (!in_lto_p) + free_attr_access_data (); + timevar_stop (TV_PHASE_DEFERRED); timevar_start (TV_PHASE_PARSING); -- cgit v1.1