public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Kito Cheng <kito.cheng@gmail.com>
To: Jin Ma <jinma@linux.alibaba.com>
Cc: gcc-patches@gcc.gnu.org, kito.cheng@sifive.com, palmer@dabbelt.com
Subject: Re: [PATCH v1] RISC-V: Change the generation mode of ADJUST_SP_RTX from gen_insn to gen_SET.
Date: Sun, 12 Feb 2023 19:34:28 +0800	[thread overview]
Message-ID: <CA+yXCZD3zXUdhhTm6it-OFVgYdp03sB6TQorvwHroNFsOzw5hA@mail.gmail.com> (raw)
In-Reply-To: <20230203094259.673-1-jinma@linux.alibaba.com>

Committed, thanks :)

On Fri, Feb 3, 2023 at 5:45 PM Jin Ma via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> The gen_insn method is used to generate ADJUST_SP_RTX here, which has certain
> potential risks:
>
> When the architecture adds pre-processing to `define_insn "adddi3"`, such as
> `define_expend "adddi3"`, the gen_expand will be automatically called here,
> causing the patern to emit directly, which will cause insn to enter REG_NOTE
> for `DWARF` instead of patern.
>
> The following error REG_NOTE occurred:
> error: invalid rtl sharing found in the insn:
> (insn 19 3 20 2 (parallel [
>         ...
>         ])
>     (expr_list:REG_CFA_ADJUST_CFA
>         (insn 18 0 0 (set (reg/f:DI 2 sp)
>             (plus:DI (reg/f:DI 2 sp)
>                 (const_int -16 [0xfffffffffffffff0]))) -1
>         (nil))))
>
> In fact, the correct one should be the following:
> (insn 19 3 20 2 (parallel [
>         ...
>         ])
>     (expr_list:REG_CFA_ADJUST_CFA
>         (set (reg/f:DI 2 sp)
>             (plus:DI (reg/f:DI 2 sp)
>                 (const_int -16 [0xfffffffffffffff0])))))
>
> Following the treatment of arm or other architectures, it is more reasonable to
> use gen_SET here.
>
> gcc/ChangeLog:
>
>         * config/riscv/riscv.cc (riscv_adjust_libcall_cfi_prologue): Change gen_add3_insn
>         to gen_rtx_SET.
>         (riscv_adjust_libcall_cfi_epilogue): Likewise.
> ---
>  gcc/config/riscv/riscv.cc | 10 ++++++----
>  1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
> index 3b7804b7501..c9c6e53c6d0 100644
> --- a/gcc/config/riscv/riscv.cc
> +++ b/gcc/config/riscv/riscv.cc
> @@ -5054,8 +5054,9 @@ riscv_adjust_libcall_cfi_prologue ()
>        }
>
>    /* Debug info for adjust sp.  */
> -  adjust_sp_rtx = gen_add3_insn (stack_pointer_rtx,
> -                                stack_pointer_rtx, GEN_INT (-saved_size));
> +  adjust_sp_rtx =
> +    gen_rtx_SET (stack_pointer_rtx,
> +                gen_rtx_PLUS (GET_MODE(stack_pointer_rtx), stack_pointer_rtx, GEN_INT (-saved_size)));
>    dwarf = alloc_reg_note (REG_CFA_ADJUST_CFA, adjust_sp_rtx,
>                           dwarf);
>    return dwarf;
> @@ -5176,8 +5177,9 @@ riscv_adjust_libcall_cfi_epilogue ()
>    int saved_size = cfun->machine->frame.save_libcall_adjustment;
>
>    /* Debug info for adjust sp.  */
> -  adjust_sp_rtx = gen_add3_insn (stack_pointer_rtx,
> -                                stack_pointer_rtx, GEN_INT (saved_size));
> +  adjust_sp_rtx =
> +    gen_rtx_SET (stack_pointer_rtx,
> +                gen_rtx_PLUS (GET_MODE(stack_pointer_rtx), stack_pointer_rtx, GEN_INT (saved_size)));
>    dwarf = alloc_reg_note (REG_CFA_ADJUST_CFA, adjust_sp_rtx,
>                           dwarf);
>
> --
> 2.17.1
>

      reply	other threads:[~2023-02-12 11:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-03  9:42 Jin Ma
2023-02-12 11:34 ` Kito Cheng [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=CA+yXCZD3zXUdhhTm6it-OFVgYdp03sB6TQorvwHroNFsOzw5hA@mail.gmail.com \
    --to=kito.cheng@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jinma@linux.alibaba.com \
    --cc=kito.cheng@sifive.com \
    --cc=palmer@dabbelt.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).