Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Analysis/TargetLibraryInfo.cpp
Line
Count
Source (jump to first uncovered line)
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
13
#include "llvm/Analysis/TargetLibraryInfo.h"
14
#include "llvm/ADT/Triple.h"
15
#include "llvm/IR/Constants.h"
16
#include "llvm/Support/CommandLine.h"
17
using namespace llvm;
18
19
static cl::opt<TargetLibraryInfoImpl::VectorLibrary> ClVectorLibrary(
20
    "vector-library", cl::Hidden, cl::desc("Vector functions library"),
21
    cl::init(TargetLibraryInfoImpl::NoLibrary),
22
    cl::values(clEnumValN(TargetLibraryInfoImpl::NoLibrary, "none",
23
                          "No vector functions library"),
24
               clEnumValN(TargetLibraryInfoImpl::Accelerate, "Accelerate",
25
                          "Accelerate framework"),
26
               clEnumValN(TargetLibraryInfoImpl::MASSV, "MASSV",
27
                          "IBM MASS vector library"),
28
               clEnumValN(TargetLibraryInfoImpl::SVML, "SVML",
29
                          "Intel SVML library")));
30
31
StringRef const TargetLibraryInfoImpl::StandardNames[LibFunc::NumLibFuncs] = {
32
#define TLI_DEFINE_STRING
33
#include "llvm/Analysis/TargetLibraryInfo.def"
34
};
35
36
98.3k
static bool hasSinCosPiStret(const Triple &T) {
37
98.3k
  // Only Darwin variants have _stret versions of combined trig functions.
38
98.3k
  if (!T.isOSDarwin())
39
68.5k
    return false;
40
29.7k
41
29.7k
  // The ABI is rather complicated on x86, so don't do anything special there.
42
29.7k
  if (T.getArch() == Triple::x86)
43
1.68k
    return false;
44
28.1k
45
28.1k
  if (T.isMacOSX() && 
T.isMacOSXVersionLT(10, 9)9.34k
)
46
4.55k
    return false;
47
23.5k
48
23.5k
  if (T.isiOS() && 
T.isOSVersionLT(7, 0)18.7k
)
49
2.41k
    return false;
50
21.1k
51
21.1k
  return true;
52
21.1k
}
53
54
98.3k
static bool hasBcmp(const Triple &TT) {
55
98.3k
  // Posix removed support from bcmp() in 2001, but the glibc and several
56
98.3k
  // implementations of the libc still have it.
57
98.3k
  if (TT.isOSLinux())
58
10.8k
    return TT.isGNUEnvironment() || 
TT.isMusl()1.49k
;
59
87.5k
  // Both NetBSD and OpenBSD are planning to remove the function. Windows does
60
87.5k
  // not have it.
61
87.5k
  return TT.isOSFreeBSD() || 
TT.isOSSolaris()87.4k
||
TT.isOSDarwin()87.4k
;
62
87.5k
}
63
64
/// Initialize the set of available library functions based on the specified
65
/// target triple. This should be carefully written so that a missing target
66
/// triple gets a sane set of defaults.
67
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
68
99.9k
                       ArrayRef<StringRef> StandardNames) {
69
99.9k
  // Verify that the StandardNames array is in alphabetical order.
70
99.9k
  assert(std::is_sorted(StandardNames.begin(), StandardNames.end(),
71
99.9k
                        [](StringRef LHS, StringRef RHS) {
72
99.9k
                          return LHS < RHS;
73
99.9k
                        }) &&
74
99.9k
         "TargetLibraryInfoImpl function names must be sorted");
75
99.9k
76
99.9k
  // Set IO unlocked variants as unavailable
77
99.9k
  // Set them as available per system below
78
99.9k
  TLI.setUnavailable(LibFunc_getchar_unlocked);
79
99.9k
  TLI.setUnavailable(LibFunc_putc_unlocked);
80
99.9k
  TLI.setUnavailable(LibFunc_putchar_unlocked);
81
99.9k
  TLI.setUnavailable(LibFunc_fputc_unlocked);
82
99.9k
  TLI.setUnavailable(LibFunc_fgetc_unlocked);
83
99.9k
  TLI.setUnavailable(LibFunc_fread_unlocked);
84
99.9k
  TLI.setUnavailable(LibFunc_fwrite_unlocked);
85
99.9k
  TLI.setUnavailable(LibFunc_fputs_unlocked);
86
99.9k
  TLI.setUnavailable(LibFunc_fgets_unlocked);
87
99.9k
88
99.9k
  bool ShouldExtI32Param = false, ShouldExtI32Return = false,
89
99.9k
       ShouldSignExtI32Param = false;
90
99.9k
  // PowerPC64, Sparc64, SystemZ need signext/zeroext on i32 parameters and
91
99.9k
  // returns corresponding to C-level ints and unsigned ints.
92
99.9k
  if (T.isPPC64() || 
T.getArch() == Triple::sparcv996.7k
||
93
99.9k
      
T.getArch() == Triple::systemz96.7k
) {
94
4.28k
    ShouldExtI32Param = true;
95
4.28k
    ShouldExtI32Return = true;
96
4.28k
  }
97
99.9k
  // Mips, on the other hand, needs signext on i32 parameters corresponding
98
99.9k
  // to both signed and unsigned ints.
99
99.9k
  if (T.isMIPS()) {
100
1.05k
    ShouldSignExtI32Param = true;
101
1.05k
  }
102
99.9k
  TLI.setShouldExtI32Param(ShouldExtI32Param);
103
99.9k
  TLI.setShouldExtI32Return(ShouldExtI32Return);
104
99.9k
  TLI.setShouldSignExtI32Param(ShouldSignExtI32Param);
105
99.9k
106
99.9k
  if (T.getArch() == Triple::r600 ||
107
99.9k
      
T.getArch() == Triple::amdgcn99.8k
) {
108
1.54k
    TLI.setUnavailable(LibFunc_ldexp);
109
1.54k
    TLI.setUnavailable(LibFunc_ldexpf);
110
1.54k
    TLI.setUnavailable(LibFunc_ldexpl);
111
1.54k
    TLI.setUnavailable(LibFunc_exp10);
112
1.54k
    TLI.setUnavailable(LibFunc_exp10f);
113
1.54k
    TLI.setUnavailable(LibFunc_exp10l);
114
1.54k
    TLI.setUnavailable(LibFunc_log10);
115
1.54k
    TLI.setUnavailable(LibFunc_log10f);
116
1.54k
    TLI.setUnavailable(LibFunc_log10l);
117
1.54k
  }
118
99.9k
119
99.9k
  // There are no library implementations of mempcy and memset for AMD gpus and
120
99.9k
  // these can be difficult to lower in the backend.
121
99.9k
  if (T.getArch() == Triple::r600 ||
122
99.9k
      
T.getArch() == Triple::amdgcn99.8k
) {
123
1.54k
    TLI.setUnavailable(LibFunc_memcpy);
124
1.54k
    TLI.setUnavailable(LibFunc_memset);
125
1.54k
    TLI.setUnavailable(LibFunc_memset_pattern16);
126
1.54k
    return;
127
1.54k
  }
128
98.3k
129
98.3k
  // memset_pattern16 is only available on iOS 3.0 and Mac OS X 10.5 and later.
130
98.3k
  // All versions of watchOS support it.
131
98.3k
  if (T.isMacOSX()) {
132
10.3k
    // available IO unlocked variants on Mac OS X
133
10.3k
    TLI.setAvailable(LibFunc_getc_unlocked);
134
10.3k
    TLI.setAvailable(LibFunc_getchar_unlocked);
135
10.3k
    TLI.setAvailable(LibFunc_putc_unlocked);
136
10.3k
    TLI.setAvailable(LibFunc_putchar_unlocked);
137
10.3k
138
10.3k
    if (T.isMacOSXVersionLT(10, 5))
139
2.12k
      TLI.setUnavailable(LibFunc_memset_pattern16);
140
88.0k
  } else if (T.isiOS()) {
141
19.4k
    if (T.isOSVersionLT(3, 0))
142
459
      TLI.setUnavailable(LibFunc_memset_pattern16);
143
68.6k
  } else if (!T.isWatchOS()) {
144
68.5k
    TLI.setUnavailable(LibFunc_memset_pattern16);
145
68.5k
  }
146
98.3k
147
98.3k
  if (!hasSinCosPiStret(T)) {
148
77.2k
    TLI.setUnavailable(LibFunc_sinpi);
149
77.2k
    TLI.setUnavailable(LibFunc_sinpif);
150
77.2k
    TLI.setUnavailable(LibFunc_cospi);
151
77.2k
    TLI.setUnavailable(LibFunc_cospif);
152
77.2k
    TLI.setUnavailable(LibFunc_sincospi_stret);
153
77.2k
    TLI.setUnavailable(LibFunc_sincospif_stret);
154
77.2k
  }
155
98.3k
156
98.3k
  if (!hasBcmp(T))
157
59.1k
    TLI.setUnavailable(LibFunc_bcmp);
158
98.3k
159
98.3k
  if (T.isMacOSX() && 
T.getArch() == Triple::x8610.3k
&&
160
98.3k
      
!T.isMacOSXVersionLT(10, 7)996
) {
161
340
    // x86-32 OSX has a scheme where fwrite and fputs (and some other functions
162
340
    // we don't care about) have two versions; on recent OSX, the one we want
163
340
    // has a $UNIX2003 suffix. The two implementations are identical except
164
340
    // for the return value in some edge cases.  However, we don't want to
165
340
    // generate code that depends on the old symbols.
166
340
    TLI.setAvailableWithName(LibFunc_fwrite, "fwrite$UNIX2003");
167
340
    TLI.setAvailableWithName(LibFunc_fputs, "fputs$UNIX2003");
168
340
  }
169
98.3k
170
98.3k
  // iprintf and friends are only available on XCore, TCE, and Emscripten.
171
98.3k
  if (T.getArch() != Triple::xcore && 
T.getArch() != Triple::tce98.3k
&&
172
98.3k
      
T.getOS() != Triple::Emscripten98.3k
) {
173
98.3k
    TLI.setUnavailable(LibFunc_iprintf);
174
98.3k
    TLI.setUnavailable(LibFunc_siprintf);
175
98.3k
    TLI.setUnavailable(LibFunc_fiprintf);
176
98.3k
  }
177
98.3k
178
98.3k
  // __small_printf and friends are only available on Emscripten.
179
98.3k
  if (T.getOS() != Triple::Emscripten) {
180
98.3k
    TLI.setUnavailable(LibFunc_small_printf);
181
98.3k
    TLI.setUnavailable(LibFunc_small_sprintf);
182
98.3k
    TLI.setUnavailable(LibFunc_small_fprintf);
183
98.3k
  }
184
98.3k
185
98.3k
  if (T.isOSWindows() && 
!T.isOSCygMing()1.87k
) {
186
1.62k
    // XXX: The earliest documentation available at the moment is for VS2015/VC19:
187
1.62k
    // https://docs.microsoft.com/en-us/cpp/c-runtime-library/floating-point-support?view=vs-2015
188
1.62k
    // XXX: In order to use an MSVCRT older than VC19,
189
1.62k
    // the specific library version must be explicit in the target triple,
190
1.62k
    // e.g., x86_64-pc-windows-msvc18.
191
1.62k
    bool hasPartialC99 = true;
192
1.62k
    if (T.isKnownWindowsMSVCEnvironment()) {
193
1.52k
      unsigned Major, Minor, Micro;
194
1.52k
      T.getEnvironmentVersion(Major, Minor, Micro);
195
1.52k
      hasPartialC99 = (Major == 0 || 
Major >= 19337
);
196
1.52k
    }
197
1.62k
198
1.62k
    // Latest targets support C89 math functions, in part.
199
1.62k
    bool isARM = (T.getArch() == Triple::aarch64 ||
200
1.62k
                  
T.getArch() == Triple::arm1.52k
);
201
1.62k
    bool hasPartialFloat = (isARM ||
202
1.62k
                            
T.getArch() == Triple::x86_641.52k
);
203
1.62k
204
1.62k
    // Win32 does not support float C89 math functions, in general.
205
1.62k
    if (!hasPartialFloat) {
206
731
      TLI.setUnavailable(LibFunc_acosf);
207
731
      TLI.setUnavailable(LibFunc_asinf);
208
731
      TLI.setUnavailable(LibFunc_atan2f);
209
731
      TLI.setUnavailable(LibFunc_atanf);
210
731
      TLI.setUnavailable(LibFunc_ceilf);
211
731
      TLI.setUnavailable(LibFunc_cosf);
212
731
      TLI.setUnavailable(LibFunc_coshf);
213
731
      TLI.setUnavailable(LibFunc_expf);
214
731
      TLI.setUnavailable(LibFunc_floorf);
215
731
      TLI.setUnavailable(LibFunc_fmodf);
216
731
      TLI.setUnavailable(LibFunc_log10f);
217
731
      TLI.setUnavailable(LibFunc_logf);
218
731
      TLI.setUnavailable(LibFunc_modff);
219
731
      TLI.setUnavailable(LibFunc_powf);
220
731
      TLI.setUnavailable(LibFunc_sinf);
221
731
      TLI.setUnavailable(LibFunc_sinhf);
222
731
      TLI.setUnavailable(LibFunc_sqrtf);
223
731
      TLI.setUnavailable(LibFunc_tanf);
224
731
      TLI.setUnavailable(LibFunc_tanhf);
225
731
    }
226
1.62k
    if (!isARM)
227
1.52k
      TLI.setUnavailable(LibFunc_fabsf);
228
1.62k
    TLI.setUnavailable(LibFunc_frexpf);
229
1.62k
    TLI.setUnavailable(LibFunc_ldexpf);
230
1.62k
231
1.62k
    // Win32 does not support long double C89 math functions.
232
1.62k
    TLI.setUnavailable(LibFunc_acosl);
233
1.62k
    TLI.setUnavailable(LibFunc_asinl);
234
1.62k
    TLI.setUnavailable(LibFunc_atan2l);
235
1.62k
    TLI.setUnavailable(LibFunc_atanl);
236
1.62k
    TLI.setUnavailable(LibFunc_ceill);
237
1.62k
    TLI.setUnavailable(LibFunc_cosl);
238
1.62k
    TLI.setUnavailable(LibFunc_coshl);
239
1.62k
    TLI.setUnavailable(LibFunc_expl);
240
1.62k
    TLI.setUnavailable(LibFunc_fabsl);
241
1.62k
    TLI.setUnavailable(LibFunc_floorl);
242
1.62k
    TLI.setUnavailable(LibFunc_fmodl);
243
1.62k
    TLI.setUnavailable(LibFunc_frexpl);
244
1.62k
    TLI.setUnavailable(LibFunc_ldexpl);
245
1.62k
    TLI.setUnavailable(LibFunc_log10l);
246
1.62k
    TLI.setUnavailable(LibFunc_logl);
247
1.62k
    TLI.setUnavailable(LibFunc_modfl);
248
1.62k
    TLI.setUnavailable(LibFunc_powl);
249
1.62k
    TLI.setUnavailable(LibFunc_sinl);
250
1.62k
    TLI.setUnavailable(LibFunc_sinhl);
251
1.62k
    TLI.setUnavailable(LibFunc_sqrtl);
252
1.62k
    TLI.setUnavailable(LibFunc_tanl);
253
1.62k
    TLI.setUnavailable(LibFunc_tanhl);
254
1.62k
255
1.62k
    // Win32 does not fully support C99 math functions.
256
1.62k
    if (!hasPartialC99) {
257
65
      TLI.setUnavailable(LibFunc_acosh);
258
65
      TLI.setUnavailable(LibFunc_acoshf);
259
65
      TLI.setUnavailable(LibFunc_asinh);
260
65
      TLI.setUnavailable(LibFunc_asinhf);
261
65
      TLI.setUnavailable(LibFunc_atanh);
262
65
      TLI.setUnavailable(LibFunc_atanhf);
263
65
      TLI.setAvailableWithName(LibFunc_cabs, "_cabs");
264
65
      TLI.setUnavailable(LibFunc_cabsf);
265
65
      TLI.setUnavailable(LibFunc_cbrt);
266
65
      TLI.setUnavailable(LibFunc_cbrtf);
267
65
      TLI.setAvailableWithName(LibFunc_copysign, "_copysign");
268
65
      TLI.setAvailableWithName(LibFunc_copysignf, "_copysignf");
269
65
      TLI.setUnavailable(LibFunc_exp2);
270
65
      TLI.setUnavailable(LibFunc_exp2f);
271
65
      TLI.setUnavailable(LibFunc_expm1);
272
65
      TLI.setUnavailable(LibFunc_expm1f);
273
65
      TLI.setUnavailable(LibFunc_fmax);
274
65
      TLI.setUnavailable(LibFunc_fmaxf);
275
65
      TLI.setUnavailable(LibFunc_fmin);
276
65
      TLI.setUnavailable(LibFunc_fminf);
277
65
      TLI.setUnavailable(LibFunc_log1p);
278
65
      TLI.setUnavailable(LibFunc_log1pf);
279
65
      TLI.setUnavailable(LibFunc_log2);
280
65
      TLI.setUnavailable(LibFunc_log2f);
281
65
      TLI.setAvailableWithName(LibFunc_logb, "_logb");
282
65
      if (hasPartialFloat)
283
29
        TLI.setAvailableWithName(LibFunc_logbf, "_logbf");
284
36
      else
285
36
        TLI.setUnavailable(LibFunc_logbf);
286
65
      TLI.setUnavailable(LibFunc_rint);
287
65
      TLI.setUnavailable(LibFunc_rintf);
288
65
      TLI.setUnavailable(LibFunc_round);
289
65
      TLI.setUnavailable(LibFunc_roundf);
290
65
      TLI.setUnavailable(LibFunc_trunc);
291
65
      TLI.setUnavailable(LibFunc_truncf);
292
65
    }
293
1.62k
294
1.62k
    // Win32 does not support long double C99 math functions.
295
1.62k
    TLI.setUnavailable(LibFunc_acoshl);
296
1.62k
    TLI.setUnavailable(LibFunc_asinhl);
297
1.62k
    TLI.setUnavailable(LibFunc_atanhl);
298
1.62k
    TLI.setUnavailable(LibFunc_cabsl);
299
1.62k
    TLI.setUnavailable(LibFunc_cbrtl);
300
1.62k
    TLI.setUnavailable(LibFunc_copysignl);
301
1.62k
    TLI.setUnavailable(LibFunc_exp2l);
302
1.62k
    TLI.setUnavailable(LibFunc_expm1l);
303
1.62k
    TLI.setUnavailable(LibFunc_fmaxl);
304
1.62k
    TLI.setUnavailable(LibFunc_fminl);
305
1.62k
    TLI.setUnavailable(LibFunc_log1pl);
306
1.62k
    TLI.setUnavailable(LibFunc_log2l);
307
1.62k
    TLI.setUnavailable(LibFunc_logbl);
308
1.62k
    TLI.setUnavailable(LibFunc_nearbyintl);
309
1.62k
    TLI.setUnavailable(LibFunc_rintl);
310
1.62k
    TLI.setUnavailable(LibFunc_roundl);
311
1.62k
    TLI.setUnavailable(LibFunc_truncl);
312
1.62k
313
1.62k
    // Win32 does not support these functions, but
314
1.62k
    // they are generally available on POSIX-compliant systems.
315
1.62k
    TLI.setUnavailable(LibFunc_access);
316
1.62k
    TLI.setUnavailable(LibFunc_bcmp);
317
1.62k
    TLI.setUnavailable(LibFunc_bcopy);
318
1.62k
    TLI.setUnavailable(LibFunc_bzero);
319
1.62k
    TLI.setUnavailable(LibFunc_chmod);
320
1.62k
    TLI.setUnavailable(LibFunc_chown);
321
1.62k
    TLI.setUnavailable(LibFunc_closedir);
322
1.62k
    TLI.setUnavailable(LibFunc_ctermid);
323
1.62k
    TLI.setUnavailable(LibFunc_fdopen);
324
1.62k
    TLI.setUnavailable(LibFunc_ffs);
325
1.62k
    TLI.setUnavailable(LibFunc_fileno);
326
1.62k
    TLI.setUnavailable(LibFunc_flockfile);
327
1.62k
    TLI.setUnavailable(LibFunc_fseeko);
328
1.62k
    TLI.setUnavailable(LibFunc_fstat);
329
1.62k
    TLI.setUnavailable(LibFunc_fstatvfs);
330
1.62k
    TLI.setUnavailable(LibFunc_ftello);
331
1.62k
    TLI.setUnavailable(LibFunc_ftrylockfile);
332
1.62k
    TLI.setUnavailable(LibFunc_funlockfile);
333
1.62k
    TLI.setUnavailable(LibFunc_getitimer);
334
1.62k
    TLI.setUnavailable(LibFunc_getlogin_r);
335
1.62k
    TLI.setUnavailable(LibFunc_getpwnam);
336
1.62k
    TLI.setUnavailable(LibFunc_gettimeofday);
337
1.62k
    TLI.setUnavailable(LibFunc_htonl);
338
1.62k
    TLI.setUnavailable(LibFunc_htons);
339
1.62k
    TLI.setUnavailable(LibFunc_lchown);
340
1.62k
    TLI.setUnavailable(LibFunc_lstat);
341
1.62k
    TLI.setUnavailable(LibFunc_memccpy);
342
1.62k
    TLI.setUnavailable(LibFunc_mkdir);
343
1.62k
    TLI.setUnavailable(LibFunc_ntohl);
344
1.62k
    TLI.setUnavailable(LibFunc_ntohs);
345
1.62k
    TLI.setUnavailable(LibFunc_open);
346
1.62k
    TLI.setUnavailable(LibFunc_opendir);
347
1.62k
    TLI.setUnavailable(LibFunc_pclose);
348
1.62k
    TLI.setUnavailable(LibFunc_popen);
349
1.62k
    TLI.setUnavailable(LibFunc_pread);
350
1.62k
    TLI.setUnavailable(LibFunc_pwrite);
351
1.62k
    TLI.setUnavailable(LibFunc_read);
352
1.62k
    TLI.setUnavailable(LibFunc_readlink);
353
1.62k
    TLI.setUnavailable(LibFunc_realpath);
354
1.62k
    TLI.setUnavailable(LibFunc_rmdir);
355
1.62k
    TLI.setUnavailable(LibFunc_setitimer);
356
1.62k
    TLI.setUnavailable(LibFunc_stat);
357
1.62k
    TLI.setUnavailable(LibFunc_statvfs);
358
1.62k
    TLI.setUnavailable(LibFunc_stpcpy);
359
1.62k
    TLI.setUnavailable(LibFunc_stpncpy);
360
1.62k
    TLI.setUnavailable(LibFunc_strcasecmp);
361
1.62k
    TLI.setUnavailable(LibFunc_strncasecmp);
362
1.62k
    TLI.setUnavailable(LibFunc_times);
363
1.62k
    TLI.setUnavailable(LibFunc_uname);
364
1.62k
    TLI.setUnavailable(LibFunc_unlink);
365
1.62k
    TLI.setUnavailable(LibFunc_unsetenv);
366
1.62k
    TLI.setUnavailable(LibFunc_utime);
367
1.62k
    TLI.setUnavailable(LibFunc_utimes);
368
1.62k
    TLI.setUnavailable(LibFunc_write);
369
1.62k
  }
370
98.3k
371
98.3k
  switch (T.getOS()) {
372
98.3k
  case Triple::MacOSX:
373
5.36k
    // exp10 and exp10f are not available on OS X until 10.9 and iOS until 7.0
374
5.36k
    // and their names are __exp10 and __exp10f. exp10l is not available on
375
5.36k
    // OS X or iOS.
376
5.36k
    TLI.setUnavailable(LibFunc_exp10l);
377
5.36k
    if (T.isMacOSXVersionLT(10, 9)) {
378
1.87k
      TLI.setUnavailable(LibFunc_exp10);
379
1.87k
      TLI.setUnavailable(LibFunc_exp10f);
380
3.49k
    } else {
381
3.49k
      TLI.setAvailableWithName(LibFunc_exp10, "__exp10");
382
3.49k
      TLI.setAvailableWithName(LibFunc_exp10f, "__exp10f");
383
3.49k
    }
384
5.36k
    break;
385
98.3k
  case Triple::IOS:
386
19.4k
  case Triple::TvOS:
387
19.4k
  case Triple::WatchOS:
388
19.4k
    TLI.setUnavailable(LibFunc_exp10l);
389
19.4k
    if (!T.isWatchOS() && 
(19.4k
T.isOSVersionLT(7, 0)19.4k
||
390
19.4k
                           
(16.8k
T.isOSVersionLT(9, 0)16.8k
&&
391
16.8k
                            
(3.43k
T.getArch() == Triple::x863.43k
||
392
3.76k
                             
T.getArch() == Triple::x86_642.93k
)))) {
393
3.76k
      TLI.setUnavailable(LibFunc_exp10);
394
3.76k
      TLI.setUnavailable(LibFunc_exp10f);
395
15.6k
    } else {
396
15.6k
      TLI.setAvailableWithName(LibFunc_exp10, "__exp10");
397
15.6k
      TLI.setAvailableWithName(LibFunc_exp10f, "__exp10f");
398
15.6k
    }
399
19.4k
    break;
400
19.4k
  case Triple::Linux:
401
10.8k
    // exp10, exp10f, exp10l is available on Linux (GLIBC) but are extremely
402
10.8k
    // buggy prior to glibc version 2.18. Until this version is widely deployed
403
10.8k
    // or we have a reasonable detection strategy, we cannot use exp10 reliably
404
10.8k
    // on Linux.
405
10.8k
    //
406
10.8k
    // Fall through to disable all of them.
407
10.8k
    LLVM_FALLTHROUGH;
408
73.5k
  default:
409
73.5k
    TLI.setUnavailable(LibFunc_exp10);
410
73.5k
    TLI.setUnavailable(LibFunc_exp10f);
411
73.5k
    TLI.setUnavailable(LibFunc_exp10l);
412
98.3k
  }
413
98.3k
414
98.3k
  // ffsl is available on at least Darwin, Mac OS X, iOS, FreeBSD, and
415
98.3k
  // Linux (GLIBC):
416
98.3k
  // http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/ffsl.3.html
417
98.3k
  // http://svn.freebsd.org/base/head/lib/libc/string/ffsl.c
418
98.3k
  // http://www.gnu.org/software/gnulib/manual/html_node/ffsl.html
419
98.3k
  switch (T.getOS()) {
420
98.3k
  case Triple::Darwin:
421
40.7k
  case Triple::MacOSX:
422
40.7k
  case Triple::IOS:
423
40.7k
  case Triple::TvOS:
424
40.7k
  case Triple::WatchOS:
425
40.7k
  case Triple::FreeBSD:
426
40.7k
  case Triple::Linux:
427
40.7k
    break;
428
57.6k
  default:
429
57.6k
    TLI.setUnavailable(LibFunc_ffsl);
430
98.3k
  }
431
98.3k
432
98.3k
  // ffsll is available on at least FreeBSD and Linux (GLIBC):
433
98.3k
  // http://svn.freebsd.org/base/head/lib/libc/string/ffsll.c
434
98.3k
  // http://www.gnu.org/software/gnulib/manual/html_node/ffsll.html
435
98.3k
  switch (T.getOS()) {
436
98.3k
  case Triple::Darwin:
437
40.7k
  case Triple::MacOSX:
438
40.7k
  case Triple::IOS:
439
40.7k
  case Triple::TvOS:
440
40.7k
  case Triple::WatchOS:
441
40.7k
  case Triple::FreeBSD:
442
40.7k
  case Triple::Linux:
443
40.7k
    break;
444
57.6k
  default:
445
57.6k
    TLI.setUnavailable(LibFunc_ffsll);
446
98.3k
  }
447
98.3k
448
98.3k
  // The following functions are available on at least FreeBSD:
449
98.3k
  // http://svn.freebsd.org/base/head/lib/libc/string/fls.c
450
98.3k
  // http://svn.freebsd.org/base/head/lib/libc/string/flsl.c
451
98.3k
  // http://svn.freebsd.org/base/head/lib/libc/string/flsll.c
452
98.3k
  if (!T.isOSFreeBSD()) {
453
98.2k
    TLI.setUnavailable(LibFunc_fls);
454
98.2k
    TLI.setUnavailable(LibFunc_flsl);
455
98.2k
    TLI.setUnavailable(LibFunc_flsll);
456
98.2k
  }
457
98.3k
458
98.3k
  // The following functions are only available on GNU/Linux (using glibc).
459
98.3k
  // Linux variants without glibc (eg: bionic, musl) may have some subset.
460
98.3k
  if (!T.isOSLinux() || 
!T.isGNUEnvironment()10.8k
) {
461
89.0k
    TLI.setUnavailable(LibFunc_dunder_strdup);
462
89.0k
    TLI.setUnavailable(LibFunc_dunder_strtok_r);
463
89.0k
    TLI.setUnavailable(LibFunc_dunder_isoc99_scanf);
464
89.0k
    TLI.setUnavailable(LibFunc_dunder_isoc99_sscanf);
465
89.0k
    TLI.setUnavailable(LibFunc_under_IO_getc);
466
89.0k
    TLI.setUnavailable(LibFunc_under_IO_putc);
467
89.0k
    // But, Android and musl have memalign.
468
89.0k
    if (!T.isAndroid() && 
!T.isMusl()88.8k
)
469
88.7k
      TLI.setUnavailable(LibFunc_memalign);
470
89.0k
    TLI.setUnavailable(LibFunc_fopen64);
471
89.0k
    TLI.setUnavailable(LibFunc_fseeko64);
472
89.0k
    TLI.setUnavailable(LibFunc_fstat64);
473
89.0k
    TLI.setUnavailable(LibFunc_fstatvfs64);
474
89.0k
    TLI.setUnavailable(LibFunc_ftello64);
475
89.0k
    TLI.setUnavailable(LibFunc_lstat64);
476
89.0k
    TLI.setUnavailable(LibFunc_open64);
477
89.0k
    TLI.setUnavailable(LibFunc_stat64);
478
89.0k
    TLI.setUnavailable(LibFunc_statvfs64);
479
89.0k
    TLI.setUnavailable(LibFunc_tmpfile64);
480
89.0k
481
89.0k
    // Relaxed math functions are included in math-finite.h on Linux (GLIBC).
482
89.0k
    TLI.setUnavailable(LibFunc_acos_finite);
483
89.0k
    TLI.setUnavailable(LibFunc_acosf_finite);
484
89.0k
    TLI.setUnavailable(LibFunc_acosl_finite);
485
89.0k
    TLI.setUnavailable(LibFunc_acosh_finite);
486
89.0k
    TLI.setUnavailable(LibFunc_acoshf_finite);
487
89.0k
    TLI.setUnavailable(LibFunc_acoshl_finite);
488
89.0k
    TLI.setUnavailable(LibFunc_asin_finite);
489
89.0k
    TLI.setUnavailable(LibFunc_asinf_finite);
490
89.0k
    TLI.setUnavailable(LibFunc_asinl_finite);
491
89.0k
    TLI.setUnavailable(LibFunc_atan2_finite);
492
89.0k
    TLI.setUnavailable(LibFunc_atan2f_finite);
493
89.0k
    TLI.setUnavailable(LibFunc_atan2l_finite);
494
89.0k
    TLI.setUnavailable(LibFunc_atanh_finite);
495
89.0k
    TLI.setUnavailable(LibFunc_atanhf_finite);
496
89.0k
    TLI.setUnavailable(LibFunc_atanhl_finite);
497
89.0k
    TLI.setUnavailable(LibFunc_cosh_finite);
498
89.0k
    TLI.setUnavailable(LibFunc_coshf_finite);
499
89.0k
    TLI.setUnavailable(LibFunc_coshl_finite);
500
89.0k
    TLI.setUnavailable(LibFunc_exp10_finite);
501
89.0k
    TLI.setUnavailable(LibFunc_exp10f_finite);
502
89.0k
    TLI.setUnavailable(LibFunc_exp10l_finite);
503
89.0k
    TLI.setUnavailable(LibFunc_exp2_finite);
504
89.0k
    TLI.setUnavailable(LibFunc_exp2f_finite);
505
89.0k
    TLI.setUnavailable(LibFunc_exp2l_finite);
506
89.0k
    TLI.setUnavailable(LibFunc_exp_finite);
507
89.0k
    TLI.setUnavailable(LibFunc_expf_finite);
508
89.0k
    TLI.setUnavailable(LibFunc_expl_finite);
509
89.0k
    TLI.setUnavailable(LibFunc_log10_finite);
510
89.0k
    TLI.setUnavailable(LibFunc_log10f_finite);
511
89.0k
    TLI.setUnavailable(LibFunc_log10l_finite);
512
89.0k
    TLI.setUnavailable(LibFunc_log2_finite);
513
89.0k
    TLI.setUnavailable(LibFunc_log2f_finite);
514
89.0k
    TLI.setUnavailable(LibFunc_log2l_finite);
515
89.0k
    TLI.setUnavailable(LibFunc_log_finite);
516
89.0k
    TLI.setUnavailable(LibFunc_logf_finite);
517
89.0k
    TLI.setUnavailable(LibFunc_logl_finite);
518
89.0k
    TLI.setUnavailable(LibFunc_pow_finite);
519
89.0k
    TLI.setUnavailable(LibFunc_powf_finite);
520
89.0k
    TLI.setUnavailable(LibFunc_powl_finite);
521
89.0k
    TLI.setUnavailable(LibFunc_sinh_finite);
522
89.0k
    TLI.setUnavailable(LibFunc_sinhf_finite);
523
89.0k
    TLI.setUnavailable(LibFunc_sinhl_finite);
524
89.0k
  }
525
98.3k
526
98.3k
  if ((T.isOSLinux() && 
T.isGNUEnvironment()10.8k
) ||
527
98.3k
      
(89.0k
T.isAndroid()89.0k
&&
!T.isAndroidVersionLT(28)204
)) {
528
9.32k
    // available IO unlocked variants on GNU/Linux and Android P or later
529
9.32k
    TLI.setAvailable(LibFunc_getc_unlocked);
530
9.32k
    TLI.setAvailable(LibFunc_getchar_unlocked);
531
9.32k
    TLI.setAvailable(LibFunc_putc_unlocked);
532
9.32k
    TLI.setAvailable(LibFunc_putchar_unlocked);
533
9.32k
    TLI.setAvailable(LibFunc_fputc_unlocked);
534
9.32k
    TLI.setAvailable(LibFunc_fgetc_unlocked);
535
9.32k
    TLI.setAvailable(LibFunc_fread_unlocked);
536
9.32k
    TLI.setAvailable(LibFunc_fwrite_unlocked);
537
9.32k
    TLI.setAvailable(LibFunc_fputs_unlocked);
538
9.32k
    TLI.setAvailable(LibFunc_fgets_unlocked);
539
9.32k
  }
540
98.3k
541
98.3k
  // As currently implemented in clang, NVPTX code has no standard library to
542
98.3k
  // speak of.  Headers provide a standard-ish library implementation, but many
543
98.3k
  // of the signatures are wrong -- for example, many libm functions are not
544
98.3k
  // extern "C".
545
98.3k
  //
546
98.3k
  // libdevice, an IR library provided by nvidia, is linked in by the front-end,
547
98.3k
  // but only used functions are provided to llvm.  Moreover, most of the
548
98.3k
  // functions in libdevice don't map precisely to standard library functions.
549
98.3k
  //
550
98.3k
  // FIXME: Having no standard library prevents e.g. many fastmath
551
98.3k
  // optimizations, so this situation should be fixed.
552
98.3k
  if (T.isNVPTX()) {
553
242
    TLI.disableAllFunctions();
554
242
    TLI.setAvailable(LibFunc_nvvm_reflect);
555
98.1k
  } else {
556
98.1k
    TLI.setUnavailable(LibFunc_nvvm_reflect);
557
98.1k
  }
558
98.3k
559
98.3k
  TLI.addVectorizableFunctionsFromVecLib(ClVectorLibrary);
560
98.3k
}
561
562
29.5k
TargetLibraryInfoImpl::TargetLibraryInfoImpl() {
563
29.5k
  // Default to everything being available.
564
29.5k
  memset(AvailableArray, -1, sizeof(AvailableArray));
565
29.5k
566
29.5k
  initialize(*this, Triple(), StandardNames);
567
29.5k
}
568
569
70.3k
TargetLibraryInfoImpl::TargetLibraryInfoImpl(const Triple &T) {
570
70.3k
  // Default to everything being available.
571
70.3k
  memset(AvailableArray, -1, sizeof(AvailableArray));
572
70.3k
573
70.3k
  initialize(*this, T, StandardNames);
574
70.3k
}
575
576
TargetLibraryInfoImpl::TargetLibraryInfoImpl(const TargetLibraryInfoImpl &TLI)
577
    : CustomNames(TLI.CustomNames), ShouldExtI32Param(TLI.ShouldExtI32Param),
