[llvm-dev] RFC: Switching to the new pass manager by default

Chandler Carruth via llvm-dev llvm-dev at lists.llvm.org
Thu Oct 19 09:18:36 PDT 2017


On Thu, Oct 19, 2017 at 4:50 AM Greg Bedwell <gregbedwell at gmail.com> wrote:

> I just tried putting a relatively recent version of our merge branch
> (r316139 + our local changes) through a small subset of the PS4 testing
> with -fexperimental-new-pass-manager enabled.  In general, most tests
> passed :).  There are a few failures I'd need to look at in more detail
> though.  The most glaring are all our tests related to generating coverage
> info:
>
> $ cat 1.cpp
> void foo(){}
> $ ./build/bin/clang -c -fprofile-instr-generate -fcoverage-mapping 1.cpp
> $ ./build/bin/clang -c -fprofile-instr-generate -fcoverage-mapping 1.cpp
> -fexperimental-new-pass-manager
> instrprof failed to lower an increment
> UNREACHABLE executed at
> /home/greg/public_git/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:5893!
>
> which I'm assuming is the same thing as was reported in
> https://bugs.llvm.org/show_bug.cgi?id=33773 .  This would definitely be a
> prerequisite for us to consider flipping the default.
>

Yeah, this is essentially the same issue as the sanitizers and one of the
remaining things I'm poking forward.


>
>
> There are a few tests looking for specific codegen that are seeing
> something different.  At a glance, it looks like the output from clang's
> -O2 looks roughly similar in some small examples with and without the new
> PM, but clang's -O1 is producing very different output.  Whether this is an
> issue, I can't say for sure (I've not tried benchmarking the -O1s against
> each other yet).  Is this expected?
>

Yeah, I've not really closely tracked the pipeline differences between the
old PM and the new PM at O1. My best guess is that the old PM uses the
always inliner and the new PM uses a full inliner.

If the compile time of O1 is regressing a lot, its easy to try and converge
these.


> It's not an example I can easily share (and also not one I'm easily able
> to verify in its present state on a branch without our local changes to
> make sure they're not responsible somehow), but if it's of interest I can
> see whether I can reduce it to something shareable and raise a bug.
>

FWIW, there are some things that can increase compile time. The thing we've
seen most often is when the inliner suddenly becomes more powerful and it
generates about 2x the amount of total code. Then you see the time in the
code generator go up by 2x. That seems to match your numbers, but
definitely feel free to file a bug if this is problematic with some more
information.


>
>
> If I get a chance, I'll try putting this through some PS4 game codebases
> to see how build time and run time performance compare there, but I'm one
> of the few manning the fort while most of the rest of the team is out
> having a nice time at the Developers' Meeting this week, so I may not get
> that chance for a bit.
>
> Cheers,
> -Greg
>
>
> On 18 October 2017 at 07:50, Chandler Carruth via llvm-dev <
> llvm-dev at lists.llvm.org> wrote:
>
>> Greetings everyone!
>>
>> The new pass manager is getting extremely close to the point where I'm
>> not aware of any significant outstanding work needed, and I'd like to see
>> what else would be needed to enable it by default. Here are the current
>> functionality I'm aware of outstanding:
>>
>> 1) Does not do non-trivial loop unswitching. Majority of this is in
>> https://reviews.llvm.org/D34200 but will need one or two small
>> follow-ups.
>>
>> 2) Currently, sanitizers don't work correctly with it. Thanks to the work
>> of others, the missing infrastructure has been added and I'll send a patch
>> to wire this up this week.
>>
>> 3) Missing support for 'optnone'. I've been working on this, but the
>> existing testing wasn't as thorough as I wanted, so it is going slowly.
>> I've got about 1/4 of this implemented and should have patches this week or
>> next.
>>
>> 4) Missing opt-bisect (or similar) facility. This looks pretty trivial to
>> add, but I've not even started. If anyone is interested in it, go for it.
>> We might even be able to do something simpler using the generic debug
>> counters and get equivalent functionality.
>>
>> ... that's it?
>>
>> Optimization quality / run-time performance:
>> - We've been using it at Google extensively and are very happy with the
>> optimization quality. Benchmarks look *very* good here.
>> - More data from other users would be important.
>> - You can try it out with `-fexperimental-new-pass-manager` to Clang
>>
>> Compile-time performance:
>> - Sometimes *much* better due to cached analyses.
>> - Sometimes worse, typically due to more / different inlining in turn
>> running main pipeline (GVN + InstCombine) more times or over more code.
>> - Overall somewhat a wash, but the increased compile times typically due
>> to the optimizer "trying" harder, so not too concerning on our end.
>> - Again, more feedback from other users good:
>> `-fexperimental-new-pass-manager` to Clang
>>
>> Once the four missing things land, I'll also happily work on collecting
>> some of the basics on the test-suite and CTMark. But I suspect more "in the
>> wild" data would really be useful here given the significance of the change.
>>
>> Thoughts? What else (beyond the four items above and feedback on run-time
>> and compile-time) would folks like to see?
>>
>> Once this happens, I'll also be preparing some batch, mechanical updates
>> to the test suite to primarily use the new pass manager. Also there is lots
>> of documentation updates that will be needed here.
>>
>> -Chandler
>>
>> PS: I'll be sending a note to cfe-dev as a "heads up" about this
>> discussion as in some ways, the default flip is mostly a Clang default
>> flip. But hopefully our doc updates will trigger this being "perceived" as
>> the default for other frontends, and I'll try to reach out to other major
>> frontends as well (Swift and Rust are on my radar, and I've already started
>> talking with Philip Reames about their Falcon JIT).
>>
>> _______________________________________________
>> LLVM Developers mailing list
>> llvm-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171019/f8784e7d/attachment-0001.html>


More information about the llvm-dev mailing list