public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Fei Gao <gaofei@eswincomputing.com>, gcc-patches@gcc.gnu.org
Cc: kito.cheng@gmail.com, palmer@dabbelt.com,
	sinan.lin@linux.alibaba.com, jiawei@iscas.ac.cn
Subject: Re: [PATCH 1/2] [RISC-V] fix cfi issue in save-restore.
Date: Sat, 3 Jun 2023 11:12:41 -0600	[thread overview]
Message-ID: <c996932c-c866-7f68-5d42-d37c3b29a88d@gmail.com> (raw)
In-Reply-To: <20230602104247.26454-1-gaofei@eswincomputing.com>



On 6/2/23 04:42, Fei Gao wrote:
> 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.
I fixed a trivial whitespace problem, rewrapped the ChangeLog and pushed 
this patch to the trunk.  Please consider adding a testcase for this bug 
to the testsuite.

jeff

      parent reply	other threads:[~2023-06-03 17:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-02 10:42 Fei Gao
2023-06-02 10:42 ` [PATCH 2/2] [V3] [RISC-V] support cm.push cm.pop cm.popret in zcmp Fei Gao
2023-06-05  8:31   ` Kito Cheng
2023-06-05  8:41     ` jiawei
2023-06-05  8:44     ` Fei Gao
2023-06-03 17:12 ` Jeff Law [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c996932c-c866-7f68-5d42-d37c3b29a88d@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gaofei@eswincomputing.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jiawei@iscas.ac.cn \
    --cc=kito.cheng@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=sinan.lin@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).