[llvm] [AMDGPU] Handle lowering addrspace casts from LDS to FLAT address in amdgpu-sw-lower-lds. (PR #121214)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 21 08:36:55 PST 2025


================
@@ -722,6 +726,16 @@ void AMDGPUSwLowerLDS::translateLDSMemoryOperationsToGlobalMemory(
       AsanInfo.Instructions.insert(NewXCHG);
       XCHG->replaceAllUsesWith(NewXCHG);
       XCHG->eraseFromParent();
+    } else if (AddrSpaceCastInst *AscI = dyn_cast<AddrSpaceCastInst>(Inst)) {
+      Value *AIOperand = AscI->getPointerOperand();
+      Value *Gep =
+          getTranslatedGlobalMemoryGEPOfLDSPointer(LoadMallocPtr, AIOperand);
+      Value *NewAI = IRB.CreateAddrSpaceCast(Gep, AscI->getType());
+      // Note: No need to add the instruction to AsanInfo instructions to be
+      // instrumented list. FLAT_ADDRESS ptr would have been already
+      // instrumented by asan pass prior to this pass.
+      AscI->replaceAllUsesWith(NewAI);
+      AscI->eraseFromParent();
     } else
       report_fatal_error("Unimplemented LDS lowering instruction");
----------------
skc7 wrote:

The latest commit now handles addrspace cast with vector of ptrs. Please let me know if I missed any other cases here. 

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


More information about the llvm-commits mailing list