annotate clang/test/CodeGen/ppc-varargs-struct.c @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // REQUIRES: powerpc-registered-target
anatofuz
parents:
diff changeset
2 // REQUIRES: asserts
anatofuz
parents:
diff changeset
3 // RUN: %clang_cc1 -triple powerpc64-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s
anatofuz
parents:
diff changeset
4 // RUN: %clang_cc1 -triple powerpc-unknown-linux-gnu -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-PPC
anatofuz
parents:
diff changeset
5
anatofuz
parents:
diff changeset
6 #include <stdarg.h>
anatofuz
parents:
diff changeset
7
anatofuz
parents:
diff changeset
8 struct x {
anatofuz
parents:
diff changeset
9 long a;
anatofuz
parents:
diff changeset
10 double b;
anatofuz
parents:
diff changeset
11 };
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 void testva (int n, ...)
anatofuz
parents:
diff changeset
14 {
anatofuz
parents:
diff changeset
15 va_list ap;
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 struct x t = va_arg (ap, struct x);
anatofuz
parents:
diff changeset
18 // CHECK: bitcast i8* %{{[a-z.0-9]*}} to %struct.x*
anatofuz
parents:
diff changeset
19 // CHECK: bitcast %struct.x* %t to i8*
anatofuz
parents:
diff changeset
20 // CHECK: bitcast %struct.x* %{{[0-9]+}} to i8*
anatofuz
parents:
diff changeset
21 // CHECK: call void @llvm.memcpy
anatofuz
parents:
diff changeset
22
anatofuz
parents:
diff changeset
23 // CHECK-PPC: [[ARRAYDECAY:%.+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %ap, i32 0, i32 0
anatofuz
parents:
diff changeset
24 // CHECK-PPC-NEXT: [[GPRPTR:%.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* [[ARRAYDECAY]], i32 0, i32 0
anatofuz
parents:
diff changeset
25 // CHECK-PPC-NEXT: [[GPR:%.+]] = load i8, i8* [[GPRPTR]], align 4
anatofuz
parents:
diff changeset
26 // CHECK-PPC-NEXT: [[COND:%.+]] = icmp ult i8 [[GPR]], 8
anatofuz
parents:
diff changeset
27 // CHECK-PPC-NEXT: br i1 [[COND]], label %[[USING_REGS:[a-z_0-9]+]], label %[[USING_OVERFLOW:[a-z_0-9]+]]
anatofuz
parents:
diff changeset
28 //
anatofuz
parents:
diff changeset
29 // CHECK-PPC:[[USING_REGS]]
anatofuz
parents:
diff changeset
30 // CHECK-PPC-NEXT: [[REGSAVE_AREA_P:%.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* [[ARRAYDECAY]], i32 0, i32 4
anatofuz
parents:
diff changeset
31 // CHECK-PPC-NEXT: [[REGSAVE_AREA:%.+]] = load i8*, i8** [[REGSAVE_AREA_P]], align 4
anatofuz
parents:
diff changeset
32 // CHECK-PPC-NEXT: [[OFFSET:%.+]] = mul i8 [[GPR]], 4
anatofuz
parents:
diff changeset
33 // CHECK-PPC-NEXT: [[RAW_REGADDR:%.+]] = getelementptr inbounds i8, i8* [[REGSAVE_AREA]], i8 [[OFFSET]]
anatofuz
parents:
diff changeset
34 // CHECK-PPC-NEXT: [[REGADDR:%.+]] = bitcast i8* [[RAW_REGADDR]] to %struct.x**
anatofuz
parents:
diff changeset
35 // CHECK-PPC-NEXT: [[USED_GPR:%[0-9]+]] = add i8 [[GPR]], 1
anatofuz
parents:
diff changeset
36 // CHECK-PPC-NEXT: store i8 [[USED_GPR]], i8* [[GPRPTR]], align 4
anatofuz
parents:
diff changeset
37 // CHECK-PPC-NEXT: br label %[[CONT:[a-z0-9]+]]
anatofuz
parents:
diff changeset
38 //
anatofuz
parents:
diff changeset
39 // CHECK-PPC:[[USING_OVERFLOW]]
anatofuz
parents:
diff changeset
40 // CHECK-PPC-NEXT: store i8 8, i8* [[GPRPTR]], align 4
anatofuz
parents:
diff changeset
41 // CHECK-PPC-NEXT: [[OVERFLOW_AREA_P:%[0-9]+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* [[ARRAYDECAY]], i32 0, i32 3
anatofuz
parents:
diff changeset
42 // CHECK-PPC-NEXT: [[OVERFLOW_AREA:%.+]] = load i8*, i8** [[OVERFLOW_AREA_P]], align 4
anatofuz
parents:
diff changeset
43 // CHECK-PPC-NEXT: %{{[0-9]+}} = ptrtoint i8* %argp.cur to i32
anatofuz
parents:
diff changeset
44 // CHECK-PPC-NEXT: %{{[0-9]+}} = add i32 %{{[0-9]+}}, 7
anatofuz
parents:
diff changeset
45 // CHECK-PPC-NEXT: %{{[0-9]+}} = and i32 %{{[0-9]+}}, -8
anatofuz
parents:
diff changeset
46 // CHECK-PPC-NEXT: %argp.cur.aligned = inttoptr i32 %{{[0-9]+}} to i8*
anatofuz
parents:
diff changeset
47 // CHECK-PPC-NEXT: [[MEMADDR:%.+]] = bitcast i8* %argp.cur.aligned to %struct.x**
anatofuz
parents:
diff changeset
48 // CHECK-PPC-NEXT: [[NEW_OVERFLOW_AREA:%[0-9]+]] = getelementptr inbounds i8, i8* %argp.cur.aligned, i32 4
anatofuz
parents:
diff changeset
49 // CHECK-PPC-NEXT: store i8* [[NEW_OVERFLOW_AREA:%[0-9]+]], i8** [[OVERFLOW_AREA_P]], align 4
anatofuz
parents:
diff changeset
50 // CHECK-PPC-NEXT: br label %[[CONT]]
anatofuz
parents:
diff changeset
51 //
anatofuz
parents:
diff changeset
52 // CHECK-PPC:[[CONT]]
anatofuz
parents:
diff changeset
53 // CHECK-PPC-NEXT: [[VAARG_ADDR:%[a-z.0-9]+]] = phi %struct.x** [ [[REGADDR]], %[[USING_REGS]] ], [ [[MEMADDR]], %[[USING_OVERFLOW]] ]
anatofuz
parents:
diff changeset
54 // CHECK-PPC-NEXT: [[AGGR:%[a-z0-9]+]] = load %struct.x*, %struct.x** [[VAARG_ADDR]]
anatofuz
parents:
diff changeset
55 // CHECK-PPC-NEXT: [[DEST:%[0-9]+]] = bitcast %struct.x* %t to i8*
anatofuz
parents:
diff changeset
56 // CHECK-PPC-NEXT: [[SRC:%.+]] = bitcast %struct.x* [[AGGR]] to i8*
anatofuz
parents:
diff changeset
57 // CHECK-PPC-NEXT: call void @llvm.memcpy.p0i8.p0i8.i32(i8* align 8 [[DEST]], i8* align 8 [[SRC]], i32 16, i1 false)
anatofuz
parents:
diff changeset
58
anatofuz
parents:
diff changeset
59 int v = va_arg (ap, int);
anatofuz
parents:
diff changeset
60
anatofuz
parents:
diff changeset
61 // CHECK: getelementptr inbounds i8, i8* %{{[a-z.0-9]*}}, i64 4
anatofuz
parents:
diff changeset
62 // CHECK: bitcast i8* %{{[0-9]+}} to i32*
anatofuz
parents:
diff changeset
63 // CHECK-PPC: [[ARRAYDECAY:%[a-z0-9]+]] = getelementptr inbounds [1 x %struct.__va_list_tag], [1 x %struct.__va_list_tag]* %ap, i32 0, i32 0
anatofuz
parents:
diff changeset
64 // CHECK-PPC-NEXT: [[GPRPTR:%.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* [[ARRAYDECAY]], i32 0, i32 0
anatofuz
parents:
diff changeset
65 // CHECK-PPC-NEXT: [[GPR:%.+]] = load i8, i8* [[GPRPTR]], align 4
anatofuz
parents:
diff changeset
66 // CHECK-PPC-NEXT: [[COND:%.+]] = icmp ult i8 [[GPR]], 8
anatofuz
parents:
diff changeset
67 // CHECK-PPC-NEXT: br i1 [[COND]], label %[[USING_REGS:.+]], label %[[USING_OVERFLOW:.+]]{{$}}
anatofuz
parents:
diff changeset
68 //
anatofuz
parents:
diff changeset
69 // CHECK-PPC:[[USING_REGS]]
anatofuz
parents:
diff changeset
70 // CHECK-PPC-NEXT: [[REGSAVE_AREA_P:%.+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* [[ARRAYDECAY]], i32 0, i32 4
anatofuz
parents:
diff changeset
71 // CHECK-PPC-NEXT: [[REGSAVE_AREA:%.+]] = load i8*, i8** [[REGSAVE_AREA_P]], align 4
anatofuz
parents:
diff changeset
72 // CHECK-PPC-NEXT: [[OFFSET:%.+]] = mul i8 [[GPR]], 4
anatofuz
parents:
diff changeset
73 // CHECK-PPC-NEXT: [[RAW_REGADDR:%.+]] = getelementptr inbounds i8, i8* [[REGSAVE_AREA]], i8 [[OFFSET]]
anatofuz
parents:
diff changeset
74 // CHECK-PPC-NEXT: [[REGADDR:%.+]] = bitcast i8* [[RAW_REGADDR]] to i32*
anatofuz
parents:
diff changeset
75 // CHECK-PPC-NEXT: [[USED_GPR:%[0-9]+]] = add i8 [[GPR]], 1
anatofuz
parents:
diff changeset
76 // CHECK-PPC-NEXT: store i8 [[USED_GPR]], i8* [[GPRPTR]], align 4
anatofuz
parents:
diff changeset
77 // CHECK-PPC-NEXT: br label %[[CONT:[a-z0-9]+]]
anatofuz
parents:
diff changeset
78 //
anatofuz
parents:
diff changeset
79 // CHECK-PPC:[[USING_OVERFLOW]]
anatofuz
parents:
diff changeset
80 // CHECK-PPC-NEXT: store i8 8, i8* [[GPRPTR]], align 4
anatofuz
parents:
diff changeset
81 // CHECK-PPC-NEXT: [[OVERFLOW_AREA_P:%[0-9]+]] = getelementptr inbounds %struct.__va_list_tag, %struct.__va_list_tag* [[ARRAYDECAY]], i32 0, i32 3
anatofuz
parents:
diff changeset
82 // CHECK-PPC-NEXT: [[OVERFLOW_AREA:%.+]] = load i8*, i8** [[OVERFLOW_AREA_P]], align 4
anatofuz
parents:
diff changeset
83 // CHECK-PPC-NEXT: [[MEMADDR:%.+]] = bitcast i8* [[OVERFLOW_AREA]] to i32*
anatofuz
parents:
diff changeset
84 // CHECK-PPC-NEXT: [[NEW_OVERFLOW_AREA:%[0-9]+]] = getelementptr inbounds i8, i8* [[OVERFLOW_AREA]], i32 4
anatofuz
parents:
diff changeset
85 // CHECK-PPC-NEXT: store i8* [[NEW_OVERFLOW_AREA]], i8** [[OVERFLOW_AREA_P]]
anatofuz
parents:
diff changeset
86 // CHECK-PPC-NEXT: br label %[[CONT]]
anatofuz
parents:
diff changeset
87 //
anatofuz
parents:
diff changeset
88 // CHECK-PPC:[[CONT]]
anatofuz
parents:
diff changeset
89 // CHECK-PPC-NEXT: [[VAARG_ADDR:%[a-z.0-9]+]] = phi i32* [ [[REGADDR]], %[[USING_REGS]] ], [ [[MEMADDR]], %[[USING_OVERFLOW]] ]
anatofuz
parents:
diff changeset
90 // CHECK-PPC-NEXT: [[THIRTYFIVE:%[0-9]+]] = load i32, i32* [[VAARG_ADDR]]
anatofuz
parents:
diff changeset
91 // CHECK-PPC-NEXT: store i32 [[THIRTYFIVE]], i32* %v, align 4
anatofuz
parents:
diff changeset
92
anatofuz
parents:
diff changeset
93 #ifdef __powerpc64__
anatofuz
parents:
diff changeset
94 __int128_t u = va_arg (ap, __int128_t);
anatofuz
parents:
diff changeset
95 #endif
anatofuz
parents:
diff changeset
96 // CHECK: bitcast i8* %{{[a-z.0-9]+}} to i128*
anatofuz
parents:
diff changeset
97 // CHECK-NEXT: load i128, i128* %{{[0-9]+}}
anatofuz
parents:
diff changeset
98 }