public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/112478] New: riscv: asm clobbers not honored
@ 2023-11-10 15:39 Michael at MichaelKloos dot com
  2023-11-10 15:49 ` [Bug target/112478] " Michael at MichaelKloos dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Michael at MichaelKloos dot com @ 2023-11-10 15:39 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 112478
           Summary: riscv: asm clobbers not honored
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Michael at MichaelKloos dot com
  Target Milestone: ---

A recent commit (bisected): 

71f906498ada9ec2780660b03bd6e27a93ad350c 
RISC-V: far-branch: Handle far jumps and branches for functions larger than 1MB 

Seems to have broken call inline asm clobbers for for the $ra register.  

I attempted to build a riscv32-rv32ia3-linux-musl cross compiler on a
x86_64-pc-linux-gnu system.  I succeeded in building the compiler and using it
to build my target binary.  However, the target binary was crashing.  On
inspection, I discovered that __muldi3 from libgcc was calling __mulsi3, but
not saving the ra (link) register.  Upon return from __mulsi3, an infinate loop
was entered between the reentry point and the end of the function, as the
return instruction was now pointing back at the reentry point.  The
intermediate code formed a loop that moved and loaded data off the stack
pointer until the program segfaulted.  libgcc makes the call to __mulsi3 with
inline assembly and sets ra as one of the clobbered registers.  

Some of the configure options used are --disable-multilib --with-arch=rv32ia
--with-abi=ilp32 --enable-checking=none

--enable-checking=none is there to work around another build-time bug which I
will file separately.  

If you need more information, let me know.

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

end of thread, other threads:[~2023-11-16 23:06 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-10 15:39 [Bug c/112478] New: riscv: asm clobbers not honored Michael at MichaelKloos dot com
2023-11-10 15:49 ` [Bug target/112478] " Michael at MichaelKloos dot com
2023-11-10 16:49 ` andrew at sifive dot com
2023-11-11 17:02 ` Michael at MichaelKloos dot com
2023-11-13 19:18 ` law at gcc dot gnu.org
2023-11-13 20:22 ` Michael at MichaelKloos dot com
2023-11-14  2:10 ` kito at gcc dot gnu.org
2023-11-14 15:22 ` Michael at MichaelKloos dot com
2023-11-14 16:24 ` kito at gcc dot gnu.org
2023-11-16 11:36 ` cvs-commit at gcc dot gnu.org
2023-11-16 23:06 ` kito at gcc dot gnu.org

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