[Committed] IBM zSystems: Make -fcall-saved-... work.
Checks
Commit Message
Committed to mainline. Bootstrap and regression tests are clean.
gcc/ChangeLog:
* config/s390/s390.cc (s390_register_info): Check call_used_regs
instead of hard-coding the register numbers for call saved
registers.
(s390_optimize_register_info): Likewise.
gcc/testsuite/ChangeLog:
* gcc.target/s390/fcall-saved.c: New test.
---
gcc/config/s390/s390.cc | 10 ++++------
gcc/testsuite/gcc.target/s390/fcall-saved.c | 11 +++++++++++
2 files changed, 15 insertions(+), 6 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/s390/fcall-saved.c
@@ -10075,8 +10075,8 @@ s390_register_info ()
memset (cfun_frame_layout.gpr_save_slots, SAVE_SLOT_NONE, 16);
- for (i = 6; i < 16; i++)
- if (clobbered_regs[i])
+ for (i = 0; i < 16; i++)
+ if (clobbered_regs[i] && !call_used_regs[i])
cfun_gpr_save_slot (i) = SAVE_SLOT_STACK;
s390_register_info_stdarg_fpr ();
@@ -10136,10 +10136,8 @@ s390_optimize_register_info ()
|| cfun_frame_layout.save_return_addr_p
|| crtl->calls_eh_return);
- memset (cfun_frame_layout.gpr_save_slots, SAVE_SLOT_NONE, 6);
-
- for (i = 6; i < 16; i++)
- if (!clobbered_regs[i])
+ for (i = 0; i < 16; i++)
+ if (!clobbered_regs[i] || call_used_regs[i])
cfun_gpr_save_slot (i) = SAVE_SLOT_NONE;
s390_register_info_set_ranges ();
new file mode 100644
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -mzarch -fcall-saved-r4" } */
+
+void test(void) {
+ asm volatile("nop" ::: "r4");
+}
+
+/* { dg-final { scan-assembler-times "\tstg\t" 1 { target { lp64 } } } } */
+/* { dg-final { scan-assembler-times "\tlg\t" 1 { target { lp64 } } } } */
+/* { dg-final { scan-assembler-times "\tst\t" 1 { target { ! lp64 } } } } */
+/* { dg-final { scan-assembler-times "\tl\t" 1 { target { ! lp64 } } } } */