Skip to content

Commit de81b85

Browse files
[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 6c9086d 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`.
1 parent fb0000b commit de81b85

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8592,6 +8592,10 @@ static bool callConvSupportsVarArgs(CallingConv::ID CC) {
85928592
switch (CC) {
85938593
case CallingConv::C:
85948594
case CallingConv::PreserveNone:
8595+
// SVE vector call is only partially supported, but it should
8596+
// support named arguments being passed. Any arguments being passed
8597+
// as varargs, are still unsupported.
8598+
case CallingConv::AArch64_SVE_VectorCall:
85958599
return true;
85968600
default:
85978601
return false;
Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
1-
; RUN: not --crash llc -mtriple aarch64-linux-gnu -mattr=+sve <%s 2>&1 | FileCheck %s
1+
; RUN: split-file %s %t
22

3-
declare i32 @sve_printf(ptr, <vscale x 4 x i32>, ...)
3+
; RUN: not --crash llc -mtriple aarch64-linux-gnu -mattr=+sve < %t/test-non-tailcall.ll 2>&1 | FileCheck %s --check-prefix=CHECKNONTAIL
4+
; RUN: not --crash llc -mtriple aarch64-linux-gnu -mattr=+sve < %t/test-tailcall.ll 2>&1 | FileCheck %s --check-prefix=CHECKTAIL
45

6+
;--- test-non-tailcall.ll
7+
declare i32 @sve_printf(ptr, <vscale x 4 x i32>, ...)
58
@.str_1 = internal constant [6 x i8] c"boo!\0A\00"
69

7-
; CHECK: Passing SVE types to variadic functions is currently not supported
8-
define void @foo(<vscale x 4 x i32> %x) {
10+
; CHECKTAIL: Passing SVE types to variadic functions is currently not supported
11+
define void @foo_nontail(<vscale x 4 x i32> %x) {
912
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)
1013
ret void
1114
}
15+
16+
;--- test-tailcall.ll
17+
declare i32 @sve_printf(ptr, <vscale x 4 x i32>, ...)
18+
@.str_1 = internal constant [6 x i8] c"boo!\0A\00"
19+
20+
; CHECKNONTAIL: Passing SVE types to variadic functions is currently not supported
21+
define void @foo_tail(<vscale x 4 x i32> %x) {
22+
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)
23+
ret void
24+
}

llvm/test/CodeGen/AArch64/sve-varargs.ll

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ declare i32 @sve_printf(ptr, <vscale x 4 x i32>, ...)
55

66
@.str_1 = internal constant [6 x i8] c"boo!\0A\00"
77

8-
define void @foo(<vscale x 4 x i32> %x) uwtable {
9-
; CHECK-LABEL: foo:
8+
define void @foo_nontail(<vscale x 4 x i32> %x) uwtable {
9+
; CHECK-LABEL: foo_nontail:
1010
; CHECK: // %bb.0:
1111
; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
1212
; CHECK-NEXT: .cfi_def_cfa_offset 16
@@ -21,3 +21,13 @@ define void @foo(<vscale x 4 x i32> %x) uwtable {
2121
call i32 (ptr, <vscale x 4 x i32>, ...) @sve_printf(ptr @.str_1, <vscale x 4 x i32> %x)
2222
ret void
2323
}
24+
25+
define void @foo_tail(<vscale x 4 x i32> %x) uwtable {
26+
; CHECK-LABEL: foo_tail:
27+
; CHECK: // %bb.0:
28+
; CHECK-NEXT: adrp x0, .str_1
29+
; CHECK-NEXT: add x0, x0, :lo12:.str_1
30+
; CHECK-NEXT: b sve_printf
31+
tail call i32 (ptr, <vscale x 4 x i32>, ...) @sve_printf(ptr @.str_1, <vscale x 4 x i32> %x)
32+
ret void
33+
}

0 commit comments

Comments
 (0)