[PATCH] D101310: [AMDGPU] Replace uses of LDS globals within non-kernel functions by pointers.

Mahesha S via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 26 10:25:23 PDT 2021


hsmhsm created this revision.
hsmhsm added reviewers: JonChesterfield, arsenm, b-sumner, t-tye, rampitec.
Herald added subscribers: kerbowa, jfb, hiraditya, tpr, dstuttard, yaxunl, mgorny, nhaehnle, jvesely, kzhuravl.
hsmhsm requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

The pass - "Lower Module LDS" supports use of LDS globals within non-kernel
 functions by lowering LDS globals as follows. It packs within non-kernel used
 LDS globals into a struct type, and creates an instance of that struct type
 within every kernel at "address zero".

However, the pass - "Lower Module LDS" sometime wastes LDS memory depending
 on the pattern of LDS globals use within the module.

Hence the current pass makes an attempt to aid the pass - "Lower Module LDS"
 for efficient LDS memory usage. The idea behind current pass is as follows:

- Instead of directly packing LDS globals into the struct as struct members, create global LDS pointers correspoding those LDS globals.
- Initialize those global LDS pointers with their respective LDS globals.
- Replace all the non-kernel function scope use of those original LDS globals by their respective pointer counter-parts.
- Then the pass "Lower Module LDS" by the virtue of its implementation idea, lands-up packing only LDS pointers as struct members, which substentially reduces unnecessary LDS memory usage.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101310

Files:
  llvm/lib/Target/AMDGPU/AMDGPU.h
  llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
  llvm/lib/Target/AMDGPU/AMDGPUReplaceLDSUseWithPointer.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/lib/Target/AMDGPU/CMakeLists.txt
  llvm/lib/Target/AMDGPU/Utils/AMDGPULDSUtils.cpp
  llvm/lib/Target/AMDGPU/Utils/AMDGPULDSUtils.h
  llvm/test/CodeGen/AMDGPU/lds_replace_by_pointer-call_diamond_shape.ll
  llvm/test/CodeGen/AMDGPU/lds_replace_by_pointer-call_miscellaneous.ll
  llvm/test/CodeGen/AMDGPU/lds_replace_by_pointer-indirect_call_diamond_shape.ll
  llvm/test/CodeGen/AMDGPU/lds_replace_by_pointer-small_lds.ll
  llvm/test/CodeGen/AMDGPU/lds_replace_by_pointer-use_both_within_kernel_and_func.ll
  llvm/test/CodeGen/AMDGPU/lds_replace_by_pointer-use_only_within_func.ll
  llvm/test/CodeGen/AMDGPU/lds_replace_by_pointer-use_only_within_kernel.ll
  llvm/test/CodeGen/AMDGPU/lds_replace_by_pointer-use_within_both_global_and_func_scope.ll
  llvm/test/CodeGen/AMDGPU/lds_replace_by_pointer-use_within_both_global_and_func_scope2.ll
  llvm/test/CodeGen/AMDGPU/lds_replace_by_pointer-use_within_const_expr.ll
  llvm/test/CodeGen/AMDGPU/lds_replace_by_pointer-use_within_const_expr2.ll
  llvm/test/CodeGen/AMDGPU/lds_replace_by_pointer-use_within_const_expr3.ll
  llvm/test/CodeGen/AMDGPU/lds_replace_by_pointer-use_within_not_rechable_func.ll
  llvm/test/CodeGen/AMDGPU/promote-alloca-to-lds-constantexpr-use.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101310.340580.patch
Type: text/x-patch
Size: 66081 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210426/032ad045/attachment.bin>


More information about the llvm-commits mailing list