578
      ShouldExtI32Return(TLI.ShouldExtI32Return),
579
90.6k
      ShouldSignExtI32Param(TLI.ShouldSignExtI32Param) {
580
90.6k
  memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
581
90.6k
  VectorDescs = TLI.VectorDescs;
582
90.6k
  ScalarDescs = TLI.ScalarDescs;
583
90.6k
}
584
585
TargetLibraryInfoImpl::TargetLibraryInfoImpl(TargetLibraryInfoImpl &&TLI)
586
    : CustomNames(std::move(TLI.CustomNames)),
587
      ShouldExtI32Param(TLI.ShouldExtI32Param),
588
      ShouldExtI32Return(TLI.ShouldExtI32Return),
589
496
      ShouldSignExtI32Param(TLI.ShouldSignExtI32Param) {
590
496
  std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),
591
496
            AvailableArray);
592
496
  VectorDescs = TLI.VectorDescs;
593
496
  ScalarDescs = TLI.ScalarDescs;
594
496
}
595
596
0
TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(const TargetLibraryInfoImpl &TLI) {
597
0
  CustomNames = TLI.CustomNames;
598
0
  ShouldExtI32Param = TLI.ShouldExtI32Param;
599
0
  ShouldExtI32Return = TLI.ShouldExtI32Return;
600
0
  ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;
601
0
  memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
602
0
  return *this;
603
0
}
604
605
0
TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(TargetLibraryInfoImpl &&TLI) {
606
0
  CustomNames = std::move(TLI.CustomNames);
607
0
  ShouldExtI32Param = TLI.ShouldExtI32Param;
608
0
  ShouldExtI32Return = TLI.ShouldExtI32Return;
609
0
  ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;
610
0
  std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),
