How to get the full alias analysis results of LLVM Alias analysis passes?

Hi all,

I am working on a project about pointer analysis based on LLVM IR, and I not very familar with LLVM Development.
Now, I want to compare the original LLVM alias analysis pass with my tool. I use AAResultsWrapperPass to do this thing, just as below:

virtual bool runOnFunction(Function &F)
{
AliasAnalysis *AA = &getAnalysis().getAAResults();
for (auto &B : F)
{
for (auto &I : B)
{
if (auto *call = dyn_cast(&I))
{
if (call->getCalledFunction()!= NULL)
{
if(call->getNumArgOperands() !=2)
continue;
Value *V1 = call->getArgOperand(0);
Value *V2 = call->getArgOperand(1);
//Get LLVM alias analysi result
AliasResult aares = AA->alias(V1, V2);

I have doubt that wether the AliasResults are analysied by all LLVM alias pass, such as -basic-aa, -globalsmodref-aa, -stens-aa. I find the implement of AAResultsWrapperPass contains some code like below:

void AAResultsWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesAll();
AU.addRequiredTransitive();
AU.addRequiredTransitive();

// We also need to mark all the alias analysis passes we will potentially
// probe in runOnFunction as used here to ensure the legacy pass manager
// preserves them. This hard coding of lists of alias analyses is specific to
// the legacy pass manager.
AU.addUsedIfAvailable();
AU.addUsedIfAvailable();
AU.addUsedIfAvailableobjcarc::ObjCARCAAWrapperPass();
AU.addUsedIfAvailable();
AU.addUsedIfAvailable();
AU.addUsedIfAvailable();
AU.addUsedIfAvailable();
AU.addUsedIfAvailable();
}

  • |

Does it mean the AAResultsWrapperPass contains all the alias analysis pass result?
By the way, is there a better implement to get the LLVM alias analysis result. Thank you for telling me about that.

Thanks for you reading. Wishing you have a good day.

Regards,
Kunpeng