<div dir="ltr">Thank you.<br><br>Is it possible to determine the liveout of the operands (see example bellow) ?<br><br>        %5 = add i32 %4, %3    <br><br>For '%5': i can simply use " i->isUsedOutsideOfBlock() "<br>
For '%3' and '%4' : this is the question ...<br><br>From your answer, is it possible to determine <b>which</b> value is liveout ( in binary instruction)?<br><br><br><div class="gmail_quote">On Sat, May 30, 2009 at 2:57 AM, John McCall <span dir="ltr"><<a href="mailto:rjmccall@apple.com">rjmccall@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">On May 29, 2009, at 11:37 PM, Rotem Varon wrote:<br>
> How can i know, if a value have uses outside of the current basic<br>
> block (liveout), without iterating through all the basic block ?<br>
<br>
</div>If the value is created within the basic block in question, and the<br>
block doesn't loop to itself, then you can just iterate through the<br>
uses and note if the use is an instruction in a different block:<br>
<br>
bool isLiveOut(Instruction* I) {<br>
        BasicBlock* I_BB = I->getParent():<br>
        for (Value::use_iterator ui = I->use_begin(), ue = I->use_end(); ui !<br>
= ue; ++ui)<br>
                if (cast<Instruction>(ui)->getParent() != I_BB)<br>
                        return true;<br>
        }<br>
}<br>
<br>
If the value is created within the block but the block loops to<br>
itself, you can get away with a very slight adjustment:<br>
<br>
                if (cast<Instruction>(ui)->getParent() != I_BB && !isa<PHINode>(ui))<br>
<br>
If the value is created in one block and you want to know if it's live<br>
out of some dominated block, that's a lot more complicated (and<br>
expensive).<br>
<font color="#888888"><br>
John.<br>
</font><div><div></div><div class="h5">_______________________________________________<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>
</div></div></blockquote></div><br></div>