public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Issue with frame pointer elimination
@ 2021-02-04 10:54 Henri Cloetens
  2021-02-04 10:57 ` AW: " Stefan Franke
  2021-02-04 23:42 ` Segher Boessenkool
  0 siblings, 2 replies; 4+ messages in thread
From: Henri Cloetens @ 2021-02-04 10:54 UTC (permalink / raw)
  To: gcc-help

Hello,

I am working on a custom gcc.9.2.0 back end, and have an issue with 
frame pointer elimination.

- the result is OK till step '276 : ira (register allocation)
- the result is NG from step '277 onward (reload)

What it did: It used R19 for the frame pointer. This register is 
call-clobbered, but is not used for
   argument passing. Some way, it assumed to be free, but it is not.

So, the frame pointer is put in it, it is call-clobbered, and the result 
is incorrect.

If the compile flag -fomit-frame-pointer is used, the issue goes away.

Has anybody any idea where to look ?.

Best Regards,

Henri.


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

* AW: Issue with frame pointer elimination
  2021-02-04 10:54 Issue with frame pointer elimination Henri Cloetens
@ 2021-02-04 10:57 ` Stefan Franke
  2021-02-04 23:42 ` Segher Boessenkool
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Franke @ 2021-02-04 10:57 UTC (permalink / raw)
  To: 'gcc-help'

> Von: Gcc-help <gcc-help-bounces@gcc.gnu.org> Im Auftrag von Henri
> Cloetens
> Gesendet: Donnerstag, 4. Februar 2021 11:54
> An: gcc-help <gcc-help@gcc.gnu.org>
> Betreff: Issue with frame pointer elimination
> 
> Hello,
> 
> I am working on a custom gcc.9.2.0 back end, and have an issue with frame
> pointer elimination.
> 
> - the result is OK till step '276 : ira (register allocation)
> - the result is NG from step '277 onward (reload)
> 
> What it did: It used R19 for the frame pointer. This register is call-clobbered,
> but is not used for
>    argument passing. Some way, it assumed to be free, but it is not.
> 
> So, the frame pointer is put in it, it is call-clobbered, and the result is
> incorrect.
> 
> If the compile flag -fomit-frame-pointer is used, the issue goes away.
> 
> Has anybody any idea where to look ?.
> 
> Best Regards,
> 
> Henri.

Maybe R19 is used as the FRAME_POINTER? Then you can't use it for other purposes which means that no function may clobber it.

Stefan


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

* Re: Issue with frame pointer elimination
  2021-02-04 10:54 Issue with frame pointer elimination Henri Cloetens
  2021-02-04 10:57 ` AW: " Stefan Franke
@ 2021-02-04 23:42 ` Segher Boessenkool
  2021-02-05  8:52   ` Henri Cloetens
  1 sibling, 1 reply; 4+ messages in thread
From: Segher Boessenkool @ 2021-02-04 23:42 UTC (permalink / raw)
  To: Henri Cloetens; +Cc: gcc-help

Hi!

On Thu, Feb 04, 2021 at 11:54:09AM +0100, Henri Cloetens wrote:
> I am working on a custom gcc.9.2.0 back end, and have an issue with 
> frame pointer elimination.

It is a much better idea to use a more current GCC version, and it is
easier to upgrade now than to upgrade later.  Just a hint, do with it
what you want :-)

> - the result is OK till step '276 : ira (register allocation)
> - the result is NG from step '277 onward (reload)

Those numbers are useless to us: they depend on your configuration, and
on the exact GCC version (it often changes within one major+minor+
patchlevel as well).

The LRA pass (you do use LRA I hope?) sets up the hard frame pointer.
If you look at that dump file you can see what happened and what went
wrong (you'll probably need to look at the lra* files in the GCC source
to figure out what happened exactly, what everything means).

> What it did: It used R19 for the frame pointer. This register is 
> call-clobbered, but is not used for
>   argument passing. Some way, it assumed to be free, but it is not.

Is R19 the FRAME_POINTER_REGNUM or the HARD_FRAME_POINTER_REGNUM?  You
didn't show how you have anything of this set up, so it is hard to give
more detailed advice.

> So, the frame pointer is put in it, it is call-clobbered, and the result 
> is incorrect.
> 
> If the compile flag -fomit-frame-pointer is used, the issue goes away.
> 
> Has anybody any idea where to look ?.

You need to save the register in your prologue code if
frame_pointer_needed, etc.


Segher

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

* Re: Issue with frame pointer elimination
  2021-02-04 23:42 ` Segher Boessenkool
@ 2021-02-05  8:52   ` Henri Cloetens
  0 siblings, 0 replies; 4+ messages in thread
From: Henri Cloetens @ 2021-02-05  8:52 UTC (permalink / raw)
  To: Segher Boessenkool; +Cc: gcc-help

Hello Segher,

Ok. Then, which one would you recommend ?.

The diagnosis is indeed correct: I took the wrong one, I took R19, which 
is call clobbered.
If I take R18, the issue is solved, but it creates other problems.

Best Regards,

Henri.


On 2/5/21 12:42 AM, Segher Boessenkool wrote:
> Hi!
>
> On Thu, Feb 04, 2021 at 11:54:09AM +0100, Henri Cloetens wrote:
>> I am working on a custom gcc.9.2.0 back end, and have an issue with
>> frame pointer elimination.
> It is a much better idea to use a more current GCC version, and it is
> easier to upgrade now than to upgrade later.  Just a hint, do with it
> what you want :-)
>
>> - the result is OK till step '276 : ira (register allocation)
>> - the result is NG from step '277 onward (reload)
> Those numbers are useless to us: they depend on your configuration, and
> on the exact GCC version (it often changes within one major+minor+
> patchlevel as well).
>
> The LRA pass (you do use LRA I hope?) sets up the hard frame pointer.
> If you look at that dump file you can see what happened and what went
> wrong (you'll probably need to look at the lra* files in the GCC source
> to figure out what happened exactly, what everything means).
>
>> What it did: It used R19 for the frame pointer. This register is
>> call-clobbered, but is not used for
>>    argument passing. Some way, it assumed to be free, but it is not.
> Is R19 the FRAME_POINTER_REGNUM or the HARD_FRAME_POINTER_REGNUM?  You
> didn't show how you have anything of this set up, so it is hard to give
> more detailed advice.
>
>> So, the frame pointer is put in it, it is call-clobbered, and the result
>> is incorrect.
>>
>> If the compile flag -fomit-frame-pointer is used, the issue goes away.
>>
>> Has anybody any idea where to look ?.
> You need to save the register in your prologue code if
> frame_pointer_needed, etc.
>
>
> Segher



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

end of thread, other threads:[~2021-02-05  8:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-04 10:54 Issue with frame pointer elimination Henri Cloetens
2021-02-04 10:57 ` AW: " Stefan Franke
2021-02-04 23:42 ` Segher Boessenkool
2021-02-05  8:52   ` Henri Cloetens

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).