| Return Sequence Optimization

Previous | TIGCC Linker Binary Code Fixup | Next

The TIGCC linker can optimize function return sequences. If a section ends with a subroutine branch followed by a simple return instruction, the subroutine branch is converted into a simple unconditional branch (jump), and the return instruction is removed. Note that this may fail easily if there is a branch to the return instruction somewhere; if the return instruction is removed, the branch will point to arbitrary code or data. You can make this less likely by telling the assembler to emit all local labels, so the linker knows it cannot optimize a return sequence because there is a label in front of the return instruction. With the GNU Assembler, this is done by using the '--keep-locals' option, which is included automatically if range-cutting is enabled. With the A68k Assembler, the '-d' switch does the job.