611
0
            AvailableArray);
612
0
  return *this;
613
0
}
614
615
46.6M
static StringRef sanitizeFunctionName(StringRef funcName) {
616
46.6M
  // Filter out empty names and names containing null bytes, those can't be in
617
46.6M
  // our table.
618
46.6M
  if (funcName.empty() || 
funcName.find('\0') != StringRef::npos46.6M
)
619
93
    return StringRef();
620
46.6M
621
46.6M
  // Check for \01 prefix that is used to mangle __asm declarations and
622
46.6M
  // strip it if present.
623
46.6M
  return GlobalValue::dropLLVMManglingEscape(funcName);
624
46.6M
}
625
626
bool TargetLibraryInfoImpl::getLibFunc(StringRef funcName,
627
46.6M
                                       LibFunc &F) const {
628
46.6M
  StringRef const *Start = &StandardNames[0];
629
46.6M
  StringRef const *End = &StandardNames[NumLibFuncs];
630
46.6M
631
46.6M
  funcName = sanitizeFunctionName(funcName);
632
46.6M
  if (funcName.empty())
633
93
    return false;
634
46.6M
635
46.6M
  StringRef const *I = std::lower_bound(
636
409M
      Start, End, funcName, [](StringRef LHS, StringRef RHS) {
637
409M
        return LHS < RHS;
638
409M
      });
639
46.6M
  if (I != End && 
*I == funcName46.5M
) {
640
16.2M
    F = (LibFunc)(I - Start);
641
16.2M
    return true;
642
16.2M
  }
643
30.3M
  return false;
644
30.3M
}
645
646
bool TargetLibraryInfoImpl::isValidProtoForLibFunc(const FunctionType &FTy,
647
                                                   LibFunc F,
648
6.27M
                                                   const DataLayout *DL) const {
649
6.27M
  LLVMContext &Ctx = FTy.getContext();
650
6.27M
  Type *PCharTy = Type::getInt8PtrTy(Ctx);
651
6.27M
  Type *SizeTTy = DL ? DL->getIntPtrType(Ctx, /*AS=*/0) : 
nullptr0
;
652
6.27M
  auto IsSizeTTy = [SizeTTy](Type *Ty) {
653
633k
    return SizeTTy ? Ty == SizeTTy : 
Ty->isIntegerTy()0
;
654
633k
  };
655
6.27M
  unsigned NumParams = FTy.getNumParams();
656
6.27M
657
6.27M
  switch (F) {
658
6.27M
  case LibFunc_execl:
659
104
  case LibFunc_execlp:
660
104
  case LibFunc_execle:
661
104
    return (NumParams >= 2 && 
FTy.getParamType(0)->isPointerTy()101
&&
662
104
            
FTy.getParamType(1)->isPointerTy()101
&&
663
104
            
FTy.getReturnType()->isIntegerTy(32)101
);
664
585
  case LibFunc_execv:
665
585
  case LibFunc_execvp:
666
585
    return (NumParams == 2 && 
FTy.getParamType(0)->isPointerTy()583
&&
667
585
            
FTy.getParamType(1)->isPointerTy()583
&&
668
585
            
FTy.getReturnType()->isIntegerTy(32)583
);
669
585
  case LibFunc_execvP:
670
116
  case LibFunc_execvpe:
671
116
  case LibFunc_execve:
672
116
    return (NumParams == 3 && 
FTy.getParamType(0)->isPointerTy()113
&&
673
116
            
FTy.getParamType(1)->isPointerTy()113
&&
674
116
            
FTy.getParamType(2)->isPointerTy()113
&&
675
116
            
FTy.getReturnType()->isIntegerTy(32)113
);
676
188k
  case LibFunc_strlen:
677
188k
    return (NumParams == 1 && 
FTy.getParamType(0)->isPointerTy()188k
&&
678
188k
            
FTy.getReturnType()->isIntegerTy()188k
);
679
116
680
14.5k
  case LibFunc_strchr:
681
14.5k
  case LibFunc_strrchr:
682
14.5k
    return (NumParams == 2 && 
FTy.getReturnType()->isPointerTy()14.5k
&&
683
14.5k
            
FTy.getParamType(0) == FTy.getReturnType()14.5k
&&
684
14.5k
            
FTy.getParamType(1)->isIntegerTy()14.5k
);
685
14.5k
686
14.5k
  case LibFunc_strtol:
687
1.61k
  case LibFunc_strtod:
688
1.61k
  case LibFunc_strtof:
689
1.61k
  case LibFunc_strtoul:
690
1.61k
  case LibFunc_strtoll:
691
1.61k
  case LibFunc_strtold:
692
1.61k
  case LibFunc_strtoull:
693
1.61k
    return ((NumParams == 2 || 
NumParams == 31.48k
) &&
694
1.61k
            
FTy.getParamType(0)->isPointerTy()1.59k
&&
695
1.61k
            
FTy.getParamType(1)->isPointerTy()1.59k
);
696
12.4k
  case LibFunc_strcat_chk:
697
12.4k
    --NumParams;
698
12.4k
    if (!IsSizeTTy(FTy.getParamType(NumParams)))
699
1
      return false;
700
12.4k
    LLVM_FALLTHROUGH;
701
16.1k
  case LibFunc_strcat:
702
16.1k
    return (NumParams == 2 && 
FTy.getReturnType()->isPointerTy()16.1k
&&
703
16.1k
            
FTy.getParamType(0) == FTy.getReturnType()16.1k
&&
704
16.1k
            
FTy.getParamType(1) == FTy.getReturnType()16.1k
);
705
12.4k
706
12.4k
  case LibFunc_strncat_chk:
707
1.84k
    --NumParams;
708
1.84k
    if (!IsSizeTTy(FTy.getParamType(NumParams)))
709
1
      return false;
710
1.84k
    LLVM_FALLTHROUGH;
711
1.94k
  case LibFunc_strncat:
712
1.94k
    return (NumParams == 3 && 
FTy.getReturnType()->isPointerTy()1.94k
&&
713
1.94k
            
FTy.getParamType(0) == FTy.getReturnType()1.94k
&&
714
1.94k
            
FTy.getParamType(1) == FTy.getReturnType()1.93k
&&
715
1.94k
            
IsSizeTTy(FTy.getParamType(2))1.93k
);
716
1.84k
717
34.8k
  case LibFunc_strcpy_chk:
718
34.8k
  case LibFunc_stpcpy_chk:
719
34.8k
    --NumParams;
720
34.8k
    if (!IsSizeTTy(FTy.getParamType(NumParams)))
721
2
      return false;
722
34.8k
    LLVM_FALLTHROUGH;
723
50.0k
  case LibFunc_strcpy:
724
50.0k
  case LibFunc_stpcpy:
725
50.0k
    return (NumParams == 2 && 
FTy.getReturnType() == FTy.getParamType(0)50.0k
&&
726
50.0k
            
FTy.getParamType(0) == FTy.getParamType(1)50.0k
&&
727
50.0k
            
FTy.getParamType(0) == PCharTy50.0k
);
728
50.0k
729
50.0k
  case LibFunc_strlcat_chk:
730
12
  case LibFunc_strlcpy_chk:
731
12
    --NumParams;
732
12
    if (!IsSizeTTy(FTy.getParamType(NumParams)))
733
2
      return false;
734
10
    LLVM_FALLTHROUGH;
735
168
  case LibFunc_strlcat:
736
168
  case LibFunc_strlcpy:
737
168
    return NumParams == 3 && 
IsSizeTTy(FTy.getReturnType())166
&&
738
168
           
FTy.getParamType(0)->isPointerTy()166
&&
739
168
           
FTy.getParamType(1)->isPointerTy()166
&&
740
168
           
IsSizeTTy(FTy.getParamType(2))166
;
741
168
742
10.4k
  case LibFunc_strncpy_chk:
743
10.4k
  case LibFunc_stpncpy_chk:
744
10.4k
    --NumParams;
745
10.4k
    if (!IsSizeTTy(FTy.getParamType(NumParams)))
746
2
      return false;
747
10.4k
    LLVM_FALLTHROUGH;
748
15.1k
  case LibFunc_strncpy:
749
15.1k
  case LibFunc_stpncpy:
750
15.1k
    return (NumParams == 3 && 
FTy.getReturnType() == FTy.getParamType(0)15.1k
&&
751
15.1k
            
FTy.getParamType(0) == FTy.getParamType(1)15.1k
&&
752
15.1k
            
FTy.getParamType(0) == PCharTy15.1k
&&
753
15.1k
            
IsSizeTTy(FTy.getParamType(2))15.1k
);
754
15.1k
755
15.1k
  case LibFunc_strxfrm:
756
105
    return (NumParams == 3 && 
FTy.getParamType(0)->isPointerTy()102
&&
757
105
            
FTy.getParamType(1)->isPointerTy()102
);
758
15.1k
759
333k
  case LibFunc_strcmp:
760
333k
    return (NumParams == 2 && 
FTy.getReturnType()->isIntegerTy(32)333k
&&
761
333k
            
FTy.getParamType(0)->isPointerTy()333k
&&
762
333k
            
FTy.getParamType(0) == FTy.getParamType(1)333k
);
763
15.1k
764
18.2k
  case LibFunc_strncmp:
765
18.2k
    return (NumParams == 3 && 
FTy.getReturnType()->isIntegerTy(32)18.2k
&&
766
18.2k
            
FTy.getParamType(0)->isPointerTy()18.2k
&&
767
18.2k
            
FTy.getParamType(0) == FTy.getParamType(1)18.2k
&&
768
18.2k
            
IsSizeTTy(FTy.getParamType(2))18.2k
);
769
15.1k
770
15.1k
  case LibFunc_strspn:
771
728
  case LibFunc_strcspn:
772
728
    return (NumParams == 2 && 
FTy.getParamType(0)->isPointerTy()722
&&
773
728
            
FTy.getParamType(0) == FTy.getParamType(1)722
&&
774
728
            
FTy.getReturnType()->isIntegerTy()722
);
775
728
776
7.40k
  case LibFunc_strcoll:
777
7.40k
  case LibFunc_strcasecmp:
778
7.40k
  case LibFunc_strncasecmp:
779
7.40k
    return (NumParams >= 2 && 
FTy.getParamType(0)->isPointerTy()7.39k
&&
780
7.40k
            
FTy.getParamType(1)->isPointerTy()7.39k
);
781
7.40k
782
7.40k
  case LibFunc_strstr:
783
3.56k
    return (NumParams == 2 && 
FTy.getReturnType()->isPointerTy()3.56k
&&
784
3.56k
            
FTy.getParamType(0)->isPointerTy()3.56k
&&
785
3.56k
            
FTy.getParamType(1)->isPointerTy()3.56k
);
786
7.40k
787
7.40k
  case LibFunc_strpbrk:
788
303
    return (NumParams == 2 && 
FTy.getParamType(0)->isPointerTy()300
&&
789
303
            
FTy.getReturnType() == FTy.getParamType(0)300
&&
790
303
            
FTy.getParamType(0) == FTy.getParamType(1)298
);
791
7.40k
792
7.40k
  case LibFunc_strtok:
793
2.34k
  case LibFunc_strtok_r:
794
2.34k
    return (NumParams >= 2 && 
FTy.getParamType(1)->isPointerTy()2.33k
);
795
3.23k
  case LibFunc_scanf:
796
3.23k
  case LibFunc_setbuf:
797
3.23k
  case LibFunc_setvbuf:
798
3.23k
    return (NumParams >= 1 && 
FTy.getParamType(0)->isPointerTy()3.22k
);
799
3.23k
  case LibFunc_strdup:
800
542
  case LibFunc_strndup:
801
542
    return (NumParams >= 1 && 
FTy.getReturnType()->isPointerTy()536
&&
802
542
            
FTy.getParamType(0)->isPointerTy()536
);
803
34.4k
  case LibFunc_sscanf:
804
34.4k
  case LibFunc_stat:
805
34.4k
  case LibFunc_statvfs:
806
34.4k
  case LibFunc_siprintf:
807
34.4k
  case LibFunc_small_sprintf:
808
34.4k
  case LibFunc_sprintf:
809
34.4k
    return (NumParams >= 2 && 
FTy.getParamType(0)->isPointerTy()34.4k
&&
810
34.4k
            
FTy.getParamType(1)->isPointerTy()34.4k
&&
811
34.4k
            
FTy.getReturnType()->isIntegerTy(32)34.4k
);
812
34.4k
813
44.3k
  case LibFunc_sprintf_chk:
814
44.3k
    return NumParams == 4 && 
FTy.getParamType(0)->isPointerTy()44.3k
&&
815
44.3k
           
FTy.getParamType(1)->isIntegerTy(32)44.3k
&&
816
44.3k
           
IsSizeTTy(FTy.getParamType(2))44.3k
&&
817
44.3k
           
FTy.getParamType(3)->isPointerTy()44.3k
&&
818
44.3k
           
FTy.getReturnType()->isIntegerTy(32)44.3k
;
819
34.4k
820
34.4k
  case LibFunc_snprintf:
821
14.2k
    return (NumParams == 3 && 
FTy.getParamType(0)->isPointerTy()14.2k
&&
822
14.2k
            
FTy.getParamType(2)->isPointerTy()14.2k
&&
823
14.2k
            
FTy.getReturnType()->isIntegerTy(32)14.2k
);
824
34.4k
825
34.4k
  case LibFunc_snprintf_chk:
826
3.35k
    return NumParams == 5 && 
FTy.getParamType(0)->isPointerTy()3.34k
&&
827
3.35k
           
IsSizeTTy(FTy.getParamType(1))3.34k
&&
828
3.35k
           
FTy.getParamType(2)->isIntegerTy(32)3.34k
&&
829
3.35k
           
IsSizeTTy(FTy.getParamType(3))3.34k
&&
830
3.35k
           
FTy.getParamType(4)->isPointerTy()3.34k
&&
831
3.35k
           
FTy.getReturnType()->isIntegerTy(32)3.34k
;
832
34.4k
833
34.4k
  case LibFunc_setitimer:
834
193
    return (NumParams == 3 && 
FTy.getParamType(1)->isPointerTy()190
&&
835
193
            
FTy.getParamType(2)->isPointerTy()190
);
836
34.4k
  case LibFunc_system:
837
9
    return (NumParams == 1 && 
FTy.getParamType(0)->isPointerTy()6
);
838
34.4k
  case LibFunc_malloc:
839
25.4k
    return (NumParams == 1 && 
FTy.getReturnType()->isPointerTy()25.3k
);
840
34.4k
  case LibFunc_memcmp:
841
21.8k
    return (NumParams == 3 && 
FTy.getReturnType()->isIntegerTy(32)21.8k
&&
842
21.8k
            
FTy.getParamType(0)->isPointerTy()21.8k
&&
843
21.8k
            
FTy.getParamType(1)->isPointerTy()21.8k
);
844
34.4k
845
34.4k
  case LibFunc_memchr:
846
6.50k
  case LibFunc_memrchr:
847
6.50k
    return (NumParams == 3 && 
FTy.getReturnType()->isPointerTy()6.49k
&&
848
6.50k
            
FTy.getReturnType() == FTy.getParamType(0)6.49k
&&
849
6.50k
            
FTy.getParamType(1)->isIntegerTy(32)6.49k
&&
850
6.50k
            
IsSizeTTy(FTy.getParamType(2))6.49k
);
851
6.50k
  case LibFunc_modf:
852
336
  case LibFunc_modff:
853
336
  case LibFunc_modfl:
854
336
    return (NumParams >= 2 && 
FTy.getParamType(1)->isPointerTy()327
);
855
336
856
135k
  case LibFunc_memcpy_chk:
857
135k
  case LibFunc_memmove_chk:
858
135k
    --NumParams;
859
135k
    if (!IsSizeTTy(FTy.getParamType(NumParams)))
860
2
      return false;
861
135k
    LLVM_FALLTHROUGH;
862
153k
  case LibFunc_memcpy:
863
153k
  case LibFunc_mempcpy:
864
153k
  case LibFunc_memmove:
865
153k
    return (NumParams == 3 && 
FTy.getReturnType() == FTy.getParamType(0)153k
&&
866
153k
            
FTy.getParamType(0)->isPointerTy()153k
&&
867
153k
            
FTy.getParamType(1)->isPointerTy()153k
&&
868
153k
            
IsSizeTTy(FTy.getParamType(2))153k
);
869
153k
870
153k
  case LibFunc_memset_chk:
871
66.7k
    --NumParams;
872
66.7k
    if (!IsSizeTTy(FTy.getParamType(NumParams)))
873
10
      return false;
874
66.7k
    LLVM_FALLTHROUGH;
875
70.5k
  case LibFunc_memset:
876
70.5k
    return (NumParams == 3 && 
FTy.getReturnType() == FTy.getParamType(0)70.5k
&&
877
70.5k
            
FTy.getParamType(0)->isPointerTy()70.5k
&&
878
70.5k
            
FTy.getParamType(1)->isIntegerTy()70.5k
&&
879
70.5k
            
IsSizeTTy(FTy.getParamType(2))70.5k
);
880
66.7k
881
66.7k
  case LibFunc_memccpy_chk:
882
6
      --NumParams;
883
6
    if (!IsSizeTTy(FTy.getParamType(NumParams)))
884
1
      return false;
885
5
    LLVM_FALLTHROUGH;
886
19
  case LibFunc_memccpy:
887
19
    return (NumParams >= 2 && 
FTy.getParamType(1)->isPointerTy()16
);
888
8
  case LibFunc_memalign:
889
8
    return (FTy.getReturnType()->isPointerTy());
890
53.5k
  case LibFunc_realloc:
891
53.5k
  case LibFunc_reallocf:
892
53.5k
    return (NumParams == 2 && 
FTy.getReturnType() == PCharTy53.5k
&&
893
53.5k
            
FTy.getParamType(0) == FTy.getReturnType()53.5k
&&
894
53.5k
            
IsSizeTTy(FTy.getParamType(1))53.5k
);
895
53.5k
  case LibFunc_read:
896
142
    return (NumParams == 3 && 
FTy.getParamType(1)->isPointerTy()134
);
897
53.5k
  case LibFunc_rewind:
898
5.36k
  case LibFunc_rmdir:
899
5.36k
  case LibFunc_remove:
900
5.36k
  case LibFunc_realpath:
901
5.36k
    return (NumParams >= 1 && 
FTy.getParamType(0)->isPointerTy()5.35k
);
902
5.36k
  case LibFunc_rename:
903
584
    return (NumParams >= 2 && 
FTy.getParamType(0)->isPointerTy()581
&&
904
584
            
FTy.getParamType(1)->isPointerTy()581
);
905
5.36k
  case LibFunc_readlink:
906
332
    return (NumParams >= 2 && 
FTy.getParamType(0)->isPointerTy()329
&&
907
332
            
FTy.getParamType(1)->isPointerTy()329
);
908
5.70k
  case LibFunc_write:
909
5.70k
    return (NumParams == 3 && 
FTy.getParamType(1)->isPointerTy()5.69k
);
910
35.9k
  case LibFunc_bcopy:
911
35.9k
  case LibFunc_bcmp:
912
35.9k
    return (NumParams == 3 && 
FTy.getParamType(0)->isPointerTy()35.9k
&&
913
35.9k
            
FTy.getParamType(1)->isPointerTy()35.9k
);
914
35.9k
  case LibFunc_bzero:
915
9
    return (NumParams == 2 && 
FTy.getParamType(0)->isPointerTy()6
);
916
35.9k
  case LibFunc_calloc:
917
3.76k
    return (NumParams == 2 && 
FTy.getReturnType()->isPointerTy()3.76k
);
918
35.9k
919
2.03M
  case LibFunc_atof:
920
2.03M
  case LibFunc_atoi:
921
2.03M
  case LibFunc_atol:
922
2.03M
  case LibFunc_atoll:
923
2.03M
  case LibFunc_ferror:
924
2.03M
  case LibFunc_getenv:
925
2.03M
  case LibFunc_getpwnam:
926
2.03M
  case LibFunc_iprintf:
927
2.03M
  case LibFunc_small_printf:
928
2.03M
  case LibFunc_pclose:
929
2.03M
  case LibFunc_perror:
930
2.03M
  case LibFunc_printf:
931
2.03M
  case LibFunc_puts:
932
2.03M
  case LibFunc_uname:
933
2.03M
  case LibFunc_under_IO_getc:
934
2.03M
  case LibFunc_unlink:
935
2.03M
  case LibFunc_unsetenv:
936
2.03M
    return (NumParams == 1 && 
FTy.getParamType(0)->isPointerTy()2.03M
);
937
2.03M
938
2.03M
  case LibFunc_access:
939
466k
  case LibFunc_chmod:
940
466k
  case LibFunc_chown:
941
466k
  case LibFunc_clearerr:
942
466k
  case LibFunc_closedir:
943
466k
  case LibFunc_ctermid:
944
466k
  case LibFunc_fclose:
945
466k
  case LibFunc_feof:
946
466k
  case LibFunc_fflush:
947
466k
  case LibFunc_fgetc:
948
466k
  case LibFunc_fgetc_unlocked:
949
466k
  case LibFunc_fileno:
950
466k
  case LibFunc_flockfile:
951
466k
  case LibFunc_free:
952
466k
  case LibFunc_fseek:
953
466k
  case LibFunc_fseeko64:
954
466k
  case LibFunc_fseeko:
955
466k
  case LibFunc_fsetpos:
956
466k
  case LibFunc_ftell:
957
466k
  case LibFunc_ftello64:
958
466k
  case LibFunc_ftello:
959
466k
  case LibFunc_ftrylockfile:
960
466k
  case LibFunc_funlockfile:
961
466k
  case LibFunc_getc:
962
466k
  case LibFunc_getc_unlocked:
963
466k
  case LibFunc_getlogin_r:
964
466k
  case LibFunc_mkdir:
965
466k
  case LibFunc_mktime:
966
466k
  case LibFunc_times:
967
466k
    return (NumParams != 0 && 
FTy.getParamType(0)->isPointerTy()466k
);
968
466k
969
466k
  case LibFunc_fopen:
970
11.5k
    return (NumParams == 2 && 
FTy.getReturnType()->isPointerTy()11.5k
&&
971
11.5k
            
FTy.getParamType(0)->isPointerTy()11.5k
&&
972
11.5k
            
FTy.getParamType(1)->isPointerTy()11.5k
);
973
466k
  case LibFunc_fork:
974
639
    return (NumParams == 0 && 
FTy.getReturnType()->isIntegerTy(32)559
);
975
466k
  case LibFunc_fdopen:
976
89
    return (NumParams == 2 && 
FTy.getReturnType()->isPointerTy()86
&&
977
89
            
FTy.getParamType(1)->isPointerTy()86
);
978
466k
  case LibFunc_fputc:
979
35.2k
  case LibFunc_fputc_unlocked:
980
35.2k
  case LibFunc_fstat:
981
35.2k
  case LibFunc_frexp:
982
35.2k
  case LibFunc_frexpf:
983
35.2k
  case LibFunc_frexpl:
984
35.2k
  case LibFunc_fstatvfs:
985
35.2k
    return (NumParams == 2 && 
FTy.getParamType(1)->isPointerTy()35.2k
);
986
35.2k
  case LibFunc_fgets:
987
20.2k
  case LibFunc_fgets_unlocked:
988
20.2k
    return (NumParams == 3 && 
FTy.getParamType(0)->isPointerTy()20.2k
&&
989
20.2k
            
FTy.getParamType(2)->isPointerTy()20.2k
);
990
20.2k
  case LibFunc_fread:
991
16.4k
  case LibFunc_fread_unlocked:
992
16.4k
    return (NumParams == 4 && 
FTy.getParamType(0)->isPointerTy()16.4k
&&
993
16.4k
            
FTy.getParamType(3)->isPointerTy()16.4k
);
994
251k
  case LibFunc_fwrite:
995
251k
  case LibFunc_fwrite_unlocked:
996
251k
    return (NumParams == 4 && 
FTy.getReturnType()->isIntegerTy()251k
&&
997
251k
            
FTy.getParamType(0)->isPointerTy()251k
&&
998
251k
            
FTy.getParamType(1)->isIntegerTy()251k
&&
999
251k
            
FTy.getParamType(2)->isIntegerTy()251k
&&
1000
251k
            
FTy.getParamType(3)->isPointerTy()251k
);
1001
251k
  case LibFunc_fputs:
1002
7.35k
  case LibFunc_fputs_unlocked:
1003
7.35k
    return (NumParams >= 2 && 
FTy.getParamType(0)->isPointerTy()7.34k
&&
1004
7.35k
            
FTy.getParamType(1)->isPointerTy()7.34k
);
1005
407k
  case LibFunc_fscanf:
1006
407k
  case LibFunc_fiprintf:
1007
407k
  case LibFunc_small_fprintf:
1008
407k
  case LibFunc_fprintf:
1009
407k
    return (NumParams >= 2 && 
FTy.getReturnType()->isIntegerTy()407k
&&
1010
407k
            
FTy.getParamType(0)->isPointerTy()407k
&&
1011
407k
            
FTy.getParamType(1)->isPointerTy()407k
);
1012
407k
  case LibFunc_fgetpos:
1013
100
    return (NumParams >= 2 && 
FTy.getParamType(0)->isPointerTy()97
&&
1014
100
            
FTy.getParamType(1)->isPointerTy()97
);
1015
407k
  case LibFunc_getchar:
1016
2.51k
  case LibFunc_getchar_unlocked:
1017
2.51k
    return (NumParams == 0 && FTy.getReturnType()->isIntegerTy());
1018
2.51k
  case LibFunc_gets:
1019
102
    return (NumParams == 1 && 
FTy.getParamType(0) == PCharTy99
);
1020
2.51k
  case LibFunc_getitimer:
1021
89
    return (NumParams == 2 && 
FTy.getParamType(1)->isPointerTy()86
);
1022
8.31k
  case LibFunc_ungetc:
1023
8.31k
    return (NumParams == 2 && 
FTy.getParamType(1)->isPointerTy()8.31k
);
1024
2.51k
  case LibFunc_utime:
1025
495
  case LibFunc_utimes:
1026
495
    return (NumParams == 2 && 
FTy.getParamType(0)->isPointerTy()489
&&
1027
495
            
FTy.getParamType(1)->isPointerTy()489
);
1028
41.1k
  case LibFunc_putc:
1029
41.1k
  case LibFunc_putc_unlocked:
1030
41.1k
    return (NumParams == 2 && 
FTy.getParamType(1)->isPointerTy()41.1k
);
1031
41.1k
  case LibFunc_pread:
1032
274
  case LibFunc_pwrite:
1033
274
    return (NumParams == 4 && 
FTy.getParamType(1)->isPointerTy()268
);
1034
274
  case LibFunc_popen:
1035
105
    return (NumParams == 2 && 
FTy.getReturnType()->isPointerTy()102
&&
1036
105
            
FTy.getParamType(0)->isPointerTy()102
&&
1037
105
            
FTy.getParamType(1)->isPointerTy()102
);
1038
289
  case LibFunc_vscanf:
1039
289
    return (NumParams == 2 && 
FTy.getParamType(1)->isPointerTy()286
);
1040
289
  case LibFunc_vsscanf:
1041
289
    return (NumParams == 3 && 
FTy.getParamType(1)->isPointerTy()286
&&
1042
289
            
FTy.getParamType(2)->isPointerTy()286
);
1043
289
  case LibFunc_vfscanf:
1044
289
    return (NumParams == 3 && 
FTy.getParamType(1)->isPointerTy()286
&&
1045
289
            
FTy.getParamType(2)->isPointerTy()286
);
1046
274
  case LibFunc_valloc:
1047
34
    return (FTy.getReturnType()->isPointerTy());
1048
274
  case LibFunc_vprintf:
1049
173
    return (NumParams == 2 && 
FTy.getParamType(0)->isPointerTy()170
);
1050
1.69k
  case LibFunc_vfprintf:
1051
1.69k
  case LibFunc_vsprintf:
1052
1.69k
    return (NumParams == 3 && 
FTy.getParamType(0)->isPointerTy()1.69k
&&
1053
1.69k
            
FTy.getParamType(1)->isPointerTy()1.69k
);
1054
1.69k
  case LibFunc_vsprintf_chk:
1055
226
    return NumParams == 5 && 
FTy.getParamType(0)->isPointerTy()225
&&
1056
226
           
FTy.getParamType(1)->isIntegerTy(32)225
&&
1057
226
           
IsSizeTTy(FTy.getParamType(2))225
&&
FTy.getParamType(3)->isPointerTy()225
;
1058
1.69k
  case LibFunc_vsnprintf:
1059
804
    return (NumParams == 4 && 
FTy.getParamType(0)->isPointerTy()801
&&
1060
804
            
FTy.getParamType(2)->isPointerTy()801
);
1061
1.69k
  case LibFunc_vsnprintf_chk:
1062
161
    return NumParams == 6 && 
FTy.getParamType(0)->isPointerTy()160
&&
1063
161
           
FTy.getParamType(2)->isIntegerTy(32)160
&&
1064
161
           
IsSizeTTy(FTy.getParamType(3))160
&&
FTy.getParamType(4)->isPointerTy()160
;
1065
9.81k
  case LibFunc_open:
1066
9.81k
    return (NumParams >= 2 && 
FTy.getParamType(0)->isPointerTy()9.81k
);
1067
1.69k
  case LibFunc_opendir:
1068
105
    return (NumParams == 1 && 
FTy.getReturnType()->isPointerTy()102
&&
1069
105
            
FTy.getParamType(0)->isPointerTy()102
);
1070
1.69k
  case LibFunc_tmpfile:
1071
159
    return (FTy.getReturnType()->isPointerTy());
1072
1.69k
  case LibFunc_htonl:
1073
5
  case LibFunc_ntohl:
1074
5
    return (NumParams == 1 && 
FTy.getReturnType()->isIntegerTy(32)3
&&
1075
5
            
FTy.getReturnType() == FTy.getParamType(0)3
);
1076
5
  case LibFunc_htons:
1077
4
  case LibFunc_ntohs:
1078
4
    return (NumParams == 1 && 
FTy.getReturnType()->isIntegerTy(16)2
&&
1079
4
            
FTy.getReturnType() == FTy.getParamType(0)2
);
1080
9
  case LibFunc_lstat:
1081
9
    return (NumParams == 2 && 
FTy.getParamType(0)->isPointerTy()6
&&
1082
9
            
FTy.getParamType(1)->isPointerTy()6
);
1083
9
  case LibFunc_lchown:
1084
9
    return (NumParams == 3 && 
FTy.getParamType(0)->isPointerTy()6
);
1085
7.72k
  case LibFunc_qsort:
1086
7.72k
    return (NumParams == 4 && 
FTy.getParamType(3)->isPointerTy()7.72k
);
1087
4
  case LibFunc_dunder_strdup:
1088
3
  case LibFunc_dunder_strndup:
1089
3
    return (NumParams >= 1 && 
FTy.getReturnType()->isPointerTy()2
&&
1090
3
            
FTy.getParamType(0)->isPointerTy()2
);
1091
3
  case LibFunc_dunder_strtok_r:
1092
1
    return (NumParams == 3 && FTy.getParamType(1)->isPointerTy());
1093
3
  case LibFunc_under_IO_putc:
1094
1
    return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
1095
3
  case LibFunc_dunder_isoc99_scanf:
1096
1
    return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy());
1097
25
  case LibFunc_stat64:
1098
25
  case LibFunc_lstat64:
1099
25
  case LibFunc_statvfs64:
1100
25
    return (NumParams == 2 && 
FTy.getParamType(0)->isPointerTy()18
&&
1101
25
            
FTy.getParamType(1)->isPointerTy()18
);
1102
25
  case LibFunc_dunder_isoc99_sscanf:
1103
1
    return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
1104
1
            FTy.getParamType(1)->isPointerTy());
