• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // REQUIRES: powerpc-registered-target
2 // REQUIRES: asserts
3 // RUN: %clang_cc1 -triple powerpc-unknown-aix -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,AIX32
4 // RUN: %clang_cc1 -triple powerpc64-unknown-aix -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,AIX64
5 
6 struct x {
7   double b;
8   long a;
9 };
10 
testva(int n,...)11 void testva (int n, ...) {
12   __builtin_va_list ap;
13   __builtin_va_start(ap, n);
14   struct x t = __builtin_va_arg(ap, struct x);
15   __builtin_va_list ap2;
16   __builtin_va_copy(ap2, ap);
17   int v = __builtin_va_arg(ap2, int);
18   __builtin_va_end(ap2);
19   __builtin_va_end(ap);
20 }
21 
22 // AIX32: define void @testva(i32 %n, ...)
23 // AIX64: define void @testva(i32 signext %n, ...)
24 
25 // CHECK-NEXT: entry:
26 // CHECK-NEXT:  %n.addr = alloca i32, align 4
27 
28 // AIX32-NEXT:  %ap = alloca i8*, align 4
29 // AIX64-NEXT:  %ap = alloca i8*, align 8
30 
31 // CHECK-NEXT:  %t = alloca %struct.x, align 8
32 
33 // AIX32-NEXT:  %ap2 = alloca i8*, align 4
34 // AIX64-NEXT:  %ap2 = alloca i8*, align 8
35 
36 // CHECK-NEXT:  %v = alloca i32, align 4
37 // CHECK-NEXT:  store i32 %n, i32* %n.addr, align 4
38 // CHECK-NEXT:  %ap1 = bitcast i8** %ap to i8*
39 // CHECK-NEXT:  call void @llvm.va_start(i8* %ap1)
40 
41 // AIX32-NEXT:  %argp.cur = load i8*, i8** %ap, align 4
42 // AIX32-NEXT:  %argp.next = getelementptr inbounds i8, i8* %argp.cur, i32 16
43 // AIX32-NEXT:  store i8* %argp.next, i8** %ap, align 4
44 // AIX64-NEXT:  %argp.cur = load i8*, i8** %ap, align 8
45 // AIX64-NEXT:  %argp.next = getelementptr inbounds i8, i8* %argp.cur, i64 16
46 // AIX64-NEXT:  store i8* %argp.next, i8** %ap, align 8
47 
48 // CHECK-NEXT:  %0 = bitcast i8* %argp.cur to %struct.x*
49 // CHECK-NEXT:  %1 = bitcast %struct.x* %t to i8*
50 // CHECK-NEXT:  %2 = bitcast %struct.x* %0 to i8*
51 
52 // AIX32-NEXT:  call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 %1, i8* align 4 %2, i32 16, i1 false)
53 // AIX64-NEXT:  call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %1, i8* align 8 %2, i64 16, i1 false)
54 
55 // CHECK-NEXT:  %3 = bitcast i8** %ap2 to i8*
56 // CHECK-NEXT:  %4 = bitcast i8** %ap to i8*
57 // CHECK-NEXT:  call void @llvm.va_copy(i8* %3, i8* %4)
58 
59 // AIX32-NEXT:  %argp.cur2 = load i8*, i8** %ap2, align 4
60 // AIX32-NEXT:  %argp.next3 = getelementptr inbounds i8, i8* %argp.cur2, i32 4
61 // AIX32-NEXT:  store i8* %argp.next3, i8** %ap2, align 4
62 // AIX32-NEXT:  %5 = bitcast i8* %argp.cur2 to i32*
63 // AIX32-NEXT:  %6 = load i32, i32* %5, align 4
64 // AIX32-NEXT:  store i32 %6, i32* %v, align 4
65 // AIX64-NEXT:  %argp.cur2 = load i8*, i8** %ap2, align 8
66 // AIX64-NEXT:  %argp.next3 = getelementptr inbounds i8, i8* %argp.cur2, i64 8
67 // AIX64-NEXT:  store i8* %argp.next3, i8** %ap2, align 8
68 // AIX64-NEXT:  %5 = getelementptr inbounds i8, i8* %argp.cur2, i64 4
69 // AIX64-NEXT:  %6 = bitcast i8* %5 to i32*
70 // AIX64-NEXT:  %7 = load i32, i32* %6, align 4
71 // AIX64-NEXT:  store i32 %7, i32* %v, align 4
72 
73 // CHECK-NEXT:  %ap24 = bitcast i8** %ap2 to i8*
74 // CHECK-NEXT:  call void @llvm.va_end(i8* %ap24)
75 // CHECK-NEXT:  %ap5 = bitcast i8** %ap to i8*
76 // CHECK-NEXT:  call void @llvm.va_end(i8* %ap5)
77 // CHECK-NEXT:  ret void
78 
79 // CHECK: declare void @llvm.va_start(i8*)
80 
81 // AIX32: declare void @llvm.memcpy.p0i8.p0i8.i32(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i32, i1 immarg)
82 // AIX64: declare void @llvm.memcpy.p0i8.p0i8.i64(i8* noalias nocapture writeonly, i8* noalias nocapture readonly, i64, i1 immarg)
83 
84 // CHECK: declare void @llvm.va_copy(i8*, i8*)
85 // CHECK: declare void @llvm.va_end(i8*)
86