blob: 4643f75da42d14a10b39954a9e9d4061a39984e1 [file] [log] [blame]
Chris Lattner0e125bb2011-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 Carruth62d42152015-01-15 02:16:27 +000014#include "llvm/Analysis/TargetLibraryInfo.h"
Chris Lattner0e125bb2011-02-18 21:50:34 +000015#include "llvm/ADT/Triple.h"
Matthias Braun50ec0b52017-05-19 22:37:09 +000016#include "llvm/IR/Constants.h"
Michael Zolotukhin6d8a2aa2015-03-17 19:50:55 +000017#include "llvm/Support/CommandLine.h"
Chris Lattner0e125bb2011-02-18 21:50:34 +000018using namespace llvm;
19
Michael Zolotukhin6d8a2aa2015-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 Mastena6669a12016-07-29 16:42:44 +000027 clEnumValN(TargetLibraryInfoImpl::SVML, "SVML",
Joel Jones74593982018-11-24 07:26:55 +000028 "Intel SVML library")));
Michael Zolotukhin6d8a2aa2015-03-17 19:50:55 +000029
Mehdi Amini9a72cd72016-10-01 03:10:48 +000030StringRef const TargetLibraryInfoImpl::StandardNames[LibFunc::NumLibFuncs] = {
Jan Wen Voungcd3d25a2015-03-03 23:41:58 +000031#define TLI_DEFINE_STRING
32#include "llvm/Analysis/TargetLibraryInfo.def"
Benjamin Kramer57a3d082015-03-08 16:07:39 +000033};
Eli Friedman489c0ff2011-11-17 01:27:36 +000034
Bob Wilsond8d92d92013-11-03 06:48:38 +000035static bool hasSinCosPiStret(const Triple &T) {
36 // Only Darwin variants have _stret versions of combined trig functions.
Bob Wilson9868d712014-10-09 05:43:30 +000037 if (!T.isOSDarwin())
Bob Wilsond8d92d92013-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 Wilson9868d712014-10-09 05:43:30 +000047 if (T.isiOS() && T.isOSVersionLT(7, 0))
Bob Wilsond8d92d92013-11-03 06:48:38 +000048 return false;
49
50 return true;
51}
52
Sanjay Patel600d24b2017-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 Carruthc0291862015-01-24 02:06:09 +000056static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
Mehdi Amini9a72cd72016-10-01 03:10:48 +000057 ArrayRef<StringRef> StandardNames) {
Bob Wilsonc740e3f2012-08-03 04:06:22 +000058 // Verify that the StandardNames array is in alphabetical order.
Craig Toppere30b8ca2016-01-03 19:43:40 +000059 assert(std::is_sorted(StandardNames.begin(), StandardNames.end(),
Mehdi Amini9a72cd72016-10-01 03:10:48 +000060 [](StringRef LHS, StringRef RHS) {
61 return LHS < RHS;
Craig Toppere30b8ca2016-01-03 19:43:40 +000062 }) &&
63 "TargetLibraryInfoImpl function names must be sorted");
Tom Stellard36a03182014-04-02 19:53:29 +000064
David Bolvanskyca22d422018-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 Koscielnicki6af8e6c2016-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 Richardson85e200e2018-06-25 16:49:20 +000088 if (T.isMIPS()) {
Marcin Koscielnicki6af8e6c2016-11-21 20:20:39 +000089 ShouldSignExtI32Param = true;
90 }
91 TLI.setShouldExtI32Param(ShouldExtI32Param);
92 TLI.setShouldExtI32Return(ShouldExtI32Return);
93 TLI.setShouldSignExtI32Param(ShouldSignExtI32Param);
94
Nicolai Hahnle78fd4f02015-12-15 17:24:15 +000095 if (T.getArch() == Triple::r600 ||
96 T.getArch() == Triple::amdgcn) {
David L. Jonesd21529f2017-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 Hahnle78fd4f02015-12-15 17:24:15 +0000106 }
107
Tom Stellardd00a9232015-01-07 01:17:37 +0000108 // There are no library implementations of mempcy and memset for AMD gpus and
Tom Stellard36a03182014-04-02 19:53:29 +0000109 // these can be difficult to lower in the backend.
Tom Stellardd00a9232015-01-07 01:17:37 +0000110 if (T.getArch() == Triple::r600 ||
Dan Gohman05532992016-01-19 14:49:23 +0000111 T.getArch() == Triple::amdgcn) {
David L. Jonesd21529f2017-01-23 23:16:46 +0000112 TLI.setUnavailable(LibFunc_memcpy);
113 TLI.setUnavailable(LibFunc_memset);
114 TLI.setUnavailable(LibFunc_memset_pattern16);
Tom Stellard36a03182014-04-02 19:53:29 +0000115 return;
116 }
117
Nico Weberad156922014-03-07 18:08:54 +0000118 // memset_pattern16 is only available on iOS 3.0 and Mac OS X 10.5 and later.
Tim Northover8b403662015-10-28 22:51:16 +0000119 // All versions of watchOS support it.
Daniel Dunbarcd01ed52011-04-20 00:14:25 +0000120 if (T.isMacOSX()) {
David Bolvanskyca22d422018-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 Dunbarcd01ed52011-04-20 00:14:25 +0000127 if (T.isMacOSXVersionLT(10, 5))
David L. Jonesd21529f2017-01-23 23:16:46 +0000128 TLI.setUnavailable(LibFunc_memset_pattern16);
Cameron Esfahani943908b2013-08-29 20:23:14 +0000129 } else if (T.isiOS()) {
Daniel Dunbar9483bb62011-04-19 20:44:08 +0000130 if (T.isOSVersionLT(3, 0))
David L. Jonesd21529f2017-01-23 23:16:46 +0000131 TLI.setUnavailable(LibFunc_memset_pattern16);
Tim Northover8b403662015-10-28 22:51:16 +0000132 } else if (!T.isWatchOS()) {
David L. Jonesd21529f2017-01-23 23:16:46 +0000133 TLI.setUnavailable(LibFunc_memset_pattern16);
Daniel Dunbar9483bb62011-04-19 20:44:08 +0000134 }
Richard Osborne815de532011-03-03 13:17:51 +0000135
Bob Wilsond8d92d92013-11-03 06:48:38 +0000136 if (!hasSinCosPiStret(T)) {
David L. Jonesd21529f2017-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 Wilsond8d92d92013-11-03 06:48:38 +0000143 }
144
Eli Friedman489c0ff2011-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. Jonesd21529f2017-01-23 23:16:46 +0000152 TLI.setAvailableWithName(LibFunc_fwrite, "fwrite$UNIX2003");
153 TLI.setAvailableWithName(LibFunc_fputs, "fputs$UNIX2003");
Eli Friedman489c0ff2011-11-17 01:27:36 +0000154 }
155
Duncan Sandseeb50c82011-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. Jonesd21529f2017-01-23 23:16:46 +0000158 TLI.setUnavailable(LibFunc_iprintf);
159 TLI.setUnavailable(LibFunc_siprintf);
160 TLI.setUnavailable(LibFunc_fiprintf);
Richard Osborne2dfb8882011-03-03 14:09:28 +0000161 }
Joe Groffa81bcbb2012-04-17 23:05:54 +0000162
Saleem Abdulrasool8dc8fb12014-07-24 22:09:06 +0000163 if (T.isOSWindows() && !T.isOSCygMing()) {
Joe Groffa81bcbb2012-04-17 23:05:54 +0000164 // Win32 does not support long double
David L. Jonesd21529f2017-01-23 23:16:46 +0000165 TLI.setUnavailable(LibFunc_acosl);
166 TLI.setUnavailable(LibFunc_asinl);
167 TLI.setUnavailable(LibFunc_atanl);
168 TLI.setUnavailable(LibFunc_atan2l);
169 TLI.setUnavailable(LibFunc_ceill);
170 TLI.setUnavailable(LibFunc_copysignl);
171 TLI.setUnavailable(LibFunc_cosl);
172 TLI.setUnavailable(LibFunc_coshl);
173 TLI.setUnavailable(LibFunc_expl);
174 TLI.setUnavailable(LibFunc_fabsf); // Win32 and Win64 both lack fabsf
175 TLI.setUnavailable(LibFunc_fabsl);
176 TLI.setUnavailable(LibFunc_floorl);
177 TLI.setUnavailable(LibFunc_fmaxl);
178 TLI.setUnavailable(LibFunc_fminl);
179 TLI.setUnavailable(LibFunc_fmodl);
180 TLI.setUnavailable(LibFunc_frexpl);
181 TLI.setUnavailable(LibFunc_ldexpf);
182 TLI.setUnavailable(LibFunc_ldexpl);
183 TLI.setUnavailable(LibFunc_logl);
184 TLI.setUnavailable(LibFunc_modfl);
185 TLI.setUnavailable(LibFunc_powl);
186 TLI.setUnavailable(LibFunc_sinl);
187 TLI.setUnavailable(LibFunc_sinhl);
188 TLI.setUnavailable(LibFunc_sqrtl);
189 TLI.setUnavailable(LibFunc_tanl);
190 TLI.setUnavailable(LibFunc_tanhl);
Joe Groffa81bcbb2012-04-17 23:05:54 +0000191
192 // Win32 only has C89 math
David L. Jonesd21529f2017-01-23 23:16:46 +0000193 TLI.setUnavailable(LibFunc_acosh);
194 TLI.setUnavailable(LibFunc_acoshf);
195 TLI.setUnavailable(LibFunc_acoshl);
196 TLI.setUnavailable(LibFunc_asinh);
197 TLI.setUnavailable(LibFunc_asinhf);
198 TLI.setUnavailable(LibFunc_asinhl);
199 TLI.setUnavailable(LibFunc_atanh);
200 TLI.setUnavailable(LibFunc_atanhf);
201 TLI.setUnavailable(LibFunc_atanhl);
Hal Finkel2ff24732017-12-16 01:26:25 +0000202 TLI.setUnavailable(LibFunc_cabs);
203 TLI.setUnavailable(LibFunc_cabsf);
204 TLI.setUnavailable(LibFunc_cabsl);
David L. Jonesd21529f2017-01-23 23:16:46 +0000205 TLI.setUnavailable(LibFunc_cbrt);
206 TLI.setUnavailable(LibFunc_cbrtf);
207 TLI.setUnavailable(LibFunc_cbrtl);
208 TLI.setUnavailable(LibFunc_exp2);
209 TLI.setUnavailable(LibFunc_exp2f);
210 TLI.setUnavailable(LibFunc_exp2l);
211 TLI.setUnavailable(LibFunc_expm1);
212 TLI.setUnavailable(LibFunc_expm1f);
213 TLI.setUnavailable(LibFunc_expm1l);
214 TLI.setUnavailable(LibFunc_log2);
215 TLI.setUnavailable(LibFunc_log2f);
216 TLI.setUnavailable(LibFunc_log2l);
217 TLI.setUnavailable(LibFunc_log1p);
218 TLI.setUnavailable(LibFunc_log1pf);
219 TLI.setUnavailable(LibFunc_log1pl);
220 TLI.setUnavailable(LibFunc_logb);
221 TLI.setUnavailable(LibFunc_logbf);
222 TLI.setUnavailable(LibFunc_logbl);
223 TLI.setUnavailable(LibFunc_nearbyint);
224 TLI.setUnavailable(LibFunc_nearbyintf);
225 TLI.setUnavailable(LibFunc_nearbyintl);
226 TLI.setUnavailable(LibFunc_rint);
227 TLI.setUnavailable(LibFunc_rintf);
228 TLI.setUnavailable(LibFunc_rintl);
229 TLI.setUnavailable(LibFunc_round);
230 TLI.setUnavailable(LibFunc_roundf);
231 TLI.setUnavailable(LibFunc_roundl);
232 TLI.setUnavailable(LibFunc_trunc);
233 TLI.setUnavailable(LibFunc_truncf);
234 TLI.setUnavailable(LibFunc_truncl);
Joe Groffa81bcbb2012-04-17 23:05:54 +0000235
236 // Win32 provides some C99 math with mangled names
David L. Jonesd21529f2017-01-23 23:16:46 +0000237 TLI.setAvailableWithName(LibFunc_copysign, "_copysign");
Joe Groffa81bcbb2012-04-17 23:05:54 +0000238
239 if (T.getArch() == Triple::x86) {
240 // Win32 on x86 implements single-precision math functions as macros
David L. Jonesd21529f2017-01-23 23:16:46 +0000241 TLI.setUnavailable(LibFunc_acosf);
242 TLI.setUnavailable(LibFunc_asinf);
243 TLI.setUnavailable(LibFunc_atanf);
244 TLI.setUnavailable(LibFunc_atan2f);
245 TLI.setUnavailable(LibFunc_ceilf);
246 TLI.setUnavailable(LibFunc_copysignf);
247 TLI.setUnavailable(LibFunc_cosf);
248 TLI.setUnavailable(LibFunc_coshf);
249 TLI.setUnavailable(LibFunc_expf);
250 TLI.setUnavailable(LibFunc_floorf);
251 TLI.setUnavailable(LibFunc_fminf);
252 TLI.setUnavailable(LibFunc_fmaxf);
253 TLI.setUnavailable(LibFunc_fmodf);
254 TLI.setUnavailable(LibFunc_logf);
255 TLI.setUnavailable(LibFunc_log10f);
256 TLI.setUnavailable(LibFunc_modff);
257 TLI.setUnavailable(LibFunc_powf);
258 TLI.setUnavailable(LibFunc_sinf);
259 TLI.setUnavailable(LibFunc_sinhf);
260 TLI.setUnavailable(LibFunc_sqrtf);
261 TLI.setUnavailable(LibFunc_tanf);
262 TLI.setUnavailable(LibFunc_tanhf);
Joe Groffa81bcbb2012-04-17 23:05:54 +0000263 }
Meador Inge2526a422012-11-10 03:11:06 +0000264
Fangrui Song956ee792018-03-30 22:22:31 +0000265 // Win32 does *not* provide these functions, but they are
Meador Ingeb904e6e2013-03-05 21:47:40 +0000266 // generally available on POSIX-compliant systems:
David L. Jonesd21529f2017-01-23 23:16:46 +0000267 TLI.setUnavailable(LibFunc_access);
268 TLI.setUnavailable(LibFunc_bcmp);
269 TLI.setUnavailable(LibFunc_bcopy);
270 TLI.setUnavailable(LibFunc_bzero);
271 TLI.setUnavailable(LibFunc_chmod);
272 TLI.setUnavailable(LibFunc_chown);
273 TLI.setUnavailable(LibFunc_closedir);
274 TLI.setUnavailable(LibFunc_ctermid);
275 TLI.setUnavailable(LibFunc_fdopen);
276 TLI.setUnavailable(LibFunc_ffs);
277 TLI.setUnavailable(LibFunc_fileno);
278 TLI.setUnavailable(LibFunc_flockfile);
279 TLI.setUnavailable(LibFunc_fseeko);
280 TLI.setUnavailable(LibFunc_fstat);
281 TLI.setUnavailable(LibFunc_fstatvfs);
282 TLI.setUnavailable(LibFunc_ftello);
283 TLI.setUnavailable(LibFunc_ftrylockfile);
284 TLI.setUnavailable(LibFunc_funlockfile);
David L. Jonesd21529f2017-01-23 23:16:46 +0000285 TLI.setUnavailable(LibFunc_getitimer);
286 TLI.setUnavailable(LibFunc_getlogin_r);
287 TLI.setUnavailable(LibFunc_getpwnam);
288 TLI.setUnavailable(LibFunc_gettimeofday);
289 TLI.setUnavailable(LibFunc_htonl);
290 TLI.setUnavailable(LibFunc_htons);
291 TLI.setUnavailable(LibFunc_lchown);
292 TLI.setUnavailable(LibFunc_lstat);
293 TLI.setUnavailable(LibFunc_memccpy);
294 TLI.setUnavailable(LibFunc_mkdir);
295 TLI.setUnavailable(LibFunc_ntohl);
296 TLI.setUnavailable(LibFunc_ntohs);
297 TLI.setUnavailable(LibFunc_open);
298 TLI.setUnavailable(LibFunc_opendir);
299 TLI.setUnavailable(LibFunc_pclose);
300 TLI.setUnavailable(LibFunc_popen);
301 TLI.setUnavailable(LibFunc_pread);
302 TLI.setUnavailable(LibFunc_pwrite);
303 TLI.setUnavailable(LibFunc_read);
304 TLI.setUnavailable(LibFunc_readlink);
305 TLI.setUnavailable(LibFunc_realpath);
306 TLI.setUnavailable(LibFunc_rmdir);
307 TLI.setUnavailable(LibFunc_setitimer);
308 TLI.setUnavailable(LibFunc_stat);
309 TLI.setUnavailable(LibFunc_statvfs);
310 TLI.setUnavailable(LibFunc_stpcpy);
311 TLI.setUnavailable(LibFunc_stpncpy);
312 TLI.setUnavailable(LibFunc_strcasecmp);
313 TLI.setUnavailable(LibFunc_strncasecmp);
314 TLI.setUnavailable(LibFunc_times);
315 TLI.setUnavailable(LibFunc_uname);
316 TLI.setUnavailable(LibFunc_unlink);
317 TLI.setUnavailable(LibFunc_unsetenv);
318 TLI.setUnavailable(LibFunc_utime);
319 TLI.setUnavailable(LibFunc_utimes);
320 TLI.setUnavailable(LibFunc_write);
Meador Inge780a1862012-11-22 15:36:42 +0000321
Meador Ingeb904e6e2013-03-05 21:47:40 +0000322 // Win32 does *not* provide provide these functions, but they are
323 // specified by C99:
David L. Jonesd21529f2017-01-23 23:16:46 +0000324 TLI.setUnavailable(LibFunc_atoll);
325 TLI.setUnavailable(LibFunc_frexpf);
326 TLI.setUnavailable(LibFunc_llabs);
Meador Inge780a1862012-11-22 15:36:42 +0000327 }
328
Reid Klecknerf4355ee2013-12-26 19:17:04 +0000329 switch (T.getOS()) {
Reid Klecknerf4355ee2013-12-26 19:17:04 +0000330 case Triple::MacOSX:
Chandler Carruthf5689f82013-12-28 02:40:19 +0000331 // exp10 and exp10f are not available on OS X until 10.9 and iOS until 7.0
332 // and their names are __exp10 and __exp10f. exp10l is not available on
333 // OS X or iOS.
David L. Jonesd21529f2017-01-23 23:16:46 +0000334 TLI.setUnavailable(LibFunc_exp10l);
Reid Klecknerf4355ee2013-12-26 19:17:04 +0000335 if (T.isMacOSXVersionLT(10, 9)) {
David L. Jonesd21529f2017-01-23 23:16:46 +0000336 TLI.setUnavailable(LibFunc_exp10);
337 TLI.setUnavailable(LibFunc_exp10f);
Reid Klecknerf4355ee2013-12-26 19:17:04 +0000338 } else {
David L. Jonesd21529f2017-01-23 23:16:46 +0000339 TLI.setAvailableWithName(LibFunc_exp10, "__exp10");
340 TLI.setAvailableWithName(LibFunc_exp10f, "__exp10f");
Reid Klecknerf4355ee2013-12-26 19:17:04 +0000341 }
342 break;
343 case Triple::IOS:
Tim Northover89a6eef2015-11-02 18:00:00 +0000344 case Triple::TvOS:
Tim Northover8b403662015-10-28 22:51:16 +0000345 case Triple::WatchOS:
David L. Jonesd21529f2017-01-23 23:16:46 +0000346 TLI.setUnavailable(LibFunc_exp10l);
Tim Northover8b403662015-10-28 22:51:16 +0000347 if (!T.isWatchOS() && (T.isOSVersionLT(7, 0) ||
348 (T.isOSVersionLT(9, 0) &&
349 (T.getArch() == Triple::x86 ||
350 T.getArch() == Triple::x86_64)))) {
David L. Jonesd21529f2017-01-23 23:16:46 +0000351 TLI.setUnavailable(LibFunc_exp10);
352 TLI.setUnavailable(LibFunc_exp10f);
Reid Klecknerf4355ee2013-12-26 19:17:04 +0000353 } else {
David L. Jonesd21529f2017-01-23 23:16:46 +0000354 TLI.setAvailableWithName(LibFunc_exp10, "__exp10");
355 TLI.setAvailableWithName(LibFunc_exp10f, "__exp10f");
Reid Klecknerf4355ee2013-12-26 19:17:04 +0000356 }
357 break;
Chandler Carruthf5689f82013-12-28 02:40:19 +0000358 case Triple::Linux:
359 // exp10, exp10f, exp10l is available on Linux (GLIBC) but are extremely
360 // buggy prior to glibc version 2.18. Until this version is widely deployed
361 // or we have a reasonable detection strategy, we cannot use exp10 reliably
362 // on Linux.
363 //
364 // Fall through to disable all of them.
Justin Bognercd1d5aa2016-08-17 20:30:52 +0000365 LLVM_FALLTHROUGH;
Reid Klecknerf4355ee2013-12-26 19:17:04 +0000366 default:
David L. Jonesd21529f2017-01-23 23:16:46 +0000367 TLI.setUnavailable(LibFunc_exp10);
368 TLI.setUnavailable(LibFunc_exp10f);
369 TLI.setUnavailable(LibFunc_exp10l);
Reid Klecknerf4355ee2013-12-26 19:17:04 +0000370 }
371
Meador Inge780a1862012-11-22 15:36:42 +0000372 // ffsl is available on at least Darwin, Mac OS X, iOS, FreeBSD, and
373 // Linux (GLIBC):
374 // http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/ffsl.3.html
Davide Italiano83b34812015-11-01 17:00:13 +0000375 // http://svn.freebsd.org/base/head/lib/libc/string/ffsl.c
Meador Inge780a1862012-11-22 15:36:42 +0000376 // http://www.gnu.org/software/gnulib/manual/html_node/ffsl.html
377 switch (T.getOS()) {
378 case Triple::Darwin:
379 case Triple::MacOSX:
380 case Triple::IOS:
Tim Northover89a6eef2015-11-02 18:00:00 +0000381 case Triple::TvOS:
Tim Northover8b403662015-10-28 22:51:16 +0000382 case Triple::WatchOS:
Meador Inge780a1862012-11-22 15:36:42 +0000383 case Triple::FreeBSD:
384 case Triple::Linux:
385 break;
386 default:
David L. Jonesd21529f2017-01-23 23:16:46 +0000387 TLI.setUnavailable(LibFunc_ffsl);
Meador Inge780a1862012-11-22 15:36:42 +0000388 }
389
390 // ffsll is available on at least FreeBSD and Linux (GLIBC):
Davide Italiano83b34812015-11-01 17:00:13 +0000391 // http://svn.freebsd.org/base/head/lib/libc/string/ffsll.c
Meador Inge780a1862012-11-22 15:36:42 +0000392 // http://www.gnu.org/software/gnulib/manual/html_node/ffsll.html
393 switch (T.getOS()) {
Tim Northover89a6eef2015-11-02 18:00:00 +0000394 case Triple::Darwin:
395 case Triple::MacOSX:
396 case Triple::IOS:
397 case Triple::TvOS:
398 case Triple::WatchOS:
Meador Inge780a1862012-11-22 15:36:42 +0000399 case Triple::FreeBSD:
400 case Triple::Linux:
401 break;
402 default:
David L. Jonesd21529f2017-01-23 23:16:46 +0000403 TLI.setUnavailable(LibFunc_ffsll);
Joe Groffa81bcbb2012-04-17 23:05:54 +0000404 }
Meador Ingeb904e6e2013-03-05 21:47:40 +0000405
Davide Italianobfd30822015-11-09 23:23:20 +0000406 // The following functions are available on at least FreeBSD:
407 // http://svn.freebsd.org/base/head/lib/libc/string/fls.c
408 // http://svn.freebsd.org/base/head/lib/libc/string/flsl.c
409 // http://svn.freebsd.org/base/head/lib/libc/string/flsll.c
410 if (!T.isOSFreeBSD()) {
David L. Jonesd21529f2017-01-23 23:16:46 +0000411 TLI.setUnavailable(LibFunc_fls);
412 TLI.setUnavailable(LibFunc_flsl);
413 TLI.setUnavailable(LibFunc_flsll);
Davide Italianobfd30822015-11-09 23:23:20 +0000414 }
415
Eli Friedmane3a5fc62018-11-06 18:23:32 +0000416 // The following functions are only available on GNU/Linux (using glibc).
417 // Linux variants without glibc (eg: bionic, musl) may have some subset.
418 if (!T.isOSLinux() || !T.isGNUEnvironment()) {
David L. Jonesd21529f2017-01-23 23:16:46 +0000419 TLI.setUnavailable(LibFunc_dunder_strdup);
420 TLI.setUnavailable(LibFunc_dunder_strtok_r);
421 TLI.setUnavailable(LibFunc_dunder_isoc99_scanf);
422 TLI.setUnavailable(LibFunc_dunder_isoc99_sscanf);
423 TLI.setUnavailable(LibFunc_under_IO_getc);
424 TLI.setUnavailable(LibFunc_under_IO_putc);
Eli Friedmane3a5fc62018-11-06 18:23:32 +0000425 // But, Android and musl have memalign.
426 if (!T.isAndroid() && !T.isMusl())
Chih-Hung Hsieh60d1e792018-01-31 19:12:50 +0000427 TLI.setUnavailable(LibFunc_memalign);
David L. Jonesd21529f2017-01-23 23:16:46 +0000428 TLI.setUnavailable(LibFunc_fopen64);
429 TLI.setUnavailable(LibFunc_fseeko64);
430 TLI.setUnavailable(LibFunc_fstat64);
431 TLI.setUnavailable(LibFunc_fstatvfs64);
432 TLI.setUnavailable(LibFunc_ftello64);
433 TLI.setUnavailable(LibFunc_lstat64);
434 TLI.setUnavailable(LibFunc_open64);
435 TLI.setUnavailable(LibFunc_stat64);
436 TLI.setUnavailable(LibFunc_statvfs64);
437 TLI.setUnavailable(LibFunc_tmpfile64);
Sanjay Patel52149f02018-01-08 17:38:09 +0000438
439 // Relaxed math functions are included in math-finite.h on Linux (GLIBC).
440 TLI.setUnavailable(LibFunc_acos_finite);
441 TLI.setUnavailable(LibFunc_acosf_finite);
442 TLI.setUnavailable(LibFunc_acosl_finite);
443 TLI.setUnavailable(LibFunc_acosh_finite);
444 TLI.setUnavailable(LibFunc_acoshf_finite);
445 TLI.setUnavailable(LibFunc_acoshl_finite);
446 TLI.setUnavailable(LibFunc_asin_finite);
447 TLI.setUnavailable(LibFunc_asinf_finite);
448 TLI.setUnavailable(LibFunc_asinl_finite);
449 TLI.setUnavailable(LibFunc_atan2_finite);
450 TLI.setUnavailable(LibFunc_atan2f_finite);
451 TLI.setUnavailable(LibFunc_atan2l_finite);
452 TLI.setUnavailable(LibFunc_atanh_finite);
453 TLI.setUnavailable(LibFunc_atanhf_finite);
454 TLI.setUnavailable(LibFunc_atanhl_finite);
455 TLI.setUnavailable(LibFunc_cosh_finite);
456 TLI.setUnavailable(LibFunc_coshf_finite);
457 TLI.setUnavailable(LibFunc_coshl_finite);
458 TLI.setUnavailable(LibFunc_exp10_finite);
459 TLI.setUnavailable(LibFunc_exp10f_finite);
460 TLI.setUnavailable(LibFunc_exp10l_finite);
461 TLI.setUnavailable(LibFunc_exp2_finite);
462 TLI.setUnavailable(LibFunc_exp2f_finite);
463 TLI.setUnavailable(LibFunc_exp2l_finite);
464 TLI.setUnavailable(LibFunc_exp_finite);
465 TLI.setUnavailable(LibFunc_expf_finite);
466 TLI.setUnavailable(LibFunc_expl_finite);
467 TLI.setUnavailable(LibFunc_log10_finite);
468 TLI.setUnavailable(LibFunc_log10f_finite);
469 TLI.setUnavailable(LibFunc_log10l_finite);
470 TLI.setUnavailable(LibFunc_log2_finite);
471 TLI.setUnavailable(LibFunc_log2f_finite);
472 TLI.setUnavailable(LibFunc_log2l_finite);
473 TLI.setUnavailable(LibFunc_log_finite);
474 TLI.setUnavailable(LibFunc_logf_finite);
475 TLI.setUnavailable(LibFunc_logl_finite);
476 TLI.setUnavailable(LibFunc_pow_finite);
477 TLI.setUnavailable(LibFunc_powf_finite);
478 TLI.setUnavailable(LibFunc_powl_finite);
479 TLI.setUnavailable(LibFunc_sinh_finite);
480 TLI.setUnavailable(LibFunc_sinhf_finite);
481 TLI.setUnavailable(LibFunc_sinhl_finite);
Meador Ingeb904e6e2013-03-05 21:47:40 +0000482 }
Michael Zolotukhin6d8a2aa2015-03-17 19:50:55 +0000483
Martin Storsjoc1078872018-05-17 08:16:08 +0000484 if ((T.isOSLinux() && T.isGNUEnvironment()) ||
485 (T.isAndroid() && !T.isAndroidVersionLT(28))) {
David Bolvanskyca22d422018-05-16 11:39:52 +0000486 // available IO unlocked variants on GNU/Linux and Android P or later
487 TLI.setAvailable(LibFunc_getc_unlocked);
488 TLI.setAvailable(LibFunc_getchar_unlocked);
489 TLI.setAvailable(LibFunc_putc_unlocked);
490 TLI.setAvailable(LibFunc_putchar_unlocked);
491 TLI.setAvailable(LibFunc_fputc_unlocked);
492 TLI.setAvailable(LibFunc_fgetc_unlocked);
493 TLI.setAvailable(LibFunc_fread_unlocked);
494 TLI.setAvailable(LibFunc_fwrite_unlocked);
495 TLI.setAvailable(LibFunc_fputs_unlocked);
496 TLI.setAvailable(LibFunc_fgets_unlocked);
497 }
498
Justin Lebar51132882016-01-26 23:51:06 +0000499 // As currently implemented in clang, NVPTX code has no standard library to
500 // speak of. Headers provide a standard-ish library implementation, but many
501 // of the signatures are wrong -- for example, many libm functions are not
502 // extern "C".
503 //
504 // libdevice, an IR library provided by nvidia, is linked in by the front-end,
505 // but only used functions are provided to llvm. Moreover, most of the
506 // functions in libdevice don't map precisely to standard library functions.
507 //
508 // FIXME: Having no standard library prevents e.g. many fastmath
509 // optimizations, so this situation should be fixed.
David Majnemerae272d72016-03-31 21:29:57 +0000510 if (T.isNVPTX()) {
Justin Lebar51132882016-01-26 23:51:06 +0000511 TLI.disableAllFunctions();
David L. Jonesd21529f2017-01-23 23:16:46 +0000512 TLI.setAvailable(LibFunc_nvvm_reflect);
David Majnemerae272d72016-03-31 21:29:57 +0000513 } else {
David L. Jonesd21529f2017-01-23 23:16:46 +0000514 TLI.setUnavailable(LibFunc_nvvm_reflect);
David Majnemerae272d72016-03-31 21:29:57 +0000515 }
Justin Lebar51132882016-01-26 23:51:06 +0000516
Michael Zolotukhin6d8a2aa2015-03-17 19:50:55 +0000517 TLI.addVectorizableFunctionsFromVecLib(ClVectorLibrary);
Chris Lattner0e125bb2011-02-18 21:50:34 +0000518}
519
Chandler Carruthc0291862015-01-24 02:06:09 +0000520TargetLibraryInfoImpl::TargetLibraryInfoImpl() {
Chris Lattner0e125bb2011-02-18 21:50:34 +0000521 // Default to everything being available.
522 memset(AvailableArray, -1, sizeof(AvailableArray));
523
Bob Wilsonc740e3f2012-08-03 04:06:22 +0000524 initialize(*this, Triple(), StandardNames);
Chris Lattner0e125bb2011-02-18 21:50:34 +0000525}
526
Joel Jones74593982018-11-24 07:26:55 +0000527TargetLibraryInfoImpl::TargetLibraryInfoImpl(const Triple &T) {
Chris Lattner0e125bb2011-02-18 21:50:34 +0000528 // Default to everything being available.
529 memset(AvailableArray, -1, sizeof(AvailableArray));
Chandler Carruthb98f63d2015-01-15 10:41:28 +0000530
Bob Wilsonc740e3f2012-08-03 04:06:22 +0000531 initialize(*this, T, StandardNames);
Chris Lattner0e125bb2011-02-18 21:50:34 +0000532}
Chris Lattner1341df92011-02-18 22:34:03 +0000533
Chandler Carruthc0291862015-01-24 02:06:09 +0000534TargetLibraryInfoImpl::TargetLibraryInfoImpl(const TargetLibraryInfoImpl &TLI)
Joel Jones74593982018-11-24 07:26:55 +0000535 : CustomNames(TLI.CustomNames), ShouldExtI32Param(TLI.ShouldExtI32Param),
Marcin Koscielnicki5ae2c522016-11-21 11:57:11 +0000536 ShouldExtI32Return(TLI.ShouldExtI32Return),
537 ShouldSignExtI32Param(TLI.ShouldSignExtI32Param) {
Chris Lattner4c0d9e22011-05-21 20:09:13 +0000538 memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
Michael Zolotukhine8f25512015-03-17 19:22:30 +0000539 VectorDescs = TLI.VectorDescs;
540 ScalarDescs = TLI.ScalarDescs;
Chandler Carruth8ca43222015-01-15 11:39:46 +0000541}
542
Chandler Carruthc0291862015-01-24 02:06:09 +0000543TargetLibraryInfoImpl::TargetLibraryInfoImpl(TargetLibraryInfoImpl &&TLI)
Joel Jones74593982018-11-24 07:26:55 +0000544 : CustomNames(std::move(TLI.CustomNames)),
Marcin Koscielnicki5ae2c522016-11-21 11:57:11 +0000545 ShouldExtI32Param(TLI.ShouldExtI32Param),
546 ShouldExtI32Return(TLI.ShouldExtI32Return),
547 ShouldSignExtI32Param(TLI.ShouldSignExtI32Param) {
Chandler Carruth8ca43222015-01-15 11:39:46 +0000548 std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),
549 AvailableArray);
Michael Zolotukhine8f25512015-03-17 19:22:30 +0000550 VectorDescs = TLI.VectorDescs;
551 ScalarDescs = TLI.ScalarDescs;
Chandler Carruth8ca43222015-01-15 11:39:46 +0000552}
553
Chandler Carruthc0291862015-01-24 02:06:09 +0000554TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(const TargetLibraryInfoImpl &TLI) {
Eli Friedman489c0ff2011-11-17 01:27:36 +0000555 CustomNames = TLI.CustomNames;
Marcin Koscielnicki5ae2c522016-11-21 11:57:11 +0000556 ShouldExtI32Param = TLI.ShouldExtI32Param;
557 ShouldExtI32Return = TLI.ShouldExtI32Return;
558 ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;
Chandler Carruth8ca43222015-01-15 11:39:46 +0000559 memcpy(AvailableArray, TLI.AvailableArray, sizeof(AvailableArray));
560 return *this;
561}
562
Chandler Carruthc0291862015-01-24 02:06:09 +0000563TargetLibraryInfoImpl &TargetLibraryInfoImpl::operator=(TargetLibraryInfoImpl &&TLI) {
Chandler Carruth8ca43222015-01-15 11:39:46 +0000564 CustomNames = std::move(TLI.CustomNames);
Marcin Koscielnicki5ae2c522016-11-21 11:57:11 +0000565 ShouldExtI32Param = TLI.ShouldExtI32Param;
566 ShouldExtI32Return = TLI.ShouldExtI32Return;
567 ShouldSignExtI32Param = TLI.ShouldSignExtI32Param;
Chandler Carruth8ca43222015-01-15 11:39:46 +0000568 std::move(std::begin(TLI.AvailableArray), std::end(TLI.AvailableArray),
569 AvailableArray);
570 return *this;
Chris Lattner4c0d9e22011-05-21 20:09:13 +0000571}
572
Michael Zolotukhin21abdf92015-03-02 23:24:40 +0000573static StringRef sanitizeFunctionName(StringRef funcName) {
Benjamin Kramer160f72d2013-03-09 13:48:23 +0000574 // Filter out empty names and names containing null bytes, those can't be in
575 // our table.
576 if (funcName.empty() || funcName.find('\0') != StringRef::npos)
Michael Zolotukhin21abdf92015-03-02 23:24:40 +0000577 return StringRef();
Benjamin Kramer160f72d2013-03-09 13:48:23 +0000578
Meador Ingeb904e6e2013-03-05 21:47:40 +0000579 // Check for \01 prefix that is used to mangle __asm declarations and
580 // strip it if present.
Peter Collingbourne6f0ecca2017-05-16 00:39:01 +0000581 return GlobalValue::dropLLVMManglingEscape(funcName);
Michael Zolotukhin21abdf92015-03-02 23:24:40 +0000582}
583
584bool TargetLibraryInfoImpl::getLibFunc(StringRef funcName,
David L. Jonesd21529f2017-01-23 23:16:46 +0000585 LibFunc &F) const {
Mehdi Amini9a72cd72016-10-01 03:10:48 +0000586 StringRef const *Start = &StandardNames[0];
David L. Jonesd21529f2017-01-23 23:16:46 +0000587 StringRef const *End = &StandardNames[NumLibFuncs];
Michael Zolotukhin21abdf92015-03-02 23:24:40 +0000588
589 funcName = sanitizeFunctionName(funcName);
590 if (funcName.empty())
591 return false;
592
Mehdi Amini9a72cd72016-10-01 03:10:48 +0000593 StringRef const *I = std::lower_bound(
594 Start, End, funcName, [](StringRef LHS, StringRef RHS) {
595 return LHS < RHS;
Michael Zolotukhind3b76a32015-03-02 20:50:08 +0000596 });
Bob Wilsonc740e3f2012-08-03 04:06:22 +0000597 if (I != End && *I == funcName) {
David L. Jonesd21529f2017-01-23 23:16:46 +0000598 F = (LibFunc)(I - Start);
Bob Wilsonc740e3f2012-08-03 04:06:22 +0000599 return true;
600 }
601 return false;
602}
Chris Lattner4c0d9e22011-05-21 20:09:13 +0000603
Ahmed Bougachad765a822016-04-27 19:04:35 +0000604bool TargetLibraryInfoImpl::isValidProtoForLibFunc(const FunctionType &FTy,
David L. Jonesd21529f2017-01-23 23:16:46 +0000605 LibFunc F,
Ahmed Bougachad765a822016-04-27 19:04:35 +0000606 const DataLayout *DL) const {
607 LLVMContext &Ctx = FTy.getContext();
608 Type *PCharTy = Type::getInt8PtrTy(Ctx);
609 Type *SizeTTy = DL ? DL->getIntPtrType(Ctx, /*AS=*/0) : nullptr;
610 auto IsSizeTTy = [SizeTTy](Type *Ty) {
611 return SizeTTy ? Ty == SizeTTy : Ty->isIntegerTy();
612 };
613 unsigned NumParams = FTy.getNumParams();
614
615 switch (F) {
Calixte Denizetc3bed1e2018-11-07 13:49:17 +0000616 case LibFunc_execl:
617 case LibFunc_execlp:
Calixte Denizet8f07efc2018-11-07 14:46:26 +0000618 case LibFunc_execle:
Calixte Denizetc3bed1e2018-11-07 13:49:17 +0000619 return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
620 FTy.getParamType(1)->isPointerTy() &&
621 FTy.getReturnType()->isIntegerTy(32));
Calixte Denizetc3bed1e2018-11-07 13:49:17 +0000622 case LibFunc_execv:
623 case LibFunc_execvp:
624 return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
625 FTy.getParamType(1)->isPointerTy() &&
626 FTy.getReturnType()->isIntegerTy(32));
627 case LibFunc_execvP:
628 case LibFunc_execvpe:
629 case LibFunc_execve:
630 return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() &&
631 FTy.getParamType(1)->isPointerTy() &&
632 FTy.getParamType(2)->isPointerTy() &&
633 FTy.getReturnType()->isIntegerTy(32));
David L. Jonesd21529f2017-01-23 23:16:46 +0000634 case LibFunc_strlen:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000635 return (NumParams == 1 && FTy.getParamType(0)->isPointerTy() &&
636 FTy.getReturnType()->isIntegerTy());
637
David L. Jonesd21529f2017-01-23 23:16:46 +0000638 case LibFunc_strchr:
639 case LibFunc_strrchr:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000640 return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
641 FTy.getParamType(0) == FTy.getReturnType() &&
642 FTy.getParamType(1)->isIntegerTy());
643
David L. Jonesd21529f2017-01-23 23:16:46 +0000644 case LibFunc_strtol:
645 case LibFunc_strtod:
646 case LibFunc_strtof:
647 case LibFunc_strtoul:
648 case LibFunc_strtoll:
649 case LibFunc_strtold:
650 case LibFunc_strtoull:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000651 return ((NumParams == 2 || NumParams == 3) &&
652 FTy.getParamType(0)->isPointerTy() &&
653 FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000654 case LibFunc_strcat:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000655 return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
656 FTy.getParamType(0) == FTy.getReturnType() &&
657 FTy.getParamType(1) == FTy.getReturnType());
658
David L. Jonesd21529f2017-01-23 23:16:46 +0000659 case LibFunc_strncat:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000660 return (NumParams == 3 && FTy.getReturnType()->isPointerTy() &&
661 FTy.getParamType(0) == FTy.getReturnType() &&
662 FTy.getParamType(1) == FTy.getReturnType() &&
Igor Laevsky7bd3fb12017-12-18 10:31:58 +0000663 IsSizeTTy(FTy.getParamType(2)));
Ahmed Bougachad765a822016-04-27 19:04:35 +0000664
David L. Jonesd21529f2017-01-23 23:16:46 +0000665 case LibFunc_strcpy_chk:
666 case LibFunc_stpcpy_chk:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000667 --NumParams;
668 if (!IsSizeTTy(FTy.getParamType(NumParams)))
669 return false;
Justin Bognerb03fd122016-08-17 05:10:15 +0000670 LLVM_FALLTHROUGH;
David L. Jonesd21529f2017-01-23 23:16:46 +0000671 case LibFunc_strcpy:
672 case LibFunc_stpcpy:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000673 return (NumParams == 2 && FTy.getReturnType() == FTy.getParamType(0) &&
674 FTy.getParamType(0) == FTy.getParamType(1) &&
675 FTy.getParamType(0) == PCharTy);
676
David L. Jonesd21529f2017-01-23 23:16:46 +0000677 case LibFunc_strncpy_chk:
678 case LibFunc_stpncpy_chk:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000679 --NumParams;
680 if (!IsSizeTTy(FTy.getParamType(NumParams)))
681 return false;
Justin Bognerb03fd122016-08-17 05:10:15 +0000682 LLVM_FALLTHROUGH;
David L. Jonesd21529f2017-01-23 23:16:46 +0000683 case LibFunc_strncpy:
684 case LibFunc_stpncpy:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000685 return (NumParams == 3 && FTy.getReturnType() == FTy.getParamType(0) &&
686 FTy.getParamType(0) == FTy.getParamType(1) &&
687 FTy.getParamType(0) == PCharTy &&
Igor Laevsky7bd3fb12017-12-18 10:31:58 +0000688 IsSizeTTy(FTy.getParamType(2)));
Ahmed Bougachad765a822016-04-27 19:04:35 +0000689
David L. Jonesd21529f2017-01-23 23:16:46 +0000690 case LibFunc_strxfrm:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000691 return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() &&
692 FTy.getParamType(1)->isPointerTy());
693
David L. Jonesd21529f2017-01-23 23:16:46 +0000694 case LibFunc_strcmp:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000695 return (NumParams == 2 && FTy.getReturnType()->isIntegerTy(32) &&
696 FTy.getParamType(0)->isPointerTy() &&
697 FTy.getParamType(0) == FTy.getParamType(1));
698
David L. Jonesd21529f2017-01-23 23:16:46 +0000699 case LibFunc_strncmp:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000700 return (NumParams == 3 && FTy.getReturnType()->isIntegerTy(32) &&
701 FTy.getParamType(0)->isPointerTy() &&
702 FTy.getParamType(0) == FTy.getParamType(1) &&
Igor Laevsky7bd3fb12017-12-18 10:31:58 +0000703 IsSizeTTy(FTy.getParamType(2)));
Ahmed Bougachad765a822016-04-27 19:04:35 +0000704
David L. Jonesd21529f2017-01-23 23:16:46 +0000705 case LibFunc_strspn:
706 case LibFunc_strcspn:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000707 return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
708 FTy.getParamType(0) == FTy.getParamType(1) &&
709 FTy.getReturnType()->isIntegerTy());
710
David L. Jonesd21529f2017-01-23 23:16:46 +0000711 case LibFunc_strcoll:
712 case LibFunc_strcasecmp:
713 case LibFunc_strncasecmp:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000714 return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
715 FTy.getParamType(1)->isPointerTy());
716
David L. Jonesd21529f2017-01-23 23:16:46 +0000717 case LibFunc_strstr:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000718 return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
719 FTy.getParamType(0)->isPointerTy() &&
720 FTy.getParamType(1)->isPointerTy());
721
David L. Jonesd21529f2017-01-23 23:16:46 +0000722 case LibFunc_strpbrk:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000723 return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
724 FTy.getReturnType() == FTy.getParamType(0) &&
725 FTy.getParamType(0) == FTy.getParamType(1));
726
David L. Jonesd21529f2017-01-23 23:16:46 +0000727 case LibFunc_strtok:
728 case LibFunc_strtok_r:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000729 return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000730 case LibFunc_scanf:
731 case LibFunc_setbuf:
732 case LibFunc_setvbuf:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000733 return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000734 case LibFunc_strdup:
735 case LibFunc_strndup:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000736 return (NumParams >= 1 && FTy.getReturnType()->isPointerTy() &&
737 FTy.getParamType(0)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000738 case LibFunc_sscanf:
739 case LibFunc_stat:
740 case LibFunc_statvfs:
741 case LibFunc_siprintf:
742 case LibFunc_sprintf:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000743 return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
Martin Storsjo0d7c3772018-05-11 16:53:56 +0000744 FTy.getParamType(1)->isPointerTy() &&
745 FTy.getReturnType()->isIntegerTy(32));
David L. Jonesd21529f2017-01-23 23:16:46 +0000746 case LibFunc_snprintf:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000747 return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() &&
Martin Storsjo0d7c3772018-05-11 16:53:56 +0000748 FTy.getParamType(2)->isPointerTy() &&
749 FTy.getReturnType()->isIntegerTy(32));
David L. Jonesd21529f2017-01-23 23:16:46 +0000750 case LibFunc_setitimer:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000751 return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() &&
752 FTy.getParamType(2)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000753 case LibFunc_system:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000754 return (NumParams == 1 && FTy.getParamType(0)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000755 case LibFunc_malloc:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000756 return (NumParams == 1 && FTy.getReturnType()->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000757 case LibFunc_memcmp:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +0000758 return (NumParams == 3 && FTy.getReturnType()->isIntegerTy(32) &&
759 FTy.getParamType(0)->isPointerTy() &&
760 FTy.getParamType(1)->isPointerTy());
Ahmed Bougachad765a822016-04-27 19:04:35 +0000761
David L. Jonesd21529f2017-01-23 23:16:46 +0000762 case LibFunc_memchr:
763 case LibFunc_memrchr:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +0000764 return (NumParams == 3 && FTy.getReturnType()->isPointerTy() &&
765 FTy.getReturnType() == FTy.getParamType(0) &&
Ahmed Bougachad765a822016-04-27 19:04:35 +0000766 FTy.getParamType(1)->isIntegerTy(32) &&
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +0000767 IsSizeTTy(FTy.getParamType(2)));
David L. Jonesd21529f2017-01-23 23:16:46 +0000768 case LibFunc_modf:
769 case LibFunc_modff:
770 case LibFunc_modfl:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000771 return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy());
772
David L. Jonesd21529f2017-01-23 23:16:46 +0000773 case LibFunc_memcpy_chk:
774 case LibFunc_memmove_chk:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000775 --NumParams;
776 if (!IsSizeTTy(FTy.getParamType(NumParams)))
777 return false;
Justin Bognerb03fd122016-08-17 05:10:15 +0000778 LLVM_FALLTHROUGH;
David L. Jonesd21529f2017-01-23 23:16:46 +0000779 case LibFunc_memcpy:
780 case LibFunc_mempcpy:
781 case LibFunc_memmove:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000782 return (NumParams == 3 && FTy.getReturnType() == FTy.getParamType(0) &&
783 FTy.getParamType(0)->isPointerTy() &&
784 FTy.getParamType(1)->isPointerTy() &&
785 IsSizeTTy(FTy.getParamType(2)));
786
David L. Jonesd21529f2017-01-23 23:16:46 +0000787 case LibFunc_memset_chk:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000788 --NumParams;
789 if (!IsSizeTTy(FTy.getParamType(NumParams)))
790 return false;
Justin Bognerb03fd122016-08-17 05:10:15 +0000791 LLVM_FALLTHROUGH;
David L. Jonesd21529f2017-01-23 23:16:46 +0000792 case LibFunc_memset:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000793 return (NumParams == 3 && FTy.getReturnType() == FTy.getParamType(0) &&
794 FTy.getParamType(0)->isPointerTy() &&
795 FTy.getParamType(1)->isIntegerTy() &&
796 IsSizeTTy(FTy.getParamType(2)));
797
David L. Jonesd21529f2017-01-23 23:16:46 +0000798 case LibFunc_memccpy:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000799 return (NumParams >= 2 && FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000800 case LibFunc_memalign:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000801 return (FTy.getReturnType()->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000802 case LibFunc_realloc:
803 case LibFunc_reallocf:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +0000804 return (NumParams == 2 && FTy.getReturnType() == PCharTy &&
805 FTy.getParamType(0) == FTy.getReturnType() &&
806 IsSizeTTy(FTy.getParamType(1)));
David L. Jonesd21529f2017-01-23 23:16:46 +0000807 case LibFunc_read:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000808 return (NumParams == 3 && FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000809 case LibFunc_rewind:
810 case LibFunc_rmdir:
811 case LibFunc_remove:
812 case LibFunc_realpath:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000813 return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000814 case LibFunc_rename:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000815 return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
816 FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000817 case LibFunc_readlink:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000818 return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
819 FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000820 case LibFunc_write:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000821 return (NumParams == 3 && FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000822 case LibFunc_bcopy:
823 case LibFunc_bcmp:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000824 return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() &&
825 FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000826 case LibFunc_bzero:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000827 return (NumParams == 2 && FTy.getParamType(0)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000828 case LibFunc_calloc:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000829 return (NumParams == 2 && FTy.getReturnType()->isPointerTy());
Ahmed Bougacha1fe3f1c2016-05-25 20:22:45 +0000830
David L. Jonesd21529f2017-01-23 23:16:46 +0000831 case LibFunc_atof:
832 case LibFunc_atoi:
833 case LibFunc_atol:
834 case LibFunc_atoll:
835 case LibFunc_ferror:
836 case LibFunc_getenv:
837 case LibFunc_getpwnam:
838 case LibFunc_iprintf:
839 case LibFunc_pclose:
840 case LibFunc_perror:
841 case LibFunc_printf:
842 case LibFunc_puts:
843 case LibFunc_uname:
844 case LibFunc_under_IO_getc:
845 case LibFunc_unlink:
846 case LibFunc_unsetenv:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000847 return (NumParams == 1 && FTy.getParamType(0)->isPointerTy());
Ahmed Bougacha1fe3f1c2016-05-25 20:22:45 +0000848
David L. Jonesd21529f2017-01-23 23:16:46 +0000849 case LibFunc_access:
850 case LibFunc_chmod:
851 case LibFunc_chown:
852 case LibFunc_clearerr:
853 case LibFunc_closedir:
854 case LibFunc_ctermid:
855 case LibFunc_fclose:
856 case LibFunc_feof:
857 case LibFunc_fflush:
858 case LibFunc_fgetc:
David Bolvanskyca22d422018-05-16 11:39:52 +0000859 case LibFunc_fgetc_unlocked:
David L. Jonesd21529f2017-01-23 23:16:46 +0000860 case LibFunc_fileno:
861 case LibFunc_flockfile:
862 case LibFunc_free:
863 case LibFunc_fseek:
864 case LibFunc_fseeko64:
865 case LibFunc_fseeko:
866 case LibFunc_fsetpos:
867 case LibFunc_ftell:
868 case LibFunc_ftello64:
869 case LibFunc_ftello:
870 case LibFunc_ftrylockfile:
871 case LibFunc_funlockfile:
872 case LibFunc_getc:
873 case LibFunc_getc_unlocked:
874 case LibFunc_getlogin_r:
875 case LibFunc_mkdir:
876 case LibFunc_mktime:
877 case LibFunc_times:
Ahmed Bougacha1fe3f1c2016-05-25 20:22:45 +0000878 return (NumParams != 0 && FTy.getParamType(0)->isPointerTy());
879
David L. Jonesd21529f2017-01-23 23:16:46 +0000880 case LibFunc_fopen:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000881 return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
882 FTy.getParamType(0)->isPointerTy() &&
883 FTy.getParamType(1)->isPointerTy());
Calixte Denizetc3bed1e2018-11-07 13:49:17 +0000884 case LibFunc_fork:
885 return (NumParams == 0 && FTy.getReturnType()->isIntegerTy(32));
David L. Jonesd21529f2017-01-23 23:16:46 +0000886 case LibFunc_fdopen:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000887 return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
888 FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000889 case LibFunc_fputc:
David Bolvanskyca22d422018-05-16 11:39:52 +0000890 case LibFunc_fputc_unlocked:
David L. Jonesd21529f2017-01-23 23:16:46 +0000891 case LibFunc_fstat:
892 case LibFunc_frexp:
893 case LibFunc_frexpf:
894 case LibFunc_frexpl:
895 case LibFunc_fstatvfs:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000896 return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000897 case LibFunc_fgets:
David Bolvanskyca22d422018-05-16 11:39:52 +0000898 case LibFunc_fgets_unlocked:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000899 return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() &&
900 FTy.getParamType(2)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000901 case LibFunc_fread:
David Bolvanskyca22d422018-05-16 11:39:52 +0000902 case LibFunc_fread_unlocked:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000903 return (NumParams == 4 && FTy.getParamType(0)->isPointerTy() &&
904 FTy.getParamType(3)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000905 case LibFunc_fwrite:
David Bolvanskyca22d422018-05-16 11:39:52 +0000906 case LibFunc_fwrite_unlocked:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000907 return (NumParams == 4 && FTy.getReturnType()->isIntegerTy() &&
908 FTy.getParamType(0)->isPointerTy() &&
909 FTy.getParamType(1)->isIntegerTy() &&
910 FTy.getParamType(2)->isIntegerTy() &&
911 FTy.getParamType(3)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000912 case LibFunc_fputs:
David Bolvanskyca22d422018-05-16 11:39:52 +0000913 case LibFunc_fputs_unlocked:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000914 return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
915 FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000916 case LibFunc_fscanf:
917 case LibFunc_fiprintf:
918 case LibFunc_fprintf:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +0000919 return (NumParams >= 2 && FTy.getReturnType()->isIntegerTy() &&
920 FTy.getParamType(0)->isPointerTy() &&
Ahmed Bougachad765a822016-04-27 19:04:35 +0000921 FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000922 case LibFunc_fgetpos:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000923 return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
924 FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000925 case LibFunc_getchar:
David Bolvanskyca22d422018-05-16 11:39:52 +0000926 case LibFunc_getchar_unlocked:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +0000927 return (NumParams == 0 && FTy.getReturnType()->isIntegerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000928 case LibFunc_gets:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +0000929 return (NumParams == 1 && FTy.getParamType(0) == PCharTy);
David L. Jonesd21529f2017-01-23 23:16:46 +0000930 case LibFunc_getitimer:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000931 return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000932 case LibFunc_ungetc:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000933 return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000934 case LibFunc_utime:
935 case LibFunc_utimes:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000936 return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
937 FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000938 case LibFunc_putc:
David Bolvanskyca22d422018-05-16 11:39:52 +0000939 case LibFunc_putc_unlocked:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000940 return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000941 case LibFunc_pread:
942 case LibFunc_pwrite:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000943 return (NumParams == 4 && FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000944 case LibFunc_popen:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000945 return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
946 FTy.getParamType(0)->isPointerTy() &&
947 FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000948 case LibFunc_vscanf:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000949 return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000950 case LibFunc_vsscanf:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000951 return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() &&
952 FTy.getParamType(2)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000953 case LibFunc_vfscanf:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000954 return (NumParams == 3 && FTy.getParamType(1)->isPointerTy() &&
955 FTy.getParamType(2)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000956 case LibFunc_valloc:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000957 return (FTy.getReturnType()->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000958 case LibFunc_vprintf:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000959 return (NumParams == 2 && FTy.getParamType(0)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000960 case LibFunc_vfprintf:
961 case LibFunc_vsprintf:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000962 return (NumParams == 3 && FTy.getParamType(0)->isPointerTy() &&
963 FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000964 case LibFunc_vsnprintf:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000965 return (NumParams == 4 && FTy.getParamType(0)->isPointerTy() &&
966 FTy.getParamType(2)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000967 case LibFunc_open:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000968 return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000969 case LibFunc_opendir:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000970 return (NumParams == 1 && FTy.getReturnType()->isPointerTy() &&
971 FTy.getParamType(0)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000972 case LibFunc_tmpfile:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000973 return (FTy.getReturnType()->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000974 case LibFunc_htonl:
975 case LibFunc_ntohl:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +0000976 return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(32) &&
977 FTy.getReturnType() == FTy.getParamType(0));
David L. Jonesd21529f2017-01-23 23:16:46 +0000978 case LibFunc_htons:
979 case LibFunc_ntohs:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +0000980 return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(16) &&
981 FTy.getReturnType() == FTy.getParamType(0));
David L. Jonesd21529f2017-01-23 23:16:46 +0000982 case LibFunc_lstat:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000983 return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
984 FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000985 case LibFunc_lchown:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000986 return (NumParams == 3 && FTy.getParamType(0)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000987 case LibFunc_qsort:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000988 return (NumParams == 4 && FTy.getParamType(3)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000989 case LibFunc_dunder_strdup:
990 case LibFunc_dunder_strndup:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000991 return (NumParams >= 1 && FTy.getReturnType()->isPointerTy() &&
992 FTy.getParamType(0)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000993 case LibFunc_dunder_strtok_r:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000994 return (NumParams == 3 && FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000995 case LibFunc_under_IO_putc:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000996 return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000997 case LibFunc_dunder_isoc99_scanf:
Ahmed Bougachad765a822016-04-27 19:04:35 +0000998 return (NumParams >= 1 && FTy.getParamType(0)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +0000999 case LibFunc_stat64:
1000 case LibFunc_lstat64:
1001 case LibFunc_statvfs64:
Michael Kuperstein79dcc272016-09-20 23:10:31 +00001002 return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
Ahmed Bougachad765a822016-04-27 19:04:35 +00001003 FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +00001004 case LibFunc_dunder_isoc99_sscanf:
Michael Kuperstein79dcc272016-09-20 23:10:31 +00001005 return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy() &&
Ahmed Bougachad765a822016-04-27 19:04:35 +00001006 FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +00001007 case LibFunc_fopen64:
Ahmed Bougachad765a822016-04-27 19:04:35 +00001008 return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
1009 FTy.getParamType(0)->isPointerTy() &&
1010 FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +00001011 case LibFunc_tmpfile64:
Ahmed Bougachad765a822016-04-27 19:04:35 +00001012 return (FTy.getReturnType()->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +00001013 case LibFunc_fstat64:
1014 case LibFunc_fstatvfs64:
Ahmed Bougachad765a822016-04-27 19:04:35 +00001015 return (NumParams == 2 && FTy.getParamType(1)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +00001016 case LibFunc_open64:
Ahmed Bougachad765a822016-04-27 19:04:35 +00001017 return (NumParams >= 2 && FTy.getParamType(0)->isPointerTy());
David L. Jonesd21529f2017-01-23 23:16:46 +00001018 case LibFunc_gettimeofday:
Ahmed Bougachad765a822016-04-27 19:04:35 +00001019 return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
1020 FTy.getParamType(1)->isPointerTy());
1021
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001022 // new(unsigned int);
David L. Jonesd21529f2017-01-23 23:16:46 +00001023 case LibFunc_Znwj:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001024 // new(unsigned long);
David L. Jonesd21529f2017-01-23 23:16:46 +00001025 case LibFunc_Znwm:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001026 // new[](unsigned int);
David L. Jonesd21529f2017-01-23 23:16:46 +00001027 case LibFunc_Znaj:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001028 // new[](unsigned long);
David L. Jonesd21529f2017-01-23 23:16:46 +00001029 case LibFunc_Znam:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001030 // new(unsigned int);
David L. Jonesd21529f2017-01-23 23:16:46 +00001031 case LibFunc_msvc_new_int:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001032 // new(unsigned long long);
David L. Jonesd21529f2017-01-23 23:16:46 +00001033 case LibFunc_msvc_new_longlong:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001034 // new[](unsigned int);
David L. Jonesd21529f2017-01-23 23:16:46 +00001035 case LibFunc_msvc_new_array_int:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001036 // new[](unsigned long long);
David L. Jonesd21529f2017-01-23 23:16:46 +00001037 case LibFunc_msvc_new_array_longlong:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001038 return (NumParams == 1 && FTy.getReturnType()->isPointerTy());
1039
1040 // new(unsigned int, nothrow);
David L. Jonesd21529f2017-01-23 23:16:46 +00001041 case LibFunc_ZnwjRKSt9nothrow_t:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001042 // new(unsigned long, nothrow);
David L. Jonesd21529f2017-01-23 23:16:46 +00001043 case LibFunc_ZnwmRKSt9nothrow_t:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001044 // new[](unsigned int, nothrow);
David L. Jonesd21529f2017-01-23 23:16:46 +00001045 case LibFunc_ZnajRKSt9nothrow_t:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001046 // new[](unsigned long, nothrow);
David L. Jonesd21529f2017-01-23 23:16:46 +00001047 case LibFunc_ZnamRKSt9nothrow_t:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001048 // new(unsigned int, nothrow);
David L. Jonesd21529f2017-01-23 23:16:46 +00001049 case LibFunc_msvc_new_int_nothrow:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001050 // new(unsigned long long, nothrow);
David L. Jonesd21529f2017-01-23 23:16:46 +00001051 case LibFunc_msvc_new_longlong_nothrow:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001052 // new[](unsigned int, nothrow);
David L. Jonesd21529f2017-01-23 23:16:46 +00001053 case LibFunc_msvc_new_array_int_nothrow:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001054 // new[](unsigned long long, nothrow);
David L. Jonesd21529f2017-01-23 23:16:46 +00001055 case LibFunc_msvc_new_array_longlong_nothrow:
Eric Fiselier96bbec72018-04-04 19:01:51 +00001056 // new(unsigned int, align_val_t)
1057 case LibFunc_ZnwjSt11align_val_t:
1058 // new(unsigned long, align_val_t)
1059 case LibFunc_ZnwmSt11align_val_t:
1060 // new[](unsigned int, align_val_t)
1061 case LibFunc_ZnajSt11align_val_t:
1062 // new[](unsigned long, align_val_t)
1063 case LibFunc_ZnamSt11align_val_t:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001064 return (NumParams == 2 && FTy.getReturnType()->isPointerTy());
1065
Eric Fiselier96bbec72018-04-04 19:01:51 +00001066 // new(unsigned int, align_val_t, nothrow)
1067 case LibFunc_ZnwjSt11align_val_tRKSt9nothrow_t:
1068 // new(unsigned long, align_val_t, nothrow)
1069 case LibFunc_ZnwmSt11align_val_tRKSt9nothrow_t:
1070 // new[](unsigned int, align_val_t, nothrow)
1071 case LibFunc_ZnajSt11align_val_tRKSt9nothrow_t:
1072 // new[](unsigned long, align_val_t, nothrow)
1073 case LibFunc_ZnamSt11align_val_tRKSt9nothrow_t:
1074 return (NumParams == 3 && FTy.getReturnType()->isPointerTy());
1075
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001076 // void operator delete[](void*);
David L. Jonesd21529f2017-01-23 23:16:46 +00001077 case LibFunc_ZdaPv:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001078 // void operator delete(void*);
David L. Jonesd21529f2017-01-23 23:16:46 +00001079 case LibFunc_ZdlPv:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001080 // void operator delete[](void*);
David L. Jonesd21529f2017-01-23 23:16:46 +00001081 case LibFunc_msvc_delete_array_ptr32:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001082 // void operator delete[](void*);
David L. Jonesd21529f2017-01-23 23:16:46 +00001083 case LibFunc_msvc_delete_array_ptr64:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001084 // void operator delete(void*);
David L. Jonesd21529f2017-01-23 23:16:46 +00001085 case LibFunc_msvc_delete_ptr32:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001086 // void operator delete(void*);
David L. Jonesd21529f2017-01-23 23:16:46 +00001087 case LibFunc_msvc_delete_ptr64:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001088 return (NumParams == 1 && FTy.getParamType(0)->isPointerTy());
1089
1090 // void operator delete[](void*, nothrow);
David L. Jonesd21529f2017-01-23 23:16:46 +00001091 case LibFunc_ZdaPvRKSt9nothrow_t:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001092 // void operator delete[](void*, unsigned int);
David L. Jonesd21529f2017-01-23 23:16:46 +00001093 case LibFunc_ZdaPvj:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001094 // void operator delete[](void*, unsigned long);
David L. Jonesd21529f2017-01-23 23:16:46 +00001095 case LibFunc_ZdaPvm:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001096 // void operator delete(void*, nothrow);
David L. Jonesd21529f2017-01-23 23:16:46 +00001097 case LibFunc_ZdlPvRKSt9nothrow_t:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001098 // void operator delete(void*, unsigned int);
David L. Jonesd21529f2017-01-23 23:16:46 +00001099 case LibFunc_ZdlPvj:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001100 // void operator delete(void*, unsigned long);
David L. Jonesd21529f2017-01-23 23:16:46 +00001101 case LibFunc_ZdlPvm:
Eric Fiselier96bbec72018-04-04 19:01:51 +00001102 // void operator delete(void*, align_val_t)
1103 case LibFunc_ZdlPvSt11align_val_t:
1104 // void operator delete[](void*, align_val_t)
1105 case LibFunc_ZdaPvSt11align_val_t:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001106 // void operator delete[](void*, unsigned int);
David L. Jonesd21529f2017-01-23 23:16:46 +00001107 case LibFunc_msvc_delete_array_ptr32_int:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001108 // void operator delete[](void*, nothrow);
David L. Jonesd21529f2017-01-23 23:16:46 +00001109 case LibFunc_msvc_delete_array_ptr32_nothrow:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001110 // void operator delete[](void*, unsigned long long);
David L. Jonesd21529f2017-01-23 23:16:46 +00001111 case LibFunc_msvc_delete_array_ptr64_longlong:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001112 // void operator delete[](void*, nothrow);
David L. Jonesd21529f2017-01-23 23:16:46 +00001113 case LibFunc_msvc_delete_array_ptr64_nothrow:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001114 // void operator delete(void*, unsigned int);
David L. Jonesd21529f2017-01-23 23:16:46 +00001115 case LibFunc_msvc_delete_ptr32_int:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001116 // void operator delete(void*, nothrow);
David L. Jonesd21529f2017-01-23 23:16:46 +00001117 case LibFunc_msvc_delete_ptr32_nothrow:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001118 // void operator delete(void*, unsigned long long);
David L. Jonesd21529f2017-01-23 23:16:46 +00001119 case LibFunc_msvc_delete_ptr64_longlong:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001120 // void operator delete(void*, nothrow);
David L. Jonesd21529f2017-01-23 23:16:46 +00001121 case LibFunc_msvc_delete_ptr64_nothrow:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001122 return (NumParams == 2 && FTy.getParamType(0)->isPointerTy());
Ahmed Bougachad765a822016-04-27 19:04:35 +00001123
Eric Fiselier96bbec72018-04-04 19:01:51 +00001124 // void operator delete(void*, align_val_t, nothrow)
1125 case LibFunc_ZdlPvSt11align_val_tRKSt9nothrow_t:
1126 // void operator delete[](void*, align_val_t, nothrow)
1127 case LibFunc_ZdaPvSt11align_val_tRKSt9nothrow_t:
1128 return (NumParams == 3 && FTy.getParamType(0)->isPointerTy());
1129
David L. Jonesd21529f2017-01-23 23:16:46 +00001130 case LibFunc_memset_pattern16:
Ahmed Bougachad765a822016-04-27 19:04:35 +00001131 return (!FTy.isVarArg() && NumParams == 3 &&
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001132 FTy.getParamType(0)->isPointerTy() &&
1133 FTy.getParamType(1)->isPointerTy() &&
1134 FTy.getParamType(2)->isIntegerTy());
Ahmed Bougachad765a822016-04-27 19:04:35 +00001135
David L. Jonesd21529f2017-01-23 23:16:46 +00001136 case LibFunc_cxa_guard_abort:
1137 case LibFunc_cxa_guard_acquire:
1138 case LibFunc_cxa_guard_release:
1139 case LibFunc_nvvm_reflect:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001140 return (NumParams == 1 && FTy.getParamType(0)->isPointerTy());
Ahmed Bougachad765a822016-04-27 19:04:35 +00001141
David L. Jonesd21529f2017-01-23 23:16:46 +00001142 case LibFunc_sincospi_stret:
1143 case LibFunc_sincospif_stret:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001144 return (NumParams == 1 && FTy.getParamType(0)->isFloatingPointTy());
1145
David L. Jonesd21529f2017-01-23 23:16:46 +00001146 case LibFunc_acos:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001147 case LibFunc_acos_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001148 case LibFunc_acosf:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001149 case LibFunc_acosf_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001150 case LibFunc_acosh:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001151 case LibFunc_acosh_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001152 case LibFunc_acoshf:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001153 case LibFunc_acoshf_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001154 case LibFunc_acoshl:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001155 case LibFunc_acoshl_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001156 case LibFunc_acosl:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001157 case LibFunc_acosl_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001158 case LibFunc_asin:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001159 case LibFunc_asin_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001160 case LibFunc_asinf:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001161 case LibFunc_asinf_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001162 case LibFunc_asinh:
1163 case LibFunc_asinhf:
1164 case LibFunc_asinhl:
1165 case LibFunc_asinl:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001166 case LibFunc_asinl_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001167 case LibFunc_atan:
1168 case LibFunc_atanf:
1169 case LibFunc_atanh:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001170 case LibFunc_atanh_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001171 case LibFunc_atanhf:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001172 case LibFunc_atanhf_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001173 case LibFunc_atanhl:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001174 case LibFunc_atanhl_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001175 case LibFunc_atanl:
1176 case LibFunc_cbrt:
1177 case LibFunc_cbrtf:
1178 case LibFunc_cbrtl:
1179 case LibFunc_ceil:
1180 case LibFunc_ceilf:
1181 case LibFunc_ceill:
1182 case LibFunc_cos:
1183 case LibFunc_cosf:
1184 case LibFunc_cosh:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001185 case LibFunc_cosh_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001186 case LibFunc_coshf:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001187 case LibFunc_coshf_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001188 case LibFunc_coshl:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001189 case LibFunc_coshl_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001190 case LibFunc_cosl:
1191 case LibFunc_exp10:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001192 case LibFunc_exp10_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001193 case LibFunc_exp10f:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001194 case LibFunc_exp10f_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001195 case LibFunc_exp10l:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001196 case LibFunc_exp10l_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001197 case LibFunc_exp2:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001198 case LibFunc_exp2_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001199 case LibFunc_exp2f:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001200 case LibFunc_exp2f_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001201 case LibFunc_exp2l:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001202 case LibFunc_exp2l_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001203 case LibFunc_exp:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001204 case LibFunc_exp_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001205 case LibFunc_expf:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001206 case LibFunc_expf_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001207 case LibFunc_expl:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001208 case LibFunc_expl_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001209 case LibFunc_expm1:
1210 case LibFunc_expm1f:
1211 case LibFunc_expm1l:
1212 case LibFunc_fabs:
1213 case LibFunc_fabsf:
1214 case LibFunc_fabsl:
1215 case LibFunc_floor:
1216 case LibFunc_floorf:
1217 case LibFunc_floorl:
1218 case LibFunc_log10:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001219 case LibFunc_log10_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001220 case LibFunc_log10f:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001221 case LibFunc_log10f_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001222 case LibFunc_log10l:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001223 case LibFunc_log10l_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001224 case LibFunc_log1p:
1225 case LibFunc_log1pf:
1226 case LibFunc_log1pl:
1227 case LibFunc_log2:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001228 case LibFunc_log2_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001229 case LibFunc_log2f:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001230 case LibFunc_log2f_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001231 case LibFunc_log2l:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001232 case LibFunc_log2l_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001233 case LibFunc_log:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001234 case LibFunc_log_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001235 case LibFunc_logb:
1236 case LibFunc_logbf:
1237 case LibFunc_logbl:
1238 case LibFunc_logf:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001239 case LibFunc_logf_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001240 case LibFunc_logl:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001241 case LibFunc_logl_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001242 case LibFunc_nearbyint:
1243 case LibFunc_nearbyintf:
1244 case LibFunc_nearbyintl:
1245 case LibFunc_rint:
1246 case LibFunc_rintf:
1247 case LibFunc_rintl:
1248 case LibFunc_round:
1249 case LibFunc_roundf:
1250 case LibFunc_roundl:
1251 case LibFunc_sin:
1252 case LibFunc_sinf:
1253 case LibFunc_sinh:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001254 case LibFunc_sinh_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001255 case LibFunc_sinhf:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001256 case LibFunc_sinhf_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001257 case LibFunc_sinhl:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001258 case LibFunc_sinhl_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001259 case LibFunc_sinl:
1260 case LibFunc_sqrt:
1261 case LibFunc_sqrt_finite:
1262 case LibFunc_sqrtf:
1263 case LibFunc_sqrtf_finite:
1264 case LibFunc_sqrtl:
1265 case LibFunc_sqrtl_finite:
1266 case LibFunc_tan:
1267 case LibFunc_tanf:
1268 case LibFunc_tanh:
1269 case LibFunc_tanhf:
1270 case LibFunc_tanhl:
1271 case LibFunc_tanl:
1272 case LibFunc_trunc:
1273 case LibFunc_truncf:
1274 case LibFunc_truncl:
Ahmed Bougachad765a822016-04-27 19:04:35 +00001275 return (NumParams == 1 && FTy.getReturnType()->isFloatingPointTy() &&
1276 FTy.getReturnType() == FTy.getParamType(0));
1277
David L. Jonesd21529f2017-01-23 23:16:46 +00001278 case LibFunc_atan2:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001279 case LibFunc_atan2_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001280 case LibFunc_atan2f:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001281 case LibFunc_atan2f_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001282 case LibFunc_atan2l:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001283 case LibFunc_atan2l_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001284 case LibFunc_fmin:
1285 case LibFunc_fminf:
1286 case LibFunc_fminl:
1287 case LibFunc_fmax:
1288 case LibFunc_fmaxf:
1289 case LibFunc_fmaxl:
1290 case LibFunc_fmod:
1291 case LibFunc_fmodf:
1292 case LibFunc_fmodl:
1293 case LibFunc_copysign:
1294 case LibFunc_copysignf:
1295 case LibFunc_copysignl:
1296 case LibFunc_pow:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001297 case LibFunc_pow_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001298 case LibFunc_powf:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001299 case LibFunc_powf_finite:
David L. Jonesd21529f2017-01-23 23:16:46 +00001300 case LibFunc_powl:
Andrew Kaylor3cd8c162017-05-12 22:11:12 +00001301 case LibFunc_powl_finite:
Ahmed Bougachad765a822016-04-27 19:04:35 +00001302 return (NumParams == 2 && FTy.getReturnType()->isFloatingPointTy() &&
1303 FTy.getReturnType() == FTy.getParamType(0) &&
1304 FTy.getReturnType() == FTy.getParamType(1));
1305
David L. Jonesd21529f2017-01-23 23:16:46 +00001306 case LibFunc_ldexp:
1307 case LibFunc_ldexpf:
1308 case LibFunc_ldexpl:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001309 return (NumParams == 2 && FTy.getReturnType()->isFloatingPointTy() &&
1310 FTy.getReturnType() == FTy.getParamType(0) &&
1311 FTy.getParamType(1)->isIntegerTy(32));
1312
David L. Jonesd21529f2017-01-23 23:16:46 +00001313 case LibFunc_ffs:
1314 case LibFunc_ffsl:
1315 case LibFunc_ffsll:
1316 case LibFunc_fls:
1317 case LibFunc_flsl:
1318 case LibFunc_flsll:
Sanjay Patel04949faf2016-09-23 18:44:09 +00001319 return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(32) &&
1320 FTy.getParamType(0)->isIntegerTy());
1321
David L. Jonesd21529f2017-01-23 23:16:46 +00001322 case LibFunc_isdigit:
1323 case LibFunc_isascii:
1324 case LibFunc_toascii:
1325 case LibFunc_putchar:
David Bolvanskyca22d422018-05-16 11:39:52 +00001326 case LibFunc_putchar_unlocked:
Ahmed Bougachad765a822016-04-27 19:04:35 +00001327 return (NumParams == 1 && FTy.getReturnType()->isIntegerTy(32) &&
Sanjay Patel04949faf2016-09-23 18:44:09 +00001328 FTy.getReturnType() == FTy.getParamType(0));
Ahmed Bougachad765a822016-04-27 19:04:35 +00001329
David L. Jonesd21529f2017-01-23 23:16:46 +00001330 case LibFunc_abs:
1331 case LibFunc_labs:
1332 case LibFunc_llabs:
Ahmed Bougachad765a822016-04-27 19:04:35 +00001333 return (NumParams == 1 && FTy.getReturnType()->isIntegerTy() &&
1334 FTy.getReturnType() == FTy.getParamType(0));
1335
David L. Jonesd21529f2017-01-23 23:16:46 +00001336 case LibFunc_cxa_atexit:
Ahmed Bougachad765a822016-04-27 19:04:35 +00001337 return (NumParams == 3 && FTy.getReturnType()->isIntegerTy() &&
1338 FTy.getParamType(0)->isPointerTy() &&
1339 FTy.getParamType(1)->isPointerTy() &&
1340 FTy.getParamType(2)->isPointerTy());
1341
David L. Jonesd21529f2017-01-23 23:16:46 +00001342 case LibFunc_sinpi:
1343 case LibFunc_cospi:
Ahmed Bougachad765a822016-04-27 19:04:35 +00001344 return (NumParams == 1 && FTy.getReturnType()->isDoubleTy() &&
1345 FTy.getReturnType() == FTy.getParamType(0));
1346
David L. Jonesd21529f2017-01-23 23:16:46 +00001347 case LibFunc_sinpif:
1348 case LibFunc_cospif:
Ahmed Bougachad765a822016-04-27 19:04:35 +00001349 return (NumParams == 1 && FTy.getReturnType()->isFloatTy() &&
1350 FTy.getReturnType() == FTy.getParamType(0));
1351
David L. Jonesd21529f2017-01-23 23:16:46 +00001352 case LibFunc_strnlen:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001353 return (NumParams == 2 && FTy.getReturnType() == FTy.getParamType(1) &&
1354 FTy.getParamType(0) == PCharTy &&
1355 FTy.getParamType(1) == SizeTTy);
1356
David L. Jonesd21529f2017-01-23 23:16:46 +00001357 case LibFunc_posix_memalign:
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001358 return (NumParams == 3 && FTy.getReturnType()->isIntegerTy(32) &&
1359 FTy.getParamType(0)->isPointerTy() &&
1360 FTy.getParamType(1) == SizeTTy && FTy.getParamType(2) == SizeTTy);
1361
Matthias Braun60b40b82017-05-05 20:25:50 +00001362 case LibFunc_wcslen:
1363 return (NumParams == 1 && FTy.getParamType(0)->isPointerTy() &&
1364 FTy.getReturnType()->isIntegerTy());
1365
Hal Finkel2ff24732017-12-16 01:26:25 +00001366 case LibFunc_cabs:
1367 case LibFunc_cabsf:
1368 case LibFunc_cabsl: {
1369 Type* RetTy = FTy.getReturnType();
1370 if (!RetTy->isFloatingPointTy())
1371 return false;
1372
1373 // NOTE: These prototypes are target specific and currently support
1374 // "complex" passed as an array or discrete real & imaginary parameters.
1375 // Add other calling conventions to enable libcall optimizations.
1376 if (NumParams == 1)
1377 return (FTy.getParamType(0)->isArrayTy() &&
1378 FTy.getParamType(0)->getArrayNumElements() == 2 &&
1379 FTy.getParamType(0)->getArrayElementType() == RetTy);
1380 else if (NumParams == 2)
1381 return (FTy.getParamType(0) == RetTy && FTy.getParamType(1) == RetTy);
1382 else
1383 return false;
1384 }
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001385 case LibFunc::NumLibFuncs:
Ahmed Bougacha86b680a2017-01-17 19:54:18 +00001386 break;
Ahmed Bougachad765a822016-04-27 19:04:35 +00001387 }
Ahmed Bougacha6b9be1d2017-01-17 03:10:02 +00001388
Ahmed Bougacha86b680a2017-01-17 19:54:18 +00001389 llvm_unreachable("Invalid libfunc");
Ahmed Bougachad765a822016-04-27 19:04:35 +00001390}
1391
1392bool TargetLibraryInfoImpl::getLibFunc(const Function &FDecl,
David L. Jonesd21529f2017-01-23 23:16:46 +00001393 LibFunc &F) const {
Ahmed Bougachad765a822016-04-27 19:04:35 +00001394 const DataLayout *DL =
1395 FDecl.getParent() ? &FDecl.getParent()->getDataLayout() : nullptr;
1396 return getLibFunc(FDecl.getName(), F) &&
1397 isValidProtoForLibFunc(*FDecl.getFunctionType(), F, DL);
1398}
1399
Chandler Carruthc0291862015-01-24 02:06:09 +00001400void TargetLibraryInfoImpl::disableAllFunctions() {
Chris Lattner1341df92011-02-18 22:34:03 +00001401 memset(AvailableArray, 0, sizeof(AvailableArray));
1402}
Chandler Carruthb98f63d2015-01-15 10:41:28 +00001403
Michael Zolotukhine8f25512015-03-17 19:22:30 +00001404static bool compareByScalarFnName(const VecDesc &LHS, const VecDesc &RHS) {
Mehdi Amini9a72cd72016-10-01 03:10:48 +00001405 return LHS.ScalarFnName < RHS.ScalarFnName;
Michael Zolotukhine8f25512015-03-17 19:22:30 +00001406}
1407
1408static bool compareByVectorFnName(const VecDesc &LHS, const VecDesc &RHS) {
Mehdi Amini9a72cd72016-10-01 03:10:48 +00001409 return LHS.VectorFnName < RHS.VectorFnName;
Michael Zolotukhine8f25512015-03-17 19:22:30 +00001410}
1411
1412static bool compareWithScalarFnName(const VecDesc &LHS, StringRef S) {
Mehdi Amini9a72cd72016-10-01 03:10:48 +00001413 return LHS.ScalarFnName < S;
Michael Zolotukhine8f25512015-03-17 19:22:30 +00001414}
1415
1416static bool compareWithVectorFnName(const VecDesc &LHS, StringRef S) {
Mehdi Amini9a72cd72016-10-01 03:10:48 +00001417 return LHS.VectorFnName < S;
Michael Zolotukhine8f25512015-03-17 19:22:30 +00001418}
1419
1420void TargetLibraryInfoImpl::addVectorizableFunctions(ArrayRef<VecDesc> Fns) {
1421 VectorDescs.insert(VectorDescs.end(), Fns.begin(), Fns.end());
Fangrui Song0cac7262018-09-27 02:13:45 +00001422 llvm::sort(VectorDescs, compareByScalarFnName);
Michael Zolotukhine8f25512015-03-17 19:22:30 +00001423
1424 ScalarDescs.insert(ScalarDescs.end(), Fns.begin(), Fns.end());
Fangrui Song0cac7262018-09-27 02:13:45 +00001425 llvm::sort(ScalarDescs, compareByVectorFnName);
Michael Zolotukhine8f25512015-03-17 19:22:30 +00001426}
1427
Michael Zolotukhin6d8a2aa2015-03-17 19:50:55 +00001428void TargetLibraryInfoImpl::addVectorizableFunctionsFromVecLib(
1429 enum VectorLibrary VecLib) {
1430 switch (VecLib) {
1431 case Accelerate: {
1432 const VecDesc VecFuncs[] = {
Michael Zolotukhinde63aac2015-05-07 17:11:51 +00001433 // Floating-Point Arithmetic and Auxiliary Functions
1434 {"ceilf", "vceilf", 4},
Michael Zolotukhin6d8a2aa2015-03-17 19:50:55 +00001435 {"fabsf", "vfabsf", 4},
1436 {"llvm.fabs.f32", "vfabsf", 4},
Michael Zolotukhinde63aac2015-05-07 17:11:51 +00001437 {"floorf", "vfloorf", 4},
1438 {"sqrtf", "vsqrtf", 4},
1439 {"llvm.sqrt.f32", "vsqrtf", 4},
1440
1441 // Exponential and Logarithmic Functions
1442 {"expf", "vexpf", 4},
1443 {"llvm.exp.f32", "vexpf", 4},
1444 {"expm1f", "vexpm1f", 4},
1445 {"logf", "vlogf", 4},
1446 {"llvm.log.f32", "vlogf", 4},
1447 {"log1pf", "vlog1pf", 4},
1448 {"log10f", "vlog10f", 4},
1449 {"llvm.log10.f32", "vlog10f", 4},
1450 {"logbf", "vlogbf", 4},
1451
1452 // Trigonometric Functions
1453 {"sinf", "vsinf", 4},
1454 {"llvm.sin.f32", "vsinf", 4},
1455 {"cosf", "vcosf", 4},
1456 {"llvm.cos.f32", "vcosf", 4},
1457 {"tanf", "vtanf", 4},
1458 {"asinf", "vasinf", 4},
1459 {"acosf", "vacosf", 4},
1460 {"atanf", "vatanf", 4},
1461
1462 // Hyperbolic Functions
1463 {"sinhf", "vsinhf", 4},
1464 {"coshf", "vcoshf", 4},
1465 {"tanhf", "vtanhf", 4},
1466 {"asinhf", "vasinhf", 4},
1467 {"acoshf", "vacoshf", 4},
1468 {"atanhf", "vatanhf", 4},
Michael Zolotukhin6d8a2aa2015-03-17 19:50:55 +00001469 };
1470 addVectorizableFunctions(VecFuncs);
1471 break;
1472 }
Matt Mastena6669a12016-07-29 16:42:44 +00001473 case SVML: {
1474 const VecDesc VecFuncs[] = {
1475 {"sin", "__svml_sin2", 2},
1476 {"sin", "__svml_sin4", 4},
1477 {"sin", "__svml_sin8", 8},
1478
1479 {"sinf", "__svml_sinf4", 4},
1480 {"sinf", "__svml_sinf8", 8},
1481 {"sinf", "__svml_sinf16", 16},
1482
Sanjay Patel4b1205b2018-06-07 18:21:24 +00001483 {"llvm.sin.f64", "__svml_sin2", 2},
1484 {"llvm.sin.f64", "__svml_sin4", 4},
1485 {"llvm.sin.f64", "__svml_sin8", 8},
1486
1487 {"llvm.sin.f32", "__svml_sinf4", 4},
1488 {"llvm.sin.f32", "__svml_sinf8", 8},
1489 {"llvm.sin.f32", "__svml_sinf16", 16},
1490
Matt Mastena6669a12016-07-29 16:42:44 +00001491 {"cos", "__svml_cos2", 2},
1492 {"cos", "__svml_cos4", 4},
1493 {"cos", "__svml_cos8", 8},
1494
1495 {"cosf", "__svml_cosf4", 4},
1496 {"cosf", "__svml_cosf8", 8},
1497 {"cosf", "__svml_cosf16", 16},
1498
Sanjay Patel4b1205b2018-06-07 18:21:24 +00001499 {"llvm.cos.f64", "__svml_cos2", 2},
1500 {"llvm.cos.f64", "__svml_cos4", 4},
1501 {"llvm.cos.f64", "__svml_cos8", 8},
1502
1503 {"llvm.cos.f32", "__svml_cosf4", 4},
1504 {"llvm.cos.f32", "__svml_cosf8", 8},
1505 {"llvm.cos.f32", "__svml_cosf16", 16},
1506
Matt Mastena6669a12016-07-29 16:42:44 +00001507 {"pow", "__svml_pow2", 2},
1508 {"pow", "__svml_pow4", 4},
1509 {"pow", "__svml_pow8", 8},
1510
1511 {"powf", "__svml_powf4", 4},
1512 {"powf", "__svml_powf8", 8},
1513 {"powf", "__svml_powf16", 16},
1514
Andrew Kaylorb01e94e2017-05-12 22:11:26 +00001515 { "__pow_finite", "__svml_pow2", 2 },
1516 { "__pow_finite", "__svml_pow4", 4 },
1517 { "__pow_finite", "__svml_pow8", 8 },
1518
1519 { "__powf_finite", "__svml_powf4", 4 },
1520 { "__powf_finite", "__svml_powf8", 8 },
1521 { "__powf_finite", "__svml_powf16", 16 },
1522
Matt Mastena6669a12016-07-29 16:42:44 +00001523 {"llvm.pow.f64", "__svml_pow2", 2},
1524 {"llvm.pow.f64", "__svml_pow4", 4},
1525 {"llvm.pow.f64", "__svml_pow8", 8},
1526
1527 {"llvm.pow.f32", "__svml_powf4", 4},
1528 {"llvm.pow.f32", "__svml_powf8", 8},
1529 {"llvm.pow.f32", "__svml_powf16", 16},
1530
1531 {"exp", "__svml_exp2", 2},
1532 {"exp", "__svml_exp4", 4},
1533 {"exp", "__svml_exp8", 8},
1534
1535 {"expf", "__svml_expf4", 4},
1536 {"expf", "__svml_expf8", 8},
1537 {"expf", "__svml_expf16", 16},
1538
Andrew Kaylorb01e94e2017-05-12 22:11:26 +00001539 { "__exp_finite", "__svml_exp2", 2 },
1540 { "__exp_finite", "__svml_exp4", 4 },
1541 { "__exp_finite", "__svml_exp8", 8 },
1542
1543 { "__expf_finite", "__svml_expf4", 4 },
1544 { "__expf_finite", "__svml_expf8", 8 },
1545 { "__expf_finite", "__svml_expf16", 16 },
1546
Matt Mastena6669a12016-07-29 16:42:44 +00001547 {"llvm.exp.f64", "__svml_exp2", 2},
1548 {"llvm.exp.f64", "__svml_exp4", 4},
1549 {"llvm.exp.f64", "__svml_exp8", 8},
1550
1551 {"llvm.exp.f32", "__svml_expf4", 4},
1552 {"llvm.exp.f32", "__svml_expf8", 8},
1553 {"llvm.exp.f32", "__svml_expf16", 16},
1554
1555 {"log", "__svml_log2", 2},
1556 {"log", "__svml_log4", 4},
1557 {"log", "__svml_log8", 8},
1558
1559 {"logf", "__svml_logf4", 4},
1560 {"logf", "__svml_logf8", 8},
1561 {"logf", "__svml_logf16", 16},
1562
Andrew Kaylorb01e94e2017-05-12 22:11:26 +00001563 { "__log_finite", "__svml_log2", 2 },
1564 { "__log_finite", "__svml_log4", 4 },
1565 { "__log_finite", "__svml_log8", 8 },
1566
1567 { "__logf_finite", "__svml_logf4", 4 },
1568 { "__logf_finite", "__svml_logf8", 8 },
1569 { "__logf_finite", "__svml_logf16", 16 },
1570
Matt Mastena6669a12016-07-29 16:42:44 +00001571 {"llvm.log.f64", "__svml_log2", 2},
1572 {"llvm.log.f64", "__svml_log4", 4},
1573 {"llvm.log.f64", "__svml_log8", 8},
1574
1575 {"llvm.log.f32", "__svml_logf4", 4},
1576 {"llvm.log.f32", "__svml_logf8", 8},
1577 {"llvm.log.f32", "__svml_logf16", 16},
1578 };
1579 addVectorizableFunctions(VecFuncs);
1580 break;
1581 }
Michael Zolotukhin6d8a2aa2015-03-17 19:50:55 +00001582 case NoLibrary:
1583 break;
1584 }
1585}
1586
Michael Zolotukhine8f25512015-03-17 19:22:30 +00001587bool TargetLibraryInfoImpl::isFunctionVectorizable(StringRef funcName) const {
1588 funcName = sanitizeFunctionName(funcName);
1589 if (funcName.empty())
1590 return false;
1591
1592 std::vector<VecDesc>::const_iterator I = std::lower_bound(
1593 VectorDescs.begin(), VectorDescs.end(), funcName,
1594 compareWithScalarFnName);
1595 return I != VectorDescs.end() && StringRef(I->ScalarFnName) == funcName;
1596}
1597
1598StringRef TargetLibraryInfoImpl::getVectorizedFunction(StringRef F,
1599 unsigned VF) const {
1600 F = sanitizeFunctionName(F);
1601 if (F.empty())
1602 return F;
1603 std::vector<VecDesc>::const_iterator I = std::lower_bound(
1604 VectorDescs.begin(), VectorDescs.end(), F, compareWithScalarFnName);
1605 while (I != VectorDescs.end() && StringRef(I->ScalarFnName) == F) {
1606 if (I->VectorizationFactor == VF)
1607 return I->VectorFnName;
1608 ++I;
1609 }
1610 return StringRef();
1611}
1612
1613StringRef TargetLibraryInfoImpl::getScalarizedFunction(StringRef F,
1614 unsigned &VF) const {
1615 F = sanitizeFunctionName(F);
1616 if (F.empty())
1617 return F;
1618
1619 std::vector<VecDesc>::const_iterator I = std::lower_bound(
1620 ScalarDescs.begin(), ScalarDescs.end(), F, compareWithVectorFnName);
1621 if (I == VectorDescs.end() || StringRef(I->VectorFnName) != F)
1622 return StringRef();
1623 VF = I->VectorizationFactor;
1624 return I->ScalarFnName;
1625}
1626
Chandler Carruth164a2aa62016-06-17 00:11:01 +00001627TargetLibraryInfo TargetLibraryAnalysis::run(Module &M,
1628 ModuleAnalysisManager &) {
Chandler Carruthc0291862015-01-24 02:06:09 +00001629 if (PresetInfoImpl)
1630 return TargetLibraryInfo(*PresetInfoImpl);
1631
1632 return TargetLibraryInfo(lookupInfoImpl(Triple(M.getTargetTriple())));
1633}
1634
Chandler Carruth164a2aa62016-06-17 00:11:01 +00001635TargetLibraryInfo TargetLibraryAnalysis::run(Function &F,
1636 FunctionAnalysisManager &) {
Chandler Carruthc0291862015-01-24 02:06:09 +00001637 if (PresetInfoImpl)
1638 return TargetLibraryInfo(*PresetInfoImpl);
1639
1640 return TargetLibraryInfo(
1641 lookupInfoImpl(Triple(F.getParent()->getTargetTriple())));
1642}
1643
Benjamin Kramerc321e532016-06-08 19:09:22 +00001644TargetLibraryInfoImpl &TargetLibraryAnalysis::lookupInfoImpl(const Triple &T) {
Chandler Carruthc0291862015-01-24 02:06:09 +00001645 std::unique_ptr<TargetLibraryInfoImpl> &Impl =
1646 Impls[T.normalize()];
1647 if (!Impl)
1648 Impl.reset(new TargetLibraryInfoImpl(T));
1649
1650 return *Impl;
1651}
1652
Matthias Braun50ec0b52017-05-19 22:37:09 +00001653unsigned TargetLibraryInfoImpl::getWCharSize(const Module &M) const {
1654 if (auto *ShortWChar = cast_or_null<ConstantAsMetadata>(
1655 M.getModuleFlag("wchar_size")))
1656 return cast<ConstantInt>(ShortWChar->getValue())->getZExtValue();
Matthias Brauncc603ee2017-09-26 02:36:57 +00001657 return 0;
Matthias Braun50ec0b52017-05-19 22:37:09 +00001658}
Chandler Carruthc0291862015-01-24 02:06:09 +00001659
Chandler Carruthb98f63d2015-01-15 10:41:28 +00001660TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass()
Chandler Carruthc0291862015-01-24 02:06:09 +00001661 : ImmutablePass(ID), TLIImpl(), TLI(TLIImpl) {
Chandler Carruthb98f63d2015-01-15 10:41:28 +00001662 initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
1663}
1664
1665TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(const Triple &T)
Chandler Carruthc0291862015-01-24 02:06:09 +00001666 : ImmutablePass(ID), TLIImpl(T), TLI(TLIImpl) {
Chandler Carruthb98f63d2015-01-15 10:41:28 +00001667 initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
1668}
1669
1670TargetLibraryInfoWrapperPass::TargetLibraryInfoWrapperPass(
Chandler Carruthc0291862015-01-24 02:06:09 +00001671 const TargetLibraryInfoImpl &TLIImpl)
1672 : ImmutablePass(ID), TLIImpl(TLIImpl), TLI(this->TLIImpl) {
Chandler Carruthb98f63d2015-01-15 10:41:28 +00001673 initializeTargetLibraryInfoWrapperPassPass(*PassRegistry::getPassRegistry());
1674}
1675
Chandler Carruthdab4eae2016-11-23 17:53:26 +00001676AnalysisKey TargetLibraryAnalysis::Key;
NAKAMURA Takumidf0cd722016-02-28 17:17:00 +00001677
Chandler Carruthb98f63d2015-01-15 10:41:28 +00001678// Register the basic pass.
1679INITIALIZE_PASS(TargetLibraryInfoWrapperPass, "targetlibinfo",
1680 "Target Library Information", false, true)
1681char TargetLibraryInfoWrapperPass::ID = 0;
1682
1683void TargetLibraryInfoWrapperPass::anchor() {}