public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/aoliva/heads/testme)] strub: drop volatile from wrapper args
@ 2023-12-11 19:44 Alexandre Oliva
  0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Oliva @ 2023-12-11 19:44 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:7bd63d94b2df3bb2a86ddb15b361f1c8488e8647

commit 7bd63d94b2df3bb2a86ddb15b361f1c8488e8647
Author: Alexandre Oliva <oliva@gnu.org>
Date:   Mon Dec 11 16:16:45 2023 -0300

    strub: drop volatile from wrapper args

Diff:
---
 gcc/ipa-strub.cc                                     | 14 +++++++++++---
 gcc/testsuite/c-c++-common/strub-internal-volatile.c |  5 +++++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/gcc/ipa-strub.cc b/gcc/ipa-strub.cc
index 45294b0b46b..bab20c386bb 100644
--- a/gcc/ipa-strub.cc
+++ b/gcc/ipa-strub.cc
@@ -2922,6 +2922,16 @@ pass_ipa_strub::execute (function *)
 	  if (nparmt)
 	    adjust_ftype++;
 	}
+      else if (TREE_THIS_VOLATILE (parm))
+	{
+	  /* Drop volatile from wrapper's arguments, they're just
+	     temporaries copied to the wrapped function.  ???  Should
+	     we drop TYPE_QUAL_ATOMIC as well?  */
+	  TREE_TYPE (parm) = build_qualified_type (TREE_TYPE (parm),
+						   TYPE_QUALS (TREE_TYPE (parm))
+						   & ~TYPE_QUAL_VOLATILE);
+	  TREE_THIS_VOLATILE (parm) = 0;
+	}
 
     /* Also adjust the wrapped function type, if needed.  */
     if (adjust_ftype)