1105
25
  case LibFunc_fopen64:
1106
1
    return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
1107
1
            FTy.getParamType(0)->isPointerTy() &&
1108
1
            FTy.getParamType(1)->isPointerTy());
1109
25
  case LibFunc_tmpfile64:
1110
8
    return (FTy.getReturnType()->isPointerTy());
1111
25
  case LibFunc_fstat64:
1112
16
  case LibFunc_fstatvfs64:
1113
16
    return (NumParams == 2 && 
FTy.getParamType(1)->isPointerTy()12
);
1114
16
  case LibFunc_open64:
1115
8
    return (NumParams >= 2 && 
FTy.getParamType(0)->isPointerTy()6
);
1116
14.5k
  case LibFunc_gettimeofday:
1117
14.5k
    return (NumParams == 2 && 
FTy.getParamType(0)->isPointerTy()14.5k
&&
1118
14.5k
            
FTy.getParamType(1)->isPointerTy()14.5k
);
1119
16
1120
16
  // new(unsigned int);
1121
80.8k
  case LibFunc_Znwj:
1122
80.8k
  // new(unsigned long);
1123
80.8k
  case LibFunc_Znwm:
1124
80.8k
  // new[](unsigned int);
1125
80.8k
  case LibFunc_Znaj:
1126
80.8k
  // new[](unsigned long);
