[llvm] [AMDGPU] Defer emitting AMDGPUAsmPrinter local Resource Usage comments until the end (PR #198233)

Janek van Oirschot via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 2 22:02:58 PDT 2026


================
@@ -743,8 +746,130 @@ void AMDGPUAsmPrinter::emitCommonFunctionComments(
   }
   OutStreamer->emitRawComment(" ScratchSize: " + getMCExprStr(ScratchSize),
                               false);
-  OutStreamer->emitRawComment(" MemoryBound: " + Twine(MFI->isMemoryBound()),
-                              false);
+  OutStreamer->emitRawComment(" MemoryBound: " + Twine(IsMemoryBound), false);
+}
+
+void AMDGPUAsmPrinter::emitDeferredComments() {
+  for (const auto &Info : DeferredComments) {
+    const Function &F = *Info.F;
+    const GCNSubtarget &STM = TM.getSubtarget<GCNSubtarget>(F);
+    MCSymbol *FnSym = TM.getSymbol(&F);
+    StringRef FuncName = FnSym->getName();
+    bool IsMemoryBound =
+        F.getFnAttribute("amdgpu-memory-bound").getValueAsBool();
+
+    MCSectionELF *CommentSection =
+        OutContext.getELFSection(".AMDGPU.csdata", ELF::SHT_PROGBITS, 0);
----------------
JanekvO wrote:

>From what I gathered, `.AMDGPU.csdata` is always empty in llvm (MC layer). The section switch is superfluous as comments are not emitted within the section but emitted as part of the Asm, with a comment prefix (and thus, also don't end up in the .text). Possibly a leftover of sc to llvm transition? (I haven't figured out how to check sc as of yet, myself)

Let me know what's the best approach for this (removal? emit something within the section?)

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


More information about the llvm-commits mailing list