[Middle-end,Backport,to,GCC11,PR100775] Updating the reg use in exit block for -fzero-call-used-regs

Message ID B32F52CF-05E9-494C-976B-802241789F97@oracle.com
State New
Headers
Series [Middle-end,Backport,to,GCC11,PR100775] Updating the reg use in exit block for -fzero-call-used-regs |

Commit Message

Qing Zhao March 11, 2022, 4:30 p.m. UTC
  Hi, 

I plan to backport the patch to fix PR100775:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100775

To gcc11 since this is a general bug to -fzero-call-used-regs. And should be fixed in gcc11 as well.

I have tested the patch with gcc11 release branch on both x86 and aarch64, no regression.

Okay for commit?

thanks.

Qing.

==================================================


From 737a0ccccb0824111f46da44c5578b9769070c52 Mon Sep 17 00:00:00 2001
From: Qing Zhao <qing.zhao@oracle.com>
Date: Thu, 10 Mar 2022 23:22:29 +0000
Subject: [PATCH] middle-end: updating the reg use in exit block for
 -fzero-call-used-regs [PR100775] GCC11 backport.

In the pass_zero_call_used_regs, when updating dataflow info after adding
the register zeroing sequence in the epilogue of the function, we should
call "df_update_exit_block_uses" to update the register use information in
the exit block to include all the registers that have been zeroed.

gcc/ChangeLog:

        PR middle-end/100775
        * function.c (gen_call_used_regs_seq): Call
        df_update_exit_block_uses when updating df.

gcc/testsuite/ChangeLog:

        PR middle-end/100775
        * gcc.target/arm/pr100775.c: New test.
---
 gcc/function.c                          | 2 +-
 gcc/testsuite/gcc.target/arm/pr100775.c | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.target/arm/pr100775.c
  

Comments

Richard Biener March 14, 2022, 7:46 a.m. UTC | #1
On Fri, Mar 11, 2022 at 5:31 PM Qing Zhao via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
>
> Hi,
>
> I plan to backport the patch to fix PR100775:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100775
>
> To gcc11 since this is a general bug to -fzero-call-used-regs. And should be fixed in gcc11 as well.
>
> I have tested the patch with gcc11 release branch on both x86 and aarch64, no regression.
>
> Okay for commit?

OK

> thanks.
>
> Qing.
>
> ==================================================
>
>
> From 737a0ccccb0824111f46da44c5578b9769070c52 Mon Sep 17 00:00:00 2001
> From: Qing Zhao <qing.zhao@oracle.com>
> Date: Thu, 10 Mar 2022 23:22:29 +0000
> Subject: [PATCH] middle-end: updating the reg use in exit block for
>  -fzero-call-used-regs [PR100775] GCC11 backport.
>
> In the pass_zero_call_used_regs, when updating dataflow info after adding
> the register zeroing sequence in the epilogue of the function, we should
> call "df_update_exit_block_uses" to update the register use information in
> the exit block to include all the registers that have been zeroed.
>
> gcc/ChangeLog:
>
>         PR middle-end/100775
>         * function.c (gen_call_used_regs_seq): Call
>         df_update_exit_block_uses when updating df.
>
> gcc/testsuite/ChangeLog:
>
>         PR middle-end/100775
>         * gcc.target/arm/pr100775.c: New test.
> ---
>  gcc/function.c                          | 2 +-
>  gcc/testsuite/gcc.target/arm/pr100775.c | 9 +++++++++
>  2 files changed, 10 insertions(+), 1 deletion(-)
>  create mode 100644 gcc/testsuite/gcc.target/arm/pr100775.c
>
> diff --git a/gcc/function.c b/gcc/function.c
> index fc7b147b5f1..0495e9f1b81 100644
> --- a/gcc/function.c
> +++ b/gcc/function.c
> @@ -5922,7 +5922,7 @@ gen_call_used_regs_seq (rtx_insn *ret, unsigned int zero_regs_type)
>
>        /* Update the data flow information.  */
>        crtl->must_be_zero_on_return |= zeroed_hardregs;
> -      df_set_bb_dirty (EXIT_BLOCK_PTR_FOR_FN (cfun));
> +      df_update_exit_block_uses ();
>      }
>  }
>
> diff --git a/gcc/testsuite/gcc.target/arm/pr100775.c b/gcc/testsuite/gcc.target/arm/pr100775.c
> new file mode 100644
> index 00000000000..c648cd5e8f7
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/arm/pr100775.c
> @@ -0,0 +1,9 @@
> +/* { dg-do compile } */
> +/* { dg-skip-if "" { ! { arm_thumb1_ok || arm_thumb2_ok } } } */
> +/* { dg-options "-mthumb -fzero-call-used-regs=used" } */
> +
> +int
> +foo (int x)
> +{
> +  return x;
> +}
> --
> 2.27.0
>
>
  
