pub fn insert_spill_reloads(
mf: &mut MachineFunction,
result: &mut RegAllocResult,
load_op: MOpcode,
store_op: MOpcode,
)Expand description
Insert spill stores and reload loads for all spilled VRegs.
For each spilled VReg v:
- After every instruction that defines
v, insert a STORE ofvto its frame slot using a fresh VReg. - Before every instruction that uses
v, insert a LOAD from its frame slot into a fresh VReg, and replace the use with that fresh VReg.
Fresh VRegs are then allocated in a second linear-scan pass (they have very
short live intervals so they virtually never cause additional spills). The
result is merged into result.
load_op / store_op are target-provided opcodes. The instructions
have the layout:
- LOAD:
dst = VReg(fresh), operands = [Imm(slot)] - STORE:
dst = None, operands = [Imm(slot), VReg(src)]