[all-commits] [llvm/llvm-project] 050744: [amdgpu] Implement dynamic LDS accesses from non-k...

Jon Chesterfield via All-commits all-commits at lists.llvm.org
Tue Apr 4 12:06:58 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0507448d829818e29f7d8df6652002c8cc5683d1
      https://github.com/llvm/llvm-project/commit/0507448d829818e29f7d8df6652002c8cc5683d1
  Author: Jon Chesterfield <jonathanchesterfield at gmail.com>
  Date:   2023-04-04 (Tue, 04 Apr 2023)

  Changed paths:
    M llvm/lib/Target/AMDGPU/AMDGPUAlwaysInlinePass.cpp
    M llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
    M llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
    M llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.cpp
    M llvm/lib/Target/AMDGPU/AMDGPUMachineFunction.h
    M llvm/lib/Target/AMDGPU/SIISelLowering.cpp
    M llvm/lib/Target/AMDGPU/Utils/AMDGPUMemoryUtils.cpp
    M llvm/lib/Target/AMDGPU/Utils/AMDGPUMemoryUtils.h
    M llvm/test/CodeGen/AMDGPU/hip.extern.shared.array.ll
    M llvm/test/CodeGen/AMDGPU/lds-frame-extern.ll
    M llvm/test/CodeGen/AMDGPU/lower-module-lds-inactive.ll
    A llvm/test/CodeGen/AMDGPU/lower-module-lds-indirect-extern-uses-max-reachable-alignment.ll

  Log Message:
  -----------
  [amdgpu] Implement dynamic LDS accesses from non-kernel functions

The premise here is to allow non-kernel functions to locate external LDS variables without using LDS or extra magic SGPRs to do so.

1/ First it crawls the callgraph to work out which external LDS variables are reachable from a given kernel
2/ Then it creates a new `extern char[0]` variable for each kernel, which will alias all the other extern LDS variables because that's the documented behaviour of these variables
3/ The address of that variable is written to a lookup table. The global variable is tagged with metadata to track what address it was allocated at by codegen
4/ The assembler builds the lookup table using the metadata
5/ Any non-kernel functions use the same magic intrinsic used by table lookups of non-dynamic LDS variables to find the address to use

Heavy overlap with the code paths taken for other lowering, in particular the same intrinsic is used to pass the dynamic scope information through the same sgpr as for table lookups of static LDS.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D144233




More information about the All-commits mailing list