Line data Source code
1 : //===- AliasAnalysisEvaluator.h - Alias Analysis Accuracy Evaluator -------===//
2 : //
3 : // The LLVM Compiler Infrastructure
4 : //
5 : // This file is distributed under the University of Illinois Open Source
6 : // License. See LICENSE.TXT for details.
7 : //
8 : //===----------------------------------------------------------------------===//
9 : /// \file
10 : ///
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.
15 : ///
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.
19 : ///
20 : /// This is inspired and adapted from code by: Naveen Neelakantam, Francesco
21 : /// Spadini, and Wojciech Stryjewski.
22 : ///
23 : //===----------------------------------------------------------------------===//
24 :
25 : #ifndef LLVM_ANALYSIS_ALIASANALYSISEVALUATOR_H
26 : #define LLVM_ANALYSIS_ALIASANALYSISEVALUATOR_H
27 :
28 : #include "llvm/IR/Function.h"
29 : #include "llvm/IR/PassManager.h"
30 :
31 : namespace llvm {
32 : class AAResults;
33 :
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;
39 :
40 : public:
41 : AAEvaluator()
42 153 : : FunctionCount(), NoAliasCount(), MayAliasCount(), PartialAliasCount(),
43 : MustAliasCount(), NoModRefCount(), ModCount(), RefCount(),
44 : ModRefCount(), MustCount(), MustRefCount(), MustModCount(),
45 153 : MustModRefCount() {}
46 : AAEvaluator(AAEvaluator &&Arg)
47 180 : : FunctionCount(Arg.FunctionCount), NoAliasCount(Arg.NoAliasCount),
48 90 : MayAliasCount(Arg.MayAliasCount),
49 90 : PartialAliasCount(Arg.PartialAliasCount),
50 180 : MustAliasCount(Arg.MustAliasCount), NoModRefCount(Arg.NoModRefCount),
51 180 : ModCount(Arg.ModCount), RefCount(Arg.RefCount),
52 180 : ModRefCount(Arg.ModRefCount), MustCount(Arg.MustCount),
53 180 : MustRefCount(Arg.MustRefCount), MustModCount(Arg.MustModCount),
54 1080 : MustModRefCount(Arg.MustModRefCount) {
55 45 : Arg.FunctionCount = 0;
56 : }
57 : ~AAEvaluator();
58 :
59 : /// Run the pass over the function.
60 : PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
61 :
62 : private:
63 : // Allow the legacy pass to run this using an internal API.
64 : friend class AAEvalLegacyPass;
65 :
66 : void runInternal(Function &F, AAResults &AA);
67 : };
68 :
69 : /// Create a wrapper of the above for the legacy pass manager.
70 : FunctionPass *createAAEvalPass();
71 :
72 : }
73 :
74 : #endif
|