LLVM  4.0.0
TypeBasedAliasAnalysis.h
Go to the documentation of this file.
1 //===- TypeBasedAliasAnalysis.h - Type-Based Alias Analysis -----*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 /// \file
10 /// This is the interface for a metadata-based TBAA. See the source file for
11 /// details on the algorithm.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_ANALYSIS_TYPEBASEDALIASANALYSIS_H
16 #define LLVM_ANALYSIS_TYPEBASEDALIASANALYSIS_H
17 
19 #include "llvm/IR/Function.h"
20 #include "llvm/IR/Metadata.h"
21 #include "llvm/Pass.h"
22 
23 namespace llvm {
24 
25 /// A simple AA result that uses TBAA metadata to answer queries.
26 class TypeBasedAAResult : public AAResultBase<TypeBasedAAResult> {
28 
29 public:
30  /// Handle invalidation events from the new pass manager.
31  ///
32  /// By definition, this result is stateless and so remains valid.
35  return false;
36  }
37 
38  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB);
39  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal);
44 
45 private:
46  bool Aliases(const MDNode *A, const MDNode *B) const;
47  bool PathAliases(const MDNode *A, const MDNode *B) const;
48 };
49 
50 /// Analysis pass providing a never-invalidated alias analysis result.
51 class TypeBasedAA : public AnalysisInfoMixin<TypeBasedAA> {
53  static AnalysisKey Key;
54 
55 public:
57 
59 };
60 
61 /// Legacy wrapper pass to provide the TypeBasedAAResult object.
63  std::unique_ptr<TypeBasedAAResult> Result;
64 
65 public:
66  static char ID;
67 
69 
70  TypeBasedAAResult &getResult() { return *Result; }
71  const TypeBasedAAResult &getResult() const { return *Result; }
72 
73  bool doInitialization(Module &M) override;
74  bool doFinalization(Module &M) override;
75  void getAnalysisUsage(AnalysisUsage &AU) const override;
76 };
77 
78 //===--------------------------------------------------------------------===//
79 //
80 // createTypeBasedAAWrapperPass - This pass implements metadata-based
81 // type-based alias analysis.
82 //
83 ImmutablePass *createTypeBasedAAWrapperPass();
84 }
85 
86 #endif
Analysis pass providing a never-invalidated alias analysis result.
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:52
This file contains the declarations for metadata subclasses.
Metadata node.
Definition: Metadata.h:830
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
TypeBasedAAResult run(Function &F, FunctionAnalysisManager &AM)
Legacy wrapper pass to provide the TypeBasedAAResult object.
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
Definition: AliasAnalysis.h:94
bool invalidate(Function &, const PreservedAnalyses &, FunctionAnalysisManager::Invalidator &)
Handle invalidation events from the new pass manager.
A CRTP-driven "mixin" base class to help implement the function alias analysis results concept...
#define F(x, y, z)
Definition: MD5.cpp:51
FunctionModRefBehavior
Summary of how a function affects memory in the program.
FunctionModRefBehavior getModRefBehavior(ImmutableCallSite CS)
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
bool doFinalization(Module &M) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:107
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:328
AliasResult
The possible results of an alias query.
Definition: AliasAnalysis.h:73
Represent the analysis usage information of a pass.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
A simple AA result that uses TBAA metadata to answer queries.
ModRefInfo getModRefInfo(ImmutableCallSite CS, const MemoryLocation &Loc)
Representation for a specific memory location.
ImmutablePass class - This class is used to provide information that does not need to be run...
Definition: Pass.h:266
TypeBasedAAResult Result
ImmutableCallSite - establish a view to a call site for examination.
Definition: CallSite.h:665
ImmutablePass * createTypeBasedAAWrapperPass()
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:525
A container for analyses that lazily runs them and caches their results.
const TypeBasedAAResult & getResult() const
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:64
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal)
bool doInitialization(Module &M) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...