LLVM  8.0.1
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 
37 public:
38  explicit AMDGPUAAResult(const DataLayout &DL, Triple T) : AAResultBase(),
39  DL(DL) {}
41  : AAResultBase(std::move(Arg)), DL(Arg.DL) {}
42 
43  /// Handle invalidation events from the new pass manager.
44  ///
45  /// By definition, this result is stateless and so remains valid.
46  bool invalidate(Function &, const PreservedAnalyses &) { return false; }
47 
48  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB);
49  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal);
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 AMDGPUAA : public AnalysisInfoMixin<AMDGPUAA> {
59 
60  static char PassID;
61 
62 public:
64 
68  }
69 };
70 
71 /// Legacy wrapper pass to provide the AMDGPUAAResult object.
73  std::unique_ptr<AMDGPUAAResult> Result;
74 
75 public:
76  static char ID;
77 
80  }
81 
82  AMDGPUAAResult &getResult() { return *Result; }
83  const AMDGPUAAResult &getResult() const { return *Result; }
84 
85  bool doInitialization(Module &M) override {
86  Result.reset(new AMDGPUAAResult(M.getDataLayout(),
87  Triple(M.getTargetTriple())));
88  return false;
89  }
90 
91  bool doFinalization(Module &M) override {
92  Result.reset();
93  return false;
94  }
95 
96  void getAnalysisUsage(AnalysisUsage &AU) const override;
97 };
98 
99 // Wrapper around ExternalAAWrapperPass so that the default constructor gets the
100 // callback.
102 public:
103  static char ID;
104 
106  [](Pass &P, Function &, AAResults &AAR) {
107  if (auto *WrapperPass = P.getAnalysisIfAvailable<AMDGPUAAWrapperPass>())
108  AAR.addAAResult(WrapperPass->getResult());
109  }) {}
110 };
111 
112 } // end namespace llvm
113 
114 #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUALIASANALYSIS_H
Pass interface - Implemented by all &#39;passes&#39;.
Definition: Pass.h:81
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:111
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
Definition: Module.h:240
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
AMDGPUAAResult(const DataLayout &DL, Triple T)
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
AMDGPUAAResult(AMDGPUAAResult &&Arg)
const AMDGPUAAResult & getResult() const
Metadata node.
Definition: Metadata.h:864
F(f)
void initializeAMDGPUAAWrapperPassPass(PassRegistry &)
AMDGPUAAResult & getResult()
bool invalidate(Function &, const PreservedAnalyses &)
Handle invalidation events from the new pass manager.
Definition: BitVector.h:938
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:371
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB)
A CRTP-driven "mixin" base class to help implement the function alias analysis results concept...
AliasResult
The possible results of an alias query.
Definition: AliasAnalysis.h:78
#define P(N)
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.
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:566
bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal)
A wrapper pass for external alias analyses.
A container for analyses that lazily runs them and caches their results.