1 //===- AliasAnalysisEvaluator.h - Alias Analysis Accuracy Evaluator -------===//
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
7 //===----------------------------------------------------------------------===//
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.
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.
19 /// This is inspired and adapted from code by: Naveen Neelakantam, Francesco
20 /// Spadini, and Wojciech Stryjewski.
22 //===----------------------------------------------------------------------===//
24 #ifndef LLVM_ANALYSIS_ALIASANALYSISEVALUATOR_H
25 #define LLVM_ANALYSIS_ALIASANALYSISEVALUATOR_H
27 #include "llvm/IR/Function.h"
28 #include "llvm/IR/PassManager.h"
33 class AAEvaluator
: public PassInfoMixin
<AAEvaluator
> {
34 int64_t FunctionCount
;
35 int64_t NoAliasCount
, MayAliasCount
, PartialAliasCount
, MustAliasCount
;
36 int64_t NoModRefCount
, ModCount
, RefCount
, ModRefCount
;
37 int64_t MustCount
, MustRefCount
, MustModCount
, MustModRefCount
;
41 : FunctionCount(), NoAliasCount(), MayAliasCount(), PartialAliasCount(),
42 MustAliasCount(), NoModRefCount(), ModCount(), RefCount(),
43 ModRefCount(), MustCount(), MustRefCount(), MustModCount(),
45 AAEvaluator(AAEvaluator
&&Arg
)
46 : FunctionCount(Arg
.FunctionCount
), NoAliasCount(Arg
.NoAliasCount
),
47 MayAliasCount(Arg
.MayAliasCount
),
48 PartialAliasCount(Arg
.PartialAliasCount
),
49 MustAliasCount(Arg
.MustAliasCount
), NoModRefCount(Arg
.NoModRefCount
),
50 ModCount(Arg
.ModCount
), RefCount(Arg
.RefCount
),
51 ModRefCount(Arg
.ModRefCount
), MustCount(Arg
.MustCount
),
52 MustRefCount(Arg
.MustRefCount
), MustModCount(Arg
.MustModCount
),
53 MustModRefCount(Arg
.MustModRefCount
) {
54 Arg
.FunctionCount
= 0;
58 /// Run the pass over the function.
59 PreservedAnalyses
run(Function
&F
, FunctionAnalysisManager
&AM
);
62 // Allow the legacy pass to run this using an internal API.
63 friend class AAEvalLegacyPass
;
65 void runInternal(Function
&F
, AAResults
&AA
);
68 /// Create a wrapper of the above for the legacy pass manager.
69 FunctionPass
*createAAEvalPass();