[llvm-dev] optnone/skipping passes in the new pass manager

238 views
Skip to first unread message

Arthur Eubanks via llvm-dev

unread,
Jun 7, 2020, 7:59:43 PM6/7/20
to llvm-dev
Looking through some of the remaining test failures under the new pass manager, I've narrowed down one of the failures in GWPAsan(!) to the fact that the new pass manager doesn't properly skip passes like the old pass manager. For example, when a function is marked optnone, or when using https://llvm.org/docs/OptBisect.html.

Lots of passes (e.g. SROA) will do the following under the legacy pass manager:

  bool runOnFunction(Function &F) override {
    if (skipFunction(F))
      return false;
    // do pass
  }

What's the right way to proceed with this? There are 50-100 calls to skipFunction() in legacy passes. This doesn't even account for other types of IR units, like skipModule(Module&).

I suppose it's possible to manually go in and add in the same check in the new passes, but that seems tedious (and how do you test that at scale? clearly there aren't many tests for it right now since check-llvm passes under the new pass manager). An alternative of skipping passes at the pass manager level would require marking each pass as necessary/optional (I think...).

Robinson, Paul via llvm-dev

unread,
Jun 8, 2020, 10:11:32 AM6/8/20
to Arthur Eubanks, llvm...@lists.llvm.org

When the optnone design was being discussed, Chandler specifically rejected having the pass manager involved in the decision (which was the original proposed design).  Assuming he still feels the same way now, if the existing `skipFunction` calls aren’t being executed under the new pass manager, then each pass that has that call will need to be modified accordingly (added to the NPM path or moved to some common point).  It would be best if the `skipFunction` calls were handled consistently in all passes so that it would become part of the normal pass boilerplate.

 

I suspect any `skipFunction` or opt-bisection tests have been written to force the old pass manager, which is why defaulting to the new pass manager doesn’t fail anywhere.

--paulr

David Blaikie via llvm-dev

unread,
Jun 8, 2020, 1:55:26 PM6/8/20
to Robinson, Paul, Chandler Carruth, llvm...@lists.llvm.org
re: Paul: Sounds about right. (+Chandler just in case he wants to weigh in)

> _______________________________________________
> LLVM Developers mailing list
> llvm...@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

Arthur Eubanks via llvm-dev

unread,
Jun 8, 2020, 5:52:09 PM6/8/20
to Robinson, Paul, llvm...@lists.llvm.org
On Mon, Jun 8, 2020 at 7:11 AM Robinson, Paul <paul.r...@sony.com> wrote:

When the optnone design was being discussed, Chandler specifically rejected having the pass manager involved in the decision (which was the original proposed design).  Assuming he still feels the same way now, if the existing `skipFunction` calls aren’t being executed under the new pass manager, then each pass that has that call will need to be modified accordingly (added to the NPM path or moved to some common point).  It would be best if the `skipFunction` calls were handled consistently in all passes so that it would become part of the normal pass boilerplate.

Makes sense, thanks for the background. I'll see if there's a clean way to make this functionality easy to use in the NPM.

 

I suspect any `skipFunction` or opt-bisection tests have been written to force the old pass manager, which is why defaulting to the new pass manager doesn’t fail anywhere.

I took a closer look at some optnone tests and they use opt instead of clang. opt still defaults to the legacy pass manager regardless of clang's default.

Robinson, Paul via llvm-dev

unread,
Jun 8, 2020, 6:36:57 PM6/8/20
to Arthur Eubanks, llvm...@lists.llvm.org

Maybe you could change the default PM in opt and see what fails?

--paulr

Arthur Eubanks via llvm-dev

