public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* RFA: RL78: Save the frame pointer if it is used.
@ 2015-05-05 14:41 Nick Clifton
  2015-05-05 19:12 ` DJ Delorie
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Clifton @ 2015-05-05 14:41 UTC (permalink / raw)
  To: dj; +Cc: gcc-patches

Hi DJ,

  Below is a small patch to fix a small problem with the need_to_save()
  function in the RL78 backend.  It was only marking the frame pointer
  register as needing a save if the frame pointer was in use.  But since
  the frame pointer is call-saved it needs to be saved any time it is
  used, even if it is not being used as a frame pointer.  This problem
  has not arisen before because the frame pointer is also marked as
  being fixed.  But it turns out that it can still be used inside some
  inline assembler, and so the prologue and epilogue code still need to
  save and restore it.

  Tested with no regressions on an rl78-elf toolchain.

  OK to apply ?

Cheers
  Nick

gcc/ChangeLog
2015-05-05  Nick Clifton  <nickc@redhat.com>

	* config/rl78/rl78.c (need_to_save): Save the frame pointer any
	time that it is used.

Index: gcc/config/rl78/rl78.c
===================================================================
--- gcc/config/rl78/rl78.c	(revision 222796)
+++ gcc/config/rl78/rl78.c	(working copy)
@@ -687,7 +687,8 @@
       return df_regs_ever_live_p (regno);
     }
 
-  if (regno == FRAME_POINTER_REGNUM && frame_pointer_needed)
+  if (regno == FRAME_POINTER_REGNUM
+      && (frame_pointer_needed || df_regs_ever_live_p (regno)))
     return true;
   if (fixed_regs[regno])
     return false;

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

* Re: RFA: RL78: Save the frame pointer if it is used.
  2015-05-05 14:41 RFA: RL78: Save the frame pointer if it is used Nick Clifton
@ 2015-05-05 19:12 ` DJ Delorie
  2015-05-06 10:17   ` Nicholas Clifton
  0 siblings, 1 reply; 3+ messages in thread
From: DJ Delorie @ 2015-05-05 19:12 UTC (permalink / raw)
  To: Nick Clifton; +Cc: gcc-patches


>   OK to apply ?

Ok, but...

> -  if (regno == FRAME_POINTER_REGNUM && frame_pointer_needed)
> +  if (regno == FRAME_POINTER_REGNUM
> +      && (frame_pointer_needed || df_regs_ever_live_p (regno)))

Do we want regs_ever_live or regs_ever_written_to ?  I seem to recall
changing a port... mep perhaps... to only save registers that are
changed, not registers that are used but read-only.

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

* Re: RFA: RL78: Save the frame pointer if it is used.
  2015-05-05 19:12 ` DJ Delorie
@ 2015-05-06 10:17   ` Nicholas Clifton
  0 siblings, 0 replies; 3+ messages in thread
From: Nicholas Clifton @ 2015-05-06 10:17 UTC (permalink / raw)
  To: DJ Delorie; +Cc: gcc-patches

Hi DJ,

>>    OK to apply ?
>
> Ok, but...

Thanks - committed.

>> -  if (regno == FRAME_POINTER_REGNUM && frame_pointer_needed)
>> +  if (regno == FRAME_POINTER_REGNUM
>> +      && (frame_pointer_needed || df_regs_ever_live_p (regno)))
>
> Do we want regs_ever_live or regs_ever_written_to ?  I seem to recall
> changing a port... mep perhaps... to only save registers that are
> changed, not registers that are used but read-only.

You are right, we would only need to save the FP if it is written to, 
but I could not find a regs_ever_written_to, or something similar.  At 
least the current version of the patch will still work though, even if 
there is a needless save/restore of the FP.

Cheers
   Nick


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

end of thread, other threads:[~2015-05-06 10:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-05 14:41 RFA: RL78: Save the frame pointer if it is used Nick Clifton
2015-05-05 19:12 ` DJ Delorie
2015-05-06 10:17   ` Nicholas Clifton

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