1127
80.8k
  case LibFunc_Znam:
1128
80.8k
  // new(unsigned int);
1129
80.8k
  case LibFunc_msvc_new_int:
1130
80.8k
  // new(unsigned long long);
1131
80.8k
  case LibFunc_msvc_new_longlong:
1132
80.8k
  // new[](unsigned int);
1133
80.8k
  case LibFunc_msvc_new_array_int:
1134
80.8k
  // new[](unsigned long long);
1135
80.8k
  case LibFunc_msvc_new_array_longlong:
1136
80.8k
    return (NumParams == 1 && 
FTy.getReturnType()->isPointerTy()80.8k
);
1137
80.8k
1138
80.8k
  // new(unsigned int, nothrow);
1139
80.8k
  case LibFunc_ZnwjRKSt9nothrow_t:
1140
62
  // new(unsigned long, nothrow);
1141
62
  case LibFunc_ZnwmRKSt9nothrow_t:
1142
62
  // new[](unsigned int, nothrow);
1143
62
  case LibFunc_ZnajRKSt9nothrow_t:
1144
62
  // new[](unsigned long, nothrow);
1145
62
  case LibFunc_ZnamRKSt9nothrow_t:
1146
62
  // new(unsigned int, nothrow);
1147
62
  case LibFunc_msvc_new_int_nothrow:
