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.

Reply via email to