1 //===- AMDGPUMemoryUtils.h - Memory related helper functions -*- 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 9 #ifndef LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUMEMORYUTILS_H 10 #define LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUMEMORYUTILS_H 11 12 #include "llvm/ADT/ArrayRef.h" 13 #include "llvm/ADT/DenseMap.h" 14 #include "llvm/ADT/DenseSet.h" 15 16 namespace llvm { 17 18 struct Align; 19 class AAResults; 20 class DataLayout; 21 class GlobalVariable; 22 class LoadInst; 23 class MemoryDef; 24 class MemorySSA; 25 class Value; 26 class Function; 27 class CallGraph; 28 class Module; 29 30 namespace AMDGPU { 31 32 using FunctionVariableMap = DenseMap<Function *, DenseSet<GlobalVariable *>>; 33 using VariableFunctionMap = DenseMap<GlobalVariable *, DenseSet<Function *>>; 34 35 Align getAlign(const DataLayout &DL, const GlobalVariable *GV); 36 37 bool isDynamicLDS(const GlobalVariable &GV); 38 bool isLDSVariableToLower(const GlobalVariable &GV); 39 40 struct LDSUsesInfoTy { 41 FunctionVariableMap direct_access; 42 FunctionVariableMap indirect_access; 43 }; 44 45 bool eliminateConstantExprUsesOfLDSFromAllInstructions(Module &M); 46 47 void getUsesOfLDSByFunction(const CallGraph &CG, Module &M, 48 FunctionVariableMap &kernels, 49 FunctionVariableMap &functions); 50 51 bool isKernelLDS(const Function *F); 52 53 LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M); 54 55 /// Strip FnAttr attribute from any functions where we may have 56 /// introduced its use. 57 void removeFnAttrFromReachable(CallGraph &CG, Function *KernelRoot, 58 ArrayRef<StringRef> FnAttrs); 59 60 /// Given a \p Def clobbering a load from \p Ptr according to the MSSA check 61 /// if this is actually a memory update or an artificial clobber to facilitate 62 /// ordering constraints. 63 bool isReallyAClobber(const Value *Ptr, MemoryDef *Def, AAResults *AA); 64 65 /// Check is a \p Load is clobbered in its function. 66 bool isClobberedInFunction(const LoadInst *Load, MemorySSA *MSSA, 67 AAResults *AA); 68 69 } // end namespace AMDGPU 70 71 } // end namespace llvm 72 73 #endif // LLVM_LIB_TARGET_AMDGPU_UTILS_AMDGPUMEMORYUTILS_H 74