<div>
Hi Rinaldini,
</div><div><br></div><div>In order to find information about loops inside a given function you should use something like "<span style="color: #508186">LoopInfo</span><span style="color: #000000"> *LI = P-></span>getAnalysis<span style="color: #000000"><</span><span style="color: #508186">LoopInfo</span><span style="color: #000000">>()", remembering to add "</span><span style="color: #000000">AU.</span>addRequired<span style="color: #000000"><</span><span style="color: #508186">LoopInfo</span><span style="color: #000000">>();" to your getAnalysisUsage method.</span></div><div><span style="color: #000000"><br></span></div><div><span style="color: #000000">If the function you are interested to is not located in the module being compiled (if you created it as an auxiliary function, for example), you could create this information by simply creating a DominatorTreeBase of your function and using it to calculate the LoopInfo, as below:</span></div><div><span style="color: #000000"><div> DominatorTreeBase<BasicBlock> *DTB;</div><div> DTB = new DominatorTreeBase<BasicBlock>(false);</div><div> DTB->recalculate(*AuxFunction);</div></span><div><br></div> LoopInfoBase<BasicBlock, Loop> LIB;</div><div><div> LIB.Calculate(*DTB);</div><div><br></div></div><div>Cheers,</div>
<div><div><br></div><div>-- </div><div>Cristianno Martins</div><div>PhD Student of Computer Science</div><div>University of Campinas</div><div>cmartins@ic.unicamp.br</div><div><br></div></div>
<p style="color: #A0A0A8;">On Thursday, 26 de April de 2012 at 11:57, Hal Finkel wrote:</p>
<blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
<span><div><div><div>Rinaldini,</div><div><br></div><div>What exactly did you run? Specifically, you may be missing some</div><div>analysis passes that are necessary for LoopInfo to have the loop</div><div>information you desire.</div><div><br></div><div> -Hal</div><div><br></div><div>On Thu, 26 Apr 2012 14:02:04 +0000</div><div>Rinaldini Julien <<a href="mailto:julien.rinaldini@heig-vd.ch">julien.rinaldini@heig-vd.ch</a>> wrote:</div><div><br></div><blockquote type="cite"><div><div>Hi,</div><div><br></div><div>I'm trying to detect if a basicblock is part of a loop or not.</div><div><br></div><div>I tried the llvm::LoopInfo like that</div><div>(<a href="http://llvm.org/docs/doxygen/html/classllvm_1_1LoopInfo.html#a4abca289c73cd09487e05d11d9f7d877">http://llvm.org/docs/doxygen/html/classllvm_1_1LoopInfo.html#a4abca289c73cd09487e05d11d9f7d877</a>):</div><div><br></div><div>LoopInfo *loop = new LoopInfo();</div><div>bool isLoop = loop->getLoopFor(myBB); // getLoopFor - Return the</div><div>inner most loop that BB lives in. If a basic block is in no loop (for</div><div>example the entry node), null is returned. See doxygen </div><div><br></div><div>But getLoopFor() always return me NULL even if my basicblock is</div><div>inside a for loop... I tried this:</div><div><a href="http://comments.gmane.org/gmane.comp.compilers.llvm.devel/38490">http://comments.gmane.org/gmane.comp.compilers.llvm.devel/38490</a> but</div><div>it didn't work too :(</div><div><br></div><div>Any advice?</div><div>Thx </div><div><br></div><div>_______________________________________________</div><div>LLVM Developers mailing list</div><div>LLVMdev@cs.uiuc.edu <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a></div><div><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a></div></div></blockquote><div><br></div><div><br></div><div><br></div><div>-- </div><div>Hal Finkel</div><div>Postdoctoral Appointee</div><div>Leadership Computing Facility</div><div>Argonne National Laboratory</div><div>_______________________________________________</div><div>LLVM Developers mailing list</div><div>LLVMdev@cs.uiuc.edu <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a></div><div><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a></div></div></div></span>
</blockquote>
<div>
<br>
</div>