blob: ae86ee3d3650001485f5d58dcd48e5e2e3b63061 [file] [log] [blame]
Chris Lattnerce991202011-02-18 21:50:34 +00001//===-- TargetLibraryInfo.cpp - Runtime library information ----------------==//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the TargetLibraryInfo class.
11//
12//===----------------------------------------------------------------------===//
13
Chandler Carruthbda13492015-01-15 02:16:27 +000014#include "llvm/Analysis/TargetLibraryInfo.h"
Chris Lattnerce991202011-02-18 21:50:34 +000015#include "llvm/ADT/Triple.h"
Matthias Braun708626d2017-05-19 22:37:09 +000016#include "llvm/IR/Constants.h"
Michael Zolotukhin58506022015-03-17 19:50:55 +000017#include "llvm/Support/CommandLine.h"
Chris Lattnerce991202011-02-18 21:50:34 +000018using namespace llvm;
19
Michael Zolotukhin58506022015-03-17 19:50:55 +000020static cl::opt<TargetLibraryInfoImpl::VectorLibrary> ClVectorLibrary(
21 "vector-library", cl::Hidden, cl::desc("Vector functions library"),
22 cl::init(TargetLibraryInfoImpl::NoLibrary),
23 cl::values(clEnumValN(TargetLibraryInfoImpl::NoLibrary, "none",
24 "No vector functions library"),
25 clEnumValN(TargetLibraryInfoImpl::Accelerate, "Accelerate",
26 "Accelerate framework"),
Matt Mastenbbbcccb2016-07-29 16:42:44 +000027 clEnumValN(TargetLibraryInfoImpl::SVML, "SVML",
Joel Jones9951b072018-11-24 07:26:55 +000028 "Intel SVML library")));
Michael Zolotukhin58506022015-03-17 19:50:55 +000029
Mehdi Amini5e07fb32016-10-01 03:10:48 +000030StringRef const TargetLibraryInfoImpl::StandardNames[LibFunc::NumLibFuncs] = {
Jan Wen Voung87a61e92015-03-03 23:41:58 +000031#define TLI_DEFINE_STRING
32#include "llvm/Analysis/TargetLibraryInfo.def"
Benjamin Kramerc8a95a82015-03-08 16:07:39 +000033};
Eli Friedman9d434db2011-11-17 01:27:36 +000034
Bob Wilson208130f2013-11-03 06:48:38 +000035static bool hasSinCosPiStret(const Triple &T) {
36 // Only Darwin variants have _stret versions of combined trig functions.
Bob Wilson8e673572014-10-09 05:43:30 +000037 if (!T.isOSDarwin())
Bob Wilson208130f2013-11-03 06:48:38 +000038 return false;
39
40 // The ABI is rather complicated on x86, so don't do anything special there.
41 if (T.getArch() == Triple::x86)
42 return false;
43
44 if (T.isMacOSX() && T.isMacOSXVersionLT(10, 9))
45 return false;
46
Bob Wilson8e673572014-10-09 05:43:30 +000047 if (T.isiOS() && T.isOSVersionLT(7, 0))
Bob Wilson208130f2013-11-03 06:48:38 +000048 return false;
49
50 return true;
51}
52
Sanjay Patel050e8902017-12-15 18:54:29 +000053/// Initialize the set of available library functions based on the specified
54/// target triple. This should be carefully written so that a missing target
55/// triple gets a sane set of defaults.
Chandler Carruth6f409cb2015-01-24 02:06:09 +000056static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
Mehdi Amini5e07fb32016-10-01 03:10:48 +000057 ArrayRef<StringRef> StandardNames) {
Bob Wilsond1e672e2012-08-03 04:06:22 +000058 // Verify that the StandardNames array is in alphabetical order.
Craig Topper2921ff92016-01-03 19:43:40 +000059 assert(std::is_sorted(StandardNames.begin(), StandardNames.end(),
Mehdi Amini5e07fb32016-10-01 03:10:48 +000060 [](StringRef LHS, StringRef RHS) {
61 return LHS < RHS;
Craig Topper2921ff92016-01-03 19:43:40 +000062 }) &&
63 "TargetLibraryInfoImpl function names must be sorted");
Tom Stellardadb852d2014-04-02 19:53:29 +000064
David Bolvanskycb037ef2018-05-16 11:39:52 +000065 // Set IO unlocked variants as unavailable
66 // Set them as available per system below
67 TLI.setUnavailable(LibFunc_getchar_unlocked);
68 TLI.setUnavailable(LibFunc_putc_unlocked);
69 TLI.setUnavailable(LibFunc_putchar_unlocked);
70 TLI.setUnavailable(LibFunc_fputc_unlocked);
71 TLI.setUnavailable(LibFunc_fgetc_unlocked);
72 TLI.setUnavailable(LibFunc_fread_unlocked);
73 TLI.setUnavailable(LibFunc_fwrite_unlocked);
74 TLI.setUnavailable(LibFunc_fputs_unlocked);
75 TLI.setUnavailable(LibFunc_fgets_unlocked);
76
Marcin Koscielnickib76c6d32016-11-21 20:20:39 +000077 bool ShouldExtI32Param = false, ShouldExtI32Return = false,
78 ShouldSignExtI32Param = false;
79 // PowerPC64, Sparc64, SystemZ need signext/zeroext on i32 parameters and
80 // returns corresponding to C-level ints and unsigned ints.
81 if (T.getArch() == Triple::ppc64 || T.getArch() == Triple::ppc64le ||
82 T.getArch() == Triple::sparcv9 || T.getArch() == Triple::systemz) {
83 ShouldExtI32Param = true;
84 ShouldExtI32Return = true;
85 }
86 // Mips, on the other hand, needs signext on i32 parameters corresponding
87 // to both signed and unsigned ints.
Alexander Richardsone8508362018-06-25 16:49:20 +000088 if (T.isMIPS()) {
Marcin Koscielnickib76c6d32016-11-21 20:20:39 +000089 ShouldSignExtI32Param = true;
90 }
91 TLI.setShouldExtI32Param(ShouldExtI32Param);
92 TLI.setShouldExtI32Return(ShouldExtI32Return);
93 TLI.setShouldSignExtI32Param(ShouldSignExtI32Param);
94
Nicolai Hahnle44c3e262015-12-15 17:24:15 +000095 if (T.getArch() == Triple::r600 ||
96 T.getArch() == Triple::amdgcn) {
David L. Jones32028c82017-01-23 23:16:46 +000097 TLI.setUnavailable(LibFunc_ldexp);
98 TLI.setUnavailable(LibFunc_ldexpf);
99 TLI.setUnavailable(LibFunc_ldexpl);
100 TLI.setUnavailable(LibFunc_exp10);
101 TLI.setUnavailable(LibFunc_exp10f);
102 TLI.setUnavailable(LibFunc_exp10l);
103 TLI.setUnavailable(LibFunc_log10);
104 TLI.setUnavailable(LibFunc_log10f);
105 TLI.setUnavailable(LibFunc_log10l);
Nicolai Hahnle44c3e262015-12-15 17:24:15 +0000106 }
107
Tom Stellardd83c5952015-01-07 01:17:37 +0000108 // There are no library implementations of mempcy and memset for AMD gpus and
Tom Stellardadb852d2014-04-02 19:53:29 +0000109 // these can be difficult to lower in the backend.
Tom Stellardd83c5952015-01-07 01:17:37 +0000110 if (T.getArch() == Triple::r600 ||
Dan Gohmanb2c08be2016-01-19 14:49:23 +0000111 T.getArch() == Triple::amdgcn) {
David L. Jones32028c82017-01-23 23:16:46 +0000112 TLI.setUnavailable(LibFunc_memcpy);
113 TLI.setUnavailable(LibFunc_memset);
114 TLI.setUnavailable(LibFunc_memset_pattern16);
Tom Stellardadb852d2014-04-02 19:53:29 +0000115 return;
116 }
117
Nico Weberf456d372014-03-07 18:08:54 +0000118 // memset_pattern16 is only available on iOS 3.0 and Mac OS X 10.5 and later.
Tim Northover7b7ff9e2015-10-28 22:51:16 +0000119 // All versions of watchOS support it.
Daniel Dunbar558692f2011-04-20 00:14:25 +0000120 if (T.isMacOSX()) {
David Bolvanskycb037ef2018-05-16 11:39:52 +0000121 // available IO unlocked variants on Mac OS X
122 TLI.setAvailable(LibFunc_getc_unlocked);
123 TLI.setAvailable(LibFunc_getchar_unlocked);
124 TLI.setAvailable(LibFunc_putc_unlocked);
125 TLI.setAvailable(LibFunc_putchar_unlocked);
126
Daniel Dunbar558692f2011-04-20 00:14:25 +0000127 if (T.isMacOSXVersionLT(10, 5))
David L. Jones32028c82017-01-23 23:16:46 +0000128 TLI.setUnavailable(LibFunc_memset_pattern16);
Cameron Esfahani441c5572013-08-29 20:23:14 +0000129 } else if (T.isiOS()) {
Daniel Dunbar13fb3b52011-04-19 20:44:08 +0000130 if (T.isOSVersionLT(3, 0))
David L. Jones32028c82017-01-23 23:16:46 +0000131 TLI.setUnavailable(LibFunc_memset_pattern16);
Tim Northover7b7ff9e2015-10-28 22:51:16 +0000132 } else if (!T.isWatchOS()) {
David L. Jones32028c82017-01-23 23:16:46 +0000133 TLI.setUnavailable(LibFunc_memset_pattern16);
Daniel Dunbar13fb3b52011-04-19 20:44:08 +0000134 }
Richard Osborne36498242011-03-03 13:17:51 +0000135
Bob Wilson208130f2013-11-03 06:48:38 +0000136 if (!hasSinCosPiStret(T)) {
David L. Jones32028c82017-01-23 23:16:46 +0000137 TLI.setUnavailable(LibFunc_sinpi);
138 TLI.setUnavailable(LibFunc_sinpif);
139 TLI.setUnavailable(LibFunc_cospi);
140 TLI.setUnavailable(LibFunc_cospif);
141 TLI.setUnavailable(LibFunc_sincospi_stret);
142 TLI.setUnavailable(LibFunc_sincospif_stret);
Bob Wilson208130f2013-11-03 06:48:38 +0000143 }
144
Eli Friedman9d434db2011-11-17 01:27:36 +0000145 if (T.isMacOSX() && T.getArch() == Triple::x86 &&
146 !T.isMacOSXVersionLT(10, 7)) {
147 // x86-32 OSX has a scheme where fwrite and fputs (and some other functions
148 // we don't care about) have two versions; on recent OSX, the one we want
149 // has a $UNIX2003 suffix. The two implementations are identical except
150 // for the return value in some edge cases. However, we don't want to
151 // generate code that depends on the old symbols.
David L. Jones32028c82017-01-23 23:16:46 +0000152 TLI.setAvailableWithName(LibFunc_fwrite, "fwrite$UNIX2003");
153 TLI.setAvailableWithName(LibFunc_fputs, "fputs$UNIX2003");
Eli Friedman9d434db2011-11-17 01:27:36 +0000154 }
155
Duncan Sands9fe88972011-06-09 11:11:45 +0000156 // iprintf and friends are only available on XCore and TCE.
157 if (T.getArch() != Triple::xcore && T.getArch() != Triple::tce) {
David L. Jones32028c82017-01-23 23:16:46 +0000158 TLI.setUnavailable(LibFunc_iprintf);
159 TLI.setUnavailable(LibFunc_siprintf);
160 TLI.setUnavailable(LibFunc_fiprintf);
Richard Osborne419454a2011-03-03 14:09:28 +0000161 }
Joe Groffd5bda5e2012-04-17 23:05:54 +0000162
Saleem Abdulrasool24ade3b2014-07-24 22:09:06 +0000163 if (T.isOSWindows() && !T.isOSCygMing()) {
Hans Wennborg8e09c6e2019-02-13 10:30:16 +0000164 // XXX: The earliest documentation available at the moment is for VS2015/VC19:
165 // https://docs.microsoft.com/en-us/cpp/c-runtime-library/floating-point-support?view=vs-2015
166 // XXX: In order to use an MSVCRT older than VC19,
167 // the specific library version must be explicit in the target triple,
168 // e.g., x86_64-pc-windows-msvc18.
169 bool hasPartialC99 = true;
170 if (T.isKnownWindowsMSVCEnvironment()) {
171 unsigned Major, Minor, Micro;
172 T.getEnvironmentVersion(Major, Minor, Micro);
173 hasPartialC99 = (Major == 0 || Major >= 19);
174 }
175
176 // Latest targets support C89 math functions, in part.
177 bool isARM = (T.getArch() == Triple::aarch64 ||
178 T.getArch() == Triple::arm);
179 bool hasPartialFloat = (isARM ||
180 T.getArch() == Triple::x86_64);
181
182 // Win32 does not support float C89 math functions, in general.
183 if (!hasPartialFloat) {
184 TLI.setUnavailable(LibFunc_acosf);
185 TLI.setUnavailable(LibFunc_asinf);
186 TLI.setUnavailable(LibFunc_atan2f);
187 TLI.setUnavailable(LibFunc_atanf);
188 TLI.setUnavailable(LibFunc_ceilf);
189 TLI.setUnavailable(LibFunc_cosf);
190 TLI.setUnavailable(LibFunc_coshf);
191 TLI.setUnavailable(LibFunc_expf);
192 TLI.setUnavailable(LibFunc_floorf);
193 TLI.setUnavailable(LibFunc_fmodf);
194 TLI.setUnavailable(LibFunc_log10f);
195 TLI.setUnavailable(LibFunc_logf);
196 TLI.setUnavailable(LibFunc_modff);
197 TLI.setUnavailable(LibFunc_powf);
198 TLI.setUnavailable(LibFunc_sinf);
199 TLI.setUnavailable(LibFunc_sinhf);
200 TLI.setUnavailable(LibFunc_sqrtf);
201 TLI.setUnavailable(LibFunc_tanf);
202 TLI.setUnavailable(LibFunc_tanhf);
203 }
204 if (!isARM)
205 TLI.setUnavailable(LibFunc_fabsf);
206 TLI.setUnavailable(LibFunc_frexpf);
207 TLI.setUnavailable(LibFunc_ldexpf);
208
209 // Win32 does not support long double C89 math functions.
David L. Jones32028c82017-01-23 23:16:46 +0000210 TLI.setUnavailable(LibFunc_acosl);
211 TLI.setUnavailable(LibFunc_asinl);
David L. Jones32028c82017-01-23 23:16:46 +0000212 TLI.setUnavailable(LibFunc_atan2l);
Hans Wennborg8e09c6e2019-02-13 10:30:16 +0000213 TLI.setUnavailable(LibFunc_atanl);
David L. Jones32028c82017-01-23 23:16:46 +0000214 TLI.setUnavailable(LibFunc_ceill);
David L. Jones32028c82017-01-23 23:16:46 +0000215 TLI.setUnavailable(LibFunc_cosl);
216 TLI.setUnavailable(LibFunc_coshl);
217 TLI.setUnavailable(LibFunc_expl);
David L. Jones32028c82017-01-23 23:16:46 +0000218 TLI.setUnavailable(LibFunc_fabsl);
219 TLI.setUnavailable(LibFunc_floorl);
David L. Jones32028c82017-01-23 23:16:46 +0000220 TLI.setUnavailable(LibFunc_fmodl);
221 TLI.setUnavailable(LibFunc_frexpl);
David L. Jones32028c82017-01-23 23:16:46 +0000222 TLI.setUnavailable(LibFunc_ldexpl);
Hans Wennborg8e09c6e2019-02-13 10:30:16 +0000223 TLI.setUnavailable(LibFunc_log10l);
David L. Jones32028c82017-01-23 23:16:46 +0000224 TLI.setUnavailable(LibFunc_logl);
225 TLI.setUnavailable(LibFunc_modfl);
226 TLI.setUnavailable(LibFunc_powl);
227 TLI.setUnavailable(LibFunc_sinl);
228 TLI.setUnavailable(LibFunc_sinhl);
229 TLI.setUnavailable(LibFunc_sqrtl);
230 TLI.setUnavailable(LibFunc_tanl);
231 TLI.setUnavailable(LibFunc_tanhl);
Joe Groffd5bda5e2012-04-17 23:05:54 +0000232
Hans Wennborg8e09c6e2019-02-13 10:30:16 +0000233 // Win32 does not fully support C99 math functions.
234 if (!hasPartialC99) {
235 TLI.setUnavailable(LibFunc_acosh);
236 TLI.setUnavailable(LibFunc_acoshf);
237 TLI.setUnavailable(LibFunc_asinh);
238 TLI.setUnavailable(LibFunc_asinhf);
239 TLI.setUnavailable(LibFunc_atanh);
240 TLI.setUnavailable(LibFunc_atanhf);
241 TLI.setAvailableWithName(LibFunc_cabs, "_cabs");
242 TLI.setUnavailable(LibFunc_cabsf);
243 TLI.setUnavailable(LibFunc_cbrt);
244 TLI.setUnavailable(LibFunc_cbrtf);
245 TLI.setAvailableWithName(LibFunc_copysign, "_copysign");
246 TLI.setAvailableWithName(LibFunc_copysignf, "_copysignf");
247 TLI.setUnavailable(LibFunc_exp2);
248 TLI.setUnavailable(LibFunc_exp2f);
249 TLI.setUnavailable(LibFunc_expm1);
250 TLI.setUnavailable(LibFunc_expm1f);
251 TLI.setUnavailable(LibFunc_fmax);
David L. Jones32028c82017-01-23 23:16:46 +0000252 TLI.setUnavailable(LibFunc_fmaxf);
Hans Wennborg8e09c6e2019-02-13 10:30:16 +0000253 TLI.setUnavailable(LibFunc_fmin);
254 TLI.setUnavailable(LibFunc_fminf);
255 TLI.setUnavailable(LibFunc_log1p);
256 TLI.setUnavailable(LibFunc_log1pf);
257 TLI.setUnavailable(LibFunc_log2);
258 TLI.setUnavailable(LibFunc_log2f);
259 TLI.setAvailableWithName(LibFunc_logb, "_logb");
260 if (hasPartialFloat)
261 TLI.setAvailableWithName(LibFunc_logbf, "_logbf");
262 else
263 TLI.setUnavailable(LibFunc_logbf);
264 TLI.setUnavailable(LibFunc_rint);
265 TLI.setUnavailable(LibFunc_rintf);
266 TLI.setUnavailable(LibFunc_round);
267 TLI.setUnavailable(LibFunc_roundf);
268 TLI.setUnavailable(LibFunc_trunc);
269 TLI.setUnavailable(LibFunc_truncf);
Joe Groffd5bda5e2012-04-17 23:05:54 +0000270 }
Meador Inge939f5002012-11-10 03:11:06 +0000271
Hans Wennborg8e09c6e2019-02-13 10:30:16 +0000272 // Win32 does not support long double C99 math functions.
273 TLI.setUnavailable(LibFunc_acoshl);
274 TLI.setUnavailable(LibFunc_asinhl);
275 TLI.setUnavailable(LibFunc_atanhl);
276 TLI.setUnavailable(LibFunc_cabsl);
277 TLI.setUnavailable(LibFunc_cbrtl);
278 TLI.setUnavailable(LibFunc_copysignl);
279 TLI.setUnavailable(LibFunc_exp2l);
280 TLI.setUnavailable(LibFunc_expm1l);
281 TLI.setUnavailable(LibFunc_fmaxl);
282 TLI.setUnavailable(LibFunc_fminl);
283 TLI.setUnavailable(LibFunc_log1pl);
284 TLI.setUnavailable(LibFunc_log2l);
285 TLI.setUnavailable(LibFunc_logbl);
286 TLI.setUnavailable(LibFunc_nearbyintl);
287 TLI.setUnavailable(LibFunc_rintl);
288 TLI.setUnavailable(LibFunc_roundl);
289 TLI.setUnavailable(LibFunc_truncl);
290
291 // Win32 does not support these functions, but
292 // they are generally available on POSIX-compliant systems.
David L. Jones32028c82017-01-23 23:16:46 +0000293 TLI.setUnavailable(LibFunc_access);
294 TLI.setUnavailable(LibFunc_bcmp);
295 TLI.setUnavailable(LibFunc_bcopy);
296 TLI.setUnavailable(LibFunc_bzero);
297 TLI.setUnavailable(LibFunc_chmod);
298 TLI.setUnavailable(LibFunc_chown);
299 TLI.setUnavailable(LibFunc_closedir);
300 TLI.setUnavailable(LibFunc_ctermid);
301 TLI.setUnavailable(LibFunc_fdopen);
302 TLI.setUnavailable(LibFunc_ffs);
303 TLI.setUnavailable(LibFunc_fileno);
304 TLI.setUnavailable(LibFunc_flockfile);
305 TLI.setUnavailable(LibFunc_fseeko);
306 TLI.setUnavailable(LibFunc_fstat);
307 TLI.setUnavailable(LibFunc_fstatvfs);
308 TLI.setUnavailable(LibFunc_ftello);
309 TLI.setUnavailable(LibFunc_ftrylockfile);
310 TLI.setUnavailable(LibFunc_funlockfile);
David L. Jones32028c82017-01-23 23:16:46 +0000311 TLI.setUnavailable(LibFunc_getitimer);
312 TLI.setUnavailable(LibFunc_getlogin_r);
313 TLI.setUnavailable(LibFunc_getpwnam);
314 TLI.setUnavailable(LibFunc_gettimeofday);
315 TLI.setUnavailable(LibFunc_htonl);
316 TLI.setUnavailable(LibFunc_htons);
317 TLI.setUnavailable(LibFunc_lchown);
318 TLI.setUnavailable(LibFunc_lstat);
319 TLI.setUnavailable(LibFunc_memccpy);
320 TLI.setUnavailable(LibFunc_mkdir);
321 TLI.setUnavailable(LibFunc_ntohl);
322 TLI.setUnavailable(LibFunc_ntohs);
323 TLI.setUnavailable(LibFunc_open);
324 TLI.setUnavailable(LibFunc_opendir);
325 TLI.setUnavailable(LibFunc_pclose);
326 TLI.setUnavailable(LibFunc_popen);
327 TLI.setUnavailable(LibFunc_pread);
328 TLI.setUnavailable(LibFunc_pwrite);
329 TLI.setUnavailable(LibFunc_read);
330 TLI.setUnavailable(LibFunc_readlink);
331 TLI.setUnavailable(LibFunc_realpath);
332 TLI.setUnavailable(LibFunc_rmdir);
333 TLI.setUnavailable(LibFunc_setitimer);
334 TLI.setUnavailable(LibFunc_stat);
335 TLI.setUnavailable(LibFunc_statvfs);
336 TLI.setUnavailable(LibFunc_stpcpy);
337 TLI.setUnavailable(LibFunc_stpncpy);
338 TLI.setUnavailable(LibFunc_strcasecmp);
339 TLI.setUnavailable(LibFunc_strncasecmp);
340 TLI.setUnavailable(LibFunc_times);
341 TLI.setUnavailable(LibFunc_uname);
342 TLI.setUnavailable(LibFunc_unlink);
343 TLI.setUnavailable(LibFunc_unsetenv);
344 TLI.setUnavailable(LibFunc_utime);
345 TLI.setUnavailable(LibFunc_utimes);
346 TLI.setUnavailable(LibFunc_write);
Meador Inge6098c6b2012-11-22 15:36:42 +0000347 }
348
Reid Kleckner52b16232013-12-26 19:17:04 +0000349 switch (T.getOS()) {
Reid Kleckner52b16232013-12-26 19:17:04 +0000350 case Triple::MacOSX:
Chandler Carruth92ffb672013-12-28 02:40:19 +0000351 // exp10 and exp10f are not available on OS X until 10.9 and iOS until 7.0
352 // and their names are __exp10 and __exp10f. exp10l is not available on
353 // OS X or iOS.
David L. Jones32028c82017-01-23 23:16:46 +0000354 TLI.setUnavailable(LibFunc_exp10l);
Reid Kleckner52b16232013-12-26 19:17:04 +0000355 if (T.isMacOSXVersionLT(10, 9)) {
David L. Jones32028c82017-01-23 23:16:46 +0000356 TLI.setUnavailable(LibFunc_exp10);
357 TLI.setUnavailable(LibFunc_exp10f);
Reid Kleckner52b16232013-12-26 19:17:04 +0000358 } else {
David L. Jones32028c82017-01-23 23:16:46 +0000359 TLI.setAvailableWithName(LibFunc_exp10, "__exp10");
360 TLI.setAvailableWithName(LibFunc_exp10f, "__exp10f");
Reid Kleckner52b16232013-12-26 19:17:04 +0000361 }
362 break;
363 case Triple::IOS:
Tim Northover68eb8a52015-11-02 18:00:00 +0000364 case Triple::TvOS:
Tim Northover7b7ff9e2015-10-28 22:51:16 +0000365 case Triple::WatchOS:
David L. Jones32028c82017-01-23 23:16:46 +0000366 TLI.setUnavailable(LibFunc_exp10l);
Tim Northover7b7ff9e2015-10-28 22:51:16 +0000367 if (!T.isWatchOS() && (T.isOSVersionLT(7, 0) ||
368 (T.isOSVersionLT(9, 0) &&
369 (T.getArch() == Triple::x86 ||
370 T.getArch() == Triple::x86_64)))) {
David L. Jones32028c82017-01-23 23:16:46 +0000371 TLI.setUnavailable(LibFunc_exp10);
372 TLI.setUnavailable(LibFunc_exp10f);
Reid Kleckner52b16232013-12-26 19:17:04 +0000373 } else {
David L. Jones32028c82017-01-23 23:16:46 +0000374 TLI.setAvailableWithName(LibFunc_exp10, "__exp10");
375 TLI.setAvailableWithName(LibFunc_exp10f, "__exp10f");
Reid Kleckner52b16232013-12-26 19:17:04 +0000376 }
377 break;
Chandler Carruth92ffb672013-12-28 02:40:19 +0000378 case Triple::Linux:
379 // exp10, exp10f, exp10l is available on Linux (GLIBC) but are extremely
380 // buggy prior to glibc version 2.18. Until this version is widely deployed
381 // or we have a reasonable detection strategy, we cannot use exp10 reliably
382 // on Linux.
383 //
384 // Fall through to disable all of them.
Justin Bogner7d7a23e2016-08-17 20:30:52 +0000385 LLVM_FALLTHROUGH;
Reid Kleckner52b16232013-12-26 19:17:04 +0000386 default:
David L. Jones32028c82017-01-23 23:16:46 +0000387 TLI.setUnavailable(LibFunc_exp10);
388 TLI.setUnavailable(LibFunc_exp10f);
389 TLI.setUnavailable(LibFunc_exp10l);
Reid Kleckner52b16232013-12-26 19:17:04 +0000390 }
391
Meador Inge6098c6b2012-11-22 15:36:42 +0000392 // ffsl is available on at least Darwin, Mac OS X, iOS, FreeBSD, and
393 // Linux (GLIBC):
394 // http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/ffsl.3.html
Davide Italiano2511ece2015-11-01 17:00:13 +0000395 // http://svn.freebsd.org/base/head/lib/libc/string/ffsl.c
Meador Inge6098c6b2012-11-22 15:36:42 +0000396 // http://www.gnu.org/software/gnulib/manual/html_node/ffsl.html
397 switch (T.getOS()) {
398 case Triple::Darwin:
399 case Triple::MacOSX:
400 case Triple::IOS:
Tim Northover68eb8a52015-11-02 18:00:00 +0000401 case Triple::TvOS:
Tim Northover7b7ff9e2015-10-28 22:51:16 +0000402 case Triple::WatchOS:
Meador Inge6098c6b2012-11-22 15:36:42 +0000403 case Triple::FreeBSD:
404 case Triple::Linux:
405 break;
406 default:
David L. Jones32028c82017-01-23 23:16:46 +0000407 TLI.setUnavailable(LibFunc_ffsl);
Meador Inge6098c6b2012-11-22 15:36:42 +0000408 }
409
410 // ffsll is available on at least FreeBSD and Linux (GLIBC):
Davide Italiano2511ece2015-11-01 17:00:13 +0000411 // http://svn.freebsd.org/base/head/lib/libc/string/ffsll.c
Meador Inge6098c6b2012-11-22 15:36:42 +0000412 // http://www.gnu.org/software/gnulib/manual/html_node/ffsll.html
413 switch (T.getOS()) {
Tim Northover68eb8a52015-11-02 18:00:00 +0000414 case Triple::Darwin:
415 case Triple::MacOSX:
416 case Triple::IOS:
417 case Triple::TvOS:
418 case Triple::WatchOS:
Meador Inge6098c6b2012-11-22 15:36:42 +0000419 case Triple::FreeBSD:
420 case Triple::Linux:
421 break;
422 default:
David L. Jones32028c82017-01-23 23:16:46 +0000423 TLI.setUnavailable(LibFunc_ffsll);
Joe Groffd5bda5e2012-04-17 23:05:54 +0000424 }
Meador Ingecf705902013-03-05 21:47:40 +0000425
Davide Italiano36ee8db2015-11-09 23:23:20 +0000426 // The following functions are available on at least FreeBSD:
427 // http://svn.freebsd.org/base/head/lib/libc/string/fls.c
428 // http://svn.freebsd.org/base/head/lib/libc/string/flsl.c
429 // http://svn.freebsd.org/base/head/lib/libc/string/flsll.c
430 if (!T.isOSFreeBSD()) {
David L. Jones32028c82017-01-23 23:16:46 +0000431 TLI.setUnavailable(LibFunc_fls);
432 TLI.setUnavailable(LibFunc_flsl);
433 TLI.setUnavailable(LibFunc_flsll);
Davide Italiano36ee8db2015-11-09 23:23:20 +0000434 }
435
Eli Friedmand9f217d2018-11-06 18:23:32 +0000436 // The following functions are only available on GNU/Linux (using glibc).
437 // Linux variants without glibc (eg: bionic, musl) may have some subset.
438 if (!T.isOSLinux() || !T.isGNUEnvironment()) {
David L. Jones32028c82017-01-23 23:16:46 +0000439 TLI.setUnavailable(LibFunc_dunder_strdup);
440 TLI.setUnavailable(LibFunc_dunder_strtok_r);
441 TLI.setUnavailable(LibFunc_dunder_isoc99_scanf);
442 TLI.setUnavailable(LibFunc_dunder_isoc99_sscanf);
443 TLI.setUnavailable(LibFunc_under_IO_getc);
444 TLI.setUnavailable(LibFunc_under_IO_putc);
Eli Friedmand9f217d2018-11-06 18:23:32 +0000445 // But, Android and musl have memalign.
446 if (!T.isAndroid() && !T.isMusl())
Chih-Hung Hsieha0ae1f82018-01-31 19:12:50 +0000447 TLI.setUnavailable(LibFunc_memalign);
David L. Jones32028c82017-01-23 23:16:46 +0000448 TLI.setUnavailable(LibFunc_fopen64);
449 TLI.setUnavailable(LibFunc_fseeko64);
450 TLI.setUnavailable(LibFunc_fstat64);
451 TLI.setUnavailable(LibFunc_fstatvfs64);
452 TLI.setUnavailable(LibFunc_ftello64);
453 TLI.setUnavailable(LibFunc_lstat64);
454 TLI.setUnavailable(LibFunc_open64);
455 TLI.setUnavailable(LibFunc_stat64);
456 TLI.setUnavailable(LibFunc_statvfs64);
457 TLI.setUnavailable(LibFunc_tmpfile64);
Sanjay Patelcc2e1c22018-01-08 17:38:09 +0000458
459 // Relaxed math functions are included in math-finite.h on Linux (GLIBC).
460 TLI.setUnavailable(LibFunc_acos_finite);
461 TLI.setUnavailable(LibFunc_acosf_finite);
462 TLI.setUnavailable(LibFunc_acosl_finite);
463 TLI.setUnavailable(LibFunc_acosh_finite);
464 TLI.setUnavailable(LibFunc_acoshf_finite);
465 TLI.setUnavailable(LibFunc_acoshl_finite);
466 TLI.setUnavailable(LibFunc_asin_finite);
467 TLI.setUnavailable(LibFunc_asinf_finite);
468 TLI.setUnavailable(LibFunc_asinl_finite);
469 TLI.setUnavailable(LibFunc_atan2_finite);
470 TLI.setUnavailable(LibFunc_atan2f_finite);
471 TLI.setUnavailable(LibFunc_atan2l_finite);
472 TLI.setUnavailable(LibFunc_atanh_finite);
473 TLI.setUnavailable(LibFunc_atanhf_finite);
474 TLI.setUnavailable(LibFunc_atanhl_finite);
475 TLI.setUnavailable(LibFunc_cosh_finite);
476 TLI.setUnavailable(LibFunc_coshf_finite);
477 TLI.setUnavailable(LibFunc_coshl_finite);
478 TLI.setUnavailable(LibFunc_exp10_finite);
479 TLI.setUnavailable(LibFunc_exp10f_finite);
480 TLI.setUnavailable(LibFunc_exp10l_finite);
481 TLI.setUnavailable(LibFunc_exp2_finite);
482 TLI.setUnavailable(LibFunc_exp2f_finite);
483 TLI.setUnavailable(LibFunc_exp2l_finite);
484 TLI.setUnavailable(LibFunc_exp_finite);
485 TLI.setUnavailable(LibFunc_expf_finite);
486 TLI.setUnavailable(LibFunc_expl_finite);
487 TLI.setUnavailable(LibFunc_log10_finite);
488 TLI.setUnavailable(LibFunc_log10f_finite);
489 TLI.setUnavailable(LibFunc_log10l_finite);
490 TLI.setUnavailable(LibFunc_log2_finite);
491 TLI.setUnavailable(LibFunc_log2f_finite);
492 TLI.setUnavailable(LibFunc_log2l_finite);
493 TLI.setUnavailable(LibFunc_log_finite);
494 TLI.setUnavailable(LibFunc_logf_finite);
495 TLI.setUnavailable(LibFunc_logl_finite);
496 TLI.setUnavailable(LibFunc_pow_finite);
497 TLI.setUnavailable(LibFunc_powf_finite);
498 TLI.setUnavailable(LibFunc_powl_finite);
499 TLI.setUnavailable(LibFunc_sinh_finite);
500 TLI.setUnavailable(LibFunc_sinhf_finite);
501 TLI.setUnavailable(LibFunc_sinhl_finite);
Meador Ingecf705902013-03-05 21:47:40 +0000502 }
Michael Zolotukhin58506022015-03-17 19:50:55 +0000503
Martin Storsjoa925a3b2018-05-17 08:16:08 +0000504 if ((T.isOSLinux() && T.isGNUEnvironment()) ||
505 (T.isAndroid() && !T.isAndroidVersionLT(28))) {
David Bolvanskycb037ef2018-05-16 11:39:52 +0000506 // available IO unlocked variants on GNU/Linux and Android P or later
507 TLI.setAvailable(LibFunc_getc_unlocked);
508 TLI.setAvailable(LibFunc_getchar_unlocked);
509 TLI.setAvailable(LibFunc_putc_unlocked);
510 TLI.setAvailable(LibFunc_putchar_unlocked);
511 TLI.setAvailable(LibFunc_fputc_unlocked);
512 TLI.setAvailable(LibFunc_fgetc_unlocked);
513 TLI.setAvailable(LibFunc_fread_unlocked);
514 TLI.setAvailable(LibFunc_fwrite_unlocked);
515 TLI.setAvailable(LibFunc_fputs_unlocked);
516 TLI.setAvailable(LibFunc_fgets_unlocked);
517 }
518
Justin Lebarda5ebe52016-01-26 23:51:06 +0000519 // As currently implemented in clang, NVPTX code has no standard library to
520 // speak of. Headers provide a standard-ish library implementation, but many
521 // of the signatures are wrong -- for example, many libm functions are not
522 // extern "C".
523 //
524 // libdevice, an IR library provided by nvidia, is linked in by the front-end,
525 // but only used functions are provided to llvm. Moreover, most of the
526 // functions in libdevice don't map precisely to standard library functions.
527 //
528 // FIXME: Having no standard library prevents e.g. many fastmath
529 // optimizations, so this situation should be fixed.
David Majnemer54136ef2016-03-31 21:29:57 +0000530 if (T.isNVPTX()) {
Justin Lebarda5ebe52016-01-26 23:51:06 +0000531 TLI.disableAllFunctions();
David L. Jones32028c82017-01-23 23:16:46 +0000532 TLI.setAvailable(LibFunc_nvvm_reflect);
David Majnemer54136ef2016-03-31 21:29:57 +0000533 } else {
David L. Jones32028c82017-01-23 23:16:46 +0000534 TLI.setUnavailable(LibFunc_nvvm_reflect);
David Majnemer54136ef2016-03-31 21:29:57 +0000535 }
Justin Lebarda5ebe52016-01-26 23:51:06 +0000536
Michael Zolotukhin58506022015-03-17 19:50:55 +0000537 TLI.addVectorizableFunctionsFromVecLib(ClVectorLibrary);
Chris Lattnerce991202011-02-18 21:50:34 +0000538}
539
Chandler Carruth6f409cb2015-01-24 02:06:09 +0000540TargetLibraryInfoImpl::TargetLibraryInfoImpl() {
Chris Lattnerce991202011-02-18 21:50:34 +0000541 // Default to everything being available.
542 memset(AvailableArray, -1, sizeof(AvailableArray));
543
Bob Wilsond1e672e2012-08-03 04:06:22 +0000544 initialize(*this, Triple(), StandardNames);
Chris Lattnerce991202011-02-18 21:50:34 +0000545}
546
Joel Jones9951b072018-11-24 07:26:55 +0000547TargetLibraryInfoImpl::TargetLibraryInfoImpl(const Triple &T) {
Chris Lattnerce991202011-02-18 21:50:34 +0000548 // Default to everything being available.
549 memset(AvailableArray, -1, sizeof(AvailableArray));
Chandler Carrutheeeec3c2015-01-15 10:41:28 +0000550
Bob Wilsond1e672e2012-08-03 04:06:22 +0000551 initialize(*this, T, StandardNames);
Chris Lattnerce991202011-02-18 21:50:34 +0000552}
Chris Lattner188a7e02011-02-18 22:34:03 +0000553
Chandler Carruth6f409cb2015-01-24 02:06:09 +0000554TargetLibraryInfoImpl::TargetLibraryInfoImpl(const TargetLibraryInfoImpl &TLI)
Joel Jones9951b072018-11-24 07:26:55 +0000555 : CustomNames(TLI.CustomNames), ShouldExtI32Param(TLI.ShouldExtI32Param),
Marcin Koscielnickiac9341f2016-11-21 11:57:11 +0000556 ShouldExtI32Return(TLI.ShouldExtI32Return),
557 ShouldSignExtI32Param(TLI.ShouldSignExtI32Param) {
Chris Lattner40f5fbc2011-05-21 20:09:13 +0000558 memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
Michael Zolotukhin06aab082015-03-17 19:22:30 +0000559 VectorDescs = TLI.VectorDescs;
560 ScalarDescs = TLI.ScalarDescs;
Chandler Carruthe2ffd022015-01-15 11:39:46 +0000561}
562
Chandler Carruth6f409cb2015-01-24 02:06:09 +0000563TargetLibraryInfoImpl::TargetLibraryInfoImpl(TargetLibraryInfoImpl &&TLI)
Joel Jones9951b072018-11-24 07:26:55 +0000564 : CustomNames(std::move(TLI.CustomNames)),
Marcin Koscielnickiac9341f2016-11-21 11:57:11 +0000565 ShouldExtI32Param(TLI.ShouldExtI32Param),
566 ShouldExtI32Return(TLI.ShouldExtI32Return),
567 ShouldSignExtI32Param(TLI.ShouldSignExtI32Param) {
Chandler Carruthe2ffd022015-01-15 11:39:46 +0000568 std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),
569 AvailableArray);
Michael Zolotukhin06aab082015-03-17 19:22:30 +0000570 VectorDescs = TLI.VectorDescs;
571 ScalarDescs = TLI.ScalarDescs;
Chandler Carruthe2ffd022015-01-15 11:39:46 +0000572}
573
Chandler Carruth6f409cb2015-01-24 02:06:09 +0000574TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(const TargetLibraryInfoImpl &TLI) {
Eli Friedman9d434db2011-11-17 01:27:36 +0000575 CustomNames = TLI.CustomNames;
Marcin Koscielnickiac9341f2016-11-21 11:57:11 +0000576 ShouldExtI32Param = TLI.ShouldExtI32Param;
577 ShouldExtI32Return = TLI.ShouldExtI32Return;
578 ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;
Chandler Carruthe2ffd022015-01-15 11:39:46 +0000579 memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
580 return *this;
581}
582
Chandler Carruth6f409cb2015-01-24 02:06:09 +0000583TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(TargetLibraryInfoImpl &&TLI) {
Chandler Carruthe2ffd022015-01-15 11:39:46 +0000584 CustomNames = std::move(TLI.CustomNames);
Marcin Koscielnickiac9341f2016-11-21 11:57:11 +0000585 ShouldExtI32Param = TLI.ShouldExtI32Param;
586 ShouldExtI32Return = TLI.ShouldExtI32Return;
587 ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;
Chandler Carruthe2ffd022015-01-15 11:39:46 +0000588 std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),
589 AvailableArray);
590 return *this;
Chris Lattner40f5fbc2011-05-21 20:09:13 +0000591}
592
Michael Zolotukhina6f1fd62015-03-02 23:24:40 +0000593static StringRef sanitizeFunctionName(StringRef funcName) {
Benjamin Kramer576f62c2013-03-09 13:48:23 +0000594 // Filter out empty names and names containing null bytes, those can't be in
595 // our table.
596 if (funcName.empty() || funcName.find('\0') != StringRef::npos)
Michael Zolotukhina6f1fd62015-03-02 23:24:40 +0000597 return StringRef();
Benjamin Kramer576f62c2013-03-09 13:48:23 +0000598
Meador Ingecf705902013-03-05 21:47:40 +0000599 // Check for \01 prefix that is used to mangle __asm declarations and
600 // strip it if present.
Peter Collingbourne6ba81f22017-05-16 00:39:01 +0000601 return GlobalValue::dropLLVMManglingEscape(funcName);
Michael Zolotukhina6f1fd62015-03-02 23:24:40 +0000602}
603
604bool TargetLibraryInfoImpl::getLibFunc(StringRef funcName,
David L. Jones32028c82017-01-23 23:16:46 +0000605 LibFunc &F) const {
Mehdi Amini5e07fb32016-10-01 03:10:48 +0000606 StringRef const *Start = &StandardNames[0];
David L. Jones32028c82017-01-23 23:16:46 +0000607 StringRef const *End = &StandardNames[NumLibFuncs];
Michael Zolotukhina6f1fd62015-03-02 23:24:40 +0000608
609 funcName = sanitizeFunctionName(funcName);
610 if (funcName.empty())
611 return false;
612
Mehdi Amini5e07fb32016-10-01 03:10:48 +0000613 StringRef const *I = std::lower_bound(
614 Start, End, funcName, [](StringRef LHS, StringRef RHS) {
615 return LHS < RHS;
Michael Zolotukhinf0274542015-03-02 20:50:08 +0000616 });
Bob Wilsond1e672e2012-08-03 04:06:22 +0000617 if (I != End && *I == funcName) {
David L. Jones32028c82017-01-23 23:16:46 +0000618 F = (LibFunc)(I - Start);
Bob Wilsond1e672e2012-08-03 04:06:22 +0000619 return true;
620 }
621 return false;
622}
Chris Lattner40f5fbc2011-05-21 20:09:13 +0000623
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000624bool TargetLibraryInfoImpl::isValidProtoForLibFunc(const FunctionType &FTy,
David L. Jones32028c82017-01-23 23:16:46 +0000625 LibFunc F,
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000626 const DataLayout *DL) const {
627 LLVMContext &Ctx = FTy.getContext();
628 Type *PCharTy = Type::getInt8PtrTy(Ctx);
629 Type *SizeTTy = DL ? DL->getIntPtrType(Ctx, /*AS=*/0) : nullptr;
630 auto IsSizeTTy = [SizeTTy](Type *Ty) {
631 return SizeTTy ? Ty == SizeTTy : Ty->isIntegerTy();
632 };
633 unsigned NumParams = FTy.getNumParams();
634
635 switch (F) {
Calixte Denizetbb746322018-11-07 13:49:17 +0000636 case LibFunc_execl:
637 case LibFunc_execlp:
Calixte Denizet5cd01d92018-11-07 14:46:26 +0000638 case LibFunc_execle:
Calixte Denizetbb746322018-11-07 13:49:17 +0000639 return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
640 FTy.getParamType(1)->isPointerTy() &&
641 FTy.getReturnType()->isIntegerTy(32));
Calixte Denizetbb746322018-11-07 13:49:17 +0000642 case LibFunc_execv:
643 case LibFunc_execvp:
644 return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
645 FTy.getParamType(1)->isPointerTy() &&
646 FTy.getReturnType()->isIntegerTy(32));
647 case LibFunc_execvP:
648 case LibFunc_execvpe:
649 case LibFunc_execve:
650 return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() &&
651 FTy.getParamType(1)->isPointerTy() &&
652 FTy.getParamType(2)->isPointerTy() &&
653 FTy.getReturnType()->isIntegerTy(32));
David L. Jones32028c82017-01-23 23:16:46 +0000654 case LibFunc_strlen:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000655 return (NumParams == 1 && FTy.getParamType(0)->isPointerTy() &&
656 FTy.getReturnType()->isIntegerTy());
657
David L. Jones32028c82017-01-23 23:16:46 +0000658 case LibFunc_strchr:
659 case LibFunc_strrchr:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000660 return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
661 FTy.getParamType(0) == FTy.getReturnType() &&
662 FTy.getParamType(1)->isIntegerTy());
663
David L. Jones32028c82017-01-23 23:16:46 +0000664 case LibFunc_strtol:
665 case LibFunc_strtod:
666 case LibFunc_strtof:
667 case LibFunc_strtoul:
668 case LibFunc_strtoll:
669 case LibFunc_strtold:
670 case LibFunc_strtoull:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000671 return ((NumParams == 2 || NumParams == 3) &&
672 FTy.getParamType(0)->isPointerTy() &&
673 FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000674 case LibFunc_strcat:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000675 return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
676 FTy.getParamType(0) == FTy.getReturnType() &&
677 FTy.getParamType(1) == FTy.getReturnType());
678
David L. Jones32028c82017-01-23 23:16:46 +0000679 case LibFunc_strncat:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000680 return (NumParams == 3 && FTy.getReturnType()->isPointerTy() &&
681 FTy.getParamType(0) == FTy.getReturnType() &&
682 FTy.getParamType(1) == FTy.getReturnType() &&
Igor Laevskyb8874952017-12-18 10:31:58 +0000683 IsSizeTTy(FTy.getParamType(2)));
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000684
David L. Jones32028c82017-01-23 23:16:46 +0000685 case LibFunc_strcpy_chk:
686 case LibFunc_stpcpy_chk:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000687 --NumParams;
688 if (!IsSizeTTy(FTy.getParamType(NumParams)))
689 return false;
Justin Bogner6673ea82016-08-17 05:10:15 +0000690 LLVM_FALLTHROUGH;
David L. Jones32028c82017-01-23 23:16:46 +0000691 case LibFunc_strcpy:
692 case LibFunc_stpcpy:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000693 return (NumParams == 2 && FTy.getReturnType() == FTy.getParamType(0) &&
694 FTy.getParamType(0) == FTy.getParamType(1) &&
695 FTy.getParamType(0) == PCharTy);
696
David L. Jones32028c82017-01-23 23:16:46 +0000697 case LibFunc_strncpy_chk:
698 case LibFunc_stpncpy_chk:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000699 --NumParams;
700 if (!IsSizeTTy(FTy.getParamType(NumParams)))
701 return false;
Justin Bogner6673ea82016-08-17 05:10:15 +0000702 LLVM_FALLTHROUGH;
David L. Jones32028c82017-01-23 23:16:46 +0000703 case LibFunc_strncpy:
704 case LibFunc_stpncpy:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000705 return (NumParams == 3 && FTy.getReturnType() == FTy.getParamType(0) &&
706 FTy.getParamType(0) == FTy.getParamType(1) &&
707 FTy.getParamType(0) == PCharTy &&
Igor Laevskyb8874952017-12-18 10:31:58 +0000708 IsSizeTTy(FTy.getParamType(2)));
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000709
David L. Jones32028c82017-01-23 23:16:46 +0000710 case LibFunc_strxfrm:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000711 return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() &&
712 FTy.getParamType(1)->isPointerTy());
713
David L. Jones32028c82017-01-23 23:16:46 +0000714 case LibFunc_strcmp:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000715 return (NumParams == 2 && FTy.getReturnType()->isIntegerTy(32) &&
716 FTy.getParamType(0)->isPointerTy() &&
717 FTy.getParamType(0) == FTy.getParamType(1));
718
David L. Jones32028c82017-01-23 23:16:46 +0000719 case LibFunc_strncmp:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000720 return (NumParams == 3 && FTy.getReturnType()->isIntegerTy(32) &&
721 FTy.getParamType(0)->isPointerTy() &&
722 FTy.getParamType(0) == FTy.getParamType(1) &&
Igor Laevskyb8874952017-12-18 10:31:58 +0000723 IsSizeTTy(FTy.getParamType(2)));
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000724
David L. Jones32028c82017-01-23 23:16:46 +0000725 case LibFunc_strspn:
726 case LibFunc_strcspn:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000727 return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
728 FTy.getParamType(0) == FTy.getParamType(1) &&
729 FTy.getReturnType()->isIntegerTy());
730
David L. Jones32028c82017-01-23 23:16:46 +0000731 case LibFunc_strcoll:
732 case LibFunc_strcasecmp:
733 case LibFunc_strncasecmp:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000734 return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
735 FTy.getParamType(1)->isPointerTy());
736
David L. Jones32028c82017-01-23 23:16:46 +0000737 case LibFunc_strstr:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000738 return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
739 FTy.getParamType(0)->isPointerTy() &&
740 FTy.getParamType(1)->isPointerTy());
741
David L. Jones32028c82017-01-23 23:16:46 +0000742 case LibFunc_strpbrk:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000743 return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
744 FTy.getReturnType() == FTy.getParamType(0) &&
745 FTy.getParamType(0) == FTy.getParamType(1));
746
David L. Jones32028c82017-01-23 23:16:46 +0000747 case LibFunc_strtok:
748 case LibFunc_strtok_r:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000749 return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000750 case LibFunc_scanf:
751 case LibFunc_setbuf:
752 case LibFunc_setvbuf:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000753 return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000754 case LibFunc_strdup:
755 case LibFunc_strndup:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000756 return (NumParams >= 1 && FTy.getReturnType()->isPointerTy() &&
757 FTy.getParamType(0)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000758 case LibFunc_sscanf:
759 case LibFunc_stat:
760 case LibFunc_statvfs:
761 case LibFunc_siprintf:
762 case LibFunc_sprintf:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000763 return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
Martin Storsjod2bdcd62018-05-11 16:53:56 +0000764 FTy.getParamType(1)->isPointerTy() &&
765 FTy.getReturnType()->isIntegerTy(32));
David L. Jones32028c82017-01-23 23:16:46 +0000766 case LibFunc_snprintf:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000767 return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() &&
Martin Storsjod2bdcd62018-05-11 16:53:56 +0000768 FTy.getParamType(2)->isPointerTy() &&
769 FTy.getReturnType()->isIntegerTy(32));
David L. Jones32028c82017-01-23 23:16:46 +0000770 case LibFunc_setitimer:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000771 return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() &&
772 FTy.getParamType(2)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000773 case LibFunc_system:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000774 return (NumParams == 1 && FTy.getParamType(0)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000775 case LibFunc_malloc:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000776 return (NumParams == 1 && FTy.getReturnType()->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000777 case LibFunc_memcmp:
Ahmed Bougachabe550d02017-01-17 03:10:02 +0000778 return (NumParams == 3 && FTy.getReturnType()->isIntegerTy(32) &&
779 FTy.getParamType(0)->isPointerTy() &&
780 FTy.getParamType(1)->isPointerTy());
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000781
David L. Jones32028c82017-01-23 23:16:46 +0000782 case LibFunc_memchr:
783 case LibFunc_memrchr:
Ahmed Bougachabe550d02017-01-17 03:10:02 +0000784 return (NumParams == 3 && FTy.getReturnType()->isPointerTy() &&
785 FTy.getReturnType() == FTy.getParamType(0) &&
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000786 FTy.getParamType(1)->isIntegerTy(32) &&
Ahmed Bougachabe550d02017-01-17 03:10:02 +0000787 IsSizeTTy(FTy.getParamType(2)));
David L. Jones32028c82017-01-23 23:16:46 +0000788 case LibFunc_modf:
789 case LibFunc_modff:
790 case LibFunc_modfl:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000791 return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy());
792
David L. Jones32028c82017-01-23 23:16:46 +0000793 case LibFunc_memcpy_chk:
794 case LibFunc_memmove_chk:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000795 --NumParams;
796 if (!IsSizeTTy(FTy.getParamType(NumParams)))
797 return false;
Justin Bogner6673ea82016-08-17 05:10:15 +0000798 LLVM_FALLTHROUGH;
David L. Jones32028c82017-01-23 23:16:46 +0000799 case LibFunc_memcpy:
800 case LibFunc_mempcpy:
801 case LibFunc_memmove:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000802 return (NumParams == 3 && FTy.getReturnType() == FTy.getParamType(0) &&
803 FTy.getParamType(0)->isPointerTy() &&
804 FTy.getParamType(1)->isPointerTy() &&
805 IsSizeTTy(FTy.getParamType(2)));
806
David L. Jones32028c82017-01-23 23:16:46 +0000807 case LibFunc_memset_chk:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000808 --NumParams;
809 if (!IsSizeTTy(FTy.getParamType(NumParams)))
810 return false;
Justin Bogner6673ea82016-08-17 05:10:15 +0000811 LLVM_FALLTHROUGH;
David L. Jones32028c82017-01-23 23:16:46 +0000812 case LibFunc_memset:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000813 return (NumParams == 3 && FTy.getReturnType() == FTy.getParamType(0) &&
814 FTy.getParamType(0)->isPointerTy() &&
815 FTy.getParamType(1)->isIntegerTy() &&
816 IsSizeTTy(FTy.getParamType(2)));
817
David L. Jones32028c82017-01-23 23:16:46 +0000818 case LibFunc_memccpy:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000819 return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000820 case LibFunc_memalign:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000821 return (FTy.getReturnType()->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000822 case LibFunc_realloc:
823 case LibFunc_reallocf:
Ahmed Bougachabe550d02017-01-17 03:10:02 +0000824 return (NumParams == 2 && FTy.getReturnType() == PCharTy &&
825 FTy.getParamType(0) == FTy.getReturnType() &&
826 IsSizeTTy(FTy.getParamType(1)));
David L. Jones32028c82017-01-23 23:16:46 +0000827 case LibFunc_read:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000828 return (NumParams == 3 && FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000829 case LibFunc_rewind:
830 case LibFunc_rmdir:
831 case LibFunc_remove:
832 case LibFunc_realpath:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000833 return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000834 case LibFunc_rename:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000835 return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
836 FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000837 case LibFunc_readlink:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000838 return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
839 FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000840 case LibFunc_write:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000841 return (NumParams == 3 && FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000842 case LibFunc_bcopy:
843 case LibFunc_bcmp:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000844 return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() &&
845 FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000846 case LibFunc_bzero:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000847 return (NumParams == 2 && FTy.getParamType(0)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000848 case LibFunc_calloc:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000849 return (NumParams == 2 && FTy.getReturnType()->isPointerTy());
Ahmed Bougachac863f712016-05-25 20:22:45 +0000850
David L. Jones32028c82017-01-23 23:16:46 +0000851 case LibFunc_atof:
852 case LibFunc_atoi:
853 case LibFunc_atol:
854 case LibFunc_atoll:
855 case LibFunc_ferror:
856 case LibFunc_getenv:
857 case LibFunc_getpwnam:
858 case LibFunc_iprintf:
859 case LibFunc_pclose:
860 case LibFunc_perror:
861 case LibFunc_printf:
862 case LibFunc_puts:
863 case LibFunc_uname:
864 case LibFunc_under_IO_getc:
865 case LibFunc_unlink:
866 case LibFunc_unsetenv:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000867 return (NumParams == 1 && FTy.getParamType(0)->isPointerTy());
Ahmed Bougachac863f712016-05-25 20:22:45 +0000868
David L. Jones32028c82017-01-23 23:16:46 +0000869 case LibFunc_access:
870 case LibFunc_chmod:
871 case LibFunc_chown:
872 case LibFunc_clearerr:
873 case LibFunc_closedir:
874 case LibFunc_ctermid:
875 case LibFunc_fclose:
876 case LibFunc_feof:
877 case LibFunc_fflush:
878 case LibFunc_fgetc:
David Bolvanskycb037ef2018-05-16 11:39:52 +0000879 case LibFunc_fgetc_unlocked:
David L. Jones32028c82017-01-23 23:16:46 +0000880 case LibFunc_fileno:
881 case LibFunc_flockfile:
882 case LibFunc_free:
883 case LibFunc_fseek:
884 case LibFunc_fseeko64:
885 case LibFunc_fseeko:
886 case LibFunc_fsetpos:
887 case LibFunc_ftell:
888 case LibFunc_ftello64:
889 case LibFunc_ftello:
890 case LibFunc_ftrylockfile:
891 case LibFunc_funlockfile:
892 case LibFunc_getc:
893 case LibFunc_getc_unlocked:
894 case LibFunc_getlogin_r:
895 case LibFunc_mkdir:
896 case LibFunc_mktime:
897 case LibFunc_times:
Ahmed Bougachac863f712016-05-25 20:22:45 +0000898 return (NumParams != 0 && FTy.getParamType(0)->isPointerTy());
899
David L. Jones32028c82017-01-23 23:16:46 +0000900 case LibFunc_fopen:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000901 return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
902 FTy.getParamType(0)->isPointerTy() &&
903 FTy.getParamType(1)->isPointerTy());
Calixte Denizetbb746322018-11-07 13:49:17 +0000904 case LibFunc_fork:
905 return (NumParams == 0 && FTy.getReturnType()->isIntegerTy(32));
David L. Jones32028c82017-01-23 23:16:46 +0000906 case LibFunc_fdopen:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000907 return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
908 FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000909 case LibFunc_fputc:
David Bolvanskycb037ef2018-05-16 11:39:52 +0000910 case LibFunc_fputc_unlocked:
David L. Jones32028c82017-01-23 23:16:46 +0000911 case LibFunc_fstat:
912 case LibFunc_frexp:
913 case LibFunc_frexpf:
914 case LibFunc_frexpl:
915 case LibFunc_fstatvfs:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000916 return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000917 case LibFunc_fgets:
David Bolvanskycb037ef2018-05-16 11:39:52 +0000918 case LibFunc_fgets_unlocked:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000919 return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() &&
920 FTy.getParamType(2)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000921 case LibFunc_fread:
David Bolvanskycb037ef2018-05-16 11:39:52 +0000922 case LibFunc_fread_unlocked:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000923 return (NumParams == 4 && FTy.getParamType(0)->isPointerTy() &&
924 FTy.getParamType(3)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000925 case LibFunc_fwrite:
David Bolvanskycb037ef2018-05-16 11:39:52 +0000926 case LibFunc_fwrite_unlocked:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000927 return (NumParams == 4 && FTy.getReturnType()->isIntegerTy() &&
928 FTy.getParamType(0)->isPointerTy() &&
929 FTy.getParamType(1)->isIntegerTy() &&
930 FTy.getParamType(2)->isIntegerTy() &&
931 FTy.getParamType(3)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000932 case LibFunc_fputs:
David Bolvanskycb037ef2018-05-16 11:39:52 +0000933 case LibFunc_fputs_unlocked:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000934 return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
935 FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000936 case LibFunc_fscanf:
937 case LibFunc_fiprintf:
938 case LibFunc_fprintf:
Ahmed Bougachabe550d02017-01-17 03:10:02 +0000939 return (NumParams >= 2 && FTy.getReturnType()->isIntegerTy() &&
940 FTy.getParamType(0)->isPointerTy() &&
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000941 FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000942 case LibFunc_fgetpos:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000943 return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
944 FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000945 case LibFunc_getchar:
David Bolvanskycb037ef2018-05-16 11:39:52 +0000946 case LibFunc_getchar_unlocked:
Ahmed Bougachabe550d02017-01-17 03:10:02 +0000947 return (NumParams == 0 && FTy.getReturnType()->isIntegerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000948 case LibFunc_gets:
Ahmed Bougachabe550d02017-01-17 03:10:02 +0000949 return (NumParams == 1 && FTy.getParamType(0) == PCharTy);
David L. Jones32028c82017-01-23 23:16:46 +0000950 case LibFunc_getitimer:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000951 return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000952 case LibFunc_ungetc:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000953 return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000954 case LibFunc_utime:
955 case LibFunc_utimes:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000956 return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
957 FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000958 case LibFunc_putc:
David Bolvanskycb037ef2018-05-16 11:39:52 +0000959 case LibFunc_putc_unlocked:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000960 return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000961 case LibFunc_pread:
962 case LibFunc_pwrite:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000963 return (NumParams == 4 && FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000964 case LibFunc_popen:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000965 return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
966 FTy.getParamType(0)->isPointerTy() &&
967 FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000968 case LibFunc_vscanf:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000969 return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000970 case LibFunc_vsscanf:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000971 return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() &&
972 FTy.getParamType(2)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000973 case LibFunc_vfscanf:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000974 return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() &&
975 FTy.getParamType(2)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000976 case LibFunc_valloc:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000977 return (FTy.getReturnType()->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000978 case LibFunc_vprintf:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000979 return (NumParams == 2 && FTy.getParamType(0)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000980 case LibFunc_vfprintf:
981 case LibFunc_vsprintf:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000982 return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() &&
983 FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000984 case LibFunc_vsnprintf:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000985 return (NumParams == 4 && FTy.getParamType(0)->isPointerTy() &&
986 FTy.getParamType(2)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000987 case LibFunc_open:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000988 return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000989 case LibFunc_opendir:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000990 return (NumParams == 1 && FTy.getReturnType()->isPointerTy() &&
991 FTy.getParamType(0)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000992 case LibFunc_tmpfile:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +0000993 return (FTy.getReturnType()->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +0000994 case LibFunc_htonl:
995 case LibFunc_ntohl:
Ahmed Bougachabe550d02017-01-17 03:10:02 +0000996 return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(32) &&
997 FTy.getReturnType() == FTy.getParamType(0));
David L. Jones32028c82017-01-23 23:16:46 +0000998 case LibFunc_htons:
999 case LibFunc_ntohs:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001000 return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(16) &&
1001 FTy.getReturnType() == FTy.getParamType(0));
David L. Jones32028c82017-01-23 23:16:46 +00001002 case LibFunc_lstat:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001003 return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
1004 FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +00001005 case LibFunc_lchown:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001006 return (NumParams == 3 && FTy.getParamType(0)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +00001007 case LibFunc_qsort:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001008 return (NumParams == 4 && FTy.getParamType(3)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +00001009 case LibFunc_dunder_strdup:
1010 case LibFunc_dunder_strndup:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001011 return (NumParams >= 1 && FTy.getReturnType()->isPointerTy() &&
1012 FTy.getParamType(0)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +00001013 case LibFunc_dunder_strtok_r:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001014 return (NumParams == 3 && FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +00001015 case LibFunc_under_IO_putc:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001016 return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +00001017 case LibFunc_dunder_isoc99_scanf:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001018 return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +00001019 case LibFunc_stat64:
1020 case LibFunc_lstat64:
1021 case LibFunc_statvfs64:
Michael Kuperstein86978b72016-09-20 23:10:31 +00001022 return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001023 FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +00001024 case LibFunc_dunder_isoc99_sscanf:
Michael Kuperstein86978b72016-09-20 23:10:31 +00001025 return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001026 FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +00001027 case LibFunc_fopen64:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001028 return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
1029 FTy.getParamType(0)->isPointerTy() &&
1030 FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +00001031 case LibFunc_tmpfile64:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001032 return (FTy.getReturnType()->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +00001033 case LibFunc_fstat64:
1034 case LibFunc_fstatvfs64:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001035 return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +00001036 case LibFunc_open64:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001037 return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy());
David L. Jones32028c82017-01-23 23:16:46 +00001038 case LibFunc_gettimeofday:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001039 return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
1040 FTy.getParamType(1)->isPointerTy());
1041
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001042 // new(unsigned int);
David L. Jones32028c82017-01-23 23:16:46 +00001043 case LibFunc_Znwj:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001044 // new(unsigned long);
David L. Jones32028c82017-01-23 23:16:46 +00001045 case LibFunc_Znwm:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001046 // new[](unsigned int);
David L. Jones32028c82017-01-23 23:16:46 +00001047 case LibFunc_Znaj:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001048 // new[](unsigned long);
David L. Jones32028c82017-01-23 23:16:46 +00001049 case LibFunc_Znam:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001050 // new(unsigned int);
David L. Jones32028c82017-01-23 23:16:46 +00001051 case LibFunc_msvc_new_int:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001052 // new(unsigned long long);
David L. Jones32028c82017-01-23 23:16:46 +00001053 case LibFunc_msvc_new_longlong:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001054 // new[](unsigned int);
David L. Jones32028c82017-01-23 23:16:46 +00001055 case LibFunc_msvc_new_array_int:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001056 // new[](unsigned long long);
David L. Jones32028c82017-01-23 23:16:46 +00001057 case LibFunc_msvc_new_array_longlong:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001058 return (NumParams == 1 && FTy.getReturnType()->isPointerTy());
1059
1060 // new(unsigned int, nothrow);
David L. Jones32028c82017-01-23 23:16:46 +00001061 case LibFunc_ZnwjRKSt9nothrow_t:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001062 // new(unsigned long, nothrow);
David L. Jones32028c82017-01-23 23:16:46 +00001063 case LibFunc_ZnwmRKSt9nothrow_t:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001064 // new[](unsigned int, nothrow);
David L. Jones32028c82017-01-23 23:16:46 +00001065 case LibFunc_ZnajRKSt9nothrow_t:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001066 // new[](unsigned long, nothrow);
David L. Jones32028c82017-01-23 23:16:46 +00001067 case LibFunc_ZnamRKSt9nothrow_t:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001068 // new(unsigned int, nothrow);
David L. Jones32028c82017-01-23 23:16:46 +00001069 case LibFunc_msvc_new_int_nothrow:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001070 // new(unsigned long long, nothrow);
David L. Jones32028c82017-01-23 23:16:46 +00001071 case LibFunc_msvc_new_longlong_nothrow:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001072 // new[](unsigned int, nothrow);
David L. Jones32028c82017-01-23 23:16:46 +00001073 case LibFunc_msvc_new_array_int_nothrow:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001074 // new[](unsigned long long, nothrow);
David L. Jones32028c82017-01-23 23:16:46 +00001075 case LibFunc_msvc_new_array_longlong_nothrow:
Eric Fiselier75627b12018-04-04 19:01:51 +00001076 // new(unsigned int, align_val_t)
1077 case LibFunc_ZnwjSt11align_val_t:
1078 // new(unsigned long, align_val_t)
1079 case LibFunc_ZnwmSt11align_val_t:
1080 // new[](unsigned int, align_val_t)
1081 case LibFunc_ZnajSt11align_val_t:
1082 // new[](unsigned long, align_val_t)
1083 case LibFunc_ZnamSt11align_val_t:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001084 return (NumParams == 2 && FTy.getReturnType()->isPointerTy());
1085
Eric Fiselier75627b12018-04-04 19:01:51 +00001086 // new(unsigned int, align_val_t, nothrow)
1087 case LibFunc_ZnwjSt11align_val_tRKSt9nothrow_t:
1088 // new(unsigned long, align_val_t, nothrow)
1089 case LibFunc_ZnwmSt11align_val_tRKSt9nothrow_t:
1090 // new[](unsigned int, align_val_t, nothrow)
1091 case LibFunc_ZnajSt11align_val_tRKSt9nothrow_t:
1092 // new[](unsigned long, align_val_t, nothrow)
1093 case LibFunc_ZnamSt11align_val_tRKSt9nothrow_t:
1094 return (NumParams == 3 && FTy.getReturnType()->isPointerTy());
1095
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001096 // void operator delete[](void*);
David L. Jones32028c82017-01-23 23:16:46 +00001097 case LibFunc_ZdaPv:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001098 // void operator delete(void*);
David L. Jones32028c82017-01-23 23:16:46 +00001099 case LibFunc_ZdlPv:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001100 // void operator delete[](void*);
David L. Jones32028c82017-01-23 23:16:46 +00001101 case LibFunc_msvc_delete_array_ptr32:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001102 // void operator delete[](void*);
David L. Jones32028c82017-01-23 23:16:46 +00001103 case LibFunc_msvc_delete_array_ptr64:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001104 // void operator delete(void*);
David L. Jones32028c82017-01-23 23:16:46 +00001105 case LibFunc_msvc_delete_ptr32:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001106 // void operator delete(void*);
David L. Jones32028c82017-01-23 23:16:46 +00001107 case LibFunc_msvc_delete_ptr64:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001108 return (NumParams == 1 && FTy.getParamType(0)->isPointerTy());
1109
1110 // void operator delete[](void*, nothrow);
David L. Jones32028c82017-01-23 23:16:46 +00001111 case LibFunc_ZdaPvRKSt9nothrow_t:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001112 // void operator delete[](void*, unsigned int);
David L. Jones32028c82017-01-23 23:16:46 +00001113 case LibFunc_ZdaPvj:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001114 // void operator delete[](void*, unsigned long);
David L. Jones32028c82017-01-23 23:16:46 +00001115 case LibFunc_ZdaPvm:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001116 // void operator delete(void*, nothrow);
David L. Jones32028c82017-01-23 23:16:46 +00001117 case LibFunc_ZdlPvRKSt9nothrow_t:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001118 // void operator delete(void*, unsigned int);
David L. Jones32028c82017-01-23 23:16:46 +00001119 case LibFunc_ZdlPvj:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001120 // void operator delete(void*, unsigned long);
David L. Jones32028c82017-01-23 23:16:46 +00001121 case LibFunc_ZdlPvm:
Eric Fiselier75627b12018-04-04 19:01:51 +00001122 // void operator delete(void*, align_val_t)
1123 case LibFunc_ZdlPvSt11align_val_t:
1124 // void operator delete[](void*, align_val_t)
1125 case LibFunc_ZdaPvSt11align_val_t:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001126 // void operator delete[](void*, unsigned int);
David L. Jones32028c82017-01-23 23:16:46 +00001127 case LibFunc_msvc_delete_array_ptr32_int:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001128 // void operator delete[](void*, nothrow);
David L. Jones32028c82017-01-23 23:16:46 +00001129 case LibFunc_msvc_delete_array_ptr32_nothrow:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001130 // void operator delete[](void*, unsigned long long);
David L. Jones32028c82017-01-23 23:16:46 +00001131 case LibFunc_msvc_delete_array_ptr64_longlong:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001132 // void operator delete[](void*, nothrow);
David L. Jones32028c82017-01-23 23:16:46 +00001133 case LibFunc_msvc_delete_array_ptr64_nothrow:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001134 // void operator delete(void*, unsigned int);
David L. Jones32028c82017-01-23 23:16:46 +00001135 case LibFunc_msvc_delete_ptr32_int:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001136 // void operator delete(void*, nothrow);
David L. Jones32028c82017-01-23 23:16:46 +00001137 case LibFunc_msvc_delete_ptr32_nothrow:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001138 // void operator delete(void*, unsigned long long);
David L. Jones32028c82017-01-23 23:16:46 +00001139 case LibFunc_msvc_delete_ptr64_longlong:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001140 // void operator delete(void*, nothrow);
David L. Jones32028c82017-01-23 23:16:46 +00001141 case LibFunc_msvc_delete_ptr64_nothrow:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001142 return (NumParams == 2 && FTy.getParamType(0)->isPointerTy());
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001143
Eric Fiselier75627b12018-04-04 19:01:51 +00001144 // void operator delete(void*, align_val_t, nothrow)
1145 case LibFunc_ZdlPvSt11align_val_tRKSt9nothrow_t:
1146 // void operator delete[](void*, align_val_t, nothrow)
1147 case LibFunc_ZdaPvSt11align_val_tRKSt9nothrow_t:
1148 return (NumParams == 3 && FTy.getParamType(0)->isPointerTy());
1149
David L. Jones32028c82017-01-23 23:16:46 +00001150 case LibFunc_memset_pattern16:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001151 return (!FTy.isVarArg() && NumParams == 3 &&
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001152 FTy.getParamType(0)->isPointerTy() &&
1153 FTy.getParamType(1)->isPointerTy() &&
1154 FTy.getParamType(2)->isIntegerTy());
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001155
David L. Jones32028c82017-01-23 23:16:46 +00001156 case LibFunc_cxa_guard_abort:
1157 case LibFunc_cxa_guard_acquire:
1158 case LibFunc_cxa_guard_release:
1159 case LibFunc_nvvm_reflect:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001160 return (NumParams == 1 && FTy.getParamType(0)->isPointerTy());
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001161
David L. Jones32028c82017-01-23 23:16:46 +00001162 case LibFunc_sincospi_stret:
1163 case LibFunc_sincospif_stret:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001164 return (NumParams == 1 && FTy.getParamType(0)->isFloatingPointTy());
1165
David L. Jones32028c82017-01-23 23:16:46 +00001166 case LibFunc_acos:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001167 case LibFunc_acos_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001168 case LibFunc_acosf:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001169 case LibFunc_acosf_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001170 case LibFunc_acosh:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001171 case LibFunc_acosh_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001172 case LibFunc_acoshf:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001173 case LibFunc_acoshf_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001174 case LibFunc_acoshl:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001175 case LibFunc_acoshl_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001176 case LibFunc_acosl:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001177 case LibFunc_acosl_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001178 case LibFunc_asin:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001179 case LibFunc_asin_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001180 case LibFunc_asinf:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001181 case LibFunc_asinf_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001182 case LibFunc_asinh:
1183 case LibFunc_asinhf:
1184 case LibFunc_asinhl:
1185 case LibFunc_asinl:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001186 case LibFunc_asinl_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001187 case LibFunc_atan:
1188 case LibFunc_atanf:
1189 case LibFunc_atanh:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001190 case LibFunc_atanh_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001191 case LibFunc_atanhf:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001192 case LibFunc_atanhf_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001193 case LibFunc_atanhl:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001194 case LibFunc_atanhl_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001195 case LibFunc_atanl:
1196 case LibFunc_cbrt:
1197 case LibFunc_cbrtf:
1198 case LibFunc_cbrtl:
1199 case LibFunc_ceil:
1200 case LibFunc_ceilf:
1201 case LibFunc_ceill:
1202 case LibFunc_cos:
1203 case LibFunc_cosf:
1204 case LibFunc_cosh:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001205 case LibFunc_cosh_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001206 case LibFunc_coshf:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001207 case LibFunc_coshf_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001208 case LibFunc_coshl:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001209 case LibFunc_coshl_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001210 case LibFunc_cosl:
1211 case LibFunc_exp10:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001212 case LibFunc_exp10_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001213 case LibFunc_exp10f:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001214 case LibFunc_exp10f_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001215 case LibFunc_exp10l:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001216 case LibFunc_exp10l_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001217 case LibFunc_exp2:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001218 case LibFunc_exp2_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001219 case LibFunc_exp2f:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001220 case LibFunc_exp2f_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001221 case LibFunc_exp2l:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001222 case LibFunc_exp2l_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001223 case LibFunc_exp:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001224 case LibFunc_exp_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001225 case LibFunc_expf:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001226 case LibFunc_expf_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001227 case LibFunc_expl:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001228 case LibFunc_expl_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001229 case LibFunc_expm1:
1230 case LibFunc_expm1f:
1231 case LibFunc_expm1l:
1232 case LibFunc_fabs:
1233 case LibFunc_fabsf:
1234 case LibFunc_fabsl:
1235 case LibFunc_floor:
1236 case LibFunc_floorf:
1237 case LibFunc_floorl:
1238 case LibFunc_log10:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001239 case LibFunc_log10_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001240 case LibFunc_log10f:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001241 case LibFunc_log10f_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001242 case LibFunc_log10l:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001243 case LibFunc_log10l_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001244 case LibFunc_log1p:
1245 case LibFunc_log1pf:
1246 case LibFunc_log1pl:
1247 case LibFunc_log2:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001248 case LibFunc_log2_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001249 case LibFunc_log2f:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001250 case LibFunc_log2f_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001251 case LibFunc_log2l:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001252 case LibFunc_log2l_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001253 case LibFunc_log:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001254 case LibFunc_log_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001255 case LibFunc_logb:
1256 case LibFunc_logbf:
1257 case LibFunc_logbl:
1258 case LibFunc_logf:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001259 case LibFunc_logf_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001260 case LibFunc_logl:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001261 case LibFunc_logl_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001262 case LibFunc_nearbyint:
1263 case LibFunc_nearbyintf:
1264 case LibFunc_nearbyintl:
1265 case LibFunc_rint:
1266 case LibFunc_rintf:
1267 case LibFunc_rintl:
1268 case LibFunc_round:
1269 case LibFunc_roundf:
1270 case LibFunc_roundl:
1271 case LibFunc_sin:
1272 case LibFunc_sinf:
1273 case LibFunc_sinh:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001274 case LibFunc_sinh_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001275 case LibFunc_sinhf:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001276 case LibFunc_sinhf_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001277 case LibFunc_sinhl:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001278 case LibFunc_sinhl_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001279 case LibFunc_sinl:
1280 case LibFunc_sqrt:
1281 case LibFunc_sqrt_finite:
1282 case LibFunc_sqrtf:
1283 case LibFunc_sqrtf_finite:
1284 case LibFunc_sqrtl:
1285 case LibFunc_sqrtl_finite:
1286 case LibFunc_tan:
1287 case LibFunc_tanf:
1288 case LibFunc_tanh:
1289 case LibFunc_tanhf:
1290 case LibFunc_tanhl:
1291 case LibFunc_tanl:
1292 case LibFunc_trunc:
1293 case LibFunc_truncf:
1294 case LibFunc_truncl:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001295 return (NumParams == 1 && FTy.getReturnType()->isFloatingPointTy() &&
1296 FTy.getReturnType() == FTy.getParamType(0));
1297
David L. Jones32028c82017-01-23 23:16:46 +00001298 case LibFunc_atan2:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001299 case LibFunc_atan2_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001300 case LibFunc_atan2f:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001301 case LibFunc_atan2f_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001302 case LibFunc_atan2l:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001303 case LibFunc_atan2l_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001304 case LibFunc_fmin:
1305 case LibFunc_fminf:
1306 case LibFunc_fminl:
1307 case LibFunc_fmax:
1308 case LibFunc_fmaxf:
1309 case LibFunc_fmaxl:
1310 case LibFunc_fmod:
1311 case LibFunc_fmodf:
1312 case LibFunc_fmodl:
1313 case LibFunc_copysign:
1314 case LibFunc_copysignf:
1315 case LibFunc_copysignl:
1316 case LibFunc_pow:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001317 case LibFunc_pow_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001318 case LibFunc_powf:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001319 case LibFunc_powf_finite:
David L. Jones32028c82017-01-23 23:16:46 +00001320 case LibFunc_powl:
Andrew Kaylor8731f0c2017-05-12 22:11:12 +00001321 case LibFunc_powl_finite:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001322 return (NumParams == 2 && FTy.getReturnType()->isFloatingPointTy() &&
1323 FTy.getReturnType() == FTy.getParamType(0) &&
1324 FTy.getReturnType() == FTy.getParamType(1));
1325
David L. Jones32028c82017-01-23 23:16:46 +00001326 case LibFunc_ldexp:
1327 case LibFunc_ldexpf:
1328 case LibFunc_ldexpl:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001329 return (NumParams == 2 && FTy.getReturnType()->isFloatingPointTy() &&
1330 FTy.getReturnType() == FTy.getParamType(0) &&
1331 FTy.getParamType(1)->isIntegerTy(32));
1332
David L. Jones32028c82017-01-23 23:16:46 +00001333 case LibFunc_ffs:
1334 case LibFunc_ffsl:
1335 case LibFunc_ffsll:
1336 case LibFunc_fls:
1337 case LibFunc_flsl:
1338 case LibFunc_flsll:
Sanjay Patelc5ddf502016-09-23 18:44:09 +00001339 return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(32) &&
1340 FTy.getParamType(0)->isIntegerTy());
1341
David L. Jones32028c82017-01-23 23:16:46 +00001342 case LibFunc_isdigit:
1343 case LibFunc_isascii:
1344 case LibFunc_toascii:
1345 case LibFunc_putchar:
David Bolvanskycb037ef2018-05-16 11:39:52 +00001346 case LibFunc_putchar_unlocked:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001347 return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(32) &&
Sanjay Patelc5ddf502016-09-23 18:44:09 +00001348 FTy.getReturnType() == FTy.getParamType(0));
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001349
David L. Jones32028c82017-01-23 23:16:46 +00001350 case LibFunc_abs:
1351 case LibFunc_labs:
1352 case LibFunc_llabs:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001353 return (NumParams == 1 && FTy.getReturnType()->isIntegerTy() &&
1354 FTy.getReturnType() == FTy.getParamType(0));
1355
David L. Jones32028c82017-01-23 23:16:46 +00001356 case LibFunc_cxa_atexit:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001357 return (NumParams == 3 && FTy.getReturnType()->isIntegerTy() &&
1358 FTy.getParamType(0)->isPointerTy() &&
1359 FTy.getParamType(1)->isPointerTy() &&
1360 FTy.getParamType(2)->isPointerTy());
1361
David L. Jones32028c82017-01-23 23:16:46 +00001362 case LibFunc_sinpi:
1363 case LibFunc_cospi:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001364 return (NumParams == 1 && FTy.getReturnType()->isDoubleTy() &&
1365 FTy.getReturnType() == FTy.getParamType(0));
1366
David L. Jones32028c82017-01-23 23:16:46 +00001367 case LibFunc_sinpif:
1368 case LibFunc_cospif:
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001369 return (NumParams == 1 && FTy.getReturnType()->isFloatTy() &&
1370 FTy.getReturnType() == FTy.getParamType(0));
1371
David L. Jones32028c82017-01-23 23:16:46 +00001372 case LibFunc_strnlen:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001373 return (NumParams == 2 && FTy.getReturnType() == FTy.getParamType(1) &&
1374 FTy.getParamType(0) == PCharTy &&
1375 FTy.getParamType(1) == SizeTTy);
1376
David L. Jones32028c82017-01-23 23:16:46 +00001377 case LibFunc_posix_memalign:
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001378 return (NumParams == 3 && FTy.getReturnType()->isIntegerTy(32) &&
1379 FTy.getParamType(0)->isPointerTy() &&
1380 FTy.getParamType(1) == SizeTTy && FTy.getParamType(2) == SizeTTy);
1381
Matthias Braun738a26c2017-05-05 20:25:50 +00001382 case LibFunc_wcslen:
1383 return (NumParams == 1 && FTy.getParamType(0)->isPointerTy() &&
1384 FTy.getReturnType()->isIntegerTy());
1385
Hal Finkel1d4f2b02017-12-16 01:26:25 +00001386 case LibFunc_cabs:
1387 case LibFunc_cabsf:
1388 case LibFunc_cabsl: {
1389 Type* RetTy = FTy.getReturnType();
1390 if (!RetTy->isFloatingPointTy())
1391 return false;
1392
1393 // NOTE: These prototypes are target specific and currently support
1394 // "complex" passed as an array or discrete real & imaginary parameters.
1395 // Add other calling conventions to enable libcall optimizations.
1396 if (NumParams == 1)
1397 return (FTy.getParamType(0)->isArrayTy() &&
1398 FTy.getParamType(0)->getArrayNumElements() == 2 &&
1399 FTy.getParamType(0)->getArrayElementType() == RetTy);
1400 else if (NumParams == 2)
1401 return (FTy.getParamType(0) == RetTy && FTy.getParamType(1) == RetTy);
1402 else
1403 return false;
1404 }
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001405 case LibFunc::NumLibFuncs:
Ahmed Bougachabf5fc972017-01-17 19:54:18 +00001406 break;
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001407 }
Ahmed Bougachabe550d02017-01-17 03:10:02 +00001408
Ahmed Bougachabf5fc972017-01-17 19:54:18 +00001409 llvm_unreachable("Invalid libfunc");
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001410}
1411
1412bool TargetLibraryInfoImpl::getLibFunc(const Function &FDecl,
David L. Jones32028c82017-01-23 23:16:46 +00001413 LibFunc &F) const {
Ahmed Bougacha8a8efec2016-04-27 19:04:35 +00001414 const DataLayout *DL =
1415 FDecl.getParent() ? &FDecl.getParent()->getDataLayout() : nullptr;
1416 return getLibFunc(FDecl.getName(), F) &&
1417 isValidProtoForLibFunc(*FDecl.getFunctionType(), F, DL);
1418}
1419
Chandler Carruth6f409cb2015-01-24 02:06:09 +00001420void TargetLibraryInfoImpl::disableAllFunctions() {
Chris Lattner188a7e02011-02-18 22:34:03 +00001421 memset(AvailableArray, 0, sizeof(AvailableArray));
1422}
Chandler Carrutheeeec3c2015-01-15 10:41:28 +00001423
Michael Zolotukhin06aab082015-03-17 19:22:30 +00001424static bool compareByScalarFnName(const VecDesc &LHS, const VecDesc &RHS) {
Mehdi Amini5e07fb32016-10-01 03:10:48 +00001425 return LHS.ScalarFnName < RHS.ScalarFnName;
Michael Zolotukhin06aab082015-03-17 19:22:30 +00001426}
1427
1428static bool compareByVectorFnName(const VecDesc &LHS, const VecDesc &RHS) {
Mehdi Amini5e07fb32016-10-01 03:10:48 +00001429 return LHS.VectorFnName < RHS.VectorFnName;
Michael Zolotukhin06aab082015-03-17 19:22:30 +00001430}
1431
1432static bool compareWithScalarFnName(const VecDesc &LHS, StringRef S) {
Mehdi Amini5e07fb32016-10-01 03:10:48 +00001433 return LHS.ScalarFnName < S;
Michael Zolotukhin06aab082015-03-17 19:22:30 +00001434}
1435
1436static bool compareWithVectorFnName(const VecDesc &LHS, StringRef S) {
Mehdi Amini5e07fb32016-10-01 03:10:48 +00001437 return LHS.VectorFnName < S;
Michael Zolotukhin06aab082015-03-17 19:22:30 +00001438}
1439
1440void TargetLibraryInfoImpl::addVectorizableFunctions(ArrayRef<VecDesc> Fns) {
1441 VectorDescs.insert(VectorDescs.end(), Fns.begin(), Fns.end());
Fangrui Song3b35e172018-09-27 02:13:45 +00001442 llvm::sort(VectorDescs, compareByScalarFnName);
Michael Zolotukhin06aab082015-03-17 19:22:30 +00001443
1444 ScalarDescs.insert(ScalarDescs.end(), Fns.begin(), Fns.end());
Fangrui Song3b35e172018-09-27 02:13:45 +00001445 llvm::sort(ScalarDescs, compareByVectorFnName);
Michael Zolotukhin06aab082015-03-17 19:22:30 +00001446}
1447
Michael Zolotukhin58506022015-03-17 19:50:55 +00001448void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib(
1449 enum VectorLibrary VecLib) {
1450 switch (VecLib) {
1451 case Accelerate: {
1452 const VecDesc VecFuncs[] = {
Michael Zolotukhind7b51442015-05-07 17:11:51 +00001453 // Floating-Point Arithmetic and Auxiliary Functions
1454 {"ceilf", "vceilf", 4},
Michael Zolotukhin58506022015-03-17 19:50:55 +00001455 {"fabsf", "vfabsf", 4},
1456 {"llvm.fabs.f32", "vfabsf", 4},
Michael Zolotukhind7b51442015-05-07 17:11:51 +00001457 {"floorf", "vfloorf", 4},
1458 {"sqrtf", "vsqrtf", 4},
1459 {"llvm.sqrt.f32", "vsqrtf", 4},
1460
1461 // Exponential and Logarithmic Functions
1462 {"expf", "vexpf", 4},
1463 {"llvm.exp.f32", "vexpf", 4},
1464 {"expm1f", "vexpm1f", 4},
1465 {"logf", "vlogf", 4},
1466 {"llvm.log.f32", "vlogf", 4},
1467 {"log1pf", "vlog1pf", 4},
1468 {"log10f", "vlog10f", 4},
1469 {"llvm.log10.f32", "vlog10f", 4},
1470 {"logbf", "vlogbf", 4},
1471
1472 // Trigonometric Functions
1473 {"sinf", "vsinf", 4},
1474 {"llvm.sin.f32", "vsinf", 4},
1475 {"cosf", "vcosf", 4},
1476 {"llvm.cos.f32", "vcosf", 4},
1477 {"tanf", "vtanf", 4},
1478 {"asinf", "vasinf", 4},
1479 {"acosf", "vacosf", 4},
1480 {"atanf", "vatanf", 4},
1481
1482 // Hyperbolic Functions
1483 {"sinhf", "vsinhf", 4},
1484 {"coshf", "vcoshf", 4},
1485 {"tanhf", "vtanhf", 4},
1486 {"asinhf", "vasinhf", 4},
1487 {"acoshf", "vacoshf", 4},
1488 {"atanhf", "vatanhf", 4},
Michael Zolotukhin58506022015-03-17 19:50:55 +00001489 };
1490 addVectorizableFunctions(VecFuncs);
1491 break;
1492 }
Matt Mastenbbbcccb2016-07-29 16:42:44 +00001493 case SVML: {
1494 const VecDesc VecFuncs[] = {
1495 {"sin", "__svml_sin2", 2},
1496 {"sin", "__svml_sin4", 4},
1497 {"sin", "__svml_sin8", 8},
1498
1499 {"sinf", "__svml_sinf4", 4},
1500 {"sinf", "__svml_sinf8", 8},
1501 {"sinf", "__svml_sinf16", 16},
1502
Sanjay Patelbd9be7a2018-06-07 18:21:24 +00001503 {"llvm.sin.f64", "__svml_sin2", 2},
1504 {"llvm.sin.f64", "__svml_sin4", 4},
1505 {"llvm.sin.f64", "__svml_sin8", 8},
1506
1507 {"llvm.sin.f32", "__svml_sinf4", 4},
1508 {"llvm.sin.f32", "__svml_sinf8", 8},
1509 {"llvm.sin.f32", "__svml_sinf16", 16},
1510
Matt Mastenbbbcccb2016-07-29 16:42:44 +00001511 {"cos", "__svml_cos2", 2},
1512 {"cos", "__svml_cos4", 4},
1513 {"cos", "__svml_cos8", 8},
1514
1515 {"cosf", "__svml_cosf4", 4},
1516 {"cosf", "__svml_cosf8", 8},
1517 {"cosf", "__svml_cosf16", 16},
1518
Sanjay Patelbd9be7a2018-06-07 18:21:24 +00001519 {"llvm.cos.f64", "__svml_cos2", 2},
1520 {"llvm.cos.f64", "__svml_cos4", 4},
1521 {"llvm.cos.f64", "__svml_cos8", 8},
1522
1523 {"llvm.cos.f32", "__svml_cosf4", 4},
1524 {"llvm.cos.f32", "__svml_cosf8", 8},
1525 {"llvm.cos.f32", "__svml_cosf16", 16},
1526
Matt Mastenbbbcccb2016-07-29 16:42:44 +00001527 {"pow", "__svml_pow2", 2},
1528 {"pow", "__svml_pow4", 4},
1529 {"pow", "__svml_pow8", 8},
1530
1531 {"powf", "__svml_powf4", 4},
1532 {"powf", "__svml_powf8", 8},
1533 {"powf", "__svml_powf16", 16},
1534
Andrew Kaylora0e10ad2017-05-12 22:11:26 +00001535 { "__pow_finite", "__svml_pow2", 2 },
1536 { "__pow_finite", "__svml_pow4", 4 },
1537 { "__pow_finite", "__svml_pow8", 8 },
1538
1539 { "__powf_finite", "__svml_powf4", 4 },
1540 { "__powf_finite", "__svml_powf8", 8 },
1541 { "__powf_finite", "__svml_powf16", 16 },
1542
Matt Mastenbbbcccb2016-07-29 16:42:44 +00001543 {"llvm.pow.f64", "__svml_pow2", 2},
1544 {"llvm.pow.f64", "__svml_pow4", 4},
1545 {"llvm.pow.f64", "__svml_pow8", 8},
1546
1547 {"llvm.pow.f32", "__svml_powf4", 4},
1548 {"llvm.pow.f32", "__svml_powf8", 8},
1549 {"llvm.pow.f32", "__svml_powf16", 16},
1550
1551 {"exp", "__svml_exp2", 2},
1552 {"exp", "__svml_exp4", 4},
1553 {"exp", "__svml_exp8", 8},
1554
1555 {"expf", "__svml_expf4", 4},
1556 {"expf", "__svml_expf8", 8},
1557 {"expf", "__svml_expf16", 16},
1558
Andrew Kaylora0e10ad2017-05-12 22:11:26 +00001559 { "__exp_finite", "__svml_exp2", 2 },
1560 { "__exp_finite", "__svml_exp4", 4 },
1561 { "__exp_finite", "__svml_exp8", 8 },
1562
1563 { "__expf_finite", "__svml_expf4", 4 },
1564 { "__expf_finite", "__svml_expf8", 8 },
1565 { "__expf_finite", "__svml_expf16", 16 },
1566
Matt Mastenbbbcccb2016-07-29 16:42:44 +00001567 {"llvm.exp.f64", "__svml_exp2", 2},
1568 {"llvm.exp.f64", "__svml_exp4", 4},
1569 {"llvm.exp.f64", "__svml_exp8", 8},
1570
1571 {"llvm.exp.f32", "__svml_expf4", 4},
1572 {"llvm.exp.f32", "__svml_expf8", 8},
1573 {"llvm.exp.f32", "__svml_expf16", 16},
1574
1575 {"log", "__svml_log2", 2},
1576 {"log", "__svml_log4", 4},
1577 {"log", "__svml_log8", 8},
1578
1579 {"logf", "__svml_logf4", 4},
1580 {"logf", "__svml_logf8", 8},
1581 {"logf", "__svml_logf16", 16},
1582
Andrew Kaylora0e10ad2017-05-12 22:11:26 +00001583 { "__log_finite", "__svml_log2", 2 },
1584 { "__log_finite", "__svml_log4", 4 },
1585 { "__log_finite", "__svml_log8", 8 },
1586
1587 { "__logf_finite", "__svml_logf4", 4 },
1588 { "__logf_finite", "__svml_logf8", 8 },
1589 { "__logf_finite", "__svml_logf16", 16 },
1590
Matt Mastenbbbcccb2016-07-29 16:42:44 +00001591 {"llvm.log.f64", "__svml_log2", 2},
1592 {"llvm.log.f64", "__svml_log4", 4},
1593 {"llvm.log.f64", "__svml_log8", 8},
1594
1595 {"llvm.log.f32", "__svml_logf4", 4},
1596 {"llvm.log.f32", "__svml_logf8", 8},
1597 {"llvm.log.f32", "__svml_logf16", 16},
1598 };
1599 addVectorizableFunctions(VecFuncs);
1600 break;
1601 }
Michael Zolotukhin58506022015-03-17 19:50:55 +00001602 case NoLibrary:
1603 break;
1604 }
1605}
1606
Michael Zolotukhin06aab082015-03-17 19:22:30 +00001607bool TargetLibraryInfoImpl::isFunctionVectorizable(StringRef funcName) const {
1608 funcName = sanitizeFunctionName(funcName);
1609 if (funcName.empty())
1610 return false;
1611
1612 std::vector<VecDesc>::const_iterator I = std::lower_bound(
1613 VectorDescs.begin(), VectorDescs.end(), funcName,
1614 compareWithScalarFnName);
1615 return I != VectorDescs.end() && StringRef(I->ScalarFnName) == funcName;
1616}
1617
1618StringRef TargetLibraryInfoImpl::getVectorizedFunction(StringRef F,
1619 unsigned VF) const {
1620 F = sanitizeFunctionName(F);
1621 if (F.empty())
1622 return F;
1623 std::vector<VecDesc>::const_iterator I = std::lower_bound(
1624 VectorDescs.begin(), VectorDescs.end(), F, compareWithScalarFnName);
1625 while (I != VectorDescs.end() && StringRef(I->ScalarFnName) == F) {
1626 if (I->VectorizationFactor == VF)
1627 return I->VectorFnName;
1628 ++I;
1629 }
1630 return StringRef();
1631}
1632
1633StringRef TargetLibraryInfoImpl::getScalarizedFunction(StringRef F,
1634 unsigned &VF) const {
1635 F = sanitizeFunctionName(F);
1636 if (F.empty())
1637 return F;
1638
1639 std::vector<VecDesc>::const_iterator I = std::lower_bound(
1640 ScalarDescs.begin(), ScalarDescs.end(), F, compareWithVectorFnName);
1641 if (I == VectorDescs.end() || StringRef(I->VectorFnName) != F)
1642 return StringRef();
1643 VF = I->VectorizationFactor;
1644 return I->ScalarFnName;
1645}
1646
Chandler Carruth04d0fe92016-06-17 00:11:01 +00001647TargetLibraryInfo TargetLibraryAnalysis::run(Module &M,
1648 ModuleAnalysisManager &) {
Chandler Carruth6f409cb2015-01-24 02:06:09 +00001649 if (PresetInfoImpl)
1650 return TargetLibraryInfo(*PresetInfoImpl);
1651
1652 return TargetLibraryInfo(lookupInfoImpl(Triple(M.getTargetTriple())));
1653}
1654
Chandler Carruth04d0fe92016-06-17 00:11:01 +00001655TargetLibraryInfo TargetLibraryAnalysis::run(Function &F,
1656 FunctionAnalysisManager &) {
Chandler Carruth6f409cb2015-01-24 02:06:09 +00001657 if (PresetInfoImpl)
1658 return TargetLibraryInfo(*PresetInfoImpl);
1659
1660 return TargetLibraryInfo(
1661 lookupInfoImpl(Triple(F.getParent()->getTargetTriple())));
1662}
1663
Benjamin Kramer36538ff2016-06-08 19:09:22 +00001664TargetLibraryInfoImpl &TargetLibraryAnalysis::lookupInfoImpl(const Triple &T) {
Chandler Carruth6f409cb2015-01-24 02:06:09 +00001665 std::unique_ptr<TargetLibraryInfoImpl> &Impl =
1666 Impls[T.normalize()];
1667 if (!Impl)
1668 Impl.reset(new TargetLibraryInfoImpl(T));
1669
1670 return *Impl;
1671}
1672
Matthias Braun708626d2017-05-19 22:37:09 +00001673unsigned TargetLibraryInfoImpl::getWCharSize(const Module &M) const {
1674 if (auto *ShortWChar = cast_or_null<ConstantAsMetadata>(
1675 M.getModuleFlag("wchar_size")))
1676 return cast<ConstantInt>(ShortWChar->getValue())->getZExtValue();
Matthias Braun77cad592017-09-26 02:36:57 +00001677 return 0;
Matthias Braun708626d2017-05-19 22:37:09 +00001678}
Chandler Carruth6f409cb2015-01-24 02:06:09 +00001679
Chandler Carrutheeeec3c2015-01-15 10:41:28 +00001680TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass()
Chandler Carruth6f409cb2015-01-24 02:06:09 +00001681 : ImmutablePass(ID), TLIImpl(), TLI(TLIImpl) {
Chandler Carrutheeeec3c2015-01-15 10:41:28 +00001682 initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
1683}
1684
1685TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(const Triple &T)
Chandler Carruth6f409cb2015-01-24 02:06:09 +00001686 : ImmutablePass(ID), TLIImpl(T), TLI(TLIImpl) {
Chandler Carrutheeeec3c2015-01-15 10:41:28 +00001687 initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
1688}
1689
1690TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(
Chandler Carruth6f409cb2015-01-24 02:06:09 +00001691 const TargetLibraryInfoImpl &TLIImpl)
1692 : ImmutablePass(ID), TLIImpl(TLIImpl), TLI(this->TLIImpl) {
Chandler Carrutheeeec3c2015-01-15 10:41:28 +00001693 initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
1694}
1695
Chandler Carruth33d56812016-11-23 17:53:26 +00001696AnalysisKey TargetLibraryAnalysis::Key;
NAKAMURA Takumid9b6afb2016-02-28 17:17:00 +00001697
Chandler Carrutheeeec3c2015-01-15 10:41:28 +00001698// Register the basic pass.
1699INITIALIZE_PASS(TargetLibraryInfoWrapperPass, "targetlibinfo",
1700 "Target Library Information", false, true)
1701char TargetLibraryInfoWrapperPass::ID = 0;
1702
1703void TargetLibraryInfoWrapperPass::anchor() {}