LLVM  13.0.0git
TargetLibraryInfo.cpp
Go to the documentation of this file.
1 //===-- TargetLibraryInfo.cpp - Runtime library information ----------------==//
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 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the TargetLibraryInfo class.
10 //
11 //===----------------------------------------------------------------------===//
12 
14 #include "llvm/ADT/Triple.h"
15 #include "llvm/IR/Constants.h"
16 #include "llvm/InitializePasses.h"
18 using namespace llvm;
19 
21  "vector-library", cl::Hidden, cl::desc("Vector functions library"),
24  "No vector functions library"),
26  "Accelerate framework"),
28  "Darwin_libsystem_m", "Darwin libsystem_m"),
30  "GLIBC Vector Math library"),
32  "IBM MASS vector library"),
34  "Intel SVML library")));
35 
36 StringLiteral const TargetLibraryInfoImpl::StandardNames[LibFunc::NumLibFuncs] =
37  {
38 #define TLI_DEFINE_STRING
39 #include "llvm/Analysis/TargetLibraryInfo.def"
40 };
41 
42 static bool hasSinCosPiStret(const Triple &T) {
43  // Only Darwin variants have _stret versions of combined trig functions.
44  if (!T.isOSDarwin())
45  return false;
46 
47  // The ABI is rather complicated on x86, so don't do anything special there.
48  if (T.getArch() == Triple::x86)
49  return false;
50 
51  if (T.isMacOSX() && T.isMacOSXVersionLT(10, 9))
52  return false;
53 
54  if (T.isiOS() && T.isOSVersionLT(7, 0))
55  return false;
56 
57  return true;
58 }
59 
60 static bool hasBcmp(const Triple &TT) {
61  // Posix removed support from bcmp() in 2001, but the glibc and several
62  // implementations of the libc still have it.
63  if (TT.isOSLinux())
64  return TT.isGNUEnvironment() || TT.isMusl();
65  // Both NetBSD and OpenBSD are planning to remove the function. Windows does
66  // not have it.
67  return TT.isOSFreeBSD() || TT.isOSSolaris();
68 }
69 
71  FunctionType *FuncTy) {
72  switch (CC) {
73  default:
74  return false;
76  return true;
80 
81  // The iOS ABI diverges from the standard in some cases, so for now don't
82  // try to simplify those calls.
83  if (Triple(TT).isiOS())
84  return false;
85 
86  if (!FuncTy->getReturnType()->isPointerTy() &&
87  !FuncTy->getReturnType()->isIntegerTy() &&
88  !FuncTy->getReturnType()->isVoidTy())
89  return false;
90 
91  for (auto *Param : FuncTy->params()) {
92  if (!Param->isPointerTy() && !Param->isIntegerTy())
93  return false;
94  }
95  return true;
96  }
97  }
98  return false;
99 }
100 
103  CI->getModule()->getTargetTriple(),
104  CI->getFunctionType());
105 }
106 
108  return ::isCallingConvCCompatible(F->getCallingConv(),
109  F->getParent()->getTargetTriple(),
110  F->getFunctionType());
111 }
112 
113 /// Initialize the set of available library functions based on the specified
114 /// target triple. This should be carefully written so that a missing target
115 /// triple gets a sane set of defaults.
116 static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
117  ArrayRef<StringLiteral> StandardNames) {
118  // Verify that the StandardNames array is in alphabetical order.
119  assert(
120  llvm::is_sorted(StandardNames,
121  [](StringRef LHS, StringRef RHS) { return LHS < RHS; }) &&
122  "TargetLibraryInfoImpl function names must be sorted");
123 
124  // Set IO unlocked variants as unavailable
125  // Set them as available per system below
126  TLI.setUnavailable(LibFunc_getchar_unlocked);
127  TLI.setUnavailable(LibFunc_putc_unlocked);
128  TLI.setUnavailable(LibFunc_putchar_unlocked);
129  TLI.setUnavailable(LibFunc_fputc_unlocked);
130  TLI.setUnavailable(LibFunc_fgetc_unlocked);
131  TLI.setUnavailable(LibFunc_fread_unlocked);
132  TLI.setUnavailable(LibFunc_fwrite_unlocked);
133  TLI.setUnavailable(LibFunc_fputs_unlocked);
134  TLI.setUnavailable(LibFunc_fgets_unlocked);
135 
136  bool ShouldExtI32Param = false, ShouldExtI32Return = false,
137  ShouldSignExtI32Param = false;
138  // PowerPC64, Sparc64, SystemZ need signext/zeroext on i32 parameters and
139  // returns corresponding to C-level ints and unsigned ints.
140  if (T.isPPC64() || T.getArch() == Triple::sparcv9 ||
141  T.getArch() == Triple::systemz) {
142  ShouldExtI32Param = true;
143  ShouldExtI32Return = true;
144  }
145  // Mips, on the other hand, needs signext on i32 parameters corresponding
146  // to both signed and unsigned ints.
147  if (T.isMIPS()) {
148  ShouldSignExtI32Param = true;
149  }
150  TLI.setShouldExtI32Param(ShouldExtI32Param);
151  TLI.setShouldExtI32Return(ShouldExtI32Return);
152  TLI.setShouldSignExtI32Param(ShouldSignExtI32Param);
153 
154  // Let's assume by default that the size of int is 32 bits, unless the target
155  // is a 16-bit architecture because then it most likely is 16 bits. If that
156  // isn't true for a target those defaults should be overridden below.
157  TLI.setIntSize(T.isArch16Bit() ? 16 : 32);
158 
159  if (T.isAMDGPU())
160  TLI.disableAllFunctions();
161 
162  // There are no library implementations of memcpy and memset for AMD gpus and
163  // these can be difficult to lower in the backend.
164  if (T.isAMDGPU()) {
165  TLI.setUnavailable(LibFunc_memcpy);
166  TLI.setUnavailable(LibFunc_memset);
167  TLI.setUnavailable(LibFunc_memset_pattern16);
168  TLI.setAvailable(llvm::LibFunc___kmpc_alloc_shared);
169  TLI.setAvailable(llvm::LibFunc___kmpc_free_shared);
170  return;
171  }
172 
173  // memset_pattern16 is only available on iOS 3.0 and Mac OS X 10.5 and later.
174  // All versions of watchOS support it.
175  if (T.isMacOSX()) {
176  // available IO unlocked variants on Mac OS X
177  TLI.setAvailable(LibFunc_getc_unlocked);
178  TLI.setAvailable(LibFunc_getchar_unlocked);
179  TLI.setAvailable(LibFunc_putc_unlocked);
180  TLI.setAvailable(LibFunc_putchar_unlocked);
181 
182  if (T.isMacOSXVersionLT(10, 5))
183  TLI.setUnavailable(LibFunc_memset_pattern16);
184  } else if (T.isiOS()) {
185  if (T.isOSVersionLT(3, 0))
186  TLI.setUnavailable(LibFunc_memset_pattern16);
187  } else if (!T.isWatchOS()) {
188  TLI.setUnavailable(LibFunc_memset_pattern16);
189  }
190 
191  if (!hasSinCosPiStret(T)) {
192  TLI.setUnavailable(LibFunc_sinpi);
193  TLI.setUnavailable(LibFunc_sinpif);
194  TLI.setUnavailable(LibFunc_cospi);
195  TLI.setUnavailable(LibFunc_cospif);
196  TLI.setUnavailable(LibFunc_sincospi_stret);
197  TLI.setUnavailable(LibFunc_sincospif_stret);
198  }
199 
200  if (!hasBcmp(T))
201  TLI.setUnavailable(LibFunc_bcmp);
202 
203  if (T.isMacOSX() && T.getArch() == Triple::x86 &&
204  !T.isMacOSXVersionLT(10, 7)) {
205  // x86-32 OSX has a scheme where fwrite and fputs (and some other functions
206  // we don't care about) have two versions; on recent OSX, the one we want
207  // has a $UNIX2003 suffix. The two implementations are identical except
208  // for the return value in some edge cases. However, we don't want to
209  // generate code that depends on the old symbols.
210  TLI.setAvailableWithName(LibFunc_fwrite, "fwrite$UNIX2003");
211  TLI.setAvailableWithName(LibFunc_fputs, "fputs$UNIX2003");
212  }
213 
214  // iprintf and friends are only available on XCore, TCE, and Emscripten.
215  if (T.getArch() != Triple::xcore && T.getArch() != Triple::tce &&
216  T.getOS() != Triple::Emscripten) {
217  TLI.setUnavailable(LibFunc_iprintf);
218  TLI.setUnavailable(LibFunc_siprintf);
219  TLI.setUnavailable(LibFunc_fiprintf);
220  }
221 
222  // __small_printf and friends are only available on Emscripten.
223  if (T.getOS() != Triple::Emscripten) {
224  TLI.setUnavailable(LibFunc_small_printf);
225  TLI.setUnavailable(LibFunc_small_sprintf);
226  TLI.setUnavailable(LibFunc_small_fprintf);
227  }
228 
229  if (T.isOSWindows() && !T.isOSCygMing()) {
230  // XXX: The earliest documentation available at the moment is for VS2015/VC19:
231  // https://docs.microsoft.com/en-us/cpp/c-runtime-library/floating-point-support?view=vs-2015
232  // XXX: In order to use an MSVCRT older than VC19,
233  // the specific library version must be explicit in the target triple,
234  // e.g., x86_64-pc-windows-msvc18.
235  bool hasPartialC99 = true;
236  if (T.isKnownWindowsMSVCEnvironment()) {
237  unsigned Major, Minor, Micro;
238  T.getEnvironmentVersion(Major, Minor, Micro);
239  hasPartialC99 = (Major == 0 || Major >= 19);
240  }
241 
242  // Latest targets support C89 math functions, in part.
243  bool isARM = (T.getArch() == Triple::aarch64 ||
244  T.getArch() == Triple::arm);
245  bool hasPartialFloat = (isARM ||
246  T.getArch() == Triple::x86_64);
247 
248  // Win32 does not support float C89 math functions, in general.
249  if (!hasPartialFloat) {
250  TLI.setUnavailable(LibFunc_acosf);
251  TLI.setUnavailable(LibFunc_asinf);
252  TLI.setUnavailable(LibFunc_atan2f);
253  TLI.setUnavailable(LibFunc_atanf);
254  TLI.setUnavailable(LibFunc_ceilf);
255  TLI.setUnavailable(LibFunc_cosf);
256  TLI.setUnavailable(LibFunc_coshf);
257  TLI.setUnavailable(LibFunc_expf);
258  TLI.setUnavailable(LibFunc_floorf);
259  TLI.setUnavailable(LibFunc_fmodf);
260  TLI.setUnavailable(LibFunc_log10f);
261  TLI.setUnavailable(LibFunc_logf);
262  TLI.setUnavailable(LibFunc_modff);
263  TLI.setUnavailable(LibFunc_powf);
264  TLI.setUnavailable(LibFunc_remainderf);
265  TLI.setUnavailable(LibFunc_sinf);
266  TLI.setUnavailable(LibFunc_sinhf);
267  TLI.setUnavailable(LibFunc_sqrtf);
268  TLI.setUnavailable(LibFunc_tanf);
269  TLI.setUnavailable(LibFunc_tanhf);
270  }
271  if (!isARM)
272  TLI.setUnavailable(LibFunc_fabsf);
273  TLI.setUnavailable(LibFunc_frexpf);
274  TLI.setUnavailable(LibFunc_ldexpf);
275 
276  // Win32 does not support long double C89 math functions.
277  TLI.setUnavailable(LibFunc_acosl);
278  TLI.setUnavailable(LibFunc_asinl);
279  TLI.setUnavailable(LibFunc_atan2l);
280  TLI.setUnavailable(LibFunc_atanl);
281  TLI.setUnavailable(LibFunc_ceill);
282  TLI.setUnavailable(LibFunc_cosl);
283  TLI.setUnavailable(LibFunc_coshl);
284  TLI.setUnavailable(LibFunc_expl);
285  TLI.setUnavailable(LibFunc_fabsl);
286  TLI.setUnavailable(LibFunc_floorl);
287  TLI.setUnavailable(LibFunc_fmodl);
288  TLI.setUnavailable(LibFunc_frexpl);
289  TLI.setUnavailable(LibFunc_ldexpl);
290  TLI.setUnavailable(LibFunc_log10l);
291  TLI.setUnavailable(LibFunc_logl);
292  TLI.setUnavailable(LibFunc_modfl);
293  TLI.setUnavailable(LibFunc_powl);
294  TLI.setUnavailable(LibFunc_remainderl);
295  TLI.setUnavailable(LibFunc_sinl);
296  TLI.setUnavailable(LibFunc_sinhl);
297  TLI.setUnavailable(LibFunc_sqrtl);
298  TLI.setUnavailable(LibFunc_tanl);
299  TLI.setUnavailable(LibFunc_tanhl);
300 
301  // Win32 does not fully support C99 math functions.
302  if (!hasPartialC99) {
303  TLI.setUnavailable(LibFunc_acosh);
304  TLI.setUnavailable(LibFunc_acoshf);
305  TLI.setUnavailable(LibFunc_asinh);
306  TLI.setUnavailable(LibFunc_asinhf);
307  TLI.setUnavailable(LibFunc_atanh);
308  TLI.setUnavailable(LibFunc_atanhf);
309  TLI.setAvailableWithName(LibFunc_cabs, "_cabs");
310  TLI.setUnavailable(LibFunc_cabsf);
311  TLI.setUnavailable(LibFunc_cbrt);
312  TLI.setUnavailable(LibFunc_cbrtf);
313  TLI.setAvailableWithName(LibFunc_copysign, "_copysign");
314  TLI.setAvailableWithName(LibFunc_copysignf, "_copysignf");
315  TLI.setUnavailable(LibFunc_exp2);
316  TLI.setUnavailable(LibFunc_exp2f);
317  TLI.setUnavailable(LibFunc_expm1);
318  TLI.setUnavailable(LibFunc_expm1f);
319  TLI.setUnavailable(LibFunc_fmax);
320  TLI.setUnavailable(LibFunc_fmaxf);
321  TLI.setUnavailable(LibFunc_fmin);
322  TLI.setUnavailable(LibFunc_fminf);
323  TLI.setUnavailable(LibFunc_log1p);
324  TLI.setUnavailable(LibFunc_log1pf);
325  TLI.setUnavailable(LibFunc_log2);
326  TLI.setUnavailable(LibFunc_log2f);
327  TLI.setAvailableWithName(LibFunc_logb, "_logb");
328  if (hasPartialFloat)
329  TLI.setAvailableWithName(LibFunc_logbf, "_logbf");
330  else
331  TLI.setUnavailable(LibFunc_logbf);
332  TLI.setUnavailable(LibFunc_rint);
333  TLI.setUnavailable(LibFunc_rintf);
334  TLI.setUnavailable(LibFunc_round);
335  TLI.setUnavailable(LibFunc_roundf);
336  TLI.setUnavailable(LibFunc_trunc);
337  TLI.setUnavailable(LibFunc_truncf);
338  }
339 
340  // Win32 does not support long double C99 math functions.
341  TLI.setUnavailable(LibFunc_acoshl);
342  TLI.setUnavailable(LibFunc_asinhl);
343  TLI.setUnavailable(LibFunc_atanhl);
344  TLI.setUnavailable(LibFunc_cabsl);
345  TLI.setUnavailable(LibFunc_cbrtl);
346  TLI.setUnavailable(LibFunc_copysignl);
347  TLI.setUnavailable(LibFunc_exp2l);
348  TLI.setUnavailable(LibFunc_expm1l);
349  TLI.setUnavailable(LibFunc_fmaxl);
350  TLI.setUnavailable(LibFunc_fminl);
351  TLI.setUnavailable(LibFunc_log1pl);
352  TLI.setUnavailable(LibFunc_log2l);
353  TLI.setUnavailable(LibFunc_logbl);
354  TLI.setUnavailable(LibFunc_nearbyintl);
355  TLI.setUnavailable(LibFunc_rintl);
356  TLI.setUnavailable(LibFunc_roundl);
357  TLI.setUnavailable(LibFunc_truncl);
358 
359  // Win32 does not support these functions, but
360  // they are generally available on POSIX-compliant systems.
361  TLI.setUnavailable(LibFunc_access);
362  TLI.setUnavailable(LibFunc_chmod);
363  TLI.setUnavailable(LibFunc_closedir);
364  TLI.setUnavailable(LibFunc_fdopen);
365  TLI.setUnavailable(LibFunc_fileno);
366  TLI.setUnavailable(LibFunc_fseeko);
367  TLI.setUnavailable(LibFunc_fstat);
368  TLI.setUnavailable(LibFunc_ftello);
369  TLI.setUnavailable(LibFunc_gettimeofday);
370  TLI.setUnavailable(LibFunc_memccpy);
371  TLI.setUnavailable(LibFunc_mkdir);
372  TLI.setUnavailable(LibFunc_open);
373  TLI.setUnavailable(LibFunc_opendir);
374  TLI.setUnavailable(LibFunc_pclose);
375  TLI.setUnavailable(LibFunc_popen);
376  TLI.setUnavailable(LibFunc_read);
377  TLI.setUnavailable(LibFunc_rmdir);
378  TLI.setUnavailable(LibFunc_stat);
379  TLI.setUnavailable(LibFunc_strcasecmp);
380  TLI.setUnavailable(LibFunc_strncasecmp);
381  TLI.setUnavailable(LibFunc_unlink);
382  TLI.setUnavailable(LibFunc_utime);
383  TLI.setUnavailable(LibFunc_write);
384  }
385 
386  if (T.isOSWindows() && !T.isWindowsCygwinEnvironment()) {
387  // These functions aren't available in either MSVC or MinGW environments.
388  TLI.setUnavailable(LibFunc_bcmp);
389  TLI.setUnavailable(LibFunc_bcopy);
390  TLI.setUnavailable(LibFunc_bzero);
391  TLI.setUnavailable(LibFunc_chown);
392  TLI.setUnavailable(LibFunc_ctermid);
393  TLI.setUnavailable(LibFunc_ffs);
394  TLI.setUnavailable(LibFunc_flockfile);
395  TLI.setUnavailable(LibFunc_fstatvfs);
396  TLI.setUnavailable(LibFunc_ftrylockfile);
397  TLI.setUnavailable(LibFunc_funlockfile);
398  TLI.setUnavailable(LibFunc_getitimer);
399  TLI.setUnavailable(LibFunc_getlogin_r);
400  TLI.setUnavailable(LibFunc_getpwnam);
401  TLI.setUnavailable(LibFunc_htonl);
402  TLI.setUnavailable(LibFunc_htons);
403  TLI.setUnavailable(LibFunc_lchown);
404  TLI.setUnavailable(LibFunc_lstat);
405  TLI.setUnavailable(LibFunc_ntohl);
406  TLI.setUnavailable(LibFunc_ntohs);
407  TLI.setUnavailable(LibFunc_pread);
408  TLI.setUnavailable(LibFunc_pwrite);
409  TLI.setUnavailable(LibFunc_readlink);
410  TLI.setUnavailable(LibFunc_realpath);
411  TLI.setUnavailable(LibFunc_setitimer);
412  TLI.setUnavailable(LibFunc_statvfs);
413  TLI.setUnavailable(LibFunc_stpcpy);
414  TLI.setUnavailable(LibFunc_stpncpy);
415  TLI.setUnavailable(LibFunc_times);
416  TLI.setUnavailable(LibFunc_uname);
417  TLI.setUnavailable(LibFunc_unsetenv);
418  TLI.setUnavailable(LibFunc_utimes);
419  }
420 
421  switch (T.getOS()) {
422  case Triple::MacOSX:
423  // exp10 and exp10f are not available on OS X until 10.9 and iOS until 7.0
424  // and their names are __exp10 and __exp10f. exp10l is not available on
425  // OS X or iOS.
426  TLI.setUnavailable(LibFunc_exp10l);
427  if (T.isMacOSXVersionLT(10, 9)) {
428  TLI.setUnavailable(LibFunc_exp10);
429  TLI.setUnavailable(LibFunc_exp10f);
430  } else {
431  TLI.setAvailableWithName(LibFunc_exp10, "__exp10");
432  TLI.setAvailableWithName(LibFunc_exp10f, "__exp10f");
433  }
434  break;
435  case Triple::IOS:
436  case Triple::TvOS:
437  case Triple::WatchOS:
438  TLI.setUnavailable(LibFunc_exp10l);
439  if (!T.isWatchOS() &&
440  (T.isOSVersionLT(7, 0) || (T.isOSVersionLT(9, 0) && T.isX86()))) {
441  TLI.setUnavailable(LibFunc_exp10);
442  TLI.setUnavailable(LibFunc_exp10f);
443  } else {
444  TLI.setAvailableWithName(LibFunc_exp10, "__exp10");
445  TLI.setAvailableWithName(LibFunc_exp10f, "__exp10f");
446  }
447  break;
448  case Triple::Linux:
449  // exp10, exp10f, exp10l is available on Linux (GLIBC) but are extremely
450  // buggy prior to glibc version 2.18. Until this version is widely deployed
451  // or we have a reasonable detection strategy, we cannot use exp10 reliably
452  // on Linux.
453  //
454  // Fall through to disable all of them.
456  default:
457  TLI.setUnavailable(LibFunc_exp10);
458  TLI.setUnavailable(LibFunc_exp10f);
459  TLI.setUnavailable(LibFunc_exp10l);
460  }
461 
462  // ffsl is available on at least Darwin, Mac OS X, iOS, FreeBSD, and
463  // Linux (GLIBC):
464  // http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/ffsl.3.html
465  // http://svn.freebsd.org/base/head/lib/libc/string/ffsl.c
466  // http://www.gnu.org/software/gnulib/manual/html_node/ffsl.html
467  switch (T.getOS()) {
468  case Triple::Darwin:
469  case Triple::MacOSX:
470  case Triple::IOS:
471  case Triple::TvOS:
472  case Triple::WatchOS:
473  case Triple::FreeBSD:
474  case Triple::Linux:
475  break;
476  default:
477  TLI.setUnavailable(LibFunc_ffsl);
478  }
479 
480  // ffsll is available on at least FreeBSD and Linux (GLIBC):
481  // http://svn.freebsd.org/base/head/lib/libc/string/ffsll.c
482  // http://www.gnu.org/software/gnulib/manual/html_node/ffsll.html
483  switch (T.getOS()) {
484  case Triple::Darwin:
485  case Triple::MacOSX:
486  case Triple::IOS:
487  case Triple::TvOS:
488  case Triple::WatchOS:
489  case Triple::FreeBSD:
490  case Triple::Linux:
491  break;
492  default:
493  TLI.setUnavailable(LibFunc_ffsll);
494  }
495 
496  // The following functions are available on at least FreeBSD:
497  // http://svn.freebsd.org/base/head/lib/libc/string/fls.c
498  // http://svn.freebsd.org/base/head/lib/libc/string/flsl.c
499  // http://svn.freebsd.org/base/head/lib/libc/string/flsll.c
500  if (!T.isOSFreeBSD()) {
501  TLI.setUnavailable(LibFunc_fls);
502  TLI.setUnavailable(LibFunc_flsl);
503  TLI.setUnavailable(LibFunc_flsll);
504  }
505 
506  // The following functions are only available on GNU/Linux (using glibc).
507  // Linux variants without glibc (eg: bionic, musl) may have some subset.
508  if (!T.isOSLinux() || !T.isGNUEnvironment()) {
509  TLI.setUnavailable(LibFunc_dunder_strdup);
510  TLI.setUnavailable(LibFunc_dunder_strtok_r);
511  TLI.setUnavailable(LibFunc_dunder_isoc99_scanf);
512  TLI.setUnavailable(LibFunc_dunder_isoc99_sscanf);
513  TLI.setUnavailable(LibFunc_under_IO_getc);
514  TLI.setUnavailable(LibFunc_under_IO_putc);
515  // But, Android and musl have memalign.
516  if (!T.isAndroid() && !T.isMusl())
517  TLI.setUnavailable(LibFunc_memalign);
518  TLI.setUnavailable(LibFunc_fopen64);
519  TLI.setUnavailable(LibFunc_fseeko64);
520  TLI.setUnavailable(LibFunc_fstat64);
521  TLI.setUnavailable(LibFunc_fstatvfs64);
522  TLI.setUnavailable(LibFunc_ftello64);
523  TLI.setUnavailable(LibFunc_lstat64);
524  TLI.setUnavailable(LibFunc_open64);
525  TLI.setUnavailable(LibFunc_stat64);
526  TLI.setUnavailable(LibFunc_statvfs64);
527  TLI.setUnavailable(LibFunc_tmpfile64);
528 
529  // Relaxed math functions are included in math-finite.h on Linux (GLIBC).
530  // Note that math-finite.h is no longer supported by top-of-tree GLIBC,
531  // so we keep these functions around just so that they're recognized by
532  // the ConstantFolder.
533  TLI.setUnavailable(LibFunc_acos_finite);
534  TLI.setUnavailable(LibFunc_acosf_finite);
535  TLI.setUnavailable(LibFunc_acosl_finite);
536  TLI.setUnavailable(LibFunc_acosh_finite);
537  TLI.setUnavailable(LibFunc_acoshf_finite);
538  TLI.setUnavailable(LibFunc_acoshl_finite);
539  TLI.setUnavailable(LibFunc_asin_finite);
540  TLI.setUnavailable(LibFunc_asinf_finite);
541  TLI.setUnavailable(LibFunc_asinl_finite);
542  TLI.setUnavailable(LibFunc_atan2_finite);
543  TLI.setUnavailable(LibFunc_atan2f_finite);
544  TLI.setUnavailable(LibFunc_atan2l_finite);
545  TLI.setUnavailable(LibFunc_atanh_finite);
546  TLI.setUnavailable(LibFunc_atanhf_finite);
547  TLI.setUnavailable(LibFunc_atanhl_finite);
548  TLI.setUnavailable(LibFunc_cosh_finite);
549  TLI.setUnavailable(LibFunc_coshf_finite);
550  TLI.setUnavailable(LibFunc_coshl_finite);
551  TLI.setUnavailable(LibFunc_exp10_finite);
552  TLI.setUnavailable(LibFunc_exp10f_finite);
553  TLI.setUnavailable(LibFunc_exp10l_finite);
554  TLI.setUnavailable(LibFunc_exp2_finite);
555  TLI.setUnavailable(LibFunc_exp2f_finite);
556  TLI.setUnavailable(LibFunc_exp2l_finite);
557  TLI.setUnavailable(LibFunc_exp_finite);
558  TLI.setUnavailable(LibFunc_expf_finite);
559  TLI.setUnavailable(LibFunc_expl_finite);
560  TLI.setUnavailable(LibFunc_log10_finite);
561  TLI.setUnavailable(LibFunc_log10f_finite);
562  TLI.setUnavailable(LibFunc_log10l_finite);
563  TLI.setUnavailable(LibFunc_log2_finite);
564  TLI.setUnavailable(LibFunc_log2f_finite);
565  TLI.setUnavailable(LibFunc_log2l_finite);
566  TLI.setUnavailable(LibFunc_log_finite);
567  TLI.setUnavailable(LibFunc_logf_finite);
568  TLI.setUnavailable(LibFunc_logl_finite);
569  TLI.setUnavailable(LibFunc_pow_finite);
570  TLI.setUnavailable(LibFunc_powf_finite);
571  TLI.setUnavailable(LibFunc_powl_finite);
572  TLI.setUnavailable(LibFunc_sinh_finite);
573  TLI.setUnavailable(LibFunc_sinhf_finite);
574  TLI.setUnavailable(LibFunc_sinhl_finite);
575  }
576 
577  if ((T.isOSLinux() && T.isGNUEnvironment()) ||
578  (T.isAndroid() && !T.isAndroidVersionLT(28))) {
579  // available IO unlocked variants on GNU/Linux and Android P or later
580  TLI.setAvailable(LibFunc_getc_unlocked);
581  TLI.setAvailable(LibFunc_getchar_unlocked);
582  TLI.setAvailable(LibFunc_putc_unlocked);
583  TLI.setAvailable(LibFunc_putchar_unlocked);
584  TLI.setAvailable(LibFunc_fputc_unlocked);
585  TLI.setAvailable(LibFunc_fgetc_unlocked);
586  TLI.setAvailable(LibFunc_fread_unlocked);
587  TLI.setAvailable(LibFunc_fwrite_unlocked);
588  TLI.setAvailable(LibFunc_fputs_unlocked);
589  TLI.setAvailable(LibFunc_fgets_unlocked);
590  }
591 
592  // As currently implemented in clang, NVPTX code has no standard library to
593  // speak of. Headers provide a standard-ish library implementation, but many
594  // of the signatures are wrong -- for example, many libm functions are not
595  // extern "C".
596  //
597  // libdevice, an IR library provided by nvidia, is linked in by the front-end,
598  // but only used functions are provided to llvm. Moreover, most of the
599  // functions in libdevice don't map precisely to standard library functions.
600  //
601  // FIXME: Having no standard library prevents e.g. many fastmath
602  // optimizations, so this situation should be fixed.
603  if (T.isNVPTX()) {
604  TLI.disableAllFunctions();
605  TLI.setAvailable(LibFunc_nvvm_reflect);
606  TLI.setAvailable(llvm::LibFunc_malloc);
607  TLI.setAvailable(llvm::LibFunc_free);
608 
609  // TODO: We could enable the following two according to [0] but we haven't
610  // done an evaluation wrt. the performance implications.
611  // [0]
612  // https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#dynamic-global-memory-allocation-and-operations
613  //
614  // TLI.setAvailable(llvm::LibFunc_memcpy);
615  // TLI.setAvailable(llvm::LibFunc_memset);
616 
617  TLI.setAvailable(llvm::LibFunc___kmpc_alloc_shared);
618  TLI.setAvailable(llvm::LibFunc___kmpc_free_shared);
619  } else {
620  TLI.setUnavailable(LibFunc_nvvm_reflect);
621  }
622 
623  // These vec_malloc/free routines are only available on AIX.
624  if (!T.isOSAIX()) {
625  TLI.setUnavailable(LibFunc_vec_calloc);
626  TLI.setUnavailable(LibFunc_vec_malloc);
627  TLI.setUnavailable(LibFunc_vec_realloc);
628  TLI.setUnavailable(LibFunc_vec_free);
629  }
630 
632 }
633 
635  // Default to everything being available.
636  memset(AvailableArray, -1, sizeof(AvailableArray));
637 
638  initialize(*this, Triple(), StandardNames);
639 }
640 
642  // Default to everything being available.
643  memset(AvailableArray, -1, sizeof(AvailableArray));
644 
645  initialize(*this, T, StandardNames);
646 }
647 
649  : CustomNames(TLI.CustomNames), ShouldExtI32Param(TLI.ShouldExtI32Param),
650  ShouldExtI32Return(TLI.ShouldExtI32Return),
651  ShouldSignExtI32Param(TLI.ShouldSignExtI32Param),
652  SizeOfInt(TLI.SizeOfInt) {
653  memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
654  VectorDescs = TLI.VectorDescs;
655  ScalarDescs = TLI.ScalarDescs;
656 }
657 
659  : CustomNames(std::move(TLI.CustomNames)),
660  ShouldExtI32Param(TLI.ShouldExtI32Param),
661  ShouldExtI32Return(TLI.ShouldExtI32Return),
662  ShouldSignExtI32Param(TLI.ShouldSignExtI32Param),
663  SizeOfInt(TLI.SizeOfInt) {
664  std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),
665  AvailableArray);
666  VectorDescs = TLI.VectorDescs;
667  ScalarDescs = TLI.ScalarDescs;
668 }
669 
671  CustomNames = TLI.CustomNames;
672  ShouldExtI32Param = TLI.ShouldExtI32Param;
673  ShouldExtI32Return = TLI.ShouldExtI32Return;
674  ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;
675  SizeOfInt = TLI.SizeOfInt;
676  memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
677  return *this;
678 }
679 
681  CustomNames = std::move(TLI.CustomNames);
682  ShouldExtI32Param = TLI.ShouldExtI32Param;
683  ShouldExtI32Return = TLI.ShouldExtI32Return;
684  ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;
685  SizeOfInt = TLI.SizeOfInt;
686  std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),
687  AvailableArray);
688  return *this;
689 }
690 
692  // Filter out empty names and names containing null bytes, those can't be in
693  // our table.
694  if (funcName.empty() || funcName.find('\0') != StringRef::npos)
695  return StringRef();
696 
697  // Check for \01 prefix that is used to mangle __asm declarations and
698  // strip it if present.
699  return GlobalValue::dropLLVMManglingEscape(funcName);
700 }
701 
703  funcName = sanitizeFunctionName(funcName);
704  if (funcName.empty())
705  return false;
706 
707  const auto *Start = std::begin(StandardNames);
708  const auto *End = std::end(StandardNames);
709  const auto *I = std::lower_bound(Start, End, funcName);
710  if (I != End && *I == funcName) {
711  F = (LibFunc)(I - Start);
712  return true;
713  }
714  return false;
715 }
716 
717 bool TargetLibraryInfoImpl::isValidProtoForLibFunc(const FunctionType &FTy,
718  LibFunc F,
719  const DataLayout *DL) const {
720  LLVMContext &Ctx = FTy.getContext();
721  Type *SizeTTy = DL ? DL->getIntPtrType(Ctx, /*AddressSpace=*/0) : nullptr;
722  auto IsSizeTTy = [SizeTTy](Type *Ty) {
723  return SizeTTy ? Ty == SizeTTy : Ty->isIntegerTy();
724  };
725  unsigned NumParams = FTy.getNumParams();
726 
727  switch (F) {
728  case LibFunc_execl:
729  case LibFunc_execlp:
730  case LibFunc_execle:
731  return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
732  FTy.getParamType(1)->isPointerTy() &&
733  FTy.getReturnType()->isIntegerTy(32));
734  case LibFunc_execv:
735  case LibFunc_execvp:
736  return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
737  FTy.getParamType(1)->isPointerTy() &&
738  FTy.getReturnType()->isIntegerTy(32));
739  case LibFunc_execvP:
740  case LibFunc_execvpe:
741  case LibFunc_execve:
742  return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() &&
743  FTy.getParamType(1)->isPointerTy() &&
744  FTy.getParamType(2)->isPointerTy() &&
745  FTy.getReturnType()->isIntegerTy(32));
746  case LibFunc_strlen_chk:
747  --NumParams;
748  if (!IsSizeTTy(FTy.getParamType(NumParams)))
749  return false;
751  case LibFunc_strlen:
752  return (NumParams == 1 && FTy.getParamType(0)->isPointerTy() &&
753  FTy.getReturnType()->isIntegerTy());
754 
755  case LibFunc_strchr:
756  case LibFunc_strrchr:
757  return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
758  FTy.getParamType(0) == FTy.getReturnType() &&
759  FTy.getParamType(1)->isIntegerTy());
760 
761  case LibFunc_strtol:
762  case LibFunc_strtod:
763  case LibFunc_strtof:
764  case LibFunc_strtoul:
765  case LibFunc_strtoll:
766  case LibFunc_strtold:
767  case LibFunc_strtoull:
768  return ((NumParams == 2 || NumParams == 3) &&
769  FTy.getParamType(0)->isPointerTy() &&
770  FTy.getParamType(1)->isPointerTy());
771  case LibFunc_strcat_chk:
772  --NumParams;
773  if (!IsSizeTTy(FTy.getParamType(NumParams)))
774  return false;
776  case LibFunc_strcat:
777  return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
778  FTy.getParamType(0) == FTy.getReturnType() &&
779  FTy.getParamType(1) == FTy.getReturnType());
780 
781  case LibFunc_strncat_chk:
782  --NumParams;
783  if (!IsSizeTTy(FTy.getParamType(NumParams)))
784  return false;
786  case LibFunc_strncat:
787  return (NumParams == 3 && FTy.getReturnType()->isPointerTy() &&
788  FTy.getParamType(0) == FTy.getReturnType() &&
789  FTy.getParamType(1) == FTy.getReturnType() &&
790  IsSizeTTy(FTy.getParamType(2)));
791 
792  case LibFunc_strcpy_chk:
793  case LibFunc_stpcpy_chk:
794  --NumParams;
795  if (!IsSizeTTy(FTy.getParamType(NumParams)))
796  return false;
798  case LibFunc_strcpy:
799  case LibFunc_stpcpy:
800  return (NumParams == 2 && FTy.getReturnType() == FTy.getParamType(0) &&
801  FTy.getParamType(0) == FTy.getParamType(1) &&
802  FTy.getParamType(0)->isPointerTy());
803 
804  case LibFunc_strlcat_chk:
805  case LibFunc_strlcpy_chk:
806  --NumParams;
807  if (!IsSizeTTy(FTy.getParamType(NumParams)))
808  return false;
810  case LibFunc_strlcat:
811  case LibFunc_strlcpy:
812  return NumParams == 3 && IsSizeTTy(FTy.getReturnType()) &&
813  FTy.getParamType(0)->isPointerTy() &&
814  FTy.getParamType(1)->isPointerTy() &&
815  IsSizeTTy(FTy.getParamType(2));
816 
817  case LibFunc_strncpy_chk:
818  case LibFunc_stpncpy_chk:
819  --NumParams;
820  if (!IsSizeTTy(FTy.getParamType(NumParams)))
821  return false;
823  case LibFunc_strncpy:
824  case LibFunc_stpncpy:
825  return (NumParams == 3 && FTy.getReturnType() == FTy.getParamType(0) &&
826  FTy.getParamType(0) == FTy.getParamType(1) &&
827  FTy.getParamType(0)->isPointerTy() &&
828  IsSizeTTy(FTy.getParamType(2)));
829 
830  case LibFunc_strxfrm:
831  return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() &&
832  FTy.getParamType(1)->isPointerTy());
833 
834  case LibFunc_strcmp:
835  return (NumParams == 2 && FTy.getReturnType()->isIntegerTy(32) &&
836  FTy.getParamType(0)->isPointerTy() &&
837  FTy.getParamType(0) == FTy.getParamType(1));
838 
839  case LibFunc_strncmp:
840  return (NumParams == 3 && FTy.getReturnType()->isIntegerTy(32) &&
841  FTy.getParamType(0)->isPointerTy() &&
842  FTy.getParamType(0) == FTy.getParamType(1) &&
843  IsSizeTTy(FTy.getParamType(2)));
844 
845  case LibFunc_strspn:
846  case LibFunc_strcspn:
847  return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
848  FTy.getParamType(0) == FTy.getParamType(1) &&
849  FTy.getReturnType()->isIntegerTy());
850 
851  case LibFunc_strcoll:
852  case LibFunc_strcasecmp:
853  case LibFunc_strncasecmp:
854  return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
855  FTy.getParamType(1)->isPointerTy());
856 
857  case LibFunc_strstr:
858  return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
859  FTy.getParamType(0)->isPointerTy() &&
860  FTy.getParamType(1)->isPointerTy());
861 
862  case LibFunc_strpbrk:
863  return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
864  FTy.getReturnType() == FTy.getParamType(0) &&
865  FTy.getParamType(0) == FTy.getParamType(1));
866 
867  case LibFunc_strtok:
868  case LibFunc_strtok_r:
869  return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy());
870  case LibFunc_scanf:
871  case LibFunc_setbuf:
872  case LibFunc_setvbuf:
873  return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy());
874  case LibFunc_strdup:
875  case LibFunc_strndup:
876  return (NumParams >= 1 && FTy.getReturnType()->isPointerTy() &&
877  FTy.getParamType(0)->isPointerTy());
878  case LibFunc_sscanf:
879  case LibFunc_stat:
880  case LibFunc_statvfs:
881  case LibFunc_siprintf:
882  case LibFunc_small_sprintf:
883  case LibFunc_sprintf:
884  return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
885  FTy.getParamType(1)->isPointerTy() &&
886  FTy.getReturnType()->isIntegerTy(32));
887 
888  case LibFunc_sprintf_chk:
889  return NumParams == 4 && FTy.getParamType(0)->isPointerTy() &&
890  FTy.getParamType(1)->isIntegerTy(32) &&
891  IsSizeTTy(FTy.getParamType(2)) &&
892  FTy.getParamType(3)->isPointerTy() &&
893  FTy.getReturnType()->isIntegerTy(32);
894 
895  case LibFunc_snprintf:
896  return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() &&
897  FTy.getParamType(2)->isPointerTy() &&
898  FTy.getReturnType()->isIntegerTy(32));
899 
900  case LibFunc_snprintf_chk:
901  return NumParams == 5 && FTy.getParamType(0)->isPointerTy() &&
902  IsSizeTTy(FTy.getParamType(1)) &&
903  FTy.getParamType(2)->isIntegerTy(32) &&
904  IsSizeTTy(FTy.getParamType(3)) &&
905  FTy.getParamType(4)->isPointerTy() &&
906  FTy.getReturnType()->isIntegerTy(32);
907 
908  case LibFunc_setitimer:
909  return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() &&
910  FTy.getParamType(2)->isPointerTy());
911  case LibFunc_system:
912  return (NumParams == 1 && FTy.getParamType(0)->isPointerTy());
913  case LibFunc___kmpc_alloc_shared:
914  case LibFunc_malloc:
915  case LibFunc_vec_malloc:
916  return (NumParams == 1 && FTy.getReturnType()->isPointerTy());
917  case LibFunc_memcmp:
918  return (NumParams == 3 && FTy.getReturnType()->isIntegerTy(32) &&
919  FTy.getParamType(0)->isPointerTy() &&
920  FTy.getParamType(1)->isPointerTy());
921 
922  case LibFunc_memchr:
923  case LibFunc_memrchr:
924  return (NumParams == 3 && FTy.getReturnType()->isPointerTy() &&
925  FTy.getReturnType() == FTy.getParamType(0) &&
926  FTy.getParamType(1)->isIntegerTy(32) &&
927  IsSizeTTy(FTy.getParamType(2)));
928  case LibFunc_modf:
929  case LibFunc_modff:
930  case LibFunc_modfl:
931  return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy());
932 
933  case LibFunc_memcpy_chk:
934  case LibFunc_mempcpy_chk:
935  case LibFunc_memmove_chk:
936  --NumParams;
937  if (!IsSizeTTy(FTy.getParamType(NumParams)))
938  return false;
940  case LibFunc_memcpy:
941  case LibFunc_mempcpy:
942  case LibFunc_memmove:
943  return (NumParams == 3 && FTy.getReturnType() == FTy.getParamType(0) &&
944  FTy.getParamType(0)->isPointerTy() &&
945  FTy.getParamType(1)->isPointerTy() &&
946  IsSizeTTy(FTy.getParamType(2)));
947 
948  case LibFunc_memset_chk:
949  --NumParams;
950  if (!IsSizeTTy(FTy.getParamType(NumParams)))
951  return false;
953  case LibFunc_memset:
954  return (NumParams == 3 && FTy.getReturnType() == FTy.getParamType(0) &&
955  FTy.getParamType(0)->isPointerTy() &&
956  FTy.getParamType(1)->isIntegerTy() &&
957  IsSizeTTy(FTy.getParamType(2)));
958 
959  case LibFunc_memccpy_chk:
960  --NumParams;
961  if (!IsSizeTTy(FTy.getParamType(NumParams)))
962  return false;
964  case LibFunc_memccpy:
965  return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy());
966  case LibFunc_memalign:
967  return (FTy.getReturnType()->isPointerTy());
968  case LibFunc_realloc:
969  case LibFunc_reallocf:
970  case LibFunc_vec_realloc:
971  return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
972  FTy.getParamType(0) == FTy.getReturnType() &&
973  IsSizeTTy(FTy.getParamType(1)));
974  case LibFunc_read:
975  return (NumParams == 3 && FTy.getParamType(1)->isPointerTy());
976  case LibFunc_rewind:
977  case LibFunc_rmdir:
978  case LibFunc_remove:
979  case LibFunc_realpath:
980  return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy());
981  case LibFunc_rename:
982  return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
983  FTy.getParamType(1)->isPointerTy());
984  case LibFunc_readlink:
985  return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
986  FTy.getParamType(1)->isPointerTy());
987  case LibFunc_write:
988  return (NumParams == 3 && FTy.getParamType(1)->isPointerTy());
989  case LibFunc_aligned_alloc:
990  return (NumParams == 2 && FTy.getReturnType()->isPointerTy());
991  case LibFunc_bcopy:
992  case LibFunc_bcmp:
993  return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() &&
994  FTy.getParamType(1)->isPointerTy());
995  case LibFunc_bzero:
996  return (NumParams == 2 && FTy.getParamType(0)->isPointerTy());
997  case LibFunc_calloc:
998  case LibFunc_vec_calloc:
999  return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
1000  FTy.getParamType(0) == FTy.getParamType(1));
1001 
1002  case LibFunc_atof:
1003  case LibFunc_atoi:
1004  case LibFunc_atol:
1005  case LibFunc_atoll:
1006  case LibFunc_ferror:
1007  case LibFunc_getenv:
1008  case LibFunc_getpwnam:
1009  case LibFunc_iprintf:
1010  case LibFunc_small_printf:
1011  case LibFunc_pclose:
1012  case LibFunc_perror:
1013  case LibFunc_printf:
1014  case LibFunc_puts:
1015  case LibFunc_uname:
1016  case LibFunc_under_IO_getc:
1017  case LibFunc_unlink:
1018  case LibFunc_unsetenv:
1019  return (NumParams == 1 && FTy.getParamType(0)->isPointerTy());
1020 
1021  case LibFunc_access:
1022  case LibFunc_chmod:
1023  case LibFunc_chown:
1024  case LibFunc_clearerr:
1025  case LibFunc_closedir:
1026  case LibFunc_ctermid:
1027  case LibFunc_fclose:
1028  case LibFunc_feof:
1029  case LibFunc_fflush:
1030  case LibFunc_fgetc:
1031  case LibFunc_fgetc_unlocked:
1032  case LibFunc_fileno:
1033  case LibFunc_flockfile:
1034  case LibFunc_free:
1035  case LibFunc_fseek:
1036  case LibFunc_fseeko64:
1037  case LibFunc_fseeko:
1038  case LibFunc_fsetpos:
1039  case LibFunc_ftell:
1040  case LibFunc_ftello64:
1041  case LibFunc_ftello:
1042  case LibFunc_ftrylockfile:
1043  case LibFunc_funlockfile:
1044  case LibFunc_getc:
1045  case LibFunc_getc_unlocked:
1046  case LibFunc_getlogin_r:
1047  case LibFunc_mkdir:
1048  case LibFunc_mktime:
1049  case LibFunc_times:
1050  case LibFunc_vec_free:
1051  return (NumParams != 0 && FTy.getParamType(0)->isPointerTy());
1052  case LibFunc___kmpc_free_shared:
1053  return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
1054  IsSizeTTy(FTy.getParamType(1)));
1055 
1056  case LibFunc_fopen:
1057  return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
1058  FTy.getParamType(0)->isPointerTy() &&
1059  FTy.getParamType(1)->isPointerTy());
1060  case LibFunc_fork:
1061  return (NumParams == 0 && FTy.getReturnType()->isIntegerTy(32));
1062  case LibFunc_fdopen:
1063  return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
1064  FTy.getParamType(1)->isPointerTy());
1065  case LibFunc_fputc:
1066  case LibFunc_fputc_unlocked:
1067  case LibFunc_fstat:
1068  case LibFunc_frexp:
1069  case LibFunc_frexpf:
1070  case LibFunc_frexpl:
1071  case LibFunc_fstatvfs:
1072  return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
1073  case LibFunc_fgets:
1074  case LibFunc_fgets_unlocked:
1075  return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() &&
1076  FTy.getParamType(2)->isPointerTy());
1077  case LibFunc_fread:
1078  case LibFunc_fread_unlocked:
1079  return (NumParams == 4 && FTy.getParamType(0)->isPointerTy() &&
1080  FTy.getParamType(3)->isPointerTy());
1081  case LibFunc_fwrite:
1082  case LibFunc_fwrite_unlocked:
1083  return (NumParams == 4 && FTy.getReturnType()->isIntegerTy() &&
1084  FTy.getParamType(0)->isPointerTy() &&
1085  FTy.getParamType(1)->isIntegerTy() &&
1086  FTy.getParamType(2)->isIntegerTy() &&
1087  FTy.getParamType(3)->isPointerTy());
1088  case LibFunc_fputs:
1089  case LibFunc_fputs_unlocked:
1090  return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
1091  FTy.getParamType(1)->isPointerTy());
1092  case LibFunc_fscanf:
1093  case LibFunc_fiprintf:
1094  case LibFunc_small_fprintf:
1095  case LibFunc_fprintf:
1096  return (NumParams >= 2 && FTy.getReturnType()->isIntegerTy() &&
1097  FTy.getParamType(0)->isPointerTy() &&
1098  FTy.getParamType(1)->isPointerTy());
1099  case LibFunc_fgetpos:
1100  return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
1101  FTy.getParamType(1)->isPointerTy());
1102  case LibFunc_getchar:
1103  case LibFunc_getchar_unlocked:
1104  return (NumParams == 0 && FTy.getReturnType()->isIntegerTy());
1105  case LibFunc_gets:
1106  return (NumParams == 1 && FTy.getParamType(0)->isPointerTy());
1107  case LibFunc_getitimer:
1108  return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
1109  case LibFunc_ungetc:
1110  return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
1111  case LibFunc_utime:
1112  case LibFunc_utimes:
1113  return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
1114  FTy.getParamType(1)->isPointerTy());
1115  case LibFunc_putc:
1116  case LibFunc_putc_unlocked:
1117  return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
1118  case LibFunc_pread:
1119  case LibFunc_pwrite:
1120  return (NumParams == 4 && FTy.getParamType(1)->isPointerTy());
1121  case LibFunc_popen:
1122  return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
1123  FTy.getParamType(0)->isPointerTy() &&
1124  FTy.getParamType(1)->isPointerTy());
1125  case LibFunc_vscanf:
1126  return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
1127  case LibFunc_vsscanf:
1128  return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() &&
1129  FTy.getParamType(2)->isPointerTy());
1130  case LibFunc_vfscanf:
1131  return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() &&
1132  FTy.getParamType(2)->isPointerTy());
1133  case LibFunc_valloc:
1134  return (FTy.getReturnType()->isPointerTy());
1135  case LibFunc_vprintf:
1136  return (NumParams == 2 && FTy.getParamType(0)->isPointerTy());
1137  case LibFunc_vfprintf:
1138  case LibFunc_vsprintf:
1139  return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() &&
1140  FTy.getParamType(1)->isPointerTy());
1141  case LibFunc_vsprintf_chk:
1142  return NumParams == 5 && FTy.getParamType(0)->isPointerTy() &&
1143  FTy.getParamType(1)->isIntegerTy(32) &&
1144  IsSizeTTy(FTy.getParamType(2)) && FTy.getParamType(3)->isPointerTy();
1145  case LibFunc_vsnprintf:
1146  return (NumParams == 4 && FTy.getParamType(0)->isPointerTy() &&
1147  FTy.getParamType(2)->isPointerTy());
1148  case LibFunc_vsnprintf_chk:
1149  return NumParams == 6 && FTy.getParamType(0)->isPointerTy() &&
1150  FTy.getParamType(2)->isIntegerTy(32) &&
1151  IsSizeTTy(FTy.getParamType(3)) && FTy.getParamType(4)->isPointerTy();
1152  case LibFunc_open:
1153  return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy());
1154  case LibFunc_opendir:
1155  return (NumParams == 1 && FTy.getReturnType()->isPointerTy() &&
1156  FTy.getParamType(0)->isPointerTy());
1157  case LibFunc_tmpfile:
1158  return (FTy.getReturnType()->isPointerTy());
1159  case LibFunc_htonl:
1160  case LibFunc_ntohl:
1161  return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(32) &&
1162  FTy.getReturnType() == FTy.getParamType(0));
1163  case LibFunc_htons:
1164  case LibFunc_ntohs:
1165  return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(16) &&
1166  FTy.getReturnType() == FTy.getParamType(0));
1167  case LibFunc_lstat:
1168  return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
1169  FTy.getParamType(1)->isPointerTy());
1170  case LibFunc_lchown:
1171  return (NumParams == 3 && FTy.getParamType(0)->isPointerTy());
1172  case LibFunc_qsort:
1173  return (NumParams == 4 && FTy.getParamType(3)->isPointerTy());
1174  case LibFunc_dunder_strdup:
1175  case LibFunc_dunder_strndup:
1176  return (NumParams >= 1 && FTy.getReturnType()->isPointerTy() &&
1177  FTy.getParamType(0)->isPointerTy());
1178  case LibFunc_dunder_strtok_r:
1179  return (NumParams == 3 && FTy.getParamType(1)->isPointerTy());
1180  case LibFunc_under_IO_putc:
1181  return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
1182  case LibFunc_dunder_isoc99_scanf:
1183  return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy());
1184  case LibFunc_stat64:
1185  case LibFunc_lstat64:
1186  case LibFunc_statvfs64:
1187  return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
1188  FTy.getParamType(1)->isPointerTy());
1189  case LibFunc_dunder_isoc99_sscanf:
1190  return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
1191  FTy.getParamType(1)->isPointerTy());
1192  case LibFunc_fopen64:
1193  return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
1194  FTy.getParamType(0)->isPointerTy() &&
1195  FTy.getParamType(1)->isPointerTy());
1196  case LibFunc_tmpfile64:
1197  return (FTy.getReturnType()->isPointerTy());
1198  case LibFunc_fstat64:
1199  case LibFunc_fstatvfs64:
1200  return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
1201  case LibFunc_open64:
1202  return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy());
1203  case LibFunc_gettimeofday:
1204  return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
1205  FTy.getParamType(1)->isPointerTy());
1206 
1207  // new(unsigned int);
1208  case LibFunc_Znwj:
1209  // new(unsigned long);
1210  case LibFunc_Znwm:
1211  // new[](unsigned int);
1212  case LibFunc_Znaj:
1213  // new[](unsigned long);
1214  case LibFunc_Znam:
1215  // new(unsigned int);
1216  case LibFunc_msvc_new_int:
1217  // new(unsigned long long);
1218  case LibFunc_msvc_new_longlong:
1219  // new[](unsigned int);
1220  case LibFunc_msvc_new_array_int:
1221  // new[](unsigned long long);
1222  case LibFunc_msvc_new_array_longlong:
1223  return (NumParams == 1 && FTy.getReturnType()->isPointerTy());
1224 
1225  // new(unsigned int, nothrow);
1226  case LibFunc_ZnwjRKSt9nothrow_t:
1227  // new(unsigned long, nothrow);
1228  case LibFunc_ZnwmRKSt9nothrow_t:
1229  // new[](unsigned int, nothrow);
1230  case LibFunc_ZnajRKSt9nothrow_t:
1231  // new[](unsigned long, nothrow);
1232  case LibFunc_ZnamRKSt9nothrow_t:
1233  // new(unsigned int, nothrow);
1234  case LibFunc_msvc_new_int_nothrow:
1235  // new(unsigned long long, nothrow);
1236  case LibFunc_msvc_new_longlong_nothrow:
1237  // new[](unsigned int, nothrow);
1238  case LibFunc_msvc_new_array_int_nothrow:
1239  // new[](unsigned long long, nothrow);
1240  case LibFunc_msvc_new_array_longlong_nothrow:
1241  // new(unsigned int, align_val_t)
1242  case LibFunc_ZnwjSt11align_val_t:
1243  // new(unsigned long, align_val_t)
1244  case LibFunc_ZnwmSt11align_val_t:
1245  // new[](unsigned int, align_val_t)
1246  case LibFunc_ZnajSt11align_val_t:
1247  // new[](unsigned long, align_val_t)
1248  case LibFunc_ZnamSt11align_val_t:
1249  return (NumParams == 2 && FTy.getReturnType()->isPointerTy());
1250 
1251  // new(unsigned int, align_val_t, nothrow)
1252  case LibFunc_ZnwjSt11align_val_tRKSt9nothrow_t:
1253  // new(unsigned long, align_val_t, nothrow)
1254  case LibFunc_ZnwmSt11align_val_tRKSt9nothrow_t:
1255  // new[](unsigned int, align_val_t, nothrow)
1256  case LibFunc_ZnajSt11align_val_tRKSt9nothrow_t:
1257  // new[](unsigned long, align_val_t, nothrow)
1258  case LibFunc_ZnamSt11align_val_tRKSt9nothrow_t:
1259  return (NumParams == 3 && FTy.getReturnType()->isPointerTy());
1260 
1261  // void operator delete[](void*);
1262  case LibFunc_ZdaPv:
1263  // void operator delete(void*);
1264  case LibFunc_ZdlPv:
1265  // void operator delete[](void*);
1266  case LibFunc_msvc_delete_array_ptr32:
1267  // void operator delete[](void*);
1268  case LibFunc_msvc_delete_array_ptr64:
1269  // void operator delete(void*);
1270  case LibFunc_msvc_delete_ptr32:
1271  // void operator delete(void*);
1272  case LibFunc_msvc_delete_ptr64:
1273  return (NumParams == 1 && FTy.getParamType(0)->isPointerTy());
1274 
1275  // void operator delete[](void*, nothrow);
1276  case LibFunc_ZdaPvRKSt9nothrow_t:
1277  // void operator delete[](void*, unsigned int);
1278  case LibFunc_ZdaPvj:
1279  // void operator delete[](void*, unsigned long);
1280  case LibFunc_ZdaPvm:
1281  // void operator delete(void*, nothrow);
1282  case LibFunc_ZdlPvRKSt9nothrow_t:
1283  // void operator delete(void*, unsigned int);
1284  case LibFunc_ZdlPvj:
1285  // void operator delete(void*, unsigned long);
1286  case LibFunc_ZdlPvm:
1287  // void operator delete(void*, align_val_t)
1288  case LibFunc_ZdlPvSt11align_val_t:
1289  // void operator delete[](void*, align_val_t)
1290  case LibFunc_ZdaPvSt11align_val_t:
1291  // void operator delete[](void*, unsigned int);
1292  case LibFunc_msvc_delete_array_ptr32_int:
1293  // void operator delete[](void*, nothrow);
1294  case LibFunc_msvc_delete_array_ptr32_nothrow:
1295  // void operator delete[](void*, unsigned long long);
1296  case LibFunc_msvc_delete_array_ptr64_longlong:
1297  // void operator delete[](void*, nothrow);
1298  case LibFunc_msvc_delete_array_ptr64_nothrow:
1299  // void operator delete(void*, unsigned int);
1300  case LibFunc_msvc_delete_ptr32_int:
1301  // void operator delete(void*, nothrow);
1302  case LibFunc_msvc_delete_ptr32_nothrow:
1303  // void operator delete(void*, unsigned long long);
1304  case LibFunc_msvc_delete_ptr64_longlong:
1305  // void operator delete(void*, nothrow);
1306  case LibFunc_msvc_delete_ptr64_nothrow:
1307  return (NumParams == 2 && FTy.getParamType(0)->isPointerTy());
1308 
1309  // void operator delete(void*, align_val_t, nothrow)
1310  case LibFunc_ZdlPvSt11align_val_tRKSt9nothrow_t:
1311  // void operator delete[](void*, align_val_t, nothrow)
1312  case LibFunc_ZdaPvSt11align_val_tRKSt9nothrow_t:
1313  // void operator delete(void*, unsigned int, align_val_t)
1314  case LibFunc_ZdlPvjSt11align_val_t:
1315  // void operator delete(void*, unsigned long, align_val_t)
1316  case LibFunc_ZdlPvmSt11align_val_t:
1317  // void operator delete[](void*, unsigned int, align_val_t);
1318  case LibFunc_ZdaPvjSt11align_val_t:
1319  // void operator delete[](void*, unsigned long, align_val_t);
1320  case LibFunc_ZdaPvmSt11align_val_t:
1321  return (NumParams == 3 && FTy.getParamType(0)->isPointerTy());
1322 
1323  // void __atomic_load(size_t, void *, void *, int)
1324  case LibFunc_atomic_load:
1325  // void __atomic_store(size_t, void *, void *, int)
1326  case LibFunc_atomic_store:
1327  return (NumParams == 4 && FTy.getParamType(0)->isIntegerTy() &&
1328  FTy.getParamType(1)->isPointerTy() &&
1329  FTy.getParamType(2)->isPointerTy() &&
1330  FTy.getParamType(3)->isIntegerTy());
1331 
1332  case LibFunc_memset_pattern16:
1333  return (!FTy.isVarArg() && NumParams == 3 &&
1334  FTy.getParamType(0)->isPointerTy() &&
1335  FTy.getParamType(1)->isPointerTy() &&
1336  FTy.getParamType(2)->isIntegerTy());
1337 
1338  case LibFunc_cxa_guard_abort:
1339  case LibFunc_cxa_guard_acquire:
1340  case LibFunc_cxa_guard_release:
1341  case LibFunc_nvvm_reflect:
1342  return (NumParams == 1 && FTy.getParamType(0)->isPointerTy());
1343 
1344  case LibFunc_sincospi_stret:
1345  case LibFunc_sincospif_stret:
1346  return (NumParams == 1 && FTy.getParamType(0)->isFloatingPointTy());
1347 
1348  case LibFunc_acos:
1349  case LibFunc_acos_finite:
1350  case LibFunc_acosf:
1351  case LibFunc_acosf_finite:
1352  case LibFunc_acosh:
1353  case LibFunc_acosh_finite:
1354  case LibFunc_acoshf:
1355  case LibFunc_acoshf_finite:
1356  case LibFunc_acoshl:
1357  case LibFunc_acoshl_finite:
1358  case LibFunc_acosl:
1359  case LibFunc_acosl_finite:
1360  case LibFunc_asin:
1361  case LibFunc_asin_finite:
1362  case LibFunc_asinf:
1363  case LibFunc_asinf_finite:
1364  case LibFunc_asinh:
1365  case LibFunc_asinhf:
1366  case LibFunc_asinhl:
1367  case LibFunc_asinl:
1368  case LibFunc_asinl_finite:
1369  case LibFunc_atan:
1370  case LibFunc_atanf:
1371  case LibFunc_atanh:
1372  case LibFunc_atanh_finite:
1373  case LibFunc_atanhf:
1374  case LibFunc_atanhf_finite:
1375  case LibFunc_atanhl:
1376  case LibFunc_atanhl_finite:
1377  case LibFunc_atanl:
1378  case LibFunc_cbrt:
1379  case LibFunc_cbrtf:
1380  case LibFunc_cbrtl:
1381  case LibFunc_ceil:
1382  case LibFunc_ceilf:
1383  case LibFunc_ceill:
1384  case LibFunc_cos:
1385  case LibFunc_cosf:
1386  case LibFunc_cosh:
1387  case LibFunc_cosh_finite:
1388  case LibFunc_coshf:
1389  case LibFunc_coshf_finite:
1390  case LibFunc_coshl:
1391  case LibFunc_coshl_finite:
1392  case LibFunc_cosl:
1393  case LibFunc_exp10:
1394  case LibFunc_exp10_finite:
1395  case LibFunc_exp10f:
1396  case LibFunc_exp10f_finite:
1397  case LibFunc_exp10l:
1398  case LibFunc_exp10l_finite:
1399  case LibFunc_exp2:
1400  case LibFunc_exp2_finite:
1401  case LibFunc_exp2f:
1402  case LibFunc_exp2f_finite:
1403  case LibFunc_exp2l:
1404  case LibFunc_exp2l_finite:
1405  case LibFunc_exp:
1406  case LibFunc_exp_finite:
1407  case LibFunc_expf:
1408  case LibFunc_expf_finite:
1409  case LibFunc_expl:
1410  case LibFunc_expl_finite:
1411  case LibFunc_expm1:
1412  case LibFunc_expm1f:
1413  case LibFunc_expm1l:
1414  case LibFunc_fabs:
1415  case LibFunc_fabsf:
1416  case LibFunc_fabsl:
1417  case LibFunc_floor:
1418  case LibFunc_floorf:
1419  case LibFunc_floorl:
1420  case LibFunc_log10:
1421  case LibFunc_log10_finite:
1422  case LibFunc_log10f:
1423  case LibFunc_log10f_finite:
1424  case LibFunc_log10l:
1425  case LibFunc_log10l_finite:
1426  case LibFunc_log1p:
1427  case LibFunc_log1pf:
1428  case LibFunc_log1pl:
1429  case LibFunc_log2:
1430  case LibFunc_log2_finite:
1431  case LibFunc_log2f:
1432  case LibFunc_log2f_finite:
1433  case LibFunc_log2l:
1434  case LibFunc_log2l_finite:
1435  case LibFunc_log:
1436  case LibFunc_log_finite:
1437  case LibFunc_logb:
1438  case LibFunc_logbf:
1439  case LibFunc_logbl:
1440  case LibFunc_logf:
1441  case LibFunc_logf_finite:
1442  case LibFunc_logl:
1443  case LibFunc_logl_finite:
1444  case LibFunc_nearbyint:
1445  case LibFunc_nearbyintf:
1446  case LibFunc_nearbyintl:
1447  case LibFunc_rint:
1448  case LibFunc_rintf:
1449  case LibFunc_rintl:
1450  case LibFunc_round:
1451  case LibFunc_roundf:
1452  case LibFunc_roundl:
1453  case LibFunc_roundeven:
1454  case LibFunc_roundevenf:
1455  case LibFunc_roundevenl:
1456  case LibFunc_sin:
1457  case LibFunc_sinf:
1458  case LibFunc_sinh:
1459  case LibFunc_sinh_finite:
1460  case LibFunc_sinhf:
1461  case LibFunc_sinhf_finite:
1462  case LibFunc_sinhl:
1463  case LibFunc_sinhl_finite:
1464  case LibFunc_sinl:
1465  case LibFunc_sqrt:
1466  case LibFunc_sqrt_finite:
1467  case LibFunc_sqrtf:
1468  case LibFunc_sqrtf_finite:
1469  case LibFunc_sqrtl:
1470  case LibFunc_sqrtl_finite:
1471  case LibFunc_tan:
1472  case LibFunc_tanf:
1473  case LibFunc_tanh:
1474  case LibFunc_tanhf:
1475  case LibFunc_tanhl:
1476  case LibFunc_tanl:
1477  case LibFunc_trunc:
1478  case LibFunc_truncf:
1479  case LibFunc_truncl:
1480  return (NumParams == 1 && FTy.getReturnType()->isFloatingPointTy() &&
1481  FTy.getReturnType() == FTy.getParamType(0));
1482 
1483  case LibFunc_atan2:
1484  case LibFunc_atan2_finite:
1485  case LibFunc_atan2f:
1486  case LibFunc_atan2f_finite:
1487  case LibFunc_atan2l:
1488  case LibFunc_atan2l_finite:
1489  case LibFunc_fmin:
1490  case LibFunc_fminf:
1491  case LibFunc_fminl:
1492  case LibFunc_fmax:
1493  case LibFunc_fmaxf:
1494  case LibFunc_fmaxl:
1495  case LibFunc_fmod:
1496  case LibFunc_fmodf:
1497  case LibFunc_fmodl:
1498  case LibFunc_remainder:
1499  case LibFunc_remainderf:
1500  case LibFunc_remainderl:
1501  case LibFunc_copysign:
1502  case LibFunc_copysignf:
1503  case LibFunc_copysignl:
1504  case LibFunc_pow:
1505  case LibFunc_pow_finite:
1506  case LibFunc_powf:
1507  case LibFunc_powf_finite:
1508  case LibFunc_powl:
1509  case LibFunc_powl_finite:
1510  return (NumParams == 2 && FTy.getReturnType()->isFloatingPointTy() &&
1511  FTy.getReturnType() == FTy.getParamType(0) &&
1512  FTy.getReturnType() == FTy.getParamType(1));
1513 
1514  case LibFunc_ldexp:
1515  case LibFunc_ldexpf:
1516  case LibFunc_ldexpl:
1517  return (NumParams == 2 && FTy.getReturnType()->isFloatingPointTy() &&
1518  FTy.getReturnType() == FTy.getParamType(0) &&
1519  FTy.getParamType(1)->isIntegerTy(getIntSize()));
1520 
1521  case LibFunc_ffs:
1522  case LibFunc_ffsl:
1523  case LibFunc_ffsll:
1524  case LibFunc_fls:
1525  case LibFunc_flsl:
1526  case LibFunc_flsll:
1527  return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(32) &&
1528  FTy.getParamType(0)->isIntegerTy());
1529 
1530  case LibFunc_isdigit:
1531  case LibFunc_isascii:
1532  case LibFunc_toascii:
1533  case LibFunc_putchar:
1534  case LibFunc_putchar_unlocked:
1535  return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(32) &&
1536  FTy.getReturnType() == FTy.getParamType(0));
1537 
1538  case LibFunc_abs:
1539  case LibFunc_labs:
1540  case LibFunc_llabs:
1541  return (NumParams == 1 && FTy.getReturnType()->isIntegerTy() &&
1542  FTy.getReturnType() == FTy.getParamType(0));
1543 
1544  case LibFunc_cxa_atexit:
1545  return (NumParams == 3 && FTy.getReturnType()->isIntegerTy() &&
1546  FTy.getParamType(0)->isPointerTy() &&
1547  FTy.getParamType(1)->isPointerTy() &&
1548  FTy.getParamType(2)->isPointerTy());
1549 
1550  case LibFunc_sinpi:
1551  case LibFunc_cospi:
1552  return (NumParams == 1 && FTy.getReturnType()->isDoubleTy() &&
1553  FTy.getReturnType() == FTy.getParamType(0));
1554 
1555  case LibFunc_sinpif:
1556  case LibFunc_cospif:
1557  return (NumParams == 1 && FTy.getReturnType()->isFloatTy() &&
1558  FTy.getReturnType() == FTy.getParamType(0));
1559 
1560  case LibFunc_strnlen:
1561  return (NumParams == 2 && FTy.getReturnType() == FTy.getParamType(1) &&
1562  FTy.getParamType(0)->isPointerTy() &&
1563  IsSizeTTy(FTy.getParamType(1)));
1564 
1565  case LibFunc_posix_memalign:
1566  return (NumParams == 3 && FTy.getReturnType()->isIntegerTy(32) &&
1567  FTy.getParamType(0)->isPointerTy() &&
1568  IsSizeTTy(FTy.getParamType(1)) && IsSizeTTy(FTy.getParamType(2)));
1569 
1570  case LibFunc_wcslen:
1571  return (NumParams == 1 && FTy.getParamType(0)->isPointerTy() &&
1572  FTy.getReturnType()->isIntegerTy());
1573 
1574  case LibFunc_cabs:
1575  case LibFunc_cabsf:
1576  case LibFunc_cabsl: {
1577  Type* RetTy = FTy.getReturnType();
1578  if (!RetTy->isFloatingPointTy())
1579  return false;
1580 
1581  // NOTE: These prototypes are target specific and currently support
1582  // "complex" passed as an array or discrete real & imaginary parameters.
1583  // Add other calling conventions to enable libcall optimizations.
1584  if (NumParams == 1)
1585  return (FTy.getParamType(0)->isArrayTy() &&
1586  FTy.getParamType(0)->getArrayNumElements() == 2 &&
1587  FTy.getParamType(0)->getArrayElementType() == RetTy);
1588  else if (NumParams == 2)
1589  return (FTy.getParamType(0) == RetTy && FTy.getParamType(1) == RetTy);
1590  else
1591  return false;
1592  }
1593  case LibFunc::NumLibFuncs:
1594  case LibFunc::NotLibFunc:
1595  break;
1596  }
1597 
1598  llvm_unreachable("Invalid libfunc");
1599 }
1600 
1602  LibFunc &F) const {
1603  // Intrinsics don't overlap w/libcalls; if our module has a large number of
1604  // intrinsics, this ends up being an interesting compile time win since we
1605  // avoid string normalization and comparison.
1606  if (FDecl.isIntrinsic()) return false;
1607 
1608  const DataLayout *DL =
1609  FDecl.getParent() ? &FDecl.getParent()->getDataLayout() : nullptr;
1610  return getLibFunc(FDecl.getName(), F) &&
1611  isValidProtoForLibFunc(*FDecl.getFunctionType(), F, DL);
1612 }
1613 
1615  memset(AvailableArray, 0, sizeof(AvailableArray));
1616 }
1617 
1618 static bool compareByScalarFnName(const VecDesc &LHS, const VecDesc &RHS) {
1619  return LHS.ScalarFnName < RHS.ScalarFnName;
1620 }
1621 
1622 static bool compareByVectorFnName(const VecDesc &LHS, const VecDesc &RHS) {
1623  return LHS.VectorFnName < RHS.VectorFnName;
1624 }
1625 
1626 static bool compareWithScalarFnName(const VecDesc &LHS, StringRef S) {
1627  return LHS.ScalarFnName < S;
1628 }
1629 
1631  llvm::append_range(VectorDescs, Fns);
1632  llvm::sort(VectorDescs, compareByScalarFnName);
1633 
1634  llvm::append_range(ScalarDescs, Fns);
1635  llvm::sort(ScalarDescs, compareByVectorFnName);
1636 }
1637 
1639  enum VectorLibrary VecLib) {
1640  switch (VecLib) {
1641  case Accelerate: {
1642  const VecDesc VecFuncs[] = {
1643  #define TLI_DEFINE_ACCELERATE_VECFUNCS
1644  #include "llvm/Analysis/VecFuncs.def"
1645  };
1646  addVectorizableFunctions(VecFuncs);
1647  break;
1648  }
1649  case DarwinLibSystemM: {
1650  const VecDesc VecFuncs[] = {
1651  #define TLI_DEFINE_DARWIN_LIBSYSTEM_M_VECFUNCS
1652  #include "llvm/Analysis/VecFuncs.def"
1653  };
1654  addVectorizableFunctions(VecFuncs);
1655  break;
1656  }
1657  case LIBMVEC_X86: {
1658  const VecDesc VecFuncs[] = {
1659  #define TLI_DEFINE_LIBMVEC_X86_VECFUNCS
1660  #include "llvm/Analysis/VecFuncs.def"
1661  };
1662  addVectorizableFunctions(VecFuncs);
1663  break;
1664  }
1665  case MASSV: {
1666  const VecDesc VecFuncs[] = {
1667  #define TLI_DEFINE_MASSV_VECFUNCS
1668  #include "llvm/Analysis/VecFuncs.def"
1669  };
1670  addVectorizableFunctions(VecFuncs);
1671  break;
1672  }
1673  case SVML: {
1674  const VecDesc VecFuncs[] = {
1675  #define TLI_DEFINE_SVML_VECFUNCS
1676  #include "llvm/Analysis/VecFuncs.def"
1677  };
1678  addVectorizableFunctions(VecFuncs);
1679  break;
1680  }
1681  case NoLibrary:
1682  break;
1683  }
1684 }
1685 
1687  funcName = sanitizeFunctionName(funcName);
1688  if (funcName.empty())
1689  return false;
1690 
1691  std::vector<VecDesc>::const_iterator I =
1692  llvm::lower_bound(VectorDescs, funcName, compareWithScalarFnName);
1693  return I != VectorDescs.end() && StringRef(I->ScalarFnName) == funcName;
1694 }
1695 
1696 StringRef
1698  const ElementCount &VF) const {
1700  if (F.empty())
1701  return F;
1702  std::vector<VecDesc>::const_iterator I =
1704  while (I != VectorDescs.end() && StringRef(I->ScalarFnName) == F) {
1705  if (I->VectorizationFactor == VF)
1706  return I->VectorFnName;
1707  ++I;
1708  }
1709  return StringRef();
1710 }
1711 
1714  if (!BaselineInfoImpl)
1715  BaselineInfoImpl =
1716  TargetLibraryInfoImpl(Triple(F.getParent()->getTargetTriple()));
1717  return TargetLibraryInfo(*BaselineInfoImpl, &F);
1718 }
1719 
1721  if (auto *ShortWChar = cast_or_null<ConstantAsMetadata>(
1722  M.getModuleFlag("wchar_size")))
1723  return cast<ConstantInt>(ShortWChar->getValue())->getZExtValue();
1724  return 0;
1725 }
1726 
1730 }
1731 
1735 }
1736 
1738  const TargetLibraryInfoImpl &TLIImpl)
1739  : ImmutablePass(ID), TLA(TLIImpl) {
1741 }
1742 
1743 AnalysisKey TargetLibraryAnalysis::Key;
1744 
1745 // Register the basic pass.
1747  "Target Library Information", false, true)
1749 
1750 void TargetLibraryInfoWrapperPass::anchor() {}
1751 
1753  ElementCount &FixedVF,
1754  ElementCount &ScalableVF) const {
1755  ScalarF = sanitizeFunctionName(ScalarF);
1756  // Use '0' here because a type of the form <vscale x 1 x ElTy> is not the
1757  // same as a scalar.
1758  ScalableVF = ElementCount::getScalable(0);
1759  FixedVF = ElementCount::getFixed(1);
1760  if (ScalarF.empty())
1761  return;
1762 
1763  std::vector<VecDesc>::const_iterator I =
1764  llvm::lower_bound(VectorDescs, ScalarF, compareWithScalarFnName);
1765  while (I != VectorDescs.end() && StringRef(I->ScalarFnName) == ScalarF) {
1766  ElementCount *VF =
1767  I->VectorizationFactor.isScalable() ? &ScalableVF : &FixedVF;
1768  if (ElementCount::isKnownGT(I->VectorizationFactor, *VF))
1769  *VF = I->VectorizationFactor;
1770  ++I;
1771  }
1772 }
llvm::TargetLibraryInfoImpl::setShouldSignExtI32Param
void setShouldSignExtI32Param(bool Val)
Set to true iff i32 parameters to library functions should have signext attribute if they correspond ...
Definition: TargetLibraryInfo.h:185
llvm::VecDesc
Describes a possible vectorization of a function.
Definition: TargetLibraryInfo.h:28
llvm::Function::isIntrinsic
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
Definition: Function.h:210
llvm::TargetLibraryInfoImpl::setAvailable
void setAvailable(LibFunc F)
Forces a function to be marked as available.
Definition: TargetLibraryInfo.h:126
llvm::TargetLibraryInfoImpl::SVML
@ SVML
Definition: TargetLibraryInfo.h:95
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
llvm::Instruction::getModule
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Definition: Instruction.cpp:66
llvm::StringRef::empty
LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:153
llvm::TargetLibraryInfoImpl::getIntSize
unsigned getIntSize() const
Get size of a C-level int or unsigned int, in bits.
Definition: TargetLibraryInfo.h:194
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:112
llvm::LinearPolySize< ElementCount >::isKnownGT
static bool isKnownGT(const LinearPolySize &LHS, const LinearPolySize &RHS)
Definition: TypeSize.h:335
llvm::Type::isPointerTy
bool isPointerTy() const
True if this is an instance of PointerType.
Definition: Type.h:228
compareByVectorFnName
static bool compareByVectorFnName(const VecDesc &LHS, const VecDesc &RHS)
Definition: TargetLibraryInfo.cpp:1622
llvm::ImmutablePass
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition: Pass.h:269
llvm::ElementCount
Definition: TypeSize.h:386
llvm::GlobalValue::dropLLVMManglingEscape
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1',...
Definition: GlobalValue.h:482
llvm::Function
Definition: Function.h:61
llvm::lower_bound
auto lower_bound(R &&Range, T &&Value)
Provide wrappers to std::lower_bound which take ranges instead of having to pass begin/end explicitly...
Definition: STLExtras.h:1644
llvm::VecDesc::VectorFnName
StringRef VectorFnName
Definition: TargetLibraryInfo.h:30
llvm::Triple::Darwin
@ Darwin
Definition: Triple.h:169
llvm::Triple::x86
@ x86
Definition: Triple.h:83
llvm::StringRef::npos
static constexpr size_t npos
Definition: StringRef.h:60
llvm::StringRef::find
LLVM_NODISCARD size_t find(char C, size_t From=0) const
Search for the first character C in the string.
Definition: StringRef.h:315
llvm::TargetLibraryInfoImpl::MASSV
@ MASSV
Definition: TargetLibraryInfo.h:94
llvm::Triple::IOS
@ IOS
Definition: Triple.h:173
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:45
llvm::cl::Hidden
@ Hidden
Definition: CommandLine.h:143
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
llvm::Triple::x86_64
@ x86_64
Definition: Triple.h:84
llvm::sys::path::end
const_iterator end(StringRef path)
Get end iterator over path.
Definition: Path.cpp:233
llvm::CallBase::getFunctionType
FunctionType * getFunctionType() const
Definition: InstrTypes.h:1241
llvm::sys::path::begin
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
Definition: Path.cpp:224
llvm::TargetLibraryInfoImpl::operator=
TargetLibraryInfoImpl & operator=(const TargetLibraryInfoImpl &TLI)
Definition: TargetLibraryInfo.cpp:670
T
#define T
Definition: Mips16ISelLowering.cpp:341
llvm::TargetLibraryInfoImpl
Implementation of the target library information.
Definition: TargetLibraryInfo.h:48
llvm::FunctionType::getNumParams
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
Definition: DerivedTypes.h:138
initialize
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringLiteral > StandardNames)
Initialize the set of available library functions based on the specified target triple.
Definition: TargetLibraryInfo.cpp:116
llvm::NotLibFunc
@ NotLibFunc
Definition: TargetLibraryInfo.h:39
llvm::Type::isFloatingPointTy
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
Definition: Type.h:162
llvm::TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib
void addVectorizableFunctionsFromVecLib(enum VectorLibrary VecLib)
Calls addVectorizableFunctions with a known preset of functions for the given vector library.
Definition: TargetLibraryInfo.cpp:1638
llvm::Triple::WatchOS
@ WatchOS
Definition: Triple.h:194
llvm::initializeTargetLibraryInfoWrapperPassPass
void initializeTargetLibraryInfoWrapperPassPass(PassRegistry &)
llvm::TargetLibraryInfoImpl::isFunctionVectorizable
bool isFunctionVectorizable(StringRef F, const ElementCount &VF) const
Return true if the function F has a vector equivalent with vectorization factor VF.
Definition: TargetLibraryInfo.h:157
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::FunctionType::isVarArg
bool isVarArg() const
Definition: DerivedTypes.h:122
llvm::TargetLibraryInfoImpl::setAvailableWithName
void setAvailableWithName(LibFunc F, StringRef Name)
Forces a function to be marked as available and provide an alternate name that must be used.
Definition: TargetLibraryInfo.h:132
CommandLine.h
llvm::Type::isArrayTy
bool isArrayTy() const
True if this is an instance of ArrayType.
Definition: Type.h:225
llvm::StringLiteral
A wrapper around a string literal that serves as a proxy for constructing global tables of StringRefs...
Definition: StringRef.h:891
llvm::Triple::FreeBSD
@ FreeBSD
Definition: Triple.h:171
llvm::Triple::sparcv9
@ sparcv9
Definition: Triple.h:76
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition: PassRegistry.cpp:31
Constants.h
llvm::TargetLibraryInfoImpl::getVectorizedFunction
StringRef getVectorizedFunction(StringRef F, const ElementCount &VF) const
Return the name of the equivalent of F, vectorized with factor VF.
Definition: TargetLibraryInfo.cpp:1697
llvm::Triple::TvOS
@ TvOS
Definition: Triple.h:193
llvm::CallingConv::ARM_AAPCS_VFP
@ ARM_AAPCS_VFP
ARM_AAPCS_VFP - Same as ARM_AAPCS, but uses hard floating point ABI.
Definition: CallingConv.h:118
llvm::TargetLibraryInfoImpl::getWidestVF
void getWidestVF(StringRef ScalarF, ElementCount &FixedVF, ElementCount &Scalable) const
Returns the largest vectorization factor used in the list of vector functions.
Definition: TargetLibraryInfo.cpp:1752
llvm::LibFunc
LibFunc
Definition: TargetLibraryInfo.h:34
INITIALIZE_PASS
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:37
llvm::VecDesc::ScalarFnName
StringRef ScalarFnName
Definition: TargetLibraryInfo.h:29
Param
Value * Param
Definition: NVPTXLowerArgs.cpp:163
llvm::Triple::Emscripten
@ Emscripten
Definition: Triple.h:201
llvm::CallingConv::C
@ C
C - The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
llvm::TargetLibraryAnalysis::run
TargetLibraryInfo run(const Function &F, FunctionAnalysisManager &)
Definition: TargetLibraryInfo.cpp:1712
TargetLibraryInfo.h
llvm::Triple::xcore
@ xcore
Definition: Triple.h:85
llvm::FunctionType::params
ArrayRef< Type * > params() const
Definition: DerivedTypes.h:129
llvm::CallBase::getCallingConv
CallingConv::ID getCallingConv() const
Definition: InstrTypes.h:1449
llvm::LinearPolySize< ElementCount >::getFixed
static ElementCount getFixed(ScalarTy MinVal)
Definition: TypeSize.h:284
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
llvm::Type::isIntegerTy
bool isIntegerTy() const
True if this is an instance of IntegerType.
Definition: Type.h:201
llvm::Type::getArrayElementType
Type * getArrayElementType() const
Definition: Type.h:375
llvm::cl::opt
Definition: CommandLine.h:1422
llvm::Triple::MacOSX
@ MacOSX
Definition: Triple.h:177
llvm::cl::values
ValuesClass values(OptsTy... Options)
Helper to build a ValuesClass by forwarding a variable number of arguments as an initializer list to ...
Definition: CommandLine.h:699
llvm::CallingConv::ARM_APCS
@ ARM_APCS
ARM_APCS - ARM Procedure Calling Standard calling convention (obsolete, but still used on some target...
Definition: CallingConv.h:111
llvm::TargetLibraryInfoWrapperPass
Definition: TargetLibraryInfo.h:463
llvm::GlobalValue::getParent
Module * getParent()
Get the module that this global value is contained inside of...
Definition: GlobalValue.h:572
move
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
Definition: README.txt:546
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
llvm::AnalysisKey
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition: PassManager.h:72
llvm::Triple::Linux
@ Linux
Definition: Triple.h:175
I
#define I(x, y, z)
Definition: MD5.cpp:59
compareByScalarFnName
static bool compareByScalarFnName(const VecDesc &LHS, const VecDesc &RHS)
Definition: TargetLibraryInfo.cpp:1618
llvm::FunctionType::getParamType
Type * getParamType(unsigned i) const
Parameter type accessors.
Definition: DerivedTypes.h:134
llvm::cl::init
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:443
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::move
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1592
llvm::TargetLibraryInfoImpl::setShouldExtI32Return
void setShouldExtI32Return(bool Val)
Set to true iff i32 results from library functions should have signext or zeroext attributes if they ...
Definition: TargetLibraryInfo.h:179
llvm::Type::getArrayNumElements
uint64_t getArrayNumElements() const
Definition: DerivedTypes.h:383
llvm::TargetLibraryInfoImpl::addVectorizableFunctions
void addVectorizableFunctions(ArrayRef< VecDesc > Fns)
Add a set of scalar -> vector mappings, queryable via getVectorizedFunction and getScalarizedFunction...
Definition: TargetLibraryInfo.cpp:1630
memcpy
<%struct.s * > cast struct s *S to sbyte *< sbyte * > sbyte uint cast struct s *agg result to sbyte *< sbyte * > sbyte uint cast struct s *memtmp to sbyte *< sbyte * > sbyte uint ret void llc ends up issuing two memcpy or custom lower memcpy(of small size) to be ldmia/stmia. I think option 2 is better but the current register allocator cannot allocate a chunk of registers at a time. A feasible temporary solution is to use specific physical registers at the lowering time for small(<
llvm::Type::isVoidTy
bool isVoidTy() const
Return true if this is 'void'.
Definition: Type.h:138
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
isCallingConvCCompatible
static bool isCallingConvCCompatible(CallingConv::ID CC, StringRef TT, FunctionType *FuncTy)
Definition: TargetLibraryInfo.cpp:70
hasBcmp
static bool hasBcmp(const Triple &TT)
Definition: TargetLibraryInfo.cpp:60
llvm::TargetLibraryInfoImpl::Accelerate
@ Accelerate
Definition: TargetLibraryInfo.h:91
Triple.h
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::Triple::arm
@ arm
Definition: Triple.h:50
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
hasSinCosPiStret
static bool hasSinCosPiStret(const Triple &T)
Definition: TargetLibraryInfo.cpp:42
llvm::append_range
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
Definition: STLExtras.h:1731
llvm::TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass
TargetLibraryInfoWrapperPass()
Definition: TargetLibraryInfo.cpp:1727
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
clEnumValN
#define clEnumValN(ENUMVAL, FLAGNAME, DESC)
Definition: CommandLine.h:674
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
LLVM_FALLTHROUGH
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
Definition: Compiler.h:281
llvm::Value::getName
StringRef getName() const
Return a constant reference to the value's name.
Definition: Value.cpp:297
llvm::Type::getContext
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Definition: Type.h:127
llvm::TargetLibraryInfoImpl::disableAllFunctions
void disableAllFunctions()
Disables all builtins.
Definition: TargetLibraryInfo.cpp:1614
std
Definition: BitVector.h:838
llvm::Type::isFloatTy
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
Definition: Type.h:147
ClVectorLibrary
static cl::opt< TargetLibraryInfoImpl::VectorLibrary > ClVectorLibrary("vector-library", cl::Hidden, cl::desc("Vector functions library"), cl::init(TargetLibraryInfoImpl::NoLibrary), cl::values(clEnumValN(TargetLibraryInfoImpl::NoLibrary, "none", "No vector functions library"), clEnumValN(TargetLibraryInfoImpl::Accelerate, "Accelerate", "Accelerate framework"), clEnumValN(TargetLibraryInfoImpl::DarwinLibSystemM, "Darwin_libsystem_m", "Darwin libsystem_m"), clEnumValN(TargetLibraryInfoImpl::LIBMVEC_X86, "LIBMVEC-X86", "GLIBC Vector Math library"), clEnumValN(TargetLibraryInfoImpl::MASSV, "MASSV", "IBM MASS vector library"), clEnumValN(TargetLibraryInfoImpl::SVML, "SVML", "Intel SVML library")))
llvm::TargetLibraryInfoImpl::setUnavailable
void setUnavailable(LibFunc F)
Forces a function to be marked as unavailable.
Definition: TargetLibraryInfo.h:121
llvm::LinearPolySize< ElementCount >::getScalable
static ElementCount getScalable(ScalarTy MinVal)
Definition: TypeSize.h:287
llvm::sort
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1475
llvm::TargetLibraryInfo
Provides information about what library functions are available for the current target.
Definition: TargetLibraryInfo.h:219
llvm::is_sorted
bool is_sorted(R &&Range, Compare C)
Wrapper function around std::is_sorted to check if elements in a range R are sorted with respect to a...
Definition: STLExtras.h:1605
llvm::Type::isDoubleTy
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
Definition: Type.h:150
llvm::TargetLibraryInfoImpl::setShouldExtI32Param
void setShouldExtI32Param(bool Val)
Set to true iff i32 parameters to library functions should have signext or zeroext attributes if they...
Definition: TargetLibraryInfo.h:172
llvm::Function::getFunctionType
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Definition: Function.h:175
llvm::TargetLibraryInfoImpl::LIBMVEC_X86
@ LIBMVEC_X86
Definition: TargetLibraryInfo.h:93
llvm::Triple::systemz
@ systemz
Definition: Triple.h:78
llvm::TargetLibraryInfoImpl::getWCharSize
unsigned getWCharSize(const Module &M) const
Returns the size of the wchar_t type in bytes or 0 if the size is unknown.
Definition: TargetLibraryInfo.cpp:1720
llvm::TargetLibraryInfoImpl::getLibFunc
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
Definition: TargetLibraryInfo.cpp:702
llvm::Module::getTargetTriple
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
Definition: Module.h:257
llvm::TargetLibraryInfoImpl::NoLibrary
@ NoLibrary
Definition: TargetLibraryInfo.h:90
llvm::NumLibFuncs
@ NumLibFuncs
Definition: TargetLibraryInfo.h:38
llvm::CallBase
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
Definition: InstrTypes.h:1161
llvm::Module::getDataLayout
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Definition: Module.cpp:397
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
llvm::TargetLibraryInfoImpl::isCallingConvCCompatible
static bool isCallingConvCCompatible(CallBase *CI)
Returns true if call site / callee has cdecl-compatible calling conventions.
Definition: TargetLibraryInfo.cpp:101
compareWithScalarFnName
static bool compareWithScalarFnName(const VecDesc &LHS, StringRef S)
Definition: TargetLibraryInfo.cpp:1626
sanitizeFunctionName
static StringRef sanitizeFunctionName(StringRef funcName)
Definition: TargetLibraryInfo.cpp:691
llvm::cl::desc
Definition: CommandLine.h:414
llvm::TargetLibraryInfoImpl::VectorLibrary
VectorLibrary
List of known vector-functions libraries.
Definition: TargetLibraryInfo.h:89
llvm::TargetLibraryInfoImpl::TargetLibraryInfoImpl
TargetLibraryInfoImpl()
Definition: TargetLibraryInfo.cpp:634
InitializePasses.h
llvm::FunctionType::getReturnType
Type * getReturnType() const
Definition: DerivedTypes.h:123
llvm::Triple::tce
@ tce
Definition: Triple.h:79
llvm::TargetLibraryInfoImpl::setIntSize
void setIntSize(unsigned Bits)
Initialize the C-level size of an integer.
Definition: TargetLibraryInfo.h:199
llvm::CallingConv::ARM_AAPCS
@ ARM_AAPCS
ARM_AAPCS - ARM Architecture Procedure Calling Standard calling convention (aka EABI).
Definition: CallingConv.h:115
llvm::Triple::aarch64
@ aarch64
Definition: Triple.h:52
llvm::FunctionType
Class to represent function types.
Definition: DerivedTypes.h:102
llvm::Intrinsic::ID
unsigned ID
Definition: TargetTransformInfo.h:38
llvm::TargetLibraryInfoImpl::DarwinLibSystemM
@ DarwinLibSystemM
Definition: TargetLibraryInfo.h:92