On Thu, Dec 19, 2024 at 3:39 AM Alexandre Oliva <[email protected]> wrote:
>
> 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.
>
> Regstrapped on x86_64-linux-gnu. Ok to install?
OK.
>
> 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 | 13 +++++++------
> gcc/testsuite/gcc.dg/strub-pr118007.c | 5 +++++
> 2 files changed, 12 insertions(+), 6 deletions(-)
> create mode 100644 gcc/testsuite/gcc.dg/strub-pr118007.c
>
> diff --git a/gcc/ipa-strub.cc b/gcc/ipa-strub.cc
> index 29ba143b4620a..6b3f5b078f29d 100644
> --- a/gcc/ipa-strub.cc
> +++ b/gcc/ipa-strub.cc
> @@ -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
> index 0000000000000..6c24cad652968
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/strub-pr118007.c
> @@ -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) {}
>
> --
> 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