Go to the documentation of this file.
30 #define DEBUG_TYPE "build-libcalls"
34 STATISTIC(NumReadNone,
"Number of functions inferred as readnone");
36 "Number of functions inferred as inaccessiblememonly");
37 STATISTIC(NumReadOnly,
"Number of functions inferred as readonly");
38 STATISTIC(NumWriteOnly,
"Number of functions inferred as writeonly");
39 STATISTIC(NumArgMemOnly,
"Number of functions inferred as argmemonly");
41 "Number of functions inferred as inaccessiblemem_or_argmemonly");
42 STATISTIC(NumNoUnwind,
"Number of functions inferred as nounwind");
43 STATISTIC(NumNoCapture,
"Number of arguments inferred as nocapture");
44 STATISTIC(NumWriteOnlyArg,
"Number of arguments inferred as writeonly");
45 STATISTIC(NumReadOnlyArg,
"Number of arguments inferred as readonly");
46 STATISTIC(NumNoAlias,
"Number of function returns inferred as noalias");
47 STATISTIC(NumNoUndef,
"Number of function returns inferred as noundef returns");
48 STATISTIC(NumReturnedArg,
"Number of arguments inferred as returned");
49 STATISTIC(NumWillReturn,
"Number of functions inferred as willreturn");
52 if (
F.doesNotAccessMemory())
54 F.setDoesNotAccessMemory();
60 if (
F.onlyAccessesInaccessibleMemory())
62 F.setOnlyAccessesInaccessibleMemory();
63 ++NumInaccessibleMemOnly;
68 if (
F.onlyReadsMemory())
70 F.setOnlyReadsMemory();
76 if (
F.onlyWritesMemory())
79 if (
F.hasFnAttribute(Attribute::ReadOnly)) {
80 F.removeFnAttr(Attribute::ReadOnly);
84 F.setOnlyWritesMemory();
89 if (
F.onlyAccessesArgMemory())
91 F.setOnlyAccessesArgMemory();
97 if (
F.onlyAccessesInaccessibleMemOrArgMem())
99 F.setOnlyAccessesInaccessibleMemOrArgMem();
100 ++NumInaccessibleMemOrArgMemOnly;
105 if (
F.doesNotThrow())
113 if (
F.hasRetAttribute(Attribute::NoAlias))
115 F.addRetAttr(Attribute::NoAlias);
121 if (
F.hasParamAttribute(ArgNo, Attribute::NoCapture))
123 F.addParamAttr(ArgNo, Attribute::NoCapture);
129 if (
F.hasParamAttribute(ArgNo, Attribute::NoAlias))
131 F.addParamAttr(ArgNo, Attribute::NoAlias);
137 if (
F.hasParamAttribute(ArgNo, Attribute::ReadOnly))
139 F.addParamAttr(ArgNo, Attribute::ReadOnly);
145 if (
F.hasParamAttribute(ArgNo, Attribute::WriteOnly))
147 F.addParamAttr(ArgNo, Attribute::WriteOnly);
153 if (!
F.getReturnType()->isVoidTy() &&
154 !
F.hasRetAttribute(Attribute::NoUndef)) {
155 F.addRetAttr(Attribute::NoUndef);
163 bool Changed =
false;
164 for (
unsigned ArgNo = 0; ArgNo <
F.arg_size(); ++ArgNo) {
165 if (!
F.hasParamAttribute(ArgNo, Attribute::NoUndef)) {
166 F.addParamAttr(ArgNo, Attribute::NoUndef);
175 if (
F.hasParamAttribute(ArgNo, Attribute::NoUndef))
177 F.addParamAttr(ArgNo, Attribute::NoUndef);
183 bool UndefAdded =
false;
190 if (
F.hasParamAttribute(ArgNo, Attribute::Returned))
192 F.addParamAttr(ArgNo, Attribute::Returned);
198 if (
F.hasFnAttribute(Attribute::NonLazyBind))
200 F.addFnAttr(Attribute::NonLazyBind);
205 if (
F.hasFnAttribute(Attribute::NoFree))
207 F.addFnAttr(Attribute::NoFree);
212 if (
F.hasFnAttribute(Attribute::WillReturn))
214 F.addFnAttr(Attribute::WillReturn);
220 if (
F.hasParamAttribute(ArgNo, Attribute::AllocAlign))
222 F.addParamAttr(ArgNo, Attribute::AllocAlign);
227 if (
F.hasParamAttribute(ArgNo, Attribute::AllocatedPointer))
229 F.addParamAttr(ArgNo, Attribute::AllocatedPointer);
235 if (
F.hasFnAttribute(Attribute::AllocSize))
243 if (
F.hasFnAttribute(
"alloc-family"))
245 F.addFnAttr(
"alloc-family", Family);
263 bool Changed =
false;
268 if (
F.getParent() !=
nullptr &&
F.getParent()->getRtLibUseGOT())
271 switch (TheLibFunc) {
273 case LibFunc_strnlen:
282 case LibFunc_strrchr:
291 case LibFunc_strtoul:
292 case LibFunc_strtoll:
293 case LibFunc_strtold:
294 case LibFunc_strtoull:
301 case LibFunc_strncat:
312 case LibFunc_strncpy:
316 case LibFunc_stpncpy:
326 case LibFunc_strxfrm:
335 case LibFunc_strncmp:
336 case LibFunc_strcspn:
344 case LibFunc_strcoll:
345 case LibFunc_strcasecmp:
346 case LibFunc_strncasecmp:
356 case LibFunc_strpbrk:
364 case LibFunc_strtok_r:
377 case LibFunc_setvbuf:
382 case LibFunc_strndup:
395 case LibFunc_statvfs:
410 case LibFunc_sprintf:
419 case LibFunc_snprintf:
428 case LibFunc_setitimer:
442 case LibFunc_aligned_alloc:
448 case LibFunc_vec_malloc:
449 Changed |=
setAllocFamily(
F, TheLibFunc == LibFunc_vec_malloc ?
"vec_malloc"
467 case LibFunc_memrchr:
491 case LibFunc_memmove:
500 case LibFunc_mempcpy:
501 case LibFunc_memccpy:
504 case LibFunc_memcpy_chk:
513 case LibFunc_memalign:
535 case LibFunc_realloc:
536 case LibFunc_reallocf:
537 case LibFunc_vec_realloc:
539 F, TheLibFunc == LibFunc_vec_realloc ?
"vec_malloc" :
"malloc");
562 case LibFunc_realpath:
576 case LibFunc_readlink:
614 case LibFunc_vec_calloc:
615 Changed |=
setAllocFamily(
F, TheLibFunc == LibFunc_vec_calloc ?
"vec_malloc"
631 case LibFunc_ctermid:
632 case LibFunc_clearerr:
633 case LibFunc_closedir:
675 case LibFunc_vec_free:
676 Changed |=
setAllocFamily(
F, TheLibFunc == LibFunc_vec_free ?
"vec_malloc"
688 case LibFunc_fgetc_unlocked:
694 case LibFunc_fsetpos:
695 case LibFunc_flockfile:
696 case LibFunc_funlockfile:
697 case LibFunc_ftrylockfile:
709 case LibFunc_fputc_unlocked:
722 case LibFunc_fstatvfs:
728 case LibFunc_fgets_unlocked:
734 case LibFunc_fread_unlocked:
741 case LibFunc_fwrite_unlocked:
749 case LibFunc_fputs_unlocked:
757 case LibFunc_fprintf:
764 case LibFunc_fgetpos:
775 case LibFunc_getlogin_r:
780 case LibFunc_getc_unlocked:
792 case LibFunc_getchar:
793 case LibFunc_getchar_unlocked:
797 case LibFunc_getitimer:
802 case LibFunc_getpwnam:
824 case LibFunc_unsetenv:
840 case LibFunc_putc_unlocked:
864 case LibFunc_putchar:
865 case LibFunc_putchar_unlocked:
889 case LibFunc_vsscanf:
897 case LibFunc_vfscanf:
904 case LibFunc_vprintf:
910 case LibFunc_vfprintf:
911 case LibFunc_vsprintf:
918 case LibFunc_vsnprintf:
931 case LibFunc_opendir:
938 case LibFunc_tmpfile:
974 case LibFunc_dunder_strndup:
977 case LibFunc_dunder_strdup:
984 case LibFunc_dunder_strtok_r:
989 case LibFunc_under_IO_getc:
994 case LibFunc_under_IO_putc:
999 case LibFunc_dunder_isoc99_scanf:
1005 case LibFunc_stat64:
1006 case LibFunc_lstat64:
1007 case LibFunc_statvfs64:
1014 case LibFunc_dunder_isoc99_sscanf:
1022 case LibFunc_fopen64:
1031 case LibFunc_fseeko64:
1032 case LibFunc_ftello64:
1037 case LibFunc_tmpfile64:
1042 case LibFunc_fstat64:
1043 case LibFunc_fstatvfs64:
1048 case LibFunc_open64:
1054 case LibFunc_gettimeofday:
1063 case LibFunc_memset_pattern4:
1064 case LibFunc_memset_pattern8:
1065 case LibFunc_memset_pattern16:
1070 case LibFunc_memset:
1073 case LibFunc_memset_chk:
1079 case LibFunc_nvvm_reflect:
1085 case LibFunc_ldexpf:
1086 case LibFunc_ldexpl:
1093 case LibFunc_acoshf:
1094 case LibFunc_acoshl:
1099 case LibFunc_asinhf:
1100 case LibFunc_asinhl:
1104 case LibFunc_atan2f:
1105 case LibFunc_atan2l:
1108 case LibFunc_atanhf:
1109 case LibFunc_atanhl:
1117 case LibFunc_copysign:
1118 case LibFunc_copysignf:
1119 case LibFunc_copysignl:
1127 case LibFunc_cospif:
1135 case LibFunc_expm1f:
1136 case LibFunc_expm1l:
1144 case LibFunc_floorf:
1145 case LibFunc_floorl:
1158 case LibFunc_isascii:
1159 case LibFunc_isdigit:
1164 case LibFunc_log10f:
1165 case LibFunc_log10l:
1167 case LibFunc_log1pf:
1168 case LibFunc_log1pl:
1177 case LibFunc_nearbyint:
1178 case LibFunc_nearbyintf:
1179 case LibFunc_nearbyintl:
1187 case LibFunc_roundf:
1188 case LibFunc_roundl:
1190 case LibFunc_sincospif_stret:
1197 case LibFunc_sinpif:
1207 case LibFunc_toascii:
1209 case LibFunc_truncf:
1210 case LibFunc_truncl:
1227 F.addParamAttr(ArgNo, ExtAttr);
1232 if (!
F->arg_size() ||
F->isVarArg())
1240 unsigned N =
M->getNumberRegisterParameters();
1247 Type *
T = A.getType();
1248 if (!
T->isIntOrPtrTy())
1255 assert(TS <= 4 &&
"Need to account for parameters larger than word size");
1256 const unsigned NumRegs = TS > 4 ? 2 : 1;
1261 F->addParamAttr(A.getArgNo(), Attribute::InReg);
1269 "Creating call to non-existing library function.");
1283 assert(
F->getFunctionType() ==
T &&
"Function type does not match.");
1284 switch (TheLibFunc) {
1286 case LibFunc_putchar:
1290 case LibFunc_ldexpf:
1291 case LibFunc_ldexpl:
1292 case LibFunc_memchr:
1293 case LibFunc_strchr:
1296 case LibFunc_memccpy:
1304 case LibFunc_calloc:
1305 case LibFunc_fwrite:
1306 case LibFunc_malloc:
1307 case LibFunc_memcmp:
1308 case LibFunc_memcpy_chk:
1309 case LibFunc_mempcpy:
1310 case LibFunc_memset_pattern16:
1311 case LibFunc_snprintf:
1312 case LibFunc_stpncpy:
1313 case LibFunc_strlcat:
1314 case LibFunc_strlcpy:
1315 case LibFunc_strncat:
1316 case LibFunc_strncmp:
1317 case LibFunc_strncpy:
1318 case LibFunc_vsnprintf:
1323 for (
unsigned i = 0;
i <
T->getNumParams();
i++)
1324 assert(!isa<IntegerType>(
T->getParamType(
i)) &&
1325 "Unhandled integer argument.");
1343 if (!TLI->
has(TheLibFunc))
1349 if (
auto *
F = dyn_cast<Function>(GV))
1382 "Cannot get name for unavailable function!");
1388 TheLibFunc = FloatFn;
1391 TheLibFunc = DoubleFn;
1392 return TLI->
getName(DoubleFn);
1394 TheLibFunc = LongDoubleFn;
1395 return TLI->
getName(LongDoubleFn);
1403 return B.CreateBitCast(V,
B.getInt8PtrTy(AS),
"cstr");
1410 bool IsVaArgs =
false) {
1411 Module *
M =
B.GetInsertBlock()->getModule();
1435 return emitLibCall(LibFunc_strdup,
B.getInt8PtrTy(),
B.getInt8PtrTy(),
1441 Type *I8Ptr =
B.getInt8PtrTy();
1442 Type *I32Ty =
B.getInt32Ty();
1443 return emitLibCall(LibFunc_strchr, I8Ptr, {I8Ptr, I32Ty},
1451 LibFunc_strncmp,
B.getInt32Ty(),
1452 {B.getInt8PtrTy(), B.getInt8PtrTy(), DL.getIntPtrType(Context)},
1453 {castToCStr(Ptr1, B), castToCStr(Ptr2, B), Len},
B, TLI);
1458 Type *I8Ptr = Dst->getType();
1459 return emitLibCall(LibFunc_strcpy, I8Ptr, {I8Ptr, I8Ptr},
1465 Type *I8Ptr =
B.getInt8PtrTy();
1466 return emitLibCall(LibFunc_stpcpy, I8Ptr, {I8Ptr, I8Ptr},
1472 Type *I8Ptr =
B.getInt8PtrTy();
1479 Type *I8Ptr =
B.getInt8PtrTy();
1487 Module *
M =
B.GetInsertBlock()->getModule();
1493 Attribute::NoUnwind);
1497 B.getInt8PtrTy(),
B.getInt8PtrTy(),
DL.getIntPtrType(
Context),
1501 CallInst *CI =
B.CreateCall(MemCpy, {Dst, Src, Len, ObjSize});
1512 LibFunc_mempcpy,
B.getInt8PtrTy(),
1513 {B.getInt8PtrTy(), B.getInt8PtrTy(), DL.getIntPtrType(Context)},
1514 {Dst, Src, Len},
B, TLI);
1521 LibFunc_memchr,
B.getInt8PtrTy(),
1522 {B.getInt8PtrTy(), B.getInt32Ty(), DL.getIntPtrType(Context)},
1523 {castToCStr(Ptr, B), Val, Len},
B, TLI);
1530 LibFunc_memcmp,
B.getInt32Ty(),
1531 {B.getInt8PtrTy(), B.getInt8PtrTy(), DL.getIntPtrType(Context)},
1532 {castToCStr(Ptr1, B), castToCStr(Ptr2, B), Len},
B, TLI);
1539 LibFunc_bcmp,
B.getInt32Ty(),
1540 {B.getInt8PtrTy(), B.getInt8PtrTy(), DL.getIntPtrType(Context)},
1541 {castToCStr(Ptr1, B), castToCStr(Ptr2, B), Len},
B, TLI);
1547 LibFunc_memccpy,
B.getInt8PtrTy(),
1548 {B.getInt8PtrTy(), B.getInt8PtrTy(), B.getInt32Ty(), Len->getType()},
1549 {Ptr1, Ptr2, Val, Len},
B, TLI);
1558 {B.getInt8PtrTy(), Size->getType(), B.getInt8PtrTy()},
1559 Args,
B, TLI,
true);
1568 {B.getInt8PtrTy(), B.getInt8PtrTy()},
Args,
B, TLI,
1575 {B.getInt8PtrTy(), B.getInt8PtrTy()},
1576 {castToCStr(Dest, B), castToCStr(Src, B)},
B, TLI);
1581 return emitLibCall(LibFunc_strlcpy, Size->getType(),
1582 {B.getInt8PtrTy(), B.getInt8PtrTy(), Size->getType()},
1583 {castToCStr(Dest, B), castToCStr(Src, B), Size},
B, TLI);
1588 return emitLibCall(LibFunc_strlcat, Size->getType(),
1589 {B.getInt8PtrTy(), B.getInt8PtrTy(), Size->getType()},
1590 {castToCStr(Dest, B), castToCStr(Src, B), Size},
B, TLI);
1596 {B.getInt8PtrTy(), B.getInt8PtrTy(), Size->getType()},
1597 {castToCStr(Dest, B), castToCStr(Src, B), Size},
B, TLI);
1603 LibFunc_vsnprintf,
B.getInt32Ty(),
1604 {B.getInt8PtrTy(), Size->getType(), B.getInt8PtrTy(), VAList->getType()},
1605 {castToCStr(Dest, B), Size, castToCStr(Fmt, B), VAList},
B, TLI);
1611 {B.getInt8PtrTy(), B.getInt8PtrTy(), VAList->getType()},
1612 {castToCStr(Dest, B), castToCStr(Fmt, B), VAList},
B, TLI);
1618 if (!
Op->getType()->isDoubleTy()) {
1621 if (
Op->getType()->isFloatTy())
1634 assert((
Name !=
"") &&
"Must specify Name to emitUnaryFloatFnCall");
1636 Module *
M =
B.GetInsertBlock()->getModule();
1645 Attrs.removeFnAttribute(
B.getContext(), Attribute::Speculatable));
1670 Module *
M =
B.GetInsertBlock()->getModule();
1673 LongDoubleFn, TheLibFunc);
1683 assert((
Name !=
"") &&
"Must specify Name to emitBinaryFloatFnCall");
1685 Module *
M =
B.GetInsertBlock()->getModule();
1695 Attrs.removeFnAttribute(
B.getContext(), Attribute::Speculatable));
1707 assert((
Name !=
"") &&
"Must specify Name to emitBinaryFloatFnCall");
1724 Module *
M =
B.GetInsertBlock()->getModule();
1727 LongDoubleFn, TheLibFunc);
1734 Module *
M =
B.GetInsertBlock()->getModule();
1740 B.getInt32Ty(),
B.getInt32Ty());
1743 B.CreateIntCast(Char,
1757 Module *
M =
B.GetInsertBlock()->getModule();
1774 Module *
M =
B.GetInsertBlock()->getModule();
1780 B.getInt32Ty(), File->getType());
1781 if (File->getType()->isPointerTy())
1783 Char =
B.CreateIntCast(Char,
B.getInt32Ty(),
true,
1785 CallInst *CI =
B.CreateCall(
F, {Char, File}, FPutcName);
1788 dyn_cast<Function>(
F.getCallee()->stripPointerCasts()))
1795 Module *
M =
B.GetInsertBlock()->getModule();
1801 B.getInt8PtrTy(), File->getType());
1802 if (File->getType()->isPointerTy())
1807 dyn_cast<Function>(
F.getCallee()->stripPointerCasts()))
1814 Module *
M =
B.GetInsertBlock()->getModule();
1822 DL.getIntPtrType(
Context), File->getType());
1824 if (File->getType()->isPointerTy())
1831 dyn_cast<Function>(
F.getCallee()->stripPointerCasts()))
1838 Module *
M =
B.GetInsertBlock()->getModule();
1845 B.getInt8PtrTy(),
DL.getIntPtrType(
Context));
1850 dyn_cast<Function>(
Malloc.getCallee()->stripPointerCasts()))
1858 Module *
M =
B.GetInsertBlock()->getModule();
1864 IntegerType *PtrType =
DL.getIntPtrType((
B.GetInsertBlock()->getContext()));
1866 B.getInt8PtrTy(), PtrType, PtrType);
1868 CallInst *CI =
B.CreateCall(Calloc, {Num, Size}, CallocName);
static bool setAllocSize(Function &F, unsigned ElemSizeArg, Optional< unsigned > NumElemsArg)
static Value * emitUnaryFloatFnCallHelper(Value *Op, LibFunc TheLibFunc, StringRef Name, IRBuilderBase &B, const AttributeList &Attrs, const TargetLibraryInfo *TLI)
This class represents an incoming formal argument to a Function.
@ FloatTyID
32-bit floating point type
@ DoubleTyID
64-bit floating point type
This is an optimization pass for GlobalISel generic memory operations.
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
A parsed version of the target data layout string in and methods for querying it.
static Attribute getWithAllocSizeArgs(LLVMContext &Context, unsigned ElemSizeArg, const Optional< unsigned > &NumElemsArg)
Value * emitCalloc(Value *Num, Value *Size, IRBuilderBase &B, const TargetLibraryInfo &TLI)
Emit a call to the calloc function.
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.
Value * emitMemCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilderBase &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
Emit a call to the memcmp function.
Value * emitFWrite(Value *Ptr, Value *Size, Value *File, IRBuilderBase &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
Emit a call to the fwrite function.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
static bool setOnlyAccessesArgMemory(Function &F)
static void appendTypeSuffix(Value *Op, StringRef &Name, SmallString< 20 > &NameBuffer)
Append a suffix to the function name according to the type of 'Op'.
Value * emitMemCCpy(Value *Ptr1, Value *Ptr2, Value *Val, Value *Len, IRBuilderBase &B, const TargetLibraryInfo *TLI)
Emit a call to the memccpy function.
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
static AttributeList get(LLVMContext &C, ArrayRef< std::pair< unsigned, Attribute >> Attrs)
Create an AttributeList with the specified parameters in it.
TypeID getTypeID() const
Return the type id for the type.
static bool setDoesNotCapture(Function &F, unsigned ArgNo)
The instances of the Type class are immutable: once they are created, they are never changed.
static bool setOnlyReadsMemory(Function &F)
static bool setArgNoUndef(Function &F, unsigned ArgNo)
Attribute::AttrKind getExtAttrForI32Param(bool Signed=true) const
Returns extension attribute kind to be used for i32 parameters corresponding to C-level int or unsign...
static void setArgExtAttr(Function &F, unsigned ArgNo, const TargetLibraryInfo &TLI, bool Signed=true)
static bool setDoesNotAccessMemory(Function &F)
static Value * emitLibCall(LibFunc TheLibFunc, Type *ReturnType, ArrayRef< Type * > ParamTypes, ArrayRef< Value * > Operands, IRBuilderBase &B, const TargetLibraryInfo *TLI, bool IsVaArgs=false)
static bool setWillReturn(Function &F)
Value * emitStrDup(Value *Ptr, IRBuilderBase &B, const TargetLibraryInfo *TLI)
Emit a call to the strdup function to the builder, for the specified pointer.
Value * emitFPutC(Value *Char, Value *File, IRBuilderBase &B, const TargetLibraryInfo *TLI)
Emit a call to the fputc function.
static bool setRetNoUndef(Function &F)
(vector float) vec_cmpeq(*A, *B) C
void setAttributes(AttributeList A)
Set the parameter attributes for this call.
Value * emitStrCat(Value *Dest, Value *Src, IRBuilderBase &B, const TargetLibraryInfo *TLI)
Emit a call to the strcat function.
Value * emitStrLCpy(Value *Dest, Value *Src, Value *Size, IRBuilderBase &B, const TargetLibraryInfo *TLI)
Emit a call to the strlcpy function.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Class to represent integer types.
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
static Value * emitBinaryFloatFnCallHelper(Value *Op1, Value *Op2, LibFunc TheLibFunc, StringRef Name, IRBuilderBase &B, const AttributeList &Attrs, const TargetLibraryInfo *TLI)
STATISTIC(NumFunctions, "Total number of functions")
Value * emitPutChar(Value *Char, IRBuilderBase &B, const TargetLibraryInfo *TLI)
Emit a call to the putchar function. This assumes that Char is an integer.
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
StringRef getName(LibFunc F) const
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.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
static void markRegisterParameterAttributes(Function *F)
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
mir Rename Register Operands
static bool setDoesNotAlias(Function &F, unsigned ArgNo)
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.
Value * emitSPrintf(Value *Dest, Value *Fmt, ArrayRef< Value * > VariadicArgs, IRBuilderBase &B, const TargetLibraryInfo *TLI)
Emit a call to the sprintf function.
@ None
No attributes have been set.
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.
static bool setReturnedArg(Function &F, unsigned ArgNo)
static bool setAllocFamily(Function &F, StringRef Family)
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.
This is an important class for using LLVM in a threaded context.
Value * emitStrLCat(Value *Dest, Value *Src, Value *Size, IRBuilderBase &B, const TargetLibraryInfo *TLI)
Emit a call to the strlcat function.
static bool setOnlyAccessesInaccessibleMemory(Function &F)
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
FunctionCallee getOrInsertLibFunc(Module *M, const TargetLibraryInfo &TLI, LibFunc TheLibFunc, FunctionType *T, AttributeList AttributeList)
Calls getOrInsertFunction() and then makes sure to add mandatory argument attributes.
Value * emitBCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilderBase &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
Emit a call to the bcmp function.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool setArgsNoUndef(Function &F)
Value * emitMemPCpy(Value *Dst, Value *Src, Value *Len, IRBuilderBase &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
Emit a call to the mempcpy function.
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.
bool has(LibFunc F) const
Tests whether a library function is available.
Value * emitStrNCat(Value *Dest, Value *Src, Value *Size, IRBuilderBase &B, const TargetLibraryInfo *TLI)
Emit a call to the strncat function.
static bool setDoesNotFreeMemory(Function &F)
static bool setRetAndArgsNoUndef(Function &F)
A Module instance is used to store all the information related to an LLVM module.
@ C
C - The default llvm calling convention, compatible with C.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
static bool setOnlyAccessesInaccessibleMemOrArgMem(Function &F)
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Type * getType() const
All values are typed, get the type of this value.
void append_range(Container &C, Range &&R)
Wrapper function to append a range to a container.
Common base class shared among various IRBuilders.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
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.
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.
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.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
static bool setRetDoesNotAlias(Function &F)
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
amdgpu Simplify well known AMD library false FunctionCallee Callee
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...
@ X86_StdCall
X86_StdCall - stdcall is the calling conventions mostly used by the Win32 API.
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...
Value * emitFPutS(Value *Str, Value *File, IRBuilderBase &B, const TargetLibraryInfo *TLI)
Emit a call to the fputs function.
static bool setAllocatedPointerParam(Function &F, unsigned ArgNo)
Value * emitMalloc(Value *Num, IRBuilderBase &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
Emit a call to the malloc function.
Value * castToCStr(Value *V, IRBuilderBase &B)
Return V if it is an i8*, otherwise cast it to i8*.
static bool setDoesNotThrow(Function &F)
bool isReallocLikeFn(const Value *V, const TargetLibraryInfo *TLI)
Tests if a value is a call or invoke to a library function that reallocates memory (e....
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.
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.
A handy container for a FunctionType+Callee-pointer pair, which can be passed around as a single enti...
Value * emitSNPrintf(Value *Dest, Value *Size, Value *Fmt, ArrayRef< Value * > Args, IRBuilderBase &B, const TargetLibraryInfo *TLI)
Emit a call to the snprintf function.
Value * emitPutS(Value *Str, IRBuilderBase &B, const TargetLibraryInfo *TLI)
Emit a call to the puts function. This assumes that Str is some pointer.
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.
This class represents a function call, abstracting a target machine's calling convention.
bool inferNonMandatoryLibFuncAttrs(Module *M, StringRef Name, const TargetLibraryInfo &TLI)
Analyze the name and prototype of the given function and set any applicable attributes.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
bool isLibFreeFunction(const Function *F, const LibFunc TLIFn)
isLibFreeFunction - Returns true if the function is a builtin free()
static bool setNonLazyBind(Function &F)
static bool setOnlyWritesMemory(Function &F)
static bool setAlignedAllocParam(Function &F, unsigned ArgNo)
Value * emitVSPrintf(Value *Dest, Value *Fmt, Value *VAList, IRBuilderBase &B, const TargetLibraryInfo *TLI)
Emit a call to the vsprintf function.
LLVM Value Representation.
Value * emitVSNPrintf(Value *Dest, Value *Size, Value *Fmt, Value *VAList, IRBuilderBase &B, const TargetLibraryInfo *TLI)
Emit a call to the vsnprintf function.
@ HalfTyID
16-bit floating point type
Value * emitMemChr(Value *Ptr, Value *Val, Value *Len, IRBuilderBase &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
Emit a call to the memchr function.
void setCallingConv(CallingConv::ID CC)
Class to represent function types.