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.