]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
strub: indirect volatile parms in wrappers
authorAlexandre Oliva <oliva@adacore.com>
Thu, 14 Dec 2023 13:41:19 +0000 (10:41 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Thu, 14 Dec 2023 13:41:19 +0000 (10:41 -0300)
Arrange for strub internal wrappers to pass volatile arguments by
reference to the wrapped bodies.

for  gcc/ChangeLog

PR middle-end/112938
* ipa-strub.cc (pass_ipa_strub::execute): Pass volatile args
by reference to internal strub wrapped bodies.

for  gcc/testsuite/ChangeLog

PR middle-end/112938
* gcc.dg/strub-internal-volatile.c: Check indirection of
volatile args.

gcc/ipa-strub.cc
gcc/testsuite/gcc.dg/strub-internal-volatile.c

index 45294b0b46bcb3c0774714aa620e923be3f4ac5f..943bb60996fc1bf5bffc4a734711a2cc41f89a6b 100644 (file)
@@ -2881,13 +2881,14 @@ pass_ipa_strub::execute (function *)
           parm = DECL_CHAIN (parm),
           nparm = DECL_CHAIN (nparm),
           nparmt = nparmt ? TREE_CHAIN (nparmt) : NULL_TREE)
-      if (!(0 /* DECL_BY_REFERENCE (narg) */
-           || is_gimple_reg_type (TREE_TYPE (nparm))
-           || VECTOR_TYPE_P (TREE_TYPE (nparm))
-           || TREE_CODE (TREE_TYPE (nparm)) == COMPLEX_TYPE
-           || (tree_fits_uhwi_p (TYPE_SIZE_UNIT (TREE_TYPE (nparm)))
-               && (tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (nparm)))
-                   <= 4 * UNITS_PER_WORD))))
+      if (TREE_THIS_VOLATILE (parm)
+         || !(0 /* DECL_BY_REFERENCE (narg) */
+              || is_gimple_reg_type (TREE_TYPE (nparm))
+              || VECTOR_TYPE_P (TREE_TYPE (nparm))
+              || TREE_CODE (TREE_TYPE (nparm)) == COMPLEX_TYPE
+              || (tree_fits_uhwi_p (TYPE_SIZE_UNIT (TREE_TYPE (nparm)))
+                  && (tree_to_uhwi (TYPE_SIZE_UNIT (TREE_TYPE (nparm)))
+                      <= 4 * UNITS_PER_WORD))))
        {
          /* No point in indirecting pointer types.  Presumably they
             won't ever pass the size-based test above, but check the
@@ -3224,9 +3225,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
index 34d4ec8b3830a218263e0227274403b1b708f818..a1436dcc0691c9f2abd3e260205731bad4f6edae 100644 (file)
@@ -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 s) {
 void g(void) {
   f(0);
 }
+
+/* We make volatile parms indirect in the wrapped f.  */
+/* { dg-final { scan-ipa-dump-times "volatile short" 2 "strub" } } */
+/* { dg-final { scan-ipa-dump-times "volatile short int &" 1 "strub" } } */