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

Akshay Deodhar via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 1 09:08:27 PDT 2026


================
@@ -888,6 +920,19 @@ void NVPTXAsmPrinter::emitFunctionBodyEnd() {
   VRegMapping.clear();
 }
 
+// PTX permits these directives only between the .func directive and the
+// function body, so they are emitted here, after the parameter list and before
+// the opening brace.
+void NVPTXAsmPrinter::emitFunctionDirectives(const Function &F,
+                                             raw_ostream &O) const {
+  if (shouldEmitPTXNoReturn(F))
+    O << ".noreturn\n";
+
+  if (shouldEmitABIPreserve(F))
+    printABIPreserve(getABIPreserve(F), O, /*Prefix=*/"", /*Sep=*/"\n",
+                     /*Suffix=*/"\n");
----------------
akshayrdeodhar wrote:

We can't- the convention for the declaration is that they need to be in a single new line, after ")". For definitions, we emit one attribute per line (that's how existing directives on definitions work). For callprototypes, we append to the same line. 

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


More information about the llvm-commits mailing list