1148
62
  // new(unsigned long long, nothrow);
1149
62
  case LibFunc_msvc_new_longlong_nothrow:
1150
62
  // new[](unsigned int, nothrow);
1151
62
  case LibFunc_msvc_new_array_int_nothrow:
1152
62
  // new[](unsigned long long, nothrow);
1153
62
  case LibFunc_msvc_new_array_longlong_nothrow:
1154
62
  // new(unsigned int, align_val_t)
1155
62
  case LibFunc_ZnwjSt11align_val_t:
1156
62
  // new(unsigned long, align_val_t)
1157
62
  case LibFunc_ZnwmSt11align_val_t:
1158
62
  // new[](unsigned int, align_val_t)
1159
62
  case LibFunc_ZnajSt11align_val_t:
1160
62
  // new[](unsigned long, align_val_t)
1161
62
  case LibFunc_ZnamSt11align_val_t:
1162
62
    return (NumParams == 2 && 
FTy.getReturnType()->isPointerTy()50
);
1163
62
1164
62
  // new(unsigned int, align_val_t, nothrow)
1165
62
  case LibFunc_ZnwjSt11align_val_tRKSt9nothrow_t:
1166
8
  // new(unsigned long, align_val_t, nothrow)
1167
8
  case LibFunc_ZnwmSt11align_val_tRKSt9nothrow_t:
1168
8
  // new[](unsigned int, align_val_t, nothrow)
1169
8
  case LibFunc_ZnajSt11align_val_tRKSt9nothrow_t:
1170
8
  // new[](unsigned long, align_val_t, nothrow)
1171
8
  case LibFunc_ZnamSt11align_val_tRKSt9nothrow_t:
1172
8
    return (NumParams == 3 && 
FTy.getReturnType()->isPointerTy()4
);
1173
8
1174
8
  // void operator delete[](void*);
1175
1.06M
  case LibFunc_ZdaPv:
1176
1.06M
  // void operator delete(void*);
1177
1.06M
  case LibFunc_ZdlPv:
1178
1.06M
  // void operator delete[](void*);
1179
1.06M
  case LibFunc_msvc_delete_array_ptr32:
1180
1.06M
  // void operator delete[](void*);
1181
1.06M
  case LibFunc_msvc_delete_array_ptr64:
1182
1.06M
  // void operator delete(void*);
1183
1.06M
  case LibFunc_msvc_delete_ptr32:
1184
1.06M
  // void operator delete(void*);
1185
1.06M
  case LibFunc_msvc_delete_ptr64:
1186
1.06M
    return (NumParams == 1 && 
FTy.getParamType(0)->isPointerTy()1.06M
);
1187
1.06M
1188
1.06M
  // void operator delete[](void*, nothrow);
1189
1.06M
  case LibFunc_ZdaPvRKSt9nothrow_t:
