Skip to content

Commit b56c3eb

Browse files
author
git apple-llvm automerger
committed
Merge commit '724f62a50241' from llvm.org/release/11.x into apple/stable/20200714
2 parents 83fc48e + 724f62a commit b56c3eb

File tree

6 files changed

+94
-0
lines changed

6 files changed

+94
-0
lines changed

clang/lib/CodeGen/TargetInfo.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5475,6 +5475,11 @@ class AArch64ABIInfo : public SwiftABIInfo {
54755475

54765476
Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
54775477
QualType Ty) const override {
5478+
llvm::Type *BaseTy = CGF.ConvertType(Ty);
5479+
if (isa<llvm::ScalableVectorType>(BaseTy))
5480+
llvm::report_fatal_error("Passing SVE types to variadic functions is "
5481+
"currently not supported");
5482+
54785483
return Kind == Win64 ? EmitMSVAArg(CGF, VAListAddr, Ty)
54795484
: isDarwinPCS() ? EmitDarwinVAArg(VAListAddr, Ty, CGF)
54805485
: EmitAAPCSVAArg(VAListAddr, Ty, CGF);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// REQUIRES: aarch64-registered-target
2+
// RUN: not %clang_cc1 -triple aarch64-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -emit-llvm -o - %s 2>&1 | FileCheck %s
3+
// RUN: not %clang_cc1 -triple arm64-apple-ios7 -target-abi darwinpcs -target-feature +sve -fallow-half-arguments-and-returns -emit-llvm -o - %s 2>&1 | FileCheck %s
4+
5+
// CHECK: Passing SVE types to variadic functions is currently not supported
6+
7+
#include <arm_sve.h>
8+
#include <stdarg.h>
9+
10+
double foo(char *str, ...) {
11+
va_list ap;
12+
svfloat64_t v;
13+
double x;
14+
15+
va_start(ap, str);
16+
v = va_arg(ap, svfloat64_t);
17+
x = va_arg(ap, double);
18+
va_end(ap);
19+
20+
return x + svaddv(svptrue_b8(), v);
21+
}

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4376,6 +4376,10 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI,
43764376

43774377
for (unsigned i = 0; i != NumArgs; ++i) {
43784378
MVT ArgVT = Outs[i].VT;
4379+
if (!Outs[i].IsFixed && ArgVT.isScalableVector())
4380+
report_fatal_error("Passing SVE types to variadic functions is "
4381+
"currently not supported");
4382+
43794383
ISD::ArgFlagsTy ArgFlags = Outs[i].Flags;
43804384
CCAssignFn *AssignFn = CCAssignFnForCall(CallConv,
43814385
/*IsVarArg=*/ !Outs[i].IsFixed);
@@ -6346,6 +6350,10 @@ SDValue AArch64TargetLowering::LowerVAARG(SDValue Op, SelectionDAG &DAG) const {
63466350
Chain = VAList.getValue(1);
63476351
VAList = DAG.getZExtOrTrunc(VAList, DL, PtrVT);
63486352

6353+
if (VT.isScalableVector())
6354+
report_fatal_error("Passing SVE types to variadic functions is "
6355+
"currently not supported");
6356+
63496357
if (Align && *Align > MinSlotSize) {
63506358
VAList = DAG.getNode(ISD::ADD, DL, PtrVT, VAList,
63516359
DAG.getConstant(Align->value() - 1, DL, PtrVT));
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
; RUN: not --crash llc -mtriple arm64-apple-ios7 -mattr=+sve < %s 2>&1 | FileCheck %s
2+
3+
; CHECK: Passing SVE types to variadic functions is currently not supported
4+
5+
@.str = private unnamed_addr constant [4 x i8] c"fmt\00", align 1
6+
define void @foo(i8* %fmt, ...) nounwind {
7+
entry:
8+
%fmt.addr = alloca i8*, align 8
9+
%args = alloca i8*, align 8
10+
%vc = alloca i32, align 4
11+
%vv = alloca <vscale x 4 x i32>, align 16
12+
store i8* %fmt, i8** %fmt.addr, align 8
13+
%args1 = bitcast i8** %args to i8*
14+
call void @llvm.va_start(i8* %args1)
15+
%0 = va_arg i8** %args, i32
16+
store i32 %0, i32* %vc, align 4
17+
%1 = va_arg i8** %args, <vscale x 4 x i32>
18+
store <vscale x 4 x i32> %1, <vscale x 4 x i32>* %vv, align 16
19+
ret void
20+
}
21+
22+
declare void @llvm.va_start(i8*) nounwind
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
; RUN: not --crash llc -mtriple aarch64-linux-gnu -mattr=+sve <%s 2>&1 | FileCheck %s
2+
3+
declare i32 @sve_printf(i8*, <vscale x 4 x i32>, ...)
4+
5+
@.str_1 = internal constant [6 x i8] c"boo!\0A\00"
6+
7+
; CHECK: Passing SVE types to variadic functions is currently not supported
8+
define void @foo(<vscale x 4 x i32> %x) {
9+
%f = getelementptr [6 x i8], [6 x i8]* @.str_1, i64 0, i64 0
10+
call i32 (i8*, <vscale x 4 x i32>, ...) @sve_printf(i8* %f, <vscale x 4 x i32> %x, <vscale x 4 x i32> %x)
11+
ret void
12+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve < %s 2>%t | FileCheck %s
3+
; RUN: FileCheck --check-prefix=WARN --allow-empty %s <%t
4+
5+
; If this check fails please read test/CodeGen/AArch64/README for instructions on how to resolve it.
6+
; WARN-NOT: warning
7+
8+
declare i32 @sve_printf(i8*, <vscale x 4 x i32>, ...)
9+
10+
@.str_1 = internal constant [6 x i8] c"boo!\0A\00"
11+
12+
define void @foo(<vscale x 4 x i32> %x) {
13+
; CHECK-LABEL: foo:
14+
; CHECK: // %bb.0:
15+
; CHECK-NEXT: str x30, [sp, #-16]! // 8-byte Folded Spill
16+
; CHECK-NEXT: .cfi_def_cfa_offset 16
17+
; CHECK-NEXT: .cfi_offset w30, -16
18+
; CHECK-NEXT: adrp x0, .str_1
19+
; CHECK-NEXT: add x0, x0, :lo12:.str_1
20+
; CHECK-NEXT: bl sve_printf
21+
; CHECK-NEXT: ldr x30, [sp], #16 // 8-byte Folded Reload
22+
; CHECK-NEXT: ret
23+
%f = getelementptr [6 x i8], [6 x i8]* @.str_1, i64 0, i64 0
24+
call i32 (i8*, <vscale x 4 x i32>, ...) @sve_printf(i8* %f, <vscale x 4 x i32> %x)
25+
ret void
26+
}

0 commit comments

Comments
 (0)