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