Steve Ellcey <sell...@marvell.com> writes:
> Here is version two of my patch to fix simd attribute handling on
> aarch64.  Unlike the first patch where I swapped the order of the
> calls to targetm.simd_clone.adjust and simd_clone_adjust_return_type,
> in this one I remove the (conditional) call to build_distinct_type_copy
> from simd_clone_adjust_return_type and do it unconditionally before
> calling either routine.  The only downside to this that I can see is
> that on non-aarch64 platforms where the return type of a vector
> function is VOID (and not changed), we will create a distinct type
> where we did not before.
>
> I also added some tests to ensure that, on aarch64, the vector
> functions created by cloning a simd function have the .variant_pcs
> directive and that the original non-vector version of the function
> does not have the directive.  Without this patch the non-vector
> version is putting out the directive, that is what this patch
> fixes.
>
> Retested on x86 and aarch64 with no regressions.
>
> OK to checkin?
>
> Steve Ellcey
> sell...@marvell.com
>
>
> 2019-07-19  Steve Ellcey  <sell...@marvell.com>
>
>       * omp-simd-clone.c (simd_clone_adjust_return_type): Remove call to
>       build_distinct_type_copy.
>       (simd_clone_adjust): Call build_distinct_type_copy.
>       (expand_simd_clones): Ditto.
>
>
> 2019-07-19  Steve Ellcey  <sell...@marvell.com>
>
>       * gcc.target/aarch64/simd_pcs_attribute.c: New test.
>       * gcc.target/aarch64/simd_pcs_attribute-2.c: Ditto.
>       * gcc.target/aarch64/simd_pcs_attribute-3.c: Ditto.
>
>
> diff --git a/gcc/omp-simd-clone.c b/gcc/omp-simd-clone.c
> index caa8da3cba5..427d6f6f514 100644
> --- a/gcc/omp-simd-clone.c
> +++ b/gcc/omp-simd-clone.c
> @@ -498,7 +498,6 @@ simd_clone_adjust_return_type (struct cgraph_node *node)
>    /* Adjust the function return type.  */
>    if (orig_rettype == void_type_node)
>      return NULL_TREE;
> -  TREE_TYPE (fndecl) = build_distinct_type_copy (TREE_TYPE (fndecl));
>    t = TREE_TYPE (TREE_TYPE (fndecl));
>    if (INTEGRAL_TYPE_P (t) || POINTER_TYPE_P (t))
>      veclen = node->simdclone->vecsize_int;
> @@ -1164,6 +1163,7 @@ simd_clone_adjust (struct cgraph_node *node)
>  {
>    push_cfun (DECL_STRUCT_FUNCTION (node->decl));
>  
> +  TREE_TYPE (node->decl) = build_distinct_type_copy (TREE_TYPE (node->decl));
>    targetm.simd_clone.adjust (node);
>  
>    tree retval = simd_clone_adjust_return_type (node);
> @@ -1737,6 +1737,8 @@ expand_simd_clones (struct cgraph_node *node)
>           simd_clone_adjust (n);
>         else
>           {
> +           TREE_TYPE (n->decl)
> +             = build_distinct_type_copy (TREE_TYPE (n->decl));
>             targetm.simd_clone.adjust (n);
>             simd_clone_adjust_return_type (n);
>             simd_clone_adjust_argument_types (n);

You can probably also remove:

      tree new_type = build_distinct_type_copy (TREE_TYPE (node->decl));
      ...
      TREE_TYPE (node->decl) = new_type;

in simd_clone_adjust_argument_types.

I'm happy doing it this way or doing the copy in the AArch64 hook.
It's really Jakub's call.

I don't think the tests need:

/* { dg-require-effective-target aarch64_variant_pcs } */

since they're only dg-do compile.  Leaving the line out would get more
coverage for people using older binutils.

The tests are OK with that change, thanks.

Richard

Reply via email to