LLVM: lib/Transforms/Utils/BuildLibCalls.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

28#include

29

30using namespace llvm;

31

32#define DEBUG_TYPE "build-libcalls"

33

34

35

36STATISTIC(NumReadNone, "Number of functions inferred as readnone");

38 "Number of functions inferred as inaccessiblememonly");

39STATISTIC(NumReadOnly, "Number of functions inferred as readonly");

40STATISTIC(NumWriteOnly, "Number of functions inferred as writeonly");

41STATISTIC(NumArgMemOnly, "Number of functions inferred as argmemonly");

43 "Number of functions inferred as memory(errnomem: write)");

45 "Number of functions inferred as inaccessiblemem_or_argmemonly");

47 NumWriteArgumentMemOrErrnoMemOnly,

48 "Number of functions inferred as memory(argmem: write, errnomem: write)");

49STATISTIC(NumNoUnwind, "Number of functions inferred as nounwind");

50STATISTIC(NumNoCallback, "Number of functions inferred as nocallback");

51STATISTIC(NumNoCapture, "Number of arguments inferred as nocapture");

52STATISTIC(NumWriteOnlyArg, "Number of arguments inferred as writeonly");

53STATISTIC(NumReadOnlyArg, "Number of arguments inferred as readonly");

54STATISTIC(NumNoAlias, "Number of function returns inferred as noalias");

55STATISTIC(NumNoUndef, "Number of function returns inferred as noundef returns");

56STATISTIC(NumReturnedArg, "Number of arguments inferred as returned");

57STATISTIC(NumWillReturn, "Number of functions inferred as willreturn");

58STATISTIC(NumCold, "Number of functions inferred as cold");

59STATISTIC(NumNoReturn, "Number of functions inferred as no return");

60

62 if (F.doesNotAccessMemory())

63 return false;

64 F.setDoesNotAccessMemory();

65 ++NumReadNone;

66 return true;

67}

68

70 if (F.hasFnAttribute(Attribute::Cold))

71 return false;

72 F.addFnAttr(Attribute::Cold);

73 ++NumCold;

74 return true;

75}

76

78 if (F.hasFnAttribute(Attribute::NoReturn))

79 return false;

80 F.addFnAttr(Attribute::NoReturn);

81 ++NumNoReturn;

82 return true;

83}

84

88 if (OrigME == NewME)

89 return false;

90 F.setMemoryEffects(NewME);

91 return true;

92}

93

96 return false;

97 ++NumInaccessibleMemOnly;

98 return true;

99}

100

103 return false;

104 ++NumReadOnly;

105 return true;

106}

107

110 return false;

111 ++NumWriteOnly;

112 return true;

113}

114

117 return false;

118 ++NumArgMemOnly;

119 return true;

120}

121

124 return false;

125 ++NumInaccessibleMemOrArgMemOnly;

126 return true;

127}

128

131 return false;

132 ++NumWriteErrnoMemOnly;

133 return true;

134}

135

139 return false;

140 ++NumWriteArgumentMemOrErrnoMemOnly;

141 return true;

142}

143

145 if (F.doesNotThrow())

146 return false;

147 F.setDoesNotThrow();

148 ++NumNoUnwind;

149 return true;

150}

151

153 if (F.hasFnAttribute(Attribute::NoCallback))

154 return false;

155 F.addFnAttr(Attribute::NoCallback);

156 ++NumNoCallback;

157 return true;

158}

159

161 if (F.hasRetAttribute(Attribute::NoAlias))

162 return false;

163 F.addRetAttr(Attribute::NoAlias);

164 ++NumNoAlias;

165 return true;

166}

167

169 if (F.hasParamAttribute(ArgNo, Attribute::Captures))

170 return false;

173 ++NumNoCapture;

174 return true;

175}

176

178 if (F.hasParamAttribute(ArgNo, Attribute::NoAlias))

179 return false;

180 F.addParamAttr(ArgNo, Attribute::NoAlias);

181 ++NumNoAlias;

182 return true;

183}

184

186 if (F.hasParamAttribute(ArgNo, Attribute::ReadOnly))

187 return false;

188 F.addParamAttr(ArgNo, Attribute::ReadOnly);

189 ++NumReadOnlyArg;

190 return true;

191}

192

194 if (F.hasParamAttribute(ArgNo, Attribute::WriteOnly))

195 return false;

196 F.addParamAttr(ArgNo, Attribute::WriteOnly);

197 ++NumWriteOnlyArg;

198 return true;

199}

200

202 if (F.getReturnType()->isVoidTy() &&

203 F.hasRetAttribute(Attribute::NoUndef)) {

204 F.addRetAttr(Attribute::NoUndef);

205 ++NumNoUndef;

206 return true;

207 }

208 return false;

209}

210

213 for (unsigned ArgNo = 0; ArgNo < F.arg_size(); ++ArgNo) {

214 if (F.hasParamAttribute(ArgNo, Attribute::NoUndef)) {

215 F.addParamAttr(ArgNo, Attribute::NoUndef);

216 ++NumNoUndef;

218 }

219 }

221}

222

224 if (F.hasParamAttribute(ArgNo, Attribute::NoUndef))

225 return false;

226 F.addParamAttr(ArgNo, Attribute::NoUndef);

227 ++NumNoUndef;

228 return true;

229}

230

232 bool UndefAdded = false;

235 return UndefAdded;

236}

237

239 if (F.hasParamAttribute(ArgNo, Attribute::Returned))

240 return false;

241 F.addParamAttr(ArgNo, Attribute::Returned);

242 ++NumReturnedArg;

243 return true;

244}

245

247 if (F.hasFnAttribute(Attribute::NonLazyBind))

248 return false;

249 F.addFnAttr(Attribute::NonLazyBind);

250 return true;

251}

252

254 if (F.hasFnAttribute(Attribute::NoFree))

255 return false;

256 F.addFnAttr(Attribute::NoFree);

257 return true;

258}

259

261 if (F.hasFnAttribute(Attribute::WillReturn))

262 return false;

263 F.addFnAttr(Attribute::WillReturn);

264 ++NumWillReturn;

265 return true;

266}

267

269 if (F.hasParamAttribute(ArgNo, Attribute::AllocAlign))

270 return false;

271 F.addParamAttr(ArgNo, Attribute::AllocAlign);

272 return true;

273}

274

276 if (F.hasParamAttribute(ArgNo, Attribute::AllocatedPointer))

277 return false;

278 F.addParamAttr(ArgNo, Attribute::AllocatedPointer);

279 return true;

280}

281

283 std::optional NumElemsArg) {

284 if (F.hasFnAttribute(Attribute::AllocSize))

285 return false;

287 NumElemsArg));

288 return true;

289}

290

292 if (F.hasFnAttribute("alloc-family"))

293 return false;

294 F.addFnAttr("alloc-family", Family);

295 return true;

296}

297

299 if (F.hasFnAttribute(Attribute::AllocKind))

300 return false;

301 F.addFnAttr(

303 return true;

304}

305

308 Function *F = M->getFunction(Name);

309 if (F)

310 return false;

312}

313

316 LibFunc TheLibFunc;

317 if (!(TLI.getLibFunc(F, TheLibFunc) && TLI.has(TheLibFunc)))

318 return false;

319

321

322 if (F.getParent() != nullptr && F.getParent()->getRtLibUseGOT())

324

325 switch (TheLibFunc) {

326 case LibFunc_nan:

327 case LibFunc_nanf:

328 case LibFunc_nanl:

329 case LibFunc_strlen:

330 case LibFunc_strnlen:

331 case LibFunc_wcslen:

338 break;

339 case LibFunc_strchr:

340 case LibFunc_strrchr:

346 break;

347 case LibFunc_strtol:

348 case LibFunc_strtod:

349 case LibFunc_strtof:

350 case LibFunc_strtoul:

351 case LibFunc_strtoll:

352 case LibFunc_strtold:

353 case LibFunc_strtoull:

359 break;

360 case LibFunc_strcat:

361 case LibFunc_strncat:

371 break;

372 case LibFunc_strcpy:

373 case LibFunc_strncpy:

375 [[fallthrough]];

376 case LibFunc_stpcpy:

377 case LibFunc_stpncpy:

387 break;

388 case LibFunc_strxfrm:

395 break;

396 case LibFunc_strcmp:

397 case LibFunc_strspn:

398 case LibFunc_strncmp:

399 case LibFunc_strcspn:

407 break;

408 case LibFunc_strcoll:

409 case LibFunc_strcasecmp:

410 case LibFunc_strncasecmp:

411

412

419 break;

420 case LibFunc_strstr:

421 case LibFunc_strpbrk:

428 break;

429 case LibFunc_strtok:

430 case LibFunc_strtok_r:

436 break;

437 case LibFunc_scanf:

442 break;

443 case LibFunc_setbuf:

444 case LibFunc_setvbuf:

448 break;

449 case LibFunc_strndup:

451 [[fallthrough]];

452 case LibFunc_strdup:

460 break;

461 case LibFunc_stat:

462 case LibFunc_statvfs:

468 break;

469 case LibFunc_sscanf:

476 break;

477 case LibFunc_sprintf:

485 break;

486 case LibFunc_snprintf:

494 break;

495 case LibFunc_setitimer:

502 break;

503 case LibFunc_system:

504

508 break;

509 case LibFunc_aligned_alloc:

513 [[fallthrough]];

514 case LibFunc_valloc:

515 case LibFunc_malloc:

516 case LibFunc_vec_malloc:

518 [[fallthrough]];

519 case LibFunc_pvalloc:

521 : "malloc");

528 break;

529 case LibFunc_memcmp:

537 break;

538 case LibFunc_memchr:

539 case LibFunc_memrchr:

545 break;

546 case LibFunc_modf:

547 case LibFunc_modff:

548 case LibFunc_modfl:

555 break;

556 case LibFunc_memcpy:

567 break;

568 case LibFunc_memmove:

577 break;

578 case LibFunc_mempcpy:

579 case LibFunc_memccpy:

581 [[fallthrough]];

582 case LibFunc_memcpy_chk:

591 break;

592 case LibFunc_memalign:

603 break;

604 case LibFunc_mkdir:

609 break;

610 case LibFunc_mktime:

615 break;

616 case LibFunc_realloc:

617 case LibFunc_reallocf:

618 case LibFunc_vec_realloc:

620 F, TheLibFunc == LibFunc_vec_realloc ? "vec_malloc" : "malloc");

631 break;

632 case LibFunc_reallocarray:

645 break;

646 case LibFunc_read:

647

650 break;

651 case LibFunc_rewind:

655 break;

656 case LibFunc_rmdir:

657 case LibFunc_remove:

658 case LibFunc_realpath:

663 break;

664 case LibFunc_rename:

671 break;

672 case LibFunc_readlink:

678 break;

679 case LibFunc_write:

680

684 break;

685 case LibFunc_bcopy:

694 break;

695 case LibFunc_bcmp:

703 break;

704 case LibFunc_bzero:

711 break;

712 case LibFunc_calloc:

713 case LibFunc_vec_calloc:

715 : "malloc");

723 break;

724 case LibFunc_chmod:

725 case LibFunc_chown:

730 break;

731 case LibFunc_ctermid:

732 case LibFunc_clearerr:

733 case LibFunc_closedir:

737 break;

738 case LibFunc_atoi:

739 case LibFunc_atol:

740 case LibFunc_atof:

741 case LibFunc_atoll:

747 break;

748 case LibFunc_access:

753 break;

754 case LibFunc_fopen:

762 break;

763 case LibFunc_fdopen:

769 break;

770 case LibFunc_feof:

774 break;

775 case LibFunc_free:

776 case LibFunc_vec_free:

778 : "malloc");

786 break;

787 case LibFunc_fseek:

788 case LibFunc_ftell:

789 case LibFunc_fgetc:

790 case LibFunc_fgetc_unlocked:

791 case LibFunc_fseeko:

792 case LibFunc_ftello:

793 case LibFunc_fileno:

794 case LibFunc_fflush:

795 case LibFunc_fclose:

796 case LibFunc_fsetpos:

797 case LibFunc_flockfile:

798 case LibFunc_funlockfile:

799 case LibFunc_ftrylockfile:

803 break;

804 case LibFunc_ferror:

809 break;

810 case LibFunc_fputc:

811 case LibFunc_fputc_unlocked:

812 case LibFunc_fstat:

816 break;

817 case LibFunc_frexp:

818 case LibFunc_frexpf:

819 case LibFunc_frexpl:

826 break;

827 case LibFunc_fstatvfs:

831 break;

832 case LibFunc_fgets:

833 case LibFunc_fgets_unlocked:

838 break;

839 case LibFunc_fread:

840 case LibFunc_fread_unlocked:

846 break;

847 case LibFunc_fwrite:

848 case LibFunc_fwrite_unlocked:

854 break;

855 case LibFunc_fputs:

856 case LibFunc_fputs_unlocked:

862 break;

863 case LibFunc_fscanf:

864 case LibFunc_fprintf:

870 break;

871 case LibFunc_fgetpos:

876 break;

877 case LibFunc_getc:

881 break;

882 case LibFunc_getlogin_r:

886 break;

887 case LibFunc_getc_unlocked:

891 break;

892 case LibFunc_getenv:

897 break;

898 case LibFunc_gets:

899 case LibFunc_getchar:

900 case LibFunc_getchar_unlocked:

903 break;

904 case LibFunc_getitimer:

908 break;

909 case LibFunc_getpwnam:

914 break;

915 case LibFunc_ungetc:

919 break;

920 case LibFunc_uname:

924 break;

925 case LibFunc_unlink:

930 break;

931 case LibFunc_unsetenv:

936 break;

937 case LibFunc_utime:

938 case LibFunc_utimes:

945 break;

946 case LibFunc_putc:

947 case LibFunc_putc_unlocked:

951 break;

952 case LibFunc_puts:

953 case LibFunc_printf:

954 case LibFunc_perror:

959 break;

960 case LibFunc_pread:

961

964 break;

965 case LibFunc_pwrite:

966

970 break;

971 case LibFunc_putchar:

972 case LibFunc_putchar_unlocked:

975 break;

976 case LibFunc_popen:

984 break;

985 case LibFunc_pclose:

989 break;

990 case LibFunc_vscanf:

995 break;

996 case LibFunc_vsscanf:

1003 break;

1004 case LibFunc_vfscanf:

1010 break;

1011 case LibFunc_vprintf:

1016 break;

1017 case LibFunc_vfprintf:

1018 case LibFunc_vsprintf:

1024 break;

1025 case LibFunc_vsnprintf:

1031 break;

1032 case LibFunc_open:

1033

1037 break;

1038 case LibFunc_opendir:

1044 break;

1045 case LibFunc_tmpfile:

1049 break;

1050 case LibFunc_times:

1054 break;

1055 case LibFunc_htonl:

1056 case LibFunc_htons:

1057 case LibFunc_ntohl:

1058 case LibFunc_ntohs:

1062 break;

1063 case LibFunc_lstat:

1069 break;

1070 case LibFunc_lchown:

1075 break;

1076 case LibFunc_qsort:

1077

1078

1081 break;

1082 case LibFunc_dunder_strndup:

1084 [[fallthrough]];

1085 case LibFunc_dunder_strdup:

1091 break;

1092 case LibFunc_dunder_strtok_r:

1097 break;

1098 case LibFunc_under_IO_getc:

1102 break;

1103 case LibFunc_under_IO_putc:

1107 break;

1108 case LibFunc_dunder_isoc99_scanf:

1113 break;

