A method, system, and apparatus for inserting spill code optimized for a complex
instruction set computing (CISC) two-address machine, such as a machine utilizing
an 80x86 processor is described. The spill code is generated in a single pass.
Copy propagation and dead-code elimination are performed to remove unnecessary
loads and stores from the stack. Instructions contained within the code block are
processed in reverse order. Temporary variables are not extended to the point that
they may become spilled by a register allocation procedure. A store to a stack
location is inserted if the stack location is not dead, saving the use of a register.
Memory operands are substituted when possible in place of load and store instructions
on CISC machines.