Ren Kunpeng via llvm-dev
2021-Jan-26 08:27 UTC
[llvm-dev] 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<AAResultsWrapperPass>().getAAResults(); for (auto &B : F) { for (auto &I : B) { if (auto *call = dyn_cast<CallInst>(&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<https://llvm.org/docs/AliasAnalysis.html#available-aliasanalysis-implementations>, 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<BasicAAWrapperPass>(); AU.addRequiredTransitive<TargetLibraryInfoWrapperPass>(); // 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<ScopedNoAliasAAWrapperPass>(); AU.addUsedIfAvailable<TypeBasedAAWrapperPass>(); AU.addUsedIfAvailable<objcarc::ObjCARCAAWrapperPass>(); AU.addUsedIfAvailable<GlobalsAAWrapperPass>(); AU.addUsedIfAvailable<SCEVAAWrapperPass>(); AU.addUsedIfAvailable<CFLAndersAAWrapperPass>(); AU.addUsedIfAvailable<CFLSteensAAWrapperPass>(); AU.addUsedIfAvailable<ExternalAAWrapperPass>(); } 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210126/6d31d711/attachment-0001.html>