1114 case LibFunc_stat64:

1115 case LibFunc_lstat64:

1116 case LibFunc_statvfs64:

1122 break;

1123 case LibFunc_dunder_isoc99_sscanf:

1130 break;

1131 case LibFunc_fopen64:

1139 break;

1140 case LibFunc_fseeko64:

1141 case LibFunc_ftello64:

1145 break;

1146 case LibFunc_tmpfile64:

1150 break;

1151 case LibFunc_fstat64:

1152 case LibFunc_fstatvfs64:

1156 break;

1157 case LibFunc_open64:

1158

1162 break;

1163 case LibFunc_gettimeofday:

1164

1165

1166

1171 break;

1172 case LibFunc_memset_pattern4:

1173 case LibFunc_memset_pattern8:

1174 case LibFunc_memset_pattern16:

1178 [[fallthrough]];

1179 case LibFunc_memset:

1181 [[fallthrough]];

1182 case LibFunc_memset_chk:

1187 break;

1188 case LibFunc_abort:

1192 break;

1193 case LibFunc_terminate:

1194

1197 break;

1198 case LibFunc_cxa_throw:

1201

1203

1204 case LibFunc_nvvm_reflect:

1208 break;

1209 case LibFunc_acos:

1210 case LibFunc_acosf:

1211 case LibFunc_acosh:

1212 case LibFunc_acoshf:

1213 case LibFunc_acoshl:

1214 case LibFunc_acosl:

1215 case LibFunc_asin:

1216 case LibFunc_asinf:

1217 case LibFunc_asinh:

1218 case LibFunc_asinhf:

1219 case LibFunc_asinhl:

1220 case LibFunc_asinl:

1221 case LibFunc_atan:

1222 case LibFunc_atan2:

1223 case LibFunc_atan2f:

1224 case LibFunc_atan2l:

1225 case LibFunc_atanf:

1226 case LibFunc_atanh:

1227 case LibFunc_atanhf:

1228 case LibFunc_atanhl:

1229 case LibFunc_atanl:

1230 case LibFunc_cos:

1231 case LibFunc_cosh:

1232 case LibFunc_coshf:

1233 case LibFunc_coshl:

1234 case LibFunc_cosf:

1235 case LibFunc_cosl:

1236 case LibFunc_cospi:

1237 case LibFunc_cospif:

1238 case LibFunc_erf:

1239 case LibFunc_erff:

1240 case LibFunc_erfl:

1241 case LibFunc_tgamma:

1242 case LibFunc_tgammaf:

1243 case LibFunc_tgammal:

1244 case LibFunc_exp:

1245 case LibFunc_expf:

1246 case LibFunc_expl:

1247 case LibFunc_exp2:

1248 case LibFunc_exp2f:

1249 case LibFunc_exp2l:

1250 case LibFunc_expm1:

1251 case LibFunc_expm1f:

1252 case LibFunc_expm1l:

1253 case LibFunc_fdim:

1254 case LibFunc_fdiml:

1255 case LibFunc_fdimf:

1256 case LibFunc_fmod:

1257 case LibFunc_fmodf:

1258 case LibFunc_fmodl:

1259 case LibFunc_hypot:

1260 case LibFunc_hypotf:

1261 case LibFunc_hypotl:

1262 case LibFunc_ldexp:

1263 case LibFunc_ldexpf:

1264 case LibFunc_ldexpl:

1265 case LibFunc_log:

1266 case LibFunc_log10:

1267 case LibFunc_log10f:

1268 case LibFunc_log10l:

1269 case LibFunc_log1p:

1270 case LibFunc_log1pf:

1271 case LibFunc_log1pl:

1272 case LibFunc_log2:

1273 case LibFunc_log2f:

1274 case LibFunc_log2l:

1275 case LibFunc_logb:

1276 case LibFunc_logbf:

1277 case LibFunc_logbl:

1278 case LibFunc_ilogb:

1279 case LibFunc_ilogbf:

1280 case LibFunc_ilogbl:

1281 case LibFunc_logf:

1282 case LibFunc_logl:

1283 case LibFunc_nextafter:

1284 case LibFunc_nextafterf:

1285 case LibFunc_nextafterl:

1286 case LibFunc_nexttoward:

1287 case LibFunc_nexttowardf:

1288 case LibFunc_nexttowardl:

1289 case LibFunc_pow:

1290 case LibFunc_powf:

1291 case LibFunc_powl:

1292 case LibFunc_remainder:

1293 case LibFunc_remainderf:

1294 case LibFunc_remainderl:

1295 case LibFunc_rint:

1296 case LibFunc_rintf:

1297 case LibFunc_rintl:

1298 case LibFunc_scalbln:

1299 case LibFunc_scalblnf:

1300 case LibFunc_scalblnl:

1301 case LibFunc_scalbn:

1302 case LibFunc_scalbnf:

1303 case LibFunc_scalbnl:

1304 case LibFunc_sin:

1305 case LibFunc_sincospif_stret:

1306 case LibFunc_sinf:

1307 case LibFunc_sinh:

1308 case LibFunc_sinhf:

1309 case LibFunc_sinhl:

1310 case LibFunc_sinl:

1311 case LibFunc_sinpi:

1312 case LibFunc_sinpif:

1313 case LibFunc_sqrt:

1314 case LibFunc_sqrtf:

1315 case LibFunc_sqrtl:

1316 case LibFunc_tan:

1317 case LibFunc_tanf:

1318 case LibFunc_tanh:

1319 case LibFunc_tanhf:

1320 case LibFunc_tanhl:

1321 case LibFunc_tanl:

1327 break;

1328 case LibFunc_abs:

1329 case LibFunc_cbrt:

1330 case LibFunc_cbrtf:

1331 case LibFunc_cbrtl:

1332 case LibFunc_copysign:

1333 case LibFunc_copysignf:

1334 case LibFunc_copysignl:

1335 case LibFunc_ceil:

1336 case LibFunc_ceilf:

1337 case LibFunc_ceill:

1338 case LibFunc_fabs:

1339 case LibFunc_fabsf:

1340 case LibFunc_fabsl:

1341 case LibFunc_ffs:

1342 case LibFunc_ffsl:

1343 case LibFunc_ffsll:

1344 case LibFunc_floor:

1345 case LibFunc_floorf:

1346 case LibFunc_floorl:

1347 case LibFunc_fls:

1348 case LibFunc_flsl:

1349 case LibFunc_flsll:

1350 case LibFunc_fmax:

1351 case LibFunc_fmaxf:

1352 case LibFunc_fmaxl:

1353 case LibFunc_fmin:

1354 case LibFunc_fminf:

1355 case LibFunc_fminl:

1356 case LibFunc_fmaximum_num:

1357 case LibFunc_fmaximum_numf:

1358 case LibFunc_fmaximum_numl:

1359 case LibFunc_fminimum_num:

1360 case LibFunc_fminimum_numf:

1361 case LibFunc_fminimum_numl:

1362 case LibFunc_labs:

1363 case LibFunc_llabs:

1364 case LibFunc_nearbyint:

1365 case LibFunc_nearbyintf:

1366 case LibFunc_nearbyintl:

1367 case LibFunc_round:

1368 case LibFunc_roundf:

1369 case LibFunc_roundl:

1370 case LibFunc_roundeven:

1371 case LibFunc_roundevenf:

1372 case LibFunc_roundevenl:

1373 case LibFunc_toascii:

1374 case LibFunc_trunc:

1375 case LibFunc_truncf:

1376 case LibFunc_truncl:

1378 [[fallthrough]];

1379 case LibFunc_isascii:

1380 case LibFunc_isdigit:

1385 break;

1386 case LibFunc_sincos:

1387 case LibFunc_sincosf:

1388 case LibFunc_sincosl:

1391 [[fallthrough]];

1392 case LibFunc_remquo:

1393 case LibFunc_remquof:

