[llvm] de81b85 - [AArch64] Allow variadic calls with SVE argument if it is named. (#136833)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 23 23:57:13 PDT 2025
Author: Sander de Smalen
Date: 2025-04-24T07:57:09+01:00
New Revision: de81b852fd8d2b654e1c7112f198026aa272c6b3
URL: https://github.com/llvm/llvm-project/commit/de81b852fd8d2b654e1c7112f198026aa272c6b3
DIFF: https://github.com/llvm/llvm-project/commit/de81b852fd8d2b654e1c7112f198026aa272c6b3.diff
LOG: [AArch64] Allow variadic calls with SVE argument if it is named. (#136833)
The following case used to work:
void foo(svint32_t a, ...);
void bar(svint32_t a) { foo(a); }
but 6c9086d13fa7e1069e75ed2d139aae30ee3863c8 introduced a regression
that wasn't caught by the existing test `sve-varargs.ll` because the
call in the test wasn't a tail call and therefore skipped the code-path
with the `report_fatal_error`.
Added:
Modified:
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/test/CodeGen/AArch64/sve-varargs-caller-broken.ll
llvm/test/CodeGen/AArch64/sve-varargs.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 447794cc2b744..713f814121aa3 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -8592,6 +8592,10 @@ static bool callConvSupportsVarArgs(CallingConv::ID CC) {
switch (CC) {
case CallingConv::C:
case CallingConv::PreserveNone:
+ // SVE vector call is only partially supported, but it should
+ // support named arguments being passed. Any arguments being passed
+ // as varargs, are still unsupported.
+ case CallingConv::AArch64_SVE_VectorCall:
return true;
default:
return false;
diff --git a/llvm/test/CodeGen/AArch64/sve-varargs-caller-broken.ll b/llvm/test/CodeGen/AArch64/sve-varargs-caller-broken.ll
index 1ecdd2ff43781..b90c02fa1c032 100644
--- a/llvm/test/CodeGen/AArch64/sve-varargs-caller-broken.ll
+++ b/llvm/test/CodeGen/AArch64/sve-varargs-caller-broken.ll
@@ -1,11 +1,24 @@
-; RUN: not --crash llc -mtriple aarch64-linux-gnu -mattr=+sve <%s 2>&1 | FileCheck %s
+; RUN: split-file %s %t
-declare i32 @sve_printf(ptr, <vscale x 4 x i32>, ...)
+; RUN: not --crash llc -mtriple aarch64-linux-gnu -mattr=+sve < %t/test-non-tailcall.ll 2>&1 | FileCheck %s --check-prefix=CHECKNONTAIL
+; RUN: not --crash llc -mtriple aarch64-linux-gnu -mattr=+sve < %t/test-tailcall.ll 2>&1 | FileCheck %s --check-prefix=CHECKTAIL
+;--- test-non-tailcall.ll
+declare i32 @sve_printf(ptr, <vscale x 4 x i32>, ...)
@.str_1 = internal constant [6 x i8] c"boo!\0A\00"
-; CHECK: Passing SVE types to variadic functions is currently not supported
-define void @foo(<vscale x 4 x i32> %x) {
+; CHECKTAIL: Passing SVE types to variadic functions is currently not supported
+define void @foo_nontail(<vscale x 4 x i32> %x) {
call i32 (ptr, <vscale x 4 x i32>, ...) @sve_printf(ptr @.str_1, <vscale x 4 x i32> %x, <vscale x 4 x i32> %x)
ret void
}
+
+;--- test-tailcall.ll
+declare i32 @sve_printf(ptr, <vscale x 4 x i32>, ...)
+ at .str_1 = internal constant [6 x i8] c"boo!\0A\00"
+
+; CHECKNONTAIL: Passing SVE types to variadic functions is currently not supported
+define void @foo_tail(<vscale x 4 x i32> %x) {
+ tail call i32 (ptr, <vscale x 4 x i32>, ...) @sve_printf(ptr @.str_1, <vscale x 4 x i32> %x, <vscale x 4 x i32> %x)
+ ret void
+}
diff --git a/llvm/test/CodeGen/AArch64/sve-varargs.ll b/llvm/test/CodeGen/AArch64/sve-varargs.ll
index c63491f445b9c..4ae92f0c8a41b 100644
--- a/llvm/test/CodeGen/AArch64/sve-varargs.ll
+++ b/llvm/test/CodeGen/AArch64/sve-varargs.ll
@@ -5,8 +5,8 @@ declare i32 @sve_printf(ptr, <vscale x 4 x i32>, ...)
@.str_1 = internal constant [6 x i8] c"boo!\0A\00"
-define void @foo(<vscale x 4 x i32> %x) uwtable {
-; CHECK-LABEL: foo:
+define void @foo_nontail(<vscale x 4 x i32> %x) uwtable {
+; CHECK-LABEL: foo_nontail:
; CHECK: // %bb.0:
; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
; CHECK-NEXT: .cfi_def_cfa_offset 16
@@ -21,3 +21,13 @@ define void @foo(<vscale x 4 x i32> %x) uwtable {
call i32 (ptr, <vscale x 4 x i32>, ...) @sve_printf(ptr @.str_1, <vscale x 4 x i32> %x)
ret void
}
+
+define void @foo_tail(<vscale x 4 x i32> %x) uwtable {
+; CHECK-LABEL: foo_tail:
+; CHECK: // %bb.0:
+; CHECK-NEXT: adrp x0, .str_1
+; CHECK-NEXT: add x0, x0, :lo12:.str_1
+; CHECK-NEXT: b sve_printf
+ tail call i32 (ptr, <vscale x 4 x i32>, ...) @sve_printf(ptr @.str_1, <vscale x 4 x i32> %x)
+ ret void
+}
More information about the llvm-commits
mailing list