RFC: PassManager extensions

Extension points were a great addition to the PassManager
infrastructure. I'm just starting to learn about the new PassManager
and am reading Bekket McClane's great series about it.

For a long time I've written passes and then hacked up
PassManagerBuilder and friends to add it to the pipeline. Then
extensions came along. Now I don't need to hack PassManagerBuilder
directly but I do need to hack the thing that sets up extensions. For
example, opt.cpp has a call to Coroutines helpers so Coroutines can
insert its passes in the pipeline using the extension mechanism. The
Coroutines authors had to modify opt.cpp directly to use their in-tree
pass.

It strikes me that we are very close to having a mechanism to better
encapsulate how a pass gets added to the pipeline. We already have code
in each pass' sources that registers the pass with the PassManager.
What if, during registration, a callback was made to the pass being
registered which would allow the pass to add itself to the pipeline
using the extension mechanism? Then all of the code to add a pass to
the pipeline would be neatly contained in the pass' own sources, without
the need to hack up unrelated code.

I have not begun to implement such a thing, because it may already be in
the works and it's mucking around with a critical piece of
infrastructure at the same time we're trying to move everyone over to
the new version of that infrastructure. Thus, this is just an RFC to
see what, if any, interest or plans there are around something like
this.

                          -David

How is what you're asking for different from llvm::RegisterStandardPasses?

-Eli

"Friedman, Eli via llvm-dev" <llvm-dev@lists.llvm.org> writes:

How is what you're asking for different from llvm::RegisterStandardPasses?

It's not. :slight_smile:

Thanks for the pointer. The "Writing an LLVM Pass" page doesn't mention
it, nor do the other resources I've looked at.

BTW, what's the status of the new PassManager changeover?

                         -David