Skip to content

[AArch64] Allow variadic calls with SVE argument if it is named. #136833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8595,6 +8595,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;
Expand Down
21 changes: 17 additions & 4 deletions llvm/test/CodeGen/AArch64/sve-varargs-caller-broken.ll
Original file line number Diff line number Diff line change
@@ -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>, ...)
@.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
}
14 changes: 12 additions & 2 deletions llvm/test/CodeGen/AArch64/sve-varargs.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
Loading