Re: [PATCH] rs6000: Fix the condition with frame_pointer_needed_indeed [PR96072]

2022-09-25 Thread Kewen.Lin via Gcc-patches
Hi Segher,

Thanks for the comments!

on 2022/9/23 06:13, Segher Boessenkool wrote:
> Hi!
> 
> On Thu, Sep 22, 2022 at 09:41:42AM +0800, Kewen.Lin wrote:
>>  * config/rs6000/rs6000-logue.cc (rs6000_emit_epilogue): Update the
>>  condition for adding REG_CFA_DEF_CFA reg note with
>>  frame_pointer_needed_indeed.
> 
>> --- a/gcc/config/rs6000/rs6000-logue.cc
>> +++ b/gcc/config/rs6000/rs6000-logue.cc
>> @@ -4956,7 +4956,7 @@ rs6000_emit_epilogue (enum epilogue_type epilogue_type)
>>   a REG_CFA_DEF_CFA note, but that's OK;  A duplicate is
>>   discarded by dwarf2cfi.cc/dwarf2out.cc, and in any case would
>>   be harmless if emitted.  */
>> -  if (frame_pointer_needed)
>> +  if (frame_pointer_needed_indeed)
>>  {
>>insn = get_last_insn ();
> 
> I thought about adding an assert here, but the very next insn gives a
> clear enough message anyway, zo it would be just noise :-)
> 
>> diff --git a/gcc/testsuite/gcc.target/powerpc/pr96072.c 
>> b/gcc/testsuite/gcc.target/powerpc/pr96072.c
>> new file mode 100644
>> index 000..23d1cc74ffd
>> --- /dev/null
>> +++ b/gcc/testsuite/gcc.target/powerpc/pr96072.c
>> @@ -0,0 +1,14 @@
>> +/* { dg-options "-O1" } */
>> +
>> +/* Verify there is no ICE on 32 bit environment.  */
> 
> /* This used to ICE with the SYSV ABI (PR96072).  */

Updated.

> 
> Please use -O2 if that works here.
> 

Updated too.

> Okay for trunk.  Thank you!
> 

Comitted in r13-2846, since it's a regression causing ICE, I think we want
this to backport?  Is it ok to backport this after burn-in time?

Thanks again!

BR,
Kewen


Re: [PATCH] rs6000: Fix the condition with frame_pointer_needed_indeed [PR96072]

2022-09-22 Thread Segher Boessenkool
Hi!

On Thu, Sep 22, 2022 at 09:41:42AM +0800, Kewen.Lin wrote:
>   * config/rs6000/rs6000-logue.cc (rs6000_emit_epilogue): Update the
>   condition for adding REG_CFA_DEF_CFA reg note with
>   frame_pointer_needed_indeed.

> --- a/gcc/config/rs6000/rs6000-logue.cc
> +++ b/gcc/config/rs6000/rs6000-logue.cc
> @@ -4956,7 +4956,7 @@ rs6000_emit_epilogue (enum epilogue_type epilogue_type)
>a REG_CFA_DEF_CFA note, but that's OK;  A duplicate is
>discarded by dwarf2cfi.cc/dwarf2out.cc, and in any case would
>be harmless if emitted.  */
> -  if (frame_pointer_needed)
> +  if (frame_pointer_needed_indeed)
>   {
> insn = get_last_insn ();

I thought about adding an assert here, but the very next insn gives a
clear enough message anyway, zo it would be just noise :-)

> diff --git a/gcc/testsuite/gcc.target/powerpc/pr96072.c 
> b/gcc/testsuite/gcc.target/powerpc/pr96072.c
> new file mode 100644
> index 000..23d1cc74ffd
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/powerpc/pr96072.c
> @@ -0,0 +1,14 @@
> +/* { dg-options "-O1" } */
> +
> +/* Verify there is no ICE on 32 bit environment.  */

/* This used to ICE with the SYSV ABI (PR96072).  */

Please use -O2 if that works here.

Okay for trunk.  Thank you!


Segher


[PATCH] rs6000: Fix the condition with frame_pointer_needed_indeed [PR96072]

2022-09-21 Thread Kewen.Lin via Gcc-patches
Hi,

As PR96072 shows, the code adding REG_CFA_DEF_CFA reg note
makes one assumption that we have emitted one insn which
restores the frame pointer previously.  That part of code
was guarded with flag frame_pointer_needed before, it was
consistent, but later it was replaced with flag
frame_pointer_needed_indeed since commit r10-7981.  It
caused ICE due to unexpected NULL insn.  This patch is to
make the conditions consistent.

Bootstrapped and regtested on powerpc64-linux-gnu P7 and
powerpc64le-linux-gnu P9 and P10.

Is it ok for trunk?

BR,
Kewen
-
PR target/96072

gcc/ChangeLog:

* config/rs6000/rs6000-logue.cc (rs6000_emit_epilogue): Update the
condition for adding REG_CFA_DEF_CFA reg note with
frame_pointer_needed_indeed.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr96072.c: New test.
---
 gcc/config/rs6000/rs6000-logue.cc  |  2 +-
 gcc/testsuite/gcc.target/powerpc/pr96072.c | 14 ++
 2 files changed, 15 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.target/powerpc/pr96072.c

diff --git a/gcc/config/rs6000/rs6000-logue.cc 
b/gcc/config/rs6000/rs6000-logue.cc
index 51f55d1d527..41daf6ee646 100644
--- a/gcc/config/rs6000/rs6000-logue.cc
+++ b/gcc/config/rs6000/rs6000-logue.cc
@@ -4956,7 +4956,7 @@ rs6000_emit_epilogue (enum epilogue_type epilogue_type)
 a REG_CFA_DEF_CFA note, but that's OK;  A duplicate is
 discarded by dwarf2cfi.cc/dwarf2out.cc, and in any case would
 be harmless if emitted.  */
-  if (frame_pointer_needed)
+  if (frame_pointer_needed_indeed)
{
  insn = get_last_insn ();
  add_reg_note (insn, REG_CFA_DEF_CFA,
diff --git a/gcc/testsuite/gcc.target/powerpc/pr96072.c 
b/gcc/testsuite/gcc.target/powerpc/pr96072.c
new file mode 100644
index 000..23d1cc74ffd
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr96072.c
@@ -0,0 +1,14 @@
+/* { dg-options "-O1" } */
+
+/* Verify there is no ICE on 32 bit environment.  */
+
+void
+he (int jn)
+{
+  {
+int bh[jn];
+if (jn != 0)
+  goto wa;
+  }
+wa:;
+}
--
2.27.0