[LLVMdev] How Fast RegisterAllocation determine if the use-reference is the last use without isKill Flag

Jakob Stoklund Olesen stoklund at 2pi.dk
Thu Nov 14 10:24:34 PST 2013


On Nov 14, 2013, at 6:20 AM, sheng wang <wansheg at qq.com> wrote:

> Hello llvmers:
>      I'm study    Fast register allocation in codegen.   I get confused
> with  isKill flag in MachineOperand.  I thin "isKill" flag  the last Use
> Reference. But,   Fast Register doesn't require  LiveVariable Analysis which
> will mark isKill Flag for global virtual Register.  So during Fast
> RegisterAllocation,  Faster Register Allocation procedure can't determine if
> this use-reference is the last use  through current path ;
> 
> , How  does Fast RegisterAllocation resolve such problem ?

It is using the use-def chain of the virtual register. Virtual registers are rewritten to physical registers in a top-down manner, and MachineRegisterInfo updates the use-def lists as operands are rewritten. When the last use of a virtual register is rewritten, its use-def chain becomes empty.

This only works for local virtual registers, of course. If a virtual register has uses or refs in multiple basic blocks, it is always assumed to be live out of the block. The fast register allocator is optimized for debug builds where the code has almost no global virtual registers.

Thanks,
/jakob



More information about the llvm-dev mailing list