LLVM  6.0.0svn
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_LIB_TARGET_AMDGPU_AMDGPUALIASANALYSIS_H
14 #define LLVM_LIB_TARGET_AMDGPU_AMDGPUALIASANALYSIS_H
15 
16 #include "AMDGPU.h"
17 #include "llvm/ADT/Triple.h"
19 #include "llvm/IR/Function.h"
20 #include "llvm/IR/Module.h"
21 #include "llvm/Pass.h"
22 #include <algorithm>
23 #include <memory>
24 
25 namespace llvm {
26 
27 class DataLayout;
28 class MDNode;
29 class MemoryLocation;
30 
31 /// A simple AA result that uses TBAA metadata to answer queries.
32 class AMDGPUAAResult : public AAResultBase<AMDGPUAAResult> {
34 
35  const DataLayout &DL;
36  AMDGPUAS AS;
37 
38 public:
39  explicit AMDGPUAAResult(const DataLayout &DL, Triple T) : AAResultBase(),
40  DL(DL), AS(AMDGPU::getAMDGPUAS(T)), ASAliasRules(AS, T.getArch()) {}
42  : AAResultBase(std::move(Arg)), DL(Arg.DL), AS(Arg.AS),
43  ASAliasRules(Arg.ASAliasRules){}
44 
45  /// Handle invalidation events from the new pass manager.
46  ///
47  /// By definition, this result is stateless and so remains valid.
48  bool invalidate(Function &, const PreservedAnalyses &) { return false; }
49 
50  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB);
51  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal);
52 
53 private:
54  bool Aliases(const MDNode *A, const MDNode *B) const;
55  bool PathAliases(const MDNode *A, const MDNode *B) const;
56 
57  class ASAliasRulesTy {
58  public:
59  ASAliasRulesTy(AMDGPUAS AS_, Triple::ArchType Arch_);
60 
61  AliasResult getAliasResult(unsigned AS1, unsigned AS2) const;
62 
63  private:
64  Triple::ArchType Arch;
65  AMDGPUAS AS;
66  const AliasResult (*ASAliasRules)[6][6];
67  } ASAliasRules;
68 };
69 
70 /// Analysis pass providing a never-invalidated alias analysis result.
71 class AMDGPUAA : public AnalysisInfoMixin<AMDGPUAA> {
73 
74  static char PassID;
75 
76 public:
78 
82  }
83 };
84 
85 /// Legacy wrapper pass to provide the AMDGPUAAResult object.
87  std::unique_ptr<AMDGPUAAResult> Result;
88 
89 public:
90  static char ID;
91 
94  }
95 
96  AMDGPUAAResult &getResult() { return *Result; }
97  const AMDGPUAAResult &getResult() const { return *Result; }
98 
99  bool doInitialization(Module &M) override {
100  Result.reset(new AMDGPUAAResult(M.getDataLayout(),
101  Triple(M.getTargetTriple())));
102  return false;
103  }
104 
105  bool doFinalization(Module &M) override {
106  Result.reset();
107  return false;
108  }
109 
110  void getAnalysisUsage(AnalysisUsage &AU) const override;
111 };
112 
113 } // end namespace llvm
114 
115 #endif // LLVM_LIB_TARGET_AMDGPU_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
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
Definition: Module.h:233
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
AMDGPUAAResult(const DataLayout &DL, Triple T)
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
AMDGPUAAResult(AMDGPUAAResult &&Arg)
AMDGPUAS getAMDGPUAS(const Module &M)
const AMDGPUAAResult & getResult() const
Metadata node.
Definition: Metadata.h:862
F(f)
void initializeAMDGPUAAWrapperPassPass(PassRegistry &)
AMDGPUAAResult & getResult()
bool invalidate(Function &, const PreservedAnalyses &)
Handle invalidation events from the new pass manager.
Definition: BitVector.h:920
AMDGPUAAResult run(Function &F, AnalysisManager< Function > &AM)
const DataLayout & getDataLayout() const
Get the data layout for the module&#39;s target platform.
Definition: Module.cpp:361
OpenCL uses address spaces to differentiate between various memory regions on the hardware...
Definition: AMDGPU.h:214
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
A CRTP-driven "mixin" base class to help implement the function alias analysis results concept...
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.
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:256
Module.h This file contains the declarations for the Module class.
amdgpu Simplify well known AMD library false Value Value * Arg
bool doFinalization(Module &M) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
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:556
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal)
A container for analyses that lazily runs them and caches their results.