From: Xi Ruoyao <xry111@xry111.site>
To: Andreas Schwab <schwab@suse.de>, caiyinyu <caiyinyu@loongson.cn>,
adhemerval.zanella@linaro.org
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] LoongArch: Add Syscall Assembly Implementation
Date: Fri, 24 Mar 2023 02:26:17 +0800 [thread overview]
Message-ID: <715a25cdd0fb53c8948e0d782d2149a68a62cbb7.camel@xry111.site> (raw)
In-Reply-To: <ff40e7eb4f1c12175d81170d81db03d6dcb54603.camel@xry111.site>
On Fri, 2023-03-24 at 01:34 +0800, Xi Ruoyao via Libc-alpha wrote:
> On Thu, 2023-03-23 at 21:43 +0800, Xi Ruoyao wrote:
> > On Thu, 2023-03-23 at 21:34 +0800, Xi Ruoyao wrote:
> > > On Thu, 2023-03-23 at 14:12 +0100, Andreas Schwab wrote:
> > > > On Mär 23 2023, caiyinyu wrote:
> > > >
> > > > > Without this patch(objdump -d libc.so...):
> > > > >
> > > > > 00000000000dd45c <syscall>:
> > > > > dd45c: 02fec063 addi.d $sp, $sp, -
> > > > > 80(0xfb0)
> > > > > dd460: 02c0606c addi.d $t0, $sp, 24(0x18)
> > > > > dd464: 29c06065 st.d $a1, $sp, 24(0x18)
> > > > > dd468: 29c08066 st.d $a2, $sp, 32(0x20)
> > > > > dd46c: 29c0a067 st.d $a3, $sp, 40(0x28)
> > > > > dd470: 29c0c068 st.d $a4, $sp, 48(0x30)
> > > > > dd474: 29c0e069 st.d $a5, $sp, 56(0x38)
> > > > > dd478: 29c1206b st.d $a7, $sp, 72(0x48)
> > > > > dd47c: 29c1006a st.d $a6, $sp, 64(0x40)
> > > >
> > > > If the argument registers are call-clobbbered, why does the compiler
> > > > need to save them?
> > >
> > > It seems triggered by va_start. If I don't use "..." and replace it
> > > with "a0, a1, a2, ..., a5", and remove va_start ... va_end, the
> > > compiled
> > > code won't save registers.
> > >
> > > I'll try to investigate further.
> >
> > Similar to GCC PR100955.
>
> Nope, it's not PR100955. PR100955 is about AArch64 but syscall is
> compiled to almost perfect assemble code on AArch64.
I was wrong. AArch64 has a assembly syscall.
> It looks like caused by the lack of [TARGET_SETUP_INCOMING_VARARGS][1]
> in GCC config/loongarch. I'll try to add it...
LoongArch has a TARGET_SETUP_INCOMING_VARARGS but it does not use the
information from stdarg pass. I can fix it, but even with the fix GCC
would still save 7 registers (now GCC trunk saves 9 registers, the fix
would make some improvement but no much).
And the issue seems not trivial to fix. On x86_64, all of GCC, Clang,
and MSVC will save some registers if va_arg is used. I've not found any
compiler which can avoid saving the va_arg GARs unnecessarily yet:
https://godbolt.org/z/n1YqWq9c9
Now to me it seems a bad idea to use va_arg in syscall.c.
--
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University
next prev parent reply other threads:[~2023-03-23 18:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-23 8:40 caiyinyu
2023-03-23 9:25 ` Xi Ruoyao
2023-03-23 12:01 ` caiyinyu
2023-03-23 13:12 ` Andreas Schwab
2023-03-23 13:34 ` Xi Ruoyao
2023-03-23 13:43 ` Xi Ruoyao
2023-03-23 17:34 ` Xi Ruoyao
2023-03-23 18:26 ` Xi Ruoyao [this message]
2023-03-23 18:40 ` Adhemerval Zanella Netto
2023-03-23 19:08 ` Xi Ruoyao
2023-03-23 13:12 ` Xi Ruoyao
2023-03-23 12:00 caiyinyu
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=715a25cdd0fb53c8948e0d782d2149a68a62cbb7.camel@xry111.site \
--to=xry111@xry111.site \
--cc=adhemerval.zanella@linaro.org \
--cc=caiyinyu@loongson.cn \
--cc=libc-alpha@sourceware.org \
--cc=schwab@suse.de \
/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).