aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/config/riscv/riscv.cc10
-rw-r--r--gcc/testsuite/gcc.target/riscv/save-restore-cfi-2.c16
2 files changed, 21 insertions, 5 deletions
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index caa7858..3954c89 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -5370,10 +5370,10 @@ riscv_adjust_libcall_cfi_prologue ()
else
offset = saved_size - ((regno - S2_REGNUM + 4) * UNITS_PER_WORD);
- reg = gen_rtx_REG (SImode, regno);
- mem = gen_frame_mem (SImode, plus_constant (Pmode,
- stack_pointer_rtx,
- offset));
+ reg = gen_rtx_REG (Pmode, regno);
+ mem = gen_frame_mem (Pmode, plus_constant (Pmode,
+ stack_pointer_rtx,
+ offset));
insn = gen_rtx_SET (mem, reg);
dwarf = alloc_reg_note (REG_CFA_OFFSET, insn, dwarf);
@@ -5510,7 +5510,7 @@ riscv_adjust_libcall_cfi_epilogue ()
for (int regno = GP_REG_FIRST; regno <= GP_REG_LAST; regno++)
if (BITSET_P (cfun->machine->frame.mask, regno - GP_REG_FIRST))
{
- reg = gen_rtx_REG (SImode, regno);
+ reg = gen_rtx_REG (Pmode, regno);
dwarf = alloc_reg_note (REG_CFA_RESTORE, reg, dwarf);
}
diff --git a/gcc/testsuite/gcc.target/riscv/save-restore-cfi-2.c b/gcc/testsuite/gcc.target/riscv/save-restore-cfi-2.c
new file mode 100644
index 0000000..44d805b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/save-restore-cfi-2.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-rtl-pro_and_epilogue -O2 -march=rv64gc -mabi=lp64d -msave-restore -mcmodel=medany" } */
+/* { dg-skip-if "" { *-*-* } {"-Os" "-O1" "-O0" "-Og" "-O3" "-Oz" "-flto"} } */
+/* { dg-final { scan-rtl-dump {expr_list:REG_CFA_OFFSET \(set \(mem/c:DI} "pro_and_epilogue" } } */
+/* { dg-final { scan-rtl-dump {expr_list:REG_CFA_RESTORE \(reg:DI 8 s0\)} "pro_and_epilogue" } } */
+
+char my_getchar();
+float getf();
+
+int foo()
+{
+ int s0 = my_getchar();
+ float f0 = getf();
+ int b = my_getchar();
+ return f0 + s0 + b;
+}