[llvm] [NVPTX] Add Custom ABI (abi_preserve) support via function attributes (PR #227499)

Durgadoss R via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 30 04:01:55 PDT 2026


================
@@ -1013,6 +1034,14 @@ void NVPTXAsmPrinter::emitDeclarationWithName(const Function *F, MCSymbol *S,
   O << "\n";
   if (shouldEmitPTXNoReturn(*F))
     O << ".noreturn";
+  // Print abi_preserve directives regardless of whether F is a definition or a
+  // declaration, subject to the same restrictions as above.
+  if (!isKernelFunction(*F) &&
+      TM.getSubtarget<NVPTXSubtarget>(*F).hasABIPreserve())
+    if (const std::string ABI =
+            getABIPreserveDirectives(*F, /*Multiline=*/false);
+        !ABI.empty())
----------------
durga4github wrote:

Since these checks are used in a few places, would it be worth moving them to a small util function?

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


More information about the llvm-commits mailing list