[llvm-dev] [RFC] Turn the MachineOutliner on by default in AArch64 under -Oz

Jessica Paquette via llvm-dev llvm-dev at lists.llvm.org
Fri Apr 20 19:06:45 PDT 2018

Hi all,

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.

For a detailed description of the MachineOutliner, see the original RFC. [2].

We've observed, comparing -Oz to -Oz + outlining on the latest trunk compiler,

* A geomean ~4.4% text size reduction of the CTMark tests (min = 0.3% on tramp3d-v4, max = 15.4% on kc)

* A geomean compile-time overhead of ~1.1% (min = 0.2% on 7zip, max = 2.2% on sqlite3)

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.

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.

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.

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.

The second patch teaches llc to handle -Oz and -Os.

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.

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.

Thanks for taking the time to read this!

*** Patches ***

1. Teaching the backend about -Oz/-Os: https://reviews.llvm.org/D45914 <https://reviews.llvm.org/D45914>
2. Teach llc about -Oz/-Os: https://reviews.llvm.org/D45915 <https://reviews.llvm.org/D45915>
3. Teaching the target about the outliner and enabling it by default under AArch64: https://reviews.llvm.org/D45916 <https://reviews.llvm.org/D45916>
4. Teaching clang to pass -Oz/-Os down to the backend: https://reviews.llvm.org/D45917 <https://reviews.llvm.org/D45917>

*** References ***
[1] Reducing Code Size Using Outlining (https://www.youtube.com/watch?v=yorld-WSOeU <https://www.youtube.com/watch?v=yorld-WSOeU>)

[2] Original RFC (http://lists.llvm.org/pipermail/llvm-dev/2016-August/104170.html <http://lists.llvm.org/pipermail/llvm-dev/2016-August/104170.html>)

[3] [RFC] Add IR level interprocedural outliner for code size. (http://lists.llvm.org/pipermail/llvm-dev/2017-July/115666.html <http://lists.llvm.org/pipermail/llvm-dev/2017-July/115666.html>)

[4] [RFC] PT.2 Add IR level interprocedural outliner for code size. (http://lists.llvm.org/pipermail/llvm-dev/2017-September/117153.html <http://lists.llvm.org/pipermail/llvm-dev/2017-September/117153.html>)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180420/2d55c87e/attachment-0001.html>

More information about the llvm-dev mailing list