I have a question about register scavenger.<br><br>I am considering using register scavenger for MIPS to free up register AT which is currently reserved to load large immediates.<br><br>All targets which currently use register scavenger to search for a scratch register (ARM, CellSPU, PowerPC and XCore)<br>
override function processFunctionBeforeCalleeSavedScan and call RegisterScavenger::setScavengingFrameIndex<br>

if they decide an emergency spill slot is needed. Since processFunctionBeforeCalleeSavedScan is called before it is known<br>which callee-saved registers need to be spilled, the targets decide whether the spill slot is needed without knowing the exact<br>
stack frame size.<br><br>It seems to me that it would be better to wait until calculateFrameObjectOffsets computes the exact stack size<br>

to make the decision and redo the stack size calculation only if the spill slot is needed.<br><br>bool PEI::runOnMachineFunction(MachineFunction &Fn) {<br>  ...<br>
  TFI->processFunctionBeforeCalleeSavedScan(Fn, RS);<br>

  ...<br>  calculateCalleeSavedRegisters(Fn);<br>  ...<br>

  calculateFrameObjectOffsets(Fn);<br>
 
...<br>  if (target needs spill slot) {<br>    call setScavengingFrameIndex and reserve spill slot<br>    calculateFrameObjectOffsets(Fn); // redo calculation.<br>  }<br><br><br>This seems to be simpler and more efficient since you don't need to write or run a function like ARM's estimateStackSize to estimate the stack size.<br>
<br>Does this sound reasonable or is there something I am missing?<br><br>