[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CodeGen / extend-arg-64.c
blob2cb56d35af21dcfaab13cf00a5d309bd51a05612
1 // RUN: %clang_cc1 -DD128 -triple x86_64-apple-darwin -fextend-arguments=64 \
2 // RUN: -Wno-strict-prototypes %s -emit-llvm -o - | FileCheck %s -check-prefix=CHECKEXT
4 // When the option isn't selected, no effect
5 // RUN: %clang_cc1 -DD128 -triple x86_64-apple-darwin \
6 // RUN: -Wno-strict-prototypes %s -emit-llvm -o - | FileCheck %s \
7 // RUN: --implicit-check-not "ext {{.*}}to i64"
9 // The option isn't supported on x86, no effect
10 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -fextend-arguments=64 \
11 // RUN: -Wno-strict-prototypes %s -emit-llvm -o - | FileCheck %s \
12 // RUN: --implicit-check-not "ext {{.*}}to i64"
14 // The option isn't supported on ppc, no effect
15 // RUN: %clang_cc1 -triple ppc64le -fextend-arguments=64 \
16 // RUN: -Wno-strict-prototypes %s -emit-llvm -o - | FileCheck %s \
17 // RUN: --implicit-check-not "ext {{.*}}to i64"
19 // The option isn't supported on ppc, no effect
20 // RUN: %clang_cc1 -DD128 -triple powerpc64-ibm-aix-xcoff -fextend-arguments=64 \
21 // RUN: -Wno-strict-prototypes %s -emit-llvm -o - | FileCheck %s \
22 // RUN: --implicit-check-not "ext {{.*}}to i64"
25 int vararg(int, ...);
26 void knr();
28 unsigned int u32;
29 int s32;
30 unsigned short u16;
31 short s16;
32 unsigned char u8;
33 signed char s8;
34 long long ll;
35 _BitInt(23) ei23;
36 float ff;
37 double dd;
38 #ifdef D128
39 __int128 i128;
40 #endif
42 int test(void) {
43 // CHECK: define{{.*}} i32 @test{{.*}}
45 // CHECKEXT: [[TAG_u32:%.*]] = load i32, ptr @u32{{.*}}
46 // CHECKEXT: [[CONV_u32:%.*]] = zext i32 [[TAG_u32]] to i64
48 // CHECKEXT: [[TAG_s32:%.*]] = load i32, ptr @s32
49 // CHECKEXT: [[CONV_s32:%.*]] = sext i32 [[TAG_s32]] to i64
51 // CHECKEXT: [[TAG_u16:%.*]] = load i16, ptr @u16
52 // CHECKEXT: [[CONV_u16:%.*]] = zext i16 [[TAG_u16]] to i64
54 // CHECKEXT: [[TAG_s16:%.*]] = load i16, ptr @s16
55 // CHECKEXT: [[CONV_s16:%.*]] = sext i16 [[TAG_s16]] to i64
57 // CHECKEXT: [[TAG_u8:%.*]] = load i8, ptr @u8
58 // CHECKEXT: [[CONV_u8:%.*]] = zext i8 [[TAG_u8]] to i64
60 // CHECKEXT: [[TAG_s8:%.*]] = load i8, ptr @s8
61 // CHECKEXT: [[CONV_s8:%.*]] = sext i8 [[TAG_s8]] to i64
62 // CHECKEXT: call{{.*}} @vararg(i32 noundef %0, i64 noundef [[CONV_u32]], i64 noundef [[CONV_s32]], i64 noundef [[CONV_u16]], i64 noundef [[CONV_s16]], i64 noundef [[CONV_u8]], i64 noundef [[CONV_s8]]
64 int sum = 0;
65 sum = vararg(sum, u32, s32, u16, s16, u8, s8);
66 knr(ll);
67 // CHECKEXT: load i64, ptr @ll
68 // CHECKEXT-NEXT: call void (i64, ...) @knr
70 knr(ei23);
71 // CHECKEXT: load i32, ptr @ei23
72 // CHECKEXT: trunc i32
73 // CHECKEXT-NEXT: call void (i23, ...) @knr
75 knr(ff);
76 // CHECKEXT: load float
77 // CHECKEXT-NEXT: fpext float {{.*}} to double
78 // CHECKEXT-NEXT: call{{.*}} void (double, ...) @knr
80 knr(dd);
81 // CHECKEXT: load double
82 // CHECKEXT-NEXT: call{{.*}} void (double, ...) @knr
84 #ifdef D128
85 knr(i128);
86 // CHECKEXT: load i128
87 // CHECKEXT: call{{.*}} void (i64, i64, ...) @knr
88 #endif
90 knr(u32, s32, u16, s16, u8, s8);
91 // CHECKEXT: [[TAg_u32:%.*]] = load i32, ptr @u32{{.*}}
92 // CHECKEXT: [[CONv_u32:%.*]] = zext i32 [[TAg_u32]] to i64
94 // CHECKEXT: [[TAg_s32:%.*]] = load i32, ptr @s32
95 // CHECKEXT: [[CONv_s32:%.*]] = sext i32 [[TAg_s32]] to i64
97 // CHECKEXT: [[TAg_u16:%.*]] = load i16, ptr @u16
98 // CHECKEXT: [[CONv_u16:%.*]] = zext i16 [[TAg_u16]] to i64
100 // CHECKEXT: [[TAg_s16:%.*]] = load i16, ptr @s16
101 // CHECKEXT: [[CONv_s16:%.*]] = sext i16 [[TAg_s16]] to i64
103 // CHECKEXT: [[TAg_u8:%.*]] = load i8, ptr @u8
104 // CHECKEXT: [[CONv_u8:%.*]] = zext i8 [[TAg_u8]] to i64
106 // CHECKEXT: [[TAg_s8:%.*]] = load i8, ptr @s8
107 // CHECKEXT: [[CONv_s8:%.*]] = sext i8 [[TAg_s8]] to i64
108 // CHECKEXT: call{{.*}} void (i64, i64, i64, i64, i64, i64, ...) @knr
109 return sum;