1190
67
  // void operator delete[](void*, unsigned int);
1191
67
  case LibFunc_ZdaPvj:
1192
67
  // void operator delete[](void*, unsigned long);
1193
67
  case LibFunc_ZdaPvm:
1194
67
  // void operator delete(void*, nothrow);
1195
67
  case LibFunc_ZdlPvRKSt9nothrow_t:
1196
67
  // void operator delete(void*, unsigned int);
1197
67
  case LibFunc_ZdlPvj:
1198
67
  // void operator delete(void*, unsigned long);
1199
67
  case LibFunc_ZdlPvm:
1200
67
  // void operator delete(void*, align_val_t)
1201
67
  case LibFunc_ZdlPvSt11align_val_t:
1202
67
  // void operator delete[](void*, align_val_t)
1203
67
  case LibFunc_ZdaPvSt11align_val_t:
1204
67
  // void operator delete[](void*, unsigned int);
1205
67
  case LibFunc_msvc_delete_array_ptr32_int:
1206
67
  // void operator delete[](void*, nothrow);
1207
67
  case LibFunc_msvc_delete_array_ptr32_nothrow:
1208
67
  // void operator delete[](void*, unsigned long long);
1209
67
  case LibFunc_msvc_delete_array_ptr64_longlong:
1210
67
  // void operator delete[](void*, nothrow);
1211
67
  case LibFunc_msvc_delete_array_ptr64_nothrow:
1212
67
  // void operator delete(void*, unsigned int);
1213
67
  case LibFunc_msvc_delete_ptr32_int:
1214
67
  // void operator delete(void*, nothrow);
1215
67
  case LibFunc_msvc_delete_ptr32_nothrow:
1216
67
  // void operator delete(void*, unsigned long long);
1217
67
  case LibFunc_msvc_delete_ptr64_longlong:
1218
67
  // void operator delete(void*, nothrow);
1219
67
  case LibFunc_msvc_delete_ptr64_nothrow:
1220
67
    return (NumParams == 2 && 
FTy.getParamType(0)->isPointerTy()51
);
1221
67
1222
67
  // void operator delete(void*, align_val_t, nothrow)
1223
67
  case LibFunc_ZdlPvSt11align_val_tRKSt9nothrow_t:
1224
8
  // void operator delete[](void*, align_val_t, nothrow)
1225
8
  case LibFunc_ZdaPvSt11align_val_tRKSt9nothrow_t:
1226
8
    return (NumParams == 3 && 
FTy.getParamType(0)->isPointerTy()6
);
1227
8
1228
357k
  case LibFunc_memset_pattern16:
1229
357k
    return (!FTy.isVarArg() && 
NumParams == 3357k
&&
1230
357k
            
FTy.getParamType(0)->isPointerTy()357k
&&
1231
357k
            
FTy.getParamType(1)->isPointerTy()357k
&&
1232
357k
            
FTy.getParamType(2)->isIntegerTy()357k
);
1233
8
1234
53.8k
  case LibFunc_cxa_guard_abort:
1235
53.8k
  case LibFunc_cxa_guard_acquire:
1236
53.8k
  case LibFunc_cxa_guard_release:
1237
53.8k
  case LibFunc_nvvm_reflect:
1238
53.8k
    return (NumParams == 1 && 
FTy.getParamType(0)->isPointerTy()53.8k
);
1239
53.8k
1240
53.8k
  case LibFunc_sincospi_stret:
1241
38
  case LibFunc_sincospif_stret:
1242
38
    return (NumParams == 1 && FTy.getParamType(0)->isFloatingPointTy());
1243
38
1244
106k
  case LibFunc_acos:
1245
106k
  case LibFunc_acos_finite:
1246
106k
  case LibFunc_acosf:
1247
106k
  case LibFunc_acosf_finite:
1248
106k
  case LibFunc_acosh:
1249
106k
  case LibFunc_acosh_finite:
1250
106k
  case LibFunc_acoshf:
1251
106k
  case LibFunc_acoshf_finite:
1252
106k
  case LibFunc_acoshl:
1253
106k
  case LibFunc_acoshl_finite:
1254
106k
  case LibFunc_acosl:
1255
106k
  case LibFunc_acosl_finite:
1256
106k
  case LibFunc_asin:
1257
106k
  case LibFunc_asin_finite:
1258
106k
  case LibFunc_asinf:
1259
106k
  case LibFunc_asinf_finite:
1260
106k
  case LibFunc_asinh:
1261
106k
  case LibFunc_asinhf:
1262
106k
  case LibFunc_asinhl:
1263
106k
  case LibFunc_asinl:
1264
106k
  case LibFunc_asinl_finite:
1265
106k
  case LibFunc_atan:
1266
106k
  case LibFunc_atanf:
1267
106k
  case LibFunc_atanh:
1268
106k
  case LibFunc_atanh_finite:
1269
106k
  case LibFunc_atanhf:
1270
106k
  case LibFunc_atanhf_finite:
1271
106k
  case LibFunc_atanhl:
1272
106k
  case LibFunc_atanhl_finite:
1273
106k
  case LibFunc_atanl:
1274
106k
  case LibFunc_cbrt:
1275
106k
  case LibFunc_cbrtf:
1276
106k
  case LibFunc_cbrtl:
1277
106k
  case LibFunc_ceil:
1278
106k
  case LibFunc_ceilf:
1279
106k
  case LibFunc_ceill:
1280
106k
  case LibFunc_cos:
1281
106k
  case LibFunc_cosf:
1282
106k
  case LibFunc_cosh:
1283
106k
  case LibFunc_cosh_finite:
1284
106k
  case LibFunc_coshf:
1285
106k
  case LibFunc_coshf_finite:
1286
106k
  case LibFunc_coshl:
1287
106k
  case LibFunc_coshl_finite:
1288
106k
  case LibFunc_cosl:
1289
106k
  case LibFunc_exp10:
1290
106k
  case LibFunc_exp10_finite:
1291
106k
  case LibFunc_exp10f:
1292
106k
  case LibFunc_exp10f_finite:
1293
106k
  case LibFunc_exp10l:
1294
106k
  case LibFunc_exp10l_finite:
1295
106k
  case LibFunc_exp2:
1296
106k
  case LibFunc_exp2_finite:
1297
106k
  case LibFunc_exp2f:
1298
106k
  case LibFunc_exp2f_finite:
1299
106k
  case LibFunc_exp2l:
1300
106k
  case LibFunc_exp2l_finite:
1301
106k
  case LibFunc_exp:
1302
106k
  case LibFunc_exp_finite:
1303
106k
  case LibFunc_expf:
1304
106k
  case LibFunc_expf_finite:
1305
106k
  case LibFunc_expl:
1306
106k
  case LibFunc_expl_finite:
1307
106k
  case LibFunc_expm1:
1308
106k
  case LibFunc_expm1f:
1309
106k
  case LibFunc_expm1l:
1310
106k
  case LibFunc_fabs:
1311
106k
  case LibFunc_fabsf:
1312
106k
  case LibFunc_fabsl:
1313
106k
  case LibFunc_floor:
1314
106k
  case LibFunc_floorf:
1315
106k
  case LibFunc_floorl:
1316
106k
  case LibFunc_log10:
1317
106k
  case LibFunc_log10_finite:
1318
106k
  case LibFunc_log10f:
1319
106k
  case LibFunc_log10f_finite:
1320
106k
  case LibFunc_log10l:
1321
106k
  case LibFunc_log10l_finite:
1322
106k
  case LibFunc_log1p:
1323
106k
  case LibFunc_log1pf:
1324
106k
  case LibFunc_log1pl:
1325
106k
  case LibFunc_log2:
1326
106k
  case LibFunc_log2_finite:
1327
106k
  case LibFunc_log2f:
1328
106k
  case LibFunc_log2f_finite:
1329
106k
  case LibFunc_log2l:
1330
106k
  case LibFunc_log2l_finite:
1331
106k
  case LibFunc_log:
1332
106k
  case LibFunc_log_finite:
1333
106k
  case LibFunc_logb:
1334
106k
  case LibFunc_logbf:
1335
106k
  case LibFunc_logbl:
1336
106k
  case LibFunc_logf:
1337
106k
  case LibFunc_logf_finite:
1338
106k
  case LibFunc_logl:
1339
106k
  case LibFunc_logl_finite:
1340
106k
  case LibFunc_nearbyint:
1341
106k
  case LibFunc_nearbyintf:
1342
106k
  case LibFunc_nearbyintl:
1343
106k
  case LibFunc_rint:
1344
106k
  case LibFunc_rintf:
1345
106k
  case LibFunc_rintl:
1346
106k
  case LibFunc_round:
1347
106k
  case LibFunc_roundf:
1348
106k
  case LibFunc_roundl:
1349
106k
  case LibFunc_sin:
1350
106k
  case LibFunc_sinf:
1351
106k
  case LibFunc_sinh:
1352
106k
  case LibFunc_sinh_finite:
1353
106k
  case LibFunc_sinhf:
1354
106k
  case LibFunc_sinhf_finite:
1355
106k
  case LibFunc_sinhl:
1356
106k
  case LibFunc_sinhl_finite:
1357
106k
  case LibFunc_sinl:
1358
106k
  case LibFunc_sqrt:
1359
106k
  case LibFunc_sqrt_finite:
1360
106k
  case LibFunc_sqrtf:
1361
106k
  case LibFunc_sqrtf_finite:
1362
106k
  case LibFunc_sqrtl:
1363
106k
  case LibFunc_sqrtl_finite:
1364
106k
  case LibFunc_tan:
1365
106k
  case LibFunc_tanf:
1366
106k
  case LibFunc_tanh:
1367
106k
  case LibFunc_tanhf:
1368
106k
  case LibFunc_tanhl:
1369
106k
  case LibFunc_tanl:
1370
106k
  case LibFunc_trunc:
1371
106k
  case LibFunc_truncf:
1372
106k
  case LibFunc_truncl:
1373
106k
    return (NumParams == 1 && 
FTy.getReturnType()->isFloatingPointTy()106k
&&
1374
106k
            
FTy.getReturnType() == FTy.getParamType(0)106k
);
1375
106k
1376
106k
  case LibFunc_atan2:
1377
12.0k
  case LibFunc_atan2_finite:
1378
12.0k
  case LibFunc_atan2f:
1379
12.0k
  case LibFunc_atan2f_finite:
1380
12.0k
  case LibFunc_atan2l:
1381
12.0k
  case LibFunc_atan2l_finite:
1382
12.0k
  case LibFunc_fmin:
1383
12.0k
  case LibFunc_fminf:
1384
12.0k
  case LibFunc_fminl:
1385
12.0k
  case LibFunc_fmax:
1386
12.0k
  case LibFunc_fmaxf:
1387
12.0k
  case LibFunc_fmaxl:
1388
12.0k
  case LibFunc_fmod:
1389
12.0k
  case LibFunc_fmodf:
1390
12.0k
  case LibFunc_fmodl:
1391
12.0k
  case LibFunc_copysign:
1392
12.0k
  case LibFunc_copysignf:
1393
12.0k
  case LibFunc_copysignl:
1394
12.0k
  case LibFunc_pow:
1395
12.0k
  case LibFunc_pow_finite:
1396
12.0k
  case LibFunc_powf:
1397
12.0k
  case LibFunc_powf_finite:
1398
12.0k
  case LibFunc_powl:
1399
12.0k
  case LibFunc_powl_finite:
1400
12.0k
    return (NumParams == 2 && 
FTy.getReturnType()->isFloatingPointTy()11.9k
&&
1401
12.0k
            
FTy.getReturnType() == FTy.getParamType(0)11.9k
&&
1402
12.0k
            
FTy.getReturnType() == FTy.getParamType(1)11.9k
);
1403
12.0k
1404
12.0k
  case LibFunc_ldexp:
1405
2.09k
  case LibFunc_ldexpf:
1406
2.09k
  case LibFunc_ldexpl:
1407
2.09k
    return (NumParams == 2 && 
FTy.getReturnType()->isFloatingPointTy()2.08k
&&
1408
2.09k
            
FTy.getReturnType() == FTy.getParamType(0)2.08k
&&
1409
2.09k
            
FTy.getParamType(1)->isIntegerTy(32)2.08k
);
1410
2.09k
1411
2.09k
  case LibFunc_ffs:
1412
401
  case LibFunc_ffsl:
1413
401
  case LibFunc_ffsll:
1414
401
  case LibFunc_fls:
1415
401
  case LibFunc_flsl:
1416
401
  case LibFunc_flsll:
1417
401
    return (NumParams == 1 && 
FTy.getReturnType()->isIntegerTy(32)388
&&
1418
401
            
FTy.getParamType(0)->isIntegerTy()388
);
1419
401
1420
55.8k
  case LibFunc_isdigit:
