Thanks Devang and John. My pass is actually a loop pass, not a function pass. So, I couldnt override the <font face="Courier">getAnalysisUsage.<br><font style="font-family: arial,helvetica,sans-serif;" size="2">I am in a loop pass, I know the outermost loop. Now How can I get the loopInfo from here? I couldn't find helpful methods in the LoopInfo class documents.</font><br>
<br></font><br><div class="gmail_quote">On Mon, Feb 28, 2011 at 5:52 PM, John Criswell <span dir="ltr"><<a href="mailto:criswell@illinois.edu">criswell@illinois.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div text="#000000" bgcolor="#ffffff"><div><div></div><div class="h5">
On 2/28/11 4:43 PM, Devang Patel wrote:
<blockquote type="cite"><br>
<div>
<div>On Feb 28, 2011, at 2:35 PM, Naznin Fauzia wrote:</div>
<br>
<blockquote type="cite">Hi all,<br>
<br>
How Can I get the Loops around an Instruction?<br>
<br>
I know I can get the basic block of an instruction using
inst.getParent() which returns a BasicBlock*. Now I want to
use the getLoopFor(BasicBlock) method of the class LoopInfo.<br>
But I dont know how to get the LoopInfo.<br>
<br>
BasicBlock* bb = inst.getParent();<br>
<br>
(... what should I add here?)<br>
<br>
Loop* innerloop = LI -> getLoopFor(bb):<br>
<br>
</blockquote>
<br>
</div>
<div>Two steps:</div>
<div>1) In your pass's getAnalysisUsage(), request LoopInfo.</div>
<div><br>
</div>
<div>
<div><span style="white-space: pre-wrap;"><font face="Courier"> </font></span><font face="Courier">virtual void
getAnalysisUsage(AnalysisUsage &AU) const {</font></div>
<div><span style="white-space: pre-wrap;"><font face="Courier"> </font></span><font face="Courier"> AU.addRequired<LoopInfo>();</font></div>
<div><span style="white-space: pre-wrap;"><font face="Courier"> </font></span><font face="Courier">}</font></div>
<div><br>
</div>
<div>2) In your runOnLoop() method get the analysis.</div>
<div><br>
</div>
<div><span style="white-space: pre-wrap;"><font face="Courier"> </font></span><font face="Courier">LoopPass *</font><span style="white-space: pre-wrap;"><font face="Courier">LI =
&getAnalysis<LoopInfo>();</font></span></div>
<div><span style="white-space: pre-wrap;"><br>
</span></div>
<div><span style="white-space: pre-wrap;">Now,
you can do LI->getLoopFor(...)</span></div>
</div>
</blockquote>
<br></div></div>
To add to what Devang has said, you may find the doxygen docs on
LoopInfo helpful:<br>
<br>
<a href="http://llvm.org/doxygen/classllvm_1_1LoopInfo.html" target="_blank">http://llvm.org/doxygen/classllvm_1_1LoopInfo.html</a><br>
<br>
-- John T.<br>
<br>
<br>
<blockquote type="cite">
<div>
<div><span style="white-space: pre-wrap;"><br>
</span></div>
<div><span style="white-space: pre-wrap;">-</span></div>
<div><span style="white-space: pre-wrap;">Devang</span></div>
<div><br>
</div>
</div>
<br>
</blockquote>
<br>
</div>
</blockquote></div><br>