1 //===- TypeBasedAliasAnalysis.h - Type-Based Alias Analysis -----*- 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 is the interface for a metadata-based TBAA. See the source file for
11 /// details on the algorithm.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_ANALYSIS_TYPEBASEDALIASANALYSIS_H
16 #define LLVM_ANALYSIS_TYPEBASEDALIASANALYSIS_H
18 #include "llvm/Analysis/AliasAnalysis.h"
19 #include "llvm/IR/Function.h"
20 #include "llvm/IR/Metadata.h"
21 #include "llvm/Pass.h"
25 /// TypeBasedAliasAnalysis - This is a simple alias analysis
26 /// implementation that uses TypeBased to answer queries.
27 class TypeBasedAliasAnalysis : public ImmutablePass, public AliasAnalysis {
29 static char ID; // Class identification, replacement for typeinfo
30 TypeBasedAliasAnalysis() : ImmutablePass(ID) {
31 initializeTypeBasedAliasAnalysisPass(*PassRegistry::getPassRegistry());
34 bool doInitialization(Module &M) override;
36 /// getAdjustedAnalysisPointer - This method is used when a pass implements
37 /// an analysis interface through multiple inheritance. If needed, it
38 /// should override this to adjust the this pointer as needed for the
39 /// specified pass info.
40 void *getAdjustedAnalysisPointer(const void *PI) override {
41 if (PI == &AliasAnalysis::ID)
42 return (AliasAnalysis *)this;
46 bool Aliases(const MDNode *A, const MDNode *B) const;
47 bool PathAliases(const MDNode *A, const MDNode *B) const;
50 void getAnalysisUsage(AnalysisUsage &AU) const override;
51 AliasResult alias(const MemoryLocation &LocA,
52 const MemoryLocation &LocB) override;
53 bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal) override;
54 FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS) override;
55 FunctionModRefBehavior getModRefBehavior(const Function *F) override;
56 ModRefInfo getModRefInfo(ImmutableCallSite CS,
57 const MemoryLocation &Loc) override;
58 ModRefInfo getModRefInfo(ImmutableCallSite CS1,
59 ImmutableCallSite CS2) override;
62 //===--------------------------------------------------------------------===//
64 // createTypeBasedAliasAnalysisPass - This pass implements metadata-based
65 // type-based alias analysis.
67 ImmutablePass *createTypeBasedAliasAnalysisPass();