[llvm] 8ad88f1 - Do not write a comma when varargs is the only argument
Adrian Vogelsgesang via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 14 02:46:41 PST 2022
Author: Joshua Cao
Date: 2022-11-14T02:46:11-08:00
New Revision: 8ad88f129cc489fc3076f399fd9c1bebc6e28bf1
URL: https://github.com/llvm/llvm-project/commit/8ad88f129cc489fc3076f399fd9c1bebc6e28bf1
DIFF: https://github.com/llvm/llvm-project/commit/8ad88f129cc489fc3076f399fd9c1bebc6e28bf1.diff
LOG: Do not write a comma when varargs is the only argument
Fixes https://github.com/llvm/llvm-project/issues/56544
AsmWriter always writes ", ..." when a tail call has a varargs argument. This patch only writes the ", " when there is an argument before the varargs argument.
I did not write a dedicated test this for this change, but I modified an existing test that will test for a regression.
Reviewed By: avogelsgesang
Differential Revision: https://reviews.llvm.org/D137893
Signed-off-by: Adrian Vogelsgesang <avogelsgesang at salesforce.com>
Added:
Modified:
llvm/lib/IR/AsmWriter.cpp
llvm/test/Transforms/Inline/inline-brunch-funnel.ll
Removed:
################################################################################
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index d49b8710bc9a4..22e12b29843e0 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -4140,7 +4140,6 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
// 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 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
// 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())
diff --git a/llvm/test/Transforms/Inline/inline-brunch-funnel.ll b/llvm/test/Transforms/Inline/inline-brunch-funnel.ll
index 54c6600c038e5..567abc6b94306 100644
--- a/llvm/test/Transforms/Inline/inline-brunch-funnel.ll
+++ b/llvm/test/Transforms/Inline/inline-brunch-funnel.ll
@@ -9,27 +9,27 @@ declare void @llvm.icall.branch.funnel(...)
; 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
}
More information about the llvm-commits
mailing list