LLVM  6.0.0svn
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 //
10 /// \file
11 /// This is the interface for a metadata-based TBAA. See the source file for
12 /// details on the algorithm.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_ANALYSIS_TYPEBASEDALIASANALYSIS_H
17 #define LLVM_ANALYSIS_TYPEBASEDALIASANALYSIS_H
18 
20 #include "llvm/IR/CallSite.h"
21 #include "llvm/IR/PassManager.h"
22 #include "llvm/Pass.h"
23 #include <memory>
24 
25 namespace llvm {
26 
27 class Function;
28 class MDNode;
29 class MemoryLocation;
30 
31 /// A simple AA result that uses TBAA metadata to answer queries.
32 class TypeBasedAAResult : public AAResultBase<TypeBasedAAResult> {
34 
35 public:
36  /// Handle invalidation events from the new pass manager.
37  ///
38  /// By definition, this result is stateless and so remains valid.
41  return false;
42  }
43 
44  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB);
45  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal);
50 
51 private:
52  bool Aliases(const MDNode *A, const MDNode *B) const;
53  bool PathAliases(const MDNode *A, const MDNode *B) const;
54 };
55 
56 /// Analysis pass providing a never-invalidated alias analysis result.
57 class TypeBasedAA : public AnalysisInfoMixin<TypeBasedAA> {
59 
60  static AnalysisKey Key;
61 
62 public:
64 
66 };
67 
68 /// Legacy wrapper pass to provide the TypeBasedAAResult object.
70  std::unique_ptr<TypeBasedAAResult> Result;
71 
72 public:
73  static char ID;
74 
76 
77  TypeBasedAAResult &getResult() { return *Result; }
78  const TypeBasedAAResult &getResult() const { return *Result; }
79 
80  bool doInitialization(Module &M) override;
81  bool doFinalization(Module &M) override;
82  void getAnalysisUsage(AnalysisUsage &AU) const override;
83 };
84 
85 //===--------------------------------------------------------------------===//
86 //
87 // createTypeBasedAAWrapperPass - This pass implements metadata-based
88 // type-based alias analysis.
89 //
91 
92 } // end namespace llvm
93 
94 #endif // LLVM_ANALYSIS_TYPEBASEDALIASANALYSIS_H
Analysis pass providing a never-invalidated alias analysis result.
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:63
const TypeBasedAAResult & getResult() const
Metadata node.
Definition: Metadata.h:862
F(f)
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
Legacy wrapper pass to provide the TypeBasedAAResult object.
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
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...
Key
PAL metadata keys.
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")
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:153
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:382
AliasResult
The possible results of an alias query.
Definition: AliasAnalysis.h:79
Represent the analysis usage information of a pass.
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:256
Establish a view to a call site for examination.
Definition: CallSite.h:713
ImmutablePass * createTypeBasedAAWrapperPass()
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:559
A container for analyses that lazily runs them and caches their results.
This header defines various interfaces for pass management in LLVM.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:70
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal)