[PATCH] D137893: [AsmWriter] Do not write a comma when varargs is the only argument

Adrian Vogelsgesang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 14 02:46:50 PST 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8ad88f129cc4: Do not write a comma when varargs is the only argument (authored by caojoshua, committed by avogelsgesang).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137893/new/

https://reviews.llvm.org/D137893

Files:
  llvm/lib/IR/AsmWriter.cpp
  llvm/test/Transforms/Inline/inline-brunch-funnel.ll


Index: llvm/test/Transforms/Inline/inline-brunch-funnel.ll
===================================================================
--- llvm/test/Transforms/Inline/inline-brunch-funnel.ll
+++ llvm/test/Transforms/Inline/inline-brunch-funnel.ll
@@ -9,27 +9,27 @@
 ; CHECK-LABEL: define void @fn_musttail(
 define void @fn_musttail() {
   call void (...) @bf_musttail()
-  ; CHECK: call void (...) @bf_musttail(
+  ; CHECK: call void (...) @bf_musttail()
   ret void
 }
 
 ; CHECK-LABEL: define internal void @bf_musttail(
 define internal void @bf_musttail(...) {
   musttail call void (...) @llvm.icall.branch.funnel(...)
-  ; CHECK: musttail call void (...) @llvm.icall.branch.funnel(
+  ; CHECK: musttail call void (...) @llvm.icall.branch.funnel(...)
   ret void
 }
 
 ; CHECK-LABEL: define void @fn_musttail_always(
 define void @fn_musttail_always() {
   call void (...) @bf_musttail_always()
-  ; CHECK: call void (...) @bf_musttail_always(
+  ; CHECK: call void (...) @bf_musttail_always()
   ret void
 }
 
 ; CHECK-LABEL: define internal void @bf_musttail_always(
 define internal void @bf_musttail_always(...) alwaysinline {
   musttail call void (...) @llvm.icall.branch.funnel(...)
-  ; CHECK: musttail call void (...) @llvm.icall.branch.funnel(
+  ; CHECK: musttail call void (...) @llvm.icall.branch.funnel(...)
   ret void
 }
Index: llvm/lib/IR/AsmWriter.cpp
===================================================================
--- llvm/lib/IR/AsmWriter.cpp
+++ llvm/lib/IR/AsmWriter.cpp
@@ -4140,7 +4140,6 @@
     // If possible, print out the short form of the call instruction.  We can
     // only do this if the first argument is a pointer to a nonvararg function,
     // and if the return type is not a pointer to a function.
-    //
     Out << ' ';
     TypePrinter.print(FTy->isVarArg() ? FTy : RetTy, Out);
     Out << ' ';
@@ -4156,8 +4155,11 @@
     // is only to aid readability, musttail calls forward varargs by default.
     if (CI->isMustTailCall() && CI->getParent() &&
         CI->getParent()->getParent() &&
-        CI->getParent()->getParent()->isVarArg())
-      Out << ", ...";
+        CI->getParent()->getParent()->isVarArg()) {
+      if (CI->arg_size() > 0)
+        Out << ", ";
+      Out << "...";
+    }
 
     Out << ')';
     if (PAL.hasFnAttrs())


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137893.475091.patch
Type: text/x-patch
Size: 2292 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221114/a30e2646/attachment.bin>


More information about the llvm-commits mailing list