1 //===-- TargetLibraryInfo.cpp - Runtime library information ----------------==//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file implements the TargetLibraryInfo class.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/Analysis/TargetLibraryInfo.h"
14 #include "llvm/ADT/DenseMap.h"
15 #include "llvm/ADT/SmallString.h"
16 #include "llvm/IR/Constants.h"
17 #include "llvm/IR/Module.h"
18 #include "llvm/InitializePasses.h"
19 #include "llvm/Support/CommandLine.h"
20 #include "llvm/TargetParser/Triple.h"
23 static cl::opt
<TargetLibraryInfoImpl::VectorLibrary
> ClVectorLibrary(
24 "vector-library", cl::Hidden
, cl::desc("Vector functions library"),
25 cl::init(TargetLibraryInfoImpl::NoLibrary
),
26 cl::values(clEnumValN(TargetLibraryInfoImpl::NoLibrary
, "none",
27 "No vector functions library"),
28 clEnumValN(TargetLibraryInfoImpl::Accelerate
, "Accelerate",
29 "Accelerate framework"),
30 clEnumValN(TargetLibraryInfoImpl::DarwinLibSystemM
,
31 "Darwin_libsystem_m", "Darwin libsystem_m"),
32 clEnumValN(TargetLibraryInfoImpl::LIBMVEC_X86
, "LIBMVEC-X86",
33 "GLIBC Vector Math library"),
34 clEnumValN(TargetLibraryInfoImpl::MASSV
, "MASSV",
35 "IBM MASS vector library"),
36 clEnumValN(TargetLibraryInfoImpl::SVML
, "SVML",
37 "Intel SVML library"),
38 clEnumValN(TargetLibraryInfoImpl::SLEEFGNUABI
, "sleefgnuabi",
39 "SIMD Library for Evaluating Elementary Functions"),
40 clEnumValN(TargetLibraryInfoImpl::ArmPL
, "ArmPL",
41 "Arm Performance Libraries"),
42 clEnumValN(TargetLibraryInfoImpl::AMDLIBM
, "AMDLIBM",
43 "AMD vector math library")));
45 StringLiteral
const TargetLibraryInfoImpl::StandardNames
[LibFunc::NumLibFuncs
] =
47 #define TLI_DEFINE_STRING
48 #include "llvm/Analysis/TargetLibraryInfo.def"
51 std::string
VecDesc::getVectorFunctionABIVariantString() const {
52 assert(!VectorFnName
.empty() && "Vector function name must not be empty.");
53 SmallString
<256> Buffer
;
54 llvm::raw_svector_ostream
Out(Buffer
);
55 Out
<< VABIPrefix
<< "_" << ScalarFnName
<< "(" << VectorFnName
<< ")";
56 return std::string(Out
.str());
59 // Recognized types of library function arguments and return types.
60 enum FuncArgTypeID
: char {
61 Void
= 0, // Must be zero.
62 Bool
, // 8 bits on all targets
66 IntPlus
, // Int or bigger.
67 Long
, // Either 32 or 64 bits.
68 IntX
, // Any integer type.
70 LLong
, // 64 bits on all targets.
72 SSizeT
, // POSIX ssize_t.
75 LDbl
, // Any floating type (TODO: tighten this up).
76 Floating
, // Any floating type.
77 Ptr
, // Any pointer type.
78 Struct
, // Any struct type.
79 Ellip
, // The ellipsis (...).
80 Same
, // Same argument type as the previous one.
83 typedef std::array
<FuncArgTypeID
, 8> FuncProtoTy
;
85 static const FuncProtoTy Signatures
[] = {
86 #define TLI_DEFINE_SIG
87 #include "llvm/Analysis/TargetLibraryInfo.def"
90 static_assert(sizeof Signatures
/ sizeof *Signatures
== LibFunc::NumLibFuncs
,
91 "Missing library function signatures");
93 static bool hasSinCosPiStret(const Triple
&T
) {
94 // Only Darwin variants have _stret versions of combined trig functions.
98 // The ABI is rather complicated on x86, so don't do anything special there.
99 if (T
.getArch() == Triple::x86
)
102 if (T
.isMacOSX() && T
.isMacOSXVersionLT(10, 9))
105 if (T
.isiOS() && T
.isOSVersionLT(7, 0))
111 static bool hasBcmp(const Triple
&TT
) {
112 // Posix removed support from bcmp() in 2001, but the glibc and several
113 // implementations of the libc still have it.
115 return TT
.isGNUEnvironment() || TT
.isMusl();
116 // Both NetBSD and OpenBSD are planning to remove the function. Windows does
118 return TT
.isOSFreeBSD() || TT
.isOSSolaris();
121 static bool isCallingConvCCompatible(CallingConv::ID CC
, StringRef TT
,
122 FunctionType
*FuncTy
) {
126 case llvm::CallingConv::C
:
128 case llvm::CallingConv::ARM_APCS
:
129 case llvm::CallingConv::ARM_AAPCS
:
130 case llvm::CallingConv::ARM_AAPCS_VFP
: {
132 // The iOS ABI diverges from the standard in some cases, so for now don't
133 // try to simplify those calls.
134 if (Triple(TT
).isiOS())
137 if (!FuncTy
->getReturnType()->isPointerTy() &&
138 !FuncTy
->getReturnType()->isIntegerTy() &&
139 !FuncTy
->getReturnType()->isVoidTy())
142 for (auto *Param
: FuncTy
->params()) {
143 if (!Param
->isPointerTy() && !Param
->isIntegerTy())
152 bool TargetLibraryInfoImpl::isCallingConvCCompatible(CallBase
*CI
) {
153 return ::isCallingConvCCompatible(CI
->getCallingConv(),
154 CI
->getModule()->getTargetTriple(),
155 CI
->getFunctionType());
158 bool TargetLibraryInfoImpl::isCallingConvCCompatible(Function
*F
) {
159 return ::isCallingConvCCompatible(F
->getCallingConv(),
160 F
->getParent()->getTargetTriple(),
161 F
->getFunctionType());
164 static void initializeBase(TargetLibraryInfoImpl
&TLI
, const Triple
&T
) {
165 bool ShouldExtI32Param
, ShouldExtI32Return
;
166 bool ShouldSignExtI32Param
, ShouldSignExtI32Return
;
167 TargetLibraryInfo::initExtensionsForTriple(
168 ShouldExtI32Param
, ShouldExtI32Return
, ShouldSignExtI32Param
,
169 ShouldSignExtI32Return
, T
);
170 TLI
.setShouldExtI32Param(ShouldExtI32Param
);
171 TLI
.setShouldExtI32Return(ShouldExtI32Return
);
172 TLI
.setShouldSignExtI32Param(ShouldSignExtI32Param
);
173 TLI
.setShouldSignExtI32Return(ShouldSignExtI32Return
);
175 // Let's assume by default that the size of int is 32 bits, unless the target
176 // is a 16-bit architecture because then it most likely is 16 bits. If that
177 // isn't true for a target those defaults should be overridden below.
178 TLI
.setIntSize(T
.isArch16Bit() ? 16 : 32);
181 /// Initialize the set of available library functions based on the specified
182 /// target triple. This should be carefully written so that a missing target
183 /// triple gets a sane set of defaults.
184 static void initializeLibCalls(TargetLibraryInfoImpl
&TLI
, const Triple
&T
,
185 ArrayRef
<StringLiteral
> StandardNames
) {
186 // Set IO unlocked variants as unavailable
187 // Set them as available per system below
188 TLI
.setUnavailable(LibFunc_getc_unlocked
);
189 TLI
.setUnavailable(LibFunc_getchar_unlocked
);
190 TLI
.setUnavailable(LibFunc_putc_unlocked
);
191 TLI
.setUnavailable(LibFunc_putchar_unlocked
);
192 TLI
.setUnavailable(LibFunc_fputc_unlocked
);
193 TLI
.setUnavailable(LibFunc_fgetc_unlocked
);
194 TLI
.setUnavailable(LibFunc_fread_unlocked
);
195 TLI
.setUnavailable(LibFunc_fwrite_unlocked
);
196 TLI
.setUnavailable(LibFunc_fputs_unlocked
);
197 TLI
.setUnavailable(LibFunc_fgets_unlocked
);
199 // There is really no runtime library on AMDGPU, apart from
200 // __kmpc_alloc/free_shared.
202 TLI
.disableAllFunctions();
203 TLI
.setAvailable(llvm::LibFunc___kmpc_alloc_shared
);
204 TLI
.setAvailable(llvm::LibFunc___kmpc_free_shared
);
208 // memset_pattern{4,8,16} is only available on iOS 3.0 and Mac OS X 10.5 and
209 // later. All versions of watchOS support it.
211 // available IO unlocked variants on Mac OS X
212 TLI
.setAvailable(LibFunc_getc_unlocked
);
213 TLI
.setAvailable(LibFunc_getchar_unlocked
);
214 TLI
.setAvailable(LibFunc_putc_unlocked
);
215 TLI
.setAvailable(LibFunc_putchar_unlocked
);
216 TLI
.setUnavailable(LibFunc_memrchr
);
218 if (T
.isMacOSXVersionLT(10, 5)) {
219 TLI
.setUnavailable(LibFunc_memset_pattern4
);
220 TLI
.setUnavailable(LibFunc_memset_pattern8
);
221 TLI
.setUnavailable(LibFunc_memset_pattern16
);
223 } else if (T
.isiOS()) {
224 if (T
.isOSVersionLT(3, 0)) {
225 TLI
.setUnavailable(LibFunc_memset_pattern4
);
226 TLI
.setUnavailable(LibFunc_memset_pattern8
);
227 TLI
.setUnavailable(LibFunc_memset_pattern16
);
229 } else if (!T
.isWatchOS()) {
230 TLI
.setUnavailable(LibFunc_memset_pattern4
);
231 TLI
.setUnavailable(LibFunc_memset_pattern8
);
232 TLI
.setUnavailable(LibFunc_memset_pattern16
);
235 if (!hasSinCosPiStret(T
)) {
236 TLI
.setUnavailable(LibFunc_sinpi
);
237 TLI
.setUnavailable(LibFunc_sinpif
);
238 TLI
.setUnavailable(LibFunc_cospi
);
239 TLI
.setUnavailable(LibFunc_cospif
);
240 TLI
.setUnavailable(LibFunc_sincospi_stret
);
241 TLI
.setUnavailable(LibFunc_sincospif_stret
);
245 TLI
.setUnavailable(LibFunc_bcmp
);
247 if (T
.isMacOSX() && T
.getArch() == Triple::x86
&&
248 !T
.isMacOSXVersionLT(10, 7)) {
249 // x86-32 OSX has a scheme where fwrite and fputs (and some other functions
250 // we don't care about) have two versions; on recent OSX, the one we want
251 // has a $UNIX2003 suffix. The two implementations are identical except
252 // for the return value in some edge cases. However, we don't want to
253 // generate code that depends on the old symbols.
254 TLI
.setAvailableWithName(LibFunc_fwrite
, "fwrite$UNIX2003");
255 TLI
.setAvailableWithName(LibFunc_fputs
, "fputs$UNIX2003");
258 // iprintf and friends are only available on XCore, TCE, and Emscripten.
259 if (T
.getArch() != Triple::xcore
&& T
.getArch() != Triple::tce
&&
260 T
.getOS() != Triple::Emscripten
) {
261 TLI
.setUnavailable(LibFunc_iprintf
);
262 TLI
.setUnavailable(LibFunc_siprintf
);
263 TLI
.setUnavailable(LibFunc_fiprintf
);
266 // __small_printf and friends are only available on Emscripten.
267 if (T
.getOS() != Triple::Emscripten
) {
268 TLI
.setUnavailable(LibFunc_small_printf
);
269 TLI
.setUnavailable(LibFunc_small_sprintf
);
270 TLI
.setUnavailable(LibFunc_small_fprintf
);
273 if (T
.isOSWindows() && !T
.isOSCygMing()) {
274 // XXX: The earliest documentation available at the moment is for VS2015/VC19:
275 // https://docs.microsoft.com/en-us/cpp/c-runtime-library/floating-point-support?view=vs-2015
276 // XXX: In order to use an MSVCRT older than VC19,
277 // the specific library version must be explicit in the target triple,
278 // e.g., x86_64-pc-windows-msvc18.
279 bool hasPartialC99
= true;
280 if (T
.isKnownWindowsMSVCEnvironment()) {
281 VersionTuple Version
= T
.getEnvironmentVersion();
282 hasPartialC99
= (Version
.getMajor() == 0 || Version
.getMajor() >= 19);
285 // Latest targets support C89 math functions, in part.
286 bool isARM
= (T
.getArch() == Triple::aarch64
||
287 T
.getArch() == Triple::arm
);
288 bool hasPartialFloat
= (isARM
||
289 T
.getArch() == Triple::x86_64
);
291 // Win32 does not support float C89 math functions, in general.
292 if (!hasPartialFloat
) {
293 TLI
.setUnavailable(LibFunc_acosf
);
294 TLI
.setUnavailable(LibFunc_asinf
);
295 TLI
.setUnavailable(LibFunc_atan2f
);
296 TLI
.setUnavailable(LibFunc_atanf
);
297 TLI
.setUnavailable(LibFunc_ceilf
);
298 TLI
.setUnavailable(LibFunc_cosf
);
299 TLI
.setUnavailable(LibFunc_coshf
);
300 TLI
.setUnavailable(LibFunc_expf
);
301 TLI
.setUnavailable(LibFunc_floorf
);
302 TLI
.setUnavailable(LibFunc_fmodf
);
303 TLI
.setUnavailable(LibFunc_hypotf
);
304 TLI
.setUnavailable(LibFunc_log10f
);
305 TLI
.setUnavailable(LibFunc_logf
);
306 TLI
.setUnavailable(LibFunc_modff
);
307 TLI
.setUnavailable(LibFunc_powf
);
308 TLI
.setUnavailable(LibFunc_remainderf
);
309 TLI
.setUnavailable(LibFunc_remquof
);
310 TLI
.setUnavailable(LibFunc_fdimf
);
311 TLI
.setUnavailable(LibFunc_sinf
);
312 TLI
.setUnavailable(LibFunc_sinhf
);
313 TLI
.setUnavailable(LibFunc_sqrtf
);
314 TLI
.setUnavailable(LibFunc_tanf
);
315 TLI
.setUnavailable(LibFunc_tanhf
);
318 TLI
.setUnavailable(LibFunc_fabsf
);
319 TLI
.setUnavailable(LibFunc_frexpf
);
320 TLI
.setUnavailable(LibFunc_ldexpf
);
322 // Win32 does not support long double C89 math functions.
323 TLI
.setUnavailable(LibFunc_acosl
);
324 TLI
.setUnavailable(LibFunc_asinl
);
325 TLI
.setUnavailable(LibFunc_atan2l
);
326 TLI
.setUnavailable(LibFunc_atanl
);
327 TLI
.setUnavailable(LibFunc_ceill
);
328 TLI
.setUnavailable(LibFunc_cosl
);
329 TLI
.setUnavailable(LibFunc_coshl
);
330 TLI
.setUnavailable(LibFunc_expl
);
331 TLI
.setUnavailable(LibFunc_fabsl
);
332 TLI
.setUnavailable(LibFunc_floorl
);
333 TLI
.setUnavailable(LibFunc_fmodl
);
334 TLI
.setUnavailable(LibFunc_frexpl
);
335 TLI
.setUnavailable(LibFunc_hypotl
);
336 TLI
.setUnavailable(LibFunc_ldexpl
);
337 TLI
.setUnavailable(LibFunc_log10l
);
338 TLI
.setUnavailable(LibFunc_logl
);
339 TLI
.setUnavailable(LibFunc_modfl
);
340 TLI
.setUnavailable(LibFunc_powl
);
341 TLI
.setUnavailable(LibFunc_remainderl
);
342 TLI
.setUnavailable(LibFunc_remquol
);
343 TLI
.setUnavailable(LibFunc_fdiml
);
344 TLI
.setUnavailable(LibFunc_sinl
);
345 TLI
.setUnavailable(LibFunc_sinhl
);
346 TLI
.setUnavailable(LibFunc_sqrtl
);
347 TLI
.setUnavailable(LibFunc_tanl
);
348 TLI
.setUnavailable(LibFunc_tanhl
);
350 // Win32 does not fully support C99 math functions.
351 if (!hasPartialC99
) {
352 TLI
.setUnavailable(LibFunc_acosh
);
353 TLI
.setUnavailable(LibFunc_acoshf
);
354 TLI
.setUnavailable(LibFunc_asinh
);
355 TLI
.setUnavailable(LibFunc_asinhf
);
356 TLI
.setUnavailable(LibFunc_atanh
);
357 TLI
.setUnavailable(LibFunc_atanhf
);
358 TLI
.setAvailableWithName(LibFunc_cabs
, "_cabs");
359 TLI
.setUnavailable(LibFunc_cabsf
);
360 TLI
.setUnavailable(LibFunc_cbrt
);
361 TLI
.setUnavailable(LibFunc_cbrtf
);
362 TLI
.setAvailableWithName(LibFunc_copysign
, "_copysign");
363 TLI
.setAvailableWithName(LibFunc_copysignf
, "_copysignf");
364 TLI
.setUnavailable(LibFunc_exp2
);
365 TLI
.setUnavailable(LibFunc_exp2f
);
366 TLI
.setUnavailable(LibFunc_expm1
);
367 TLI
.setUnavailable(LibFunc_expm1f
);
368 TLI
.setUnavailable(LibFunc_fmax
);
369 TLI
.setUnavailable(LibFunc_fmaxf
);
370 TLI
.setUnavailable(LibFunc_fmin
);
371 TLI
.setUnavailable(LibFunc_fminf
);
372 TLI
.setUnavailable(LibFunc_log1p
);
373 TLI
.setUnavailable(LibFunc_log1pf
);
374 TLI
.setUnavailable(LibFunc_log2
);
375 TLI
.setUnavailable(LibFunc_log2f
);
376 TLI
.setAvailableWithName(LibFunc_logb
, "_logb");
377 TLI
.setUnavailable(LibFunc_ilogb
);
378 TLI
.setUnavailable(LibFunc_ilogbf
);
380 TLI
.setAvailableWithName(LibFunc_logbf
, "_logbf");
382 TLI
.setUnavailable(LibFunc_logbf
);
383 TLI
.setUnavailable(LibFunc_rint
);
384 TLI
.setUnavailable(LibFunc_rintf
);
385 TLI
.setUnavailable(LibFunc_round
);
386 TLI
.setUnavailable(LibFunc_roundf
);
387 TLI
.setUnavailable(LibFunc_scalbln
);
388 TLI
.setUnavailable(LibFunc_scalblnf
);
389 TLI
.setUnavailable(LibFunc_scalblnl
);
390 TLI
.setUnavailable(LibFunc_scalbn
);
391 TLI
.setUnavailable(LibFunc_scalbnf
);
392 TLI
.setUnavailable(LibFunc_scalbnl
);
393 TLI
.setUnavailable(LibFunc_trunc
);
394 TLI
.setUnavailable(LibFunc_truncf
);
397 // Win32 does not support long double C99 math functions.
398 TLI
.setUnavailable(LibFunc_acoshl
);
399 TLI
.setUnavailable(LibFunc_asinhl
);
400 TLI
.setUnavailable(LibFunc_atanhl
);
401 TLI
.setUnavailable(LibFunc_cabsl
);
402 TLI
.setUnavailable(LibFunc_cbrtl
);
403 TLI
.setUnavailable(LibFunc_copysignl
);
404 TLI
.setUnavailable(LibFunc_exp2l
);
405 TLI
.setUnavailable(LibFunc_expm1l
);
406 TLI
.setUnavailable(LibFunc_fmaxl
);
407 TLI
.setUnavailable(LibFunc_fminl
);
408 TLI
.setUnavailable(LibFunc_log1pl
);
409 TLI
.setUnavailable(LibFunc_log2l
);
410 TLI
.setUnavailable(LibFunc_logbl
);
411 TLI
.setUnavailable(LibFunc_ilogbl
);
412 TLI
.setUnavailable(LibFunc_nearbyintl
);
413 TLI
.setUnavailable(LibFunc_rintl
);
414 TLI
.setUnavailable(LibFunc_roundl
);
415 TLI
.setUnavailable(LibFunc_scalblnl
);
416 TLI
.setUnavailable(LibFunc_scalbnl
);
417 TLI
.setUnavailable(LibFunc_truncl
);
419 // Win32 does not support these functions, but
420 // they are generally available on POSIX-compliant systems.
421 TLI
.setUnavailable(LibFunc_access
);
422 TLI
.setUnavailable(LibFunc_chmod
);
423 TLI
.setUnavailable(LibFunc_closedir
);
424 TLI
.setUnavailable(LibFunc_fdopen
);
425 TLI
.setUnavailable(LibFunc_fileno
);
426 TLI
.setUnavailable(LibFunc_fseeko
);
427 TLI
.setUnavailable(LibFunc_fstat
);
428 TLI
.setUnavailable(LibFunc_ftello
);
429 TLI
.setUnavailable(LibFunc_gettimeofday
);
430 TLI
.setUnavailable(LibFunc_memccpy
);
431 TLI
.setUnavailable(LibFunc_mkdir
);
432 TLI
.setUnavailable(LibFunc_open
);
433 TLI
.setUnavailable(LibFunc_opendir
);
434 TLI
.setUnavailable(LibFunc_pclose
);
435 TLI
.setUnavailable(LibFunc_popen
);
436 TLI
.setUnavailable(LibFunc_read
);
437 TLI
.setUnavailable(LibFunc_rmdir
);
438 TLI
.setUnavailable(LibFunc_stat
);
439 TLI
.setUnavailable(LibFunc_strcasecmp
);
440 TLI
.setUnavailable(LibFunc_strncasecmp
);
441 TLI
.setUnavailable(LibFunc_unlink
);
442 TLI
.setUnavailable(LibFunc_utime
);
443 TLI
.setUnavailable(LibFunc_write
);
446 if (T
.isOSWindows() && !T
.isWindowsCygwinEnvironment()) {
447 // These functions aren't available in either MSVC or MinGW environments.
448 TLI
.setUnavailable(LibFunc_bcmp
);
449 TLI
.setUnavailable(LibFunc_bcopy
);
450 TLI
.setUnavailable(LibFunc_bzero
);
451 TLI
.setUnavailable(LibFunc_chown
);
452 TLI
.setUnavailable(LibFunc_ctermid
);
453 TLI
.setUnavailable(LibFunc_ffs
);
454 TLI
.setUnavailable(LibFunc_flockfile
);
455 TLI
.setUnavailable(LibFunc_fstatvfs
);
456 TLI
.setUnavailable(LibFunc_ftrylockfile
);
457 TLI
.setUnavailable(LibFunc_funlockfile
);
458 TLI
.setUnavailable(LibFunc_getitimer
);
459 TLI
.setUnavailable(LibFunc_getlogin_r
);
460 TLI
.setUnavailable(LibFunc_getpwnam
);
461 TLI
.setUnavailable(LibFunc_htonl
);
462 TLI
.setUnavailable(LibFunc_htons
);
463 TLI
.setUnavailable(LibFunc_lchown
);
464 TLI
.setUnavailable(LibFunc_lstat
);
465 TLI
.setUnavailable(LibFunc_memrchr
);
466 TLI
.setUnavailable(LibFunc_ntohl
);
467 TLI
.setUnavailable(LibFunc_ntohs
);
468 TLI
.setUnavailable(LibFunc_pread
);
469 TLI
.setUnavailable(LibFunc_pwrite
);
470 TLI
.setUnavailable(LibFunc_readlink
);
471 TLI
.setUnavailable(LibFunc_realpath
);
472 TLI
.setUnavailable(LibFunc_setitimer
);
473 TLI
.setUnavailable(LibFunc_statvfs
);
474 TLI
.setUnavailable(LibFunc_stpcpy
);
475 TLI
.setUnavailable(LibFunc_stpncpy
);
476 TLI
.setUnavailable(LibFunc_times
);
477 TLI
.setUnavailable(LibFunc_uname
);
478 TLI
.setUnavailable(LibFunc_unsetenv
);
479 TLI
.setUnavailable(LibFunc_utimes
);
481 // MinGW does have ldexpf, but it is a plain wrapper over regular ldexp.
482 // Therefore it's not beneficial to transform code to use it, i.e.
483 // just pretend that the function is not available.
484 TLI
.setUnavailable(LibFunc_ldexpf
);
487 // Pick just one set of new/delete variants.
488 if (T
.isOSMSVCRT()) {
489 // MSVC, doesn't have the Itanium new/delete.
490 TLI
.setUnavailable(LibFunc_ZdaPv
);
491 TLI
.setUnavailable(LibFunc_ZdaPvRKSt9nothrow_t
);
492 TLI
.setUnavailable(LibFunc_ZdaPvSt11align_val_t
);
493 TLI
.setUnavailable(LibFunc_ZdaPvSt11align_val_tRKSt9nothrow_t
);
494 TLI
.setUnavailable(LibFunc_ZdaPvj
);
495 TLI
.setUnavailable(LibFunc_ZdaPvjSt11align_val_t
);
496 TLI
.setUnavailable(LibFunc_ZdaPvm
);
497 TLI
.setUnavailable(LibFunc_ZdaPvmSt11align_val_t
);
498 TLI
.setUnavailable(LibFunc_ZdlPv
);
499 TLI
.setUnavailable(LibFunc_ZdlPvRKSt9nothrow_t
);
500 TLI
.setUnavailable(LibFunc_ZdlPvSt11align_val_t
);
501 TLI
.setUnavailable(LibFunc_ZdlPvSt11align_val_tRKSt9nothrow_t
);
502 TLI
.setUnavailable(LibFunc_ZdlPvj
);
503 TLI
.setUnavailable(LibFunc_ZdlPvjSt11align_val_t
);
504 TLI
.setUnavailable(LibFunc_ZdlPvm
);
505 TLI
.setUnavailable(LibFunc_ZdlPvmSt11align_val_t
);
506 TLI
.setUnavailable(LibFunc_Znaj
);
507 TLI
.setUnavailable(LibFunc_ZnajRKSt9nothrow_t
);
508 TLI
.setUnavailable(LibFunc_ZnajSt11align_val_t
);
509 TLI
.setUnavailable(LibFunc_ZnajSt11align_val_tRKSt9nothrow_t
);
510 TLI
.setUnavailable(LibFunc_Znam
);
511 TLI
.setUnavailable(LibFunc_ZnamRKSt9nothrow_t
);
512 TLI
.setUnavailable(LibFunc_ZnamRKSt9nothrow_t12__hot_cold_t
);
513 TLI
.setUnavailable(LibFunc_ZnamSt11align_val_t
);
514 TLI
.setUnavailable(LibFunc_ZnamSt11align_val_tRKSt9nothrow_t
);
515 TLI
.setUnavailable(LibFunc_Znwj
);
516 TLI
.setUnavailable(LibFunc_ZnwjRKSt9nothrow_t
);
517 TLI
.setUnavailable(LibFunc_ZnwjSt11align_val_t
);
518 TLI
.setUnavailable(LibFunc_ZnwjSt11align_val_tRKSt9nothrow_t
);
519 TLI
.setUnavailable(LibFunc_Znwm
);
520 TLI
.setUnavailable(LibFunc_ZnwmRKSt9nothrow_t
);
521 TLI
.setUnavailable(LibFunc_ZnwmRKSt9nothrow_t12__hot_cold_t
);
522 TLI
.setUnavailable(LibFunc_ZnwmSt11align_val_t
);
523 TLI
.setUnavailable(LibFunc_ZnwmSt11align_val_tRKSt9nothrow_t
);
524 TLI
.setUnavailable(LibFunc_Znwm12__hot_cold_t
);
525 TLI
.setUnavailable(LibFunc_ZnwmSt11align_val_t12__hot_cold_t
);
526 TLI
.setUnavailable(LibFunc_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t
);
527 TLI
.setUnavailable(LibFunc_Znam12__hot_cold_t
);
528 TLI
.setUnavailable(LibFunc_ZnamSt11align_val_t12__hot_cold_t
);
529 TLI
.setUnavailable(LibFunc_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t
);
530 TLI
.setUnavailable(LibFunc_size_returning_new
);
531 TLI
.setUnavailable(LibFunc_size_returning_new_hot_cold
);
532 TLI
.setUnavailable(LibFunc_size_returning_new_aligned
);
533 TLI
.setUnavailable(LibFunc_size_returning_new_aligned_hot_cold
);
535 // Not MSVC, assume it's Itanium.
536 TLI
.setUnavailable(LibFunc_msvc_new_int
);
537 TLI
.setUnavailable(LibFunc_msvc_new_int_nothrow
);
538 TLI
.setUnavailable(LibFunc_msvc_new_longlong
);
539 TLI
.setUnavailable(LibFunc_msvc_new_longlong_nothrow
);
540 TLI
.setUnavailable(LibFunc_msvc_delete_ptr32
);
541 TLI
.setUnavailable(LibFunc_msvc_delete_ptr32_nothrow
);
542 TLI
.setUnavailable(LibFunc_msvc_delete_ptr32_int
);
543 TLI
.setUnavailable(LibFunc_msvc_delete_ptr64
);
544 TLI
.setUnavailable(LibFunc_msvc_delete_ptr64_nothrow
);
545 TLI
.setUnavailable(LibFunc_msvc_delete_ptr64_longlong
);
546 TLI
.setUnavailable(LibFunc_msvc_new_array_int
);
547 TLI
.setUnavailable(LibFunc_msvc_new_array_int_nothrow
);
548 TLI
.setUnavailable(LibFunc_msvc_new_array_longlong
);
549 TLI
.setUnavailable(LibFunc_msvc_new_array_longlong_nothrow
);
550 TLI
.setUnavailable(LibFunc_msvc_delete_array_ptr32
);
551 TLI
.setUnavailable(LibFunc_msvc_delete_array_ptr32_nothrow
);
552 TLI
.setUnavailable(LibFunc_msvc_delete_array_ptr32_int
);
553 TLI
.setUnavailable(LibFunc_msvc_delete_array_ptr64
);
554 TLI
.setUnavailable(LibFunc_msvc_delete_array_ptr64_nothrow
);
555 TLI
.setUnavailable(LibFunc_msvc_delete_array_ptr64_longlong
);
560 // exp10 and exp10f are not available on OS X until 10.9 and iOS until 7.0
561 // and their names are __exp10 and __exp10f. exp10l is not available on
563 TLI
.setUnavailable(LibFunc_exp10l
);
564 if (T
.isMacOSXVersionLT(10, 9)) {
565 TLI
.setUnavailable(LibFunc_exp10
);
566 TLI
.setUnavailable(LibFunc_exp10f
);
568 TLI
.setAvailableWithName(LibFunc_exp10
, "__exp10");
569 TLI
.setAvailableWithName(LibFunc_exp10f
, "__exp10f");
574 case Triple::WatchOS
:
576 TLI
.setUnavailable(LibFunc_exp10l
);
577 if (!T
.isWatchOS() &&
578 (T
.isOSVersionLT(7, 0) || (T
.isOSVersionLT(9, 0) && T
.isX86()))) {
579 TLI
.setUnavailable(LibFunc_exp10
);
580 TLI
.setUnavailable(LibFunc_exp10f
);
582 TLI
.setAvailableWithName(LibFunc_exp10
, "__exp10");
583 TLI
.setAvailableWithName(LibFunc_exp10f
, "__exp10f");
587 // exp10, exp10f, exp10l is available on Linux (GLIBC) but are extremely
588 // buggy prior to glibc version 2.18. Until this version is widely deployed
589 // or we have a reasonable detection strategy, we cannot use exp10 reliably
592 // Fall through to disable all of them.
595 TLI
.setUnavailable(LibFunc_exp10
);
596 TLI
.setUnavailable(LibFunc_exp10f
);
597 TLI
.setUnavailable(LibFunc_exp10l
);
600 // ffsl is available on at least Darwin, Mac OS X, iOS, FreeBSD, and
602 // http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/ffsl.3.html
603 // http://svn.freebsd.org/base/head/lib/libc/string/ffsl.c
604 // http://www.gnu.org/software/gnulib/manual/html_node/ffsl.html
610 case Triple::WatchOS
:
612 case Triple::FreeBSD
:
616 TLI
.setUnavailable(LibFunc_ffsl
);
619 // ffsll is available on at least FreeBSD and Linux (GLIBC):
620 // http://svn.freebsd.org/base/head/lib/libc/string/ffsll.c
621 // http://www.gnu.org/software/gnulib/manual/html_node/ffsll.html
627 case Triple::WatchOS
:
629 case Triple::FreeBSD
:
633 TLI
.setUnavailable(LibFunc_ffsll
);
636 // The following functions are available on at least FreeBSD:
637 // http://svn.freebsd.org/base/head/lib/libc/string/fls.c
638 // http://svn.freebsd.org/base/head/lib/libc/string/flsl.c
639 // http://svn.freebsd.org/base/head/lib/libc/string/flsll.c
640 if (!T
.isOSFreeBSD()) {
641 TLI
.setUnavailable(LibFunc_fls
);
642 TLI
.setUnavailable(LibFunc_flsl
);
643 TLI
.setUnavailable(LibFunc_flsll
);
646 // The following functions are only available on GNU/Linux (using glibc).
647 // Linux variants without glibc (eg: bionic, musl) may have some subset.
648 if (!T
.isOSLinux() || !T
.isGNUEnvironment()) {
649 TLI
.setUnavailable(LibFunc_dunder_strdup
);
650 TLI
.setUnavailable(LibFunc_dunder_strtok_r
);
651 TLI
.setUnavailable(LibFunc_dunder_isoc99_scanf
);
652 TLI
.setUnavailable(LibFunc_dunder_isoc99_sscanf
);
653 TLI
.setUnavailable(LibFunc_under_IO_getc
);
654 TLI
.setUnavailable(LibFunc_under_IO_putc
);
655 // But, Android and musl have memalign.
656 if (!T
.isAndroid() && !T
.isMusl())
657 TLI
.setUnavailable(LibFunc_memalign
);
658 TLI
.setUnavailable(LibFunc_fopen64
);
659 TLI
.setUnavailable(LibFunc_fseeko64
);
660 TLI
.setUnavailable(LibFunc_fstat64
);
661 TLI
.setUnavailable(LibFunc_fstatvfs64
);
662 TLI
.setUnavailable(LibFunc_ftello64
);
663 TLI
.setUnavailable(LibFunc_lstat64
);
664 TLI
.setUnavailable(LibFunc_open64
);
665 TLI
.setUnavailable(LibFunc_stat64
);
666 TLI
.setUnavailable(LibFunc_statvfs64
);
667 TLI
.setUnavailable(LibFunc_tmpfile64
);
669 // Relaxed math functions are included in math-finite.h on Linux (GLIBC).
670 // Note that math-finite.h is no longer supported by top-of-tree GLIBC,
671 // so we keep these functions around just so that they're recognized by
672 // the ConstantFolder.
673 TLI
.setUnavailable(LibFunc_acos_finite
);
674 TLI
.setUnavailable(LibFunc_acosf_finite
);
675 TLI
.setUnavailable(LibFunc_acosl_finite
);
676 TLI
.setUnavailable(LibFunc_acosh_finite
);
677 TLI
.setUnavailable(LibFunc_acoshf_finite
);
678 TLI
.setUnavailable(LibFunc_acoshl_finite
);
679 TLI
.setUnavailable(LibFunc_asin_finite
);
680 TLI
.setUnavailable(LibFunc_asinf_finite
);
681 TLI
.setUnavailable(LibFunc_asinl_finite
);
682 TLI
.setUnavailable(LibFunc_atan2_finite
);
683 TLI
.setUnavailable(LibFunc_atan2f_finite
);
684 TLI
.setUnavailable(LibFunc_atan2l_finite
);
685 TLI
.setUnavailable(LibFunc_atanh_finite
);
686 TLI
.setUnavailable(LibFunc_atanhf_finite
);
687 TLI
.setUnavailable(LibFunc_atanhl_finite
);
688 TLI
.setUnavailable(LibFunc_cosh_finite
);
689 TLI
.setUnavailable(LibFunc_coshf_finite
);
690 TLI
.setUnavailable(LibFunc_coshl_finite
);
691 TLI
.setUnavailable(LibFunc_exp10_finite
);
692 TLI
.setUnavailable(LibFunc_exp10f_finite
);
693 TLI
.setUnavailable(LibFunc_exp10l_finite
);
694 TLI
.setUnavailable(LibFunc_exp2_finite
);
695 TLI
.setUnavailable(LibFunc_exp2f_finite
);
696 TLI
.setUnavailable(LibFunc_exp2l_finite
);
697 TLI
.setUnavailable(LibFunc_exp_finite
);
698 TLI
.setUnavailable(LibFunc_expf_finite
);
699 TLI
.setUnavailable(LibFunc_expl_finite
);
700 TLI
.setUnavailable(LibFunc_log10_finite
);
701 TLI
.setUnavailable(LibFunc_log10f_finite
);
702 TLI
.setUnavailable(LibFunc_log10l_finite
);
703 TLI
.setUnavailable(LibFunc_log2_finite
);
704 TLI
.setUnavailable(LibFunc_log2f_finite
);
705 TLI
.setUnavailable(LibFunc_log2l_finite
);
706 TLI
.setUnavailable(LibFunc_log_finite
);
707 TLI
.setUnavailable(LibFunc_logf_finite
);
708 TLI
.setUnavailable(LibFunc_logl_finite
);
709 TLI
.setUnavailable(LibFunc_pow_finite
);
710 TLI
.setUnavailable(LibFunc_powf_finite
);
711 TLI
.setUnavailable(LibFunc_powl_finite
);
712 TLI
.setUnavailable(LibFunc_sinh_finite
);
713 TLI
.setUnavailable(LibFunc_sinhf_finite
);
714 TLI
.setUnavailable(LibFunc_sinhl_finite
);
715 TLI
.setUnavailable(LibFunc_sqrt_finite
);
716 TLI
.setUnavailable(LibFunc_sqrtf_finite
);
717 TLI
.setUnavailable(LibFunc_sqrtl_finite
);
720 if ((T
.isOSLinux() && T
.isGNUEnvironment()) ||
721 (T
.isAndroid() && !T
.isAndroidVersionLT(28))) {
722 // available IO unlocked variants on GNU/Linux and Android P or later
723 TLI
.setAvailable(LibFunc_getc_unlocked
);
724 TLI
.setAvailable(LibFunc_getchar_unlocked
);
725 TLI
.setAvailable(LibFunc_putc_unlocked
);
726 TLI
.setAvailable(LibFunc_putchar_unlocked
);
727 TLI
.setAvailable(LibFunc_fputc_unlocked
);
728 TLI
.setAvailable(LibFunc_fgetc_unlocked
);
729 TLI
.setAvailable(LibFunc_fread_unlocked
);
730 TLI
.setAvailable(LibFunc_fwrite_unlocked
);
731 TLI
.setAvailable(LibFunc_fputs_unlocked
);
732 TLI
.setAvailable(LibFunc_fgets_unlocked
);
735 if (T
.isAndroid() && T
.isAndroidVersionLT(21)) {
736 TLI
.setUnavailable(LibFunc_stpcpy
);
737 TLI
.setUnavailable(LibFunc_stpncpy
);
741 // PS4/PS5 do have memalign.
742 TLI
.setAvailable(LibFunc_memalign
);
744 // PS4/PS5 do not have new/delete with "unsigned int" size parameter;
745 // they only have the "unsigned long" versions.
746 TLI
.setUnavailable(LibFunc_ZdaPvj
);
747 TLI
.setUnavailable(LibFunc_ZdaPvjSt11align_val_t
);
748 TLI
.setUnavailable(LibFunc_ZdlPvj
);
749 TLI
.setUnavailable(LibFunc_ZdlPvjSt11align_val_t
);
750 TLI
.setUnavailable(LibFunc_Znaj
);
751 TLI
.setUnavailable(LibFunc_ZnajRKSt9nothrow_t
);
752 TLI
.setUnavailable(LibFunc_ZnajSt11align_val_t
);
753 TLI
.setUnavailable(LibFunc_ZnajSt11align_val_tRKSt9nothrow_t
);
754 TLI
.setUnavailable(LibFunc_Znwj
);
755 TLI
.setUnavailable(LibFunc_ZnwjRKSt9nothrow_t
);
756 TLI
.setUnavailable(LibFunc_ZnwjSt11align_val_t
);
757 TLI
.setUnavailable(LibFunc_ZnwjSt11align_val_tRKSt9nothrow_t
);
759 // None of the *_chk functions.
760 TLI
.setUnavailable(LibFunc_memccpy_chk
);
761 TLI
.setUnavailable(LibFunc_memcpy_chk
);
762 TLI
.setUnavailable(LibFunc_memmove_chk
);
763 TLI
.setUnavailable(LibFunc_mempcpy_chk
);
764 TLI
.setUnavailable(LibFunc_memset_chk
);
765 TLI
.setUnavailable(LibFunc_snprintf_chk
);
766 TLI
.setUnavailable(LibFunc_sprintf_chk
);
767 TLI
.setUnavailable(LibFunc_stpcpy_chk
);
768 TLI
.setUnavailable(LibFunc_stpncpy_chk
);
769 TLI
.setUnavailable(LibFunc_strcat_chk
);
770 TLI
.setUnavailable(LibFunc_strcpy_chk
);
771 TLI
.setUnavailable(LibFunc_strlcat_chk
);
772 TLI
.setUnavailable(LibFunc_strlcpy_chk
);
773 TLI
.setUnavailable(LibFunc_strlen_chk
);
774 TLI
.setUnavailable(LibFunc_strncat_chk
);
775 TLI
.setUnavailable(LibFunc_strncpy_chk
);
776 TLI
.setUnavailable(LibFunc_vsnprintf_chk
);
777 TLI
.setUnavailable(LibFunc_vsprintf_chk
);
779 // Various Posix system functions.
780 TLI
.setUnavailable(LibFunc_access
);
781 TLI
.setUnavailable(LibFunc_chmod
);
782 TLI
.setUnavailable(LibFunc_chown
);
783 TLI
.setUnavailable(LibFunc_closedir
);
784 TLI
.setUnavailable(LibFunc_ctermid
);
785 TLI
.setUnavailable(LibFunc_execl
);
786 TLI
.setUnavailable(LibFunc_execle
);
787 TLI
.setUnavailable(LibFunc_execlp
);
788 TLI
.setUnavailable(LibFunc_execv
);
789 TLI
.setUnavailable(LibFunc_execvP
);
790 TLI
.setUnavailable(LibFunc_execve
);
791 TLI
.setUnavailable(LibFunc_execvp
);
792 TLI
.setUnavailable(LibFunc_execvpe
);
793 TLI
.setUnavailable(LibFunc_fork
);
794 TLI
.setUnavailable(LibFunc_fstat
);
795 TLI
.setUnavailable(LibFunc_fstatvfs
);
796 TLI
.setUnavailable(LibFunc_getenv
);
797 TLI
.setUnavailable(LibFunc_getitimer
);
798 TLI
.setUnavailable(LibFunc_getlogin_r
);
799 TLI
.setUnavailable(LibFunc_getpwnam
);
800 TLI
.setUnavailable(LibFunc_gettimeofday
);
801 TLI
.setUnavailable(LibFunc_lchown
);
802 TLI
.setUnavailable(LibFunc_lstat
);
803 TLI
.setUnavailable(LibFunc_mkdir
);
804 TLI
.setUnavailable(LibFunc_open
);
805 TLI
.setUnavailable(LibFunc_opendir
);
806 TLI
.setUnavailable(LibFunc_pclose
);
807 TLI
.setUnavailable(LibFunc_popen
);
808 TLI
.setUnavailable(LibFunc_pread
);
809 TLI
.setUnavailable(LibFunc_pwrite
);
810 TLI
.setUnavailable(LibFunc_read
);
811 TLI
.setUnavailable(LibFunc_readlink
);
812 TLI
.setUnavailable(LibFunc_realpath
);
813 TLI
.setUnavailable(LibFunc_rename
);
814 TLI
.setUnavailable(LibFunc_rmdir
);
815 TLI
.setUnavailable(LibFunc_setitimer
);
816 TLI
.setUnavailable(LibFunc_stat
);
817 TLI
.setUnavailable(LibFunc_statvfs
);
818 TLI
.setUnavailable(LibFunc_system
);
819 TLI
.setUnavailable(LibFunc_times
);
820 TLI
.setUnavailable(LibFunc_tmpfile
);
821 TLI
.setUnavailable(LibFunc_unlink
);
822 TLI
.setUnavailable(LibFunc_uname
);
823 TLI
.setUnavailable(LibFunc_unsetenv
);
824 TLI
.setUnavailable(LibFunc_utime
);
825 TLI
.setUnavailable(LibFunc_utimes
);
826 TLI
.setUnavailable(LibFunc_valloc
);
827 TLI
.setUnavailable(LibFunc_write
);
829 // Miscellaneous other functions not provided.
830 TLI
.setUnavailable(LibFunc_atomic_load
);
831 TLI
.setUnavailable(LibFunc_atomic_store
);
832 TLI
.setUnavailable(LibFunc___kmpc_alloc_shared
);
833 TLI
.setUnavailable(LibFunc___kmpc_free_shared
);
834 TLI
.setUnavailable(LibFunc_dunder_strndup
);
835 TLI
.setUnavailable(LibFunc_bcmp
);
836 TLI
.setUnavailable(LibFunc_bcopy
);
837 TLI
.setUnavailable(LibFunc_bzero
);
838 TLI
.setUnavailable(LibFunc_cabs
);
839 TLI
.setUnavailable(LibFunc_cabsf
);
840 TLI
.setUnavailable(LibFunc_cabsl
);
841 TLI
.setUnavailable(LibFunc_ffs
);
842 TLI
.setUnavailable(LibFunc_flockfile
);
843 TLI
.setUnavailable(LibFunc_fseeko
);
844 TLI
.setUnavailable(LibFunc_ftello
);
845 TLI
.setUnavailable(LibFunc_ftrylockfile
);
846 TLI
.setUnavailable(LibFunc_funlockfile
);
847 TLI
.setUnavailable(LibFunc_htonl
);
848 TLI
.setUnavailable(LibFunc_htons
);
849 TLI
.setUnavailable(LibFunc_isascii
);
850 TLI
.setUnavailable(LibFunc_memccpy
);
851 TLI
.setUnavailable(LibFunc_mempcpy
);
852 TLI
.setUnavailable(LibFunc_memrchr
);
853 TLI
.setUnavailable(LibFunc_ntohl
);
854 TLI
.setUnavailable(LibFunc_ntohs
);
855 TLI
.setUnavailable(LibFunc_reallocarray
);
856 TLI
.setUnavailable(LibFunc_reallocf
);
857 TLI
.setUnavailable(LibFunc_roundeven
);
858 TLI
.setUnavailable(LibFunc_roundevenf
);
859 TLI
.setUnavailable(LibFunc_roundevenl
);
860 TLI
.setUnavailable(LibFunc_stpcpy
);
861 TLI
.setUnavailable(LibFunc_stpncpy
);
862 TLI
.setUnavailable(LibFunc_strlcat
);
863 TLI
.setUnavailable(LibFunc_strlcpy
);
864 TLI
.setUnavailable(LibFunc_strndup
);
865 TLI
.setUnavailable(LibFunc_strnlen
);
866 TLI
.setUnavailable(LibFunc_toascii
);
869 // As currently implemented in clang, NVPTX code has no standard library to
870 // speak of. Headers provide a standard-ish library implementation, but many
871 // of the signatures are wrong -- for example, many libm functions are not
874 // libdevice, an IR library provided by nvidia, is linked in by the front-end,
875 // but only used functions are provided to llvm. Moreover, most of the
876 // functions in libdevice don't map precisely to standard library functions.
878 // FIXME: Having no standard library prevents e.g. many fastmath
879 // optimizations, so this situation should be fixed.
881 TLI
.disableAllFunctions();
882 TLI
.setAvailable(LibFunc_nvvm_reflect
);
883 TLI
.setAvailable(llvm::LibFunc_malloc
);
884 TLI
.setAvailable(llvm::LibFunc_free
);
886 // TODO: We could enable the following two according to [0] but we haven't
887 // done an evaluation wrt. the performance implications.
889 // https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#dynamic-global-memory-allocation-and-operations
891 // TLI.setAvailable(llvm::LibFunc_memcpy);
892 // TLI.setAvailable(llvm::LibFunc_memset);
894 TLI
.setAvailable(llvm::LibFunc___kmpc_alloc_shared
);
895 TLI
.setAvailable(llvm::LibFunc___kmpc_free_shared
);
897 TLI
.setUnavailable(LibFunc_nvvm_reflect
);
900 // These vec_malloc/free routines are only available on AIX.
902 TLI
.setUnavailable(LibFunc_vec_calloc
);
903 TLI
.setUnavailable(LibFunc_vec_malloc
);
904 TLI
.setUnavailable(LibFunc_vec_realloc
);
905 TLI
.setUnavailable(LibFunc_vec_free
);
909 TLI
.setUnavailable(LibFunc_memrchr
);
911 TLI
.addVectorizableFunctionsFromVecLib(ClVectorLibrary
, T
);
914 /// Initialize the set of available library functions based on the specified
915 /// target triple. This should be carefully written so that a missing target
916 /// triple gets a sane set of defaults.
917 static void initialize(TargetLibraryInfoImpl
&TLI
, const Triple
&T
,
918 ArrayRef
<StringLiteral
> StandardNames
) {
919 initializeBase(TLI
, T
);
920 initializeLibCalls(TLI
, T
, StandardNames
);
923 TargetLibraryInfoImpl::TargetLibraryInfoImpl() {
924 // Default to nothing being available.
925 memset(AvailableArray
, 0, sizeof(AvailableArray
));
926 initializeBase(*this, Triple());
929 TargetLibraryInfoImpl::TargetLibraryInfoImpl(const Triple
&T
) {
930 // Default to everything being available.
931 memset(AvailableArray
, -1, sizeof(AvailableArray
));
933 initialize(*this, T
, StandardNames
);
936 TargetLibraryInfoImpl::TargetLibraryInfoImpl(const TargetLibraryInfoImpl
&TLI
)
937 : CustomNames(TLI
.CustomNames
), ShouldExtI32Param(TLI
.ShouldExtI32Param
),
938 ShouldExtI32Return(TLI
.ShouldExtI32Return
),
939 ShouldSignExtI32Param(TLI
.ShouldSignExtI32Param
),
940 ShouldSignExtI32Return(TLI
.ShouldSignExtI32Return
),
941 SizeOfInt(TLI
.SizeOfInt
) {
942 memcpy(AvailableArray
, TLI
.AvailableArray
, sizeof(AvailableArray
));
943 VectorDescs
= TLI
.VectorDescs
;
944 ScalarDescs
= TLI
.ScalarDescs
;
947 TargetLibraryInfoImpl::TargetLibraryInfoImpl(TargetLibraryInfoImpl
&&TLI
)
948 : CustomNames(std::move(TLI
.CustomNames
)),
949 ShouldExtI32Param(TLI
.ShouldExtI32Param
),
950 ShouldExtI32Return(TLI
.ShouldExtI32Return
),
951 ShouldSignExtI32Param(TLI
.ShouldSignExtI32Param
),
952 ShouldSignExtI32Return(TLI
.ShouldSignExtI32Return
),
953 SizeOfInt(TLI
.SizeOfInt
) {
954 std::move(std::begin(TLI
.AvailableArray
), std::end(TLI
.AvailableArray
),
956 VectorDescs
= TLI
.VectorDescs
;
957 ScalarDescs
= TLI
.ScalarDescs
;
960 TargetLibraryInfoImpl
&TargetLibraryInfoImpl::operator=(const TargetLibraryInfoImpl
&TLI
) {
961 CustomNames
= TLI
.CustomNames
;
962 ShouldExtI32Param
= TLI
.ShouldExtI32Param
;
963 ShouldExtI32Return
= TLI
.ShouldExtI32Return
;
964 ShouldSignExtI32Param
= TLI
.ShouldSignExtI32Param
;
965 ShouldSignExtI32Return
= TLI
.ShouldSignExtI32Return
;
966 SizeOfInt
= TLI
.SizeOfInt
;
967 memcpy(AvailableArray
, TLI
.AvailableArray
, sizeof(AvailableArray
));
971 TargetLibraryInfoImpl
&TargetLibraryInfoImpl::operator=(TargetLibraryInfoImpl
&&TLI
) {
972 CustomNames
= std::move(TLI
.CustomNames
);
973 ShouldExtI32Param
= TLI
.ShouldExtI32Param
;
974 ShouldExtI32Return
= TLI
.ShouldExtI32Return
;
975 ShouldSignExtI32Param
= TLI
.ShouldSignExtI32Param
;
976 ShouldSignExtI32Return
= TLI
.ShouldSignExtI32Return
;
977 SizeOfInt
= TLI
.SizeOfInt
;
978 std::move(std::begin(TLI
.AvailableArray
), std::end(TLI
.AvailableArray
),
983 static StringRef
sanitizeFunctionName(StringRef funcName
) {
984 // Filter out empty names and names containing null bytes, those can't be in
986 if (funcName
.empty() || funcName
.contains('\0'))
989 // Check for \01 prefix that is used to mangle __asm declarations and
990 // strip it if present.
991 return GlobalValue::dropLLVMManglingEscape(funcName
);
994 static DenseMap
<StringRef
, LibFunc
>
995 buildIndexMap(ArrayRef
<StringLiteral
> StandardNames
) {
996 DenseMap
<StringRef
, LibFunc
> Indices
;
998 Indices
.reserve(LibFunc::NumLibFuncs
);
999 for (const auto &Func
: StandardNames
)
1000 Indices
[Func
] = static_cast<LibFunc
>(Idx
++);
1004 bool TargetLibraryInfoImpl::getLibFunc(StringRef funcName
, LibFunc
&F
) const {
1005 funcName
= sanitizeFunctionName(funcName
);
1006 if (funcName
.empty())
1009 static const DenseMap
<StringRef
, LibFunc
> Indices
=
1010 buildIndexMap(StandardNames
);
1012 if (auto Loc
= Indices
.find(funcName
); Loc
!= Indices
.end()) {
1019 // Return true if ArgTy matches Ty.
1021 static bool matchType(FuncArgTypeID ArgTy
, const Type
*Ty
, unsigned IntBits
,
1022 unsigned SizeTBits
) {
1025 return Ty
->isVoidTy();
1027 return Ty
->isIntegerTy(8);
1029 return Ty
->isIntegerTy(16);
1031 return Ty
->isIntegerTy(32);
1033 return Ty
->isIntegerTy(IntBits
);
1035 return Ty
->isIntegerTy() && Ty
->getPrimitiveSizeInBits() >= IntBits
;
1037 return Ty
->isIntegerTy();
1039 // TODO: Figure out and use long size.
1040 return Ty
->isIntegerTy() && Ty
->getPrimitiveSizeInBits() >= IntBits
;
1042 return Ty
->isIntegerTy(64);
1044 return Ty
->isIntegerTy(64);
1047 return Ty
->isIntegerTy(SizeTBits
);
1049 return Ty
->isFloatTy();
1051 return Ty
->isDoubleTy();
1052 // TODO: Tighten this up.
1054 return Ty
->isFloatingPointTy();
1056 return Ty
->isFloatingPointTy();
1058 return Ty
->isPointerTy();
1060 return Ty
->isStructTy();
1065 llvm_unreachable("Invalid type");
1068 static bool isValidProtoForSizeReturningNew(const FunctionType
&FTy
, LibFunc F
,
1070 int SizeTSizeBits
) {
1072 case LibFunc_size_returning_new
: {
1073 if (FTy
.getNumParams() != 1 ||
1074 !FTy
.getParamType(0)->isIntegerTy(SizeTSizeBits
)) {
1078 case LibFunc_size_returning_new_hot_cold
: {
1079 if (FTy
.getNumParams() != 2 ||
1080 !FTy
.getParamType(0)->isIntegerTy(SizeTSizeBits
) ||
1081 !FTy
.getParamType(1)->isIntegerTy(8)) {
1085 case LibFunc_size_returning_new_aligned
: {
1086 if (FTy
.getNumParams() != 2 ||
1087 !FTy
.getParamType(0)->isIntegerTy(SizeTSizeBits
) ||
1088 !FTy
.getParamType(1)->isIntegerTy(SizeTSizeBits
)) {
1092 case LibFunc_size_returning_new_aligned_hot_cold
:
1093 if (FTy
.getNumParams() != 3 ||
1094 !FTy
.getParamType(0)->isIntegerTy(SizeTSizeBits
) ||
1095 !FTy
.getParamType(1)->isIntegerTy(SizeTSizeBits
) ||
1096 !FTy
.getParamType(2)->isIntegerTy(8)) {
1104 auto &Context
= M
.getContext();
1105 PointerType
*PtrTy
= PointerType::get(Context
, 0);
1106 StructType
*SizedPtrTy
= StructType::get(
1107 Context
, {PtrTy
, Type::getIntNTy(Context
, SizeTSizeBits
)});
1108 return FTy
.getReturnType() == SizedPtrTy
;
1111 bool TargetLibraryInfoImpl::isValidProtoForLibFunc(const FunctionType
&FTy
,
1113 const Module
&M
) const {
1114 unsigned NumParams
= FTy
.getNumParams();
1117 // Special handling for <complex.h> functions:
1120 case LibFunc_cabsl
: {
1121 Type
*RetTy
= FTy
.getReturnType();
1122 if (!RetTy
->isFloatingPointTy())
1125 Type
*ParamTy
= FTy
.getParamType(0);
1126 // NOTE: These prototypes are target specific and currently support
1127 // "complex" passed as an array or discrete real & imaginary parameters.
1128 // Add other calling conventions to enable libcall optimizations.
1130 return (ParamTy
->isArrayTy() && ParamTy
->getArrayNumElements() == 2 &&
1131 ParamTy
->getArrayElementType() == RetTy
);
1132 else if (NumParams
== 2)
1133 return ParamTy
== RetTy
&& FTy
.getParamType(1) == RetTy
;
1137 // Special handling for the sincospi functions that return either
1138 // a struct or vector:
1139 case LibFunc_sincospi_stret
:
1140 case LibFunc_sincospif_stret
: {
1144 Type
*RetTy
= FTy
.getReturnType();
1145 Type
*ParamTy
= FTy
.getParamType(0);
1146 if (auto *Ty
= dyn_cast
<StructType
>(RetTy
)) {
1147 if (Ty
->getNumElements() != 2)
1149 return (Ty
->getElementType(0) == ParamTy
&&
1150 Ty
->getElementType(1) == ParamTy
);
1153 if (auto *Ty
= dyn_cast
<FixedVectorType
>(RetTy
)) {
1154 if (Ty
->getNumElements() != 2)
1156 return Ty
->getElementType() == ParamTy
;
1161 // Special handling of __size_returning_new functions that return a struct
1162 // of type {void*, size_t}.
1163 case LibFunc_size_returning_new
:
1164 case LibFunc_size_returning_new_hot_cold
:
1165 case LibFunc_size_returning_new_aligned
:
1166 case LibFunc_size_returning_new_aligned_hot_cold
:
1167 return isValidProtoForSizeReturningNew(FTy
, F
, M
, getSizeTSize(M
));
1172 unsigned IntBits
= getIntSize();
1173 unsigned SizeTBits
= getSizeTSize(M
);
1176 // Iterate over the type ids in the function prototype, matching each
1177 // against the function's type FTy, starting with its return type.
1178 // Return true if both match in number and kind, inclduing the ellipsis.
1179 Type
*Ty
= FTy
.getReturnType(), *LastTy
= Ty
;
1180 const auto &ProtoTypes
= Signatures
[F
];
1181 for (auto TyID
: ProtoTypes
) {
1182 if (Idx
&& TyID
== Void
)
1183 // Except in the first position where it designates the function's
1184 // return type Void ends the argument list.
1187 if (TyID
== Ellip
) {
1188 // The ellipsis ends the protoype list but is not a part of FTy's
1189 // argument list. Except when it's last it must be followed by
1191 assert(Idx
== ProtoTypes
.size() - 1 || ProtoTypes
[Idx
+ 1] == Void
);
1192 return FTy
.isFunctionVarArg();
1196 assert(Idx
!= 0 && "Type ID 'Same' must not be first!");
1200 if (!Ty
|| !matchType(TyID
, Ty
, IntBits
, SizeTBits
))
1205 if (Idx
== NumParams
) {
1206 // There's at least one and at most two more type ids than there are
1207 // arguments in FTy's argument list.
1213 Ty
= FTy
.getParamType(Idx
++);
1216 // Return success only if all entries on both lists have been processed
1217 // and the function is not a variadic one.
1218 return Idx
== NumParams
+ 1 && !FTy
.isFunctionVarArg();
1221 bool TargetLibraryInfoImpl::getLibFunc(const Function
&FDecl
,
1223 // Intrinsics don't overlap w/libcalls; if our module has a large number of
1224 // intrinsics, this ends up being an interesting compile time win since we
1225 // avoid string normalization and comparison.
1226 if (FDecl
.isIntrinsic()) return false;
1228 const Module
*M
= FDecl
.getParent();
1229 assert(M
&& "Expecting FDecl to be connected to a Module.");
1231 if (FDecl
.LibFuncCache
== Function::UnknownLibFunc
)
1232 if (!getLibFunc(FDecl
.getName(), FDecl
.LibFuncCache
))
1233 FDecl
.LibFuncCache
= NotLibFunc
;
1235 if (FDecl
.LibFuncCache
== NotLibFunc
)
1238 F
= FDecl
.LibFuncCache
;
1239 return isValidProtoForLibFunc(*FDecl
.getFunctionType(), F
, *M
);
1242 bool TargetLibraryInfoImpl::getLibFunc(unsigned int Opcode
, Type
*Ty
,
1244 // Must be a frem instruction with float or double arguments.
1245 if (Opcode
!= Instruction::FRem
|| (!Ty
->isDoubleTy() && !Ty
->isFloatTy()))
1248 F
= Ty
->isDoubleTy() ? LibFunc_fmod
: LibFunc_fmodf
;
1252 void TargetLibraryInfoImpl::disableAllFunctions() {
1253 memset(AvailableArray
, 0, sizeof(AvailableArray
));
1256 static bool compareByScalarFnName(const VecDesc
&LHS
, const VecDesc
&RHS
) {
1257 return LHS
.getScalarFnName() < RHS
.getScalarFnName();
1260 static bool compareByVectorFnName(const VecDesc
&LHS
, const VecDesc
&RHS
) {
1261 return LHS
.getVectorFnName() < RHS
.getVectorFnName();
1264 static bool compareWithScalarFnName(const VecDesc
&LHS
, StringRef S
) {
1265 return LHS
.getScalarFnName() < S
;
1268 void TargetLibraryInfoImpl::addVectorizableFunctions(ArrayRef
<VecDesc
> Fns
) {
1269 llvm::append_range(VectorDescs
, Fns
);
1270 llvm::sort(VectorDescs
, compareByScalarFnName
);
1272 llvm::append_range(ScalarDescs
, Fns
);
1273 llvm::sort(ScalarDescs
, compareByVectorFnName
);
1276 static const VecDesc VecFuncs_Accelerate
[] = {
1277 #define TLI_DEFINE_ACCELERATE_VECFUNCS
1278 #include "llvm/Analysis/VecFuncs.def"
1279 #undef TLI_DEFINE_ACCELERATE_VECFUNCS
1282 static const VecDesc VecFuncs_DarwinLibSystemM
[] = {
1283 #define TLI_DEFINE_DARWIN_LIBSYSTEM_M_VECFUNCS
1284 #include "llvm/Analysis/VecFuncs.def"
1285 #undef TLI_DEFINE_DARWIN_LIBSYSTEM_M_VECFUNCS
1288 static const VecDesc VecFuncs_LIBMVEC_X86
[] = {
1289 #define TLI_DEFINE_LIBMVEC_X86_VECFUNCS
1290 #include "llvm/Analysis/VecFuncs.def"
1291 #undef TLI_DEFINE_LIBMVEC_X86_VECFUNCS
1294 static const VecDesc VecFuncs_MASSV
[] = {
1295 #define TLI_DEFINE_MASSV_VECFUNCS
1296 #include "llvm/Analysis/VecFuncs.def"
1297 #undef TLI_DEFINE_MASSV_VECFUNCS
1300 static const VecDesc VecFuncs_SVML
[] = {
1301 #define TLI_DEFINE_SVML_VECFUNCS
1302 #include "llvm/Analysis/VecFuncs.def"
1303 #undef TLI_DEFINE_SVML_VECFUNCS
1306 static const VecDesc VecFuncs_SLEEFGNUABI_VF2
[] = {
1307 #define TLI_DEFINE_SLEEFGNUABI_VF2_VECFUNCS
1308 #define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, VABI_PREFIX) \
1309 {SCAL, VEC, VF, /* MASK = */ false, VABI_PREFIX},
1310 #include "llvm/Analysis/VecFuncs.def"
1311 #undef TLI_DEFINE_SLEEFGNUABI_VF2_VECFUNCS
1313 static const VecDesc VecFuncs_SLEEFGNUABI_VF4
[] = {
1314 #define TLI_DEFINE_SLEEFGNUABI_VF4_VECFUNCS
1315 #define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, VABI_PREFIX) \
1316 {SCAL, VEC, VF, /* MASK = */ false, VABI_PREFIX},
1317 #include "llvm/Analysis/VecFuncs.def"
1318 #undef TLI_DEFINE_SLEEFGNUABI_VF4_VECFUNCS
1320 static const VecDesc VecFuncs_SLEEFGNUABI_VFScalable
[] = {
1321 #define TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS
1322 #define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MASK, VABI_PREFIX) \
1323 {SCAL, VEC, VF, MASK, VABI_PREFIX},
1324 #include "llvm/Analysis/VecFuncs.def"
1325 #undef TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS
1328 static const VecDesc VecFuncs_SLEEFGNUABI_VFScalableRISCV
[] = {
1329 #define TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS_RISCV
1330 #define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MASK, VABI_PREFIX) \
1331 {SCAL, VEC, VF, MASK, VABI_PREFIX},
1332 #include "llvm/Analysis/VecFuncs.def"
1333 #undef TLI_DEFINE_SLEEFGNUABI_SCALABLE_VECFUNCS_RISCV
1336 static const VecDesc VecFuncs_ArmPL
[] = {
1337 #define TLI_DEFINE_ARMPL_VECFUNCS
1338 #define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MASK, VABI_PREFIX) \
1339 {SCAL, VEC, VF, MASK, VABI_PREFIX},
1340 #include "llvm/Analysis/VecFuncs.def"
1341 #undef TLI_DEFINE_ARMPL_VECFUNCS
1344 const VecDesc VecFuncs_AMDLIBM
[] = {
1345 #define TLI_DEFINE_AMDLIBM_VECFUNCS
1346 #define TLI_DEFINE_VECFUNC(SCAL, VEC, VF, MASK, VABI_PREFIX) \
1347 {SCAL, VEC, VF, MASK, VABI_PREFIX},
1348 #include "llvm/Analysis/VecFuncs.def"
1349 #undef TLI_DEFINE_AMDLIBM_VECFUNCS
1352 void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib(
1353 enum VectorLibrary VecLib
, const llvm::Triple
&TargetTriple
) {
1356 addVectorizableFunctions(VecFuncs_Accelerate
);
1359 case DarwinLibSystemM
: {
1360 addVectorizableFunctions(VecFuncs_DarwinLibSystemM
);
1364 addVectorizableFunctions(VecFuncs_LIBMVEC_X86
);
1368 addVectorizableFunctions(VecFuncs_MASSV
);
1372 addVectorizableFunctions(VecFuncs_SVML
);
1376 switch (TargetTriple
.getArch()) {
1379 case llvm::Triple::aarch64
:
1380 case llvm::Triple::aarch64_be
:
1381 addVectorizableFunctions(VecFuncs_SLEEFGNUABI_VF2
);
1382 addVectorizableFunctions(VecFuncs_SLEEFGNUABI_VF4
);
1383 addVectorizableFunctions(VecFuncs_SLEEFGNUABI_VFScalable
);
1385 case llvm::Triple::riscv64
:
1386 addVectorizableFunctions(VecFuncs_SLEEFGNUABI_VFScalableRISCV
);
1392 switch (TargetTriple
.getArch()) {
1395 case llvm::Triple::aarch64
:
1396 case llvm::Triple::aarch64_be
:
1397 addVectorizableFunctions(VecFuncs_ArmPL
);
1403 addVectorizableFunctions(VecFuncs_AMDLIBM
);
1411 bool TargetLibraryInfoImpl::isFunctionVectorizable(StringRef funcName
) const {
1412 funcName
= sanitizeFunctionName(funcName
);
1413 if (funcName
.empty())
1416 std::vector
<VecDesc
>::const_iterator I
=
1417 llvm::lower_bound(VectorDescs
, funcName
, compareWithScalarFnName
);
1418 return I
!= VectorDescs
.end() && StringRef(I
->getScalarFnName()) == funcName
;
1421 StringRef
TargetLibraryInfoImpl::getVectorizedFunction(StringRef F
,
1422 const ElementCount
&VF
,
1423 bool Masked
) const {
1424 const VecDesc
*VD
= getVectorMappingInfo(F
, VF
, Masked
);
1426 return VD
->getVectorFnName();
1431 TargetLibraryInfoImpl::getVectorMappingInfo(StringRef F
, const ElementCount
&VF
,
1432 bool Masked
) const {
1433 F
= sanitizeFunctionName(F
);
1436 std::vector
<VecDesc
>::const_iterator I
=
1437 llvm::lower_bound(VectorDescs
, F
, compareWithScalarFnName
);
1438 while (I
!= VectorDescs
.end() && StringRef(I
->getScalarFnName()) == F
) {
1439 if ((I
->getVectorizationFactor() == VF
) && (I
->isMasked() == Masked
))
1446 TargetLibraryInfo
TargetLibraryAnalysis::run(const Function
&F
,
1447 FunctionAnalysisManager
&) {
1448 if (!BaselineInfoImpl
)
1450 TargetLibraryInfoImpl(Triple(F
.getParent()->getTargetTriple()));
1451 return TargetLibraryInfo(*BaselineInfoImpl
, &F
);
1454 unsigned TargetLibraryInfoImpl::getWCharSize(const Module
&M
) const {
1455 if (auto *ShortWChar
= cast_or_null
<ConstantAsMetadata
>(
1456 M
.getModuleFlag("wchar_size")))
1457 return cast
<ConstantInt
>(ShortWChar
->getValue())->getZExtValue();
1461 unsigned TargetLibraryInfoImpl::getSizeTSize(const Module
&M
) const {
1462 // There is really no guarantee that sizeof(size_t) is equal to the index
1463 // size of the default address space. If that isn't true then it should be
1464 // possible to derive the SizeTTy from the target triple here instead and do
1467 // Hard coding address space zero may seem unfortunate, but a number of
1468 // configurations of common targets (i386, x86-64 x32, aarch64 x32, possibly
1469 // others) have larger-than-size_t index sizes on non-default address spaces,
1470 // making this the best default.
1471 return M
.getDataLayout().getIndexSizeInBits(/*AddressSpace=*/0);
1474 TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass()
1475 : ImmutablePass(ID
), TLA(TargetLibraryInfoImpl()) {
1476 initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
1479 TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(const Triple
&T
)
1480 : ImmutablePass(ID
), TLA(TargetLibraryInfoImpl(T
)) {
1481 initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
1484 TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(
1485 const TargetLibraryInfoImpl
&TLIImpl
)
1486 : ImmutablePass(ID
), TLA(TLIImpl
) {
1487 initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
1490 TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(
1491 const TargetLibraryInfo
&TLIOther
)
1492 : TargetLibraryInfoWrapperPass(*TLIOther
.Impl
) {}
1494 AnalysisKey
TargetLibraryAnalysis::Key
;
1496 // Register the basic pass.
1497 INITIALIZE_PASS(TargetLibraryInfoWrapperPass
, "targetlibinfo",
1498 "Target Library Information", false, true)
1499 char TargetLibraryInfoWrapperPass::ID
= 0;
1501 void TargetLibraryInfoWrapperPass::anchor() {}
1503 void TargetLibraryInfoImpl::getWidestVF(StringRef ScalarF
,
1504 ElementCount
&FixedVF
,
1505 ElementCount
&ScalableVF
) const {
1506 ScalarF
= sanitizeFunctionName(ScalarF
);
1507 // Use '0' here because a type of the form <vscale x 1 x ElTy> is not the
1508 // same as a scalar.
1509 ScalableVF
= ElementCount::getScalable(0);
1510 FixedVF
= ElementCount::getFixed(1);
1511 if (ScalarF
.empty())
1514 std::vector
<VecDesc
>::const_iterator I
=
1515 llvm::lower_bound(VectorDescs
, ScalarF
, compareWithScalarFnName
);
1516 while (I
!= VectorDescs
.end() && StringRef(I
->getScalarFnName()) == ScalarF
) {
1518 I
->getVectorizationFactor().isScalable() ? &ScalableVF
: &FixedVF
;
1519 if (ElementCount::isKnownGT(I
->getVectorizationFactor(), *VF
))
1520 *VF
= I
->getVectorizationFactor();