1 // REQUIRES: powerpc-registered-target
3 // RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
4 // RUN: %clang_cc1 -triple powerpc-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-PPC
5 // RUN: %clang_cc1 -triple powerpc64-ibm-aix-xcoff -emit-llvm -o - %s | FileCheck %s
14 void testva (int n
, ...)
18 struct x t
= va_arg (ap
, struct x
);
19 // CHECK: call void @llvm.memcpy
21 // CHECK-PPC: [[ARRAYDECAY:%.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %ap, i32 0, i32 0
22 // CHECK-PPC-NEXT: [[GPRPTR:%.+]] = getelementptr inbounds %struct.__va_list_tag, ptr [[ARRAYDECAY]], i32 0, i32 0
23 // CHECK-PPC-NEXT: [[GPR:%.+]] = load i8, ptr [[GPRPTR]], align 4
24 // CHECK-PPC-NEXT: [[COND:%.+]] = icmp ult i8 [[GPR]], 8
25 // CHECK-PPC-NEXT: br i1 [[COND]], label %[[USING_REGS:[a-z_0-9]+]], label %[[USING_OVERFLOW:[a-z_0-9]+]]
27 // CHECK-PPC:[[USING_REGS]]
28 // CHECK-PPC-NEXT: [[REGSAVE_AREA_P:%.+]] = getelementptr inbounds %struct.__va_list_tag, ptr [[ARRAYDECAY]], i32 0, i32 4
29 // CHECK-PPC-NEXT: [[REGSAVE_AREA:%.+]] = load ptr, ptr [[REGSAVE_AREA_P]], align 4
30 // CHECK-PPC-NEXT: [[OFFSET:%.+]] = mul i8 [[GPR]], 4
31 // CHECK-PPC-NEXT: [[RAW_REGADDR:%.+]] = getelementptr inbounds i8, ptr [[REGSAVE_AREA]], i8 [[OFFSET]]
32 // CHECK-PPC-NEXT: [[USED_GPR:%[0-9]+]] = add i8 [[GPR]], 1
33 // CHECK-PPC-NEXT: store i8 [[USED_GPR]], ptr [[GPRPTR]], align 4
34 // CHECK-PPC-NEXT: br label %[[CONT:[a-z0-9]+]]
36 // CHECK-PPC:[[USING_OVERFLOW]]
37 // CHECK-PPC-NEXT: store i8 8, ptr [[GPRPTR]], align 4
38 // CHECK-PPC-NEXT: [[OVERFLOW_AREA_P:%[0-9]+]] = getelementptr inbounds %struct.__va_list_tag, ptr [[ARRAYDECAY]], i32 0, i32 3
39 // CHECK-PPC-NEXT: [[OVERFLOW_AREA:%.+]] = load ptr, ptr [[OVERFLOW_AREA_P]], align 4
40 // CHECK-PPC-NEXT: %{{[0-9]+}} = ptrtoint ptr %argp.cur to i32
41 // CHECK-PPC-NEXT: %{{[0-9]+}} = add i32 %{{[0-9]+}}, 7
42 // CHECK-PPC-NEXT: %{{[0-9]+}} = and i32 %{{[0-9]+}}, -8
43 // CHECK-PPC-NEXT: %argp.cur.aligned = inttoptr i32 %{{[0-9]+}} to ptr
44 // CHECK-PPC-NEXT: [[NEW_OVERFLOW_AREA:%[0-9]+]] = getelementptr inbounds i8, ptr %argp.cur.aligned, i32 4
45 // CHECK-PPC-NEXT: store ptr [[NEW_OVERFLOW_AREA:%[0-9]+]], ptr [[OVERFLOW_AREA_P]], align 4
46 // CHECK-PPC-NEXT: br label %[[CONT]]
49 // CHECK-PPC-NEXT: [[VAARG_ADDR:%[a-z.0-9]+]] = phi ptr [ [[RAW_REGADDR]], %[[USING_REGS]] ], [ %argp.cur.aligned, %[[USING_OVERFLOW]] ]
50 // CHECK-PPC-NEXT: [[AGGR:%[a-z0-9]+]] = load ptr, ptr [[VAARG_ADDR]]
51 // CHECK-PPC-NEXT: call void @llvm.memcpy.p0.p0.i32(ptr align 8 %t, ptr align 8 [[AGGR]], i32 16, i1 false)
53 int v
= va_arg (ap
, int);
55 // CHECK: getelementptr inbounds i8, ptr %{{[a-z.0-9]*}}, i64 4
56 // CHECK-PPC: [[ARRAYDECAY:%[a-z0-9]+]] = getelementptr inbounds [1 x %struct.__va_list_tag], ptr %ap, i32 0, i32 0
57 // CHECK-PPC-NEXT: [[GPRPTR:%.+]] = getelementptr inbounds %struct.__va_list_tag, ptr [[ARRAYDECAY]], i32 0, i32 0
58 // CHECK-PPC-NEXT: [[GPR:%.+]] = load i8, ptr [[GPRPTR]], align 4
59 // CHECK-PPC-NEXT: [[COND:%.+]] = icmp ult i8 [[GPR]], 8
60 // CHECK-PPC-NEXT: br i1 [[COND]], label %[[USING_REGS:.+]], label %[[USING_OVERFLOW:.+]]{{$}}
62 // CHECK-PPC:[[USING_REGS]]
63 // CHECK-PPC-NEXT: [[REGSAVE_AREA_P:%.+]] = getelementptr inbounds %struct.__va_list_tag, ptr [[ARRAYDECAY]], i32 0, i32 4
64 // CHECK-PPC-NEXT: [[REGSAVE_AREA:%.+]] = load ptr, ptr [[REGSAVE_AREA_P]], align 4
65 // CHECK-PPC-NEXT: [[OFFSET:%.+]] = mul i8 [[GPR]], 4
66 // CHECK-PPC-NEXT: [[RAW_REGADDR:%.+]] = getelementptr inbounds i8, ptr [[REGSAVE_AREA]], i8 [[OFFSET]]
67 // CHECK-PPC-NEXT: [[USED_GPR:%[0-9]+]] = add i8 [[GPR]], 1
68 // CHECK-PPC-NEXT: store i8 [[USED_GPR]], ptr [[GPRPTR]], align 4
69 // CHECK-PPC-NEXT: br label %[[CONT:[a-z0-9]+]]
71 // CHECK-PPC:[[USING_OVERFLOW]]
72 // CHECK-PPC-NEXT: store i8 8, ptr [[GPRPTR]], align 4
73 // CHECK-PPC-NEXT: [[OVERFLOW_AREA_P:%[0-9]+]] = getelementptr inbounds %struct.__va_list_tag, ptr [[ARRAYDECAY]], i32 0, i32 3
74 // CHECK-PPC-NEXT: [[OVERFLOW_AREA:%.+]] = load ptr, ptr [[OVERFLOW_AREA_P]], align 4
75 // CHECK-PPC-NEXT: [[NEW_OVERFLOW_AREA:%[0-9]+]] = getelementptr inbounds i8, ptr [[OVERFLOW_AREA]], i32 4
76 // CHECK-PPC-NEXT: store ptr [[NEW_OVERFLOW_AREA]], ptr [[OVERFLOW_AREA_P]]
77 // CHECK-PPC-NEXT: br label %[[CONT]]
80 // CHECK-PPC-NEXT: [[VAARG_ADDR:%[a-z.0-9]+]] = phi ptr [ [[RAW_REGADDR]], %[[USING_REGS]] ], [ [[OVERFLOW_AREA]], %[[USING_OVERFLOW]] ]
81 // CHECK-PPC-NEXT: [[THIRTYFIVE:%[0-9]+]] = load i32, ptr [[VAARG_ADDR]]
82 // CHECK-PPC-NEXT: store i32 [[THIRTYFIVE]], ptr %v, align 4
85 __int128_t u
= va_arg (ap
, __int128_t
);
87 // CHECK: load i128, ptr %argp.cur3