public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] strub: drop nonaliased parm from build_ref_type_for [PR113394]
@ 2024-01-30  2:30 Alexandre Oliva
  2024-01-30  6:06 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Alexandre Oliva @ 2024-01-30  2:30 UTC (permalink / raw)
  To: gcc-patches


Variant type copies can't have their own alias sets any more, and it's
not like setting them affected the pointed-to objects anyway.

Regstrapped on x86_64-linux-gnu; also bootstrapped with -fstrub=internal
enabled by default.  Ok to install?


for  gcc/ChangeLog

	PR debug/113394
	* ipa-strub.cc (build_ref_type_for): Drop nonaliased.  Adjust
	caller.

for  gcc/testsuite/ChangeLog

	PR debug/113394
	* gcc.dg/strub-internal-pr113394.c: New.
---
 gcc/ipa-strub.cc                               |   31 ++++--------------------
 gcc/testsuite/gcc.dg/strub-internal-pr113394.c |    6 +++++
 2 files changed, 11 insertions(+), 26 deletions(-)
 create mode 100644 gcc/testsuite/gcc.dg/strub-internal-pr113394.c

diff --git a/gcc/ipa-strub.cc b/gcc/ipa-strub.cc
index e1b07016b8879..0ee063c9eddc4 100644
--- a/gcc/ipa-strub.cc
+++ b/gcc/ipa-strub.cc
@@ -2052,36 +2052,17 @@ walk_regimplify_phi (gphi *stmt)
   return needs_commit;
 }
 
-/* Create a reference type to use for PARM when turning it into a reference.
-   NONALIASED causes the reference type to gain its own separate alias set, so
-   that accessing the indirectly-passed parm won'will not add aliasing
-   noise.  */
+/* Create a reference type to use for PARM when turning it into a
+   reference.  */
 
 static tree
-build_ref_type_for (tree parm, bool nonaliased = true)
+build_ref_type_for (tree parm)
 {
   gcc_checking_assert (TREE_CODE (parm) == PARM_DECL);
 
   tree ref_type = build_reference_type (TREE_TYPE (parm));
 
-  if (!nonaliased)
-    return ref_type;
-
-  /* Each PARM turned indirect still points to the distinct memory area at the
-     wrapper, and the reference in unchanging, so we might qualify it, but...
-     const is not really important, since we're only using default defs for the
-     reference parm anyway, and not introducing any defs, and restrict seems to
-     cause trouble.  E.g., libgnat/s-concat3.adb:str_concat_3 has memmoves that,
-     if it's wrapped, the memmoves are deleted in dse1.  Using a distinct alias
-     set seems to not run afoul of this problem, and it hopefully enables the
-     compiler to tell the pointers do point to objects that are not otherwise
-     aliased.  */
-  tree qref_type = build_variant_type_copy (ref_type);
-
-  TYPE_ALIAS_SET (qref_type) = new_alias_set ();
-  record_alias_subset (TYPE_ALIAS_SET (qref_type), get_alias_set (ref_type));
-
-  return qref_type;
+  return ref_type;
 }
 
 /* Add cgraph edges from current_function_decl to callees in SEQ with frequency
@@ -2909,9 +2890,7 @@ pass_ipa_strub::execute (function *)
 	     if with transparent reference, and the wrapper doesn't take any
 	     extra parms that could point into wrapper's parms.  So we can
 	     probably drop the TREE_ADDRESSABLE and keep the TRUE.  */
-	  tree ref_type = build_ref_type_for (nparm,
-					      true
-					      || !TREE_ADDRESSABLE (parm));
+	  tree ref_type = build_ref_type_for (nparm);
 
 	  DECL_ARG_TYPE (nparm) = TREE_TYPE (nparm) = ref_type;
 	  relayout_decl (nparm);
diff --git a/gcc/testsuite/gcc.dg/strub-internal-pr113394.c b/gcc/testsuite/gcc.dg/strub-internal-pr113394.c
new file mode 100644
index 0000000000000..d21c209cdf699
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/strub-internal-pr113394.c
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-fstrub=internal -g" } */
+
+/* gcc.c-torture/compile/20020210-1.c */
+/* PR c/5615 */
+void f(int a, struct {int b[a];} c) {} /* { dg-warning "anonymous struct" } */


-- 
Alexandre Oliva, happy hacker            https://FSFLA.org/blogs/lxo/
   Free Software Activist                   GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity
Excluding neuro-others for not behaving ""normal"" is *not* inclusive

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] strub: drop nonaliased parm from build_ref_type_for [PR113394]
  2024-01-30  2:30 [PATCH] strub: drop nonaliased parm from build_ref_type_for [PR113394] Alexandre Oliva
@ 2024-01-30  6:06 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2024-01-30  6:06 UTC (permalink / raw)
  To: Alexandre Oliva; +Cc: gcc-patches



