LLVM  5.0.0
AMDGPUAliasAnalysis.h
Go to the documentation of this file.
1 //===- AMDGPUAliasAnalysis ---------------------------------------*- 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 AMGPU address space based alias analysis pass.
11 //===----------------------------------------------------------------------===//
12 
13 #ifndef LLVM_ANALYSIS_AMDGPUALIASANALYSIS_H
14 #define LLVM_ANALYSIS_AMDGPUALIASANALYSIS_H
15 
16 #include "AMDGPU.h"
18 #include "llvm/IR/Function.h"
19 #include "llvm/IR/Module.h"
20 #include "llvm/Pass.h"
21 
22 namespace llvm {
23 
24 /// A simple AA result that uses TBAA metadata to answer queries.
25 class AMDGPUAAResult : public AAResultBase<AMDGPUAAResult> {
27 
28  const DataLayout &DL;
29  AMDGPUAS AS;
30 
31 public:
32  explicit AMDGPUAAResult(const DataLayout &DL, Triple T) : AAResultBase(),
33  DL(DL), AS(AMDGPU::getAMDGPUAS(T)), ASAliasRules(AS, T.getArch()) {}
35  : AAResultBase(std::move(Arg)), DL(Arg.DL), AS(Arg.AS),
36  ASAliasRules(Arg.ASAliasRules){}
37 
38  /// Handle invalidation events from the new pass manager.
39  ///
40  /// By definition, this result is stateless and so remains valid.
41  bool invalidate(Function &, const PreservedAnalyses &) { return false; }
42 
43  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB);
44  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal);
45 
46 private:
47  bool Aliases(const MDNode *A, const MDNode *B) const;
48  bool PathAliases(const MDNode *A, const MDNode *B) const;
49 
50  class ASAliasRulesTy {
51  public:
52  ASAliasRulesTy(AMDGPUAS AS_, Triple::ArchType Arch_);
53  AliasResult getAliasResult(unsigned AS1, unsigned AS2) const;
54  private:
55  Triple::ArchType Arch;
56  AMDGPUAS AS;
57  const AliasResult (*ASAliasRules)[6][6];
58  } ASAliasRules;
59 };
60 
61 /// Analysis pass providing a never-invalidated alias analysis result.
62 class AMDGPUAA : public AnalysisInfoMixin<AMDGPUAA> {
64  static char PassID;
65 
66 public:
68 
72  }
73 };
74 
75 /// Legacy wrapper pass to provide the AMDGPUAAResult object.
77  std::unique_ptr<AMDGPUAAResult> Result;
78 
79 public:
80  static char ID;
81 
84  }
85 
86  AMDGPUAAResult &getResult() { return *Result; }
87  const AMDGPUAAResult &getResult() const { return *Result; }
88 
89  bool doInitialization(Module &M) override {
90  Result.reset(new AMDGPUAAResult(M.getDataLayout(),
91  Triple(M.getTargetTriple())));
92  return false;
93  }
94  bool doFinalization(Module &M) override {
95  Result.reset();
96  return false;
97  }
98  void getAnalysisUsage(AnalysisUsage &AU) const override;
99 };
100 
101 }
102 #endif // LLVM_ANALYSIS_AMDGPUALIASANALYSIS_H
bool doInitialization(Module &M) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:109
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
AMDGPUAAResult(const DataLayout &DL, Triple T)
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:63
AMDGPUAAResult(AMDGPUAAResult &&Arg)
AMDGPUAS getAMDGPUAS(const Module &M)
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Metadata node.
Definition: Metadata.h:862
void initializeAMDGPUAAWrapperPassPass(PassRegistry &)
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
Definition: Module.h:233
AMDGPUAAResult & getResult()
bool invalidate(Function &, const PreservedAnalyses &)
Handle invalidation events from the new pass manager.
AMDGPUAAResult run(Function &F, AnalysisManager< Function > &AM)
OpenCL uses address spaces to differentiate between various memory regions on the hardware...
Definition: AMDGPU.h:164
AMDGPUAAResult Result
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
A CRTP-driven "mixin" base class to help implement the function alias analysis results concept...
#define F(x, y, z)
Definition: MD5.cpp:55
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:153
const AMDGPUAAResult & getResult() const
#define A
Definition: LargeTest.cpp:12
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:73
Represent the analysis usage information of a pass.
Legacy wrapper pass to provide the AMDGPUAAResult object.
Analysis pass providing a never-invalidated alias analysis result.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
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
#define B
Definition: LargeTest.cpp:24
Module.h This file contains the declarations for the Module class.
bool doFinalization(Module &M) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.cpp:361
A simple AA result that uses TBAA metadata to answer queries.
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:545
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal)
A container for analyses that lazily runs them and caches their results.