lto/121935 - visit all DECL_ARGUMENTS in free-lang-data

Message ID 20250914091030.3341C139CB@imap1.dmz-prg2.suse.org
State Committed
Commit 38666cbccff5114e2f23930fae180f03c385eb45
Headers
Series lto/121935 - visit all DECL_ARGUMENTS in free-lang-data |

Commit Message

Richard Biener Sept. 14, 2025, 9:10 a.m. UTC
  With no longer visiting TREE_CHAIN for decls we have to visit
the DECL_ARGUMENT chain manually.

LTO bootstrap and regtest running on x86_64-unknown-linux-gnu.

I'm not sure whether LTO bootstrap worked before, but hopefully this
would have fixed it.  Testing non-LTO to be able to push it anyway as
well.

Richard.

	PR lto/121935
	* ipa-free-lang-data.cc (find_decls_types_r): Visit DECL_ARGUMENTS
	chain manually.

	* g++.dg/lto/pr121935_0.C: New testcase.
---
 gcc/ipa-free-lang-data.cc             |  3 ++-
 gcc/testsuite/g++.dg/lto/pr121935_0.C | 13 +++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/g++.dg/lto/pr121935_0.C
  

Comments

Sam James Sept. 14, 2025, 10:57 a.m. UTC | #1
Richard Biener <rguenther@suse.de> writes:

> With no longer visiting TREE_CHAIN for decls we have to visit
> the DECL_ARGUMENT chain manually.
>
> LTO bootstrap and regtest running on x86_64-unknown-linux-gnu.
>
> I'm not sure whether LTO bootstrap worked before

I didn't have bootstrap issues myself but I only tried my usual x86_64, not
other targets (which I test less often). But the patch regtests fine for me.

Thanks.

> but hopefully this
> would have fixed it.  Testing non-LTO to be able to push it anyway as
> well.
>
> Richard.
>
> 	PR lto/121935
> 	* ipa-free-lang-data.cc (find_decls_types_r): Visit DECL_ARGUMENTS
> 	chain manually.
>
> 	* g++.dg/lto/pr121935_0.C: New testcase.
> ---
>  gcc/ipa-free-lang-data.cc             |  3 ++-
>  gcc/testsuite/g++.dg/lto/pr121935_0.C | 13 +++++++++++++
>  2 files changed, 15 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/g++.dg/lto/pr121935_0.C
>
> diff --git a/gcc/ipa-free-lang-data.cc b/gcc/ipa-free-lang-data.cc
> index 41afc6ec82f..8196cab6079 100644
> --- a/gcc/ipa-free-lang-data.cc
> +++ b/gcc/ipa-free-lang-data.cc
> @@ -735,7 +735,8 @@ find_decls_types_r (tree *tp, int *ws, void *data)
>  
>        if (TREE_CODE (t) == FUNCTION_DECL)
>  	{
> -	  fld_worklist_push (DECL_ARGUMENTS (t), fld);
> +	  for (tree arg = DECL_ARGUMENTS (t); arg; arg = DECL_CHAIN (arg))
> +	    fld_worklist_push (arg, fld);
>  	  fld_worklist_push (DECL_RESULT (t), fld);
>  	}
>        else if (TREE_CODE (t) == FIELD_DECL)
> diff --git a/gcc/testsuite/g++.dg/lto/pr121935_0.C b/gcc/testsuite/g++.dg/lto/pr121935_0.C
> new file mode 100644
> index 00000000000..a4519b1d3ad
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/lto/pr121935_0.C
> @@ -0,0 +1,13 @@
> +// { dg-lto-do assemble }
> +// { dg-lto-options {{-flto -Wno-return-type}} }
> +
> +struct a {
> +  static int b;
> +};
> +template <int> struct c {
> +  struct d {
> +    d e(unsigned, unsigned, bool, bool, bool, unsigned, a);
> +  };
> +};
> +template <>
> +c<2>::d c<2>::d::e(unsigned, unsigned, bool, bool, bool, unsigned, const a) { }
  
Richard Biener Sept. 14, 2025, 11:25 a.m. UTC | #2
On Sun, 14 Sep 2025, Sam James wrote:

> Richard Biener <rguenther@suse.de> writes:
> 
> > With no longer visiting TREE_CHAIN for decls we have to visit
> > the DECL_ARGUMENT chain manually.
> >
> > LTO bootstrap and regtest running on x86_64-unknown-linux-gnu.
> >
> > I'm not sure whether LTO bootstrap worked before
> 
> I didn't have bootstrap issues myself but I only tried my usual x86_64, not
> other targets (which I test less often). But the patch regtests fine for me.

