[llvm] [AMDGPU] Emit the relocation symbol for LDS and named barrier when object linking is enabled (PR #192380)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 16 10:36:20 PDT 2026


================
@@ -330,10 +331,18 @@ void AMDGPUAsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
       return;
     }
 
-    // LDS variables aren't emitted in HSA or PAL yet.
     const Triple::OSType OS = TM.getTargetTriple().getOS();
-    if (OS == Triple::AMDHSA || OS == Triple::AMDPAL)
-      return;
+    if (OS == Triple::AMDHSA || OS == Triple::AMDPAL) {
+      if (!AMDGPUTargetMachine::EnableObjectLinking)
+        return;
+      // With object linking, LDS definitions should have been externalized
+      // by earlier passes (e.g. LDS lowering, named barrier lowering).
+      // Only declarations reach here, emitted as SHN_AMDGPU_LDS symbols
+      // so the linker can assign their offsets.
+      assert(GV->isDeclaration() &&
+             "LDS definitions should have been externalized when object "
+             "linking is enabled");
----------------
shiltian wrote:

I agree, but here it is the asm printer, and apparently the LDS lowering should run anyway since it is mandatory. It's like we don't have to check if RA runs or not here, right?

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


More information about the llvm-commits mailing list