LLVM  13.0.0git
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"
17 
18 namespace llvm {
19 
20 class DataLayout;
21 class MDNode;
22 class MemoryLocation;
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 
30 public:
31  explicit AMDGPUAAResult(const DataLayout &DL) : AAResultBase(), DL(DL) {}
33  : AAResultBase(std::move(Arg)), DL(Arg.DL) {}
34 
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);
47 };
48 
49 /// Analysis pass providing a never-invalidated alias analysis result.
50 class AMDGPUAA : public AnalysisInfoMixin<AMDGPUAA> {
52 
53  static AnalysisKey Key;
54 
55 public:
57 
59  return AMDGPUAAResult(F.getParent()->getDataLayout());
60  }
61 };
62 
63 /// Legacy wrapper pass to provide the AMDGPUAAResult object.
65  std::unique_ptr<AMDGPUAAResult> Result;
66 
67 public:
68  static char ID;
69 
72  }
73 
74  AMDGPUAAResult &getResult() { return *Result; }
75  const AMDGPUAAResult &getResult() const { return *Result; }
76 
77  bool doInitialization(Module &M) override {
78  Result.reset(new AMDGPUAAResult(M.getDataLayout()));
79  return false;
80  }
81 
82  bool doFinalization(Module &M) override {
83  Result.reset();
84  return false;
85  }
86 
87  void getAnalysisUsage(AnalysisUsage &AU) const override;
88 };
89 
90 // Wrapper around ExternalAAWrapperPass so that the default constructor gets the
91 // callback.
93 public:
94  static char ID;
95 
97  [](Pass &P, Function &, AAResults &AAR) {
98  if (auto *WrapperPass = P.getAnalysisIfAvailable<AMDGPUAAWrapperPass>())
99  AAR.addAAResult(WrapperPass->getResult());
100  }) {}
101 };
102 
103 } // end namespace llvm
104 
105 #endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUALIASANALYSIS_H
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:155
llvm::AMDGPUAA
Analysis pass providing a never-invalidated alias analysis result.
Definition: AMDGPUAliasAnalysis.h:50
llvm
Definition: AllocatorList.h:23
llvm::AMDGPUAAResult::pointsToConstantMemory
bool pointsToConstantMemory(const MemoryLocation &Loc, AAQueryInfo &AAQI, bool OrLocal)
Definition: AMDGPUAliasAnalysis.cpp:122
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:112
llvm::ImmutablePass
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition: Pass.h:269
llvm::Function
Definition: Function.h:61
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
llvm::AMDGPUAAWrapperPass::ID
static char ID
Definition: AMDGPUAliasAnalysis.h:68
llvm::AMDGPUAAWrapperPass::AMDGPUAAWrapperPass
AMDGPUAAWrapperPass()
Definition: AMDGPUAliasAnalysis.h:70
llvm::AMDGPUExternalAAWrapper::ID
static char ID
Definition: AMDGPUAliasAnalysis.h:94
llvm::AMDGPUAAWrapperPass
Legacy wrapper pass to provide the AMDGPUAAResult object.
Definition: AMDGPUAliasAnalysis.h:64
llvm::AliasResult
The possible results of an alias query.
Definition: AliasAnalysis.h:81
llvm::AMDGPUAAResult::invalidate
bool invalidate(Function &, const PreservedAnalyses &, FunctionAnalysisManager::Invalidator &Inv)
Handle invalidation events from the new pass manager.
Definition: AMDGPUAliasAnalysis.h:38
llvm::AMDGPUAAWrapperPass::getAnalysisUsage
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
Definition: AMDGPUAliasAnalysis.cpp:40
F
#define F(x, y, z)
Definition: MD5.cpp:56
AliasAnalysis.h
Arg
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Definition: AMDGPULibCalls.cpp:205
llvm::AAQueryInfo
This class stores info we want to provide to or retain within an alias query.
Definition: AliasAnalysis.h:414
llvm::AMDGPUAAWrapperPass::doInitialization
bool doInitialization(Module &M) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
Definition: AMDGPUAliasAnalysis.h:77
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition: PassRegistry.cpp:31
llvm::AAResults
Definition: AliasAnalysis.h:456
llvm::AnalysisUsage
Represent the analysis usage information of a pass.
Definition: PassAnalysisSupport.h:47
llvm::AnalysisManager::Invalidator
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:670
llvm::AMDGPUAAWrapperPass::doFinalization
bool doFinalization(Module &M) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
Definition: AMDGPUAliasAnalysis.h:82
llvm::AnalysisKey
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:72
llvm::AMDGPUExternalAAWrapper
Definition: AMDGPUAliasAnalysis.h:92
llvm::AMDGPUAAResult::AMDGPUAAResult
AMDGPUAAResult(AMDGPUAAResult &&Arg)
Definition: AMDGPUAliasAnalysis.h:32
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1540
llvm::initializeAMDGPUAAWrapperPassPass
void initializeAMDGPUAAWrapperPassPass(PassRegistry &)
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::AnalysisInfoMixin
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:391
llvm::AMDGPUExternalAAWrapper::AMDGPUExternalAAWrapper
AMDGPUExternalAAWrapper()
Definition: AMDGPUAliasAnalysis.h:96
llvm::AMDGPUAAWrapperPass::getResult
const AMDGPUAAResult & getResult() const
Definition: AMDGPUAliasAnalysis.h:75
AMDGPU.h
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::AMDGPUAAResult::AMDGPUAAResult
AMDGPUAAResult(const DataLayout &DL)
Definition: AMDGPUAliasAnalysis.h:31
std
Definition: BitVector.h:838
llvm::AMDGPUAAResult
A simple AA result that uses TBAA metadata to answer queries.
Definition: AMDGPUAliasAnalysis.h:25
llvm::Pass
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:91
llvm::ExternalAAWrapperPass
A wrapper pass for external alias analyses.
Definition: AliasAnalysis.h:1287
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
llvm::AMDGPUAA::run
AMDGPUAAResult run(Function &F, AnalysisManager< Function > &AM)
Definition: AMDGPUAliasAnalysis.h:58
llvm::AMDGPUAAWrapperPass::getResult
AMDGPUAAResult & getResult()
Definition: AMDGPUAliasAnalysis.h:74
llvm::AMDGPUAAResult::alias
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB, AAQueryInfo &AAQI)
Definition: AMDGPUAliasAnalysis.cpp:70
llvm::AAResultBase
A CRTP-driven "mixin" base class to help implement the function alias analysis results concept.
Definition: AliasAnalysis.h:1064
llvm::MemoryLocation
Representation for a specific memory location.
Definition: MemoryLocation.h:209