public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [rs6000] Fix compare debug failure on AIX
@ 2015-04-29 10:31 Eric Botcazou
  2015-04-29 10:37 ` pinskia
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Botcazou @ 2015-04-29 10:31 UTC (permalink / raw)
  To: gcc-patches; +Cc: David Edelsohn

[-- Attachment #1: Type: text/plain, Size: 645 bytes --]

You can easily get -fcompare-debug failures on AIX with small functions, in 
fact you get the failure for the empty function:

void foo (void) {}

eric@polaris:~/build/gcc/powerpc-ibm-aix7.1> gcc/xgcc -Bgcc -S t.c -O -
fcompare-debug
xgcc: error: t.c: -fcompare-debug failure (length)

Fixed thusly, tested on powerpc-ibm-aix7.1, OK for the mainline?


2015-04-29  Eric Botcazou  <ebotcazou@adacore.com>

	* config/rs6000/rs6000.c (rs6000_stack_info): For XCOFF, replace test
	on debug info with test on optimization to decide stack pushing.


2015-04-29  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc.dg/empty3.c: New test.


-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 1060 bytes --]

Index: config/rs6000/rs6000.c
===================================================================
--- config/rs6000/rs6000.c	(revision 222439)
+++ config/rs6000/rs6000.c	(working copy)
@@ -21932,8 +21932,8 @@ rs6000_stack_info (void)
   /* Determine if we need to allocate any stack frame:
 
      For AIX we need to push the stack if a frame pointer is needed
-     (because the stack might be dynamically adjusted), if we are
-     debugging, if we make calls, or if the sum of fp_save, gp_save,
+     (because the stack might be dynamically adjusted), if we are not
+     optimizing, if we make calls, or if the sum of fp_save, gp_save,
      and local variables are more than the space needed to save all
      non-volatile registers: 32-bit: 18*8 + 19*4 = 220 or 64-bit: 18*8
      + 18*8 = 288 (GPR13 reserved).
@@ -21950,7 +21950,7 @@ rs6000_stack_info (void)
   else if (frame_pointer_needed)
     info_ptr->push_p = 1;
 
-  else if (TARGET_XCOFF && write_symbols != NO_DEBUG)
+  else if (TARGET_XCOFF && !optimize)
     info_ptr->push_p = 1;
 
   else

[-- Attachment #3: empty3.c --]
[-- Type: text/x-csrc, Size: 61 bytes --]

/* { dg-options "-O -fcompare-debug" } */

void foo (void) {}

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [rs6000] Fix compare debug failure on AIX
  2015-04-29 10:31 [rs6000] Fix compare debug failure on AIX Eric Botcazou
@ 2015-04-29 10:37 ` pinskia
  2015-04-30 11:35   ` Eric Botcazou
  0 siblings, 1 reply; 10+ messages in thread
From: pinskia @ 2015-04-29 10:37 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: gcc-patches, David Edelsohn





> On Apr 29, 2015, at 3:22 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> 
> You can easily get -fcompare-debug failures on AIX with small functions, in 
> fact you get the failure for the empty function:
> 
> void foo (void) {}
> 
> eric@polaris:~/build/gcc/powerpc-ibm-aix7.1> gcc/xgcc -Bgcc -S t.c -O -
> fcompare-debug
> xgcc: error: t.c: -fcompare-debug failure (length)
> 
> Fixed thusly, tested on powerpc-ibm-aix7.1, OK for the mainline?
> 
> 
> 2015-04-29  Eric Botcazou  <ebotcazou@adacore.com>
> 
>    * config/rs6000/rs6000.c (rs6000_stack_info): For XCOFF, replace test
>    on debug info with test on optimization to decide stack pushing.

We might want to check if doing -Og and not just -O0. 

Thanks,
Andrew

> 
> 
> 2015-04-29  Eric Botcazou  <ebotcazou@adacore.com>
> 
>    * gcc.dg/empty3.c: New test.
> 
> 
> -- 
> Eric Botcazou
> <p.diff>
> <empty3.c>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [rs6000] Fix compare debug failure on AIX
  2015-04-29 10:37 ` pinskia
