LLVM 20.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
16#include "llvm/IR/Module.h"
17
18namespace llvm {
19
20class DataLayout;
21class MemoryLocation;
22
23/// A simple AA result that uses TBAA metadata to answer queries.
25 const DataLayout &DL;
26
27public:
28 explicit AMDGPUAAResult(const DataLayout &DL) : DL(DL) {}
30 : AAResultBase(std::move(Arg)), DL(Arg.DL) {}
31
32 /// Handle invalidation events from the new pass manager.
33 ///
34 /// By definition, this result is stateless and so remains valid.
37 return false;
38 }
39
40 AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB,
41 AAQueryInfo &AAQI, const Instruction *CtxI);
43 bool IgnoreLocals);
44};
45
46/// Analysis pass providing a never-invalidated alias analysis result.
47class AMDGPUAA : public AnalysisInfoMixin<AMDGPUAA> {
49
50 static AnalysisKey Key;
51
52public:
54
56 return AMDGPUAAResult(F.getDataLayout());
57 }
58};
59
60/// Legacy wrapper pass to provide the AMDGPUAAResult object.
62 std::unique_ptr<AMDGPUAAResult> Result;
63
64public:
65 static char ID;
66
68
69 AMDGPUAAResult &getResult() { return *Result; }
70 const AMDGPUAAResult &getResult() const { return *Result; }
71
72 bool doInitialization(Module &M) override {
73 Result.reset(new AMDGPUAAResult(M.getDataLayout()));
74 return false;
75 }
76
77 bool doFinalization(Module &M) override {
78 Result.reset();
79 return false;
80 }
81
82 void getAnalysisUsage(AnalysisUsage &AU) const override;
83};
84
85// Wrapper around ExternalAAWrapperPass so that the default constructor gets the
86// callback.
88public:
89 static char ID;
90
92 [](Pass &P, Function &, AAResults &AAR) {
93 if (auto *WrapperPass = P.getAnalysisIfAvailable<AMDGPUAAWrapperPass>())
94 AAR.addAAResult(WrapperPass->getResult());
95 }) {}
96};
97
98} // end namespace llvm
99
100#endif // LLVM_LIB_TARGET_AMDGPU_AMDGPUALIASANALYSIS_H
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define F(x, y, z)
Definition: MD5.cpp:55
Module.h This file contains the declarations for the Module class.
#define P(N)
This class stores info we want to provide to or retain within an alias query.
A base class to help implement the function alias analysis results concept.
A simple AA result that uses TBAA metadata to answer queries.
AMDGPUAAResult(const DataLayout &DL)
AliasResult alias(const MemoryLocation &LocA, const MemoryLocation &LocB, AAQueryInfo &AAQI, const Instruction *CtxI)
AMDGPUAAResult(AMDGPUAAResult &&Arg)
ModRefInfo getModRefInfoMask(const MemoryLocation &Loc, AAQueryInfo &AAQI, bool IgnoreLocals)
bool invalidate(Function &, const PreservedAnalyses &, FunctionAnalysisManager::Invalidator &Inv)
Handle invalidation events from the new pass manager.
Legacy wrapper pass to provide the AMDGPUAAResult object.
bool doFinalization(Module &M) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
AMDGPUAAResult & getResult()
const AMDGPUAAResult & getResult() const
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
bool doInitialization(Module &M) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
Analysis pass providing a never-invalidated alias analysis result.
AMDGPUAAResult run(Function &F, AnalysisManager< Function > &AM)
The possible results of an alias query.
Definition: AliasAnalysis.h:82
API to communicate dependencies between analyses during invalidation.
Definition: PassManager.h:292
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
Represent the analysis usage information of a pass.
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:103
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition: Pass.h:281
Representation for a specific memory location.
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:94
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:111
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
Definition: ModRef.h:27
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:1849
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
A CRTP mix-in that provides informational APIs needed for analysis passes.
Definition: PassManager.h:92
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: Analysis.h:28
A wrapper pass for external alias analyses.