<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 4, 2017 at 3:49 AM, Martin J. O'Riordan <span dir="ltr"><<a href="mailto:martin.oriordan@movidius.com" target="_blank">martin.oriordan@movidius.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-IE" link="blue" vlink="purple"><div class="m_-4775240265916013809WordSection1"><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black">Thanks Sean,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black">My apologies for previously writing “Thanks Sean and Silva”, I intended “Thanks Sean and Ryan” - duh! - sleep deprived having just flown to the USA.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black">The dump is very enlightening for me, and very large - I hadn’t realised that there were quite so many passes.  At ‘</span><span style="font-family:"Courier New";color:black">-O0</span><span style="font-family:"Book Antiqua",serif;color:black">’ there are ~70 passes, but at ‘</span><span style="font-family:"Courier New";color:black">-O1</span><span style="font-family:"Book Antiqua",serif;color:black">’ it jumps to ~310 passes, and then ~340 passes at ‘</span><span style="font-family:"Courier New";color:black">-O2</span><span style="font-family:"Book Antiqua",serif;color:black">’ and ‘</span><span style="font-family:"Courier New";color:black">-O3</span><span style="font-family:"Book Antiqua",serif;color:black">’.  I will have to carefully study these passes to see what optimisations they perform (if any), though there are the obvious ones too.<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black">One thing I observed, is that there are some passes that report:<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black"><u></u> <u></u></span></p><p class="MsoNormal" style="margin-left:36.0pt"><span style="font-family:"Courier New";color:black">Unnamed pass: implement Pass::getPassName()<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black">This always appears after the final Target ‘</span><span style="font-family:"Courier New";color:black">AsmPrinter</span><span style="font-family:"Book Antiqua",serif;color:black">’ pass (“SHAVE Assembly Printer” in our case) and appears to be from the ‘</span><span style="font-family:"Courier New";color:black">FPPassManager</span><span style="font-family:"Book Antiqua",serif;color:black">’, while the other happens after ‘Global Variable Optimizer’ for optimisation levels of ‘</span><span style="font-family:"Courier New";color:black">-O1</span><span style="font-family:"Book Antiqua",serif;color:black">’ and higher and this seems to be the from the ‘</span><span style="font-family:"Courier New";color:black">MPPassManager</span><span style="font-family:"Book Antiqua",serif;color:black">’.  I am using the release LLVM v4.0 sources, not the head revision.  I guess these are noise and can be ignored.</span></p></div></div></blockquote><div><br></div><div>I remember running into these before. I forget exactly what we ended up discovering they were but I remember that it wasn't remarkable. Vaguely remembering, I think the GlobalOpt one was something related to it accessing function AA results or something like that. The reason it didn't have a name is that it goes through some sort of adapter thing which doesn't implement getPassName.</div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-IE" link="blue" vlink="purple"><div class="m_-4775240265916013809WordSection1"><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black"><u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black">All the best,<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black">            MartinO<u></u><u></u></span></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif;color:black"><u></u> <u></u></span></p><p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Sean Silva [mailto:<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>] <br><b>Sent:</b> 29 June 2017 04:15<br><b>To:</b> ORiordan, Martin <<a href="mailto:martin.oriordan@intel.com" target="_blank">martin.oriordan@intel.com</a>><br><b>Cc:</b> Ryan Taylor <<a href="mailto:ryta1203@gmail.com" target="_blank">ryta1203@gmail.com</a>>; Martin J. O'Riordan <<a href="mailto:martin.oriordan@movidius.com" target="_blank">martin.oriordan@movidius.com</a>><wbr>; llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span></p><div><div class="h5"><br><b>Subject:</b> Re: [llvm-dev] Definitive list of optimisations at each optimisation level<u></u><u></u></div></div><p></p><div><div class="h5"><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">On Mon, Jun 26, 2017 at 5:04 AM, ORiordan, Martin <<a href="mailto:martin.oriordan@intel.com" target="_blank">martin.oriordan@intel.com</a>> wrote:<u></u><u></u></p><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm"><div><div><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif">Thanks Sean and Silva.</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif">I guess what I was seeking was a URL that I could point (non-compiler) people at, but I guess no such reference exists.  What I can do if reference bot the source manager and use ‘-</span>mllvm -debug-pass=Structure’ for each optimisation level, and document that.  The downside is that this will continuously go out of data with each release.<u></u><u></u></p></div></div></blockquote><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Yeah, the nasty thing is that as each user of LLVM is running potentially different pass pipelines, we don't really have a good way to write a user-facing (or at least non-compiler-dev-facing) page describing the optimizations that they should expect the compiler to do, as the compiler developers using LLVM may have changed it. In theory, we could provide such a page for the open-source clang. Such a page of course couldn't go into massive detail about each pass and as such will likely be mostly describing the basics.<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Most of the information that users would care about is likely to not get out of date very easily (e.g. we might switch GVN implementations, but the way in which they differ isn't going to be relevant to such a document; we might switch EarlyCSE to MemorySSA, but that isn't relevant to such a document).<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">-- Sean Silva<u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm"><div><div><p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">All the best,<u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">            MartinO<u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">PS: Movidius is now part of Intel, so I will be gradually switching to my Intel email address.<u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif"> </span><u></u><u></u></p><p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Ryan Taylor [mailto:<a href="mailto:ryta1203@gmail.com" target="_blank">ryta1203@gmail.com</a>] <br><b>Sent:</b> Sunday, June 25, 2017 2:59 AM<br><b>To:</b> Sean Silva <<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>><br><b>Cc:</b> Martin J. O'Riordan <<a href="mailto:martin.oriordan@movidius.com" target="_blank">martin.oriordan@movidius.com</a>><wbr>; llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br><b>Subject:</b> Re: [llvm-dev] Definitive list of optimisations at each optimisation level</span><u></u><u></u></p><div><div><p class="MsoNormal"> <u></u><u></u></p><div><p class="MsoNormal">I agree, it's much clearer, it just takes runs at multiple opt levels and therefore I don't find it to be a "one stop shop". <u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p><div><p class="MsoNormal">On Jun 24, 2017 8:44 PM, "Sean Silva" <<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>> wrote:<u></u><u></u></p><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt"><div><div><p class="MsoNormal">Looking at PassManagerBuilder can be useful because there are sometimes comments giving some idea of the intent of the particular choice of passes, but it can be difficult to see the big picture of all the passes that are run because it is very parameterized and split across multiple subroutines.<u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">Running clang at O0 through O3 with -mllvm -debug-pass=Structure is generally more enlightening because then you see everything in one place for each optimization level.<u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">-- Sean Silva<u></u><u></u></p><div><p class="MsoNormal"> <u></u><u></u></p><div><p class="MsoNormal">On Jun 24, 2017 12:54 PM, "Ryan Taylor" <<a href="mailto:ryta1203@gmail.com" target="_blank">ryta1203@gmail.com</a>> wrote:<u></u><u></u></p><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt"><div><p class="MsoNormal">Right but then you'll have to call each opt level. Have u looked in the pass manager? <u></u><u></u></p></div><div><div><p class="MsoNormal"> <u></u><u></u></p><div><p class="MsoNormal">On Jun 24, 2017 3:52 PM, "Sean Silva via llvm-dev" <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<u></u><u></u></p><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt"><div><div><p class="MsoNormal">The most definitive list you can probably hope to get will be obtained by passing -mllvm -debug-pass=Structure to a clang invocation.<u></u><u></u></p></div><div><p class="MsoNormal"> <u></u><u></u></p></div><div><p class="MsoNormal">-- Sean Silva<u></u><u></u></p><div><p class="MsoNormal"> <u></u><u></u></p><div><p class="MsoNormal">On Jun 24, 2017 7:10 AM, "Martin J. O'Riordan via llvm-dev" <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<u></u><u></u></p><blockquote style="border:none;border-left:solid #cccccc 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5.0pt"><div><div><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif">I am often asked what optimisations “our” compiler performs at each level.  But “our” compiler is actually CLang/LLVM which we have retargeted to our proprietary target.</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif">Most of the work we do is in maintaining our target specific backend.  Certainly there are optimisations that we do to take best advantage of our instruction set during lowering and instruction selection, and we have also added a couple of additional passes which manipulate the IR in advance of lowering to better shape it for our target.</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif">But in practice the vast majority of optimisations are contributed by the continuously evolving and excellent LLVM target independent passes, and have little or nothing to do with the work we do in our backend - though it is obviously directed/tuned by the various target call-backs and the target cost models.</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif">Is there a “one stop shop” list of the optimisation passes that LLVM performs, and identification of which are enabled by default for each of the 4 standard optimisation levels ‘-O0’ thru ‘-O3’?</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif">The reason that I ask, is that I really don’t have an honest or informed answer that I can provide to people when they ask, and I haven’t found a definitive statement of this in the LLVM documentation that I could refer them to.</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif">Thanks,</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif"> </span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif">            MartinO</span><u></u><u></u></p><p class="MsoNormal"><span style="font-family:"Book Antiqua",serif"> </span><u></u><u></u></p></div></div><p class="MsoNormal" style="margin-bottom:12.0pt"><br>______________________________<wbr>_________________<br>LLVM Developers mailing list<br><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><u></u><u></u></p></blockquote></div><p class="MsoNormal"> <u></u><u></u></p></div></div></div><p class="MsoNormal" style="margin-bottom:12.0pt"><br>______________________________<wbr>_________________<br>LLVM Developers mailing list<br><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><u></u><u></u></p></blockquote></div></div></div></blockquote></div><p class="MsoNormal"> <u></u><u></u></p></div></div></div></blockquote></div></div></div></div></div><p>------------------------------<wbr>------------------------------<wbr>--<br>Intel Research and Development Ireland Limited<br>Registered in Ireland<br>Registered Office: Collinstown Industrial Park, Leixlip, County Kildare<br>Registered Number: 308263<u></u><u></u></p><p>This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.<u></u><u></u></p></div></blockquote></div><p class="MsoNormal"><u></u> <u></u></p></div></div></div></div></div></div></blockquote></div><br></div></div>