This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] S/390: Fix cfi for GPR 2 FPR saves


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 --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" } } */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]