LTO bootstrap also succeeded.  I've pushed the patch.

Richard.

> Thanks.
> 
> > but hopefully this
> > would have fixed it.  Testing non-LTO to be able to push it anyway as
> > well.
> >
> > Richard.
> >
> > 	PR lto/121935
> > 	* ipa-free-lang-data.cc (find_decls_types_r): Visit DECL_ARGUMENTS
> > 	chain manually.
> >
> > 	* g++.dg/lto/pr121935_0.C: New testcase.
> > ---
> >  gcc/ipa-free-lang-data.cc             |  3 ++-
> >  gcc/testsuite/g++.dg/lto/pr121935_0.C | 13 +++++++++++++
> >  2 files changed, 15 insertions(+), 1 deletion(-)
> >  create mode 100644 gcc/testsuite/g++.dg/lto/pr121935_0.C
> >
> > diff --git a/gcc/ipa-free-lang-data.cc b/gcc/ipa-free-lang-data.cc
> > index 41afc6ec82f..8196cab6079 100644
> > --- a/gcc/ipa-free-lang-data.cc
> > +++ b/gcc/ipa-free-lang-data.cc
> > @@ -735,7 +735,8 @@ find_decls_types_r (tree *tp, int *ws, void *data)
> >  
> >        if (TREE_CODE (t) == FUNCTION_DECL)
> >  	{
> > -	  fld_worklist_push (DECL_ARGUMENTS (t), fld);
> > +	  for (tree arg = DECL_ARGUMENTS (t); arg; arg = DECL_CHAIN (arg))
> > +	    fld_worklist_push (arg, fld);
> >  	  fld_worklist_push (DECL_RESULT (t), fld);
> >  	}
> >        else if (TREE_CODE (t) == FIELD_DECL)
> > diff --git a/gcc/testsuite/g++.dg/lto/pr121935_0.C b/gcc/testsuite/g++.dg/lto/pr121935_0.C
> > new file mode 100644
> > index 00000000000..a4519b1d3ad
> > --- /dev/null
> > +++ b/gcc/testsuite/g++.dg/lto/pr121935_0.C
> > @@ -0,0 +1,13 @@
> > +// { dg-lto-do assemble }
> > +// { dg-lto-options {{-flto -Wno-return-type}} }
> > +
> > +struct a {
> > +  static int b;
> > +};
> > +template <int> struct c {
> > +  struct d {
> > +    d e(unsigned, unsigned, bool, bool, bool, unsigned, a);
> > +  };
> > +};
> > +template <>
> > +c<2>::d c<2>::d::e(unsigned, unsigned, bool, bool, bool, unsigned, const a) { }
>
  

Patch

diff --git a/gcc/ipa-free-lang-data.cc b/gcc/ipa-free-lang-data.cc
index 41afc6ec82f..8196cab6079 100644
--- a/gcc/ipa-free-lang-data.cc
+++ b/gcc/ipa-free-lang-data.cc
@@ -735,7 +735,8 @@  find_decls_types_r (tree *tp, int *ws, void *data)
 
       if (TREE_CODE (t) == FUNCTION_DECL)
 	{
-	  fld_worklist_push (DECL_ARGUMENTS (t), fld);
+	  for (tree arg = DECL_ARGUMENTS (t); arg; arg = DECL_CHAIN (arg))
+	    fld_worklist_push (arg, fld);
 	  fld_worklist_push (DECL_RESULT (t), fld);
 	}
       else if (TREE_CODE (t) == FIELD_DECL)
diff --git a/gcc/testsuite/g++.dg/lto/pr121935_0.C b/gcc/testsuite/g++.dg/lto/pr121935_0.C
new file mode 100644
index 00000000000..a4519b1d3ad
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lto/pr121935_0.C
@@ -0,0 +1,13 @@ 
+// { dg-lto-do assemble }
+// { dg-lto-options {{-flto -Wno-return-type}} }
+
+struct a {
+  static int b;
+};
+template <int> struct c {
+  struct d {
+    d e(unsigned, unsigned, bool, bool, bool, unsigned, a);
+  };
+};
+template <>
+c<2>::d c<2>::d::e(unsigned, unsigned, bool, bool, bool, unsigned, const a) { }