[llvm-dev] How can I call AAResults::getModRefInfo in module pass
Philip Pfaffe via llvm-dev
llvm-dev at lists.llvm.org
Fri May 10 06:52:34 PDT 2019
Hi,
bottom line, AA in ModulePasses is broken. I'm not completely sure what
causes your particular error, even if it would not crash, you probably
would not get the expected results. The reason is that analysis groups
(like AliasAnalysis) do not work with ad-hoc passes (like what you get when
calling getAnalysis with an argument).
Have you tried your code on llvm 8 or trunk?
All of this should work with the non-legacy PassManager though, so I
suggest trying that out! You might encounter bugs there too, seeing that
you're on llvm 7. So I'd recommend moving to 8 or trunk for that as well!
Cheers,
Philip
On Fri, May 10, 2019 at 3:56 AM Xu Mingjie via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> 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.
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190510/9072d25a/attachment.html>
More information about the llvm-dev
mailing list