LLVM  10.0.0svn
TypeBasedAliasAnalysis.h
Go to the documentation of this file.
1 //===- TypeBasedAliasAnalysis.h - Type-Based Alias Analysis -----*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
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/InstrTypes.h"
20 #include "llvm/IR/PassManager.h"
21 #include "llvm/Pass.h"
22 #include <memory>
23 
24 namespace llvm {
25 
26 class Function;
27 class MDNode;
28 class MemoryLocation;
29 
30 /// A simple AA result that uses TBAA metadata to answer queries.
31 class TypeBasedAAResult : public AAResultBase<TypeBasedAAResult> {
33 
34 public:
35  /// Handle invalidation events from the new pass manager.
36  ///
37  /// By definition, this result is stateless and so remains valid.
39  FunctionAnalysisManager::Invalidator &) {
40  return false;
41  }
42 
43  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
44  AAQueryInfo &AAQI);
45  bool pointsToConstantMemory(const MemoryLocation &Loc, AAQueryInfo &AAQI,
46  bool OrLocal);
49  ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc,
50  AAQueryInfo &AAQI);
51  ModRefInfo getModRefInfo(const CallBase *Call1, const CallBase *Call2,
52  AAQueryInfo &AAQI);
53 
54 private:
55  bool Aliases(const MDNode *A, const MDNode *B) const;
56  bool PathAliases(const MDNode *A, const MDNode *B) const;
57 };
58 
59 /// Analysis pass providing a never-invalidated alias analysis result.
60 class TypeBasedAA : public AnalysisInfoMixin<TypeBasedAA> {
62 
63  static AnalysisKey Key;
64 
65 public:
67 
69 };
70 
71 /// Legacy wrapper pass to provide the TypeBasedAAResult object.
73  std::unique_ptr<TypeBasedAAResult> Result;
74 
75 public:
76  static char ID;
77 
79 
80  TypeBasedAAResult &getResult() { return *Result; }
81  const TypeBasedAAResult &getResult() const { return *Result; }
82 
83  bool doInitialization(Module &M) override;
84  bool doFinalization(Module &M) override;
85  void getAnalysisUsage(AnalysisUsage &AU) const override;
86 };
87 
88 //===--------------------------------------------------------------------===//
89 //
90 // createTypeBasedAAWrapperPass - This pass implements metadata-based
91 // type-based alias analysis.
92 //
94 
95 } // end namespace llvm
96 
97 #endif // LLVM_ANALYSIS_TYPEBASEDALIASANALYSIS_H
Analysis pass providing a never-invalidated alias analysis result.
This class represents lattice values for constants.
Definition: AllocatorList.h:23
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:65
const TypeBasedAAResult & getResult() const
This class stores info we want to provide to or retain within an alias query.
Metadata node.
Definition: Metadata.h:863
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1100
F(f)
Legacy wrapper pass to provide the TypeBasedAAResult object.
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB, AAQueryInfo &AAQI)
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.
bool pointsToConstantMemory(const MemoryLocation &Loc, AAQueryInfo &AAQI, bool OrLocal)
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:153
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:389
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:255
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc, AAQueryInfo &AAQI)
ImmutablePass * createTypeBasedAAWrapperPass()
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
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