37 using namespace PatternMatch;
41 cl::desc(
"Treat error-reporting calls as cold"));
46 cl::desc(
"Enable unsafe double to float "
47 "shrinking for math lib calls"));
71 if (
ICmpInst *IC = dyn_cast<ICmpInst>(U))
73 if (
Constant *C = dyn_cast<Constant>(IC->getOperand(1)))
86 if (
ICmpInst *IC = dyn_cast<ICmpInst>(U))
87 if (IC->isEquality() && IC->getOperand(1) == With)
98 if ((*it)->getType()->isFloatingPointTy())
111 return TLI->
has(FloatFn);
113 return TLI->
has(DoubleFn);
115 return TLI->
has(LongDoubleFn);
138 case LibFunc::stpncpy_chk:
139 case LibFunc::strncpy_chk:
141 case LibFunc::stpncpy:
142 case LibFunc::strncpy: {
148 case LibFunc::strcpy_chk:
149 case LibFunc::stpcpy_chk:
151 case LibFunc::stpcpy:
152 case LibFunc::strcpy: {
158 case LibFunc::memmove_chk:
159 case LibFunc::memcpy_chk:
161 case LibFunc::memmove:
162 case LibFunc::memcpy: {
168 case LibFunc::memset_chk:
170 case LibFunc::memset: {
211 return emitStrLenMemCpy(Src, Dst, Len, B);
214 Value *LibCallSimplifier::emitStrLenMemCpy(
Value *Src,
Value *Dst, uint64_t Len,
252 Len = LengthArg->getZExtValue();
265 if (SrcLen == 0 || Len == 0)
274 return emitStrLenMemCpy(Src, Dst, SrcLen, B);
375 if (HasStr1 && HasStr2)
378 if (HasStr1 && Str1.empty())
382 if (HasStr2 && Str2.empty())
415 Length = LengthArg->getZExtValue();
430 if (HasStr1 && HasStr2) {
436 if (HasStr1 && Str1.empty())
440 if (HasStr2 && Str2.empty())
522 if (
ConstantInt *LengthArg = dyn_cast<ConstantInt>(LenOp))
523 Len = LengthArg->getZExtValue();
531 if (Len > SrcLen + 1)
555 if (
SelectInst *SI = dyn_cast<SelectInst>(Src)) {
558 if (LenTrue && LenFalse) {
562 "folded strlen(select) to select of constants");
591 if ((HasS1 && S1.
empty()) || (HasS2 && S2.
empty()))
595 if (HasS1 && HasS2) {
604 if (HasS2 && S2.
size() == 1)
619 if (isa<ConstantPointerNull>(EndPtr)) {
642 if ((HasS1 && S1.
empty()) || (HasS2 && S2.
empty()))
646 if (HasS1 && HasS2) {
669 if (HasS1 && S1.
empty())
673 if (HasS1 && HasS2) {
681 if (HasS2 && S2.
empty())
709 ICmpInst *Old = cast<ICmpInst>(*UI++);
713 replaceAllUsesWith(Old, Cmp);
724 if (HasStr2 && ToFindStr.
empty())
728 if (HasStr1 && HasStr2) {
729 size_t Offset = SearchStr.
find(ToFindStr);
736 Result = B.CreateConstInBoundsGEP1_64(Result, Offset,
"strstr");
737 return B.CreateBitCast(Result, CI->
getType());
741 if (HasStr2 && ToFindStr.
size() == 1) {
743 return StrChr ? B.CreateBitCast(StrChr, CI->
getType()) :
nullptr;
762 if (LenC && LenC->isNullValue())
773 Str = Str.
substr(0, LenC->getZExtValue());
786 *std::max_element(reinterpret_cast<const unsigned char *>(Str.
begin()),
787 reinterpret_cast<const unsigned char *>(Str.
end()));
794 if (!DL.fitsInLegalInteger(Max + 1))
799 unsigned char Width =
NextPowerOf2(std::max((
unsigned char)7, Max));
862 return B.
CreateSub(LHSV, RHSV,
"chardiff");
870 if (Len > LHSStr.
size() || Len > RHSStr.
size())
875 int Cmp = memcmp(LHSStr.
data(), RHSStr.
data(), Len);
932 if (
FPExtInst *Cast = dyn_cast<FPExtInst>(Val)) {
933 Value *Op = Cast->getOperand(0);
937 if (
ConstantFP *Const = dyn_cast<ConstantFP>(Val)) {
1017 Value *Ret =
nullptr;
1018 if (UnsafeFPShrink && Callee->
getName() ==
"cos" && TLI->has(LibFunc::cosf)) {
1019 Ret = optimizeUnaryDoubleFP(CI, B,
true);
1041 Value *Ret =
nullptr;
1042 if (UnsafeFPShrink && Callee->
getName() ==
"pow" && TLI->has(LibFunc::powf)) {
1043 Ret = optimizeUnaryDoubleFP(CI, B,
true);
1055 if (
ConstantFP *Op1C = dyn_cast<ConstantFP>(Op1)) {
1057 if (Op1C->isExactlyValue(1.0))
1060 if (Op1C->isExactlyValue(2.0) &&
1065 if (Op1C->isExactlyValue(10.0) &&
1112 Value *Ret =
nullptr;
1113 if (UnsafeFPShrink && Callee->
getName() ==
"exp2" &&
1114 TLI->has(LibFunc::exp2f)) {
1115 Ret = optimizeUnaryDoubleFP(CI, B,
true);
1130 LdExp = LibFunc::ldexpf;
1132 LdExp = LibFunc::ldexp;
1134 if (TLI->has(LdExp)) {
1135 Value *LdExpArg =
nullptr;
1136 if (
SIToFPInst *OpC = dyn_cast<SIToFPInst>(Op)) {
1137 if (OpC->getOperand(0)->getType()->getPrimitiveSizeInBits() <= 32)
1139 }
else if (
UIToFPInst *OpC = dyn_cast<UIToFPInst>(Op)) {
1140 if (OpC->getOperand(0)->getType()->getPrimitiveSizeInBits() < 32)
1166 Value *Ret =
nullptr;
1167 if (Callee->
getName() ==
"fabs" && TLI->has(LibFunc::fabsf)) {
1168 Ret = optimizeUnaryDoubleFP(CI, B,
false);
1180 if (I->getOpcode() == Instruction::FMul)
1181 if (I->getOperand(0) == I->getOperand(1))
1190 Value *Ret =
nullptr;
1191 if (TLI->has(LibFunc::sqrtf) && (Callee->
getName() ==
"sqrt" ||
1193 Ret = optimizeUnaryDoubleFP(CI, B,
true);
1209 if (I->getOpcode() == Instruction::FMul && I->hasUnsafeAlgebra()) {
1213 Value *Op0 = I->getOperand(0);
1214 Value *Op1 = I->getOperand(1);
1215 Value *RepeatOp =
nullptr;
1216 Value *OtherOp =
nullptr;
1226 Value *OtherMul0, *OtherMul1;
1229 if (OtherMul0 == OtherMul1) {
1231 RepeatOp = OtherMul0;
1288 classifyArgUse(U, CI->
getParent(), IsFloat, SinCalls, CosCalls,
1292 if (SinCosCalls.
empty() && (SinCalls.empty() || CosCalls.empty()))
1295 Value *Sin, *Cos, *SinCos;
1298 replaceTrigInsts(SinCalls, Sin);
1299 replaceTrigInsts(CosCalls, Cos);
1300 replaceTrigInsts(SinCosCalls, SinCos);
1311 bool AttributesSafe =
1322 LibCallSimplifier::classifyArgUse(
Value *Val,
BasicBlock *BB,
bool IsFloat,
1334 if (!TLI->getLibFunc(FuncName, Func) || !TLI->has(Func) || !
isTrigLibCall(CI))
1338 if (Func == LibFunc::sinpif)
1340 else if (Func == LibFunc::cospif)
1342 else if (Func == LibFunc::sincospif_stret)
1345 if (Func == LibFunc::sinpi)
1347 else if (Func == LibFunc::cospi)
1349 else if (Func == LibFunc::sincospi_stret)
1358 replaceAllUsesWith(*I, Res);
1370 Name =
"__sincospif_stret";
1372 assert(
T.getArch() !=
Triple::x86 &&
"x86 messy and unsupported for now");
1379 Name =
"__sincospi_stret";
1385 ResTy, ArgTy,
nullptr);
1387 if (
Instruction *ArgInst = dyn_cast<Instruction>(Arg)) {
1399 SinCos = B.
CreateCall(Callee, Arg,
"sincospi");
1428 if (
ConstantInt *CI = dyn_cast<ConstantInt>(Op)) {
1432 return B.
getInt32(CI->getValue().countTrailingZeros() + 1);
1552 return GV->
getName() ==
"stderr";
1562 if (FormatStr.
empty())
1572 if (FormatStr.
size() == 1) {
1580 if (FormatStr[FormatStr.
size() - 1] ==
'\n' &&
1620 if (
Value *V = optimizePrintFString(CI, B)) {
1648 for (
unsigned i = 0, e = FormatStr.
size(); i != e; ++i)
1649 if (FormatStr[i] ==
'%')
1655 FormatStr.
size() + 1),
1662 if (FormatStr.
size() != 2 || FormatStr[0] !=
'%' ||
1667 if (FormatStr[1] ==
'c') {
1680 if (FormatStr[1] ==
's') {
1707 if (
Value *V = optimizeSPrintFString(CI, B)) {
1726 optimizeErrorReporting(CI, B, 0);
1741 for (
unsigned i = 0, e = FormatStr.
size(); i != e; ++i)
1742 if (FormatStr[i] ==
'%')
1753 if (FormatStr.
size() != 2 || FormatStr[0] !=
'%' ||
1758 if (FormatStr[1] ==
'c') {
1765 if (FormatStr[1] ==
's') {
1783 if (
Value *V = optimizeFPrintFString(CI, B)) {
1802 optimizeErrorReporting(CI, B, 3);
1817 if (!SizeC || !CountC)
1819 uint64_t Bytes = SizeC->
getZExtValue() * CountC->getZExtValue();
1837 optimizeErrorReporting(CI, B, 1);
1883 bool LibCallSimplifier::hasFloatVersion(
StringRef FuncName) {
1886 FloatFuncName +=
'f';
1887 if (TLI->getLibFunc(FloatFuncName, Func))
1888 return TLI->has(Func);
1892 Value *LibCallSimplifier::optimizeStringMemoryLibCall(
CallInst *CI,
1899 if (TLI->getLibFunc(FuncName, Func) && TLI->has(Func)) {
1903 "Optimizing string/memory libcall would change the calling convention");
1905 case LibFunc::strcat:
1906 return optimizeStrCat(CI, Builder);
1907 case LibFunc::strncat:
1908 return optimizeStrNCat(CI, Builder);
1909 case LibFunc::strchr:
1910 return optimizeStrChr(CI, Builder);
1911 case LibFunc::strrchr:
1912 return optimizeStrRChr(CI, Builder);
1913 case LibFunc::strcmp:
1914 return optimizeStrCmp(CI, Builder);
1915 case LibFunc::strncmp:
1916 return optimizeStrNCmp(CI, Builder);
1917 case LibFunc::strcpy:
1918 return optimizeStrCpy(CI, Builder);
1919 case LibFunc::stpcpy:
1920 return optimizeStpCpy(CI, Builder);
1921 case LibFunc::strncpy:
1922 return optimizeStrNCpy(CI, Builder);
1923 case LibFunc::strlen:
1924 return optimizeStrLen(CI, Builder);
1925 case LibFunc::strpbrk:
1926 return optimizeStrPBrk(CI, Builder);
1927 case LibFunc::strtol:
1928 case LibFunc::strtod:
1929 case LibFunc::strtof:
1930 case LibFunc::strtoul:
1931 case LibFunc::strtoll:
1932 case LibFunc::strtold:
1933 case LibFunc::strtoull:
1934 return optimizeStrTo(CI, Builder);
1935 case LibFunc::strspn:
1936 return optimizeStrSpn(CI, Builder);
1937 case LibFunc::strcspn:
1938 return optimizeStrCSpn(CI, Builder);
1939 case LibFunc::strstr:
1940 return optimizeStrStr(CI, Builder);
1941 case LibFunc::memchr:
1942 return optimizeMemChr(CI, Builder);
1943 case LibFunc::memcmp:
1944 return optimizeMemCmp(CI, Builder);
1945 case LibFunc::memcpy:
1946 return optimizeMemCpy(CI, Builder);
1947 case LibFunc::memmove:
1948 return optimizeMemMove(CI, Builder);
1949 case LibFunc::memset:
1950 return optimizeMemSet(CI, Builder);
1979 UnsafeFPShrink =
true;
1984 if (!isCallingConvC)
1986 switch (II->getIntrinsicID()) {
1987 case Intrinsic::pow:
1988 return optimizePow(CI, Builder);
1989 case Intrinsic::exp2:
1990 return optimizeExp2(CI, Builder);
1991 case Intrinsic::fabs:
1992 return optimizeFabs(CI, Builder);
1993 case Intrinsic::sqrt:
1994 return optimizeSqrt(CI, Builder);
2001 if (
Value *SimplifiedFortifiedCI = FortifiedSimplifier.optimizeCall(CI)) {
2005 if (
Value *V = optimizeStringMemoryLibCall(SimplifiedCI, Builder)) {
2011 return SimplifiedFortifiedCI;
2015 if (TLI->getLibFunc(FuncName, Func) && TLI->has(Func)) {
2019 if (
Value *V = optimizeStringMemoryLibCall(CI, Builder))
2025 return optimizeCos(CI, Builder);
2026 case LibFunc::sinpif:
2027 case LibFunc::sinpi:
2028 case LibFunc::cospif:
2029 case LibFunc::cospi:
2030 return optimizeSinCosPi(CI, Builder);
2034 return optimizePow(CI, Builder);
2035 case LibFunc::exp2l:
2037 case LibFunc::exp2f:
2038 return optimizeExp2(CI, Builder);
2039 case LibFunc::fabsf:
2041 case LibFunc::fabsl:
2042 return optimizeFabs(CI, Builder);
2043 case LibFunc::sqrtf:
2045 case LibFunc::sqrtl:
2046 return optimizeSqrt(CI, Builder);
2049 case LibFunc::ffsll:
2050 return optimizeFFS(CI, Builder);
2053 case LibFunc::llabs:
2054 return optimizeAbs(CI, Builder);
2055 case LibFunc::isdigit:
2056 return optimizeIsDigit(CI, Builder);
2057 case LibFunc::isascii:
2058 return optimizeIsAscii(CI, Builder);
2059 case LibFunc::toascii:
2060 return optimizeToAscii(CI, Builder);
2061 case LibFunc::printf:
2062 return optimizePrintF(CI, Builder);
2063 case LibFunc::sprintf:
2064 return optimizeSPrintF(CI, Builder);
2065 case LibFunc::fprintf:
2066 return optimizeFPrintF(CI, Builder);
2067 case LibFunc::fwrite:
2068 return optimizeFWrite(CI, Builder);
2069 case LibFunc::fputs:
2070 return optimizeFPuts(CI, Builder);
2072 return optimizePuts(CI, Builder);
2073 case LibFunc::perror:
2074 return optimizeErrorReporting(CI, Builder);
2075 case LibFunc::vfprintf:
2076 case LibFunc::fiprintf:
2077 return optimizeErrorReporting(CI, Builder, 0);
2078 case LibFunc::fputc:
2079 return optimizeErrorReporting(CI, Builder, 1);
2081 case LibFunc::floor:
2083 case LibFunc::round:
2084 case LibFunc::nearbyint:
2085 case LibFunc::trunc:
2086 if (hasFloatVersion(FuncName))
2087 return optimizeUnaryDoubleFP(CI, Builder,
false);
2090 case LibFunc::acosh:
2092 case LibFunc::asinh:
2094 case LibFunc::atanh:
2098 case LibFunc::exp10:
2099 case LibFunc::expm1:
2101 case LibFunc::log10:
2102 case LibFunc::log1p:
2109 if (UnsafeFPShrink && hasFloatVersion(FuncName))
2110 return optimizeUnaryDoubleFP(CI, Builder,
true);
2112 case LibFunc::copysign:
2115 if (hasFloatVersion(FuncName))
2116 return optimizeBinaryDoubleFP(CI, Builder);
2128 : FortifiedSimplifier(TLI), DL(DL), TLI(TLI), UnsafeFPShrink(
false),
2129 Replacer(Replacer) {}
2136 void LibCallSimplifier::replaceAllUsesWithDefault(
Instruction *I,
2194 bool FortifiedLibCallSimplifier::isFortifiedCallFoldable(
CallInst *CI,
2202 if (ObjSizeCI->isAllOnesValue())
2205 if (OnlyLowerUnknownSize)
2213 return ObjSizeCI->getZExtValue() >= Len;
2216 return ObjSizeCI->getZExtValue() >= SizeCI->getZExtValue();
2227 if (isFortifiedCallFoldable(CI, 3, 2,
false)) {
2241 if (isFortifiedCallFoldable(CI, 3, 2,
false)) {
2255 if (isFortifiedCallFoldable(CI, 3, 2,
false)) {
2263 Value *FortifiedLibCallSimplifier::optimizeStrpCpyChk(
CallInst *CI,
2277 if (Func == LibFunc::stpcpy_chk && !OnlyLowerUnknownSize && Dst == Src) {
2287 if (isFortifiedCallFoldable(CI, 2, 1,
true))
2290 if (OnlyLowerUnknownSize)
2303 if (Ret && Func == LibFunc::stpcpy_chk)
2308 Value *FortifiedLibCallSimplifier::optimizeStrpNCpyChk(
CallInst *CI,
2316 if (isFortifiedCallFoldable(CI, 3, 2,
false)) {
2353 case LibFunc::memcpy_chk:
2354 return optimizeMemCpyChk(CI, Builder);
2355 case LibFunc::memmove_chk:
2356 return optimizeMemMoveChk(CI, Builder);
2357 case LibFunc::memset_chk:
2358 return optimizeMemSetChk(CI, Builder);
2359 case LibFunc::stpcpy_chk:
2360 case LibFunc::strcpy_chk:
2361 return optimizeStrpCpyChk(CI, Builder, Func);
2362 case LibFunc::stpncpy_chk:
2363 case LibFunc::strncpy_chk:
2364 return optimizeStrpNCpyChk(CI, Builder, Func);
2373 : TLI(TLI), OnlyLowerUnknownSize(OnlyLowerUnknownSize) {}
Value * CreateGEP(Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="")
Value * EmitPutChar(Value *Char, IRBuilder<> &B, const TargetLibraryInfo *TLI)
EmitPutChar - Emit a call to the putchar function.
iplist< Instruction >::iterator eraseFromParent()
eraseFromParent - This method unlinks 'this' from the containing basic block and deletes it...
void push_back(const T &Elt)
Value * EmitStrLen(Value *Ptr, IRBuilder<> &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
EmitStrLen - Emit a call to the strlen function to the builder, for the specified pointer...
A parsed version of the target data layout string in and methods for querying it. ...
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
uint64_t GetStringLength(Value *V)
GetStringLength - If we can compute the length of the string pointed to by the specified pointer...
LoadInst * CreateLoad(Value *Ptr, const char *Name)
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
Value * CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="")
size_t size() const
size - Get the string size.
Value * CreateIntCast(Value *V, Type *DestTy, bool isSigned, const Twine &Name="")
static bool callHasFloatingPointArgument(const CallInst *CI)
Value * optimizeCall(CallInst *CI)
Take the given call instruction and return a more optimal value to replace the instruction with or 0 ...
A Module instance is used to store all the information related to an LLVM module. ...
unsigned getNumParams() const
getNumParams - Return the number of fixed parameters this function type requires. ...
static Constant * getInfinity(Type *Ty, bool Negative=false)
2: 32-bit floating point type
size_t find(char C, size_t From=0) const
Search for the first character C in the string.
CallInst - This class represents a function call, abstracting a target machine's calling convention...
An efficient, type-erasing, non-owning reference to a callable.
size_t rfind(char C, size_t From=npos) const
Search for the last character C in the string.
StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
bool isDoubleTy() const
isDoubleTy - Return true if this is 'double', a 64-bit IEEE fp type.
Value * CreateICmpULT(Value *LHS, Value *RHS, const Twine &Name="")
Value * EmitFWrite(Value *Ptr, Value *Size, Value *File, IRBuilder<> &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
EmitFWrite - Emit a call to the fwrite function.
static bool hasUnaryFloatFn(const TargetLibraryInfo *TLI, Type *Ty, LibFunc::Func DoubleFn, LibFunc::Func FloatFn, LibFunc::Func LongDoubleFn)
Check whether the overloaded unary floating point function corresponing to Ty is available.
const Function * getParent() const
Return the enclosing method, or null if none.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
static cl::opt< bool > ColdErrorCalls("error-reporting-is-cold", cl::init(true), cl::Hidden, cl::desc("Treat error-reporting calls as cold"))
CallInst * CreateMemSet(Value *Ptr, Value *Val, uint64_t Size, unsigned Align, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memset to the specified pointer and the specified value.
LoadInst - an instruction for reading from memory.
static bool isTrigLibCall(CallInst *CI)
StringRef drop_back(size_t N=1) const
Return a StringRef equal to 'this' but with the last N elements dropped.
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
void emitOptimizationRemark(LLVMContext &Ctx, const char *PassName, const Function &Fn, const DebugLoc &DLoc, const Twine &Msg)
Emit an optimization-applied message.
static bool isReportingError(Function *Callee, CallInst *CI, int StreamArg)
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
InstTy * Insert(InstTy *I, const Twine &Name="") const
Insert and return the specified instruction.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
static cl::opt< bool > EnableUnsafeFPShrink("enable-double-float-shrink", cl::Hidden, cl::init(false), cl::desc("Enable unsafe double to float ""shrinking for math lib calls"))
static Constant * getNullValue(Type *Ty)
StringRef getName() const
Return a constant reference to the value's name.
iterator begin()
Instruction iterator methods.
void setCallingConv(CallingConv::ID CC)
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
int compare(StringRef RHS) const
compare - Compare two strings; the result is -1, 0, or 1 if this string is lexicographically less tha...
bool match(Val *V, const Pattern &P)
Value * CreateExtractValue(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &Name="")
SelectInst - This class represents the LLVM 'select' instruction.
static bool ignoreCallingConv(LibFunc::Func Func)
bool has(LibFunc::Func F) const
Tests whether a library function is available.
Value * EmitUnaryFloatFnCall(Value *Op, StringRef Name, IRBuilder<> &B, const AttributeSet &Attrs)
EmitUnaryFloatFnCall - Emit a call to the unary function named 'Name' (e.g.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
FortifiedLibCallSimplifier(const TargetLibraryInfo *TLI, bool OnlyLowerUnknownSize=false)
Value * CreateIntToPtr(Value *V, Type *DestTy, const Twine &Name="")
Value * EmitPutS(Value *Str, IRBuilder<> &B, const TargetLibraryInfo *TLI)
EmitPutS - Emit a call to the puts function.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
unsigned getNumArgOperands() const
getNumArgOperands - Return the number of call arguments.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Number of individual test Apply this number of consecutive mutations to each input exit after the first new interesting input is found the minimized corpus is saved into the first input directory Number of jobs to run If min(jobs, NumberOfCpuCores()/2)\" is used.") FUZZER_FLAG_INT(reload
Instruction * clone() const
clone() - Create a copy of 'this' instruction that is identical in all ways except the following: ...
Value * CreateICmpSGT(Value *LHS, Value *RHS, const Twine &Name="")
Function does not access memory.
Function creates no aliases of pointer.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
FunctionType - Class to represent function types.
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
void SetFastMathFlags(FastMathFlags NewFMF)
Set the fast-math flags to be used with generated fp-math operators.
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
bool hasFnAttr(Attribute::AttrKind A) const
Determine whether this call has the given attribute.
const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
static cl::opt< std::string > FuncName("cppfname", cl::desc("Specify the name of the generated function"), cl::value_desc("function name"))
static void insertSinCosCall(IRBuilder<> &B, Function *OrigCallee, Value *Arg, bool UseFloat, Value *&Sin, Value *&Cos, Value *&SinCos)
CallInst * CreateMemMove(Value *Dst, Value *Src, uint64_t Size, unsigned Align, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memmove between the specified pointers.
ConstantFolder - Create constants with minimum, target independent, folding.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
TypeID getTypeID() const
getTypeID - Return the type id for the type.
bool isFloatingPointTy() const
isFloatingPointTy - Return true if this is one of the six floating point types
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
static Value * valueHasFloatPrecision(Value *Val)
Return a variant of Val with float type.
StoreInst * CreateStore(Value *Val, Value *Ptr, bool isVolatile=false)
Value * EmitFPutS(Value *Str, Value *File, IRBuilder<> &B, const TargetLibraryInfo *TLI)
EmitFPutS - Emit a call to the puts function.
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block...
Value * EmitMemCpyChk(Value *Dst, Value *Src, Value *Len, Value *ObjSize, IRBuilder<> &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
EmitMemCpyChk - Emit a call to the __memcpy_chk function to the builder.
ConstantInt * getIntN(unsigned N, uint64_t C)
Get a constant N-bit value, zero extended or truncated from a 64-bit value.
void addAttribute(unsigned i, Attribute::AttrKind attr)
addAttribute - adds the attribute to the list of attributes.
Value * EmitStrCpy(Value *Dst, Value *Src, IRBuilder<> &B, const TargetLibraryInfo *TLI, StringRef Name="strcpy")
EmitStrCpy - Emit a call to the strcpy function to the builder, for the specified pointer arguments...
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
bool getLibFunc(StringRef funcName, LibFunc::Func &F) const
Searches for a particular function name.
Type * getDoubleTy()
Fetch the type representing a 64-bit floating point value.
Type * getParamType(unsigned i) const
Parameter type accessors.
initializer< Ty > init(const Ty &Val)
Constant * getOrInsertFunction(StringRef Name, FunctionType *T, AttributeSet AttributeList)
Look up the specified function in the module symbol table.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
This is an important base class in LLVM.
Value * EmitStrChr(Value *Ptr, char C, IRBuilder<> &B, const TargetLibraryInfo *TLI)
EmitStrChr - Emit a call to the strchr function to the builder, for the specified pointer and charact...
bool isFloatTy() const
isFloatTy - Return true if this is 'float', a 32-bit IEEE fp type.
ConstantFP - Floating Point Values [float, double].
This instruction compares its operands according to the predicate given to the constructor.
opStatus convert(const fltSemantics &, roundingMode, bool *)
APFloat::convert - convert a value of one floating point type to another.
Value * getOperand(unsigned i) const
Value * getPointerOperand()
Value * EmitStrNCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilder<> &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
EmitStrNCmp - Emit a call to the strncmp function to the builder.
Function doesn't unwind stack.
ConstantInt * getInt64(uint64_t C)
Get a constant 64-bit value.
static bool checkStringCopyLibFuncSignature(Function *F, LibFunc::Func Func)
Returns whether F matches the signature expected for the string/memory copying library function Func...
Predicate getPredicate() const
Return the predicate for this instruction.
Marks function as being in a cold path.
static Constant * getAllOnesValue(Type *Ty)
Get the all ones value.
bool isPointerTy() const
isPointerTy - True if this is an instance of PointerType.
Value * CreateInBoundsGEP(Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="")
uint64_t NextPowerOf2(uint64_t A)
NextPowerOf2 - Returns the next power of two (in 64-bits) that is strictly greater than A...
size_t find_first_not_of(char C, size_t From=0) const
Find the first character in the string that is not C or npos if not found.
LLVMContext & getContext() const
All values hold a context through their type.
CallInst * CreateCall(Value *Callee, ArrayRef< Value * > Args=None, const Twine &Name="")
PointerType * getInt8PtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer to an 8-bit integer value.
static PointerType * getInt8PtrTy(LLVMContext &C, unsigned AS=0)
Triple - Helper class for working with autoconf configuration names.
Value * CreateFDiv(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space...
This is the shared class of boolean and integer constants.
Value * CastToCStr(Value *V, IRBuilder<> &B)
CastToCStr - Return V if it is an i8*, otherwise cast it to i8*.
Value * CreateExtractElement(Value *Vec, Value *Idx, const Twine &Name="")
Value * CreateZExt(Value *V, Type *DestTy, const Twine &Name="")
GlobalVariable * CreateGlobalString(StringRef Str, const Twine &Name="", unsigned AddressSpace=0)
Make a new global variable with initializer type i8*.
static StructType * get(LLVMContext &Context, ArrayRef< Type * > Elements, bool isPacked=false)
StructType::get - This static method is the primary way to create a literal StructType.
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
Provides information about what library functions are available for the current target.
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
BasicBlock * GetInsertBlock() const
Value * stripPointerCasts()
Strip off pointer casts, all-zero GEPs, and aliases.
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.
Function * getCalledFunction() const
getCalledFunction - Return the function called, or null if this is an indirect function invocation...
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
const BasicBlock & getEntryBlock() const
static Constant * get(Type *Ty, double V)
get() - This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in the specified type.
BinaryOp_match< LHS, RHS, Instruction::FMul > m_FMul(const LHS &L, const RHS &R)
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
Value * EmitFPutC(Value *Char, Value *File, IRBuilder<> &B, const TargetLibraryInfo *TLI)
EmitFPutC - Emit a call to the fputc function.
AttributeSet getAttributes() const
Return the attribute list for this Function.
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
Class for arbitrary precision integers.
Value * EmitStrNCpy(Value *Dst, Value *Src, Value *Len, IRBuilder<> &B, const TargetLibraryInfo *TLI, StringRef Name="strncpy")
EmitStrNCpy - Emit a call to the strncpy function to the builder, for the specified pointer arguments...
bool isIntegerTy() const
isIntegerTy - True if this is an instance of IntegerType.
Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="")
iterator_range< user_iterator > users()
IntegerType * getInt8Ty()
Fetch the type representing an 8-bit integer.
LLVM_ATTRIBUTE_UNUSED_RESULT std::enable_if< !is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
ConstantInt * getFalse()
Get the constant value for i1 false.
bool isStructTy() const
isStructTy - True if this is an instance of StructType.
Value * CreateShl(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
Value * CreateIsNotNull(Value *Arg, const Twine &Name="")
Return an i1 value testing if Arg is not null.
void setCalledFunction(Value *Fn)
setCalledFunction - Set the function called.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
Value * CreateZExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a ZExt or Trunc from the integer value V to DestTy.
static const fltSemantics IEEEsingle
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
CallInst * CreateMemCpy(Value *Dst, Value *Src, uint64_t Size, unsigned Align, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memcpy between the specified pointers.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
static bool isOnlyUsedInZeroEqualityComparison(Value *V)
isOnlyUsedInZeroEqualityComparison - Return true if it only matters that the value is equal or not-eq...
static bool isFNeg(const Value *V, bool IgnoreZeroSign=false)
Value * CreateSExt(Value *V, Type *DestTy, const Twine &Name="")
FunctionType * getFunctionType() const
APFloat abs(APFloat X)
Returns the absolute value of the argument.
This class represents a cast unsigned integer to floating point.
Value * optimizeCall(CallInst *CI)
optimizeCall - Take the given call instruction and return a more optimal value to replace the instruc...
Value * CreateICmpNE(Value *LHS, Value *RHS, const Twine &Name="")
Type * getFloatTy()
Fetch the type representing a 32-bit floating point value.
size_t find_first_of(char C, size_t From=0) const
Find the first character in the string that is C, or npos if not found.
Value * EmitMemCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilder<> &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
EmitMemCmp - Emit a call to the memcmp function.
const APFloat & getValueAPF() const
bool getConstantStringInfo(const Value *V, StringRef &Str, uint64_t Offset=0, bool TrimAtNul=true)
getConstantStringInfo - This function computes the length of a null-terminated C string pointed to by...
bool isExactlyValue(const APFloat &V) const
isExactlyValue - We don't rely on operator== working on double values, as it returns true for things ...
3: 64-bit floating point type
Value * CreateFMul(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
StringRef getValueAsString() const
Return the attribute's value as a string.
This class represents a cast from signed integer to floating point.
static bool isOnlyUsedInEqualityComparison(Value *V, Value *With)
isOnlyUsedInEqualityComparison - Return true if it is only used in equality comparisons with With...
Value * EmitMemChr(Value *Ptr, Value *Val, Value *Len, IRBuilder<> &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
EmitMemChr - Emit a call to the memchr function.
Type * getReturnType() const
user_iterator user_begin()
Value * CreateNeg(Value *V, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
This class represents a truncation of floating point types.
Module * getParent()
Get the module that this global value is contained inside of...
Value * CreateTrunc(Value *V, Type *DestTy, const Twine &Name="")
LLVM Value Representation.
Value * CreateFCmpOEQ(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
bool isZero() const
Returns true if and only if the float is plus or minus zero.
static VectorType * get(Type *ElementType, unsigned NumElements)
VectorType::get - This static method is the primary way to construct an VectorType.
ConstantInt * getInt8(uint8_t C)
Get a constant 8-bit value.
C - The default llvm calling convention, compatible with C.
StringRef - Represent a constant reference to a string, i.e.
CallingConv::ID getCallingConv() const
getCallingConv/setCallingConv - Get or set the calling convention of this function call...
Value * CreateFPExt(Value *V, Type *DestTy, const Twine &Name="")
Value * EmitBinaryFloatFnCall(Value *Op1, Value *Op2, StringRef Name, IRBuilder<> &B, const AttributeSet &Attrs)
EmitUnaryFloatFnCall - Emit a call to the binary function named 'Name' (e.g.
ConstantInt * getInt(const APInt &AI)
Get a constant integer value.
This class represents an extension of floating point types.
LibCallSimplifier(const DataLayout &DL, const TargetLibraryInfo *TLI, function_ref< void(Instruction *, Value *)> Replacer=&replaceAllUsesWithDefault)
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
static Constant * getFPExtend(Constant *C, Type *Ty, bool OnlyIfReduced=false)
const BasicBlock * getParent() const
IntrinsicInst - A useful wrapper class for inspecting calls to intrinsic functions.
bool isVoidTy() const
isVoidTy - Return true if this is 'void'.
bool empty() const
empty - Check if the string is empty.
const Use * const_op_iterator