1 //===--- TargetLibraryInfoTest.cpp - TLI/LibFunc unit tests ---------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "llvm/Analysis/TargetLibraryInfo.h"
10 #include "llvm/AsmParser/Parser.h"
11 #include "llvm/IR/LLVMContext.h"
12 #include "llvm/IR/LegacyPassManager.h"
13 #include "llvm/IR/Module.h"
14 #include "llvm/Support/SourceMgr.h"
15 #include "gtest/gtest.h"
21 class TargetLibraryInfoTest
: public testing::Test
{
24 TargetLibraryInfoImpl TLII
;
25 TargetLibraryInfo TLI
;
27 std::unique_ptr
<Module
> M
;
29 TargetLibraryInfoTest() : TLI(TLII
) {}
31 void parseAssembly(const char *Assembly
) {
33 M
= parseAssemblyString(Assembly
, Error
, Context
);
36 raw_string_ostream
os(errMsg
);
40 report_fatal_error(Twine(os
.str()));
43 ::testing::AssertionResult
isLibFunc(const Function
*FDecl
,
45 StringRef ExpectedLFName
= TLI
.getName(ExpectedLF
);
48 return ::testing::AssertionFailure() << ExpectedLFName
<< " not found";
51 if (!TLI
.getLibFunc(*FDecl
, F
))
52 return ::testing::AssertionFailure() << ExpectedLFName
<< " invalid";
54 return ::testing::AssertionSuccess() << ExpectedLFName
<< " is LibFunc";
58 } // end anonymous namespace
60 // Check that we don't accept egregiously incorrect prototypes.
61 TEST_F(TargetLibraryInfoTest
, InvalidProto
) {
62 parseAssembly("%foo = type { %foo }\n");
64 auto *StructTy
= StructType::getTypeByName(Context
, "foo");
65 auto *InvalidFTy
= FunctionType::get(StructTy
, /*isVarArg=*/false);
67 for (unsigned FI
= 0; FI
!= LibFunc::NumLibFuncs
; ++FI
) {
68 LibFunc LF
= (LibFunc
)FI
;
69 auto *F
= cast
<Function
>(
70 M
->getOrInsertFunction(TLI
.getName(LF
), InvalidFTy
).getCallee());
71 EXPECT_FALSE(isLibFunc(F
, LF
));
75 // Check that we do accept know-correct prototypes.
76 TEST_F(TargetLibraryInfoTest
, ValidProto
) {
78 // These functions use a 64-bit size_t; use the appropriate datalayout.
79 "target datalayout = \"p:64:64:64\"\n"
81 // Struct pointers are replaced with an opaque pointer.
82 "%struct = type opaque\n"
84 // These functions were extracted as-is from the OS X headers.
85 "declare double @__cospi(double)\n"
86 "declare float @__cospif(float)\n"
87 "declare { double, double } @__sincospi_stret(double)\n"
88 "declare <2 x float> @__sincospif_stret(float)\n"
89 "declare double @__sinpi(double)\n"
90 "declare float @__sinpif(float)\n"
91 "declare i32 @abs(i32)\n"
92 "declare i32 @access(i8*, i32)\n"
93 "declare double @acos(double)\n"
94 "declare float @acosf(float)\n"
95 "declare double @acosh(double)\n"
96 "declare float @acoshf(float)\n"
97 "declare x86_fp80 @acoshl(x86_fp80)\n"
98 "declare x86_fp80 @acosl(x86_fp80)\n"
99 "declare i8* @aligned_alloc(i64, i64)\n"
100 "declare double @asin(double)\n"
101 "declare float @asinf(float)\n"
102 "declare double @asinh(double)\n"
103 "declare float @asinhf(float)\n"
104 "declare x86_fp80 @asinhl(x86_fp80)\n"
105 "declare x86_fp80 @asinl(x86_fp80)\n"
106 "declare double @atan(double)\n"
107 "declare double @atan2(double, double)\n"
108 "declare float @atan2f(float, float)\n"
109 "declare x86_fp80 @atan2l(x86_fp80, x86_fp80)\n"
110 "declare float @atanf(float)\n"
111 "declare double @atanh(double)\n"
112 "declare float @atanhf(float)\n"
113 "declare x86_fp80 @atanhl(x86_fp80)\n"
114 "declare x86_fp80 @atanl(x86_fp80)\n"
115 "declare double @atof(i8*)\n"
116 "declare i32 @atoi(i8*)\n"
117 "declare i64 @atol(i8*)\n"
118 "declare i64 @atoll(i8*)\n"
119 "declare i32 @bcmp(i8*, i8*, i64)\n"
120 "declare void @bcopy(i8*, i8*, i64)\n"
121 "declare void @bzero(i8*, i64)\n"
122 "declare i8* @calloc(i64, i64)\n"
123 "declare double @cbrt(double)\n"
124 "declare float @cbrtf(float)\n"
125 "declare x86_fp80 @cbrtl(x86_fp80)\n"
126 "declare double @ceil(double)\n"
127 "declare float @ceilf(float)\n"
128 "declare x86_fp80 @ceill(x86_fp80)\n"
129 "declare i32 @chown(i8*, i32, i32)\n"
130 "declare void @clearerr(%struct*)\n"
131 "declare double @copysign(double, double)\n"
132 "declare float @copysignf(float, float)\n"
133 "declare x86_fp80 @copysignl(x86_fp80, x86_fp80)\n"
134 "declare double @cabs([2 x double])\n"
135 "declare float @cabsf([2 x float])\n"
136 "declare x86_fp80 @cabsl([2 x x86_fp80])\n"
137 "declare double @cos(double)\n"
138 "declare float @cosf(float)\n"
139 "declare double @cosh(double)\n"
140 "declare float @coshf(float)\n"
141 "declare x86_fp80 @coshl(x86_fp80)\n"
142 "declare x86_fp80 @cosl(x86_fp80)\n"
143 "declare i8* @ctermid(i8*)\n"
144 "declare double @exp(double)\n"
145 "declare double @exp2(double)\n"
146 "declare float @exp2f(float)\n"
147 "declare x86_fp80 @exp2l(x86_fp80)\n"
148 "declare float @expf(float)\n"
149 "declare x86_fp80 @expl(x86_fp80)\n"
150 "declare double @expm1(double)\n"
151 "declare float @expm1f(float)\n"
152 "declare x86_fp80 @expm1l(x86_fp80)\n"
153 "declare double @fabs(double)\n"
154 "declare float @fabsf(float)\n"
155 "declare x86_fp80 @fabsl(x86_fp80)\n"
156 "declare i32 @fclose(%struct*)\n"
157 "declare i32 @feof(%struct*)\n"
158 "declare i32 @ferror(%struct*)\n"
159 "declare i32 @fflush(%struct*)\n"
160 "declare i32 @ffs(i32)\n"
161 "declare i32 @ffsl(i64)\n"
162 "declare i32 @ffsll(i64)\n"
163 "declare i32 @fgetc(%struct*)\n"
164 "declare i32 @fgetc_unlocked(%struct*)\n"
165 "declare i32 @fgetpos(%struct*, i64*)\n"
166 "declare i8* @fgets(i8*, i32, %struct*)\n"
167 "declare i8* @fgets_unlocked(i8*, i32, %struct*)\n"
168 "declare i32 @fileno(%struct*)\n"
169 "declare void @flockfile(%struct*)\n"
170 "declare double @floor(double)\n"
171 "declare float @floorf(float)\n"
172 "declare x86_fp80 @floorl(x86_fp80)\n"
173 "declare i32 @fls(i32)\n"
174 "declare i32 @flsl(i64)\n"
175 "declare i32 @flsll(i64)\n"
176 "declare double @fmax(double, double)\n"
177 "declare float @fmaxf(float, float)\n"
178 "declare x86_fp80 @fmaxl(x86_fp80, x86_fp80)\n"
179 "declare double @fmin(double, double)\n"
180 "declare float @fminf(float, float)\n"
181 "declare x86_fp80 @fminl(x86_fp80, x86_fp80)\n"
182 "declare double @fmod(double, double)\n"
183 "declare float @fmodf(float, float)\n"
184 "declare x86_fp80 @fmodl(x86_fp80, x86_fp80)\n"
185 "declare i32 @fprintf(%struct*, i8*, ...)\n"
186 "declare i32 @fputc(i32, %struct*)\n"
187 "declare i32 @fputc_unlocked(i32, %struct*)\n"
188 "declare i64 @fread(i8*, i64, i64, %struct*)\n"
189 "declare i64 @fread_unlocked(i8*, i64, i64, %struct*)\n"
190 "declare void @free(i8*)\n"
191 "declare double @frexp(double, i32*)\n"
192 "declare float @frexpf(float, i32*)\n"
193 "declare x86_fp80 @frexpl(x86_fp80, i32*)\n"
194 "declare i32 @fscanf(%struct*, i8*, ...)\n"
195 "declare i32 @fseek(%struct*, i64, i32)\n"
196 "declare i32 @fseeko(%struct*, i64, i32)\n"
197 "declare i32 @fsetpos(%struct*, i64*)\n"
198 "declare i32 @fstatvfs(i32, %struct*)\n"
199 "declare i64 @ftell(%struct*)\n"
200 "declare i64 @ftello(%struct*)\n"
201 "declare i32 @ftrylockfile(%struct*)\n"
202 "declare void @funlockfile(%struct*)\n"
203 "declare i32 @getc(%struct*)\n"
204 "declare i32 @getc_unlocked(%struct*)\n"
205 "declare i32 @getchar()\n"
206 "declare i32 @getchar_unlocked()\n"
207 "declare i8* @getenv(i8*)\n"
208 "declare i32 @getitimer(i32, %struct*)\n"
209 "declare i32 @getlogin_r(i8*, i64)\n"
210 "declare %struct* @getpwnam(i8*)\n"
211 "declare i8* @gets(i8*)\n"
212 "declare i32 @gettimeofday(%struct*, i8*)\n"
213 "declare i32 @_Z7isasciii(i32)\n"
214 "declare i32 @_Z7isdigiti(i32)\n"
215 "declare i64 @labs(i64)\n"
216 "declare double @ldexp(double, i32)\n"
217 "declare float @ldexpf(float, i32)\n"
218 "declare x86_fp80 @ldexpl(x86_fp80, i32)\n"
219 "declare i64 @llabs(i64)\n"
220 "declare double @log(double)\n"
221 "declare double @log10(double)\n"
222 "declare float @log10f(float)\n"
223 "declare x86_fp80 @log10l(x86_fp80)\n"
224 "declare double @log1p(double)\n"
225 "declare float @log1pf(float)\n"
226 "declare x86_fp80 @log1pl(x86_fp80)\n"
227 "declare double @log2(double)\n"
228 "declare float @log2f(float)\n"
229 "declare x86_fp80 @log2l(x86_fp80)\n"
230 "declare double @logb(double)\n"
231 "declare float @logbf(float)\n"
232 "declare x86_fp80 @logbl(x86_fp80)\n"
233 "declare float @logf(float)\n"
234 "declare x86_fp80 @logl(x86_fp80)\n"
235 "declare i8* @malloc(i64)\n"
236 "declare i8* @memccpy(i8*, i8*, i32, i64)\n"
237 "declare i8* @memchr(i8*, i32, i64)\n"
238 "declare i32 @memcmp(i8*, i8*, i64)\n"
239 "declare i8* @memcpy(i8*, i8*, i64)\n"
240 "declare i8* @memmove(i8*, i8*, i64)\n"
241 "declare i8* @memset(i8*, i32, i64)\n"
242 "declare void @memset_pattern16(i8*, i8*, i64)\n"
243 "declare void @memset_pattern4(i8*, i8*, i64)\n"
244 "declare void @memset_pattern8(i8*, i8*, i64)\n"
245 "declare i32 @mkdir(i8*, i16)\n"
246 "declare double @modf(double, double*)\n"
247 "declare float @modff(float, float*)\n"
248 "declare x86_fp80 @modfl(x86_fp80, x86_fp80*)\n"
249 "declare double @nearbyint(double)\n"
250 "declare float @nearbyintf(float)\n"
251 "declare x86_fp80 @nearbyintl(x86_fp80)\n"
252 "declare i32 @pclose(%struct*)\n"
253 "declare void @perror(i8*)\n"
254 "declare i32 @posix_memalign(i8**, i64, i64)\n"
255 "declare double @pow(double, double)\n"
256 "declare float @powf(float, float)\n"
257 "declare x86_fp80 @powl(x86_fp80, x86_fp80)\n"
258 "declare i32 @printf(i8*, ...)\n"
259 "declare i32 @putc(i32, %struct*)\n"
260 "declare i32 @putc_unlocked(i32, %struct*)\n"
261 "declare i32 @putchar(i32)\n"
262 "declare i32 @putchar_unlocked(i32)\n"
263 "declare i32 @puts(i8*)\n"
264 "declare void @qsort(i8*, i64, i64, i32 (i8*, i8*)*)\n"
265 "declare i64 @readlink(i8*, i8*, i64)\n"
266 "declare i8* @realloc(i8*, i64)\n"
267 "declare i8* @reallocf(i8*, i64)\n"
268 "declare double @remainder(double, double)\n"
269 "declare float @remainderf(float, float)\n"
270 "declare x86_fp80 @remainderl(x86_fp80, x86_fp80)\n"
271 "declare i32 @remove(i8*)\n"
272 "declare i32 @rename(i8*, i8*)\n"
273 "declare void @rewind(%struct*)\n"
274 "declare double @rint(double)\n"
275 "declare float @rintf(float)\n"
276 "declare x86_fp80 @rintl(x86_fp80)\n"
277 "declare i32 @rmdir(i8*)\n"
278 "declare double @round(double)\n"
279 "declare float @roundf(float)\n"
280 "declare x86_fp80 @roundl(x86_fp80)\n"
281 "declare double @roundeven(double)\n"
282 "declare float @roundevenf(float)\n"
283 "declare x86_fp80 @roundevenl(x86_fp80)\n"
284 "declare i32 @scanf(i8*, ...)\n"
285 "declare void @setbuf(%struct*, i8*)\n"
286 "declare i32 @setitimer(i32, %struct*, %struct*)\n"
287 "declare i32 @setvbuf(%struct*, i8*, i32, i64)\n"
288 "declare double @sin(double)\n"
289 "declare float @sinf(float)\n"
290 "declare double @sinh(double)\n"
291 "declare float @sinhf(float)\n"
292 "declare x86_fp80 @sinhl(x86_fp80)\n"
293 "declare x86_fp80 @sinl(x86_fp80)\n"
294 "declare i32 @snprintf(i8*, i64, i8*, ...)\n"
295 "declare i32 @sprintf(i8*, i8*, ...)\n"
296 "declare double @sqrt(double)\n"
297 "declare float @sqrtf(float)\n"
298 "declare x86_fp80 @sqrtl(x86_fp80)\n"
299 "declare i32 @sscanf(i8*, i8*, ...)\n"
300 "declare i32 @statvfs(i8*, %struct*)\n"
301 "declare i8* @stpcpy(i8*, i8*)\n"
302 "declare i8* @stpncpy(i8*, i8*, i64)\n"
303 "declare i32 @strcasecmp(i8*, i8*)\n"
304 "declare i8* @strcat(i8*, i8*)\n"
305 "declare i8* @strchr(i8*, i32)\n"
306 "declare i32 @strcmp(i8*, i8*)\n"
307 "declare i32 @strcoll(i8*, i8*)\n"
308 "declare i8* @strcpy(i8*, i8*)\n"
309 "declare i64 @strcspn(i8*, i8*)\n"
310 "declare i8* @strdup(i8*)\n"
311 "declare i64 @strlen(i8*)\n"
312 "declare i32 @strncasecmp(i8*, i8*, i64)\n"
313 "declare i8* @strncat(i8*, i8*, i64)\n"
314 "declare i32 @strncmp(i8*, i8*, i64)\n"
315 "declare i8* @strncpy(i8*, i8*, i64)\n"
316 "declare i8* @strndup(i8*, i64)\n"
317 "declare i64 @strnlen(i8*, i64)\n"
318 "declare i8* @strpbrk(i8*, i8*)\n"
319 "declare i8* @strrchr(i8*, i32)\n"
320 "declare i64 @strspn(i8*, i8*)\n"
321 "declare i8* @strstr(i8*, i8*)\n"
322 "declare i8* @strtok(i8*, i8*)\n"
323 "declare i8* @strtok_r(i8*, i8*, i8**)\n"
324 "declare i64 @strtol(i8*, i8**, i32)\n"
325 "declare i64 @strlcat(i8*, i8*, i64)\n"
326 "declare i64 @strlcpy(i8*, i8*, i64)\n"
327 "declare x86_fp80 @strtold(i8*, i8**)\n"
328 "declare i64 @strtoll(i8*, i8**, i32)\n"
329 "declare i64 @strtoul(i8*, i8**, i32)\n"
330 "declare i64 @strtoull(i8*, i8**, i32)\n"
331 "declare i64 @strxfrm(i8*, i8*, i64)\n"
332 "declare double @tan(double)\n"
333 "declare float @tanf(float)\n"
334 "declare double @tanh(double)\n"
335 "declare float @tanhf(float)\n"
336 "declare x86_fp80 @tanhl(x86_fp80)\n"
337 "declare x86_fp80 @tanl(x86_fp80)\n"
338 "declare i64 @times(%struct*)\n"
339 "declare %struct* @tmpfile()\n"
340 "declare i32 @_Z7toasciii(i32)\n"
341 "declare double @trunc(double)\n"
342 "declare float @truncf(float)\n"
343 "declare x86_fp80 @truncl(x86_fp80)\n"
344 "declare i32 @uname(%struct*)\n"
345 "declare i32 @ungetc(i32, %struct*)\n"
346 "declare i32 @unlink(i8*)\n"
347 "declare i32 @utime(i8*, %struct*)\n"
348 "declare i32 @utimes(i8*, %struct*)\n"
349 "declare i8* @valloc(i64)\n"
350 "declare i32 @vfprintf(%struct*, i8*, %struct*)\n"
351 "declare i32 @vfscanf(%struct*, i8*, %struct*)\n"
352 "declare i32 @vprintf(i8*, %struct*)\n"
353 "declare i32 @vscanf(i8*, %struct*)\n"
354 "declare i32 @vsnprintf(i8*, i64, i8*, %struct*)\n"
355 "declare i32 @vsprintf(i8*, i8*, %struct*)\n"
356 "declare i32 @vsscanf(i8*, i8*, %struct*)\n"
357 "declare i64 @wcslen(i32*)\n"
358 "declare i32 @fork()\n"
359 "declare i32 @execl(i8*, i8*, ...)\n"
360 "declare i32 @execle(i8*, i8*, ...)\n"
361 "declare i32 @execlp(i8*, i8*, ...)\n"
362 "declare i32 @execv(i8*, i8**)\n"
363 "declare i32 @execvP(i8*, i8*, i8**)\n"
364 "declare i32 @execve(i8*, i8**, i8**)\n"
365 "declare i32 @execvp(i8*, i8**)\n"
366 "declare i32 @execvpe(i8*, i8**, i8**)\n"
368 // These functions were also extracted from the OS X headers, but they are
369 // available with a special name on darwin.
370 // This test uses the default TLI name instead.
371 "declare i32 @chmod(i8*, i16)\n"
372 "declare i32 @closedir(%struct*)\n"
373 "declare %struct* @fdopen(i32, i8*)\n"
374 "declare %struct* @fopen(i8*, i8*)\n"
375 "declare i32 @fputs(i8*, %struct*)\n"
376 "declare i32 @fputs_unlocked(i8*, %struct*)\n"
377 "declare i32 @fstat(i32, %struct*)\n"
378 "declare i64 @fwrite(i8*, i64, i64, %struct*)\n"
379 "declare i64 @fwrite_unlocked(i8*, i64, i64, %struct*)\n"
380 "declare i32 @lchown(i8*, i32, i32)\n"
381 "declare i32 @lstat(i8*, %struct*)\n"
382 "declare i64 @mktime(%struct*)\n"
383 "declare i32 @open(i8*, i32, ...)\n"
384 "declare %struct* @opendir(i8*)\n"
385 "declare %struct* @popen(i8*, i8*)\n"
386 "declare i64 @pread(i32, i8*, i64, i64)\n"
387 "declare i64 @pwrite(i32, i8*, i64, i64)\n"
388 "declare i64 @read(i32, i8*, i64)\n"
389 "declare i8* @realpath(i8*, i8*)\n"
390 "declare i32 @stat(i8*, %struct*)\n"
391 "declare double @strtod(i8*, i8**)\n"
392 "declare float @strtof(i8*, i8**)\n"
393 "declare i32 @system(i8*)\n"
394 "declare i32 @unsetenv(i8*)\n"
395 "declare i64 @write(i32, i8*, i64)\n"
397 // These functions are available on Linux but not Darwin; they only differ
398 // from their non-64 counterparts in the struct type.
399 // Use the same prototype as the non-64 variant.
400 "declare %struct* @fopen64(i8*, i8*)\n"
401 "declare i32 @fstat64(i32, %struct*)\n"
402 "declare i32 @fstatvfs64(i32, %struct*)\n"
403 "declare i32 @lstat64(i8*, %struct*)\n"
404 "declare i32 @open64(i8*, i32, ...)\n"
405 "declare i32 @stat64(i8*, %struct*)\n"
406 "declare i32 @statvfs64(i8*, %struct*)\n"
407 "declare %struct* @tmpfile64()\n"
409 // These functions are also -64 variants, but do differ in the type of the
410 // off_t (vs off64_t) parameter. The non-64 variants declared above used
411 // a 64-bit off_t, so, in practice, they are also equivalent.
412 "declare i32 @fseeko64(%struct*, i64, i32)\n"
413 "declare i64 @ftello64(%struct*)\n"
415 "declare void @_ZdaPv(i8*)\n"
416 "declare void @_ZdaPvRKSt9nothrow_t(i8*, %struct*)\n"
417 "declare void @_ZdaPvSt11align_val_t(i8*, i64)\n"
418 "declare void @_ZdaPvSt11align_val_tRKSt9nothrow_t(i8*, i64, %struct*)\n"
419 "declare void @_ZdaPvj(i8*, i32)\n"
420 "declare void @_ZdaPvjSt11align_val_t(i8*, i32, i32)\n"
421 "declare void @_ZdaPvm(i8*, i64)\n"
422 "declare void @_ZdaPvmSt11align_val_t(i8*, i64, i64)\n"
423 "declare void @_ZdlPv(i8*)\n"
424 "declare void @_ZdlPvRKSt9nothrow_t(i8*, %struct*)\n"
425 "declare void @_ZdlPvSt11align_val_t(i8*, i64)\n"
426 "declare void @_ZdlPvSt11align_val_tRKSt9nothrow_t(i8*, i64, %struct*)\n"
427 "declare void @_ZdlPvj(i8*, i32)\n"
428 "declare void @_ZdlPvjSt11align_val_t(i8*, i32, i32)\n"
429 "declare void @_ZdlPvm(i8*, i64)\n"
430 "declare void @_ZdlPvmSt11align_val_t(i8*, i64, i64)\n"
431 "declare i8* @_Znaj(i32)\n"
432 "declare i8* @_ZnajRKSt9nothrow_t(i32, %struct*)\n"
433 "declare i8* @_ZnajSt11align_val_t(i32, i32)\n"
434 "declare i8* @_ZnajSt11align_val_tRKSt9nothrow_t(i32, i32, %struct*)\n"
435 "declare i8* @_Znam(i64)\n"
436 "declare i8* @_ZnamRKSt9nothrow_t(i64, %struct*)\n"
437 "declare i8* @_ZnamSt11align_val_t(i64, i64)\n"
438 "declare i8* @_ZnamSt11align_val_tRKSt9nothrow_t(i64, i64, %struct*)\n"
439 "declare i8* @_Znwj(i32)\n"
440 "declare i8* @_ZnwjRKSt9nothrow_t(i32, %struct*)\n"
441 "declare i8* @_ZnwjSt11align_val_t(i32, i32)\n"
442 "declare i8* @_ZnwjSt11align_val_tRKSt9nothrow_t(i32, i32, %struct*)\n"
443 "declare i8* @_Znwm(i64)\n"
444 "declare i8* @_ZnwmRKSt9nothrow_t(i64, %struct*)\n"
445 "declare i8* @_ZnwmSt11align_val_t(i64, i64)\n"
446 "declare i8* @_ZnwmSt11align_val_tRKSt9nothrow_t(i64, i64, %struct*)\n"
448 "declare void @\"??3@YAXPEAX@Z\"(i8*)\n"
449 "declare void @\"??3@YAXPEAXAEBUnothrow_t@std@@@Z\"(i8*, %struct*)\n"
450 "declare void @\"??3@YAXPEAX_K@Z\"(i8*, i64)\n"
451 "declare void @\"??_V@YAXPEAX@Z\"(i8*)\n"
452 "declare void @\"??_V@YAXPEAXAEBUnothrow_t@std@@@Z\"(i8*, %struct*)\n"
453 "declare void @\"??_V@YAXPEAX_K@Z\"(i8*, i64)\n"
454 "declare i8* @\"??2@YAPAXI@Z\"(i32)\n"
455 "declare i8* @\"??2@YAPAXIABUnothrow_t@std@@@Z\"(i32, %struct*)\n"
456 "declare i8* @\"??2@YAPEAX_K@Z\"(i64)\n"
457 "declare i8* @\"??2@YAPEAX_KAEBUnothrow_t@std@@@Z\"(i64, %struct*)\n"
458 "declare i8* @\"??_U@YAPAXI@Z\"(i32)\n"
459 "declare i8* @\"??_U@YAPAXIABUnothrow_t@std@@@Z\"(i32, %struct*)\n"
460 "declare i8* @\"??_U@YAPEAX_K@Z\"(i64)\n"
461 "declare i8* @\"??_U@YAPEAX_KAEBUnothrow_t@std@@@Z\"(i64, %struct*)\n"
463 "declare void @\"??3@YAXPAX@Z\"(i8*)\n"
464 "declare void @\"??3@YAXPAXABUnothrow_t@std@@@Z\"(i8*, %struct*)\n"
465 "declare void @\"??3@YAXPAXI@Z\"(i8*, i32)\n"
466 "declare void @\"??_V@YAXPAX@Z\"(i8*)\n"
467 "declare void @\"??_V@YAXPAXABUnothrow_t@std@@@Z\"(i8*, %struct*)\n"
468 "declare void @\"??_V@YAXPAXI@Z\"(i8*, i32)\n"
470 // These other functions were derived from the .def C declaration.
471 "declare i32 @__cxa_atexit(void (i8*)*, i8*, i8*)\n"
472 "declare void @__cxa_guard_abort(%struct*)\n"
473 "declare i32 @__cxa_guard_acquire(%struct*)\n"
474 "declare void @__cxa_guard_release(%struct*)\n"
476 "declare i32 @__nvvm_reflect(i8*)\n"
478 "declare i8* @__memcpy_chk(i8*, i8*, i64, i64)\n"
479 "declare i8* @__memmove_chk(i8*, i8*, i64, i64)\n"
480 "declare i8* @__memset_chk(i8*, i32, i64, i64)\n"
481 "declare i8* @__stpcpy_chk(i8*, i8*, i64)\n"
482 "declare i8* @__stpncpy_chk(i8*, i8*, i64, i64)\n"
483 "declare i8* @__strcpy_chk(i8*, i8*, i64)\n"
484 "declare i8* @__strncpy_chk(i8*, i8*, i64, i64)\n"
485 "declare i8* @__memccpy_chk(i8*, i8*, i32, i64, i64)\n"
486 "declare i8* @__mempcpy_chk(i8*, i8*, i64, i64)\n"
487 "declare i32 @__snprintf_chk(i8*, i64, i32, i64, i8*, ...)\n"
488 "declare i32 @__sprintf_chk(i8*, i32, i64, i8*, ...)\n"
489 "declare i8* @__strcat_chk(i8*, i8*, i64)\n"
490 "declare i64 @__strlcat_chk(i8*, i8*, i64, i64)\n"
491 "declare i64 @__strlen_chk(i8*, i64)\n"
492 "declare i8* @__strncat_chk(i8*, i8*, i64, i64)\n"
493 "declare i64 @__strlcpy_chk(i8*, i8*, i64, i64)\n"
494 "declare i32 @__vsnprintf_chk(i8*, i64, i32, i64, i8*, %struct*)\n"
495 "declare i32 @__vsprintf_chk(i8*, i32, i64, i8*, %struct*)\n"
497 "declare i8* @memalign(i64, i64)\n"
498 "declare i8* @mempcpy(i8*, i8*, i64)\n"
499 "declare i8* @memrchr(i8*, i32, i64)\n"
501 "declare void @__atomic_load(i64, i8*, i8*, i32)\n"
502 "declare void @__atomic_store(i64, i8*, i8*, i32)\n"
504 // These are similar to the FILE* fgetc/fputc.
505 "declare i32 @_IO_getc(%struct*)\n"
506 "declare i32 @_IO_putc(i32, %struct*)\n"
508 "declare i32 @__isoc99_scanf(i8*, ...)\n"
509 "declare i32 @__isoc99_sscanf(i8*, i8*, ...)\n"
510 "declare i8* @__strdup(i8*)\n"
511 "declare i8* @__strndup(i8*, i64)\n"
512 "declare i8* @__strtok_r(i8*, i8*, i8**)\n"
514 "declare double @__sqrt_finite(double)\n"
515 "declare float @__sqrtf_finite(float)\n"
516 "declare x86_fp80 @__sqrtl_finite(x86_fp80)\n"
517 "declare double @exp10(double)\n"
518 "declare float @exp10f(float)\n"
519 "declare x86_fp80 @exp10l(x86_fp80)\n"
521 // These printf variants have the same prototype as the non-'i' versions.
522 "declare i32 @fiprintf(%struct*, i8*, ...)\n"
523 "declare i32 @iprintf(i8*, ...)\n"
524 "declare i32 @siprintf(i8*, i8*, ...)\n"
526 // __small_printf variants have the same prototype as the non-'i'
528 "declare i32 @__small_fprintf(%struct*, i8*, ...)\n"
529 "declare i32 @__small_printf(i8*, ...)\n"
530 "declare i32 @__small_sprintf(i8*, i8*, ...)\n"
532 "declare i32 @htonl(i32)\n"
533 "declare i16 @htons(i16)\n"
534 "declare i32 @ntohl(i32)\n"
535 "declare i16 @ntohs(i16)\n"
537 "declare i32 @isascii(i32)\n"
538 "declare i32 @isdigit(i32)\n"
539 "declare i32 @toascii(i32)\n"
541 // These functions were extracted from math-finite.h which provides
542 // functions similar to those in math.h, but optimized for handling
543 // finite values only.
544 "declare double @__acos_finite(double)\n"
545 "declare float @__acosf_finite(float)\n"
546 "declare x86_fp80 @__acosl_finite(x86_fp80)\n"
547 "declare double @__acosh_finite(double)\n"
548 "declare float @__acoshf_finite(float)\n"
549 "declare x86_fp80 @__acoshl_finite(x86_fp80)\n"
550 "declare double @__asin_finite(double)\n"
551 "declare float @__asinf_finite(float)\n"
552 "declare x86_fp80 @__asinl_finite(x86_fp80)\n"
553 "declare double @__atan2_finite(double, double)\n"
554 "declare float @__atan2f_finite(float, float)\n"
555 "declare x86_fp80 @__atan2l_finite(x86_fp80, x86_fp80)\n"
556 "declare double @__atanh_finite(double)\n"
557 "declare float @__atanhf_finite(float)\n"
558 "declare x86_fp80 @__atanhl_finite(x86_fp80)\n"
559 "declare double @__cosh_finite(double)\n"
560 "declare float @__coshf_finite(float)\n"
561 "declare x86_fp80 @__coshl_finite(x86_fp80)\n"
562 "declare double @__exp10_finite(double)\n"
563 "declare float @__exp10f_finite(float)\n"
564 "declare x86_fp80 @__exp10l_finite(x86_fp80)\n"
565 "declare double @__exp2_finite(double)\n"
566 "declare float @__exp2f_finite(float)\n"
567 "declare x86_fp80 @__exp2l_finite(x86_fp80)\n"
568 "declare double @__exp_finite(double)\n"
569 "declare float @__expf_finite(float)\n"
570 "declare x86_fp80 @__expl_finite(x86_fp80)\n"
571 "declare double @__log10_finite(double)\n"
572 "declare float @__log10f_finite(float)\n"
573 "declare x86_fp80 @__log10l_finite(x86_fp80)\n"
574 "declare double @__log2_finite(double)\n"
575 "declare float @__log2f_finite(float)\n"
576 "declare x86_fp80 @__log2l_finite(x86_fp80)\n"
577 "declare double @__log_finite(double)\n"
578 "declare float @__logf_finite(float)\n"
579 "declare x86_fp80 @__logl_finite(x86_fp80)\n"
580 "declare double @__pow_finite(double, double)\n"
581 "declare float @__powf_finite(float, float)\n"
582 "declare x86_fp80 @__powl_finite(x86_fp80, x86_fp80)\n"
583 "declare double @__sinh_finite(double)\n"
584 "declare float @__sinhf_finite(float)\n"
585 "declare x86_fp80 @__sinhl_finite(x86_fp80)\n"
587 // These functions are aix vec allocation/free routines
588 "declare i8* @vec_calloc(i64, i64)\n"
589 "declare i8* @vec_malloc(i64)\n"
590 "declare i8* @vec_realloc(i8*, i64)\n"
591 "declare void @vec_free(i8*)\n"
593 // These functions are OpenMP Offloading allocation / free routines
594 "declare i8* @__kmpc_alloc_shared(i64)\n"
595 "declare void @__kmpc_free_shared(i8*, i64)\n");
597 for (unsigned FI
= 0; FI
!= LibFunc::NumLibFuncs
; ++FI
) {
598 LibFunc LF
= (LibFunc
)FI
;
599 // Make sure everything is available; we're not testing target defaults.
600 TLII
.setAvailable(LF
);
601 Function
*F
= M
->getFunction(TLI
.getName(LF
));
602 EXPECT_TRUE(isLibFunc(F
, LF
));