<div>
                    Hi there,
                </div><div><br></div><div>I guess I did something like this some time ago: I needed a set of infos about some loops, but the code should be modified only in another moment. In that case, I just created two dynamic passes for opt: an analysis and a transformation pass, and both of them were LoopPasses. After that, I simply accessed the data from my analysis directly from my transformation, and the machinery in LLVM itself took care of the sync between them (linking a transform to the analysis of each respective loop, and keeping the results of the analysis alive, even if some other transformation caused my analysis to be invalidated).</div><div><br></div><div>In order to access the analysis, you might need check the getAnalysisUsage method: <a href="http://llvm.org/docs/WritingAnLLVMPass.html#getAnalysisUsage">http://llvm.org/docs/WritingAnLLVMPass.html#getAnalysisUsage</a></div><div>You might remember that the header file of your analysis must be accessible from your transformation code location (I kept all the files in the same directory).</div><div><br></div><div>The only catch in here is that you need to include all the code of the analysis in its header file. I don't know exactly why, but when I tried to create a separate .cpp file, I couldn't link the code.</div><div><br></div><div>And, last, you might invoke your passes just importing all dynamic libraries you created (in my case, I just linked both passes into one dynamic library), and you might use only the flag for your transformation (the LLVM should call your analysis automatically), except in case you have more than one implementation of your analysis -- so, you should explicitly invoke the one you want, if it is not the default one.</div><div><br></div><div>Hope I could help,</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 Tuesday, 21 de August de 2012 at 14:24, Rao, Prashantha wrote:</p>
                <blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
                    <span><div><div>

<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 12 (filtered medium)">
<base href="x-msg://25179/"><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->


<div>
<p style="margin: 0px; "><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p style="margin: 0px; "><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p style="margin: 0px; "><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Andrew Trick [<a href="mailto:atrick@apple.com">mailto:atrick@apple.com</a>]
<br>
<b>Sent:</b> Tuesday, August 21, 2012 9:58 PM<br>
<b>To:</b> Rao, Prashantha<br>
<b>Cc:</b> <a href="mailto:llvmdev@cs.uiuc.edu">llvmdev@cs.uiuc.edu</a><br>
<b>Subject:</b> Re: [LLVMdev] How to uniquely remember a loop?<o:p></o:p></span></p>
</div>
</div>
<p style="margin: 0px; "><o:p> </o:p></p>
<div>
<div>
<p style="margin: 0px; ">On Aug 21, 2012, at 4:17 AM, "Rao, Prashantha" <<a href="mailto:Prashantha.Rao@amd.com">Prashantha.Rao@amd.com</a>> wrote:<o:p></o:p></p>
</div><blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<div>
<div>
<p style="margin: 0px; "><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">More than one loop may share the same header;
</span><o:p></o:p></p>
</div>
</div>
</div>
</blockquote><div>
<p style="margin: 0px; "><o:p> </o:p></p>
</div>
<p style="margin: 0px; ">You have a different definition of loop than the rest of the optimizer. You can identify your loops by the backedge if you prefer.<o:p></o:p></p>
</div>
<div>
<p style="margin: 0px; "><br>
<br>
<o:p></o:p></p>
<div>
<div>
<div>
<p style="margin: 0px; "><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I can certainly run LoopSimplify as a prepass. But will that ensure unique loop header for each loop.</span><o:p></o:p></p>
</div>
</div>
</div>
<div>
<p style="margin: 0px; "><o:p> </o:p></p>
</div>
<div>
<p style="margin: 0px; ">It tries to split loops into single back edge loops. No guarantee.<o:p></o:p></p>
</div>
<p style="margin: 0px; "><br>
<br>
<o:p></o:p></p>
<div>
<div>
<p style="margin: 0px; "><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">As I will be performing transformation after the analysis other optimizations will not interfere (hopefully).</span><o:p></o:p></p>
</div>
</div>
<div>
<p style="margin: 0px; "><o:p> </o:p></p>
</div>
<div>
<p style="margin: 0px; ">Now it sounds like you're writing a standard in-process Analysis pass that can be used by your transformation without being invalidated. If so, just refer directly to Loop* from LoopInfo.<o:p></o:p></p>
</div>
<p style="margin: 0px; "><br>
<br>
<o:p></o:p></p>
<div>
<div>
<p style="margin: 0px; "><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Will the debug info metadata be available always?  If so, what are good pointers to explore?</span><o:p></o:p></p>
</div>
</div>
<p style="margin: 0px; "><o:p> </o:p></p>
</div>
<div>
<p style="margin: 0px; ">Certainly no guarantee. Do you want your optimization to depend on debug info?<o:p></o:p></p>
</div>
<div>
<p style="margin: 0px; "><o:p> </o:p></p>
</div>
<div>
<div style="mso-element:para-border-div;border:none;border-bottom:solid windowtext 1.0pt;padding:0in 0in 1.0pt 0in">
<p style="border: none; padding: 0in; margin: 0px; ">-Andy<o:p></o:p></p>
</div>
<p style="margin: 0px; "><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p style="margin: 0px; "><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Andy-<o:p></o:p></span></p>
<p style="margin: 0px; "><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p style="margin: 0px; "><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I will go with an Analysis phase followed by transformation phase and I will make LoopInfo run as prepass for analysis. That should make LoopInfo  valid when
 I run analysis and transform. <o:p></o:p></span></p>
<p style="margin: 0px; "><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p style="margin: 0px; "><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thanks,<o:p></o:p></span></p>
<p style="margin: 0px; "><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">-Prashantha<o:p></o:p></span></p>
<p style="margin: 0px; "><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
</div>
</div>


</div><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>