1421
55.8k
  case LibFunc_isascii:
1422
55.8k
  case LibFunc_toascii:
1423
55.8k
  case LibFunc_putchar:
1424
55.8k
  case LibFunc_putchar_unlocked:
1425
55.8k
    return (NumParams == 1 && 
FTy.getReturnType()->isIntegerTy(32)55.7k
&&
1426
55.8k
            
FTy.getReturnType() == FTy.getParamType(0)55.7k
);
1427
55.8k
1428
55.8k
  case LibFunc_abs:
1429
245
  case LibFunc_labs:
1430
245
  case LibFunc_llabs:
1431
245
    return (NumParams == 1 && 
FTy.getReturnType()->isIntegerTy()236
&&
1432
245
            
FTy.getReturnType() == FTy.getParamType(0)236
);
1433
245
1434
21.4k
  case LibFunc_cxa_atexit:
1435
21.4k
    return (NumParams == 3 && 
FTy.getReturnType()->isIntegerTy()21.4k
&&
1436
21.4k
            
FTy.getParamType(0)->isPointerTy()21.4k
&&
1437
21.4k
            
FTy.getParamType(1)->isPointerTy()21.4k
&&
1438
21.4k
            
FTy.getParamType(2)->isPointerTy()21.4k
);
1439
245
1440
245
  case LibFunc_sinpi:
1441
92
  case LibFunc_cospi:
1442
92
    return (NumParams == 1 && 
FTy.getReturnType()->isDoubleTy()88
&&
1443
92
            
FTy.getReturnType() == FTy.getParamType(0)88
);
1444
92
1445
92
  case LibFunc_sinpif:
1446
70
  case LibFunc_cospif:
1447
70
    return (NumParams == 1 && 
FTy.getReturnType()->isFloatTy()66
&&
1448
70
            
FTy.getReturnType() == FTy.getParamType(0)66
);
1449
70
1450
70
  case LibFunc_strnlen:
1451
28
    return (NumParams == 2 && 
FTy.getReturnType() == FTy.getParamType(1)25
&&
1452
28
            
FTy.getParamType(0) == PCharTy25
&&
1453
28
            
FTy.getParamType(1) == SizeTTy25
);
1454
70
1455
33.4k
  case LibFunc_posix_memalign:
1456
33.4k
    return (NumParams == 3 && 
FTy.getReturnType()->isIntegerTy(32)33.4k
&&
1457
33.4k
            
FTy.getParamType(0)->isPointerTy()33.4k
&&
1458
33.4k
            
FTy.getParamType(1) == SizeTTy33.4k
&&
FTy.getParamType(2) == SizeTTy33.4k
);
1459
70
1460
512
  case LibFunc_wcslen:
1461
512
    return (NumParams == 1 && 
FTy.getParamType(0)->isPointerTy()509
&&
1462
512
            
FTy.getReturnType()->isIntegerTy()509
);
1463
70
1464
131
  case LibFunc_cabs:
1465
131
  case LibFunc_cabsf:
1466
131
  case LibFunc_cabsl: {
1467
131
    Type* RetTy = FTy.getReturnType();
1468
131
    if (!RetTy->isFloatingPointTy())
1469
3
      return false;
1470
128
1471
128
    // NOTE: These prototypes are target specific and currently support
1472
128
    // "complex" passed as an array or discrete real & imaginary parameters.
1473
128
    // Add other calling conventions to enable libcall optimizations.
1474
128
    if (NumParams == 1)
1475
110
      return (FTy.getParamType(0)->isArrayTy() &&
1476
110
              FTy.getParamType(0)->getArrayNumElements() == 2 &&
1477
110
              FTy.getParamType(0)->getArrayElementType() == RetTy);
1478
18
    else if (NumParams == 2)
1479
18
      return (FTy.getParamType(0) == RetTy && FTy.getParamType(1) == RetTy);
1480
0
    else
1481
0
      return false;
1482
0
  }
1483
0
  case LibFunc::NumLibFuncs:
1484
0
    break;
1485
0
  }
1486
0
1487
0
  llvm_unreachable("Invalid libfunc");
1488
0
}
1489
1490
bool TargetLibraryInfoImpl::getLibFunc(const Function &FDecl,
1491
24.0M
                                       LibFunc &F) const {
1492
24.0M
  // Intrinsics don't overlap w/libcalls; if our module has a large number of
1493
24.0M
  // intrinsics, this ends up being an interesting compile time win since we
1494
24.0M
  // avoid string normalization and comparison. 
1495
24.0M
  if (FDecl.isIntrinsic()) 
return false4.02M
;
1496
19.9M
  
1497
19.9M
  const DataLayout *DL =
1498
18.4E
      FDecl.getParent() ? 
&FDecl.getParent()->getDataLayout()19.9M
: nullptr;
1499
19.9M
  return getLibFunc(FDecl.getName(), F) &&
1500
19.9M
         
isValidProtoForLibFunc(*FDecl.getFunctionType(), F, DL)6.27M
;
1501
19.9M
}
1502
1503
8.94k
void TargetLibraryInfoImpl::disableAllFunctions() {
1504
8.94k
  memset(AvailableArray, 0, sizeof(AvailableArray));
1505
8.94k
}
1506
1507
3.34k
static bool compareByScalarFnName(const VecDesc &LHS, const VecDesc &RHS) {
1508
3.34k
  return LHS.ScalarFnName < RHS.ScalarFnName;
1509
3.34k
}
1510
1511
3.48k
static bool compareByVectorFnName(const VecDesc &LHS, const VecDesc &RHS) {
1512
3.48k
  return LHS.VectorFnName < RHS.VectorFnName;
1513
3.48k
}
1514
1515
4.38k
static bool compareWithScalarFnName(const VecDesc &LHS, StringRef S) {
1516
4.38k
  return LHS.ScalarFnName < S;
1517
4.38k
}
1518
1519
0
static bool compareWithVectorFnName(const VecDesc &LHS, StringRef S) {
1520
0
  return LHS.VectorFnName < S;
1521
0
}
1522
1523
7
void TargetLibraryInfoImpl::addVectorizableFunctions(ArrayRef<VecDesc> Fns) {
1524
7
  VectorDescs.insert(VectorDescs.end(), Fns.begin(), Fns.end());
1525
7
  llvm::sort(VectorDescs, compareByScalarFnName);
1526
7
1527
7
  ScalarDescs.insert(ScalarDescs.end(), Fns.begin(), Fns.end());
1528
7
  llvm::sort(ScalarDescs, compareByVectorFnName);
1529
7
}
1530
1531
void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib(
1532
98.3k
    enum VectorLibrary VecLib) {
1533
98.3k
  switch (VecLib) {
1534
98.3k
  case Accelerate: {
1535
1
    const VecDesc VecFuncs[] = {
1536
1
    #define TLI_DEFINE_ACCELERATE_VECFUNCS
1537
1
    #include "llvm/Analysis/VecFuncs.def"
1538
1
    };
1539
1
    addVectorizableFunctions(VecFuncs);
1540
1
    break;
1541
98.3k
  }
1542
98.3k
  case MASSV: {
1543
4
    const VecDesc VecFuncs[] = {
1544
4
    #define TLI_DEFINE_MASSV_VECFUNCS
1545
4
    #include "llvm/Analysis/VecFuncs.def"
1546
4
    };
1547
4
    addVectorizableFunctions(VecFuncs);
1548
4
    break;
1549
98.3k
  }
1550
98.3k
  case SVML: {
1551
2
    const VecDesc VecFuncs[] = {
1552
2
    #define TLI_DEFINE_SVML_VECFUNCS
1553
2
    #include "llvm/Analysis/VecFuncs.def"
1554
2
    };
1555
2
    addVectorizableFunctions(VecFuncs);
1556
2
    break;
1557
98.3k
  }
1558
98.3k
  case NoLibrary:
1559
98.3k
    break;
1560
98.3k
  }
1561
98.3k
}
1562
1563
31.8k
bool TargetLibraryInfoImpl::isFunctionVectorizable(StringRef funcName) const {
1564
31.8k
  funcName = sanitizeFunctionName(funcName);
1565
31.8k
  if (funcName.empty())
1566
0
    return false;
1567
31.8k
1568
31.8k
  std::vector<VecDesc>::const_iterator I =
1569
31.8k
      llvm::lower_bound(VectorDescs, funcName, compareWithScalarFnName);
1570
31.8k
  return I != VectorDescs.end() && 
StringRef(I->ScalarFnName) == funcName130
;
1571
31.8k
}
1572
1573
StringRef TargetLibraryInfoImpl::getVectorizedFunction(StringRef F,
1574
1.71k
                                                       unsigned VF) const {
1575
1.71k
  F = sanitizeFunctionName(F);
1576
1.71k
  if (F.empty())
1577
0
    return F;
1578
1.71k
  std::vector<VecDesc>::const_iterator I =
1579
1.71k
      llvm::lower_bound(VectorDescs, F, compareWithScalarFnName);
1580
1.94k
  while (I != VectorDescs.end() && 
StringRef(I->ScalarFnName) == F852
) {
1581
744
    if (I->VectorizationFactor == VF)
1582
512
      return I->VectorFnName;
1583
232
    ++I;
1584
232
  }
1585
1.71k
  
return StringRef()1.19k
;
1586
1.71k
}
1587
1588
StringRef TargetLibraryInfoImpl::getScalarizedFunction(StringRef F,
1589
0
                                                       unsigned &VF) const {
1590
0
  F = sanitizeFunctionName(F);
1591
0
  if (F.empty())
1592
0
    return F;
1593
0
1594
0
  std::vector<VecDesc>::const_iterator I =
1595
0
      llvm::lower_bound(ScalarDescs, F, compareWithVectorFnName);
1596
0
  if (I == VectorDescs.end() || StringRef(I->VectorFnName) != F)
1597
0
    return StringRef();
1598
0
  VF = I->VectorizationFactor;
1599
0
  return I->ScalarFnName;
1600
0
}
1601
1602
TargetLibraryInfo TargetLibraryAnalysis::run(Module &M,
1603
437
                                             ModuleAnalysisManager &) {
1604
437
  if (PresetInfoImpl)
1605
90
    return TargetLibraryInfo(*PresetInfoImpl);
1606
347
1607
347
  return TargetLibraryInfo(lookupInfoImpl(Triple(M.getTargetTriple())));
1608
347
}
1609
1610
TargetLibraryInfo TargetLibraryAnalysis::run(Function &F,
1611
7.70k
                                             FunctionAnalysisManager &) {
1612
7.70k
  if (PresetInfoImpl)
1613
3.63k
    return TargetLibraryInfo(*PresetInfoImpl);
1614
4.07k
1615
4.07k
  return TargetLibraryInfo(
1616
4.07k
      lookupInfoImpl(Triple(F.getParent()->getTargetTriple())));
1617
4.07k
}
1618
1619
4.42k
TargetLibraryInfoImpl &TargetLibraryAnalysis::lookupInfoImpl(const Triple &T) {
1620
4.42k
  std::unique_ptr<TargetLibraryInfoImpl> &Impl =
1621
4.42k
      Impls[T.normalize()];
1622
4.42k
  if (!Impl)
1623
1.29k
    Impl.reset(new TargetLibraryInfoImpl(T));
1624
4.42k
1625
4.42k
  return *Impl;
1626
4.42k
}
1627
1628
73
unsigned TargetLibraryInfoImpl::getWCharSize(const Module &M) const {
1629
73
  if (auto *ShortWChar = cast_or_null<ConstantAsMetadata>(
1630
72
      M.getModuleFlag("wchar_size")))
1631
72
    return cast<ConstantInt>(ShortWChar->getValue())->getZExtValue();
1632
1
  return 0;
1633
1
}
1634
1635
TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass()
1636
29.4k
    : ImmutablePass(ID), TLIImpl(), TLI(TLIImpl) {
1637
29.4k
  initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
1638
29.4k
}
1639
1640
TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(const Triple &T)
1641
0
    : ImmutablePass(ID), TLIImpl(T), TLI(TLIImpl) {
1642
0
  initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
1643
0
}
1644
1645
TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(
1646
    const TargetLibraryInfoImpl &TLIImpl)
1647
90.3k
    : ImmutablePass(ID), TLIImpl(TLIImpl), TLI(this->TLIImpl) {
1648
90.3k
  initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
1649
90.3k
}
1650
1651
AnalysisKey TargetLibraryAnalysis::Key;
1652
1653
// Register the basic pass.
1654
INITIALIZE_PASS(TargetLibraryInfoWrapperPass, "targetlibinfo",
1655
                "Target Library Information", false, true)
1656
char TargetLibraryInfoWrapperPass::ID = 0;
1657
1658
0
void TargetLibraryInfoWrapperPass::anchor() {}