[PATCH] D154946: [AMDGPULowerModuleLDSPass] Kernels do not always have entries in KernelToReplacement map

Jon Chesterfield via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 11 09:11:52 PDT 2023


JonChesterfield added a comment.

OK, I think I've got the root cause.

The slow path lowering for normal variables is a table lookup indexed by kernel id, which is an integer assigned somewhat arbitrarily and later made available through the lds intrinsic (involves dedicating a sgpr to the i32 value).

The lowering for dynamic variables is a table lookup indexed by the same kernel id because I didn't think it was worth burning a second sgpr on it.

The pass successfully assigns integers to kernels that use either of these variables. assignLDSKernelIDToEachKernel takes two sets, combines them, sorts the result.

Where it then goes wrong is the lookup table construction assumes every kernel with an index will have a corresponding element, which was true before dynamic variable lowering was introduced. Now however, if a kernel uses dynamic variables and no table lookup static ones, it'll have an assigned index but the corresponding table entry needs to be poison.

Lowerdynamicldsvariables handles this correctly because it was written at the same time as breaking that invariant.

Right fix is going to involve poison at some positions in the lookup table, probably similarly to buildLookupTable. Likely to look like a hybrid of this patch and D154972 <https://reviews.llvm.org/D154972>.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154946/new/

https://reviews.llvm.org/D154946



More information about the llvm-commits mailing list