[PATCH] LoongArch: Add Syscall Assembly Implementation

Xi Ruoyao xry111@xry111.site
Thu Mar 23 17:34:13 GMT 2023


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.

It looks like caused by the lack of [TARGET_SETUP_INCOMING_VARARGS][1]
in GCC config/loongarch.  I'll try to add it...

[1]: https://gcc.gnu.org/onlinedocs/gccint/Varargs.html#index-TARGET_005fSETUP_005fINCOMING_005fVARARGS

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University


More information about the Libc-alpha mailing list