LLVM  14.0.0git
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/PassManager.h"
20 #include "llvm/Pass.h"
21 #include <memory>
22 
23 namespace llvm {
24 
25 class CallBase;
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.
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 };
57 
58 /// Analysis pass providing a never-invalidated alias analysis result.
59 class TypeBasedAA : public AnalysisInfoMixin<TypeBasedAA> {
61 
62  static AnalysisKey Key;
63 
64 public:
66 
68 };
69 
70 /// Legacy wrapper pass to provide the TypeBasedAAResult object.
72  std::unique_ptr<TypeBasedAAResult> Result;
73 
74 public:
75  static char ID;
76 
78 
79  TypeBasedAAResult &getResult() { return *Result; }
80  const TypeBasedAAResult &getResult() const { return *Result; }
81 
82  bool doInitialization(Module &M) override;
83  bool doFinalization(Module &M) override;
84  void getAnalysisUsage(AnalysisUsage &AU) const override;
85 };
86 
87 //===--------------------------------------------------------------------===//
88 //
89 // createTypeBasedAAWrapperPass - This pass implements metadata-based
90 // type-based alias analysis.
91 //
92 ImmutablePass *createTypeBasedAAWrapperPass();
93 
94 } // end namespace llvm
95 
96 #endif // LLVM_ANALYSIS_TYPEBASEDALIASANALYSIS_H
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:155
llvm::TypeBasedAAResult::getModRefInfo
ModRefInfo getModRefInfo(const CallBase *Call, const MemoryLocation &Loc, AAQueryInfo &AAQI)
Definition: TypeBasedAliasAnalysis.cpp:426
llvm
This file implements support for optimizing divisions by a constant.
Definition: AllocatorList.h:23
llvm::TypeBasedAAWrapperPass::doFinalization
bool doFinalization(Module &M) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
Definition: TypeBasedAliasAnalysis.cpp:732
llvm::ImmutablePass
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition: Pass.h:269
llvm::TypeBasedAA::run
TypeBasedAAResult run(Function &F, FunctionAnalysisManager &AM)
Definition: TypeBasedAliasAnalysis.cpp:711
llvm::Function
Definition: Function.h:62
Pass.h
llvm::TypeBasedAAWrapperPass::TypeBasedAAWrapperPass
TypeBasedAAWrapperPass()
Definition: TypeBasedAliasAnalysis.cpp:723
llvm::TypeBasedAAResult
A simple AA result that uses TBAA metadata to answer queries.
Definition: TypeBasedAliasAnalysis.h:31
llvm::AliasResult
The possible results of an alias query.
Definition: AliasAnalysis.h:82
llvm::TypeBasedAAWrapperPass::doInitialization
bool doInitialization(Module &M) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
Definition: TypeBasedAliasAnalysis.cpp:727
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::TypeBasedAA
Analysis pass providing a never-invalidated alias analysis result.
Definition: TypeBasedAliasAnalysis.h:59
AliasAnalysis.h
llvm::AAQueryInfo
This class stores info we want to provide to or retain within an alias query.
Definition: AliasAnalysis.h:459
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::AnalysisManager::Invalidator
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:670
llvm::TypeBasedAAWrapperPass
Legacy wrapper pass to provide the TypeBasedAAResult object.
Definition: TypeBasedAliasAnalysis.h:71
llvm::TypeBasedAAWrapperPass::getResult
TypeBasedAAResult & getResult()
Definition: TypeBasedAliasAnalysis.h:79
llvm::TypeBasedAAWrapperPass::ID
static char ID
Definition: TypeBasedAliasAnalysis.h:75
llvm::TypeBasedAAWrapperPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition: TypeBasedAliasAnalysis.cpp:737
llvm::AnalysisKey
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:72
llvm::TypeBasedAAResult::alias
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB, AAQueryInfo &AAQI)
Definition: TypeBasedAliasAnalysis.cpp:371
llvm::ModRefInfo
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
Definition: AliasAnalysis.h:149
llvm::createTypeBasedAAWrapperPass
ImmutablePass * createTypeBasedAAWrapperPass()
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::MDNode
Metadata node.
Definition: Metadata.h:906
llvm::AnalysisInfoMixin
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:397
llvm::TypeBasedAAResult::getModRefBehavior
FunctionModRefBehavior getModRefBehavior(const CallBase *Call)
Definition: TypeBasedAliasAnalysis.cpp:405
llvm::ReplayInlineScope::Function
@ Function
llvm::FunctionModRefBehavior
FunctionModRefBehavior
Summary of how a function affects memory in the program.
Definition: AliasAnalysis.h:263
PassManager.h
llvm::TypeBasedAAWrapperPass::getResult
const TypeBasedAAResult & getResult() const
Definition: TypeBasedAliasAnalysis.h:80
llvm::TypeBasedAAResult::invalidate
bool invalidate(Function &, const PreservedAnalyses &, FunctionAnalysisManager::Invalidator &)
Handle invalidation events from the new pass manager.
Definition: TypeBasedAliasAnalysis.h:38
llvm::TypeBasedAAResult::pointsToConstantMemory
bool pointsToConstantMemory(const MemoryLocation &Loc, AAQueryInfo &AAQI, bool OrLocal)
Definition: TypeBasedAliasAnalysis.cpp:385
llvm::CallBase
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1161
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
llvm::AAResultBase
A CRTP-driven "mixin" base class to help implement the function alias analysis results concept.
Definition: AliasAnalysis.h:1131
llvm::MemoryLocation
Representation for a specific memory location.
Definition: MemoryLocation.h:209