@ 2015-04-30 11:35   ` Eric Botcazou
  2015-05-01 13:48     ` David Edelsohn
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Botcazou @ 2015-04-30 11:35 UTC (permalink / raw)
  To: pinskia; +Cc: gcc-patches, David Edelsohn

[-- Attachment #1: Type: text/plain, Size: 137 bytes --]

> We might want to check if doing -Og and not just -O0.

You're right, thanks, amended patch attached, same ChangeLog.

-- 
Eric Botcazou

[-- Attachment #2: p.diff --]
[-- Type: text/x-patch, Size: 1075 bytes --]

Index: config/rs6000/rs6000.c
===================================================================
--- config/rs6000/rs6000.c	(revision 222439)
+++ config/rs6000/rs6000.c	(working copy)
@@ -21932,8 +21932,8 @@ rs6000_stack_info (void)
   /* Determine if we need to allocate any stack frame:
 
      For AIX we need to push the stack if a frame pointer is needed
-     (because the stack might be dynamically adjusted), if we are
-     debugging, if we make calls, or if the sum of fp_save, gp_save,
+     (because the stack might be dynamically adjusted), if we want
+     to debug, if we make calls, or if the sum of fp_save, gp_save,
      and local variables are more than the space needed to save all
      non-volatile registers: 32-bit: 18*8 + 19*4 = 220 or 64-bit: 18*8
      + 18*8 = 288 (GPR13 reserved).
@@ -21950,7 +21950,7 @@ rs6000_stack_info (void)
   else if (frame_pointer_needed)
     info_ptr->push_p = 1;
 
-  else if (TARGET_XCOFF && write_symbols != NO_DEBUG)
+  else if (TARGET_XCOFF && (!optimize || optimize_debug))
     info_ptr->push_p = 1;
 
   else

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [rs6000] Fix compare debug failure on AIX
  2015-04-30 11:35   ` Eric Botcazou
@ 2015-05-01 13:48     ` David Edelsohn
  2015-05-02  4:24       ` Alan Modra
  2015-05-02 10:05       ` Eric Botcazou
  0 siblings, 2 replies; 10+ messages in thread
From: David Edelsohn @ 2015-05-01 13:48 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: Andrew Pinski, GCC Patches

On Thu, Apr 30, 2015 at 7:28 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> We might want to check if doing -Og and not just -O0.
>
> You're right, thanks, amended patch attached, same ChangeLog.

Why should GCC unnecessarily create stack frames to avoid
compare-debug testcase failures?

- David

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [rs6000] Fix compare debug failure on AIX
  2015-05-01 13:48     ` David Edelsohn
@ 2015-05-02  4:24       ` Alan Modra
  2015-05-02 10:05       ` Eric Botcazou
  1 sibling, 0 replies; 10+ messages in thread
From: Alan Modra @ 2015-05-02  4:24 UTC (permalink / raw)
  To: David Edelsohn; +Cc: Eric Botcazou, Andrew Pinski, GCC Patches

On Fri, May 01, 2015 at 09:48:51AM -0400, David Edelsohn wrote:
> On Thu, Apr 30, 2015 at 7:28 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> >> We might want to check if doing -Og and not just -O0.
> >
> > You're right, thanks, amended patch attached, same ChangeLog.
> 
> Why should GCC unnecessarily create stack frames to avoid
> compare-debug testcase failures?

More to the point, do you need a frame on AIX when debugging?  If yes
then the correct change is to replace

  else if (TARGET_XCOFF && write_symbols != NO_DEBUG)
    info_ptr->push_p = 1;

with

  else if (TARGET_XCOFF)
    info_ptr->push_p = 1;

If no, then the correct change is to delete those lines from
rs6000_stack_info, and fix the comment.

https://gcc.gnu.org/ml/gcc-patches/2003-03/msg01693.html 

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [rs6000] Fix compare debug failure on AIX
  2015-05-01 13:48     ` David Edelsohn
  2015-05-02  4:24       ` Alan Modra
@ 2015-05-02 10:05       ` Eric Botcazou
  2015-05-04  0:32         ` David Edelsohn
  1 sibling, 1 reply; 10+ messages in thread
From: Eric Botcazou @ 2015-05-02 10:05 UTC (permalink / raw)
  To: David Edelsohn; +Cc: gcc-patches, Andrew Pinski

> Why should GCC unnecessarily create stack frames to avoid
> compare-debug testcase failures?

I'm not sure I understand the question... compare-debug failures are failures 
(-g is not supposed to change the generated code and this XCOFF-specific bug 
was reported to us) so they need to be fixed.

From there on, as Alan said, there are 2 cases: either AIX needs a frame for 
debugging or it doesn't.  If the latter, then the lines can simply be deleted.
If the former, we have to draw a line somewhere; Alan suggests always creating 
a frame while I suggest creating it only at -O0 and -Og.

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [rs6000] Fix compare debug failure on AIX
  2015-05-02 10:05       ` Eric Botcazou
@ 2015-05-04  0:32         ` David Edelsohn
  2015-05-04  8:33           ` Richard Biener
                             ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: David Edelsohn @ 2015-05-04  0:32 UTC (permalink / raw)
  To: Eric Botcazou; +Cc: GCC Patches, Andrew Pinski

On Sat, May 2, 2015 at 6:04 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> Why should GCC unnecessarily create stack frames to avoid
>> compare-debug testcase failures?
>
> I'm not sure I understand the question... compare-debug failures are failures
> (-g is not supposed to change the generated code and this XCOFF-specific bug
> was reported to us) so they need to be fixed.
>
> From there on, as Alan said, there are 2 cases: either AIX needs a frame for
> debugging or it doesn't.  If the latter, then the lines can simply be deleted.
> If the former, we have to draw a line somewhere; Alan suggests always creating
> a frame while I suggest creating it only at -O0 and -Og.

I believe that AIX does need a frame for debugging.  I don't remember
the exact reason off hand.

I'm sorry that XCOFF debugging changes the generated code (only in the
sense of allocating a frame), but that is a system dependency.  It's
been this way for over 20 years.  I see no reason to produce worse
code at -O0 when not debugging simply to make testcases happier.

By the way, I'm still waiting for the DWARF debugging patches from
Adacore compatible with AIX as and ld.  DWARF debugging would not
require pushing a frame, and would resolve the failure when testing
with DWARF.  The patch would be adjusted to only push a frame when
writing XCOFF debugging.

- David

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [rs6000] Fix compare debug failure on AIX
  2015-05-04  0:32         ` David Edelsohn
@ 2015-05-04  8:33           ` Richard Biener
  2015-05-04 13:26           ` Tristan Gingold
  2015-05-11  8:25           ` Eric Botcazou
  2 siblings, 0 replies; 10+ messages in thread
From: Richard Biener @ 2015-05-04  8:33 UTC (permalink / raw)
  To: David Edelsohn; +Cc: Eric Botcazou, GCC Patches, Andrew Pinski

On Mon, May 4, 2015 at 2:32 AM, David Edelsohn <dje.gcc@gmail.com> wrote:
> On Sat, May 2, 2015 at 6:04 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>>> Why should GCC unnecessarily create stack frames to avoid
>>> compare-debug testcase failures?
>>
>> I'm not sure I understand the question... compare-debug failures are failures
>> (-g is not supposed to change the generated code and this XCOFF-specific bug
>> was reported to us) so they need to be fixed.
>>
>> From there on, as Alan said, there are 2 cases: either AIX needs a frame for
>> debugging or it doesn't.  If the latter, then the lines can simply be deleted.
>> If the former, we have to draw a line somewhere; Alan suggests always creating
>> a frame while I suggest creating it only at -O0 and -Og.
>
> I believe that AIX does need a frame for debugging.  I don't remember
> the exact reason off hand.
>
> I'm sorry that XCOFF debugging changes the generated code (only in the
> sense of allocating a frame), but that is a system dependency.  It's
> been this way for over 20 years.  I see no reason to produce worse
> code at -O0 when not debugging simply to make testcases happier.

The simple reason is because it is policy for GCC to generate the same
code with -g0 and -g.  You can't simply say you don't care.

You never want to run into the situation that you miscompile a program
with -g0 but not with -g because that's very much no fun to debug.

Yes, I don't think we have this policy written down anywhere - something
we should improve on.

Richard.

> By the way, I'm still waiting for the DWARF debugging patches from
> Adacore compatible with AIX as and ld.  DWARF debugging would not
> require pushing a frame, and would resolve the failure when testing
> with DWARF.  The patch would be adjusted to only push a frame when
> writing XCOFF debugging.
>
> - David

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [rs6000] Fix compare debug failure on AIX
  2015-05-04  0:32         ` David Edelsohn
  2015-05-04  8:33           ` Richard Biener
@ 2015-05-04 13:26           ` Tristan Gingold
  2015-05-11  8:25           ` Eric Botcazou
  2 siblings, 0 replies; 10+ messages in thread
From: Tristan Gingold @ 2015-05-04 13:26 UTC (permalink / raw)
  To: David Edelsohn; +Cc: Eric Botcazou, GCC Patches, Andrew Pinski


> On 04 May 2015, at 02:32, David Edelsohn <dje.gcc@gmail.com> wrote:
> 
> On Sat, May 2, 2015 at 6:04 AM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>>> Why should GCC unnecessarily create stack frames to avoid
>>> compare-debug testcase failures?
>> 
>> I'm not sure I understand the question... compare-debug failures are failures
>> (-g is not supposed to change the generated code and this XCOFF-specific bug
>> was reported to us) so they need to be fixed.
>> 
>> From there on, as Alan said, there are 2 cases: either AIX needs a frame for
>> debugging or it doesn't.  If the latter, then the lines can simply be deleted.
>> If the former, we have to draw a line somewhere; Alan suggests always creating
>> a frame while I suggest creating it only at -O0 and -Og.
> 
> I believe that AIX does need a frame for debugging.  I don't remember
> the exact reason off hand.
> 
> I'm sorry that XCOFF debugging changes the generated code (only in the
> sense of allocating a frame), but that is a system dependency.  It's
> been this way for over 20 years.  I see no reason to produce worse
> code at -O0 when not debugging simply to make testcases happier.
> 
> By the way, I'm still waiting for the DWARF debugging patches from
> Adacore compatible with AIX as and ld.  DWARF debugging would not
> require pushing a frame, and would resolve the failure when testing
> with DWARF.  The patch would be adjusted to only push a frame when
> writing XCOFF debugging.

Sorry but we don’t have these patches.  We have a tiny patch to generate
Dwarf debug infos on XCOFF platforms but that requires GNU as and ld.

Tristan.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [rs6000] Fix compare debug failure on AIX
  2015-05-04  0:32         ` David Edelsohn
  2015-05-04  8:33           ` Richard Biener
  2015-05-04 13:26           ` Tristan Gingold
@ 2015-05-11  8:25           ` Eric Botcazou
  2 siblings, 0 replies; 10+ messages in thread
From: Eric Botcazou @ 2015-05-11  8:25 UTC (permalink / raw)
  To: David Edelsohn; +Cc: gcc-patches, Andrew Pinski

> I'm sorry that XCOFF debugging changes the generated code (only in the
> sense of allocating a frame), but that is a system dependency.  It's
> been this way for over 20 years.  I see no reason to produce worse
> code at -O0 when not debugging simply to make testcases happier.

You apparently read my previous message too quickly, this was reported to 
AdaCore on real code, i.e. someone opened a ticket and complained that the 
compiler was generating different code with and without -g for XCOFF.

Note that someone a little perverse could easily use this obvious defect to 
prevent the compiler from bootstrapping on AIX. ;-)

-- 
Eric Botcazou

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-05-11  8:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-04-29 10:31 [rs6000] Fix compare debug failure on AIX Eric Botcazou
2015-04-29 10:37 ` pinskia
2015-04-30 11:35   ` Eric Botcazou
2015-05-01 13:48     ` David Edelsohn
2015-05-02  4:24       ` Alan Modra
2015-05-02 10:05       ` Eric Botcazou
2015-05-04  0:32         ` David Edelsohn
2015-05-04  8:33           ` Richard Biener
2015-05-04 13:26           ` Tristan Gingold
2015-05-11  8:25           ` Eric Botcazou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).