[llvm-dev] How can I call AAResults::getModRefInfo in module pass
Xu Mingjie via llvm-dev
llvm-dev at lists.llvm.org
Thu May 9 18:55:48 PDT 2019
Hi,
I' m writing a module pass with LLVM 7.0.0.
I want to use AAResults::getModRefInfo(const Instruction *I, const Optional<MemoryLocation> &OptLoc) to check if somes instructions may write the specified memory location in my module pass.
So in getAnalyisisUsage function of my pass I have:
AU.addRequired<llvm::AAResultsWrapperPass>();
AU.addRequired<llvm::DominatorTreeWrapperPass>();
AU.addRequired<llvm::TargetLibraryInfoWrapperPass>();
And I get the AAResults by
AAResults& AA = getAnalysis<AAResultsWrapperPass>(*I->getFunction()).getAAResults();
In the main function I define a legacy::PassManager, and I do this
PassRegistry &Registry = *PassRegistry::getPassRegistry();
initializeCore(Registry);
initializeScalarOpts(Registry);
initializeIPO(Registry);
initializeAnalysis(Registry);
initializeTransformUtils(Registry);
initializeInstCombine(Registry);
initializeInstrumentation(Registry);
initializeTarget(Registry);
Then I call
Passes.add(new MyModulePass());
Passes.run(M);
However I get a segmentation fault when AAResults::getModRefInfo() encounters a StoreInst.
Could you please tell me if there is something that I’m doing wrong?
Thanks.
More information about the llvm-dev
mailing list