[llvm] [AMDGPU] Fix LDS access via flat pointer argument in amdgpu-sw-lower-lds (PR #209842)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 19 03:52:56 PDT 2026
================
@@ -1320,6 +1419,20 @@ bool AMDGPUSwLowerLDS::run() {
Changed = true;
}
+ // Lower any remaining non-kernel that reaches lowered LDS through a flat
+ // round trip (addrspacecast flat->local). Functions handled above already had
+ // these accesses translated there, so skip them. No detection is needed:
+ // collapsing the round trip is valid regardless of the pointer's origin.
+ for (Function &F : M) {
+ if (F.isDeclaration() || AMDGPU::isKernel(F))
+ continue;
+ if (FuncLDSAccessInfo.NonKernelToLDSAccessMap.contains(&F) ||
+ FuncLDSAccessInfo.NonKernelsWithLDSArgument.contains(&F))
+ continue;
+ if (lowerNonKernelLDSFlatArgAccesses(&F))
+ Changed = true;
+ }
+
----------------
skc7 wrote:
Yes, this PR only fixes the bug, a helper function gets LDS as a flat pointer, casts it back to addrspace(3), and ends up reading dead LDS after relocation. This fix is what unblocks the rocPRIM (ROCM-24185) failure now. I'm happy to do the redesign, if necessary, as a follow-up.
https://github.com/llvm/llvm-project/pull/209842
More information about the llvm-commits
mailing list