> Am 30.01.2024 um 03:31 schrieb Alexandre Oliva <oliva@adacore.com>:
> 
> 
> Variant type copies can't have their own alias sets any more, and it's
> not like setting them affected the pointed-to objects anyway.
> 
> Regstrapped on x86_64-linux-gnu; also bootstrapped with -fstrub=internal
> enabled by default.  Ok to install?

Ok

Richard 

> for  gcc/ChangeLog
> 
>    PR debug/113394
>    * ipa-strub.cc (build_ref_type_for): Drop nonaliased.  Adjust
>    caller.
> 
> for  gcc/testsuite/ChangeLog
> 
>    PR debug/113394
>    * gcc.dg/strub-internal-pr113394.c: New.
> ---
> gcc/ipa-strub.cc                               |   31 ++++--------------------
> gcc/testsuite/gcc.dg/strub-internal-pr113394.c |    6 +++++
> 2 files changed, 11 insertions(+), 26 deletions(-)
> create mode 100644 gcc/testsuite/gcc.dg/strub-internal-pr113394.c
> 
> diff --git a/gcc/ipa-strub.cc b/gcc/ipa-strub.cc
> index e1b07016b8879..0ee063c9eddc4 100644
> --- a/gcc/ipa-strub.cc
> +++ b/gcc/ipa-strub.cc
> @@ -2052,36 +2052,17 @@ walk_regimplify_phi (gphi *stmt)
>   return needs_commit;
> }
> 
> -/* Create a reference type to use for PARM when turning it into a reference.
> -   NONALIASED causes the reference type to gain its own separate alias set, so
> -   that accessing the indirectly-passed parm won'will not add aliasing
> -   noise.  */
> +/* Create a reference type to use for PARM when turning it into a
> +   reference.  */
> 
> static tree
> -build_ref_type_for (tree parm, bool nonaliased = true)
> +build_ref_type_for (tree parm)
> {
>   gcc_checking_assert (TREE_CODE (parm) == PARM_DECL);
> 
>   tree ref_type = build_reference_type (TREE_TYPE (parm));
> 
> -  if (!nonaliased)
> -    return ref_type;
> -
> -  /* Each PARM turned indirect still points to the distinct memory area at the
> -     wrapper, and the reference in unchanging, so we might qualify it, but...
> -     const is not really important, since we're only using default defs for the
> -     reference parm anyway, and not introducing any defs, and restrict seems to
> -     cause trouble.  E.g., libgnat/s-concat3.adb:str_concat_3 has memmoves that,
> -     if it's wrapped, the memmoves are deleted in dse1.  Using a distinct alias
> -     set seems to not run afoul of this problem, and it hopefully enables the
> -     compiler to tell the pointers do point to objects that are not otherwise
> -     aliased.  */
> -  tree qref_type = build_variant_type_copy (ref_type);
> -
> -  TYPE_ALIAS_SET (qref_type) = new_alias_set ();
> -  record_alias_subset (TYPE_ALIAS_SET (qref_type), get_alias_set (ref_type));
> -
> -  return qref_type;
> +  return ref_type;
> }
> 
> /* Add cgraph edges from current_function_decl to callees in SEQ with frequency
> @@ -2909,9 +2890,7 @@ pass_ipa_strub::execute (function *)
>         if with transparent reference, and the wrapper doesn't take any
>         extra parms that could point into wrapper's parms.  So we can
>         probably drop the TREE_ADDRESSABLE and keep the TRUE.  */
> -      tree ref_type = build_ref_type_for (nparm,
> -                          true
> -                          || !TREE_ADDRESSABLE (parm));
> +      tree ref_type = build_ref_type_for (nparm);
> 
>      DECL_ARG_TYPE (nparm) = TREE_TYPE (nparm) = ref_type;
>      relayout_decl (nparm);
> diff --git a/gcc/testsuite/gcc.dg/strub-internal-pr113394.c b/gcc/testsuite/gcc.dg/strub-internal-pr113394.c
> new file mode 100644
> index 0000000000000..d21c209cdf699
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/strub-internal-pr113394.c
> @@ -0,0 +1,6 @@
> +/* { dg-do compile } */
> +/* { dg-options "-fstrub=internal -g" } */
> +
> +/* gcc.c-torture/compile/20020210-1.c */
> +/* PR c/5615 */
> +void f(int a, struct {int b[a];} c) {} /* { dg-warning "anonymous struct" } */
> 
> 
> --
> Alexandre Oliva, happy hacker            https://FSFLA.org/blogs/lxo/
>   Free Software Activist                   GNU Toolchain Engineer
> More tolerance and less prejudice are key for inclusion and diversity
> Excluding neuro-others for not behaving ""normal"" is *not* inclusive

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-01-30  6:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-30  2:30 [PATCH] strub: drop nonaliased parm from build_ref_type_for [PR113394] Alexandre Oliva
2024-01-30  6:06 ` Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).