<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi Daniel, <div><br></div><div>You forgot to attache the patch. </div><div><br></div><div>Thanks,</div><div>Nadav</div><div><br><div><div>On Apr 11, 2013, at 1:53 PM, "Malea, Daniel" <<a href="mailto:daniel.malea@intel.com">daniel.malea@intel.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Hi all,<br><br>There has been some talk about debugging LLVM IR on the lists and on IRC, so I implemented a transform pass that allows just that! Here's a screenshot of me stepping through the IR generated by clang to catch an exception:<span class="Apple-converted-space"> </span><a href="http://i.imgur.com/OG6rUIE.png">http://i.imgur.com/OG6rUIE.png</a><br><br>Before I get into the details, here are some limitations:<br><br> *   It is a requirement (for now) that the input module have debug metadata (that is, it was generated with clang –g or equivalent)<br> *   By running the pass, metadata that correlates machine code back to the original source file are lost. Until debuggers know about IR, this will remain a limitation.<br> *   Printing variables that exist in the original source works, but LLVM temporaries not so much (in the current implementation)<br><br>That said, the patch includes a few test cases that use opt to modify code with debug metadata decorators to allow debugging of IR. If you'd like to give it a shot, add the pass to your PassManager by calling createDebugIRPass()!<br><br>I'd be appreciative of testing and/or review comments! The patch is available on phabricator<span class="Apple-converted-space"> </span><a href="http://llvm-reviews.chandlerc.com/D659">http://llvm-reviews.chandlerc.com/D659</a>and the details from the review request follow.<br><br><br>I plan to commit it as 4 separate patches, here's what they do:<br><br><br>Part #1: FormattedStream -- Add line tracking<br>- previously formatted_raw_ostream tracked columns, now it tracks lines too<br>- used by DebugIR pass to know the line number to connect to each IR instruction<br><br>Part #2: Pull up AssemblyWriter interface into header to allow subclassing<br>- made all functions virtual so that subclasses can specialize them<br>- add printInstructionLine so that subclasses can choose whether or not to<br>print the newline character (without having to implement printBasicBlock()<br><br>Part #3: DebugIR -- emit IR file and replace source lines with IR lines in MD<br>- requires existing debug information to be present<br>- fixes up file name and line number information<br>- emits a "<orig_filename>-debug.ll" succinct IR file (without !dbg metadata<br>or debug intrinsics) that can be read by a debugger<br><br>Part #4: DebugIR tests -- lit tests for the line number transform<br>- simple one-function case<br>- function-calling case<br>- external function calling case<br>- exception throwing case<br>- vector case<br>- O3 (vector) case<br><br><br><br>Thanks,<br><br><br>--<br><br>Daniel Malea <<a href="mailto:daniel.malea@intel.com">daniel.malea@intel.com</a><<a href="mailto:daniel.malea@intel.com">mailto:daniel.malea@intel.com</a>>><br><br>Intel Waterloo<br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a></div></blockquote></div><br></div></body></html>