public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/110188] New: gcc for RISC-V stack aligned error
@ 2023-06-09  7:27 jzhgonha at 163 dot com
  2023-06-09  7:56 ` [Bug target/110188] " pinskia at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: jzhgonha at 163 dot com @ 2023-06-09  7:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110188

            Bug ID: 110188
           Summary: gcc for RISC-V stack aligned error
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jzhgonha at 163 dot com
  Target Milestone: ---

I use gcc(10.2.0) which is for RISC-V to compile a C language function,
according to disassembly language, stack just consumed 3word(12bytes), RISC-V
specification stipulate stack must aligned 16byte, but actual "addi sp,sp,-32"
show that stack occupy 32bytes, why not 16bytes?
I have tried different optimization levels, but all occupy 32bytes.
I also have tried another compiler which is called zcc, that occupy 16bytes.

C code main.c is following
int myadd(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int
a9);
int main(void)
{
    return myadd(1,2,3,4,5,6,7,8,9);
}

command line is following
riscv64-unknown-elf-gcc -c main.c -o main.o -march=rv32imac
-mpreferred-stack-boundary=4
riscv64-unknown-elf-objdump -d main.o > main.asm

diassembly main.asm is following
00000000 <main>:
   0:   1101                    addi    sp,sp,-32
   2:   ce06                    sw      ra,28(sp)
   4:   cc22                    sw      s0,24(sp)
   6:   1000                    addi    s0,sp,32
   8:   47a5                    li      a5,9
   a:   c03e                    sw      a5,0(sp)
   c:   48a1                    li      a7,8
   e:   481d                    li      a6,7
  10:   4799                    li      a5,6
  12:   4715                    li      a4,5
  14:   4691                    li      a3,4
  16:   460d                    li      a2,3
  18:   4589                    li      a1,2
  1a:   4505                    li      a0,1
  1c:   00000097                auipc   ra,0x0
  20:   000080e7                jalr    ra # 1c <main+0x1c>
  24:   87aa                    mv      a5,a0
  26:   853e                    mv      a0,a5
  28:   40f2                    lw      ra,28(sp)
  2a:   4462                    lw      s0,24(sp)
  2c:   6105                    addi    sp,sp,32
  2e:   8082                    ret

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-06-12  0:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-09  7:27 [Bug c/110188] New: gcc for RISC-V stack aligned error jzhgonha at 163 dot com
2023-06-09  7:56 ` [Bug target/110188] " pinskia at gcc dot gnu.org
2023-06-09  8:06 ` 18761437418 at 163 dot com
2023-06-09  8:20 ` schwab@linux-m68k.org
2023-06-09 12:59 ` 18761437418 at 163 dot com
2023-06-09 13:51 ` kito at gcc dot gnu.org
2023-06-12  0:15 ` jzhgonha at 163 dot com

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).