public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Max Filippov <jcmvbkbc@gmail.com>
To: "Takayuki 'January June' Suwa" <jjsuwa_sys3175@yahoo.co.jp>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH v2 2/5] xtensa: Add support for sibling call optimization
Date: Wed, 15 Jun 2022 17:00:52 -0700	[thread overview]
Message-ID: <CAMo8BfJ+34JtgrTq_5XORQfCh93KFu7GHqRZNY0g09-PgF4iGA@mail.gmail.com> (raw)
In-Reply-To: <ff631cb0-3b12-e9d7-8910-f34ec0fa3ed3@yahoo.co.jp>

On Wed, Jun 15, 2022 at 5:23 AM Takayuki 'January June' Suwa
<jjsuwa_sys3175@yahoo.co.jp> wrote:
>
> On 2022/06/15 5:17, Max Filippov wrote:
> > Hi Suwa-san,
> hi!
>
> > This change results in a bunch of new regression test failures:
> > The code generated for e.g. gcc.c-torture/execute/921208-2.c looks like this:
> oh, PICed...
>
> indirect (incl. via function pointer, virtual functions and of course PIC ones in Xtensa ISA) sibcalls must be avoided if pointer to the target cannot be retained during function epilogue.
> otherwise, it will be look like this:
> >       callx0  a14
> >       l32i.n  a0, sp, 12
> >       l32i.n  a14, sp, 0      // restored by the epilogue because A14 is callee-saved
> >       mov.n   a4, a12
> >       mov.n   a5, a13
> >       l32i.n  a12, sp, 8
> >       l32i.n  a13, sp, 4
> >       l32r    a3, .LC4
> >       movi.n  a2, 0
> >       addi    sp, sp, 16
> >       jx      a14             // but A14 pointed to g@PLT in this function...
>
> luckily, no role is assigned from A9 to A11 in call0 ABI (A9 is already used inside of the pro/epilogue), and the "split2" stage is prior to "pro_and_epilogue"...
>
> ===
> This patch introduces support for sibling call optimization, when call0
> ABI is in effect.
>
> gcc/ChangeLog:
>
>         * config/xtensa/xtensa-protos.h (xtensa_prepare_expand_call,
>         xtensa_emit_sibcall): New prototypes.
>         (xtensa_expand_epilogue): Add new argument that specifies whether
>         or not sibling call.
>         * config/xtensa/xtensa.cc (TARGET_FUNCTION_OK_FOR_SIBCALL):
>         New macro definition.
>         (xtensa_prepare_expand_call): New function in order to share
>         the common code.
>         (xtensa_emit_sibcall, xtensa_function_ok_for_sibcall):
>         New functions.
>         (xtensa_expand_epilogue): Add new argument sibcall_p and use it
>         for sibling call handling.
>         * config/xtensa/xtensa.md (call, call_value):
>         Use xtensa_prepare_expand_call.
>         (call_internal, call_value_internal):
>         Add the condition in order to be disabled if sibling call.
>         (sibcall, sibcall_value, sibcall_epilogue): New expansions.
>         (sibcall_internal, sibcall_value_internal): New insn patterns,
>         and split ones in order to take care of the indirect sibcalls.
>
> gcc/testsuite/ChangeLog:
>
>         * gcc.target/xtensa/sibcalls.c: New.
> ---
>  gcc/config/xtensa/xtensa-protos.h          |  4 +-
>  gcc/config/xtensa/xtensa.cc                | 58 +++++++++++++-
>  gcc/config/xtensa/xtensa.md                | 93 ++++++++++++++++++----
>  gcc/testsuite/gcc.target/xtensa/sibcalls.c | 20 +++++
>  4 files changed, 155 insertions(+), 20 deletions(-)
>  create mode 100644 gcc/testsuite/gcc.target/xtensa/sibcalls.c

Regtested for target=xtensa-linux-uclibc, no new regressions.
Committed to master.

-- 
Thanks.
-- Max

      reply	other threads:[~2022-06-16  0:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-14  3:36 [PATCH " Takayuki 'January June' Suwa
2022-06-14 20:17 ` Max Filippov
2022-06-15 12:21   ` [PATCH v2 " Takayuki 'January June' Suwa
2022-06-16  0:00     ` Max Filippov [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=CAMo8BfJ+34JtgrTq_5XORQfCh93KFu7GHqRZNY0g09-PgF4iGA@mail.gmail.com \
    --to=jcmvbkbc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jjsuwa_sys3175@yahoo.co.jp \
    /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).