The below code gives me the below warning. The resultant code doesn't work.
sdcc -mz80 ./liverange.c
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp0. Please contact sdcc authors with source code to reproduce.
/// GPL 2.0 or later
#include <stdint.h>
uint16_t fast_rand();
void StatePlayerHit( uint8_t amount );
void PlayerHit( int8_t percent ) {
percent = fast_rand() % 8 + 8;
StatePlayerHit( percent );
}
void main() { PlayerHit(1); }
//sdcc -mz80 --fverbose-asm ./liverange.c -c && ucsim_z80 -I if=outputs[0xff] liverange.ihx
sdcc -mz80 ./liverange.c
./liverange.c:3: warning 283: function declarator with no prototype
Warning: Non-connected liverange found and extended to connected component of the CFG:iTemp0. Please contact sdcc authors with source code to reproduce.
sdcc -v
SDCC : mcs51/z80/z180/r2k/r2ka/r3ka/sm83/tlcs90/ez80_z80/z80n/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15/mos6502 4.2.9 #13701 (Linux)
I can reproduce both issues using sdcc from current trunk on my Debian GNU/Linux testing amd64 system.
Weird stuff that happens here:
percentfrom each other - both end up as iTemp0. So we have a non-connceted live-range of iTemp0.StatePlayerHit: On one hand bc is saved (as it should if iTemp0 is alive there), on the other hand tail-call optimization behaves as if it wasn't alive there. In the end, we get code that corrupts the stack.Last edit: Philipp Klaus Krause 2023-12-12
In [r14526] the code generation part of this bug is fixed. The problem of a non-connected liverange is still there, but at least that is only a code quality problem, not wrong code anymore.
Related
Commit: [r14526]
The rest of this bug is fixed in [r14527].
Related
Commit: [r14527]