LLVM  9.0.0svn
AMDGPUAliasAnalysis.h
Go to the documentation of this file.
1 //===- AMDGPUAliasAnalysis --------------------------------------*- 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 /// \file
9 /// This is the AMGPU address space based alias analysis pass.
10 //===----------------------------------------------------------------------===//
11 
12 #ifndef LLVM_LIB_TARGET_AMDGPU_AMDGPUALIASANALYSIS_H
13 #define LLVM_LIB_TARGET_AMDGPU_AMDGPUALIASANALYSIS_H
14 
15 #include "AMDGPU.h"
16 #include "llvm/ADT/Triple.h"
18 #include "llvm/IR/Function.h"
19 #include "llvm/IR/Module.h"
20 #include "llvm/Pass.h"
21 #include <algorithm>
22 #include <memory>
23 
24 namespace llvm {
25 
26 class DataLayout;
27 class MDNode;
28 class MemoryLocation;
29 
30 /// A simple AA result that uses TBAA metadata to answer queries.
31 class AMDGPUAAResult : public AAResultBase<AMDGPUAAResult> {
33 
34  const DataLayout &DL;
35 
36 public:
37  explicit AMDGPUAAResult(const DataLayout &DL, Triple T) : AAResultBase(),
38  DL(DL) {}
40  : AAResultBase(std::move(Arg)), DL(Arg.DL) {}
41 
42  /// Handle invalidation events from the new pass manager.
43  ///
44  /// By definition, this result is stateless and so remains valid.
45  bool invalidate(Function &, const PreservedAnalyses &) { return false; }
46 
47  AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB);
48  bool pointsToConstantMemory(const MemoryLocation &Loc, bool OrLocal);
49 
50 private:
51  bool Aliases(const MDNode *A, const MDNode *B) const;
52  bool PathAliases(const MDNode *A, const MDNode *B) const;
53 };
54 
55 /// Analysis pass providing a never-invalidated alias analysis result.
56 class AMDGPUAA : public AnalysisInfoMixin<AMDGPUAA> {
58 
59  static char PassID;
60 
61 public:
63 
67  }
68 };
69 
70 /// Legacy wrapper pass to provide the AMDGPUAAResult object.
72  std::unique_ptr<AMDGPUAAResult> Result;
73 
74 public:
75  static char ID;
76 
79  }
80 
81  AMDGPUAAResult &getResult() { return *Result; }
82  const AMDGPUAAResult &getResult() const { return *Result; }
83 
84  bool doInitialization(Module &M) override {
85  Result.reset(new AMDGPUAAResult(M.getDataLayout(),
86  Triple(M.getTargetTriple())));
87  return false;
88  }
89 
90  bool doFinalization(Module &M) override {
91  Result.reset();
92  return false;
93  }
94 
95  void getAnalysisUsage(AnalysisUsage &AU) const override;
96 };
97 
98 // Wrapper around ExternalAAWrapperPass so that the default constructor gets the
99 // callback.
101 public:
102  static char ID;
103 
105  [](Pass &P, Function &, AAResults &AAR) {
106  if (auto *WrapperPass = P.getAnalysisIfAvailable<AMDGPUAAWrapperPass>())
107  AAR.addAAResult(WrapperPass->getResult());
108  }) {}
109 };
110 
111 } // end namespace llvm
112 
113 #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUALIASANALYSIS_H
Pass interface - Implemented by all &#39;passes&#39;.
Definition: Pass.h:80
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:110
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
Definition: Module.h:239
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:23
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:64
AMDGPUAAResult(AMDGPUAAResult &&Arg)
const AMDGPUAAResult & getResult() const
Metadata node.
Definition: Metadata.h:863
F(f)
void initializeAMDGPUAAWrapperPassPass(PassRegistry &)
AMDGPUAAResult & getResult()
bool invalidate(Function &, const PreservedAnalyses &)
Handle invalidation events from the new pass manager.
Definition: BitVector.h:937
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:369
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:77
#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:153
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:382
Represent the analysis usage information of a pass.
Legacy wrapper pass to provide the AMDGPUAAResult object.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Analysis pass providing a never-invalidated alias analysis result.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:43
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
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...
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:565
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.