[LLVMdev] Computing live values

Chris Lattner sabre at nondot.org
Wed May 11 11:17:12 PDT 2005


On Wed, 11 May 2005, Vladimir Prus wrote:
> Say I want to find all LLVM Value*-es that a live on exit from a basic block.
> What's the best way?
>
> - The 'LiveRange', 'LiveVariables' and 'LiveIntervals' classes seem to be tied
> to register allocation.
> - The ./lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.h file seem to provide
> what I need, but it's no a public header.

This is overkill.  I would suggest something like this:

bool LiveOutsideOfBlock(Instruction *I) {
   for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E; ++UI)
     if (cast<Instruction>(*UI))->getParent() != I->getParent()) return true;
   return false;
}

-Chris

-- 
http://nondot.org/sabre/
http://llvm.cs.uiuc.edu/




More information about the llvm-dev mailing list