1 //===- AliasAnalysisCounter.h - Alias Analysis Query Counter ----*- C++ -*-===//
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 //===----------------------------------------------------------------------===//
10 /// This declares an alias analysis which counts and prints queries made
11 /// through it. By inserting this between other AAs you can track when specific
12 /// layers of LLVM's AA get queried.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_ANALYSIS_ALIASANALYSISCOUNTER_H
17 #define LLVM_ANALYSIS_ALIASANALYSISCOUNTER_H
19 #include "llvm/Analysis/AliasAnalysis.h"
20 #include "llvm/IR/Module.h"
21 #include "llvm/Pass.h"
25 class AliasAnalysisCounter : public ModulePass, public AliasAnalysis {
26 unsigned No, May, Partial, Must;
27 unsigned NoMR, JustRef, JustMod, MR;
31 static char ID; // Class identification, replacement for typeinfo
33 AliasAnalysisCounter();
34 ~AliasAnalysisCounter() override;
36 bool runOnModule(Module &M) override;
38 void getAnalysisUsage(AnalysisUsage &AU) const override;
40 /// getAdjustedAnalysisPointer - This method is used when a pass implements
41 /// an analysis interface through multiple inheritance. If needed, it
42 /// should override this to adjust the this pointer as needed for the
43 /// specified pass info.
44 void *getAdjustedAnalysisPointer(AnalysisID PI) override;
46 // Forwarding functions: just delegate to a real AA implementation, counting
47 // the number of responses...
48 AliasResult alias(const MemoryLocation &LocA,
49 const MemoryLocation &LocB) override;
51 using AliasAnalysis::getModRefInfo;
52 ModRefInfo getModRefInfo(ImmutableCallSite CS,
53 const MemoryLocation &Loc) override;
56 //===--------------------------------------------------------------------===//
58 // createAliasAnalysisCounterPass - This pass counts alias queries and how the
59 // alias analysis implementation responds.
61 ModulePass *createAliasAnalysisCounterPass();