[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
Thu Aug 20 02:11:31 PDT 2026


skc7 wrote:

> I don't think my comment [#209842 (comment)](https://github.com/llvm/llvm-project/pull/209842#issuecomment-5136261531) has been resolved. Even if just to fix the issue, wouldn't a full module scan followed by a rewrite of all AS3 related code be sufficient? Does it have to be this complicated?

Hi @shiltian . Thanks for the suggestion.

The current state/architecture of the pass is that it doesn't relocate LDS into static AS1 global. Each variable goes into a per-kernel buffer that's `__asan_malloc`'d at the prologue with redzones poisoned and a matching `__asan_free`. And every access loads that runtime base from a shared LDS slot and adds the variable's offset. So, there's no static AS1 symbol to rewrite operands to. The address only exists at runtime. And the buffer is per-kernel, dynamic LDS can't be static global and AS3 only ops have no drop-in AS1 form. So, a mechanical type swap doesn't actually cover the cases in this architecture of the pass.

> "Even if just to fix the issue, wouldn't a full module scan followed by a rewrite of all AS3 related code be sufficient?"

 This PR just doesn't rewrite all AS3, it folds the one leftover shape that can occur: a flat->local round trip on lowered LDS. A blanket AS3→AS1 rewrite doesn't fit, because on the kernel side LDS isn't a static AS1 global. It's a runtime `__asan_malloc` buffer addressed as base+offset, so there's no AS1 symbol to rewrite operands to. And in the callee the right target is the flat pointer, not AS1. 
 
> "Does it have to be this complicated?"

A uniform LDS -> global conversion is a reasonable longer-term direction, and it includes re-design of the pass core strategy rather than a change that fits in this fix. This PR is scoped to fix the miscompile breaking rocPRIM(ROCM-24185).

https://github.com/llvm/llvm-project/pull/209842


More information about the llvm-commits mailing list