Menu

#3482 Warning: Non-connected liverange found

closed-fixed
None
other
5
2023-12-12
2022-09-12
Under4Mhz
No

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)
1 Attachments

Discussion

  • Philipp Klaus Krause

    I can reproduce both issues using sdcc from current trunk on my Debian GNU/Linux testing amd64 system.

    Weird stuff that happens here:

    • A dead parameter receive is not eliminated
    • The live-range splitter apparently didn't split the two different percent from each other - both end up as iTemp0. So we have a non-connceted live-range of iTemp0.
    • The non-connected range is found, and extended (as it should) resulting in the warning.
    • Code generation apparently gets confused about the live-range of iTemp0 including the call to 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
  • Philipp Klaus Krause

    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]

  • Philipp Klaus Krause

    • status: open --> closed-fixed
    • assigned_to: Philipp Klaus Krause
     
  • Philipp Klaus Krause

    The rest of this bug is fixed in [r14527].

     

    Related

    Commit: [r14527]


Log in to post a comment.