migrating out-of-source passes to new PassManager?

I’ve got some out-of-source passes which were written before the new PassManager was a thing.

I’m trying to get them to build and run properly, with a minimum of effort. I’m willing to use the Legacy PassManager only, even if that’s a crutch that will eventually go away.

Unfortunately I’m hitting some speed-bumps:

  • I can’t find any documentation giving an overview of how the new PassManager is supposed to be used. This tutorial seems out of date.

  • I’ve looked at how some other passes were ported to the new PassManager, for example: here. However, it’s not really clear how closely they match my situation:

  • They’re in-source, but my passes are out-of-source.

  • They seem to cater to both the new and legacy PassManagers. It’s not clear if a Pass needs to interact with both of those pass managers if the only goal is to use the legacy one.

  • I’m getting failed asserts from LLVM when using AAResultsWrapperPass, but I can’t figure out what I’m doing wrong:

Assertion `ResultPass && "getAnalysis*() called on an analysis that was not " “‘required’ by pass!”’ failed.

​(Bear in mind that this code worked fine with LLVM 3.7. All of the old “AU.addRequired<…>()” calls are still there, although I’ve changed the AA-provider to “AAResultsWrapperPass”.)

Can anyone suggest good sources of info for what I’m trying to do?