1 //===- AliasAnalysisEvaluator.h - Alias Analysis Accuracy Evaluator -------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// This file implements a simple N^2 alias analysis accuracy evaluator. The
12 /// analysis result is a set of statistics of how many times the AA
13 /// infrastructure provides each kind of alias result and mod/ref result when
14 /// queried with all pairs of pointers in the function.
16 /// It can be used to evaluate a change in an alias analysis implementation,
17 /// algorithm, or the AA pipeline infrastructure itself. It acts like a stable
18 /// and easily tested consumer of all AA information exposed.
20 /// This is inspired and adapted from code by: Naveen Neelakantam, Francesco
21 /// Spadini, and Wojciech Stryjewski.
23 //===----------------------------------------------------------------------===//
25 #ifndef LLVM_ANALYSIS_ALIASANALYSISEVALUATOR_H
26 #define LLVM_ANALYSIS_ALIASANALYSISEVALUATOR_H
28 #include "llvm/IR/Function.h"
29 #include "llvm/IR/PassManager.h"
34 class AAEvaluator : public PassInfoMixin<AAEvaluator> {
35 int64_t FunctionCount;
36 int64_t NoAliasCount, MayAliasCount, PartialAliasCount, MustAliasCount;
37 int64_t NoModRefCount, ModCount, RefCount, ModRefCount;
38 int64_t MustCount, MustRefCount, MustModCount, MustModRefCount;
42 : FunctionCount(), NoAliasCount(), MayAliasCount(), PartialAliasCount(),
43 MustAliasCount(), NoModRefCount(), ModCount(), RefCount(),
44 ModRefCount(), MustCount(), MustRefCount(), MustModCount(),
46 AAEvaluator(AAEvaluator &&Arg)
47 : FunctionCount(Arg.FunctionCount), NoAliasCount(Arg.NoAliasCount),
48 MayAliasCount(Arg.MayAliasCount),
49 PartialAliasCount(Arg.PartialAliasCount),
50 MustAliasCount(Arg.MustAliasCount), NoModRefCount(Arg.NoModRefCount),
51 ModCount(Arg.ModCount), RefCount(Arg.RefCount),
52 ModRefCount(Arg.ModRefCount), MustCount(Arg.MustCount),
53 MustRefCount(Arg.MustRefCount), MustModCount(Arg.MustModCount),
54 MustModRefCount(Arg.MustModRefCount) {
55 Arg.FunctionCount = 0;
59 /// Run the pass over the function.
60 PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
63 // Allow the legacy pass to run this using an internal API.
64 friend class AAEvalLegacyPass;
66 void runInternal(Function &F, AAResults &AA);
69 /// Create a wrapper of the above for the legacy pass manager.
70 FunctionPass *createAAEvalPass();