<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi Son Tuan,<div class=""><br class=""></div><div class="">Thanks for taking a look at this :). Responses inline --</div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On Mar 14, 2018, at 8:11 AM, Son Tuan VU <<a href="mailto:sontuan.vu119@gmail.com" class="">sontuan.vu119@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi Vedant, hi all,<div class=""><br class=""></div><div class="">My goal is to measure debug info loss of <i class="">each</i><b class=""> </b>optimization pass in LLVM. I am trying to create a debugify-each mode in opt, inspired by verify-each mode which is supposed to already work.</div></div></div></blockquote><div><br class=""></div>+ Anastasis, who's interested in working on this as well. There's definitely enough work to go around: once we can measure debug info loss after each pass, we'll need a testing harness.</div><div><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">However, if I understand correctly, the verify-each mode (triggered by -verify-each option in opt) only works when we provide a pass list or a pass pipeline.</div></div></div></blockquote><div><br class=""></div><div>Yes, you're correct.</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""> Is this intended? I mean, why do not let people verify each pass in -O{1,2,3} pipeline?</div></div></div></blockquote><div><br class=""></div><div>That's a good question! Like you, I assumed -verify-each "does the right thing" when you pass -O1/-O2/etc. to opt.</div><div><br class=""></div><div>I'm not sure if the current behavior is intended (hopefully others will chime in about this :). If no one does, please file a bug.</div><div><br class=""></div><div>I imagine this is pretty simple to fix. You can just define and use custom pass managers within opt which inject debugify passes as needed:</div><div><br class=""></div><div><div></div><blockquote type="cite" class=""><blockquote type="cite" class=""><div>// In opt.cpp:</div></blockquote></blockquote><blockquote type="cite" class=""><blockquote type="cite" class=""><br class=""></blockquote></blockquote><blockquote type="cite" class=""><blockquote type="cite" class=""><div>class DebugifyEachFunctionPassManager : public legacy::FunctionPassManager {</div><div>public:</div><div>  explicit DebugifyEachFunctionPassManager(Module *M)</div><div>      : FunctionPassManager(M) {}</div><div><br class=""></div><div>  void add(Pass *P) override {</div><div>    // FunctionPassManager::add(<debugify>)</div><div>    FunctionPassManager::add(P);</div><div>  }</div><div>};</div></blockquote></blockquote><div><br class=""></div></div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">My second question is more about debugify: what should be the best way to debugify each pass? Adding a debugify-each mode would make the output unreadable!</div></div></div></blockquote><div><br class=""></div><div>The intermediate output is all irrelevant. I think it'd be best to simply throw it away. What really matters are the debug info loss statistics: we should capture these stats after each pass and dump them as JSON, at the end of the pipeline.</div><div><br class=""></div><div>vedant</div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class=""> Maybe writing a script that collects all optimization options (like -mem2reg or -constmerge), then pass each one of them to opt with -enable-debugify so that we have 1 output file for each debugified pass?</div><div class=""><br class=""></div><div class="">Thank you for your help,</div><div class=""><br clear="all" class=""><div class=""><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr" class="">Son Tuan Vu</div></div></div>
</div></div>
</div></blockquote></div><br class=""></div></body></html>