unread,
Jun 8, 2020, 7:30:00 PM6/8/20
to Robinson, Paul, llvm...@lists.llvm.org
Hmm it looks like getting NPM to work with opt is non-trivial. Only a small portion of the opt functionality works with NPM :(

Johannes Doerfert via llvm-dev

unread,
Jun 8, 2020, 8:21:36 PM6/8/20
to Arthur Eubanks, Robinson, Paul, llvm...@lists.llvm.org


On 6/8/20 6:29 PM, Arthur Eubanks via llvm-dev wrote:
Hmm it looks like getting NPM to work with opt is non-trivial. Only a small
portion of the opt functionality works with NPM :(

I am very much looking forward to use the NPM by default but this sounds like a problem we need to fix first :(.

You happen to have some "list" of things that are missing?



On Mon, Jun 8, 2020 at 3:36 PM Robinson, Paul <paul.r...@sony.com>
wrote:

Maybe you could change the default PM in opt and see what fails?

--paulr



*From:* Arthur Eubanks <aeub...@google.com>
*Sent:* Monday, June 8, 2020 5:52 PM
*To:* Robinson, Paul <paul.r...@sony.com>
*Cc:* Chandler Carruth <chan...@gmail.com>; llvm...@lists.llvm.org
*Subject:* Re: [llvm-dev] optnone/skipping passes in the new pass manager







On Mon, Jun 8, 2020 at 7:11 AM Robinson, Paul <paul.r...@sony.com>
wrote:

When the optnone design was being discussed, Chandler specifically
rejected having the pass manager involved in the decision (which was the
original proposed design).  Assuming he still feels the same way now, if
the existing `skipFunction` calls aren’t being executed under the new pass
manager, then each pass that has that call will need to be modified
accordingly (added to the NPM path or moved to some common point).  It
would be best if the `skipFunction` calls were handled consistently in all
passes so that it would become part of the normal pass boilerplate.

Makes sense, thanks for the background. I'll see if there's a clean way to
make this functionality easy to use in the NPM.



I suspect any `skipFunction` or opt-bisection tests have been written to
force the old pass manager, which is why defaulting to the new pass manager
doesn’t fail anywhere.

I took a closer look at some optnone tests and they use opt instead of
clang. opt still defaults to the legacy pass manager regardless of clang's
default.

--paulr



*From:* llvm-dev <llvm-dev...@lists.llvm.org> *On Behalf Of *Arthur
Eubanks via llvm-dev
*Sent:* Sunday, June 7, 2020 7:59 PM
*To:* llvm-dev <llvm...@lists.llvm.org>
*Subject:* [llvm-dev] optnone/skipping passes in the new pass manager



Looking through some of the remaining test failures under the new pass
manager, I've narrowed down one of the failures in GWPAsan(!) to the fact
that the new pass manager doesn't properly skip passes like the old pass
manager. For example, when a function is marked optnone, or when using
https://llvm.org/docs/OptBisect.html
<https://urldefense.com/v3/__https:/llvm.org/docs/OptBisect.html__;!!JmoZiZGBv3RvKRSx!t3zrtZFFWm0ifdWgL9SiWSNETodW3pMSJ8m8YWqK139cicFp_U1juO0D90-VinpUWg$>
.



Lots of passes (e.g. SROA) will do the following under the legacy pass
manager:



  bool runOnFunction(Function &F) override {
    if (skipFunction(F))
      return false;

    // do pass

  }



What's the right way to proceed with this? There are 50-100 calls to
skipFunction() in legacy passes. This doesn't even account for other types
of IR units, like skipModule(Module&).



I suppose it's possible to manually go in and add in the same check in the
new passes, but that seems tedious (and how do you test that at scale?
clearly there aren't many tests for it right now since check-llvm passes
under the new pass manager). An alternative of skipping passes at the pass
manager level would require marking each pass as necessary/optional (I
think...).


Arthur Eubanks via llvm-dev

unread,
Jun 8, 2020, 8:50:12 PM6/8/20
to Johannes Doerfert, llvm...@lists.llvm.org
On Mon, Jun 8, 2020 at 5:21 PM Johannes Doerfert <johannes...@gmail.com> wrote:


On 6/8/20 6:29 PM, Arthur Eubanks via llvm-dev wrote:
Hmm it looks like getting NPM to work with opt is non-trivial. Only a small
portion of the opt functionality works with NPM :(

I am very much looking forward to use the NPM by default but this sounds like a problem we need to fix first :(.

I'll look into this some more. 

You happen to have some "list" of things that are missing?

Not really, my process is fairly straightforward, set the ENABLE_EXPERIMENTAL_NEW_PASS_MANAGER CMake flag to TRUE, run check-all, and look at new failures. So far these two issues (skipping passes and opt) are the biggest issues I've stumbled across (and mostly by luck, like I said there were a couple failures in GwpAsan that unearthed this, at least for me). I'm still relatively new so I might be missing some existing list of NPM issues that somebody else more experienced has come up with?

Chen, Yuanfang via llvm-dev

unread,
Jun 8, 2020, 8:56:15 PM6/8/20
to llvm-dev, Arthur Eubanks
I think adding a before-pass callback checking optnone to PassInstrumentation of NPM should suffice for the `skipFunction` alone. However, it is closely related to opt-bisect which makes it more complicated.

This was the previous discussion.
http://lists.llvm.org/pipermail/llvm-dev/2018-September/126477.html


________________________________________
From: llvm-dev <llvm-dev...@lists.llvm.org> on behalf of Arthur Eubanks via llvm-dev <llvm...@lists.llvm.org>
Sent: Sunday, June 7, 2020 4:58 PM
To: llvm-dev
Subject: [llvm-dev] optnone/skipping passes in the new pass manager

Arthur Eubanks via llvm-dev

unread,
Jun 9, 2020, 12:45:17 PM6/9/20
to Chen, Yuanfang, llvm-dev
Thanks for the link to the previous discussion, that's super helpful! I'll have to read it over more closely again.

That does remind me of another item on the NPM TODO list: codegen is still using the legacy pass manager. I don't think it's a blocker as long as things like opt-bisect work with it (as mentioned in the previous discussion).
Reply all
Reply to author
Forward
0 new messages