1 | //===- AliasAnalysisEvaluator.h - Alias Analysis Accuracy Evaluator -------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | /// \file |
9 | /// |
10 | /// This file implements a simple N^2 alias analysis accuracy evaluator. The |
11 | /// analysis result is a set of statistics of how many times the AA |
12 | /// infrastructure provides each kind of alias result and mod/ref result when |
13 | /// queried with all pairs of pointers in the function. |
14 | /// |
15 | /// It can be used to evaluate a change in an alias analysis implementation, |
16 | /// algorithm, or the AA pipeline infrastructure itself. It acts like a stable |
17 | /// and easily tested consumer of all AA information exposed. |
18 | /// |
19 | /// This is inspired and adapted from code by: Naveen Neelakantam, Francesco |
20 | /// Spadini, and Wojciech Stryjewski. |
21 | /// |
22 | //===----------------------------------------------------------------------===// |
23 | |
24 | #ifndef LLVM_ANALYSIS_ALIASANALYSISEVALUATOR_H |
25 | #define LLVM_ANALYSIS_ALIASANALYSISEVALUATOR_H |
26 | |
27 | #include "llvm/IR/PassManager.h" |
28 | |
29 | namespace llvm { |
30 | class AAResults; |
31 | class Function; |
32 | |
33 | class AAEvaluator : public PassInfoMixin<AAEvaluator> { |
34 | int64_t FunctionCount = 0; |
35 | int64_t NoAliasCount = 0, MayAliasCount = 0, PartialAliasCount = 0; |
36 | int64_t MustAliasCount = 0; |
37 | int64_t NoModRefCount = 0, ModCount = 0, RefCount = 0, ModRefCount = 0; |
38 | |
39 | public: |
40 | AAEvaluator() = default; |
41 | AAEvaluator(AAEvaluator &&Arg) |
42 | : FunctionCount(Arg.FunctionCount), NoAliasCount(Arg.NoAliasCount), |
43 | MayAliasCount(Arg.MayAliasCount), |
44 | PartialAliasCount(Arg.PartialAliasCount), |
45 | MustAliasCount(Arg.MustAliasCount), NoModRefCount(Arg.NoModRefCount), |
46 | ModCount(Arg.ModCount), RefCount(Arg.RefCount), |
47 | ModRefCount(Arg.ModRefCount) { |
48 | Arg.FunctionCount = 0; |
49 | } |
50 | ~AAEvaluator(); |
51 | |
52 | /// Run the pass over the function. |
53 | PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); |
54 | |
55 | private: |
56 | void runInternal(Function &F, AAResults &AA); |
57 | }; |
58 | } |
59 | |
60 | #endif |
61 | |