<div dir="ltr">Hi,<div><br></div><div>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).</div><div><br></div><div>Have you tried your code on llvm 8 or trunk?</div><div><br></div><div>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!</div><div><br></div><div>Cheers,</div><div>Philip</div><div><br><div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, May 10, 2019 at 3:56 AM Xu Mingjie via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I' m writing a module pass with LLVM 7.0.0.<br>
<br>
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.<br>
<br>
<br>
<br>
So in getAnalyisisUsage function of my pass I have:<br>
<br>
AU.addRequired<llvm::AAResultsWrapperPass>();<br>
<br>
AU.addRequired<llvm::DominatorTreeWrapperPass>();<br>
<br>
AU.addRequired<llvm::TargetLibraryInfoWrapperPass>();<br>
<br>
<br>
<br>
And I get the AAResults by<br>
<br>
AAResults& AA = getAnalysis<AAResultsWrapperPass>(*I->getFunction()).getAAResults();<br>
<br>
<br>
<br>
In the main function I define a legacy::PassManager, and I do this<br>
<br>
PassRegistry &Registry = *PassRegistry::getPassRegistry();<br>
<br>
initializeCore(Registry);<br>
<br>
initializeScalarOpts(Registry);<br>
<br>
initializeIPO(Registry);<br>
<br>
initializeAnalysis(Registry);<br>
<br>
initializeTransformUtils(Registry);<br>
<br>
initializeInstCombine(Registry);<br>
<br>
initializeInstrumentation(Registry);<br>
<br>
initializeTarget(Registry);<br>
<br>
<br>
<br>
Then I call<br>
<br>
Passes.add(new MyModulePass());<br>
<br>
Passes.run(M);<br>
<br>
<br>
<br>
However I get a segmentation fault when AAResults::getModRefInfo() encounters a StoreInst.<br>
<br>
Could you please tell me if there is something that I’m doing wrong?<br>
<br>
<br>
<br>
Thanks.<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>