public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] [RISC-V] fix cfi issue in save-restore.
@ 2023-06-05 16:18 Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2023-06-05 16:18 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:218979975305aea1a95557f8312f9775b2e919f8

commit 218979975305aea1a95557f8312f9775b2e919f8
Author: Fei Gao <gaofei@eswincomputing.com>
Date:   Sat Jun 3 11:11:18 2023 -0600

    [RISC-V] fix cfi issue in save-restore.
    
    This patch fixes a cfi issue introduced by
    https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=60524be1e3929d83e15fceac6e2aa053c8a6fb20
    
    Test code:
    char my_getchar();
    float getf();
    int test_f0()
    {
      int s0 = my_getchar();
      float f0 = getf();
      int b = my_getchar();
      return f0+s0+b;
    }
    
    cflags: -g -Os -march=rv32imafc -mabi=ilp32f -msave-restore -mcmodel=medlow
    
    before patch:
    test_f0:
    ...
            .cfi_startproc
            call    t0,__riscv_save_1
            .cfi_offset 8, -8
            .cfi_offset 1, -4
            .cfi_def_cfa_offset 16
    ...
            addi    sp,sp,-16
            .cfi_def_cfa_offset 32
    
    ...
    
            addi    sp,sp,16
            .cfi_def_cfa_offset 0  // issue here
    ...
            tail    __riscv_restore_1
            .cfi_restore 8
            .cfi_restore 1
            .cfi_def_cfa_offset -16 // issue here
            .cfi_endproc
    
    after patch:
    test_f0:
    ...
            .cfi_startproc
            call    t0,__riscv_save_1
            .cfi_offset 8, -8
            .cfi_offset 1, -4
            .cfi_def_cfa_offset 16
    ...
            addi    sp,sp,-16
            .cfi_def_cfa_offset 32
    
    ...
    
            addi    sp,sp,16
            .cfi_def_cfa_offset 16  // corrected here
    ...
            tail    __riscv_restore_1
            .cfi_restore 8
            .cfi_restore 1
            .cfi_def_cfa_offset 0 // corrected here
            .cfi_endproc
    
    gcc/ChangeLog:
    
            * config/riscv/riscv.cc (riscv_expand_epilogue): fix cfi issue with
            correct offset.

Diff:
---
 gcc/config/riscv/riscv.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 85db1e3c86b..caa7858b864 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -5652,7 +5652,7 @@ riscv_expand_epilogue (int style)
 					   adjust));
 	  rtx dwarf = NULL_RTX;
 	  rtx cfa_adjust_rtx = gen_rtx_PLUS (Pmode, stack_pointer_rtx,
-					     GEN_INT (step2));
+					     GEN_INT (step2 + libcall_size));
 
 	  dwarf = alloc_reg_note (REG_CFA_DEF_CFA, cfa_adjust_rtx, dwarf);
 	  RTX_FRAME_RELATED_P (insn) = 1;
@@ -5689,7 +5689,7 @@ riscv_expand_epilogue (int style)
 
       rtx dwarf = NULL_RTX;
       rtx cfa_adjust_rtx = gen_rtx_PLUS (Pmode, stack_pointer_rtx,
-					 const0_rtx);
+					 GEN_INT (libcall_size));
       dwarf = alloc_reg_note (REG_CFA_DEF_CFA, cfa_adjust_rtx, dwarf);
       RTX_FRAME_RELATED_P (insn) = 1;

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] [RISC-V] fix cfi issue in save-restore.
@ 2023-07-14  2:42 Jeff Law
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Law @ 2023-07-14  2:42 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:cef4b933d7f07d6a56252b97184549a964fb9e5e

commit cef4b933d7f07d6a56252b97184549a964fb9e5e
Author: Fei Gao <gaofei@eswincomputing.com>
Date:   Sat Jun 3 11:11:18 2023 -0600

    [RISC-V] fix cfi issue in save-restore.
    
    This patch fixes a cfi issue introduced by
    https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=60524be1e3929d83e15fceac6e2aa053c8a6fb20
    
    Test code:
    char my_getchar();
    float getf();
    int test_f0()
    {
      int s0 = my_getchar();
      float f0 = getf();
      int b = my_getchar();
      return f0+s0+b;
    }
    
    cflags: -g -Os -march=rv32imafc -mabi=ilp32f -msave-restore -mcmodel=medlow
    
    before patch:
    test_f0:
    ...
            .cfi_startproc
            call    t0,__riscv_save_1
            .cfi_offset 8, -8
            .cfi_offset 1, -4
            .cfi_def_cfa_offset 16
    ...
            addi    sp,sp,-16
            .cfi_def_cfa_offset 32
    
    ...
    
            addi    sp,sp,16
            .cfi_def_cfa_offset 0  // issue here
    ...
            tail    __riscv_restore_1
            .cfi_restore 8
            .cfi_restore 1
            .cfi_def_cfa_offset -16 // issue here
            .cfi_endproc
    
    after patch:
    test_f0:
    ...
            .cfi_startproc
            call    t0,__riscv_save_1
            .cfi_offset 8, -8
            .cfi_offset 1, -4
            .cfi_def_cfa_offset 16
    ...
            addi    sp,sp,-16
            .cfi_def_cfa_offset 32
    
    ...
    
            addi    sp,sp,16
            .cfi_def_cfa_offset 16  // corrected here
    ...
            tail    __riscv_restore_1
            .cfi_restore 8
            .cfi_restore 1
            .cfi_def_cfa_offset 0 // corrected here
            .cfi_endproc
    
    gcc/ChangeLog:
    
            * config/riscv/riscv.cc (riscv_expand_epilogue): fix cfi issue with
            correct offset.

Diff:
---
 gcc/config/riscv/riscv.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 85db1e3c86b..caa7858b864 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -5652,7 +5652,7 @@ riscv_expand_epilogue (int style)
 					   adjust));
 	  rtx dwarf = NULL_RTX;
 	  rtx cfa_adjust_rtx = gen_rtx_PLUS (Pmode, stack_pointer_rtx,
-					     GEN_INT (step2));
+					     GEN_INT (step2 + libcall_size));
 
 	  dwarf = alloc_reg_note (REG_CFA_DEF_CFA, cfa_adjust_rtx, dwarf);
 	  RTX_FRAME_RELATED_P (insn) = 1;
@@ -5689,7 +5689,7 @@ riscv_expand_epilogue (int style)
 
       rtx dwarf = NULL_RTX;
       rtx cfa_adjust_rtx = gen_rtx_PLUS (Pmode, stack_pointer_rtx,
-					 const0_rtx);
+					 GEN_INT (libcall_size));
       dwarf = alloc_reg_note (REG_CFA_DEF_CFA, cfa_adjust_rtx, dwarf);
       RTX_FRAME_RELATED_P (insn) = 1;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-07-14  2:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-05 16:18 [gcc(refs/vendors/riscv/heads/gcc-13-with-riscv-opts)] [RISC-V] fix cfi issue in save-restore Jeff Law
2023-07-14  2:42 Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).