[LLVMdev] Basic block liveouts

Lang Hames lhames at gmail.com
Sun Nov 7 12:34:18 PST 2010


I'm not sure this will work: The "next" use may be in a sibling block,
rather than a successor, or there could be intervening definitions. In
either case the value isn't really live out of the block.

I think the live-ins list only includes physical registers too.

You're probably best off running the LiveIntervals pass and seeing
which intervals are live across the last index in the basic block (see
LiveIntervals::getMBBEndIdx()).

- Lang.

On Fri, Nov 5, 2010 at 1:05 PM, Jeff Kunkel <jdkunk3 at gmail.com> wrote:
> 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
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>




More information about the llvm-dev mailing list