LLVM  14.0.0git
AliasAnalysisEvaluator.h
Go to the documentation of this file.
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/Function.h"
28 #include "llvm/IR/PassManager.h"
29 
30 namespace llvm {
31 class AAResults;
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  int64_t MustCount = 0, MustRefCount = 0, MustModCount = 0;
39  int64_t MustModRefCount = 0;
40 
41 public:
42  AAEvaluator() = default;
44  : FunctionCount(Arg.FunctionCount), NoAliasCount(Arg.NoAliasCount),
45  MayAliasCount(Arg.MayAliasCount),
46  PartialAliasCount(Arg.PartialAliasCount),
47  MustAliasCount(Arg.MustAliasCount), NoModRefCount(Arg.NoModRefCount),
48  ModCount(Arg.ModCount), RefCount(Arg.RefCount),
49  ModRefCount(Arg.ModRefCount), MustCount(Arg.MustCount),
50  MustRefCount(Arg.MustRefCount), MustModCount(Arg.MustModCount),
51  MustModRefCount(Arg.MustModRefCount) {
52  Arg.FunctionCount = 0;
53  }
54  ~AAEvaluator();
55 
56  /// Run the pass over the function.
58 
59 private:
60  // Allow the legacy pass to run this using an internal API.
61  friend class AAEvalLegacyPass;
62 
63  void runInternal(Function &F, AAResults &AA);
64 };
65 
66 /// Create a wrapper of the above for the legacy pass manager.
68 
69 }
70 
71 #endif
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:155
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::PassInfoMixin
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:374
llvm::Function
Definition: Function.h:62
llvm::AAEvalLegacyPass
Definition: AliasAnalysisEvaluator.cpp:397
F
#define F(x, y, z)
Definition: MD5.cpp:55
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:185
llvm::createAAEvalPass
FunctionPass * createAAEvalPass()
Create a wrapper of the above for the legacy pass manager.
Definition: AliasAnalysisEvaluator.cpp:436
llvm::AAResults
Definition: AliasAnalysis.h:507
llvm::AAEvaluator::AAEvaluator
AAEvaluator()=default
llvm::AAEvaluator::run
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Run the pass over the function.
Definition: AliasAnalysisEvaluator.cpp:92
llvm::AAEvaluator::~AAEvaluator
~AAEvaluator()
Definition: AliasAnalysisEvaluator.cpp:335
Function.h
PassManager.h
llvm::AAEvaluator
Definition: AliasAnalysisEvaluator.h:33
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
llvm::FunctionPass
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:298
llvm::AAEvaluator::AAEvaluator
AAEvaluator(AAEvaluator &&Arg)
Definition: AliasAnalysisEvaluator.h:43