<div class="socmaildefaultfont" dir="ltr" style="font-family:Arial;font-size:10.5pt" ><div class="socmaildefaultfont" dir="ltr" style="font-family:Arial;font-size:10.5pt" ><div dir="ltr" > </div>
<div dir="ltr" >Hi all,</div>
<div dir="ltr" > </div>
<div dir="ltr" > </div>
<div dir="ltr" >The documentation at the top of LiveVariables.cpp states the following:<br><br>     "It ... assumes that physical registers are only live within a single basic block (allowing it to do a single local analysis to resolve physical register lifetimes in each basic block).  If a physical register is not register allocatable, it is not tracked. "</div>
<div dir="ltr" > </div>
<div dir="ltr" >This is consistent with the behaviour I'm witnessing, but I don't understand why it's designed this way. I am developing an out-of-tree backend and I have the following scenario:</div>
<div dir="ltr" > </div>
<div dir="ltr" >      -physreg X marked as a live-in for a successor MBB (A.K.A., a live-out of the current block)<br>      -physreg X is a member of an allocatable reg-class<br>      -the only reference to physreg X in the current block is a<strong>: %physregX<def> = COPY %vreg43<kill></strong></div>
<div dir="ltr" > </div>
<div dir="ltr" >That is the IR immediately before the Live Variables pass. The problem is that LiveVariables is marking physregX as dead, meaning that after LiveVariables, the IR above becomes:</div>
<div dir="ltr" > </div>
<div dir="ltr" > </div>
<div dir="ltr" >   <strong>%physregX<def,dead> = COPY %vreg43<kill></strong></div>
<div dir="ltr" > </div>
<div dir="ltr" > </div>
<div dir="ltr" >...and this eventually causes the COPY to be eliminated rather than lowered to machine instructions. Why does LiveVariables assume physical registers are only live within a single basic block? I have confirmed that if I remove the allocatable check in runOnBlock() [if (!TRI->isInAllocatableClass(LI.PhysReg))] and instead add all successor live-ins to LiveOuts regardless of regclass allocatability, my copy is not marked dead and not subsequently eliminated. This seems consistent with the aforementioned comment, so I don't think it's a bug but I really don't understand the intention here. If anyone could shed some light on why allocatable live-in's are pretty much ignored here, that'd be really helpful.</div>
<div dir="ltr" > </div>
<div dir="ltr" >Thanks in advance,</div>
<div dir="ltr" >Tyler</div>
<div dir="ltr" > </div></div></div><BR>