[PATCH] D82339: [HIP][AMDGPU] Do not perform Promote Alloca optimization for GPU kernels with dynamic LDS usage.
Konstantin Pyzhov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 22 18:49:15 PDT 2020
kpyzhov created this revision.
kpyzhov added reviewers: yaxunl, b-sumner.
kpyzhov added a project: AMDGPU.
Herald added subscribers: llvm-commits, kerbowa, hiraditya, t-tye, tpr, dstuttard, nhaehnle, wdng, jvesely, kzhuravl, arsenm.
Herald added a project: LLVM.
The "Promote Alloca" optimization tries to move some stack allocations to statically allocated LDS, so it adds new static LDS loads/stores to the kernel.
Mixed static/dynamic LDS is not correctly supported by the hip-clang yet, so adding static LDS load/stores to a kernel that already has dynamic LDS operations causes conflicts.
This patch disables Promote Alloca optimization for kernels that use dynamic LDS.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D82339
Files:
llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
Index: llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp
@@ -736,6 +736,12 @@
continue;
if (Use->getParent()->getParent() == &F) {
+ // Do not promote alloca to static LDS if this function uses any dynamic shared memory
+ // since mixed static/dynamic LDS is not fully supported yet.
+ uint64_t AllocSize = DL.getTypeAllocSize(GV.getValueType());
+ if (AllocSize == 0)
+ return false;
+
unsigned Align = GV.getAlignment();
if (Align == 0)
Align = DL.getABITypeAlignment(GV.getValueType());
@@ -744,7 +750,6 @@
// determined from the inverse order of uses in the function. I'm not
// sure if the use list order is in any way connected to this, so the
// total reported size is likely incorrect.
- uint64_t AllocSize = DL.getTypeAllocSize(GV.getValueType());
CurrentLocalMemUsage = alignTo(CurrentLocalMemUsage, Align);
CurrentLocalMemUsage += AllocSize;
break;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82339.272582.patch
Type: text/x-patch
Size: 1172 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200623/c79616d4/attachment.bin>
More information about the llvm-commits
mailing list