Qing Zhao March 16, 2022, 8:23 p.m. UTC | #2
Thanks. Just committed the patch to gcc11 branch.

Qing

> On Mar 14, 2022, at 2:46 AM, Richard Biener <richard.guenther@gmail.com> wrote:
> 
> On Fri, Mar 11, 2022 at 5:31 PM Qing Zhao via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>> 
>> 
>> Hi,
>> 
>> I plan to backport the patch to fix PR100775:
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100775
>> 
>> To gcc11 since this is a general bug to -fzero-call-used-regs. And should be fixed in gcc11 as well.
>> 
>> I have tested the patch with gcc11 release branch on both x86 and aarch64, no regression.
>> 
>> Okay for commit?
> 
> OK
> 
>> thanks.
>> 
>> Qing.
>> 
>> ==================================================
>> 
>> 
>> From 737a0ccccb0824111f46da44c5578b9769070c52 Mon Sep 17 00:00:00 2001
>> From: Qing Zhao <qing.zhao@oracle.com>
>> Date: Thu, 10 Mar 2022 23:22:29 +0000
>> Subject: [PATCH] middle-end: updating the reg use in exit block for
>> -fzero-call-used-regs [PR100775] GCC11 backport.
>> 
>> In the pass_zero_call_used_regs, when updating dataflow info after adding
>> the register zeroing sequence in the epilogue of the function, we should
>> call "df_update_exit_block_uses" to update the register use information in
>> the exit block to include all the registers that have been zeroed.
>> 
>> gcc/ChangeLog:
>> 
>>        PR middle-end/100775
>>        * function.c (gen_call_used_regs_seq): Call
>>        df_update_exit_block_uses when updating df.
>> 
>> gcc/testsuite/ChangeLog:
>> 
>>        PR middle-end/100775
>>        * gcc.target/arm/pr100775.c: New test.
>> ---
>> gcc/function.c                          | 2 +-
>> gcc/testsuite/gcc.target/arm/pr100775.c | 9 +++++++++
>> 2 files changed, 10 insertions(+), 1 deletion(-)
>> create mode 100644 gcc/testsuite/gcc.target/arm/pr100775.c
>> 
>> diff --git a/gcc/function.c b/gcc/function.c
>> index fc7b147b5f1..0495e9f1b81 100644
>> --- a/gcc/function.c
>> +++ b/gcc/function.c
>> @@ -5922,7 +5922,7 @@ gen_call_used_regs_seq (rtx_insn *ret, unsigned int zero_regs_type)
>> 
>>       /* Update the data flow information.  */
>>       crtl->must_be_zero_on_return |= zeroed_hardregs;
>> -      df_set_bb_dirty (EXIT_BLOCK_PTR_FOR_FN (cfun));
>> +      df_update_exit_block_uses ();
>>     }
>> }
>> 
>> diff --git a/gcc/testsuite/gcc.target/arm/pr100775.c b/gcc/testsuite/gcc.target/arm/pr100775.c
>> new file mode 100644
>> index 00000000000..c648cd5e8f7
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.target/arm/pr100775.c
>> @@ -0,0 +1,9 @@
>> +/* { dg-do compile } */
>> +/* { dg-skip-if "" { ! { arm_thumb1_ok || arm_thumb2_ok } } } */
>> +/* { dg-options "-mthumb -fzero-call-used-regs=used" } */
>> +
>> +int
>> +foo (int x)
>> +{
>> +  return x;
>> +}
>> --
>> 2.27.0
>> 
>>
  

Patch

diff --git a/gcc/function.c b/gcc/function.c
index fc7b147b5f1..0495e9f1b81 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -5922,7 +5922,7 @@  gen_call_used_regs_seq (rtx_insn *ret, unsigned int zero_regs_type)
 
       /* Update the data flow information.  */
       crtl->must_be_zero_on_return |= zeroed_hardregs;
-      df_set_bb_dirty (EXIT_BLOCK_PTR_FOR_FN (cfun));
+      df_update_exit_block_uses ();
     }
 }
 
diff --git a/gcc/testsuite/gcc.target/arm/pr100775.c b/gcc/testsuite/gcc.target/arm/pr100775.c
new file mode 100644
index 00000000000..c648cd5e8f7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/pr100775.c
@@ -0,0 +1,9 @@ 
+/* { dg-do compile } */
+/* { dg-skip-if "" { ! { arm_thumb1_ok || arm_thumb2_ok } } } */
+/* { dg-options "-mthumb -fzero-call-used-regs=used" } */
+
+int
+foo (int x)
+{
+  return x;
+}