SourceForge has been redesigned. Learn more.

#1850 Unreachable code not eliminated.


When compiling the attached code using e.g. sdcc --std-c99 -mz80 test.c there are two unreachable iCode (487 and 488, numbers will change when compiling for other ports, but the issue remains). For some reason these are not eliminated as they should be. Besides the obvious issue of generating code that serves no purpose and wastes space there can be further problems:
It results in an unconnected control-flow graph, which can confuse e.g. register allocation.



  • Philipp Klaus Krause

    Code sample.

  • Erik Petrich

    Erik Petrich - 2011-11-05

    Even if not officially reachable, the return label may or may not be used by the code generator for the RETURN iCode. Besides generating the function epilogue, the ENDFUNCTION iCode is also used in generating some debugging symbols. So I would prefer to leave these two iCodes in place, but have the front end make it easier for the back end to see that it thinks these are unreachable (so they could easily be omitted from the control-flow graph) and let the code generator emit whatever is necessary for its design in this case.


Log in to post a comment.