Accessing the stack is extremly inefficient in sdcc. This currently is sdcc's worst code quality problem for many ports. The problem can be seen in the attahced files:
stackhell.c, a minimal example.
stackhell2.c, which illustrates how bad the problem can become when using local aggregates.
device/lib/sdcc-mullong.c illustrates a real-world case, where sdcc generates approx. 700 bytes for Z80 vs. spprox 250 bytes for non-free HITECH-C and approx. 450 bytes for free z88dk. The situation is similar with other ports (unless compiling the function as not reentrant).
Wiki: SDCC 4.3.0 Release
Wiki: SDCC 4.4.0 Release
Wiki: SDCC 4.5.0 Release
Minimal example
Aggregate example
Reducing priority by one, since this performance problem is not as important as the standard-compliance problem addressed by the other priority 9 items.
Philipp
One way to fix this would be to make the addresses of local aggregates rematerializeable.
Philipp
In [r10602], basic support for rematerialization of on-stack addresses has been implemented for stm8.
Philipp
Support for rematerialization of stack addresses has improved in stm8, and has been ported to pdk13, pdk14, pdk15.
It is still missing for z80, z180, gbz80, tlcs90, r2k, r3ka, mcs51, ds390, hc08, s08.
As of [r12795], all stable ports except for mcs51 and ds390 have support for rematerialization of stack addresses.