diff mbox

S/390: Fix cfi for GPR 2 FPR saves

Message ID 20150722135706.GA24034@maggie
State New
Headers show

Commit Message

Andreas Krebbel July 22, 2015, 1:57 p.m. UTC
Hi,

GCC currently does not emit register save cfi information for the
stack pointer register.  Instead dwarf2cfi considers the load into an
FPR as using a new CFA register from now on.

Adding a CFA_REGISTER note prevent dwarf2cfi from interpreting the
insn itself.

This fixes the Glibc testcases tst-cancelx4 and tst-cancelx5.

I'll commit the patch after waiting a few days for review comments.

Bootstrapped on s390x. No regressions.

Bye,

-Andreas-

gcc/ChangeLog:

2015-07-22  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

	* config/s390/s390.c (s390_save_gprs_to_fprs): Add CFA_REGISTER
	reg note to the GPR -> FPR save instructions.

gcc/testsuite/ChangeLog:

2015-07-22  Andreas Krebbel  <krebbel@linux.vnet.ibm.com>

	* gcc.target/s390/gpr2fprsavecfi.c: New test.
diff mbox

Patch

diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index faf7621..a31f33c 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -10134,6 +10134,10 @@  s390_save_gprs_to_fprs (void)
 	    emit_move_insn (gen_rtx_REG (DImode, cfun_gpr_save_slot (i)),
 			    gen_rtx_REG (DImode, i));
 	  RTX_FRAME_RELATED_P (insn) = 1;
+	  /* This prevents dwarf2cfi from interpreting the set.  Doing
+	     so it might emit def_cfa_register infos setting an FPR as
+	     new CFA.  */
+	  add_reg_note (insn, REG_CFA_REGISTER, PATTERN (insn));
 	}
     }
 }
diff --git a/gcc/testsuite/gcc.target/s390/gpr2fprsavecfi.c b/gcc/testsuite/gcc.target/s390/gpr2fprsavecfi.c
new file mode 100644
index 0000000..92a0d3a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/gpr2fprsavecfi.c
@@ -0,0 +1,23 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O3 -march=z10 -mzarch -fdwarf2-cfi-asm" } */
+
+char *gl[100];
+
+long
+foo ()
+{
+  long r = 0;
+  char bla[100];
+  int i;
+
+  __builtin_memcpy (bla, gl, 100);
+
+  for (i = 0; i < 100; i++)
+    r += bla[i];
+
+  return r;
+}
+
+/* { dg-final { scan-assembler-not "cfi_def_cfa_register" } } */
+/* { dg-final { scan-assembler "cfi_register" } } */
+/* { dg-final { scan-assembler "cfi_def_cfa_offset" } } */