This set of patches adds support for dumping IR before or after specified Passes. It adds the following command-line options: -print-before=<pass-option> -print-after=<pass-option> -print-before-all -print-after-all Use it like this: llc -debug -print-before=linearscan-regalloc file.bc -o file.s -help will print the pass options available to -print-before and -print-after. The patches add support to clang, llvm and llvm-gcc, respectively. We use this extensively to debug Passes by examining IR before and after they run. Please review for commit and comment. It would be great to get this into the 2.7 release. Thanks! -Dave -------------- next part -------------- A non-text attachment was scrubbed... Name: clang-beforeafter.patch Type: text/x-patch Size: 3083 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100302/f2329b58/attachment.bin> -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-beforeafter.patch Type: text/x-patch Size: 113597 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100302/f2329b58/attachment-0001.bin> -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm-gcc-beforeafter.patch Type: text/x-patch Size: 6035 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100302/f2329b58/attachment-0002.bin>
On Mar 2, 2010, at 1:45 PM, David Greene wrote:> This set of patches adds support for dumping IR before or after specified > Passes. It adds the following command-line options: > > -print-before=<pass-option> > -print-after=<pass-option> > -print-before-all > -print-after-allThis patch looks very invasive for such a simple thing, isn't there a better way? Also, please please please stay in 80 columns. -Chris> > Use it like this: > > llc -debug -print-before=linearscan-regalloc file.bc -o file.s > > -help will print the pass options available to -print-before and -print-after. > > The patches add support to clang, llvm and llvm-gcc, respectively. > > We use this extensively to debug Passes by examining IR before and after > they run. > > Please review for commit and comment. It would be great to get this into the > 2.7 release. > > Thanks! > > -Dave > > <clang-beforeafter.patch><llvm-beforeafter.patch><llvm-gcc-beforeafter.patch>_______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
On Thursday 04 March 2010 01:54:55 Chris Lattner wrote:> On Mar 2, 2010, at 1:45 PM, David Greene wrote: > > This set of patches adds support for dumping IR before or after specified > > Passes. It adds the following command-line options: > > > > -print-before=<pass-option> > > -print-after=<pass-option> > > -print-before-all > > -print-after-all > > This patch looks very invasive for such a simple thing, isn't there a > better way?Possibly. What specifically do you object to? The main problem is that one needs different printers at different stages of the compiler: ModulePrinter, FunctionPrinter and MachineFunctionPrinter. It makes sense to write the code once and parameterize it on the printer type. I see addPass<> as the most "invasive" in the sense that the patch changes almost every call of PM.addPass(..) to addPass<>(PM, ...). That's a consequence of code sharing. I wanted a command-line interface that is intuitive. This requires that passes show up in the print option as a result of registering them with the PassManager. I could get rid of the "Previous" parameter to addPass<> if we don't mind duplicate output in the case where we want something printed after Pass A and before Pass B when Pass B immediately follows Pass A. I'm happy to revisit design decisions if you let me know what you want to see changed.> Also, please please please stay in 80 columns.Ah, thought I had fixed all of that. I will do another scan. -Dave
On Mar 2, 2010, at 1:45 PM, David Greene wrote:> -print-before-all > -print-after-allWhat's the difference between printing before all passes and printing after all passes? /jakob
On Monday 29 March 2010 12:47:30 Jakob Stoklund Olesen wrote:> On Mar 2, 2010, at 1:45 PM, David Greene wrote: > > -print-before-all > > -print-after-all > > What's the difference between printing before all passes and printing after > all passes?So you want an IR dump before the very first pass? Do you want one after the very last pass? Usually I use both so I get before/after dumps for each pass. -Dave
On Mar 29, 2010, at 10:47 AM, Jakob Stoklund Olesen wrote:> > On Mar 2, 2010, at 1:45 PM, David Greene wrote: > >> -print-before-all >> -print-after-all > > What's the difference between printing before all passes and printing after all passes?Makes it easier to find what you're looking for probably. Matter of semantics but if I'm looking for something before I go into the 3rd inst-combine pass it's probably easier to look for instcombine-3.before than licm.after :) -eric