Author: Nikita Popov Date: 2020-12-05T11:09:15+01:00 New Revision: f8afba5f7a25a69c12191d979d78d40fa6e5b684
URL: https://github.com/llvm/llvm-project/commit/f8afba5f7a25a69c12191d979d78d40fa6e5b684 DIFF: https://github.com/llvm/llvm-project/commit/f8afba5f7a25a69c12191d979d78d40fa6e5b684.diff LOG: [AA] Add statistics for alias results (NFC) Count how many NoAlias/MustAlias/MayAlias we get from top-level queries. Added: Modified: llvm/include/llvm/Analysis/AliasAnalysis.h llvm/lib/Analysis/AliasAnalysis.cpp Removed: ################################################################################ diff --git a/llvm/include/llvm/Analysis/AliasAnalysis.h b/llvm/include/llvm/Analysis/AliasAnalysis.h index 7a4338905129..05c01931766e 100644 --- a/llvm/include/llvm/Analysis/AliasAnalysis.h +++ b/llvm/include/llvm/Analysis/AliasAnalysis.h @@ -814,6 +814,9 @@ class AAResults { std::vector<AnalysisKey *> AADeps; + /// Query depth used to distinguish recursive queries. + unsigned Depth; + friend class BatchAAResults; }; diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp index 3d094a65a5e3..6635e5302e36 100644 --- a/llvm/lib/Analysis/AliasAnalysis.cpp +++ b/llvm/lib/Analysis/AliasAnalysis.cpp @@ -24,6 +24,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/AliasAnalysis.h" +#include "llvm/ADT/Statistic.h" #include "llvm/Analysis/BasicAliasAnalysis.h" #include "llvm/Analysis/CFLAndersAliasAnalysis.h" #include "llvm/Analysis/CFLSteensAliasAnalysis.h" @@ -54,8 +55,14 @@ #include <functional> #include <iterator> +#define DEBUG_TYPE "aa" + using namespace llvm; +STATISTIC(NumNoAlias, "Number of NoAlias results"); +STATISTIC(NumMayAlias, "Number of MayAlias results"); +STATISTIC(NumMustAlias, "Number of MustAlias results"); + /// Allow disabling BasicAA from the AA results. This is particularly useful /// when testing to isolate a single AA implementation. cl::opt<bool> DisableBasicAA("disable-basic-aa", cl::Hidden, cl::init(false)); @@ -109,12 +116,25 @@ AliasResult AAResults::alias(const MemoryLocation &LocA, AliasResult AAResults::alias(const MemoryLocation &LocA, const MemoryLocation &LocB, AAQueryInfo &AAQI) { + AliasResult Result = MayAlias; + + Depth++; for (const auto &AA : AAs) { - auto Result = AA->alias(LocA, LocB, AAQI); + Result = AA->alias(LocA, LocB, AAQI); if (Result != MayAlias) - return Result; + break; + } + Depth--; + + if (Depth == 0) { + if (Result == NoAlias) + ++NumNoAlias; + else if (Result == MustAlias) + ++NumMustAlias; + else + ++NumMayAlias; } - return MayAlias; + return Result; } bool AAResults::pointsToConstantMemory(const MemoryLocation &Loc, _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits