public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] rs6000: Use SAVE_MULTIPLE only if we restore what it saves (PR80938)
@ 2017-08-09 21:16 Segher Boessenkool
  2017-08-10  4:18 ` Alan Modra
  0 siblings, 1 reply; 11+ messages in thread
From: Segher Boessenkool @ 2017-08-09 21:16 UTC (permalink / raw)
  To: gcc-patches; +Cc: dje.gcc, Segher Boessenkool

We can have SAVE_MULTIPLE while we do not have REST_MULTIPLE.  If the
inline restore does not restore all registers, the CFI for the save
and restore can conflict if things are shrink-wrapped.

We could restore all registers that are saved (not ideal), or emit
the CFI notes to say we did (which will work fine, but is also not
so great); instead, let's not save the registers that are unused.

Tested on powerpc64-linux {-m32,-m64}; committing to trunk.


Segher


2017-08-09  Segher Boessenkool  <segher@kernel.crashing.org>

	PR target/80938
	* config/rs6000/rs6000.c (rs6000_savres_strategy): Don't use
	SAVE_MULTIPLE if not all the registers that saves, should be saved.

---
 gcc/config/rs6000/rs6000.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 0f0b1ff..e8cdd25 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -24437,6 +24437,21 @@ rs6000_savres_strategy (rs6000_stack_t *info,
   else if (!lr_save_p && info->first_gp_reg_save > 29)
     strategy |= SAVE_INLINE_GPRS | REST_INLINE_GPRS;
 
+  /* We can only use save multiple if we need to save all the registers from
+     first_gp_reg_save.  Otherwise, the CFI gets messed up (we save some
+     register we do not restore).  */
+  if (strategy & SAVE_MULTIPLE)
+    {
+      int i;
+
+      for (i = info->first_gp_reg_save; i < 32; i++)
+	if (fixed_reg_p (i) || !save_reg_p (i))
+	  {
+	    strategy &= ~SAVE_MULTIPLE;
+	    break;
+	  }
+    }
+
   /* We can only use load multiple or the out-of-line routines to
      restore gprs if we've saved all the registers from
      first_gp_reg_save.  Otherwise, we risk loading garbage.
-- 
1.9.3

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

end of thread, other threads:[~2017-08-17  2:23 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-09 21:16 [PATCH] rs6000: Use SAVE_MULTIPLE only if we restore what it saves (PR80938) Segher Boessenkool
2017-08-10  4:18 ` Alan Modra
2017-08-10  4:44   ` Segher Boessenkool
2017-08-10  5:26     ` Alan Modra
2017-08-10 13:46       ` Segher Boessenkool
2017-08-11  4:58         ` [RS6000] PR 80938, Don't emit eh_frame for regs that don't need saving Alan Modra
2017-08-15 10:40           ` Segher Boessenkool
2017-08-16  0:13             ` Alan Modra
2017-08-17  2:23               ` Segher Boessenkool
2017-08-17  5:28                 ` Alan Modra
2017-08-17  5:50                   ` Segher Boessenkool

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