forked from OSchip/llvm-project
[AA] Add statistics for alias results (NFC)
Count how many NoAlias/MustAlias/MayAlias we get from top-level queries.
This commit is contained in:
parent
8925d23474
commit
f8afba5f7a
|
@ -814,6 +814,9 @@ private:
|
|||
|
||||
std::vector<AnalysisKey *> AADeps;
|
||||
|
||||
/// Query depth used to distinguish recursive queries.
|
||||
unsigned Depth;
|
||||
|
||||
friend class BatchAAResults;
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
return MayAlias;
|
||||
Depth--;
|
||||
|
||||
if (Depth == 0) {
|
||||
if (Result == NoAlias)
|
||||
++NumNoAlias;
|
||||
else if (Result == MustAlias)
|
||||
++NumMustAlias;
|
||||
else
|
||||
++NumMayAlias;
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
bool AAResults::pointsToConstantMemory(const MemoryLocation &Loc,
|
||||
|
|
Loading…
Reference in New Issue