@@ -3224,9 +3234,7 @@ pass_ipa_strub::execute (function *)
 		    {
 		      tree tmp = arg;
 		      /* If ARG is e.g. volatile, we must copy and
-			 convert in separate statements.  ???  Should
-			 we drop volatile from the wrapper
-			 instead?  */
+			 convert in separate statements.  */
 		      if (!is_gimple_val (arg))
 			{
 			  tmp = create_tmp_reg (TYPE_MAIN_VARIANT
diff --git a/gcc/testsuite/c-c++-common/strub-internal-volatile.c b/gcc/testsuite/c-c++-common/strub-internal-volatile.c
index cdfca67616b..0ffa98d799d 100644
--- a/gcc/testsuite/c-c++-common/strub-internal-volatile.c
+++ b/gcc/testsuite/c-c++-common/strub-internal-volatile.c
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-options "-fdump-ipa-strub" } */
 /* { dg-require-effective-target strub } */
 
 void __attribute__ ((strub("internal")))
@@ -8,3 +9,7 @@ f(volatile short) {
 void g(void) {
   f(0);
 }
+
+/* We drop volatile from the wrapper, and keep it in the wrapped f, so
+   the count remains 1.  */
+/* { dg-final { scan-ipa-dump-times "volatile" 1 "strub" } } */

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

* [gcc(refs/users/aoliva/heads/testme)] strub: drop volatile from wrapper args
@ 2023-12-11 22:08 Alexandre Oliva
  0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Oliva @ 2023-12-11 22:08 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:917412bceaa01b289719c3c8786f9ed4465ccb7c

commit 917412bceaa01b289719c3c8786f9ed4465ccb7c
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Mon Dec 11 16:16:45 2023 -0300

    strub: drop volatile from wrapper args
    
    Drop volatile from argument types in internal strub wrappers that are
    not made indirect.  Their volatility is only relevant within the body
    of the function, and that body is moved to the wrapped function.
    
    
    for  gcc/ChangeLog
    
            * ipa-strub.cc (pass_ipa_strub::execute): Drop volatile from
            internal strub wrapper args.
    
    for  gcc/testsuite/ChangeLog
    
            * c-c++-common/strub-internal-volatile.c: Check for dropped
            volatile in wrapper.

Diff:
---
 gcc/ipa-strub.cc                                     | 14 +++++++++++---
 gcc/testsuite/c-c++-common/strub-internal-volatile.c |  5 +++++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/gcc/ipa-strub.cc b/gcc/ipa-strub.cc
index 45294b0b46b..bab20c386bb 100644
--- a/gcc/ipa-strub.cc
+++ b/gcc/ipa-strub.cc
@@ -2922,6 +2922,16 @@ pass_ipa_strub::execute (function *)
 	  if (nparmt)
 	    adjust_ftype++;
 	}
+      else if (TREE_THIS_VOLATILE (parm))
+	{
+	  /* Drop volatile from wrapper's arguments, they're just
+	     temporaries copied to the wrapped function.  ???  Should
+	     we drop TYPE_QUAL_ATOMIC as well?  */
+	  TREE_TYPE (parm) = build_qualified_type (TREE_TYPE (parm),
+						   TYPE_QUALS (TREE_TYPE (parm))
+						   & ~TYPE_QUAL_VOLATILE);
+	  TREE_THIS_VOLATILE (parm) = 0;
+	}
 
     /* Also adjust the wrapped function type, if needed.  */
     if (adjust_ftype)
@@ -3224,9 +3234,7 @@ pass_ipa_strub::execute (function *)
 		    {
 		      tree tmp = arg;
 		      /* If ARG is e.g. volatile, we must copy and
-			 convert in separate statements.  ???  Should
-			 we drop volatile from the wrapper
-			 instead?  */
+			 convert in separate statements.  */
 		      if (!is_gimple_val (arg))
 			{
 			  tmp = create_tmp_reg (TYPE_MAIN_VARIANT
diff --git a/gcc/testsuite/c-c++-common/strub-internal-volatile.c b/gcc/testsuite/c-c++-common/strub-internal-volatile.c
index cdfca67616b..0ffa98d799d 100644
--- a/gcc/testsuite/c-c++-common/strub-internal-volatile.c
+++ b/gcc/testsuite/c-c++-common/strub-internal-volatile.c
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-options "-fdump-ipa-strub" } */
 /* { dg-require-effective-target strub } */
 
 void __attribute__ ((strub("internal")))
@@ -8,3 +9,7 @@ f(volatile short) {
 void g(void) {
   f(0);
 }
+
+/* We drop volatile from the wrapper, and keep it in the wrapped f, so
+   the count remains 1.  */
+/* { dg-final { scan-ipa-dump-times "volatile" 1 "strub" } } */

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

* [gcc(refs/users/aoliva/heads/testme)] strub: drop volatile from wrapper args
@ 2023-12-11 19:33 Alexandre Oliva
  0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Oliva @ 2023-12-11 19:33 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:7fd452fd7d93f55bb982aed09ccc4a7d26fd57d5

commit 7fd452fd7d93f55bb982aed09ccc4a7d26fd57d5
Author: Alexandre Oliva <oliva@gnu.org>
Date:   Mon Dec 11 16:16:45 2023 -0300

    strub: drop volatile from wrapper args

Diff:
---
 gcc/ipa-strub.cc                                     | 14 +++++++++++---
 gcc/testsuite/c-c++-common/strub-internal-volatile.c |  5 +++++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/gcc/ipa-strub.cc b/gcc/ipa-strub.cc
index 45294b0b46b..bab20c386bb 100644
--- a/gcc/ipa-strub.cc
+++ b/gcc/ipa-strub.cc
@@ -2922,6 +2922,16 @@ pass_ipa_strub::execute (function *)
 	  if (nparmt)
 	    adjust_ftype++;
 	}
+      else if (TREE_THIS_VOLATILE (parm))
+	{
+	  /* Drop volatile from wrapper's arguments, they're just
+	     temporaries copied to the wrapped function.  ???  Should
+	     we drop TYPE_QUAL_ATOMIC as well?  */
+	  TREE_TYPE (parm) = build_qualified_type (TREE_TYPE (parm),
+						   TYPE_QUALS (TREE_TYPE (parm))
+						   & ~TYPE_QUAL_VOLATILE);
+	  TREE_THIS_VOLATILE (parm) = 0;
+	}
 
     /* Also adjust the wrapped function type, if needed.  */
     if (adjust_ftype)
@@ -3224,9 +3234,7 @@ pass_ipa_strub::execute (function *)
 		    {
 		      tree tmp = arg;
 		      /* If ARG is e.g. volatile, we must copy and
-			 convert in separate statements.  ???  Should
-			 we drop volatile from the wrapper
-			 instead?  */
+			 convert in separate statements.  */
 		      if (!is_gimple_val (arg))
 			{
 			  tmp = create_tmp_reg (TYPE_MAIN_VARIANT
diff --git a/gcc/testsuite/c-c++-common/strub-internal-volatile.c b/gcc/testsuite/c-c++-common/strub-internal-volatile.c
index cdfca67616b..4eb62ee40d5 100644
--- a/gcc/testsuite/c-c++-common/strub-internal-volatile.c
+++ b/gcc/testsuite/c-c++-common/strub-internal-volatile.c
@@ -1,4 +1,5 @@
 /* { dg-do compile } */
+/* { dg-options "-fdump-ipa-strub" } */
 /* { dg-require-effective-target strub } */
 
 void __attribute__ ((strub("internal")))
@@ -8,3 +9,7 @@ f(volatile short) {
 void g(void) {
   f(0);
 }
+
+/* We drop volatile from the wrapper, and keep it in the wrapped f, so
+   the count remains 1.  */
+/* { dg-final { scan-tree-dump "volatile" 1 "strub" } } */

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

end of thread, other threads:[~2023-12-11 22:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-11 19:44 [gcc(refs/users/aoliva/heads/testme)] strub: drop volatile from wrapper args Alexandre Oliva
  -- strict thread matches above, loose matches on Subject: below --
2023-12-11 22:08 Alexandre Oliva
2023-12-11 19:33 Alexandre Oliva

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).