[LLVMdev] Register allocation in two passes

Borja Ferrer borja.ferav at gmail.com
Mon Nov 28 15:39:38 PST 2011


Hello,

I'm having a curious design conflict related to reserving registers before
the register allocator pass is executed with the backend I'm writing.
Basically, what I need is to reserve a certain register only if frame space
is allocated in the stack, more precisely I'm interested in the case where
a register spill occurs.
In order to know if a register is spilled the register allocator has to be
executed so i can reserve this special reg, but since the register
reservation occurs before the allocator is executed there's no way to get
this info in only a single pass.
The only solution i can think of is running the regalloc twice, first to
see if any regs are spilled without performing any changes and a second one
for doing the real allocation. As a test I've managed to do this with the
Greedy regalloc by making the first regalloc execution to not perform a
virtreg rewrite at the end of the function pass. But i really want to know
if this is safe and if there's a better way of doing it.

Thanks for any suggestions
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111129/fcddc401/attachment.html>


More information about the llvm-dev mailing list