diff mbox series

clear more front end VLA bounds from IL (PR 97172)

Message ID e15c86db-3716-5c76-c9d6-b9e063cebfb1@gmail.com
State New
Headers show
Series clear more front end VLA bounds from IL (PR 97172) | expand

Commit Message

Martin Sebor Feb. 23, 2021, 7:19 p.m. UTC
Adding attribute access to declarations of functions that take
VLA arguments relies on the front end adding attribute "arg spec"
to each VLA parameter.  Like the VLA bounds in attribute access,
the same VLA bounds in attribute "arg spec" can cause trouble
during LTO streaming which expects front end trees to have been
either gimplified or removed.  For some reason, with arg spec
the LTO abort happens only with -fpic/-shared and so it escaped
testing in the prior fixes.

The attached patch clears the bounds from attribute "arg spec."

Martin

Comments

Richard Biener Feb. 24, 2021, 8:56 a.m. UTC | #1
On Tue, Feb 23, 2021 at 8:53 PM Martin Sebor via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Adding attribute access to declarations of functions that take
> VLA arguments relies on the front end adding attribute "arg spec"
> to each VLA parameter.  Like the VLA bounds in attribute access,
> the same VLA bounds in attribute "arg spec" can cause trouble
> during LTO streaming which expects front end trees to have been
> either gimplified or removed.  For some reason, with arg spec
> the LTO abort happens only with -fpic/-shared and so it escaped
> testing in the prior fixes.
>
> The attached patch clears the bounds from attribute "arg spec."

OK.

Richard.

> Martin
Christophe Lyon Feb. 25, 2021, 4:06 p.m. UTC | #2
Hi,



On Wed, 24 Feb 2021 at 09:57, Richard Biener via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> On Tue, Feb 23, 2021 at 8:53 PM Martin Sebor via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
> >
> > Adding attribute access to declarations of functions that take
> > VLA arguments relies on the front end adding attribute "arg spec"
> > to each VLA parameter.  Like the VLA bounds in attribute access,
> > the same VLA bounds in attribute "arg spec" can cause trouble
> > during LTO streaming which expects front end trees to have been
> > either gimplified or removed.  For some reason, with arg spec
> > the LTO abort happens only with -fpic/-shared and so it escaped
> > testing in the prior fixes.
> >
> > The attached patch clears the bounds from attribute "arg spec."
>
> OK.


I committed the patch below as obvious, to avoid failures on targets
where -shared is not supported.
This happens on Arm where the multilibs are not compiled with -fpic
and link fails because
some relocations are generated which are incompatible with -shared.

commit 01c2ce169a05c8e59c4182796876f7e0754e4b5c
Author: Christophe Lyon <christophe.lyon@linaro.org>
Date:   Thu Feb 25 15:55:28 2021 +0000

    PR middle-end/97172 - ICE: tree code 'ssa_name' is not supported
in LTO streams

    Skip test when -shared is not supported.

    2021-02-25  Christophe Lyon  <christophe.lyon@linaro.org>

        gcc/testsuite/
        PR middle-end/97172
        * gcc.dg/pr97172-2.c: Add dg-require-effective-target shared.

diff --git a/gcc/testsuite/gcc.dg/pr97172-2.c b/gcc/testsuite/gcc.dg/pr97172-2.c
index 6f355bb..99cc6c2 100644
--- a/gcc/testsuite/gcc.dg/pr97172-2.c
+++ b/gcc/testsuite/gcc.dg/pr97172-2.c
@@ -3,6 +3,7 @@
    { dg-do link }
    { dg-options "-Wall -flto -fpic -shared" }
    { dg-require-effective-target fpic }
+   { dg-require-effective-target shared }
    { dg-require-effective-target lto } */

 #include "pr97172.c"

Christophe

>
> Richard.
>
> > Martin
Martin Sebor Feb. 25, 2021, 4:15 p.m. UTC | #3
On 2/25/21 9:06 AM, Christophe Lyon wrote:
> Hi,
> 
> 
> 
> On Wed, 24 Feb 2021 at 09:57, Richard Biener via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>>
>> On Tue, Feb 23, 2021 at 8:53 PM Martin Sebor via Gcc-patches
>> <gcc-patches@gcc.gnu.org> wrote:
>>>
>>> Adding attribute access to declarations of functions that take
>>> VLA arguments relies on the front end adding attribute "arg spec"
>>> to each VLA parameter.  Like the VLA bounds in attribute access,
>>> the same VLA bounds in attribute "arg spec" can cause trouble
>>> during LTO streaming which expects front end trees to have been
>>> either gimplified or removed.  For some reason, with arg spec
>>> the LTO abort happens only with -fpic/-shared and so it escaped
>>> testing in the prior fixes.
>>>
>>> The attached patch clears the bounds from attribute "arg spec."
>>
>> OK.
> 
> 
> I committed the patch below as obvious, to avoid failures on targets
> where -shared is not supported.
> This happens on Arm where the multilibs are not compiled with -fpic
> and link fails because
> some relocations are generated which are incompatible with -shared.

Thanks!

Martin

> 
> commit 01c2ce169a05c8e59c4182796876f7e0754e4b5c
> Author: Christophe Lyon <christophe.lyon@linaro.org>
> Date:   Thu Feb 25 15:55:28 2021 +0000
> 
>      PR middle-end/97172 - ICE: tree code 'ssa_name' is not supported
> in LTO streams
> 
>      Skip test when -shared is not supported.
> 
>      2021-02-25  Christophe Lyon  <christophe.lyon@linaro.org>
> 
>          gcc/testsuite/
>          PR middle-end/97172
>          * gcc.dg/pr97172-2.c: Add dg-require-effective-target shared.
> 
> diff --git a/gcc/testsuite/gcc.dg/pr97172-2.c b/gcc/testsuite/gcc.dg/pr97172-2.c
> index 6f355bb..99cc6c2 100644
> --- a/gcc/testsuite/gcc.dg/pr97172-2.c
> +++ b/gcc/testsuite/gcc.dg/pr97172-2.c
> @@ -3,6 +3,7 @@
>      { dg-do link }
>      { dg-options "-Wall -flto -fpic -shared" }
>      { dg-require-effective-target fpic }
> +   { dg-require-effective-target shared }
>      { dg-require-effective-target lto } */
> 
>   #include "pr97172.c"
> 
> Christophe
> 
>>
>> Richard.
>>
>>> Martin
diff mbox series

Patch

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 60933d20810..16c6b12d477 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 a5852a3bae7..b559ed5d76a 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 00000000000..6f355bb9ed9
--- /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"