On 26/08/16 09:52, Kyrill Tkachov wrote:
> Hi all,
> 
> I'd like to backport this fix for an ILP32 ICE. This was a simple
> band-aid proposed by Andrew
> that is self-contained and doesn't touch non-ILP32 or non-aarch64 code
> so it should be pretty safe
> to backport. It has been in trunk and GCC 6 for quite some time without
> issues until Renlin's patch at r235282
> fixed the midend issue [1].
> 
> Bootstrapped and tested on GCC 5 on aarch64-none-linux-gnu.
> Is this patch ok for the branch?
> 

OK.

R.

> Thanks,
> Kyrill
> 
> [1] https://gcc.gnu.org/ml/gcc-patches/2016-08/msg00332.html
> 
> 2016-08-26  Kyrylo Tkachov  <kyrylo.tkac...@arm.com>
> 
>     Backport from mainline
>     2016-04-20  Andrew Pinski  <apin...@cavium.com>
>                 Kyrylo Tkachov  <kyrylo.tkac...@arm.com>
> 
>     PR target/64971
>     * config/aarch64/aarch64.md (sibcall): Force call
>     address to be DImode for ILP32.
>     (sibcall_value): Likewise.
> 
> 
>     PR target/64971
>    * gcc.c-torture/compile/pr37433
> <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=37433>-1.c: New testcase.
> 
> back-5.patch
> 
> 
> diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
> index 
> 116fd89102c98c5e1816998ce56cbc4d87525e97..501ae4481451b1730233eb4dfaca2a66a5b1c2ae
>  100644
> --- a/gcc/config/aarch64/aarch64.md
> +++ b/gcc/config/aarch64/aarch64.md
> @@ -687,6 +687,13 @@ (define_expand "sibcall"
>         && (GET_CODE (XEXP (operands[0], 0)) != SYMBOL_REF))
>       XEXP (operands[0], 0) = force_reg (Pmode, XEXP (operands[0], 0));
>  
> +    /* This is a band-aid.  An SImode symbol reference is sometimes generated
> +       by expand_expr_addr_expr.  See PR 64971.  */
> +    if (TARGET_ILP32
> +     && GET_CODE (XEXP (operands[0], 0)) == SYMBOL_REF
> +     && GET_MODE (XEXP (operands[0], 0)) == SImode)
> +      XEXP (operands[0], 0) = convert_memory_address (Pmode,
> +                                                   XEXP (operands[0], 0));
>      if (operands[2] == NULL_RTX)
>        operands[2] = const0_rtx;
>  
> @@ -717,6 +724,14 @@ (define_expand "sibcall_value"
>         && (GET_CODE (XEXP (operands[1], 0)) != SYMBOL_REF))
>       XEXP (operands[1], 0) = force_reg (Pmode, XEXP (operands[1], 0));
>  
> +    /* This is a band-aid.  An SImode symbol reference is sometimes generated
> +       by expand_expr_addr_expr.  See PR 64971.  */
> +    if (TARGET_ILP32
> +     && GET_CODE (XEXP (operands[1], 0)) == SYMBOL_REF
> +     && GET_MODE (XEXP (operands[1], 0)) == SImode)
> +      XEXP (operands[1], 0) = convert_memory_address (Pmode,
> +                                                   XEXP (operands[1], 0));
> +
>      if (operands[3] == NULL_RTX)
>        operands[3] = const0_rtx;
>  
> diff --git a/gcc/testsuite/gcc.c-torture/compile/pr37433-1.c 
> b/gcc/testsuite/gcc.c-torture/compile/pr37433-1.c
> new file mode 100644
> index 
> 0000000000000000000000000000000000000000..c69e9692eb0229154676fc088c41741fa30f1871
> --- /dev/null
> +++ b/gcc/testsuite/gcc.c-torture/compile/pr37433-1.c
> @@ -0,0 +1,13 @@
> +void
> +regex_subst (void)
> +{
> +  const void *subst = "";
> +  (*(void (*)(int))subst) (0);
> +}
> +
> +void
> +foobar (void)
> +{
> +  int x;
> +  (*(void (*)(void))&x) ();
> +}
> 

Reply via email to