Using AAResultsWrapperPass in ModulePass

Hi,

Did anyone faced any issues with the recent changes made for AliasAnalysis.
AliasAnalysis interface changed to AAResultsWrapperPass.
Prior was able to use AliasAnalysis in module pass, now facing error while using AAResultsWrapperPass:

ld: /home*/ashutosh/I2DPromo*/llvm/include/llvm/PassAnalysisSupport.h:230: AnalysisType& llvm::Pass::getAnalysisID(llvm::AnalysisID) const [with AnalysisType = llvm::AAResultsWrapperPass; llvm::AnalysisID = const void*]: Assertion `ResultPass && "getAnalysis*() called on an analysis that was not " “‘required’ by pass!”’ failed.
clang: error: unable to execute command: Aborted (core dumped)

AAResultsWrapperPass is a FunctionPass. Is that the reason this can’t be used in ModulePass ?

Looks like I’m missing something, can anyone help to get AliasAnalysis in ModulePass ?

Usage:
class myclass: public ModulePass {
public:
void getAnalysisUsage(AnalysisUsage &AU) const override {
AU.addRequired();
AU.setPreservesAll();
}
}
bool myclass::runOnModule(Module &M) {
AA = &getAnalysis().getAAResults();
}
INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)

Regards,
Ashutosh

Ah, I got it. ‘createLegacyPMAAResults’ can help here.

Regards,

Ashutosh