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