$ sdcc -v
SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.7.1 #10419 (Linux)published under GNU General Public License (GPL)
Source code to reproduce the issu: https://github.com/EtchedPixels/FUZIX:
$ git clone https://github.com/EtchedPixels/FUZIX.git
$ cd FUZIX/Applications/MWC/cmd
$ sdcc -V --std-c99 -mz80 --less-pedantic --opt-code-size -D__FUZIX__ -Ddouble=float -I/opt/fcc/include/ -c calendar.c
- /opt/sdcc/bin/sdcpp -nostdinc -Wall -std=c99 -D__FUZIX__ -Ddouble=float -I/opt/fcc/include/ -obj-ext=.rel -D__SDCC_STACK_AUTO -D__SDCC_CHAR_UNSIGNED -
D__SDCC_INT_LONG_REENT -D__SDCC_FLOAT_REENT -D__SDCC=3_7_1 -D__SDCC_VERSION_MAJOR=3 -D__SDCC_VERSION_MINOR=7 -D__SDCC_VERSION_PATCH=1 -D__SDCC_REVISION=
10419 -D__SDCC_z80 -D__STDC_NO_COMPLEX__=1 -D__STDC_NO_THREADS__=1 -D__STDC_NO_ATOMICS__=1 -D__STDC_NO_VLA__=1 -D__STDC_ISO_10646__=201409L -D__STDC_UTF
_16__=1 -D__STDC_UTF_32__=1 -isystem /opt/sdcc/bin/../share/sdcc/include/z80 -isystem /opt/sdcc/share/sdcc/include/z80 -isystem /opt/sdcc/bin/../share/s
dcc/include -isystem /opt/sdcc/share/sdcc/include calendar.c
calendar.c:233: warning 84: 'auto' variable 'retval' may be used before initialization
calendar.c:321: warning 84: 'auto' variable 'nfiles' may be used before initialization
calendar.c:357: warning 84: 'auto' variable 'foundfiles' may be used before initialization
calendar.c:388: warning 84: 'auto' variable 'matchstr' may be used before initialization
calendar.c:391: warning 84: 'auto' variable 'matchstr' may be used before initialization
calendar.c:403: warning 84: 'auto' variable 'matchstr' may be used before initialization
calendar.c:406: warning 84: 'auto' variable 'matchstr' may be used before initialization
calendar.c:416: warning 84: 'auto' variable 'matchdate' may be used before initialization
calendar.c:416: warning 84: 'auto' variable 'matchdate' may be used before initialization
calendar.c:416: warning 84: 'auto' variable 'matchdate' may be used before initialization
calendar.c:416: warning 84: 'auto' variable 'matchdate' may be used before initialization
calendar.c:431: warning 84: 'auto' variable 'matchdate' may be used before initialization
calendar.c:432: warning 84: 'auto' variable 'matchdate' may be used before initialization
calendar.c:437: warning 84: 'auto' variable 'matchdate' may be used before initialization
calendar.c:443: warning 84: 'auto' variable 'matchdate' may be used before initialization
calendar.c:448: warning 84: 'auto' variable 'matchdate' may be used before initialization
calendar.c:453: warning 84: 'auto' variable 'matchdate' may be used before initialization
calendar.c:457: warning 84: 'auto' variable 'matchdate' may be used before initialization
calendar.c:462: warning 84: 'auto' variable 'matchdate' may be used before initialization
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return [243/9144]
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '4336' : code generator internal error
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '3632' : Shouldn't push BC if it's wiped out by the return
Contact Author with source code
calendar.c:469: error 9: FATAL Compiler Internal Error in file 'gen.c' line number '4509' : code generator internal error
Contact Author with source code
I simplified the reproducer a bit. The attached file can be compiled via
in current SDCC 3.7.1 #10429
Philipp
Something weird is happening here. The register allocator asks for the cost for a call to findmon() at iCode 401 where both iTemp28 and iTemp184, though both are alive, are allocated to register pair bc. At first sight, the internal data structures of the register allcoator seem to correctly show the conflict, so this shouldn't even reach the calculation of the cost function in codegen.
Philipp
P.S.: The bug can also be reproduced via sdcc -mz80 calendar.c --max-allocs-per-node 72
The problem is a non-connected live-range: Variable iTemp28 is alive at iCode 8 (and plenty of far-away icodes), but at none of the neighbours of iCode 8 in the CFG.
Philipp
There could also be a lospre issue here, since this non-connected live-range is apparently introduced by lospre. But the live-range splitter should be able to deal with it anyway, so we definitely have issues in the live-range splitter, and the live-range extender.
For now, --nolospre is a workaround.
TODO:
1) Find issue in live-range extender, fix it (this will result in correct code; there will still be a warning, but no error anymore).
2) Check, why the live-range splitter can't handle this case.
3) Check why lospre introduces the non-connected range.
Philipp
Regarding the issue in the live-range extender: This was apparently introduced when optimizing the live-range connectivity check for speed in [r10278]. When using the old test, it works correctly.
Philipp
In [r10437], the issue in the live-range extender has been fixed, so code is now generated "correctly" for this file.
Philipp
P.S.: It doesn't really matter how thegenerated code behaves; it has undefined behaviour due to reading the unitialized variable nfiles, which was necessary to trigger the bug. When nfiles is initialized to 0, the issue cannot be reproduced.
So the introduction of the non-connected live-ragne by lospre should be a non-issue. That only leaves the possible failure of the live-range splitter as remaining bug.
Last edit: Philipp Klaus Krause 2018-06-12
The live-range splitter works from definitions. So when there is a component of the live-range that contains no definitions (i.e. all uses of the variable in that component are reads from the unitialized variable), that component is not split off.
Philipp
P.S.: Maybe we should rather replace all variable reads in such a component by literal 0 to reduce register pressure? Or use some way to make it undefined behviour allt he way to the backend? Just eliminate the iCode doing the read?
Last edit: Philipp Klaus Krause 2018-06-12
In [10442], the situation seems good enough to close this bug report.
Philipp