1394 case LibFunc_remquol:

1402 break;

1403 default:

1404

1405

1406 break;

1407 }

1408

1409

1413}

1414

1418 if (ExtAttr != Attribute::None && F.hasParamAttribute(ArgNo, ExtAttr))

1419 F.addParamAttr(ArgNo, ExtAttr);

1420}

1421

1425 if (ExtAttr != Attribute::None && F.hasRetAttribute(ExtAttr))

1426 F.addRetAttr(ExtAttr);

1427}

1428

1429

1431 if (F->arg_size() || F->isVarArg())

1432 return;

1433

1436 return;

1437

1438 const Module *M = F->getParent();

1439 unsigned N = M->getNumberRegisterParameters();

1440 if (N)

1441 return;

1442

1444

1446 Type *T = A.getType();

1447 if (T->isIntOrPtrTy())

1448 continue;

1449

1450 const TypeSize &TS = DL.getTypeAllocSize(T);

1451 if (TS > 8)

1452 continue;

1453

1454 assert(TS <= 4 && "Need to account for parameters larger than word size");

1455 const unsigned NumRegs = TS > 4 ? 2 : 1;

1456 if (N < NumRegs)

1457 return;

1458

1459 N -= NumRegs;

1460 F->addParamAttr(A.getArgNo(), Attribute::InReg);

1461 }

1462}

1463

1466 AttributeList AttributeList) {

1468 "Creating call to non-existing library function.");

1470 FunctionCallee C = M->getOrInsertFunction(Name, T, AttributeList);

1471

1472

1473

1474

1475

1476

1477

1478

1479

1480

1482 assert(F->getFunctionType() == T && "Function type does not match.");

1483 switch (TheLibFunc) {

1484 case LibFunc_fputc:

1485 case LibFunc_putchar:

1487 break;

1488 case LibFunc_ldexp:

1489 case LibFunc_ldexpf:

1490 case LibFunc_ldexpl:

1491 case LibFunc_memchr:

1492 case LibFunc_memrchr:

1493 case LibFunc_strchr:

1495 break;

1496 case LibFunc_memccpy:

1498 break;

1499

1500

1501

1502

1503 case LibFunc_bcmp:

1505 break;

1506 case LibFunc_calloc:

1507 case LibFunc_fwrite:

1508 case LibFunc_malloc:

1509 case LibFunc_memcmp:

1510 case LibFunc_memcpy_chk:

1511 case LibFunc_mempcpy:

1512 case LibFunc_memset_pattern16:

1513 case LibFunc_snprintf:

1514 case LibFunc_stpncpy:

1515 case LibFunc_strlcat:

1516 case LibFunc_strlcpy:

1517 case LibFunc_strncat:

1518 case LibFunc_strncmp:

1519 case LibFunc_strncpy:

1520 case LibFunc_vsnprintf:

1521 break;

1522

1523 default:

1524#ifndef NDEBUG

1525 for (unsigned i = 0; i < T->getNumParams(); i++)

1527 "Unhandled integer argument.");

1528#endif

1529 break;

1530 }

1531

1533

1534 return C;

1535}

1536

1541

1543 LibFunc TheLibFunc) {

1545 if (!TLI->has(TheLibFunc))

1546 return false;

1547

1548

1549

1550 if (GlobalValue *GV = M->getNamedValue(FuncName)) {

1553 return false;

1554 }

1555

1556 return true;

1557}

1558

1561 LibFunc TheLibFunc;

1562 return TLI->getLibFunc(Name, TheLibFunc) &&

1564}

1565

1567 LibFunc DoubleFn, LibFunc FloatFn, LibFunc LongDoubleFn) {

1568 switch (Ty->getTypeID()) {

1570 return false;

1575 default:

1577 }

1578}

1579

1581 Type *Ty, LibFunc DoubleFn, LibFunc FloatFn,

1582 LibFunc LongDoubleFn, LibFunc &TheLibFunc) {

1583 assert(hasFloatFn(M, TLI, Ty, DoubleFn, FloatFn, LongDoubleFn) &&

1584 "Cannot get name for unavailable function!");

1585

1586 switch (Ty->getTypeID()) {

1590 TheLibFunc = FloatFn;

1591 return TLI->getName(FloatFn);

1593 TheLibFunc = DoubleFn;

1594 return TLI->getName(DoubleFn);

1595 default:

1596 TheLibFunc = LongDoubleFn;

1597 return TLI->getName(LongDoubleFn);

1598 }

1599}

1600

1601

1602

1606

1608 const Module *M = B.GetInsertBlock()->getModule();

1610}

1611

1616 bool IsVaArgs = false) {

1617 Module *M = B.GetInsertBlock()->getModule();

1619 return nullptr;

1620

1625 CallInst *CI = B.CreateCall(Callee, Operands, FuncName);

1629 return CI;

1630}

1631

1634 Type *CharPtrTy = B.getPtrTy();

1636 return emitLibCall(LibFunc_strlen, SizeTTy, CharPtrTy, Ptr, B, TLI);

1637}

1638

1642 "Argument to wcslen intrinsic must be a pointer.");

1643 Type *PtrTy = B.getPtrTy();

1645 return emitLibCall(LibFunc_wcslen, SizeTTy, PtrTy, Ptr, B, TLI);

1646}

1647

1650 Type *CharPtrTy = B.getPtrTy();

1651 return emitLibCall(LibFunc_strdup, CharPtrTy, CharPtrTy, Ptr, B, TLI);

1652}

1653

1656 Type *CharPtrTy = B.getPtrTy();

1658 return emitLibCall(LibFunc_strchr, CharPtrTy, {CharPtrTy, IntTy},

1659 {Ptr, ConstantInt::get(IntTy, C)}, B, TLI);

1660}

1661

1664 Type *CharPtrTy = B.getPtrTy();

1668 LibFunc_strncmp, IntTy,

1669 {CharPtrTy, CharPtrTy, SizeTTy},

1670 {Ptr1, Ptr2, Len}, B, TLI);

1671}

1672

1675 Type *CharPtrTy = Dst->getType();

1676 return emitLibCall(LibFunc_strcpy, CharPtrTy, {CharPtrTy, CharPtrTy},

1677 {Dst, Src}, B, TLI);

1678}

1679

1682 Type *CharPtrTy = B.getPtrTy();

1683 return emitLibCall(LibFunc_stpcpy, CharPtrTy, {CharPtrTy, CharPtrTy},

1684 {Dst, Src}, B, TLI);

1685}

1686

1689 Type *CharPtrTy = B.getPtrTy();

1691 return emitLibCall(LibFunc_strncpy, CharPtrTy, {CharPtrTy, CharPtrTy, SizeTTy},

1692 {Dst, Src, Len}, B, TLI);

1693}

1694

1697 Type *CharPtrTy = B.getPtrTy();

1699 return emitLibCall(LibFunc_stpncpy, CharPtrTy, {CharPtrTy, CharPtrTy, SizeTTy},

1700 {Dst, Src, Len}, B, TLI);

1701}

1702

1706 Module *M = B.GetInsertBlock()->getModule();

1708 return nullptr;

1709

1710 AttributeList AS;

1711 AS = AttributeList::get(M->getContext(), AttributeList::FunctionIndex,

1712 Attribute::NoUnwind);

1713 Type *VoidPtrTy = B.getPtrTy();

1716 AttributeList::get(M->getContext(), AS), VoidPtrTy,

1717 VoidPtrTy, VoidPtrTy, SizeTTy, SizeTTy);

1718 CallInst *CI = B.CreateCall(MemCpy, {Dst, Src, Len, ObjSize});

1722 return CI;

1723}

1724

1727 Type *VoidPtrTy = B.getPtrTy();

1729 return emitLibCall(LibFunc_mempcpy, VoidPtrTy,

1730 {VoidPtrTy, VoidPtrTy, SizeTTy},

1731 {Dst, Src, Len}, B, TLI);

1732}

1733

1736 Type *VoidPtrTy = B.getPtrTy();

1739 return emitLibCall(LibFunc_memchr, VoidPtrTy,

1740 {VoidPtrTy, IntTy, SizeTTy},

1741 {Ptr, Val, Len}, B, TLI);

1742}

1743

1746 Type *VoidPtrTy = B.getPtrTy();

1749 return emitLibCall(LibFunc_memrchr, VoidPtrTy,

1750 {VoidPtrTy, IntTy, SizeTTy},

1751 {Ptr, Val, Len}, B, TLI);

1752}

1753

1756 Type *VoidPtrTy = B.getPtrTy();

1759 return emitLibCall(LibFunc_memcmp, IntTy,

1760 {VoidPtrTy, VoidPtrTy, SizeTTy},

1761 {Ptr1, Ptr2, Len}, B, TLI);

1762}

1763

1766 Type *VoidPtrTy = B.getPtrTy();

1770 {VoidPtrTy, VoidPtrTy, SizeTTy},

1771 {Ptr1, Ptr2, Len}, B, TLI);

1772}

1773

1776 Type *VoidPtrTy = B.getPtrTy();

1779 return emitLibCall(LibFunc_memccpy, VoidPtrTy,

1780 {VoidPtrTy, VoidPtrTy, IntTy, SizeTTy},

1781 {Ptr1, Ptr2, Val, Len}, B, TLI);

1782}

1783

1787 Type *CharPtrTy = B.getPtrTy();

1792 return emitLibCall(LibFunc_snprintf, IntTy,

1793 {CharPtrTy, SizeTTy, CharPtrTy},

1794 Args, B, TLI, true);

1795}

1796

1800 Type *CharPtrTy = B.getPtrTy();

1804 return emitLibCall(LibFunc_sprintf, IntTy,

1805 {CharPtrTy, CharPtrTy}, Args, B, TLI,

1806 true);

1807}

1808

1811 Type *CharPtrTy = B.getPtrTy();

1812 return emitLibCall(LibFunc_strcat, CharPtrTy,

1813 {CharPtrTy, CharPtrTy},

1814 {Dest, Src}, B, TLI);

1815}

1816

1819 Type *CharPtrTy = B.getPtrTy();

1821 return emitLibCall(LibFunc_strlcpy, SizeTTy,

1822 {CharPtrTy, CharPtrTy, SizeTTy},

1823 {Dest, Src, Size}, B, TLI);

1824}

1825

1828 Type *CharPtrTy = B.getPtrTy();

1830 return emitLibCall(LibFunc_strlcat, SizeTTy,

1831 {CharPtrTy, CharPtrTy, SizeTTy},

1832 {Dest, Src, Size}, B, TLI);

1833}

1834

1837 Type *CharPtrTy = B.getPtrTy();

1839 return emitLibCall(LibFunc_strncat, CharPtrTy,

1840 {CharPtrTy, CharPtrTy, SizeTTy},

1841 {Dest, Src, Size}, B, TLI);

1842}

1843

1846 Type *CharPtrTy = B.getPtrTy();

1850 LibFunc_vsnprintf, IntTy,

1851 {CharPtrTy, SizeTTy, CharPtrTy, VAList->getType()},

1852 {Dest, Size, Fmt, VAList}, B, TLI);

1853}

1854

1857 Type *CharPtrTy = B.getPtrTy();

1859 return emitLibCall(LibFunc_vsprintf, IntTy,

1860 {CharPtrTy, CharPtrTy, VAList->getType()},

1861 {Dest, Fmt, VAList}, B, TLI);

1862}

1863

1864

1867 if (Op->getType()->isDoubleTy()) {

1868 NameBuffer += Name;

1869

1870 if (Op->getType()->isFloatTy())

1871 NameBuffer += 'f';

1872 else

1873 NameBuffer += 'l';

1874

1875 Name = NameBuffer;

1876 }

1877}

1878

1881 const AttributeList &Attrs,

1883 assert((Name != "") && "Must specify Name to emitUnaryFloatFnCall");

1884

1885 Module *M = B.GetInsertBlock()->getModule();

1887 Op->getType());

1888 CallInst *CI = B.CreateCall(Callee, Op, Name);

1889

1890

1891

1892

1894 Attrs.removeFnAttribute(B.getContext(), Attribute::Speculatable));

1898

1899 return CI;

1900}

1901

1904 const AttributeList &Attrs) {

1907

1908 LibFunc TheLibFunc;

1910

1912}

1913

1915 LibFunc DoubleFn, LibFunc FloatFn,

1917 const AttributeList &Attrs) {

1918

1919 Module *M = B.GetInsertBlock()->getModule();

1920 LibFunc TheLibFunc;

1922 LongDoubleFn, TheLibFunc);

1923

1925}

1926

1928 LibFunc TheLibFunc,

1930 const AttributeList &Attrs,

1932 assert((Name != "") && "Must specify Name to emitBinaryFloatFnCall");

1933

1934 Module *M = B.GetInsertBlock()->getModule();

1938 CallInst *CI = B.CreateCall(Callee, { Op1, Op2 }, Name);

1939

1940

1941

1942

1944 Attrs.removeFnAttribute(B.getContext(), Attribute::Speculatable));

1948

1949 return CI;

1950}

1951

1955 const AttributeList &Attrs) {

1956 assert((Name != "") && "Must specify Name to emitBinaryFloatFnCall");

1957

1960

1961 LibFunc TheLibFunc;

1963

1965}

1966

1969 LibFunc DoubleFn, LibFunc FloatFn,

1971 const AttributeList &Attrs) {

1972

1973 Module *M = B.GetInsertBlock()->getModule();

1974 LibFunc TheLibFunc;

1976 LongDoubleFn, TheLibFunc);

1977

1979}

1980

1981

1982

1985 Module *M = B.GetInsertBlock()->getModule();

1987 return nullptr;

1988

1992 IntTy, IntTy);

1994 CallInst *CI = B.CreateCall(PutChar, Char, PutCharName);

1995

1999 return CI;

2000}

2001

2004 Module *M = B.GetInsertBlock()->getModule();

2006 return nullptr;

2007

2013 CallInst *CI = B.CreateCall(PutS, Str, PutsName);

2017 return CI;

2018}

2019

2022 Module *M = B.GetInsertBlock()->getModule();

2024 return nullptr;

2025

2029 IntTy, File->getType());

2030 if (File->getType()->isPointerTy())

2032 CallInst *CI = B.CreateCall(F, {Char, File}, FPutcName);

2033

2037 return CI;

2038}

2039

2042 Module *M = B.GetInsertBlock()->getModule();

2044 return nullptr;

2045

2049 B.getPtrTy(), File->getType());

2050 if (File->getType()->isPointerTy())

2052 CallInst *CI = B.CreateCall(F, {Str, File}, FPutsName);

2053

2057 return CI;

2058}

2059

2062 Module *M = B.GetInsertBlock()->getModule();

2064 return nullptr;

2065

2070 SizeTTy, SizeTTy, File->getType());

2071

2072 if (File->getType()->isPointerTy())

2075 B.CreateCall(F, {Ptr, Size,

2076 ConstantInt::get(SizeTTy, 1), File});

2077

2081 return CI;

2082}

2083

2086 Module *M = B.GetInsertBlock()->getModule();

2088 return nullptr;

2089

2096

2100

2101 return CI;

2102}

2103

2106 Module *M = B.GetInsertBlock()->getModule();

2108 return nullptr;

2109

2113 M, TLI, LibFunc_calloc, B.getPtrTy(AddrSpace), SizeTTy, SizeTTy);

2115 CallInst *CI = B.CreateCall(Calloc, {Num, Size}, CallocName);

2116

2117 if (const auto *F =

2120

2121 return CI;

2122}

2123

2126 LibFunc SizeFeedbackNewFunc,

2128 Module *M = B.GetInsertBlock()->getModule();

2130 return nullptr;

2131

2133

2134

2136 StructType::get(M->getContext(), {B.getPtrTy(), Num->getType()});

2138 M->getOrInsertFunction(Name, SizedPtrT, Num->getType(), B.getInt8Ty());

2140 CallInst *CI = B.CreateCall(Func, {Num, B.getInt8(HotCold)}, "sized_ptr");

2141

2144

2145 return CI;

2146}

2147

2151 LibFunc SizeFeedbackNewFunc,

2153 Module *M = B.GetInsertBlock()->getModule();

2155 return nullptr;

2156

2158

2159

2161 StructType::get(M->getContext(), {B.getPtrTy(), Num->getType()});

2163 Align->getType(), B.getInt8Ty());

2166 B.CreateCall(Func, {Num, Align, B.getInt8(HotCold)}, "sized_ptr");

2167

2170

2171 return CI;

2172}

2173

2177 Module *M = B.GetInsertBlock()->getModule();

2179 return nullptr;

2180

2183 M->getOrInsertFunction(Name, B.getPtrTy(), Num->getType(), B.getInt8Ty());

2185 CallInst *CI = B.CreateCall(Func, {Num, B.getInt8(HotCold)}, Name);

2186

2190

2191 return CI;

2192}

2193

2196 LibFunc NewFunc, uint8_t HotCold) {

2197 Module *M = B.GetInsertBlock()->getModule();

2199 return nullptr;

2200

2203 Name, B.getPtrTy(), Num->getType(), NoThrow->getType(), B.getInt8Ty());

2205 CallInst *CI = B.CreateCall(Func, {Num, NoThrow, B.getInt8(HotCold)}, Name);

2206

2210

2211 return CI;

2212}

2213

2216 LibFunc NewFunc, uint8_t HotCold) {

2217 Module *M = B.GetInsertBlock()->getModule();

2219 return nullptr;

2220

2223 Name, B.getPtrTy(), Num->getType(), Align->getType(), B.getInt8Ty());

2225 CallInst *CI = B.CreateCall(Func, {Num, Align, B.getInt8(HotCold)}, Name);

2226

2230

2231 return CI;

2232}

2233

2237 LibFunc NewFunc, uint8_t HotCold) {

2238 Module *M = B.GetInsertBlock()->getModule();

2240 return nullptr;

2241

2245 B.getInt8Ty());

2248 B.CreateCall(Func, {Num, Align, NoThrow, B.getInt8(HotCold)}, Name);

2249

2253

2254 return CI;

2255}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL

static bool setRetNoUndef(Function &F)

Definition BuildLibCalls.cpp:201

static void appendTypeSuffix(Value *Op, StringRef &Name, SmallString< 20 > &NameBuffer)

Append a suffix to the function name according to the type of 'Op'.

Definition BuildLibCalls.cpp:1865

static bool setDoesNotAlias(Function &F, unsigned ArgNo)

Definition BuildLibCalls.cpp:177

static bool setDoesNotAccessMemory(Function &F)

Definition BuildLibCalls.cpp:61

static bool setOnlyWritesArgMemOrErrnoMem(Function &F)

Definition BuildLibCalls.cpp:136

static bool setArgsNoUndef(Function &F)

Definition BuildLibCalls.cpp:211

static IntegerType * getSizeTTy(IRBuilderBase &B, const TargetLibraryInfo *TLI)

Definition BuildLibCalls.cpp:1607

static Value * emitUnaryFloatFnCallHelper(Value *Op, LibFunc TheLibFunc, StringRef Name, IRBuilderBase &B, const AttributeList &Attrs, const TargetLibraryInfo *TLI)

Definition BuildLibCalls.cpp:1879

static bool setAllocatedPointerParam(Function &F, unsigned ArgNo)

Definition BuildLibCalls.cpp:275

static void setRetExtAttr(Function &F, const TargetLibraryInfo &TLI, bool Signed=true)

Definition BuildLibCalls.cpp:1422

static bool setMemoryEffects(Function &F, MemoryEffects ME)

Definition BuildLibCalls.cpp:85

static Value * emitLibCall(LibFunc TheLibFunc, Type *ReturnType, ArrayRef< Type * > ParamTypes, ArrayRef< Value * > Operands, IRBuilderBase &B, const TargetLibraryInfo *TLI, bool IsVaArgs=false)

Definition BuildLibCalls.cpp:1612

static bool setNonLazyBind(Function &F)

Definition BuildLibCalls.cpp:246

static bool setIsCold(Function &F)

Definition BuildLibCalls.cpp:69

static bool setOnlyAccessesInaccessibleMemOrArgMem(Function &F)

Definition BuildLibCalls.cpp:122

static bool setAllocSize(Function &F, unsigned ElemSizeArg, std::optional< unsigned > NumElemsArg)

Definition BuildLibCalls.cpp:282

static bool setAlignedAllocParam(Function &F, unsigned ArgNo)

Definition BuildLibCalls.cpp:268

static bool setRetAndArgsNoUndef(Function &F)

Definition BuildLibCalls.cpp:231

static bool setRetDoesNotAlias(Function &F)

Definition BuildLibCalls.cpp:160

static bool setReturnedArg(Function &F, unsigned ArgNo)

Definition BuildLibCalls.cpp:238

static Value * emitBinaryFloatFnCallHelper(Value *Op1, Value *Op2, LibFunc TheLibFunc, StringRef Name, IRBuilderBase &B, const AttributeList &Attrs, const TargetLibraryInfo *TLI)

Definition BuildLibCalls.cpp:1927

static bool setOnlyWritesErrnoMemory(Function &F)

Definition BuildLibCalls.cpp:129

static bool setDoesNotCapture(Function &F, unsigned ArgNo)

Definition BuildLibCalls.cpp:168

static bool setDoesNotThrow(Function &F)

Definition BuildLibCalls.cpp:144

static bool setWillReturn(Function &F)

Definition BuildLibCalls.cpp:260

static bool setAllocKind(Function &F, AllocFnKind K)

Definition BuildLibCalls.cpp:298

static bool setNoReturn(Function &F)

Definition BuildLibCalls.cpp:77

static bool setOnlyAccessesInaccessibleMemory(Function &F)

Definition BuildLibCalls.cpp:94

static IntegerType * getIntTy(IRBuilderBase &B, const TargetLibraryInfo *TLI)

Definition BuildLibCalls.cpp:1603

static bool setAllocFamily(Function &F, StringRef Family)

Definition BuildLibCalls.cpp:291

static bool setArgNoUndef(Function &F, unsigned ArgNo)

Definition BuildLibCalls.cpp:223

static bool setDoesNotCallback(Function &F)

Definition BuildLibCalls.cpp:152

static void setArgExtAttr(Function &F, unsigned ArgNo, const TargetLibraryInfo &TLI, bool Signed=true)

Definition BuildLibCalls.cpp:1415

static bool setOnlyAccessesArgMemory(Function &F)

Definition BuildLibCalls.cpp:115

static bool setOnlyWritesMemory(Function &F)

Definition BuildLibCalls.cpp:108

static bool setOnlyReadsMemory(Function &F)

Definition BuildLibCalls.cpp:101

static bool setDoesNotFreeMemory(Function &F)

Definition BuildLibCalls.cpp:253

static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")

static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")

This file contains the declarations for the subclasses of Constant, which represent the different fla...

Module.h This file contains the declarations for the Module class.

This file defines the SmallString class.

This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...

#define STATISTIC(VARNAME, DESC)

This class represents an incoming formal argument to a Function.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

static LLVM_ABI Attribute get(LLVMContext &Context, AttrKind Kind, uint64_t Val=0)

Return a uniquified Attribute object.

static LLVM_ABI Attribute getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg, const std::optional< unsigned > &NumElemsArg)

AttrKind

This enumeration lists the attributes that can be associated with parameters, function results,...

@ None

No attributes have been set.

static LLVM_ABI Attribute getWithCaptureInfo(LLVMContext &Context, CaptureInfo CI)

void setCallingConv(CallingConv::ID CC)

void setAttributes(AttributeList A)

Set the attributes for this call.

This class represents a function call, abstracting a target machine's calling convention.

static CaptureInfo none()

Create CaptureInfo that does not capture any components of the pointer.

A parsed version of the target data layout string in and methods for querying it.

A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...

Class to represent function types.

static LLVM_ABI FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)

This static method is the primary way of constructing a FunctionType.

Common base class shared among various IRBuilders.

Class to represent integer types.

static MemoryEffectsBase readOnly()

static MemoryEffectsBase argMemOnly(ModRefInfo MR=ModRefInfo::ModRef)

static MemoryEffectsBase inaccessibleMemOnly(ModRefInfo MR=ModRefInfo::ModRef)

static MemoryEffectsBase errnoMemOnly(ModRefInfo MR=ModRefInfo::ModRef)

static MemoryEffectsBase writeOnly()

static MemoryEffectsBase inaccessibleOrArgMemOnly(ModRefInfo MR=ModRefInfo::ModRef)

static MemoryEffectsBase argumentOrErrnoMemOnly(ModRefInfo ArgMR=ModRefInfo::ModRef, ModRefInfo ErrnoMR=ModRefInfo::ModRef)

A Module instance is used to store all the information related to an LLVM module.

SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

StringRef - Represent a constant reference to a string, i.e.

Class to represent struct types.

static LLVM_ABI StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)

This static method is the primary way to create a literal StructType.

Provides information about what library functions are available for the current target.

bool isValidProtoForLibFunc(const FunctionType &FTy, LibFunc F, const Module &M) const

Return true if the function type FTy is valid for the library function F, regardless of whether the f...

bool has(LibFunc F) const

Tests whether a library function is available.

unsigned getSizeTSize(const Module &M) const

Returns the size of the size_t type in bits.

bool getLibFunc(StringRef funcName, LibFunc &F) const

Searches for a particular function name.

StringRef getName(LibFunc F) const

unsigned getIntSize() const

Get size of a C-level int or unsigned int, in bits.

The instances of the Type class are immutable: once they are created, they are never changed.

bool isPointerTy() const

True if this is an instance of PointerType.

@ HalfTyID

16-bit floating point type

@ FloatTyID

32-bit floating point type

@ DoubleTyID

64-bit floating point type

LLVM Value Representation.

Type * getType() const

All values are typed, get the type of this value.

LLVM_ABI const Value * stripPointerCasts() const

Strip off pointer casts, all-zero GEPs and address space casts.

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

@ X86_StdCall

stdcall is mostly used by the Win32 API.

@ C

The default llvm calling convention, compatible with C.

This is an optimization pass for GlobalISel generic memory operations.

LLVM_ABI Value * emitUnaryFloatFnCall(Value *Op, const TargetLibraryInfo *TLI, StringRef Name, IRBuilderBase &B, const AttributeList &Attrs)

Emit a call to the unary function named 'Name' (e.g.

Definition BuildLibCalls.cpp:1902

LLVM_ABI Value * emitStrChr(Value *Ptr, char C, IRBuilderBase &B, const TargetLibraryInfo *TLI)

Emit a call to the strchr function to the builder, for the specified pointer and character.

Definition BuildLibCalls.cpp:1654

LLVM_ABI Value * emitPutChar(Value *Char, IRBuilderBase &B, const TargetLibraryInfo *TLI)

Emit a call to the putchar function. This assumes that Char is an 'int'.

Definition BuildLibCalls.cpp:1983

LLVM_ABI Value * emitMemCpyChk(Value *Dst, Value *Src, Value *Len, Value *ObjSize, IRBuilderBase &B, const DataLayout &DL, const TargetLibraryInfo *TLI)

Emit a call to the __memcpy_chk function to the builder.

Definition BuildLibCalls.cpp:1703

LLVM_ABI Value * emitStrNCpy(Value *Dst, Value *Src, Value *Len, IRBuilderBase &B, const TargetLibraryInfo *TLI)

Emit a call to the strncpy function to the builder, for the specified pointer arguments and length.

Definition BuildLibCalls.cpp:1687

LLVM_ABI Value * emitHotColdNewAlignedNoThrow(Value *Num, Value *Align, Value *NoThrow, IRBuilderBase &B, const TargetLibraryInfo *TLI, LibFunc NewFunc, uint8_t HotCold)

Definition BuildLibCalls.cpp:2234

decltype(auto) dyn_cast(const From &Val)

dyn_cast - Return the argument parameter cast to the specified type.

LLVM_ABI Value * emitSPrintf(Value *Dest, Value *Fmt, ArrayRef< Value * > VariadicArgs, IRBuilderBase &B, const TargetLibraryInfo *TLI)

Emit a call to the sprintf function.

Definition BuildLibCalls.cpp:1797

LLVM_ABI Value * emitMemRChr(Value *Ptr, Value *Val, Value *Len, IRBuilderBase &B, const DataLayout &DL, const TargetLibraryInfo *TLI)

Emit a call to the memrchr function, analogously to emitMemChr.

Definition BuildLibCalls.cpp:1744

LLVM_ABI Value * emitStrLCat(Value *Dest, Value *Src, Value *Size, IRBuilderBase &B, const TargetLibraryInfo *TLI)

Emit a call to the strlcat function.

Definition BuildLibCalls.cpp:1826

void append_range(Container &C, Range &&R)

Wrapper function to append range R to container C.

MemoryEffectsBase< IRMemLocation > MemoryEffects

Summary of how a function affects memory in the program.

LLVM_ABI bool hasFloatFn(const Module *M, const TargetLibraryInfo *TLI, Type *Ty, LibFunc DoubleFn, LibFunc FloatFn, LibFunc LongDoubleFn)

Check whether the overloaded floating point function corresponding to Ty is available.

Definition BuildLibCalls.cpp:1566

LLVM_ABI bool inferNonMandatoryLibFuncAttrs(Module *M, StringRef Name, const TargetLibraryInfo &TLI)

Analyze the name and prototype of the given function and set any applicable attributes.

Definition BuildLibCalls.cpp:306

LLVM_ABI bool isLibFreeFunction(const Function *F, const LibFunc TLIFn)

isLibFreeFunction - Returns true if the function is a builtin free()

LLVM_ABI Value * emitStrNCat(Value *Dest, Value *Src, Value *Size, IRBuilderBase &B, const TargetLibraryInfo *TLI)

Emit a call to the strncat function.

Definition BuildLibCalls.cpp:1835

LLVM_ABI bool isLibFuncEmittable(const Module *M, const TargetLibraryInfo *TLI, LibFunc TheLibFunc)

Check whether the library function is available on target and also that it in the current Module is a...

Definition BuildLibCalls.cpp:1542

LLVM_ABI Value * emitVSNPrintf(Value *Dest, Value *Size, Value *Fmt, Value *VAList, IRBuilderBase &B, const TargetLibraryInfo *TLI)

Emit a call to the vsnprintf function.

Definition BuildLibCalls.cpp:1844

LLVM_ABI Value * emitStrNCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilderBase &B, const DataLayout &DL, const TargetLibraryInfo *TLI)

Emit a call to the strncmp function to the builder.

Definition BuildLibCalls.cpp:1662

LLVM_ABI Value * emitMemCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilderBase &B, const DataLayout &DL, const TargetLibraryInfo *TLI)

Emit a call to the memcmp function.

Definition BuildLibCalls.cpp:1754

LLVM_ABI Value * emitBinaryFloatFnCall(Value *Op1, Value *Op2, const TargetLibraryInfo *TLI, StringRef Name, IRBuilderBase &B, const AttributeList &Attrs)

Emit a call to the binary function named 'Name' (e.g.

Definition BuildLibCalls.cpp:1952

LLVM_ABI Value * emitFPutS(Value *Str, Value *File, IRBuilderBase &B, const TargetLibraryInfo *TLI)

Emit a call to the fputs function.

Definition BuildLibCalls.cpp:2040

LLVM_ABI Value * emitStrDup(Value *Ptr, IRBuilderBase &B, const TargetLibraryInfo *TLI)

Emit a call to the strdup function to the builder, for the specified pointer.

Definition BuildLibCalls.cpp:1648

LLVM_ABI Value * emitBCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilderBase &B, const DataLayout &DL, const TargetLibraryInfo *TLI)

Emit a call to the bcmp function.

Definition BuildLibCalls.cpp:1764

LLVM_ABI void markRegisterParameterAttributes(Function *F)

Definition BuildLibCalls.cpp:1430

LLVM_ABI StringRef getFloatFn(const Module *M, const TargetLibraryInfo *TLI, Type *Ty, LibFunc DoubleFn, LibFunc FloatFn, LibFunc LongDoubleFn, LibFunc &TheLibFunc)

Get the name of the overloaded floating point function corresponding to Ty.

Definition BuildLibCalls.cpp:1580

LLVM_ABI FunctionCallee getOrInsertLibFunc(Module *M, const TargetLibraryInfo &TLI, LibFunc TheLibFunc, FunctionType *T, AttributeList AttributeList)

Calls getOrInsertFunction() and then makes sure to add mandatory argument attributes.

Definition BuildLibCalls.cpp:1464

LLVM_ABI Value * emitStrLen(Value *Ptr, IRBuilderBase &B, const DataLayout &DL, const TargetLibraryInfo *TLI)

Emit a call to the strlen function to the builder, for the specified pointer.

Definition BuildLibCalls.cpp:1632

LLVM_ABI Value * emitFPutC(Value *Char, Value *File, IRBuilderBase &B, const TargetLibraryInfo *TLI)

Emit a call to the fputc function.

Definition BuildLibCalls.cpp:2020

LLVM_ABI Value * emitStpNCpy(Value *Dst, Value *Src, Value *Len, IRBuilderBase &B, const TargetLibraryInfo *TLI)

Emit a call to the stpncpy function to the builder, for the specified pointer arguments and length.

Definition BuildLibCalls.cpp:1695

LLVM_ABI Value * emitStrCat(Value *Dest, Value *Src, IRBuilderBase &B, const TargetLibraryInfo *TLI)

Emit a call to the strcat function.

Definition BuildLibCalls.cpp:1809

LLVM_ABI Value * emitCalloc(Value *Num, Value *Size, IRBuilderBase &B, const TargetLibraryInfo &TLI, unsigned AddrSpace)

Emit a call to the calloc function.

Definition BuildLibCalls.cpp:2104

bool isa(const From &Val)

isa - Return true if the parameter to the template is an instance of one of the template type argu...

LLVM_ABI Value * emitVSPrintf(Value *Dest, Value *Fmt, Value *VAList, IRBuilderBase &B, const TargetLibraryInfo *TLI)

Emit a call to the vsprintf function.

Definition BuildLibCalls.cpp:1855

LLVM_ABI bool isReallocLikeFn(const Function *F)

Tests if a function is a call or invoke to a library function that reallocates memory (e....

LLVM_ABI Value * emitFWrite(Value *Ptr, Value *Size, Value *File, IRBuilderBase &B, const DataLayout &DL, const TargetLibraryInfo *TLI)

Emit a call to the fwrite function.

Definition BuildLibCalls.cpp:2060

LLVM_ABI Value * emitSNPrintf(Value *Dest, Value *Size, Value *Fmt, ArrayRef< Value * > Args, IRBuilderBase &B, const TargetLibraryInfo *TLI)

Emit a call to the snprintf function.

Definition BuildLibCalls.cpp:1784

@ Mod

The access may modify the value stored in memory.

LLVM_ABI Value * emitStpCpy(Value *Dst, Value *Src, IRBuilderBase &B, const TargetLibraryInfo *TLI)

Emit a call to the stpcpy function to the builder, for the specified pointer arguments.

Definition BuildLibCalls.cpp:1680

DWARFExpression::Operation Op

LLVM_ABI Value * emitWcsLen(Value *Ptr, IRBuilderBase &B, const DataLayout &DL, const TargetLibraryInfo *TLI)

Emit a call to the wcslen function to the builder, for the specified pointer.

Definition BuildLibCalls.cpp:1639

decltype(auto) cast(const From &Val)

cast - Return the argument parameter cast to the specified type.

LLVM_ABI Value * emitHotColdNewNoThrow(Value *Num, Value *NoThrow, IRBuilderBase &B, const TargetLibraryInfo *TLI, LibFunc NewFunc, uint8_t HotCold)

Definition BuildLibCalls.cpp:2194

LLVM_ABI Value * emitMalloc(Value *Num, IRBuilderBase &B, const DataLayout &DL, const TargetLibraryInfo *TLI)

Emit a call to the malloc function.

Definition BuildLibCalls.cpp:2084

LLVM_ABI Value * emitMemChr(Value *Ptr, Value *Val, Value *Len, IRBuilderBase &B, const DataLayout &DL, const TargetLibraryInfo *TLI)

Emit a call to the memchr function.

Definition BuildLibCalls.cpp:1734

LLVM_ABI Value * emitHotColdNewAligned(Value *Num, Value *Align, IRBuilderBase &B, const TargetLibraryInfo *TLI, LibFunc NewFunc, uint8_t HotCold)

Definition BuildLibCalls.cpp:2214

LLVM_ABI Value * emitPutS(Value *Str, IRBuilderBase &B, const TargetLibraryInfo *TLI)

Emit a call to the puts function. This assumes that Str is some pointer.

Definition BuildLibCalls.cpp:2002

LLVM_ABI Value * emitMemCCpy(Value *Ptr1, Value *Ptr2, Value *Val, Value *Len, IRBuilderBase &B, const TargetLibraryInfo *TLI)

Emit a call to the memccpy function.

Definition BuildLibCalls.cpp:1774

LLVM_ABI Value * emitHotColdSizeReturningNew(Value *Num, IRBuilderBase &B, const TargetLibraryInfo *TLI, LibFunc NewFunc, uint8_t HotCold)

Definition BuildLibCalls.cpp:2124

LLVM_ABI Value * emitHotColdNew(Value *Num, IRBuilderBase &B, const TargetLibraryInfo *TLI, LibFunc NewFunc, uint8_t HotCold)

Emit a call to the hot/cold operator new function.

Definition BuildLibCalls.cpp:2174

LLVM_ABI Value * emitStrLCpy(Value *Dest, Value *Src, Value *Size, IRBuilderBase &B, const TargetLibraryInfo *TLI)

Emit a call to the strlcpy function.

Definition BuildLibCalls.cpp:1817

LLVM_ABI Value * emitHotColdSizeReturningNewAligned(Value *Num, Value *Align, IRBuilderBase &B, const TargetLibraryInfo *TLI, LibFunc NewFunc, uint8_t HotCold)

Definition BuildLibCalls.cpp:2148

LLVM_ABI Value * emitStrCpy(Value *Dst, Value *Src, IRBuilderBase &B, const TargetLibraryInfo *TLI)

Emit a call to the strcpy function to the builder, for the specified pointer arguments.

Definition BuildLibCalls.cpp:1673

LLVM_ABI Value * emitMemPCpy(Value *Dst, Value *Src, Value *Len, IRBuilderBase &B, const DataLayout &DL, const TargetLibraryInfo *TLI)

Emit a call to the mempcpy function.

Definition BuildLibCalls.cpp:1725

This struct is a compact representation of a valid (non-zero power of two) alignment.