RISC-V Embedded, code generator seems to use wrong registers.
Original Reporter info from Mantis: Bernd
-
Reporter name: Bernd
Original Reporter info from Mantis: Bernd
- Reporter name: Bernd
Description:
The attached test program was compiled with the following options:
ppcrossrv32 -CpRV32IMAC -Tembedded -WpGD32VF103CB -k-melf32lriscv -B -al -O2 test.pas
The test program fails, because the local copy of the shortstring variable sIn (in the procedure TestShortString) is corrupt. I think, that fpc_shortstr_to_shortstr is called with a wrong register setup.
The relevant part of TestShortString is assembled to:
.section .text.n_p$test_$$_testshortstring$shortstring,"ax" .balign 4 .globl P$TEST_$$_TESTSHORTSTRING$SHORTSTRING P$TEST_$$_TESTSHORTSTRING$SHORTSTRING: # Temps allocated between x8-316 and x8-60 # [test.pas] # [9] begin addi x2,x2,-8 sw x1,4(x2) sw x8,0(x2) addi x8,x2,8 addi x2,x2,-316 # Var sIn located at x8-56, size=OS_32 # Var b located at x8-60, size=OS_8 sw x10,-56(x8) lw x10,-56(x8) addi x13,x10,0 &LtPos;&LtPos;< x13 should be x12 addi x12,x0,255 &LtPos;&LtPos;< x12 should be x11 addi x11,x8,-316 &LtPos;&LtPos;< x11 should be x10 .Lj5: auipc x1,%pcrel_hi(fpc_shortstr_to_shortstr) jalr x1,x1,%pcrel_lo(.Lj5)
If I swap the registers at runtime, the program runs correct.
Mantis conversion info:
- Mantis ID: 37709
- OS: Embedded
- Build: 46784
- Platform: RISC-V
- Fixed in version: 3.3.1
- Fixed in revision: 46803 (#c8f592d2)