<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 25, 2016, at 4:34 PM, Michael Gottesman via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; 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;" class=""><blockquote type="cite" class=""><div class=""><br class="Apple-interchange-newline">On Mar 25, 2016, at 4:30 PM, Matthias Braun via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="">Andy,</div><div class=""><br class=""></div><div class="">I'd love to see this feature. I wouldn't care too much wether the interface is a single number or two numbers, but if possible print the name of the function and the name of the pass that was just skipped so the developers knows where to start looking.</div></div></div></blockquote><div class=""><br class=""></div><div class="">We do this in swift actually as well. We have a feature called -sil-print-pass-name. It causes the pass manager to print out the action the pass manager is performing and an identifier of the object it is performing the action to. </div></div></div></blockquote><div><br class=""></div><div>This looks equivalent to "-debug-pass=Executions" in LLVM right?</div><div><br class=""></div><div>-- </div><div>Mehdi</div><div><br class=""></div><div><br class=""></div><br class=""><blockquote type="cite" class=""><div class=""><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; 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;" class=""><div class="">When you get the final number, you can rerun with that option set and it will tell you the last pass invocation. It makes it /really/ easy.</div><div class=""><br class=""></div><div class="">Michael</div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><br class=""></div><div class="">- Matthias</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class=""><div class="">On Mar 25, 2016, at 12:13 PM, Kaylor, Andrew via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="WordSection1" style="page: WordSection1; font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; 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;"><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);">Hi Mehdi,<o:p class=""></o:p></span></div><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);"><o:p class=""> </o:p></span></div><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);">I started by trying to implement a single number approach, but it doesn’t allow quite the approach I wanted in terms of isolating individual functions.  Also, I think that there would be problems with that once parallel function optimization is enabled.<o:p class=""></o:p></span></div><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);"><o:p class=""> </o:p></span></div><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);">I am open to revisiting that approach to see if the problems I had with it can be resolved.<o:p class=""></o:p></span></div><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><a name="_MailEndCompose" class=""><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);"><o:p class=""> </o:p></span></a></div><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);">-Andy<o:p class=""></o:p></span></div><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif; color: rgb(31, 73, 125);"><o:p class=""> </o:p></span></div><div class=""><div class="" style="border-style: solid none none; border-top-color: rgb(225, 225, 225); border-top-width: 1pt; padding: 3pt 0in 0in;"><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><a name="_____replyseparator" class=""></a><b class=""><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">From:</span></b><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"><span class="Apple-converted-space"> </span><a href="mailto:mehdi.amini@apple.com" class="">mehdi.amini@apple.com</a><span class="Apple-converted-space"> </span>[<a href="mailto:mehdi.amini@apple.com" class="">mailto:mehdi.amini@apple.com</a>]<span class="Apple-converted-space"> </span><br class=""><b class="">Sent:</b><span class="Apple-converted-space"> </span>Friday, March 25, 2016 11:57 AM<br class=""><b class="">To:</b><span class="Apple-converted-space"> </span>Kaylor, Andrew <<a href="mailto:andrew.kaylor@intel.com" class="">andrew.kaylor@intel.com</a>><br class=""><b class="">Cc:</b><span class="Apple-converted-space"> </span><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class=""><b class="">Subject:</b><span class="Apple-converted-space"> </span>Re: [llvm-dev] RFC: New support for triaging optimization-related failures in front ends<o:p class=""></o:p></span></div></div></div><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p class=""> </o:p></div><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">Hi Andy,<o:p class=""></o:p></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p class=""> </o:p></div><div class=""><blockquote class="" style="margin-top: 5pt; margin-bottom: 5pt;"><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">On Mar 25, 2016, at 11:41 AM, Kaylor, Andrew via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="" style="color: purple; text-decoration: underline;">llvm-dev@lists.llvm.org</a>> wrote:<o:p class=""></o:p></div></div><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p class=""> </o:p></div><div class=""><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">The Intel C++ compiler has long had an internal facility to help our development teams track down the source of optimization related bugs by allowing a sort of binary search in which optimization passes and even individual optimizations are selectively disabled in response to front end command line options.  As we've been doing development work on LLVM our developers have found that we miss this capability and so we would like to introduce something like this to the LLVM code base.<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">I am aware of the many existing facilities in LLVM for tracking down bugs such as llc, opt and bugpoint.  Our development teams are, of course, making use of these facilities, but we believe that the feature I am going to propose today can powerfully complement these existing tools and provide a better way to automate defect finding in products that provide a front end for LLVM.  This can also be used by customers (who may not be able to share their source code) to narrow down problems and provide a concise reproducer.<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">While the combination of llc, opt and bugpoint is very effective at locating compilation failures that can be reproduced from an LLVM IR or bitcode file, they can be cumbersome and difficult to automate, particularly when debugging runtime failures in programs with non-trivial build systems.  The new feature that I am proposing provides a way to selectively turn off ranges of optimizations directly from a set of front end command line options.<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">The proposed feature works by assigning arbitrary but repeatable values to modules, functions, passes, etc. as a compilation unit is being optimized.  The developer can then use these numbers to selectively disable parts of the optimization without otherwise altering the behavior of the compiler.<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">In keeping with the current LLVM pass manager structure, I am handling module passes, SCC passes and function passes separately.  I propose handling loop, region and basic block passes as if they were function passes.  (I think what this means will become clear below.)  Because the handling of function passes illustrates well all of the steps involved in using the feature I am proposing, I'll start by describing that case in detail.  I'm describing this as a series of manual steps, but I intend that these steps could be easily automated.<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">I propose introducing three command line options to support locating problems with function pass optimizations.  I envision these as options available through the front end but implemented in the core LLVM library.<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">-num-fn<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  sets an upper limit on the function to optimize<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  -1 enables all and displays the numbering<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">-num-fn-pass<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  sets an upper limit on the function pass to run on the limit function specified by -num-fn<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  -1 enables all and displays the numbering<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  ignored if -num-fn is not used or is -1<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  all passes are run on functions below the limit function<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  only necessary and analysis passes are run on functions above the limit function<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">-num-fn-case<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  sets an upper limit on the optimization case to apply within the limit function pass specified by -num-fn-pass<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  -1 enables all and displays the numbering<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  ignored if -num-fn-pass is not used or is -1<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  all cases are applied in passes below the limit function pass<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  no cases are applied in optional passes below the limit function pass<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">As an example, a developer searching for function pass related optimization problems (assuming a case which fails when compiled with -O2 but passes when compiled with -O0) would begin by using the '-num-fn=-1' option to see the functioning numbering.<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">clang -c -O2 -num-fn=-1 test.c<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (1) prune_match<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (2) free_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (3) hash_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (4) insert_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (5) zero_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (6) init_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (8) clean_up<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">The developer would then use a binary search, recompiling with selective optimization and re-running the test case to determine the function in which the problem occurs.<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">clang -c -O2 -num-fn=4 test.c<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"><test passes><o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">clang -c -O2 -num-fn=6 test.c<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"><test passes><o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">clang -c -O2 -num-fn=7 test.c<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"><test fails><o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Having found the problem function, the developer would use the '-num-fn-pass=-1' option to see the numbering of function passes (including loop, region and basic block passes) that are run on that function.<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">clang -c -O2 -num-fn=7 -num-fn-pass=-1 test.c<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (1) prune_match<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (2) free_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (3) hash_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (4) insert_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (5) zero_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (6) init_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running necessary pass Function Pass Manager on function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running necessary pass Module Verifier on function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running necessary pass Add DWARF path discriminators (3) on function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running pass (1) Simplify the CFG on function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running analysis pass Dominator Tree Construction on function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running pass (2) SROA on function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running pass (3) Early CSE on function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running pass (4) Lower 'expect' Intrinsics on function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"><additional passes ignored for brevity><o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">NOT Optimizing function (8) clean_up<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">The user would again use a binary search to determine the problem pass.<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">clang -c -O2 -num-fn=7 -num-fn-pass=2 test.c<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"><test passes><o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">clang -c -O2 -num-fn=7 -num-fn-pass=3 test.c<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"><test fails><o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Having determined the problem pass, the developer would use the '-num-fn-case=-1' option to see the numbering of individual optimizations applied by the pass.<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">clang -c -O2 -num-fn=7 -num-fn-pass=3 -num-fn-case=-1 test.c<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (1) prune_match<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (2) free_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (3) hash_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (4) insert_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (5) zero_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (6) init_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running necessary pass Function Pass Manager on function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running necessary pass Module Verifier on function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running necessary pass Add DWARF path discriminators (3) on function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running pass (1) Simplify the CFG on function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running analysis pass Dominator Tree Construction on function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running pass (2) SROA on function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running pass (3) Early CSE on function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Another case (1): EarlyCSE CSE value<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Another case (2): EarlyCSE CSE value<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Another case (3): EarlyCSE CSE value<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Another case (4): EarlyCSE CSE load<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Another case (5): EarlyCSE CSE value<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Another case (6): EarlyCSE CSE load<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Another case (7): EarlyCSE CSE value<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Another case (8): EarlyCSE CSE load<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">NOT running pass (4) Lower 'expect' Intrinsics on function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"><additional passes ignored for brevity><o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">NOT Optimizing function (8) clean_up<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Finally, the developer would use one last binary search to determine which optimization case was causing the failure.<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">clang -c -O2 -num-fn=7 -num-fn-pass=3 -num-fn-case=4 test.c<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"><test fails><o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">clang -c -O2 -num-fn=7 -num-fn-pass=3 -num-fn-case=2 test.c<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"><test passes><o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">clang -c -O2 -num-fn=7 -num-fn-pass=3 -num-fn-case=3 test.c<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"><test fails><o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Most of the above functionality can be implemented by inserting hooks into the various pass managers.  Support for the '-num-fn-case' option would require instrumentation of individual passes.  I propose implementing this on an 'opt in' basis so that it can be added to passes as needed and passes which do not opt in will simply not report having selectable cases.<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Note that I have introduced the concept of a "necessary" pass.  Because the goal of this is to have the front end produce the same sort of object or executable file that it normally would, some passes (such as the register allocator and its various helper passes) cannot be skipped.  I am also, for now, proposing that all analysis passes be run always to avoid the problem of determining which analysis passes would be required for later "necessary" passes.  We can revisit this as needed.<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">As I've said, I intend to handle loop, region and basic block passes as if they were just another function pass.  While I would like to display an associated number for the target loop, region or block, I don't see value in being able to filter passes based on this value (because they are relatively dynamic constructs), so consecutive runs of a single loop pass (for instance) on different loops would be identified as distinct function passes.  For example:<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running pass (25) Loop Invariant Code Motion on loop (1), function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running pass (26) Loop Invariant Code Motion on loop (2), function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running pass (27) Loop Invariant Code Motion on loop (3), function (7) matches_S<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">I would also like to have a feature that would allow the developer to request that an LLVM IR/bitcode file be emitted just before the first disabled pass so that the isolated IR could be used with opt, llc or bugpoint for further debugging.  I haven't worked out exactly how this would work, so I'm just mentioning it here as a fuzzy part of the proposal.<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Circling back now to module and SCC passes, these would work in pretty much the same way as the above method for function passes so I won't cover them in as much detail.  I propose the following new command line options.<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">-num-mod<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  sets an upper limit on the module on which to run module passes<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  -1 enables all and displays the numbering<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  defaults to 1 since I expect most front ends to usually operate on a single module<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">-num-mod-pass<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  sets an upper limit on the module pass to run on the limit module specified by -num-mod<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  -1 enables all and displays the numbering<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  ignored if -num-mod is -1<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  all passes are run on modules below the limit module<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  only necessary and analysis passes are run on modules above the limit module<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">-num-mod-case<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  sets an upper limit on the optimization case to apply within the limit module pass specified by -num-mod-pass<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  -1 enables all and displays the numbering<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  ignored if -num-mod-pass is not used or is -1<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  all cases are applied in passes below the limit module pass<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  no cases are applied in optional passes below the limit module pass<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">-num-scc-pass<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  sets an upper limit on the SCC pass to run<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  -1 enables all and displays the numbering<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">-num-scc-case<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  sets an upper limit on the optimization case to apply within the limit SCC pass specified by -num-scc-pass<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  -1 enables all and displays the numbering<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  ignored if -num-scc-pass is not used or is -1<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  all cases are applied in passes below the limit SCC pass<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">  no cases are applied in optional passes below the limit SCC pass<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Similar to loops, regions and basic blocks, I would like to present numbering information for each unique SCC, but I do not believe there is value in being able to filter on a specific SCC because they are subject to reorganization.  Rather I would treat each invocation of an SCC pass as a separate selectable pass.  The output for an SCC problem search would look something like this:<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing SCC (1): <null function><o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running pass (1) Remove unused exception handling info on SCC (1)<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running pass (2) Function Integration/Inlining on SCC (1)<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running pass (3) Deduce function attributes on SCC (1)<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing SCC (2): isupper<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running pass (4) Remove unused exception handling info on SCC (2)<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running pass (5) Function Integration/Inlining on SCC (2)<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running pass (6) Deduce function attributes on SCC (2)<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"><snip><o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Optimizing SCC (34): or_purge_E_list, and_purge_E_list, purge_Exp<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running pass (101) Remove unused exception handling info on SCC (34)<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running pass (102) Function Integration/Inlining on SCC (34)<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">running pass (103) Deduce function attributes on SCC (34)<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"><snip><o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Here I'm printing the functions (if any) associated with nodes in the SCC just to give the developer some feedback on which part of the code is being worked on.<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">I have a working prototype of all of the above functionality using both the new pass manager and the legacy pass manager.<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">So what do you think?  Do you agree that support for a feature of this sort would be useful in the LLVM core library?  What problems do you see in my proposal?  What additional options would you like to see added?<o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;"> <o:p class=""></o:p></span></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><span class="" style="font-size: 11pt; font-family: Calibri, sans-serif;">Thanks in advance for any feedback.<o:p class=""></o:p></span></div></div></div></blockquote></div><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p class=""> </o:p></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p class=""> </o:p></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">You're right that we could benefit from support to help "bisecting" where a miscompile happens in a more automated way.<o:p class=""></o:p></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p class=""> </o:p></div></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">Reading through you (long but nice) description, I thought about something simpler: a single number incremented every time a pass in the optimizer is ran (as the order shown by -debug-pass=Executions). <o:p class=""></o:p></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">That way you run once to get the total number of passes that ran and then, a simple bisect script can find quite quickly at which point the miscompile is introduced (between 0 and max).<o:p class=""></o:p></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">I haven't thought about it much but I'm interested in you view of the pros/cons.<o:p class=""></o:p></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p class=""> </o:p></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">-- <o:p class=""></o:p></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;">Mehdi<o:p class=""></o:p></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p class=""> </o:p></div></div><div class=""><div class="" style="margin: 0in 0in 0.0001pt; font-size: 12pt; font-family: 'Times New Roman', serif;"><o:p class=""> </o:p></div></div></div><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; 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; float: none; display: inline !important;">_______________________________________________</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; 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;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; 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; float: none; display: inline !important;">LLVM Developers mailing list</span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; 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;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; 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; float: none; display: inline !important;"><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a></span><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; 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;"><span class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; 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; float: none; display: inline !important;"><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></span></div></blockquote></div><br class=""></div>_______________________________________________<br class="">LLVM Developers mailing list<br class=""><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a><br class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br class=""></div></blockquote></div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; 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;"><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; 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; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; 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;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; 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; float: none; display: inline !important;" class="">LLVM Developers mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; 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;" class=""><a href="mailto:llvm-dev@lists.llvm.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; 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;" class="">llvm-dev@lists.llvm.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; 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;" class=""><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; 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;" class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></div></blockquote></div><br class=""></body></html>