addRequired() + getAnalysis() for new / non-legacy pass manager

Hi!

I am trying to extend the native AliasAnalysis of LLVM to use an external analysis pass. Doing this with the legacy pass manager works fine through calling addRequired() in the getAnalysisUsage and getAnalysis() in function runOnFunction(). In the new pass manager, I haven’t found a similar way of doing this. When running opt with -O3, I encounter the following error:

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

Changing to getAnalysisIfAvailable() makes the pass not crash, but then I assume I am not using the external analysis pass to its full extent.

So, the question is as such: in order to use the external analysis pass, do I need to use some form of the same mechanism (addRequired() + getAnalysis()) for the new pass manager, or should it be enough to use it in the legacy using the wrapper pass?

Appreciate any help!

Andreas

Hi Andreas,

in the new PM there is no equivalent for addRequired(). Because it implemented as a caching strategy, Analyses are just ran on demand if they’re not available or have been invalidated.

To get your AA pass into the battle, just add it to the AAManager that goes into your new-PM instance.

The new PM is currently not the default in opt or clang. opt -O3 will thus use the legacy PM. Additionally, as of yet there is no support for plugin passes in the new PM, as there was before (my patch hasn’t made it through review yet).

Best,
Philip

Hi Andreas,

in the new PM there is no equivalent for addRequired().

And perhaps most significantly, you don’t call “getAnalysis” at all in the new PM…

To get your AA pass into the battle, just add it to the AAManager that goes into your new-PM instance.

Yep!

The new PM is currently not the default in opt or clang. opt -O3 will thus use the legacy PM. Additionally, as of yet there is no support for plugin passes in the new PM, as there was before (my patch hasn’t made it through review yet).

I’m so sorry, I have totally lost track of this. Can you ping? We should get this moving.