public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/110634] New: Incorrect RISC-V assembly with -fno-omit-frame-pointer
@ 2023-07-11 19:43 bjorn at kernel dot org
  2023-07-11 19:47 ` [Bug target/110634] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: bjorn at kernel dot org @ 2023-07-11 19:43 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 110634
           Summary: Incorrect RISC-V assembly with -fno-omit-frame-pointer
           Product: gcc
           Version: 12.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bjorn at kernel dot org
  Target Milestone: ---

Is see inconsistencies when comparing -fno-omit-frame-pointer GCC and clang
builds. 

$ cat foo.c
int foo(int a, int b) {
  return a + b;
}

$ clang-17 --target=riscv64-linux-gnu -O3 -fno-omit-frame-pointer -c foo.c -o
foo.o && riscv64-linux-gnu-objdump -d foo.o 

foo.o:     file format elf64-littleriscv


Disassembly of section .text:

0000000000000000 <foo>:
   0:   1141                    add     sp,sp,-16
   2:   e406                    sd      ra,8(sp)
   4:   e022                    sd      s0,0(sp)
   6:   0800                    add     s0,sp,16
   8:   9d2d                    addw    a0,a0,a1
   a:   60a2                    ld      ra,8(sp)
   c:   6402                    ld      s0,0(sp)
   e:   0141                    add     sp,sp,16
  10:   8082                    ret


Where GCC yields:

$ riscv64-linux-gnu-gcc -O3 -fno-omit-frame-pointer -c foo.c -o foo.o &&
riscv64-linux-gnu-objdump -d foo.o 

foo.o:     file format elf64-littleriscv


Disassembly of section .text:

0000000000000000 <foo>:
   0:   1141                    add     sp,sp,-16
   2:   e422                    sd      s0,8(sp)
   4:   0800                    add     s0,sp,16
   6:   6422                    ld      s0,8(sp)
   8:   9d2d                    addw    a0,a0,a1
   a:   0141                    add     sp,sp,16
   c:   8082                    ret


I would expect GCC to store "ra" similar to clang, but the spec is a bit vague
[1].

https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc#frame-pointer-convention

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

end of thread, other threads:[~2023-07-19 17:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-11 19:43 [Bug c/110634] New: Incorrect RISC-V assembly with -fno-omit-frame-pointer bjorn at kernel dot org
2023-07-11 19:47 ` [Bug target/110634] " pinskia at gcc dot gnu.org
2023-07-11 19:50 ` bjorn at kernel dot org
2023-07-11 19:52 ` pinskia at gcc dot gnu.org
2023-07-11 20:07 ` schwab@linux-m68k.org
2023-07-19 17:57 ` cleger at rivosinc 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).