<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: Arial; font-size: 12pt; color: #000000'><P>John,</P>
<P> </P>
<P>I was able to get access to the dominator tree by doing exactly as you said.  I instantiate a PassManager object, make my code inherit from Pass, and add it to the PassManager.  Then I overload runOnFunction, etc just like when writing a pass for opt.</P>
<P> </P>
<P>All of that seems to be working great.</P>
<P> </P>
<P>Thanks for your help,</P>
<P> </P>
<P>David</P>
<P> </P>
<P> </P>
<P>
<HR id=zwchr>
</P>
<P><B>From: </B>"John Criswell" <criswell@illinois.edu><BR><B>To: </B>"david dewey" <david.dewey@comcast.net><BR><B>Cc: </B>llvmdev@cs.uiuc.edu<BR><B>Sent: </B>Friday, July 29, 2011 11:04:10 AM<BR><B>Subject: </B>Re: [LLVMdev] Accessing Dominator Tree<BR><BR>On 7/29/11 10:00 AM, <A class=moz-txt-link-abbreviated href="mailto:david.dewey@comcast.net" target=_blank>david.dewey@comcast.net</A> wrote: </P>
<BLOCKQUOTE cite=mid:975478276.14098.1311951620906.JavaMail.root@sz0154a.westchester.pa.mail.comcast.net>
<STYLE>p { margin: 0; }</STYLE>

<DIV style="FONT-FAMILY: Arial; COLOR: rgb(0,0,0); FONT-SIZE: 12pt">
<P>John,</P>
<P> </P>
<P>Thanks for the quick reply.  Using a PassManager object should work fine.  As you said, my only objection is to exec'ing opt.  </P>
<P> </P>
<P>I had actually tried instantiating a PassManager object before, but I was definitely not doing it right.  I will take a look at how clang and SAFECode use it, and see if I can get it working.</P></DIV></BLOCKQUOTE><BR>The SAFECode sc tool is based on opt, so you can just see what opt does.  Clang does something weird with the PassManager object (I think), so I recommend looking at opt or sc over clang.<BR><BR>-- John T.<BR><BR>
<BLOCKQUOTE cite=mid:975478276.14098.1311951620906.JavaMail.root@sz0154a.westchester.pa.mail.comcast.net>
<DIV style="FONT-FAMILY: Arial; COLOR: #000000; FONT-SIZE: 12pt">
<P> </P>
<P>Thanks,</P>
<P> </P>
<P>David</P>
<P><BR> </P>
<P></P>
<HR id=zwchr>

<P><B>From: </B>"John Criswell" <A class=moz-txt-link-rfc2396E href="mailto:criswell@illinois.edu" target=_blank><criswell@illinois.edu></A><BR><B>To: </B>"david dewey" <A class=moz-txt-link-rfc2396E href="mailto:david.dewey@comcast.net" target=_blank><david.dewey@comcast.net></A><BR><B>Cc: </B><A class=moz-txt-link-abbreviated href="mailto:llvmdev@cs.uiuc.edu" target=_blank>llvmdev@cs.uiuc.edu</A><BR><B>Sent: </B>Friday, July 29, 2011 10:56:20 AM<BR><B>Subject: </B>Re: [LLVMdev] Accessing Dominator Tree<BR><BR>On 7/29/11 9:43 AM, <A class=moz-txt-link-abbreviated href="mailto:david.dewey@comcast.net" target=_blank>david.dewey@comcast.net</A> wrote: </P>
<BLOCKQUOTE cite=mid:1034242797.13028.1311950602990.JavaMail.root@sz0154a.westchester.pa.mail.comcast.net>
<STYLE>p { margin: 0; }</STYLE>

<DIV style="FONT-FAMILY: Arial; COLOR: rgb(0,0,0); FONT-SIZE: 12pt">
<P>Hello,</P>
<P> </P>
<P>I am working on a project that requires me to perform some analysis on a bitcode file outside the existing LLVM analysis frameworks (opt, etc.).  In what I am doing, I need to be able to access the dominator tree for a given function.  Is there a way I can instantiate a DominatorTree object outside the existing analysis frameworks?</P></DIV></BLOCKQUOTE><BR>If you use a PassManager object to run passes, then you can simply have your analysis be an LLVM pass and use the standard getAnalysis<>() template function to get access to the dominator tree analysis.  Any program can create a PassManager to run LLVM passes to perform analysis and transformation; the clang C/C++ front-end and the sc tool in SAFECode do this.<BR><BR>I don't know if using a PassManager is what you consider to be "outside the existing LLVM framework."  I'm hoping your only objection is to using the opt tool to run LLVM passes.<BR><BR>-- John T.<BR><BR>
<BLOCKQUOTE cite=mid:1034242797.13028.1311950602990.JavaMail.root@sz0154a.westchester.pa.mail.comcast.net>
<DIV style="FONT-FAMILY: Arial; COLOR: #000000; FONT-SIZE: 12pt">
<P> </P>
<P>I have tried several things all along the lines of:</P>
<P> </P>
<P>DominatorTree DT;</P>
<P>DT.getBase().recalculate(F);</P>
<P> </P>
<P>Everything I have tried results in an assertion failure when trying to access the front() of what I assume is the DominatorTree:</P>
<P> </P>
<P>Assertion failed: !empty() && "Called front() on empty list!"</P>
<P> </P>
<P>If anyone has an example of how to do this, I would really appreciate it.</P>
<P> </P>
<P>Thanks,</P>
<P> </P>
<P>David<BR></P></DIV><BR>
<FIELDSET class=mimeAttachmentHeader></FIELDSET> <BR><PRE>_______________________________________________
LLVM Developers mailing list
<A class=moz-txt-link-abbreviated href="mailto:LLVMdev@cs.uiuc.edu" target=_blank>LLVMdev@cs.uiuc.edu</A>         <A class=moz-txt-link-freetext href="http://llvm.cs.uiuc.edu/" target=_blank>http://llvm.cs.uiuc.edu</A>
<A class=moz-txt-link-freetext href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target=_blank>http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</A>
</PRE></BLOCKQUOTE><BR></DIV></BLOCKQUOTE><BR></div></body></html>