The compiler crash with a SEGV when I try to compile some C files with a z80 target and the --reserve-regs-iy option.
I've attached an example of source which make the compiler crash.
this make the compiler crash with -mz80 --reserve-regs-iy
sorry I pushed on the wrong button :-)
I've made a regression test and this bug occurs from revision 7537.
How to reproduce this bug (I've used revision 7950):
sdcc -mz80 --reserve-regs-iy reserve-regs-iy-bug.c
Program received signal SIGSEGV, Segmentation fault.
cheapMove (to=0x1, to_offset=0, from=0x81b5eec, from_offset=0) at gen.c:2800
2800 if (to->type == AOP_ACC && from->type == AOP_ACC && to_offset == from_offset)
But when I compile it with --oldralloc, it works fine.
Hmm, for some reason emitCall thinks that the return value of printf() is used when using --reserve-regs-iy, and tries to assign it to a non-exisitng variable.
Unfortunately, the problem persists even if you remove printf. In fact many source files makes the compiler crashes with this option.
Try to compile the Z80 RTL with --reserve-regs-iy:
make -k SCC='$(top_builddir)/bin/sdcc -mz80 --reserve-regs-iy'
On 105 C files, 86 caused a SEGV, 3 an ABRT and only 16 compiled with success.
And from the 16 .asm generated, 10 contain references to IY.
if you add --oldralloc, it works fine but some .asm still contains references to IY.
The problem appears on revision 7537. On 7536, the RTL compile fines with --reserve-regs-iy but there are still references to IY.
Thanks, knowing the revision # that introduced the bug helped.
It seems the special handling ot --reserve-regs-iy was lost when factoring out some port-specific stuff from the generic register allocator code.
I've got two ideas for a fix, one a quick hack, which might make it into the 3.2.0 release, and a cleaner, but bigger solution that seems to be a good long-term solution.
P.S.: With the quick hack, regression tests pass when using --reserve-regs-iy, except for one failing test, and do not crash the compiler any more; I'll implement the cleaner solution in a branch later today.
P.P.S.: --reserve-regs-iy isn't perfect yet: For functions that use more than 128 bytes of stack space for local variables or that have more than 128 bytes of parameters, iy is still used.
Fixed in revision #7953.
Log in to post a comment.