LLVM  8.0.1
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/InstrTypes.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);
48  ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc);
49  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2);
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.
This class represents lattice values for constants.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
const TypeBasedAAResult & getResult() const
Metadata node.
Definition: Metadata.h:864
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1014
F(f)
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
Legacy wrapper pass to provide the TypeBasedAAResult object.
bool invalidate(Function &, const PreservedAnalyses &, FunctionAnalysisManager::Invalidator &)
Handle invalidation events from the new pass manager.
FunctionModRefBehavior getModRefBehavior(const CallBase *Call)
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.
AliasResult
The possible results of an alias query.
Definition: AliasAnalysis.h:78
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:154
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:383
Represent the analysis usage information of a pass.
A simple AA result that uses TBAA metadata to answer queries.
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
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc)
ImmutablePass * createTypeBasedAAWrapperPass()
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:642
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
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:71
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal)