1 //===-------------------- NVPTXAliasAnalysis.h ------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 /// This is the NVPTX address space based alias analysis pass.
10 //===----------------------------------------------------------------------===//
12 #ifndef LLVM_LIB_TARGET_NVPTX_NVPTXALIASANALYSIS_H
13 #define LLVM_LIB_TARGET_NVPTX_NVPTXALIASANALYSIS_H
15 #include "llvm/Analysis/AliasAnalysis.h"
21 class NVPTXAAResult
: public AAResultBase
{
24 NVPTXAAResult(NVPTXAAResult
&&Arg
) : AAResultBase(std::move(Arg
)) {}
26 /// Handle invalidation events from the new pass manager.
28 /// By definition, this result is stateless and so remains valid.
29 bool invalidate(Function
&, const PreservedAnalyses
&,
30 FunctionAnalysisManager::Invalidator
&Inv
) {
34 AliasResult
alias(const MemoryLocation
&LocA
, const MemoryLocation
&LocB
,
35 AAQueryInfo
&AAQI
, const Instruction
*CtxI
= nullptr);
37 ModRefInfo
getModRefInfoMask(const MemoryLocation
&Loc
, AAQueryInfo
&AAQI
,
41 /// Analysis pass providing a never-invalidated alias analysis result.
42 class NVPTXAA
: public AnalysisInfoMixin
<NVPTXAA
> {
43 friend AnalysisInfoMixin
<NVPTXAA
>;
45 static AnalysisKey Key
;
48 using Result
= NVPTXAAResult
;
50 NVPTXAAResult
run(Function
&F
, AnalysisManager
<Function
> &AM
) {
51 return NVPTXAAResult();
55 /// Legacy wrapper pass to provide the NVPTXAAResult object.
56 class NVPTXAAWrapperPass
: public ImmutablePass
{
57 std::unique_ptr
<NVPTXAAResult
> Result
;
64 NVPTXAAResult
&getResult() { return *Result
; }
65 const NVPTXAAResult
&getResult() const { return *Result
; }
67 bool doInitialization(Module
&M
) override
{
68 Result
.reset(new NVPTXAAResult());
72 bool doFinalization(Module
&M
) override
{
77 void getAnalysisUsage(AnalysisUsage
&AU
) const override
;
80 // Wrapper around ExternalAAWrapperPass so that the default
81 // constructor gets the callback.
82 class NVPTXExternalAAWrapper
: public ExternalAAWrapperPass
{
86 NVPTXExternalAAWrapper()
87 : ExternalAAWrapperPass([](Pass
&P
, Function
&, AAResults
&AAR
) {
88 if (auto *WrapperPass
=
89 P
.getAnalysisIfAvailable
<NVPTXAAWrapperPass
>())
90 AAR
.addAAResult(WrapperPass
->getResult());
94 ImmutablePass
*createNVPTXAAWrapperPass();
95 void initializeNVPTXAAWrapperPassPass(PassRegistry
&);
96 ImmutablePass
*createNVPTXExternalAAWrapperPass();
97 void initializeNVPTXExternalAAWrapperPass(PassRegistry
&);
99 } // end namespace llvm
101 #endif // LLVM_LIB_TARGET_NVPTX_NVPTXALIASANALYSIS_H