]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
strub: accept indirection of volatile pointer types [PR118007]
authorAlexandre Oliva <oliva@adacore.com>
Fri, 20 Dec 2024 21:02:01 +0000 (18:02 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Fri, 20 Dec 2024 21:02:01 +0000 (18:02 -0300)
We don't want to indirect pointers in strub wrappers, because it
generally isn't profitable, but if the argument is volatile, then we
must use indirection to preserve access patterns, so amend the
assertion check.

for  gcc/ChangeLog

PR middle-end/118007
* ipa-strub.cc (pass_ipa_strub::execute): Accept indirecting
volatile args of pointer types.

for  gcc/testsuite/ChangeLog

PR middle-end/118007
* gcc.dg/strub-pr118007.c: New.

gcc/ipa-strub.cc
gcc/testsuite/gcc.dg/strub-pr118007.c [new file with mode: 0644]

index 29ba143b4620a8c00f8754970d4d0f2a2a323a61..6b3f5b078f29d08e7e16f036be0b04d14955cb9b 100644 (file)
@@ -2881,12 +2881,13 @@ pass_ipa_strub::execute (function *)
                   && (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
-            assumption here, because getting this wrong would mess
-            with attribute access and possibly others.  We deal with
-            fn spec below.  */
-         gcc_checking_assert (!POINTER_TYPE_P (TREE_TYPE (nparm)));
+         /* No point in indirecting pointer types, unless they're
+            volatile.  Presumably they won't ever pass the size-based
+            test above, but check the assumption here, because
+            getting this wrong would mess with attribute access and
+            possibly others.  We deal with fn spec below.  */
+         gcc_checking_assert (!POINTER_TYPE_P (TREE_TYPE (nparm))
+                              || TREE_THIS_VOLATILE (parm));
 
          indirect_nparms.add (nparm);
 
diff --git a/gcc/testsuite/gcc.dg/strub-pr118007.c b/gcc/testsuite/gcc.dg/strub-pr118007.c
new file mode 100644 (file)
index 0000000..6c24cad
--- /dev/null
@@ -0,0 +1,5 @@
+/* { dg-require-effective-target strub } */
+/* { dg-do compile } */
+/* { dg-options "-fstrub=all -O2" } */
+
+void rb_ec_error_print(struct rb_execution_context_struct *volatile) {}