Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / complex-builtins.c
blobd2dca400c53b8c47cb76a87bbf6b98201180f799
1 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -o - -emit-llvm %s | FileCheck %s -check-prefix=NO__ERRNO
2 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -w -o - -emit-llvm -fmath-errno %s | FileCheck %s -check-prefix=HAS_ERRNO
4 // Test attributes and codegen of complex builtins.
6 void foo(float f) {
7 __builtin_cabs(f); __builtin_cabsf(f); __builtin_cabsl(f);
9 // NO__ERRNO: declare double @cabs(double noundef, double noundef) [[READNONE:#[0-9]+]]
10 // NO__ERRNO: declare float @cabsf(<2 x float> noundef) [[READNONE]]
11 // NO__ERRNO: declare x86_fp80 @cabsl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE:#[0-9]+]]
12 // HAS_ERRNO: declare double @cabs(double noundef, double noundef) [[NOT_READNONE:#[0-9]+]]
13 // HAS_ERRNO: declare float @cabsf(<2 x float> noundef) [[NOT_READNONE]]
14 // HAS_ERRNO: declare x86_fp80 @cabsl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
16 __builtin_cacos(f); __builtin_cacosf(f); __builtin_cacosl(f);
18 // NO__ERRNO: declare { double, double } @cacos(double noundef, double noundef) [[READNONE]]
19 // NO__ERRNO: declare <2 x float> @cacosf(<2 x float> noundef) [[READNONE]]
20 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @cacosl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
21 // HAS_ERRNO: declare { double, double } @cacos(double noundef, double noundef) [[NOT_READNONE]]
22 // HAS_ERRNO: declare <2 x float> @cacosf(<2 x float> noundef) [[NOT_READNONE]]
23 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @cacosl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
25 __builtin_cacosh(f); __builtin_cacoshf(f); __builtin_cacoshl(f);
27 // NO__ERRNO: declare { double, double } @cacosh(double noundef, double noundef) [[READNONE]]
28 // NO__ERRNO: declare <2 x float> @cacoshf(<2 x float> noundef) [[READNONE]]
29 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @cacoshl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
30 // HAS_ERRNO: declare { double, double } @cacosh(double noundef, double noundef) [[NOT_READNONE]]
31 // HAS_ERRNO: declare <2 x float> @cacoshf(<2 x float> noundef) [[NOT_READNONE]]
32 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @cacoshl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
34 __builtin_carg(f); __builtin_cargf(f); __builtin_cargl(f);
36 // NO__ERRNO: declare double @carg(double noundef, double noundef) [[READNONE]]
37 // NO__ERRNO: declare float @cargf(<2 x float> noundef) [[READNONE]]
38 // NO__ERRNO: declare x86_fp80 @cargl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
39 // HAS_ERRNO: declare double @carg(double noundef, double noundef) [[NOT_READNONE]]
40 // HAS_ERRNO: declare float @cargf(<2 x float> noundef) [[NOT_READNONE]]
41 // HAS_ERRNO: declare x86_fp80 @cargl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
43 __builtin_casin(f); __builtin_casinf(f); __builtin_casinl(f);
45 // NO__ERRNO: declare { double, double } @casin(double noundef, double noundef) [[READNONE]]
46 // NO__ERRNO: declare <2 x float> @casinf(<2 x float> noundef) [[READNONE]]
47 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @casinl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
48 // HAS_ERRNO: declare { double, double } @casin(double noundef, double noundef) [[NOT_READNONE]]
49 // HAS_ERRNO: declare <2 x float> @casinf(<2 x float> noundef) [[NOT_READNONE]]
50 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @casinl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
52 __builtin_casinh(f); __builtin_casinhf(f); __builtin_casinhl(f);
54 // NO__ERRNO: declare { double, double } @casinh(double noundef, double noundef) [[READNONE]]
55 // NO__ERRNO: declare <2 x float> @casinhf(<2 x float> noundef) [[READNONE]]
56 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @casinhl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
57 // HAS_ERRNO: declare { double, double } @casinh(double noundef, double noundef) [[NOT_READNONE]]
58 // HAS_ERRNO: declare <2 x float> @casinhf(<2 x float> noundef) [[NOT_READNONE]]
59 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @casinhl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
61 __builtin_catan(f); __builtin_catanf(f); __builtin_catanl(f);
63 // NO__ERRNO: declare { double, double } @catan(double noundef, double noundef) [[READNONE]]
64 // NO__ERRNO: declare <2 x float> @catanf(<2 x float> noundef) [[READNONE]]
65 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @catanl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
66 // HAS_ERRNO: declare { double, double } @catan(double noundef, double noundef) [[NOT_READNONE]]
67 // HAS_ERRNO: declare <2 x float> @catanf(<2 x float> noundef) [[NOT_READNONE]]
68 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @catanl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
70 __builtin_catanh(f); __builtin_catanhf(f); __builtin_catanhl(f);
72 // NO__ERRNO: declare { double, double } @catanh(double noundef, double noundef) [[READNONE]]
73 // NO__ERRNO: declare <2 x float> @catanhf(<2 x float> noundef) [[READNONE]]
74 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @catanhl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
75 // HAS_ERRNO: declare { double, double } @catanh(double noundef, double noundef) [[NOT_READNONE]]
76 // HAS_ERRNO: declare <2 x float> @catanhf(<2 x float> noundef) [[NOT_READNONE]]
77 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @catanhl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
79 __builtin_ccos(f); __builtin_ccosf(f); __builtin_ccosl(f);
81 // NO__ERRNO: declare { double, double } @ccos(double noundef, double noundef) [[READNONE]]
82 // NO__ERRNO: declare <2 x float> @ccosf(<2 x float> noundef) [[READNONE]]
83 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @ccosl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
84 // HAS_ERRNO: declare { double, double } @ccos(double noundef, double noundef) [[NOT_READNONE]]
85 // HAS_ERRNO: declare <2 x float> @ccosf(<2 x float> noundef) [[NOT_READNONE]]
86 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @ccosl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
88 __builtin_ccosh(f); __builtin_ccoshf(f); __builtin_ccoshl(f);
90 // NO__ERRNO: declare { double, double } @ccosh(double noundef, double noundef) [[READNONE]]
91 // NO__ERRNO: declare <2 x float> @ccoshf(<2 x float> noundef) [[READNONE]]
92 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @ccoshl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
93 // HAS_ERRNO: declare { double, double } @ccosh(double noundef, double noundef) [[NOT_READNONE]]
94 // HAS_ERRNO: declare <2 x float> @ccoshf(<2 x float> noundef) [[NOT_READNONE]]
95 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @ccoshl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
97 __builtin_cexp(f); __builtin_cexpf(f); __builtin_cexpl(f);
99 // NO__ERRNO: declare { double, double } @cexp(double noundef, double noundef) [[READNONE]]
100 // NO__ERRNO: declare <2 x float> @cexpf(<2 x float> noundef) [[READNONE]]
101 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @cexpl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
102 // HAS_ERRNO: declare { double, double } @cexp(double noundef, double noundef) [[NOT_READNONE]]
103 // HAS_ERRNO: declare <2 x float> @cexpf(<2 x float> noundef) [[NOT_READNONE]]
104 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @cexpl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
106 __builtin_cimag(f); __builtin_cimagf(f); __builtin_cimagl(f);
108 // NO__ERRNO-NOT: .cimag
109 // NO__ERRNO-NOT: @cimag
110 // HAS_ERRNO-NOT: .cimag
111 // HAS_ERRNO-NOT: @cimag
113 __builtin_conj(f); __builtin_conjf(f); __builtin_conjl(f);
115 // NO__ERRNO-NOT: .conj
116 // NO__ERRNO-NOT: @conj
117 // HAS_ERRNO-NOT: .conj
118 // HAS_ERRNO-NOT: @conj
120 __builtin_clog(f); __builtin_clogf(f); __builtin_clogl(f);
122 // NO__ERRNO: declare { double, double } @clog(double noundef, double noundef) [[READNONE]]
123 // NO__ERRNO: declare <2 x float> @clogf(<2 x float> noundef) [[READNONE]]
124 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @clogl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
125 // HAS_ERRNO: declare { double, double } @clog(double noundef, double noundef) [[NOT_READNONE]]
126 // HAS_ERRNO: declare <2 x float> @clogf(<2 x float> noundef) [[NOT_READNONE]]
127 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @clogl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
129 __builtin_cproj(f); __builtin_cprojf(f); __builtin_cprojl(f);
131 // NO__ERRNO: declare { double, double } @cproj(double noundef, double noundef) [[READNONE]]
132 // NO__ERRNO: declare <2 x float> @cprojf(<2 x float> noundef) [[READNONE]]
133 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @cprojl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
134 // HAS_ERRNO: declare { double, double } @cproj(double noundef, double noundef) [[READNONE:#[0-9]+]]
135 // HAS_ERRNO: declare <2 x float> @cprojf(<2 x float> noundef) [[READNONE]]
136 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @cprojl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[WILLRETURN_NOT_READNONE:#[0-9]+]]
138 __builtin_cpow(f,f); __builtin_cpowf(f,f); __builtin_cpowl(f,f);
140 // NO__ERRNO: declare { double, double } @cpow(double noundef, double noundef, double noundef, double noundef) [[READNONE]]
141 // NO__ERRNO: declare <2 x float> @cpowf(<2 x float> noundef, <2 x float> noundef) [[READNONE]]
142 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @cpowl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16, ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
143 // HAS_ERRNO: declare { double, double } @cpow(double noundef, double noundef, double noundef, double noundef) [[NOT_READNONE]]
144 // HAS_ERRNO: declare <2 x float> @cpowf(<2 x float> noundef, <2 x float> noundef) [[NOT_READNONE]]
145 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @cpowl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16, ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
147 __builtin_creal(f); __builtin_crealf(f); __builtin_creall(f);
149 // NO__ERRNO-NOT: .creal
150 // NO__ERRNO-NOT: @creal
151 // HAS_ERRNO-NOT: .creal
152 // HAS_ERRNO-NOT: @creal
154 __builtin_csin(f); __builtin_csinf(f); __builtin_csinl(f);
156 // NO__ERRNO: declare { double, double } @csin(double noundef, double noundef) [[READNONE]]
157 // NO__ERRNO: declare <2 x float> @csinf(<2 x float> noundef) [[READNONE]]
158 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @csinl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
159 // HAS_ERRNO: declare { double, double } @csin(double noundef, double noundef) [[NOT_READNONE]]
160 // HAS_ERRNO: declare <2 x float> @csinf(<2 x float> noundef) [[NOT_READNONE]]
161 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @csinl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
163 __builtin_csinh(f); __builtin_csinhf(f); __builtin_csinhl(f);
165 // NO__ERRNO: declare { double, double } @csinh(double noundef, double noundef) [[READNONE]]
166 // NO__ERRNO: declare <2 x float> @csinhf(<2 x float> noundef) [[READNONE]]
167 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @csinhl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
168 // HAS_ERRNO: declare { double, double } @csinh(double noundef, double noundef) [[NOT_READNONE]]
169 // HAS_ERRNO: declare <2 x float> @csinhf(<2 x float> noundef) [[NOT_READNONE]]
170 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @csinhl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
172 __builtin_csqrt(f); __builtin_csqrtf(f); __builtin_csqrtl(f);
174 // NO__ERRNO: declare { double, double } @csqrt(double noundef, double noundef) [[READNONE]]
175 // NO__ERRNO: declare <2 x float> @csqrtf(<2 x float> noundef) [[READNONE]]
176 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @csqrtl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
177 // HAS_ERRNO: declare { double, double } @csqrt(double noundef, double noundef) [[NOT_READNONE]]
178 // HAS_ERRNO: declare <2 x float> @csqrtf(<2 x float> noundef) [[NOT_READNONE]]
179 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @csqrtl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
181 __builtin_ctan(f); __builtin_ctanf(f); __builtin_ctanl(f);
183 // NO__ERRNO: declare { double, double } @ctan(double noundef, double noundef) [[READNONE]]
184 // NO__ERRNO: declare <2 x float> @ctanf(<2 x float> noundef) [[READNONE]]
185 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @ctanl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
186 // HAS_ERRNO: declare { double, double } @ctan(double noundef, double noundef) [[NOT_READNONE]]
187 // HAS_ERRNO: declare <2 x float> @ctanf(<2 x float> noundef) [[NOT_READNONE]]
188 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @ctanl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
190 __builtin_ctanh(f); __builtin_ctanhf(f); __builtin_ctanhl(f);
192 // NO__ERRNO: declare { double, double } @ctanh(double noundef, double noundef) [[READNONE]]
193 // NO__ERRNO: declare <2 x float> @ctanhf(<2 x float> noundef) [[READNONE]]
194 // NO__ERRNO: declare { x86_fp80, x86_fp80 } @ctanhl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
195 // HAS_ERRNO: declare { double, double } @ctanh(double noundef, double noundef) [[NOT_READNONE]]
196 // HAS_ERRNO: declare <2 x float> @ctanhf(<2 x float> noundef) [[NOT_READNONE]]
197 // HAS_ERRNO: declare { x86_fp80, x86_fp80 } @ctanhl(ptr noundef byval({ x86_fp80, x86_fp80 }) align 16) [[NOT_READNONE]]
200 // NO__ERRNO: attributes [[READNONE]] = { {{.*}}memory(none){{.*}} }
201 // NO__ERRNO: attributes [[NOT_READNONE]] = { nounwind {{.*}} }
203 // HAS_ERRNO: attributes [[NOT_READNONE]] = { nounwind {{.*}} }
204 // HAS_ERRNO: attributes [[READNONE]] = { {{.*}}memory(none){{.*}} }
205 // HAS_ERRNO: attributes [[WILLRETURN_NOT_READNONE]] = { nounwind willreturn {{.*}} }