[llvm] [AMDGPU] Restrict promote alloca on pointers across address spaces (PR #119762)

Sumanth Gundapaneni via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 17 07:46:46 PST 2024


================
@@ -796,6 +796,16 @@ bool AMDGPUPromoteAllocaImpl::tryPromoteAllocaToVector(AllocaInst &Alloca) {
       if (!IsSimple)
         return RejectUser(Inst, "not a simple load or store");
 
+      // If the access type is a pointer, reject the address spaces with
+      // different pointer sizes.
+      // store <2 x ptr> %arg, ptr addrspace(5) %alloca - Reject.
----------------
sgundapa wrote:

https://llvm.org/docs/AMDGPUUsage.html#address-spaces
"Code that manipulates the stack values in other lanes of a wavefront, such as by addrspacecast-ing stack pointers to generic ones and taking offsets that reach other lanes or by explicitly constructing the scratch buffer descriptor, triggers undefined behavior when it modifies the scratch values of other lanes"

In theory, if we can define a behavior of saving a 32-bit value in to 64-bit value, this should be fine and the vice-versa will be challenging.

In the above example , if %alloca is defined by addrcast, we can impart a reasonable conversion.  
I am begining to understand the amdgpu arch, some of my assumptions could be wrong.



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


More information about the llvm-commits mailing list