[LLVMdev] Basic block liveouts

Jeff Kunkel jdkunk3 at gmail.com
Fri Nov 5 13:05:49 PDT 2010


Because I feel bad for giving a non-answer:

An easy way to find if a virtual register is alive after the basic block is
to
While iterating over the virtual registers
- Check to see if the virtual register's "next" value exists outside of the
basic block.

for instance:

std::vector<unsigned> findLiveOut( MachineBasicBlock * mbb ) {
  std::vector<unsigned> liveout;
  for( MachineBasicBlock::iterator mbbi = mbb->begin(), mbbe = mbb->end();
mbbi != mbbe; ++mbbi ) {
    for( opi = 0, ope = mbbi->getNumOperands(); opi < ope; ++opi ) {
      MachineOperand & operand = mbbi->getOperand(opi);
      if( operand.isReg() == false )
        continue;
      if( operand.getReg() == 0 )
        continue;
      if( ! TargetRegisterInfo::isVirtualRegister(operand.getReg()) )
        continue;
      if( mbb != operand.getNextOperandForReg()->getParent()->getParent() )
        liveout.push_back( operand.getReg() );
    }
  }
  return liveout;
}


On Fri, Nov 5, 2010 at 7:41 AM, s Last namerc <srcsrc84 at yahoo.com> wrote:

> Is there an easy way to obtain all liveout variables of a basic block?
> Liveins
> can be found for each MachineBasicBlock, but I can only find liveouts for
> the
> whole function, at MachineRegisterInfo. Do I need to find them out
> manually?
>
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20101105/83e56d86/attachment.html>


More information about the llvm-dev mailing list