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