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: Add CFI for mcount call sequences


Fixes unwind for mcount.

2018-07-17  Ilya Leoshkevich  <iii@linux.ibm.com>

	* config/s390/s390.c (s390_function_profiler):
        Generate CFI.
---
 gcc/config/s390/s390.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index ba18cb1c39a..3627f41eb05 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -13153,7 +13153,7 @@ output_asm_nops (const char *user, int hw)
 void
 s390_function_profiler (FILE *file, int labelno)
 {
-  rtx op[7];
+  rtx op[8];
 
   char label[128];
   ASM_GENERATE_INTERNAL_LABEL (label, "LP", labelno);
@@ -13163,6 +13163,7 @@ s390_function_profiler (FILE *file, int labelno)
   op[0] = gen_rtx_REG (Pmode, RETURN_REGNUM);
   op[1] = gen_rtx_REG (Pmode, STACK_POINTER_REGNUM);
   op[1] = gen_rtx_MEM (Pmode, plus_constant (Pmode, op[1], UNITS_PER_LONG));
+  op[7] = GEN_INT (UNITS_PER_LONG);
 
   op[2] = gen_rtx_REG (Pmode, 1);
   op[3] = gen_rtx_SYMBOL_REF (Pmode, label);
@@ -13196,9 +13197,13 @@ s390_function_profiler (FILE *file, int labelno)
       else
         {
           output_asm_insn ("stg\t%0,%1", op);
+          if (flag_dwarf2_cfi_asm)
+            output_asm_insn (".cfi_rel_offset\t%0,%7", op);
           output_asm_insn ("larl\t%2,%3", op);
           output_asm_insn ("brasl\t%0,%4", op);
           output_asm_insn ("lg\t%0,%1", op);
+          if (flag_dwarf2_cfi_asm)
+            output_asm_insn (".cfi_restore\t%0", op);
         }
     }
   else if (TARGET_CPU_ZARCH)
@@ -13209,9 +13214,13 @@ s390_function_profiler (FILE *file, int labelno)
       else
         {
           output_asm_insn ("st\t%0,%1", op);
+          if (flag_dwarf2_cfi_asm)
+            output_asm_insn (".cfi_rel_offset\t%0,%7", op);
           output_asm_insn ("larl\t%2,%3", op);
           output_asm_insn ("brasl\t%0,%4", op);
           output_asm_insn ("l\t%0,%1", op);
+          if (flag_dwarf2_cfi_asm)
+            output_asm_insn (".cfi_restore\t%0", op);
         }
     }
   else if (!flag_pic)
@@ -13225,6 +13234,8 @@ s390_function_profiler (FILE *file, int labelno)
       else
         {
           output_asm_insn ("st\t%0,%1", op);
+          if (flag_dwarf2_cfi_asm)
+            output_asm_insn (".cfi_rel_offset\t%0,%7", op);
           output_asm_insn ("bras\t%2,%l6", op);
           output_asm_insn (".long\t%4", op);
           output_asm_insn (".long\t%3", op);
@@ -13234,6 +13245,8 @@ s390_function_profiler (FILE *file, int labelno)
           output_asm_insn ("l\t%2,4(%2)", op);
           output_asm_insn ("basr\t%0,%0", op);
           output_asm_insn ("l\t%0,%1", op);
+          if (flag_dwarf2_cfi_asm)
+            output_asm_insn (".cfi_restore\t%0", op);
         }
     }
   else
@@ -13248,6 +13261,8 @@ s390_function_profiler (FILE *file, int labelno)
       else
         {
           output_asm_insn ("st\t%0,%1", op);
+          if (flag_dwarf2_cfi_asm)
+            output_asm_insn (".cfi_rel_offset\t%0,%7", op);
           output_asm_insn ("bras\t%2,%l6", op);
           targetm.asm_out.internal_label (file, "L",
                                           CODE_LABEL_NUMBER (op[5]));
@@ -13260,6 +13275,8 @@ s390_function_profiler (FILE *file, int labelno)
           output_asm_insn ("a\t%2,4(%2)", op);
           output_asm_insn ("basr\t%0,%0", op);
           output_asm_insn ("l\t%0,%1", op);
+          if (flag_dwarf2_cfi_asm)
+            output_asm_insn (".cfi_restore\t%0", op);
         }
     }
 
-- 
2.17.1


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