John, Thanks for the quick reply. Using a PassManager object should work fine. As you said, my only objection is to exec'ing opt. 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. Thanks, David ----- Original Message ----- From: "John Criswell" <criswell at illinois.edu> To: "david dewey" <david.dewey at comcast.net> Cc: llvmdev at cs.uiuc.edu Sent: Friday, July 29, 2011 10:56:20 AM Subject: Re: [LLVMdev] Accessing Dominator Tree On 7/29/11 9:43 AM, david.dewey at comcast.net wrote: Hello, 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? 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. 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. -- John T. I have tried several things all along the lines of: DominatorTree DT; DT.getBase().recalculate(F); Everything I have tried results in an assertion failure when trying to access the front() of what I assume is the DominatorTree: Assertion failed: !empty() && "Called front() on empty list!" If anyone has an example of how to do this, I would really appreciate it. Thanks, David _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110729/044d12a7/attachment.html>
On 7/29/11 10:00 AM, david.dewey at comcast.net wrote:> > John, > > Thanks for the quick reply. Using a PassManager object should work > fine. As you said, my only objection is to exec'ing opt. > > 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. >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. -- John T.> Thanks, > > David > > > ------------------------------------------------------------------------ > > *From: *"John Criswell" <criswell at illinois.edu> > *To: *"david dewey" <david.dewey at comcast.net> > *Cc: *llvmdev at cs.uiuc.edu > *Sent: *Friday, July 29, 2011 10:56:20 AM > *Subject: *Re: [LLVMdev] Accessing Dominator Tree > > On 7/29/11 9:43 AM, david.dewey at comcast.net wrote: > > Hello, > > 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? > > > 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. > > 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. > > -- John T. > > I have tried several things all along the lines of: > > DominatorTree DT; > > DT.getBase().recalculate(F); > > Everything I have tried results in an assertion failure when > trying to access the front() of what I assume is the DominatorTree: > > Assertion failed: !empty() && "Called front() on empty list!" > > If anyone has an example of how to do this, I would really > appreciate it. > > Thanks, > > David > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110729/20445425/attachment.html>
John, 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. All of that seems to be working great. Thanks for your help, David ----- Original Message ----- From: "John Criswell" <criswell at illinois.edu> To: "david dewey" <david.dewey at comcast.net> Cc: llvmdev at cs.uiuc.edu Sent: Friday, July 29, 2011 11:04:10 AM Subject: Re: [LLVMdev] Accessing Dominator Tree On 7/29/11 10:00 AM, david.dewey at comcast.net wrote: John, Thanks for the quick reply. Using a PassManager object should work fine. As you said, my only objection is to exec'ing opt. 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. 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. -- John T. Thanks, David ----- Original Message ----- From: "John Criswell" <criswell at illinois.edu> To: "david dewey" <david.dewey at comcast.net> Cc: llvmdev at cs.uiuc.edu Sent: Friday, July 29, 2011 10:56:20 AM Subject: Re: [LLVMdev] Accessing Dominator Tree On 7/29/11 9:43 AM, david.dewey at comcast.net wrote: Hello, 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? 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. 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. -- John T. I have tried several things all along the lines of: DominatorTree DT; DT.getBase().recalculate(F); Everything I have tried results in an assertion failure when trying to access the front() of what I assume is the DominatorTree: Assertion failed: !empty() && "Called front() on empty list!" If anyone has an example of how to do this, I would really appreciate it. Thanks, David _______________________________________________ LLVM Developers mailing list LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110801/c952af2f/attachment.html>