<div>Because I feel bad for giving a non-answer:</div><div><br></div>An easy way to find if a virtual register is alive after the basic block is to<div>While iterating over the virtual registers</div><div>- Check to see if the virtual register's "next" value exists outside of the basic block.</div>
<div><br></div><div>for instance:</div><div><br></div><div>std::vector<unsigned> findLiveOut( MachineBasicBlock * mbb ) {</div><div> std::vector<unsigned> liveout;</div><div> for( MachineBasicBlock::iterator mbbi = mbb->begin(), mbbe = mbb->end(); mbbi != mbbe; ++mbbi ) {</div>
<div> for( opi = 0, ope = mbbi->getNumOperands(); opi < ope; ++opi ) {</div><div> MachineOperand & operand = mbbi->getOperand(opi);</div><div> if( operand.isReg() == false )</div><div> continue;</div>
<div> if( operand.getReg() == 0 )</div><div> continue;</div><div> if( ! TargetRegisterInfo::isVirtualRegister(operand.getReg()) )</div><div> continue;</div><div> if( mbb != operand.getNextOperandForReg()->getParent()->getParent() )</div>
<div> liveout.push_back( operand.getReg() );</div><div> }</div><div> }</div><div> return liveout;</div><div>}</div><div> <br><br><div class="gmail_quote">On Fri, Nov 5, 2010 at 7:41 AM, s Last namerc <span dir="ltr"><<a href="mailto:srcsrc84@yahoo.com">srcsrc84@yahoo.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Is there an easy way to obtain all liveout variables of a basic block? Liveins<br>
can be found for each MachineBasicBlock, but I can only find liveouts for the<br>
whole function, at MachineRegisterInfo. Do I need to find them out manually?<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></div><br></div>