1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4
2 // RUN: %clang_cc1 -triple spirv64-unknown-unknown -fcuda-is-device -emit-llvm -o - %s | FileCheck %s
9 // CHECK-LABEL: define spir_func void @testva(
10 // CHECK-SAME: i32 noundef [[N:%.*]], ...) #[[ATTR0:[0-9]+]] {
12 // CHECK-NEXT: [[N_ADDR:%.*]] = alloca i32, align 4
13 // CHECK-NEXT: [[AP:%.*]] = alloca ptr addrspace(4), align 8
14 // CHECK-NEXT: [[T:%.*]] = alloca [[STRUCT_X:%.*]], align 8
15 // CHECK-NEXT: [[AP2:%.*]] = alloca ptr addrspace(4), align 8
16 // CHECK-NEXT: [[V:%.*]] = alloca i32, align 4
17 // CHECK-NEXT: [[VARET:%.*]] = alloca i32, align 4
18 // CHECK-NEXT: [[N_ADDR_ASCAST:%.*]] = addrspacecast ptr [[N_ADDR]] to ptr addrspace(4)
19 // CHECK-NEXT: [[AP_ASCAST:%.*]] = addrspacecast ptr [[AP]] to ptr addrspace(4)
20 // CHECK-NEXT: [[T_ASCAST:%.*]] = addrspacecast ptr [[T]] to ptr addrspace(4)
21 // CHECK-NEXT: [[AP2_ASCAST:%.*]] = addrspacecast ptr [[AP2]] to ptr addrspace(4)
22 // CHECK-NEXT: [[V_ASCAST:%.*]] = addrspacecast ptr [[V]] to ptr addrspace(4)
23 // CHECK-NEXT: [[VARET_ASCAST:%.*]] = addrspacecast ptr [[VARET]] to ptr addrspace(4)
24 // CHECK-NEXT: store i32 [[N]], ptr addrspace(4) [[N_ADDR_ASCAST]], align 4
25 // CHECK-NEXT: call void @llvm.va_start.p4(ptr addrspace(4) [[AP_ASCAST]])
26 // CHECK-NEXT: [[TMP0:%.*]] = va_arg ptr addrspace(4) [[AP_ASCAST]], ptr
27 // CHECK-NEXT: call void @llvm.memcpy.p4.p0.i64(ptr addrspace(4) align 8 [[T_ASCAST]], ptr align 8 [[TMP0]], i64 16, i1 false)
28 // CHECK-NEXT: call void @llvm.va_copy.p4(ptr addrspace(4) [[AP2_ASCAST]], ptr addrspace(4) [[AP_ASCAST]])
29 // CHECK-NEXT: [[TMP1:%.*]] = va_arg ptr addrspace(4) [[AP2_ASCAST]], i32
30 // CHECK-NEXT: store i32 [[TMP1]], ptr addrspace(4) [[VARET_ASCAST]], align 4
31 // CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr addrspace(4) [[VARET_ASCAST]], align 4
32 // CHECK-NEXT: store i32 [[TMP2]], ptr addrspace(4) [[V_ASCAST]], align 4
33 // CHECK-NEXT: call void @llvm.va_end.p4(ptr addrspace(4) [[AP2_ASCAST]])
34 // CHECK-NEXT: call void @llvm.va_end.p4(ptr addrspace(4) [[AP_ASCAST]])
35 // CHECK-NEXT: ret void
37 void testva(int n
, ...) {
39 __builtin_va_start(ap
, n
);
40 struct x t
= __builtin_va_arg(ap
, struct x
);
41 __builtin_va_list ap2
;
42 __builtin_va_copy(ap2
, ap
);
43 int v
= __builtin_va_arg(ap2
, int);
44 __builtin_va_end(ap2
);