From: Martin Sebor Date: Wed, 24 Feb 2021 15:57:59 +0000 (-0700) Subject: PR middle-end/97172 - ICE: tree code 'ssa_name' is not supported in LTO streams X-Git-Tag: basepoints/gcc-12~897 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ea5a82df9ba0c9d23e386290d24fc920968a8695;p=thirdparty%2Fgcc.git PR middle-end/97172 - ICE: tree code 'ssa_name' is not supported in LTO streams gcc/ChangeLog: PR middle-end/97172 * attribs.c (attr_access::free_lang_data): Clear attribute arg spec from function arguments. gcc/c/ChangeLog: PR middle-end/97172 * c-decl.c (free_attr_access_data): Clear attribute arg spec. gcc/testsuite/ChangeLog: PR middle-end/97172 * gcc.dg/pr97172-2.c: New test. --- diff --git a/gcc/attribs.c b/gcc/attribs.c index 60933d20810d..16c6b12d4778 100644 --- a/gcc/attribs.c +++ b/gcc/attribs.c @@ -2265,6 +2265,14 @@ attr_access::free_lang_data (tree attrs) *pvbnd = NULL_TREE; } } + + for (tree argspec = attrs; (argspec = lookup_attribute ("arg spec", argspec)); + argspec = TREE_CHAIN (argspec)) + { + /* Same as above. */ + tree *pvblist = &TREE_VALUE (argspec); + *pvblist = NULL_TREE; + } } /* Defined in attr_access. */ diff --git a/gcc/c/c-decl.c b/gcc/c/c-decl.c index a5852a3bae7a..b559ed5d76ae 100644 --- a/gcc/c/c-decl.c +++ b/gcc/c/c-decl.c @@ -12166,6 +12166,10 @@ free_attr_access_data () /* Iterate over all functions declared in the translation unit. */ FOR_EACH_FUNCTION (n) { + for (tree parm = DECL_ARGUMENTS (n->decl); parm; parm = TREE_CHAIN (parm)) + if (tree attrs = DECL_ATTRIBUTES (parm)) + attr_access::free_lang_data (attrs); + tree fntype = TREE_TYPE (n->decl); if (!fntype) continue; diff --git a/gcc/testsuite/gcc.dg/pr97172-2.c b/gcc/testsuite/gcc.dg/pr97172-2.c new file mode 100644 index 000000000000..6f355bb9ed96 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr97172-2.c @@ -0,0 +1,8 @@ +/* PR middle-end/97172 - ICE: tree code ‘ssa_name’ is not supported in LTO + streams + { dg-do link } + { dg-options "-Wall -flto -fpic -shared" } + { dg-require-effective-target fpic } + { dg-require-effective-target lto } */ + +#include "pr97172.c"