<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><span style="font-family: HelveticaNeue;" class="">Hi all,</span><br class="" style="font-family: HelveticaNeue;"><br class="" style="font-family: HelveticaNeue;"><span style="font-family: HelveticaNeue;" class="">The MachineOutliner has come a long way since the original incarnation presented at the 2016 LLVM Developer's Meeting [1]. In particular, we've been pushing a lot on the AArch64 target for the MachineOutliner. It's mature enough at this point that we'd like to take things a step further and turn it on by default in AArch64 under -Oz. Since the primary goal of -Oz is "make it as small as possible", the outliner is a good addition to the -Oz pass pipeline.</span><br class="" style="font-family: HelveticaNeue;"><br class="" style="font-family: HelveticaNeue;"><span style="font-family: HelveticaNeue;" class="">For a detailed description of the MachineOutliner, see the original RFC. [2].</span><br class="" style="font-family: HelveticaNeue;"><br class="" style="font-family: HelveticaNeue;"><span style="font-family: HelveticaNeue;" class="">We've observed, comparing -Oz to -Oz + outlining on the latest trunk compiler,</span><br class="" style="font-family: HelveticaNeue;"><br class="" style="font-family: HelveticaNeue;"><span style="font-family: HelveticaNeue;" class="">* A geomean ~4.4% text size reduction of the CTMark tests (min = 0.3% on tramp3d-v4, max = 15.4% on kc)</span><br class="" style="font-family: HelveticaNeue;"><br class="" style="font-family: HelveticaNeue;"><span style="font-family: HelveticaNeue;" class="">* A geomean compile-time overhead of ~1.1% (min = 0.2% on 7zip, max = 2.2% on sqlite3)</span><br class="" style="font-family: HelveticaNeue;"><br class="" style="font-family: HelveticaNeue;"><span style="font-family: HelveticaNeue;" class="">We perform regular testing to ensure the outliner produces correct AArch64 code at -Oz. Tests include the LLVM test suite and standard external test suites such as SPEC. All tests compile and execute. We've also been making sure that the outliner produces debuggable code. Users are still guaranteed to have sane backtraces in the presence of outlined functions.</span><br class="" style="font-family: HelveticaNeue;"><br class="" style="font-family: HelveticaNeue;"><span style="font-family: HelveticaNeue;" class="">Added exposure to various programs would help the outlining algorithm mature further. This, in turn, will help the overall outlining project. For example, there have been a few discussions on implementing an IR-level outlining pass [3, 4]. Ultimately, the goal is to create a shared outlining interface. This interface would allow the outliner to exist at any level of representation [4]. The general outlining algorithm will be part of the shared interface. Thus, in the spirit of incremental improvement, it makes sense to begin "stress-testing" it sooner than later.</span><br class="" style="font-family: HelveticaNeue;"><br class="" style="font-family: HelveticaNeue;"><font face="HelveticaNeue" class="">There are a few patches necessary to facilitate this. They are available in the patches section of this email. I’ll summarize what they do here for the sake of discussion though.</font><br class="" style="font-family: HelveticaNeue;"><br class="" style="font-family: HelveticaNeue;"><span style="font-family: HelveticaNeue;" class="">The first patch is one that teaches the backend about size optimization levels. This is comparable to what's done in the inliner. Today, the only way to tell if something is optimizing for size is by looking at function attributes. This is fine for function passes, but insufficient for module passes like the MachineOutliner. The function attribute approach forces the outliner to iterate over every function in the module before deciding to take action. If -Oz isn't passed in, then the outliner will not find any functions worth outlining from. This would incur unnecessary compile-time overhead. Thus, we decided the best course of action is to teach the backend about size options.</span><div class=""><br class=""></div><div class="">The second patch teaches llc to handle -Oz and -Os.<br class="" style="font-family: HelveticaNeue;"><br class="" style="font-family: HelveticaNeue;"><span style="font-family: HelveticaNeue;" class="">The third patch teaches targets about the outliner. A target will be able to specify if, and when it wants outlining on by default. It also adds a flag to disable the MachineOutliner for users that don’t want outlining behaviour when it is enabled by default.</span></div><div class=""><br class=""></div><div class="">The final patch teaches clang to pass the new size information down along to the backend. This allows us to do things like, clang -Oz … foo.c and have the outliner run.<br class="" style="font-family: HelveticaNeue;"><br class="" style="font-family: HelveticaNeue;"><span style="font-family: HelveticaNeue;" class="">Thanks for taking the time to read this!</span></div><div class=""><span style="font-family: HelveticaNeue;" class="">Jessica</span><br class="" style="font-family: HelveticaNeue;"><br class="" style="font-family: HelveticaNeue;"><span style="font-family: HelveticaNeue;" class="">*** Patches ***</span><br class="" style="font-family: HelveticaNeue;"><br class="" style="font-family: HelveticaNeue;"><span style="font-family: HelveticaNeue;" class="">1. Teaching the backend about -Oz/-Os: </span><font face="HelveticaNeue" class=""><a href="https://reviews.llvm.org/D45914" class="">https://reviews.llvm.org/D45914</a></font><div class="">2. Teach llc about -Oz/-Os: <a href="https://reviews.llvm.org/D45915" class="">https://reviews.llvm.org/D45915</a></div><div class=""><span style="font-family: HelveticaNeue;" class="">3. Teaching the target about the outliner and enabling it by default under AArch64: </span><font face="HelveticaNeue" class=""><a href="https://reviews.llvm.org/D45916" class="">https://reviews.llvm.org/D45916</a></font></div><div class="">4. Teaching clang to pass -Oz/-Os down to the backend: <a href="https://reviews.llvm.org/D45917" class="">https://reviews.llvm.org/D45917</a><br class="" style="font-family: HelveticaNeue;"><br class="" style="font-family: HelveticaNeue;"><br class="" style="font-family: HelveticaNeue;"><span style="font-family: HelveticaNeue;" class="">*** References ***</span><br class="" style="font-family: HelveticaNeue;"><span style="font-family: HelveticaNeue;" class="">[1] Reducing Code Size Using Outlining (</span><a href="https://www.youtube.com/watch?v=yorld-WSOeU" class="" style="font-family: HelveticaNeue;">https://www.youtube.com/watch?v=yorld-WSOeU</a><span style="font-family: HelveticaNeue;" class="">)</span><br class="" style="font-family: HelveticaNeue;"><br class="" style="font-family: HelveticaNeue;"><span style="font-family: HelveticaNeue;" class="">[2] Original RFC (</span><a href="http://lists.llvm.org/pipermail/llvm-dev/2016-August/104170.html" class="" style="font-family: HelveticaNeue;">http://lists.llvm.org/pipermail/llvm-dev/2016-August/104170.html</a><span style="font-family: HelveticaNeue;" class="">)</span><br class="" style="font-family: HelveticaNeue;"><br class="" style="font-family: HelveticaNeue;"><span style="font-family: HelveticaNeue;" class="">[3] [RFC] Add IR level interprocedural outliner for code size. (</span><a href="http://lists.llvm.org/pipermail/llvm-dev/2017-July/115666.html" class="" style="font-family: HelveticaNeue;">http://lists.llvm.org/pipermail/llvm-dev/2017-July/115666.html</a><span style="font-family: HelveticaNeue;" class="">)</span><br class="" style="font-family: HelveticaNeue;"><br class="" style="font-family: HelveticaNeue;"><span style="font-family: HelveticaNeue;" class="">[4] [RFC] PT.2 Add IR level interprocedural outliner for code size. (</span><a href="http://lists.llvm.org/pipermail/llvm-dev/2017-September/117153.html" class="" style="font-family: HelveticaNeue;">http://lists.llvm.org/pipermail/llvm-dev/2017-September/117153.html</a><span style="font-family: HelveticaNeue;" class="">)</span></div></div></body></html>