diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2024-01-09 20:00:28 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2024-04-19 21:14:10 +0000 | 
| commit | cdc20ff6a7f12464aed70d9b6e67ea07da9f0399 (patch) | |
| tree | 0c2f259d41b6d1f146c344cb9cf2b15ea99d35bb /contrib/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp | |
| parent | 7adf29b6244fe016ef869f287a66048195f9af29 (diff) | |
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp')
| -rw-r--r-- | contrib/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp | 39 | 
1 files changed, 30 insertions, 9 deletions
diff --git a/contrib/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp b/contrib/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp index 323462e60a29..31777295b4f8 100644 --- a/contrib/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp +++ b/contrib/llvm-project/llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp @@ -19,6 +19,26 @@  using namespace llvm; +static const GlobalVariable * +getKernelDynLDSGlobalFromFunction(const Function &F) { +  const Module *M = F.getParent(); +  SmallString<64> KernelDynLDSName("llvm.amdgcn."); +  KernelDynLDSName += F.getName(); +  KernelDynLDSName += ".dynlds"; +  return M->getNamedGlobal(KernelDynLDSName); +} + +static bool hasLDSKernelArgument(const Function &F) { +  for (const Argument &Arg : F.args()) { +    Type *ArgTy = Arg.getType(); +    if (auto PtrTy = dyn_cast<PointerType>(ArgTy)) { +      if (PtrTy->getAddressSpace() == AMDGPUAS::LOCAL_ADDRESS) +        return true; +    } +  } +  return false; +} +  AMDGPUMachineFunction::AMDGPUMachineFunction(const Function &F,                                               const AMDGPUSubtarget &ST)      : IsEntryFunction(AMDGPU::isEntryFunctionCC(F.getCallingConv())), @@ -65,6 +85,10 @@ AMDGPUMachineFunction::AMDGPUMachineFunction(const Function &F,    Attribute NSZAttr = F.getFnAttribute("no-signed-zeros-fp-math");    NoSignedZerosFPMath =        NSZAttr.isStringAttribute() && NSZAttr.getValueAsString() == "true"; + +  const GlobalVariable *DynLdsGlobal = getKernelDynLDSGlobalFromFunction(F); +  if (DynLdsGlobal || hasLDSKernelArgument(F)) +    UsesDynamicLDS = true;  }  unsigned AMDGPUMachineFunction::allocateLDSGlobal(const DataLayout &DL, @@ -139,15 +163,6 @@ unsigned AMDGPUMachineFunction::allocateLDSGlobal(const DataLayout &DL,    return Offset;  } -static const GlobalVariable * -getKernelDynLDSGlobalFromFunction(const Function &F) { -  const Module *M = F.getParent(); -  std::string KernelDynLDSName = "llvm.amdgcn."; -  KernelDynLDSName += F.getName(); -  KernelDynLDSName += ".dynlds"; -  return M->getNamedGlobal(KernelDynLDSName); -} -  std::optional<uint32_t>  AMDGPUMachineFunction::getLDSKernelIdMetadata(const Function &F) {    // TODO: Would be more consistent with the abs symbols to use a range @@ -210,3 +225,9 @@ void AMDGPUMachineFunction::setDynLDSAlign(const Function &F,      }    }  } + +void AMDGPUMachineFunction::setUsesDynamicLDS(bool DynLDS) { +  UsesDynamicLDS = DynLDS; +} + +bool AMDGPUMachineFunction::isDynamicLDSUsed() const { return UsesDynamicLDS; }  | 
