45 cl::desc(
"Enable unsafe double to float " 46 "shrinking for math lib calls"));
54 return Func == LibFunc_abs || Func == LibFunc_labs ||
55 Func == LibFunc_llabs || Func == LibFunc_strlen;
75 if (!FuncTy->getReturnType()->isPointerTy() &&
76 !FuncTy->getReturnType()->isIntegerTy() &&
77 !FuncTy->getReturnType()->isVoidTy())
80 for (
auto Param : FuncTy->params()) {
81 if (!Param->isPointerTy() && !Param->isIntegerTy())
93 if (
ICmpInst *IC = dyn_cast<ICmpInst>(U))
94 if (IC->isEquality() && IC->getOperand(1) == With)
104 return OI->getType()->isFloatingPointTy();
115 std::string nptr = Str.
str();
117 long long int Result = strtoll(nptr.c_str(), &End, Base);
144 if (!TLI->
getLibFunc(*InnerCallee, Func) || !TLI->
has(Func) ||
145 Func != LibFunc_fopen)
157 if (
ICmpInst *IC = dyn_cast<ICmpInst>(U))
158 if (
Constant *
C = dyn_cast<Constant>(IC->getOperand(1)))
159 if (
C->isNullValue())
200 return emitStrLenMemCpy(Src, Dst, Len, B);
203 Value *LibCallSimplifier::emitStrLenMemCpy(
Value *Src,
Value *Dst, uint64_t Len,
231 Len = LengthArg->getZExtValue();
244 if (SrcLen == 0 || Len == 0)
253 return emitStrLenMemCpy(Src, Dst, SrcLen, B);
333 if (HasStr1 && HasStr2)
336 if (HasStr1 && Str1.empty())
340 if (HasStr2 && Str2.empty())
349 std::min(Len1, Len2)),
354 if (!HasStr1 && HasStr2) {
360 }
else if (HasStr1 && !HasStr2) {
379 Length = LengthArg->getZExtValue();
394 if (HasStr1 && HasStr2) {
400 if (HasStr1 && Str1.empty())
404 if (HasStr2 && Str2.empty())
411 if (!HasStr1 && HasStr2) {
412 Len2 = std::min(Len2, Length);
418 }
else if (HasStr1 && !HasStr2) {
419 Len1 = std::min(Len1, Length);
490 if (
ConstantInt *LengthArg = dyn_cast<ConstantInt>(LenOp))
491 Len = LengthArg->getZExtValue();
499 if (Len > SrcLen + 1)
531 uint64_t NullTermIdx;
532 if (Slice.
Array ==
nullptr) {
535 NullTermIdx = ~((uint64_t)0);
536 for (uint64_t
I = 0,
E = Slice.
Length;
I <
E; ++
I) {
544 if (NullTermIdx == ~((uint64_t)0))
552 cast<ArrayType>(
GEP->getSourceElementType())->getNumElements();
565 (
GEP->isInBounds() && isa<GlobalVariable>(
GEP->getOperand(0)) &&
566 NullTermIdx == ArrSize - 1)) {
580 if (LenTrue && LenFalse) {
583 <<
"folded strlen(select) to select of constants";
600 return optimizeStringLength(CI, B, 8);
605 unsigned WCharSize = TLI->getWCharSize(M) * 8;
610 return optimizeStringLength(CI, B, WCharSize);
620 if ((HasS1 && S1.
empty()) || (HasS2 && S2.
empty()))
624 if (HasS1 && HasS2) {
634 if (HasS2 && S2.
size() == 1)
642 if (isa<ConstantPointerNull>(EndPtr)) {
658 if ((HasS1 && S1.
empty()) || (HasS2 && S2.
empty()))
662 if (HasS1 && HasS2) {
678 if (HasS1 && S1.
empty())
682 if (HasS1 && HasS2) {
690 if (HasS2 && S2.
empty())
711 ICmpInst *Old = cast<ICmpInst>(*UI++);
715 replaceAllUsesWith(Old, Cmp);
726 if (HasStr2 && ToFindStr.
empty())
730 if (HasStr1 && HasStr2) {
743 if (HasStr2 && ToFindStr.
size() == 1) {
745 return StrChr ? B.CreateBitCast(StrChr, CI->
getType()) :
nullptr;
756 if (LenC && LenC->isZero())
767 Str = Str.
substr(0, LenC->getZExtValue());
780 *std::max_element(reinterpret_cast<const unsigned char *>(Str.
begin()),
781 reinterpret_cast<const unsigned char *>(Str.
end()));
788 if (!DL.fitsInLegalInteger(Max + 1))
796 APInt Bitfield(Width, 0);
798 Bitfield.
setBit((
unsigned char)
C);
852 return B.
CreateSub(LHSV, RHSV,
"chardiff");
860 unsigned PrefAlignment = DL.getPrefTypeAlignment(IntType);
863 Value *LHSV =
nullptr;
864 if (
auto *LHSC = dyn_cast<Constant>(LHS)) {
868 Value *RHSV =
nullptr;
869 if (
auto *RHSC = dyn_cast<Constant>(RHS)) {
885 IntType->
getPointerTo(RHS->getType()->getPointerAddressSpace());
898 if (Len > LHSStr.
size() || Len > RHSStr.
size())
932 if (!FillValue || FillValue->getZExtValue() != 0)
940 if (!Malloc || !Malloc->hasOneUse())
944 Function *InnerCallee = Malloc->getCalledFunction();
949 if (!TLI->getLibFunc(*InnerCallee, Func) || !TLI->has(Func) ||
950 Func != LibFunc_malloc)
960 const DataLayout &DL = Malloc->getModule()->getDataLayout();
963 Malloc->getArgOperand(0), Malloc->getAttributes(),
969 eraseFromParent(Malloc);
975 if (
auto *Calloc = foldMallocMemset(CI, B))
1015 if (
FPExtInst *Cast = dyn_cast<FPExtInst>(Val)) {
1016 Value *
Op = Cast->getOperand(0);
1020 if (
ConstantFP *Const = dyn_cast<ConstantFP>(Val)) {
1033 bool isBinary,
bool isPrecise =
false) {
1051 if (!V[0] || (isBinary && !V[1]))
1065 if (FnName.
back() ==
'f' &&
1066 FnName.
size() == (CalleeNm.
size() + 1) &&
1092 bool isPrecise =
false) {
1098 bool isPrecise =
false) {
1133 if (!isa<FPMathOperator>(Call))
1170 assert(Exp != 0 &&
"Incorrect exponent 0 not handled");
1172 if (InnerChain[Exp])
1173 return InnerChain[Exp];
1175 static const unsigned AddChain[33][2] = {
1179 {1, 2}, {2, 2}, {2, 3}, {3, 3}, {2, 5}, {4, 4},
1180 {1, 8}, {5, 5}, {1, 10}, {6, 6}, {4, 9}, {7, 7},
1181 {3, 12}, {8, 8}, {8, 9}, {2, 16}, {1, 18}, {10, 10},
1182 {6, 15}, {11, 11}, {3, 20}, {12, 12}, {8, 17}, {13, 13},
1183 {3, 24}, {14, 14}, {4, 25}, {15, 15}, {3, 28}, {16, 16},
1187 getPow(InnerChain, AddChain[Exp][1], B));
1188 return InnerChain[Exp];
1221 TLI->getLibFunc(CalleeFn->
getName(), LibFn) && TLI->has(LibFn)) {
1232 case LibFunc_expf:
case LibFunc_exp:
case LibFunc_expl:
1233 ExpName = TLI->getName(LibFunc_exp);
1235 LibFnFloat = LibFunc_expf;
1236 LibFnDouble = LibFunc_exp;
1237 LibFnLongDouble = LibFunc_expl;
1239 case LibFunc_exp2f:
case LibFunc_exp2:
case LibFunc_exp2l:
1240 ExpName = TLI->getName(LibFunc_exp2);
1242 LibFnFloat = LibFunc_exp2f;
1243 LibFnDouble = LibFunc_exp2;
1244 LibFnLongDouble = LibFunc_exp2l;
1262 eraseFromParent(BaseFn);
1275 if (
hasUnaryFloatFn(TLI, Ty, LibFunc_exp2, LibFunc_exp2f, LibFunc_exp2l)) {
1278 BaseR = BaseR / *BaseF;
1281 const APFloat *NF = IsReciprocal ? &BaseR : BaseF;
1283 if ((IsInteger || IsReciprocal) &&
1286 double N = NI.
logBase2() * (IsReciprocal ? -1.0 : 1.0);
1293 LibFunc_exp2l, B, Attrs);
1300 hasUnaryFloatFn(TLI, Ty, LibFunc_exp10, LibFunc_exp10f, LibFunc_exp10l))
1302 LibFunc_exp10l, B, Attrs);
1324 LibFunc_sqrtl, B, Attrs);
1348 Sqrt = B.CreateCall(FAbsFn, Sqrt,
"abs");
1356 Value *FCmp = B.CreateFCmpOEQ(Base, NegInf,
"isinf");
1357 Sqrt = B.CreateSelect(FCmp, PosInf, Sqrt);
1372 Value *Shrunk =
nullptr;
1376 if (!
hasUnaryFloatFn(TLI, Ty, LibFunc_pow, LibFunc_powf, LibFunc_powl))
1385 if (UnsafeFPShrink &&
1386 Name == TLI->getName(LibFunc_pow) && hasFloatVersion(Name))
1395 if (
Value *Exp = replacePowWithExp(Pow, B))
1416 if (
Value *Sqrt = replacePowWithSqrt(Pow, B))
1433 Value *Sqrt =
nullptr;
1451 Value *InnerChain[33] = {
nullptr};
1452 InnerChain[1] = Base;
1453 InnerChain[2] = B.
CreateFMul(Base, Base,
"square");
1479 if (UnsafeFPShrink && Name ==
"exp2" && hasFloatVersion(Name))
1485 LibFunc LdExp = LibFunc_ldexpl;
1487 LdExp = LibFunc_ldexpf;
1489 LdExp = LibFunc_ldexp;
1491 if (TLI->has(LdExp)) {
1492 Value *LdExpArg =
nullptr;
1493 if (
SIToFPInst *OpC = dyn_cast<SIToFPInst>(Op)) {
1494 if (OpC->getOperand(0)->getType()->getPrimitiveSizeInBits() <= 32)
1496 }
else if (
UIToFPInst *OpC = dyn_cast<UIToFPInst>(Op)) {
1497 if (OpC->getOperand(0)->getType()->getPrimitiveSizeInBits() < 32)
1525 if ((Name ==
"fmin" || Name ==
"fmax") && hasFloatVersion(Name))
1561 if (UnsafeFPShrink && hasFloatVersion(Name))
1570 if (!OpC || !OpC->isFast())
1575 if (Name !=
"log" && Name !=
"log2" && Name !=
"log10")
1585 if (F && ((TLI->getLibFunc(F->
getName(), Func) && TLI->has(Func) &&
1592 if (F && Name ==
"log" && TLI->getLibFunc(F->
getName(), Func) &&
1593 TLI->has(Func) && Func == LibFunc_exp2)
1595 OpC->getArgOperand(0),
1608 if (TLI->has(LibFunc_sqrtf) && (Callee->
getName() ==
"sqrt" ||
1624 Value *RepeatOp =
nullptr;
1625 Value *OtherOp =
nullptr;
1635 Value *OtherMul0, *OtherMul1;
1638 if (OtherMul0 == OtherMul1 && cast<Instruction>(Op0)->isFast()) {
1640 RepeatOp = OtherMul0;
1675 if (UnsafeFPShrink && Name ==
"tan" && hasFloatVersion(Name))
1684 if (!CI->
isFast() || !OpC->isFast())
1692 if (F && TLI->getLibFunc(F->
getName(), Func) && TLI->has(Func) &&
1693 ((Func == LibFunc_atan && Callee->
getName() ==
"tan") ||
1694 (Func == LibFunc_atanf && Callee->
getName() ==
"tanf") ||
1695 (Func == LibFunc_atanl && Callee->
getName() ==
"tanl")))
1696 Ret = OpC->getArgOperand(0);
1717 Name =
"__sincospif_stret";
1726 Name =
"__sincospi_stret";
1734 if (
Instruction *ArgInst = dyn_cast<Instruction>(Arg)) {
1737 B.
SetInsertPoint(ArgInst->getParent(), ++ArgInst->getIterator());
1745 SinCos = B.
CreateCall(Callee, Arg,
"sincospi");
1776 classifyArgUse(U, F, IsFloat, SinCalls, CosCalls, SinCosCalls);
1782 Value *Sin, *Cos, *SinCos;
1788 replaceAllUsesWith(
C, Res);
1791 replaceTrigInsts(SinCalls, Sin);
1792 replaceTrigInsts(CosCalls, Cos);
1793 replaceTrigInsts(SinCosCalls, SinCos);
1798 void LibCallSimplifier::classifyArgUse(
1814 if (!Callee || !TLI->getLibFunc(*Callee, Func) || !TLI->has(Func) ||
1819 if (Func == LibFunc_sinpif)
1821 else if (Func == LibFunc_cospif)
1823 else if (Func == LibFunc_sincospif_stret)
1826 if (Func == LibFunc_sinpi)
1828 else if (Func == LibFunc_cospi)
1830 else if (Func == LibFunc_sincospi_stret)
1961 return GV->
getName() ==
"stderr";
1971 if (FormatStr.
empty())
1981 if (FormatStr.
size() == 1 || FormatStr ==
"%%")
1989 if (ChrStr.
size() != 1)
1995 if (FormatStr[FormatStr.
size() - 1] ==
'\n' &&
2021 if (
Value *V = optimizePrintFString(CI, B)) {
2055 FormatStr.
size() + 1));
2061 if (FormatStr.
size() != 2 || FormatStr[0] !=
'%' ||
2066 if (FormatStr[1] ==
'c') {
2079 if (FormatStr[1] ==
's') {
2100 if (
Value *V = optimizeSPrintFString(CI, B)) {
2140 else if (N < FormatStr.
size() + 1)
2148 FormatStr.
size() + 1));
2154 if (FormatStr.
size() == 2 && FormatStr[0] ==
'%' &&
2158 if (FormatStr[1] ==
'c') {
2176 if (FormatStr[1] ==
's') {
2184 else if (N < Str.
size() + 1)
2198 if (
Value *V = optimizeSnPrintFString(CI, B)) {
2206 optimizeErrorReporting(CI, B, 0);
2233 if (FormatStr.
size() != 2 || FormatStr[0] !=
'%' ||
2238 if (FormatStr[1] ==
'c') {
2245 if (FormatStr[1] ==
's') {
2257 if (
Value *V = optimizeFPrintFString(CI, B)) {
2276 optimizeErrorReporting(CI, B, 3);
2281 if (SizeC && CountC) {
2282 uint64_t Bytes = SizeC->
getZExtValue() * CountC->getZExtValue();
2306 optimizeErrorReporting(CI, B, 1);
2336 optimizeErrorReporting(CI, B, 1);
2386 bool LibCallSimplifier::hasFloatVersion(
StringRef FuncName) {
2389 FloatFuncName +=
'f';
2390 if (TLI->getLibFunc(FloatFuncName, Func))
2391 return TLI->has(Func);
2395 Value *LibCallSimplifier::optimizeStringMemoryLibCall(
CallInst *CI,
2400 if (TLI->getLibFunc(*Callee, Func) && TLI->has(Func)) {
2404 "Optimizing string/memory libcall would change the calling convention");
2406 case LibFunc_strcat:
2407 return optimizeStrCat(CI, Builder);
2408 case LibFunc_strncat:
2409 return optimizeStrNCat(CI, Builder);
2410 case LibFunc_strchr:
2411 return optimizeStrChr(CI, Builder);
2412 case LibFunc_strrchr:
2413 return optimizeStrRChr(CI, Builder);
2414 case LibFunc_strcmp:
2415 return optimizeStrCmp(CI, Builder);
2416 case LibFunc_strncmp:
2417 return optimizeStrNCmp(CI, Builder);
2418 case LibFunc_strcpy:
2419 return optimizeStrCpy(CI, Builder);
2420 case LibFunc_stpcpy:
2421 return optimizeStpCpy(CI, Builder);
2422 case LibFunc_strncpy:
2423 return optimizeStrNCpy(CI, Builder);
2424 case LibFunc_strlen:
2425 return optimizeStrLen(CI, Builder);
2426 case LibFunc_strpbrk:
2427 return optimizeStrPBrk(CI, Builder);
2428 case LibFunc_strtol:
2429 case LibFunc_strtod:
2430 case LibFunc_strtof:
2431 case LibFunc_strtoul:
2432 case LibFunc_strtoll:
2433 case LibFunc_strtold:
2434 case LibFunc_strtoull:
2435 return optimizeStrTo(CI, Builder);
2436 case LibFunc_strspn:
2437 return optimizeStrSpn(CI, Builder);
2438 case LibFunc_strcspn:
2439 return optimizeStrCSpn(CI, Builder);
2440 case LibFunc_strstr:
2441 return optimizeStrStr(CI, Builder);
2442 case LibFunc_memchr:
2443 return optimizeMemChr(CI, Builder);
2444 case LibFunc_memcmp:
2445 return optimizeMemCmp(CI, Builder);
2446 case LibFunc_memcpy:
2447 return optimizeMemCpy(CI, Builder);
2448 case LibFunc_memmove:
2449 return optimizeMemMove(CI, Builder);
2450 case LibFunc_memset:
2451 return optimizeMemSet(CI, Builder);
2452 case LibFunc_realloc:
2453 return optimizeRealloc(CI, Builder);
2454 case LibFunc_wcslen:
2455 return optimizeWcslen(CI, Builder);
2463 Value *LibCallSimplifier::optimizeFloatingPointLibCall(
CallInst *CI,
2474 case LibFunc_sinpif:
2476 case LibFunc_cospif:
2478 return optimizeSinCosPi(CI, Builder);
2482 return optimizePow(CI, Builder);
2486 return optimizeExp2(CI, Builder);
2494 return optimizeSqrt(CI, Builder);
2500 return optimizeLog(CI, Builder);
2504 return optimizeTan(CI, Builder);
2511 case LibFunc_nearbyint:
2535 case LibFunc_copysign:
2545 return optimizeFMinFMax(CI, Builder);
2549 return optimizeCAbs(CI, Builder);
2575 else if (isa<FPMathOperator>(CI) && CI->
isFast())
2576 UnsafeFPShrink =
true;
2580 if (!isCallingConvC)
2584 switch (II->getIntrinsicID()) {
2586 return optimizePow(CI, Builder);
2588 return optimizeExp2(CI, Builder);
2590 return optimizeLog(CI, Builder);
2592 return optimizeSqrt(CI, Builder);
2600 if (
Value *SimplifiedFortifiedCI = FortifiedSimplifier.optimizeCall(CI)) {
2607 if (
Value *V = optimizeStringMemoryLibCall(SimplifiedCI, TmpBuilder)) {
2610 eraseFromParent(SimplifiedCI);
2614 return SimplifiedFortifiedCI;
2618 if (TLI->getLibFunc(*Callee, Func) && TLI->has(Func)) {
2622 if (
Value *V = optimizeStringMemoryLibCall(CI, Builder))
2624 if (
Value *V = optimizeFloatingPointLibCall(CI, Func, Builder))
2630 return optimizeFFS(CI, Builder);
2634 return optimizeFls(CI, Builder);
2638 return optimizeAbs(CI, Builder);
2639 case LibFunc_isdigit:
2640 return optimizeIsDigit(CI, Builder);
2641 case LibFunc_isascii:
2642 return optimizeIsAscii(CI, Builder);
2643 case LibFunc_toascii:
2644 return optimizeToAscii(CI, Builder);
2648 return optimizeAtoi(CI, Builder);
2649 case LibFunc_strtol:
2650 case LibFunc_strtoll:
2651 return optimizeStrtol(CI, Builder);
2652 case LibFunc_printf:
2653 return optimizePrintF(CI, Builder);
2654 case LibFunc_sprintf:
2655 return optimizeSPrintF(CI, Builder);
2656 case LibFunc_snprintf:
2657 return optimizeSnPrintF(CI, Builder);
2658 case LibFunc_fprintf:
2659 return optimizeFPrintF(CI, Builder);
2660 case LibFunc_fwrite:
2661 return optimizeFWrite(CI, Builder);
2663 return optimizeFRead(CI, Builder);
2665 return optimizeFPuts(CI, Builder);
2667 return optimizeFGets(CI, Builder);
2669 return optimizeFPutc(CI, Builder);
2671 return optimizeFGetc(CI, Builder);
2673 return optimizePuts(CI, Builder);
2674 case LibFunc_perror:
2675 return optimizeErrorReporting(CI, Builder);
2676 case LibFunc_vfprintf:
2677 case LibFunc_fiprintf:
2678 return optimizeErrorReporting(CI, Builder, 0);
2691 : FortifiedSimplifier(TLI), DL(DL), TLI(TLI), ORE(ORE),
2692 UnsafeFPShrink(
false), Replacer(Replacer), Eraser(Eraser) {}
2699 void LibCallSimplifier::eraseFromParent(
Instruction *I) {
2738 bool FortifiedLibCallSimplifier::isFortifiedCallFoldable(
CallInst *CI,
2746 if (ObjSizeCI->isMinusOne())
2749 if (OnlyLowerUnknownSize)
2757 return ObjSizeCI->getZExtValue() >= Len;
2760 return ObjSizeCI->getZExtValue() >= SizeCI->getZExtValue();
2765 Value *FortifiedLibCallSimplifier::optimizeMemCpyChk(
CallInst *CI,
2767 if (isFortifiedCallFoldable(CI, 3, 2,
false)) {
2775 Value *FortifiedLibCallSimplifier::optimizeMemMoveChk(
CallInst *CI,
2777 if (isFortifiedCallFoldable(CI, 3, 2,
false)) {
2785 Value *FortifiedLibCallSimplifier::optimizeMemSetChk(
CallInst *CI,
2789 if (isFortifiedCallFoldable(CI, 3, 2,
false)) {
2797 Value *FortifiedLibCallSimplifier::optimizeStrpCpyChk(
CallInst *CI,
2807 if (Func == LibFunc_stpcpy_chk && !OnlyLowerUnknownSize && Dst == Src) {
2817 if (isFortifiedCallFoldable(CI, 2, 1,
true))
2820 if (OnlyLowerUnknownSize)
2833 if (Ret && Func == LibFunc_stpcpy_chk)
2838 Value *FortifiedLibCallSimplifier::optimizeStrpNCpyChk(
CallInst *CI,
2843 if (isFortifiedCallFoldable(CI, 3, 2,
false)) {
2883 case LibFunc_memcpy_chk:
2884 return optimizeMemCpyChk(CI, Builder);
2885 case LibFunc_memmove_chk:
2886 return optimizeMemMoveChk(CI, Builder);
2887 case LibFunc_memset_chk:
2888 return optimizeMemSetChk(CI, Builder);
2889 case LibFunc_stpcpy_chk:
2890 case LibFunc_strcpy_chk:
2891 return optimizeStrpCpyChk(CI, Builder, Func);
2892 case LibFunc_stpncpy_chk:
2893 case LibFunc_strncpy_chk:
2894 return optimizeStrpNCpyChk(CI, Builder, Func);
2903 : TLI(TLI), OnlyLowerUnknownSize(OnlyLowerUnknownSize) {}
Value * CreateNSWNeg(Value *V, const Twine &Name="")
Value * CreateInBoundsGEP(Value *Ptr, ArrayRef< Value *> IdxList, const Twine &Name="")
void computeKnownBits(const Value *V, KnownBits &Known, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, OptimizationRemarkEmitter *ORE=nullptr, bool UseInstrInfo=true)
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOn...
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
bool hasNoInfs() const
Determine whether the no-infs flag is set.
A parsed version of the target data layout string in and methods for querying it. ...
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
Value * CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="")
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
bool hasNoSignedZeros() const
Determine whether the no-signed-zeros flag is set.
ARM_AAPCS - ARM Architecture Procedure Calling Standard calling convention (aka EABI).
void flipAllBits()
Toggle every bit to its opposite value.
C - The default llvm calling convention, compatible with C.
bool isOnlyUsedInZeroEqualityComparison(const Instruction *CxtI)
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
bool doesNotAccessMemory(unsigned OpNo) const
void setFast(bool B=true)
Value * CreateICmpNE(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateIsNotNull(Value *Arg, const Twine &Name="")
Return an i1 value testing if Arg is not null.
Value * CreateZExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a ZExt or Trunc from the integer value V to DestTy.
This class represents lattice values for constants.
static bool callHasFloatingPointArgument(const CallInst *CI)
Type * getParamType(unsigned i) const
Parameter type accessors.
Value * CreateICmpULT(Value *LHS, Value *RHS, const Twine &Name="")
Constant * getOrInsertFunction(StringRef Name, FunctionType *T, AttributeList AttributeList)
Look up the specified function in the module symbol table.
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of converting the string to 'bool...
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. ...
static Constant * getInfinity(Type *Ty, bool Negative=false)
LLVM_NODISCARD size_t rfind(char C, size_t From=npos) const
Search for the last character C in the string.
void push_back(const T &Elt)
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
Value * CreateICmpSLT(Value *LHS, Value *RHS, const Twine &Name="")
This class represents a function call, abstracting a target machine's calling convention.
An efficient, type-erasing, non-owning reference to a callable.
LLVMContext & getContext() const
All values hold a context through their type.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
Value * CreateSExt(Value *V, Type *DestTy, const Twine &Name="")
const fltSemantics & getSemantics() const
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
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.
An instruction for reading from memory.
static bool isTrigLibCall(CallInst *CI)
Value * emitStrNCpy(Value *Dst, Value *Src, Value *Len, IRBuilder<> &B, const TargetLibraryInfo *TLI, StringRef Name="strncpy")
Emit a call to the strncpy function to the builder, for the specified pointer arguments and length...
bool isGEPBasedOnPointerToString(const GEPOperator *GEP, unsigned CharSize=8)
Returns true if the GEP is based on a pointer to a string (array of.
Value * emitFPutSUnlocked(Value *Str, Value *File, IRBuilder<> &B, const TargetLibraryInfo *TLI)
Emit a call to the fputs_unlocked function.
uint64_t Offset
Slice starts at this Offset.
void addAttribute(unsigned i, Attribute::AttrKind Kind)
adds the attribute to the list of attributes.
LLVMContext & getContext() const
Get the context in which this basic block lives.
Value * emitMalloc(Value *Num, IRBuilder<> &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
Emit a call to the malloc function.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
static bool isReportingError(Function *Callee, CallInst *CI, int StreamArg)
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
iterator begin()
Instruction iterator methods.
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
static Value * replaceUnaryCall(CallInst *CI, IRBuilder<> &B, Intrinsic::ID IID)
Value * getArgOperand(unsigned i) const
opStatus convertToInteger(MutableArrayRef< integerPart > Input, unsigned int Width, bool IsSigned, roundingMode RM, bool *IsExact) const
specific_fpval m_SpecificFP(double V)
Match a specific floating point value or vector with all elements equal to the value.
bool match(Val *V, const Pattern &P)
LibCallSimplifier(const DataLayout &DL, const TargetLibraryInfo *TLI, OptimizationRemarkEmitter &ORE, function_ref< void(Instruction *, Value *)> Replacer=&replaceAllUsesWithDefault, function_ref< void(Instruction *)> Eraser=&eraseFromParentDefault)
amdgpu Simplify well known AMD library false Value Value const Twine & Name
Value * CreateFPExt(Value *V, Type *DestTy, const Twine &Name="")
void setBit(unsigned BitPosition)
Set a given bit to 1.
This class represents the LLVM 'select' instruction.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
bool isNonNegative() const
Determine if this APInt Value is non-negative (>= 0)
FortifiedLibCallSimplifier(const TargetLibraryInfo *TLI, bool OnlyLowerUnknownSize=false)
A Use represents the edge between a Value definition and its users.
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
Value * emitPutChar(Value *Char, IRBuilder<> &B, const TargetLibraryInfo *TLI)
Emit a call to the putchar function. This assumes that Char is an integer.
bool isIntegerTy() const
True if this is an instance of IntegerType.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
void setCalledFunction(Value *Fn)
Sets the function called, including updating the function type.
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
CallInst * CreateMemMove(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign, uint64_t Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memmove between the specified pointers.
Value * emitUnaryFloatFnCall(Value *Op, StringRef Name, IRBuilder<> &B, const AttributeList &Attrs)
Emit a call to the unary function named 'Name' (e.g.
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"))
Value * emitFPutCUnlocked(Value *Char, Value *File, IRBuilder<> &B, const TargetLibraryInfo *TLI)
Emit a call to the fputc_unlocked function.
static StructType * get(LLVMContext &Context, ArrayRef< Type *> Elements, bool isPacked=false)
This static method is the primary way to create a literal StructType.
StoreInst * CreateStore(Value *Val, Value *Ptr, bool isVolatile=false)
static Value * convertStrToNumber(CallInst *CI, StringRef &Str, int64_t Base)
Value * CreateIntToPtr(Value *V, Type *DestTy, const Twine &Name="")
Instruction * clone() const
Create a copy of 'this' instruction that is identical in all ways except the following: ...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
Class to represent function types.
Value * CreateBitCast(Value *V, Type *DestTy, const Twine &Name="")
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
Type * getType() const
All values are typed, get the type of this value.
Value * CreateSExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a SExt or Trunc from the integer value V to DestTy.
apfloat_match m_APFloat(const APFloat *&Res)
Match a ConstantFP or splatted ConstantVector, binding the specified pointer to the contained APFloat...
const ConstantDataArray * Array
ConstantDataArray pointer.
opStatus convert(const fltSemantics &ToSemantics, roundingMode RM, bool *losesInfo)
BasicBlock * GetInsertBlock() const
Value * emitMemCpyChk(Value *Dst, Value *Src, Value *Len, Value *ObjSize, IRBuilder<> &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
Emit a call to the __memcpy_chk function to the builder.
bool has(LibFunc F) const
Tests whether a library function is available.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Value * emitStrCpy(Value *Dst, Value *Src, IRBuilder<> &B, const TargetLibraryInfo *TLI, StringRef Name="strcpy")
Emit a call to the strcpy function to the builder, for the specified pointer arguments.
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
AttributeList getAttributes() const
Return the attribute list for this Function.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
static const fltSemantics & IEEEdouble() LLVM_READNONE
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
static Value * valueHasFloatPrecision(Value *Val)
Return a variant of Val with float type.
Value * CreateZExt(Value *V, Type *DestTy, const Twine &Name="")
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
uint64_t GetStringLength(const Value *V, unsigned CharSize=8)
If we can compute the length of the string pointed to by the specified pointer, return 'len+1'...
void takeName(Value *V)
Transfer the name from V to this value.
amdgpu Simplify well known AMD library false Value * Callee
Function * getDeclaration(Module *M, ID id, ArrayRef< Type *> Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block...
Value * getOperand(unsigned i) const
ConstantInt * getIntN(unsigned N, uint64_t C)
Get a constant N-bit value, zero extended or truncated from a 64-bit value.
ARM_AAPCS_VFP - Same as ARM_AAPCS, but uses hard floating point ABI.
static bool isOnlyUsedInComparisonWithZero(Value *V)
bool getConstantDataArrayInfo(const Value *V, ConstantDataArraySlice &Slice, unsigned ElementSize, uint64_t Offset=0)
Returns true if the value V is a pointer into a ConstantDataArray.
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
Value * emitFPutS(Value *Str, Value *File, IRBuilder<> &B, const TargetLibraryInfo *TLI)
Emit a call to the fputs function.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
const BasicBlock & getEntryBlock() const
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...
bool inferLibFuncAttributes(Function &F, const TargetLibraryInfo &TLI)
Analyze the name and prototype of the given function and set any applicable attributes.
Type * getDoubleTy()
Fetch the type representing a 64-bit floating point value.
OneUse_match< T > m_OneUse(const T &SubPattern)
initializer< Ty > init(const Ty &Val)
static bool isLocallyOpenedFile(Value *File, CallInst *CI, IRBuilder<> &B, const TargetLibraryInfo *TLI)
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Value * CreateFMul(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
void setNoSignedZeros(bool B=true)
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
Value * CreateConstInBoundsGEP1_64(Type *Ty, Value *Ptr, uint64_t Idx0, const Twine &Name="")
ConstantInt * getTrue()
Get the constant value for i1 true.
bool isNoBuiltin() const
Return true if the call should not be treated as a call to a builtin.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="", Instruction *MDFrom=nullptr)
bool isPointerTy() const
True if this is an instance of PointerType.
LLVM_NODISCARD 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.
FunctionType * getFunctionType() const
ConstantFP - Floating Point Values [float, double].
Value * CreateFCmpOGT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
ARM_APCS - ARM Procedure Calling Standard calling convention (obsolete, but still used on some target...
double convertToDouble() const
bool isExactlyValue(double V) const
We don't rely on operator== working on double values, as it returns true for things that are clearly ...
bool isFast() const
Determine whether all fast-math-flags are set.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
Value * CreateNeg(Value *V, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
bool optForSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
This instruction compares its operands according to the predicate given to the constructor.
void setCallingConv(CallingConv::ID CC)
Value * getPointerOperand()
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE int compare(StringRef RHS) const
compare - Compare two strings; the result is -1, 0, or 1 if this string is lexicographically less tha...
static bool isCallingConvCCompatible(CallInst *CI)
Class to represent integer types.
ConstantInt * getInt64(uint64_t C)
Get a constant 64-bit value.
Value * castToCStr(Value *V, IRBuilder<> &B)
Return V if it is an i8*, otherwise cast it to i8*.
Represents offset+length into a ConstantDataArray.
Value * CreateExtractElement(Value *Vec, Value *Idx, const Twine &Name="")
const Function * getFunction() const
Return the function this instruction belongs to.
Constant * ConstantFoldLoadFromConstPtr(Constant *C, Type *Ty, const DataLayout &DL)
ConstantFoldLoadFromConstPtr - Return the value that a load from C would produce if it is constant an...
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
uint64_t NextPowerOf2(uint64_t A)
Returns the next power of two (in 64-bits) that is strictly greater than A.
const Constant * stripPointerCasts() const
Value * emitStrChr(Value *Ptr, char C, IRBuilder<> &B, const TargetLibraryInfo *TLI)
Emit a call to the strchr function to the builder, for the specified pointer and character.
Value * CreateExtractValue(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &Name="")
LLVM_NODISCARD char back() const
back - Get the last character in the string.
bool hasFnAttr(Attribute::AttrKind Kind) const
Determine whether this call has the given attribute.
static bool isBinary(MachineInstr &MI)
Value * CreateTrunc(Value *V, Type *DestTy, const Twine &Name="")
Triple - Helper class for working with autoconf configuration names.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef drop_back(size_t N=1) const
Return a StringRef equal to 'this' but with the last N elements dropped.
Value * emitFWriteUnlocked(Value *Ptr, Value *Size, Value *N, Value *File, IRBuilder<> &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
Emit a call to the fwrite_unlocked function.
Value * CreateGEP(Value *Ptr, ArrayRef< Value *> IdxList, const Twine &Name="")
Value * CreateFCmpOLT(Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * emitStrLen(Value *Ptr, IRBuilder<> &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
Emit a call to the strlen function to the builder, for the specified pointer.
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
Value * emitBinaryFloatFnCall(Value *Op1, Value *Op2, StringRef Name, IRBuilder<> &B, const AttributeList &Attrs)
Emit a call to the binary function named 'Name' (e.g.
static const fltSemantics & IEEEsingle() LLVM_READNONE
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
static Value * optimizeDoubleFP(CallInst *CI, IRBuilder<> &B, bool isBinary, bool isPrecise=false)
Shrink double -> float functions.
Value * emitFGetCUnlocked(Value *File, IRBuilder<> &B, const TargetLibraryInfo *TLI)
Emit a call to the fgetc_unlocked function. File is a pointer to FILE.
This is the shared class of boolean and integer constants.
GlobalVariable * CreateGlobalString(StringRef Str, const Twine &Name="", unsigned AddressSpace=0)
Make a new global variable with initializer type i8*.
Value * CreateIntCast(Value *V, Type *DestTy, bool isSigned, const Twine &Name="")
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
uint64_t getElementAsInteger(unsigned i) const
If this is a sequential container of integers (of any size), return the specified element in the low ...
Module.h This file contains the declarations for the Module class.
uint64_t Length
Length of the slice.
Provides information about what library functions are available for the current target.
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
void getOperandBundlesAsDefs(SmallVectorImpl< OperandBundleDef > &Defs) const
Return the list of operand bundles attached to this instruction as a vector of OperandBundleDefs.
CallInst * CreateMemCpy(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign, uint64_t Size, bool isVolatile=false, MDNode *TBAATag=nullptr, MDNode *TBAAStructTag=nullptr, MDNode *ScopeTag=nullptr, MDNode *NoAliasTag=nullptr)
Create and insert a memcpy between the specified pointers.
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.
static Constant * get(Type *Ty, double V)
This returns a ConstantFP, or a vector containing a splat of a ConstantFP, for the specified value in...
AttributeList getAttributes() const
Return the parameter attributes for this call.
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...
void setNoNaNs(bool B=true)
unsigned logBase2() const
The access may modify the value stored in memory.
FunctionType * getFunctionType() const
Returns the FunctionType for me.
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
Class for arbitrary precision integers.
bool ule(const APInt &RHS) const
Unsigned less or equal comparison.
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
iterator_range< user_iterator > users()
IntegerType * getInt8Ty()
Fetch the type representing an 8-bit integer.
Value * CreateShl(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
Value * emitFPutC(Value *Char, Value *File, IRBuilder<> &B, const TargetLibraryInfo *TLI)
Emit a call to the fputc function.
ConstantInt * getFalse()
Get the constant value for i1 false.
amdgpu Simplify well known AMD library false Value Value * Arg
Value * emitFGetSUnlocked(Value *Str, Value *Size, Value *File, IRBuilder<> &B, const TargetLibraryInfo *TLI)
Emit a call to the fgets_unlocked function.
specific_fpval m_FPOne()
Match a float 1.0 or vector with all elements equal to 1.0.
opStatus add(const APFloat &RHS, roundingMode RM)
Predicate getPredicate() const
Return the predicate for this instruction.
FNeg_match< OpTy > m_FNeg(const OpTy &X)
Match 'fneg X' as 'fsub -0.0, X'.
unsigned getNumArgOperands() const
Merge contiguous icmps into a memcmp
unsigned getIntegerBitWidth() const
LLVM_NODISCARD bool empty() const
static Value * optimizeUnaryDoubleFP(CallInst *CI, IRBuilder<> &B, bool isPrecise=false)
Shrink double -> float for unary functions.
Value * emitStrNCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilder<> &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
Emit a call to the strncmp function to the builder.
CallingConv::ID getCallingConv() const
StringRef getName() const
Return a constant reference to the value's name.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
const Function * getParent() const
Return the enclosing method, or null if none.
LLVM_NODISCARD 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.
APFloat abs(APFloat X)
Returns the absolute value of the argument.
This class represents a cast unsigned integer to floating point.
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
static Value * optimizeBinaryDoubleFP(CallInst *CI, IRBuilder<> &B, bool isPrecise=false)
Shrink double -> float for binary functions.
Value * optimizeCall(CallInst *CI)
optimizeCall - Take the given call instruction and return a more optimal value to replace the instruc...
unsigned getKnownAlignment(Value *V, const DataLayout &DL, const Instruction *CxtI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr)
Try to infer an alignment for the specified pointer.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value *> Args=None, const Twine &Name="", MDNode *FPMathTag=nullptr)
static void insertSinCosCall(IRBuilder<> &B, Function *OrigCallee, Value *Arg, bool UseFloat, Value *&Sin, Value *&Cos, Value *&SinCos)
Type * getFloatTy()
Fetch the type representing a 32-bit floating point value.
Value * CreateFAdd(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
bool isStrictFP() const
Determine if the call requires strict floating point semantics.
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateFDiv(Value *L, Value *R, const Twine &Name="", MDNode *FPMD=nullptr)
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
bool getConstantStringInfo(const Value *V, StringRef &Str, uint64_t Offset=0, bool TrimAtNul=true)
This function computes the length of a null-terminated C string pointed to by V.
Value * emitFWrite(Value *Ptr, Value *Size, Value *File, IRBuilder<> &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
Emit a call to the fwrite function.
InstTy * Insert(InstTy *I, const Twine &Name="") const
Insert and return the specified instruction.
Value * emitMemCmp(Value *Ptr1, Value *Ptr2, Value *Len, IRBuilder<> &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
Emit a call to the memcmp function.
This class represents a cast from signed integer to floating point.
static bool isOnlyUsedInEqualityComparison(Value *V, Value *With)
Return true if it is only used in equality comparisons with With.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
user_iterator user_begin()
This class represents a truncation of floating point types.
Value * emitFReadUnlocked(Value *Ptr, Value *Size, Value *N, Value *File, IRBuilder<> &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
Emit a call to the fread_unlocked function.
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
Return the basic size of this type if it is a primitive type.
Module * getParent()
Get the module that this global value is contained inside of...
LLVM Value Representation.
Value * emitPutS(Value *Str, IRBuilder<> &B, const TargetLibraryInfo *TLI)
Emit a call to the puts function. This assumes that Str is some pointer.
static VectorType * get(Type *ElementType, unsigned NumElements)
This static method is the primary way to construct an VectorType.
Value * emitMemChr(Value *Ptr, Value *Val, Value *Len, IRBuilder<> &B, const DataLayout &DL, const TargetLibraryInfo *TLI)
Emit a call to the memchr function.
void setFastMathFlags(FastMathFlags NewFMF)
Set the fast-math flags to be used with generated fp-math operators.
static bool canTransformToMemCmp(CallInst *CI, Value *Str, uint64_t Len, const DataLayout &DL)
Value * emitCalloc(Value *Num, Value *Size, const AttributeList &Attrs, IRBuilder<> &B, const TargetLibraryInfo &TLI)
Emit a call to the calloc function.
ConstantInt * getInt8(uint8_t C)
Get a constant 8-bit value.
static Value * optimizeTrigReflections(CallInst *Call, LibFunc Func, IRBuilder<> &B)
bool hasNoNaNs() const
Determine whether the no-NaNs flag is set.
bool hasOneUse() const
Return true if there is exactly one user of this value.
static Value * getSqrtCall(Value *V, AttributeList Attrs, bool NoErrno, Module *M, IRBuilder<> &B, const TargetLibraryInfo *TLI)
Convenience struct for specifying and reasoning about fast-math flags.
StringRef - Represent a constant reference to a string, i.e.
bool isDereferenceableAndAlignedPointer(const Value *V, unsigned Align, const DataLayout &DL, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr)
Returns true if V is always a dereferenceable pointer with alignment greater or equal than requested...
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
ConstantInt * getInt(const APInt &AI)
Get a constant integer value.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t find(char C, size_t From=0) const
Search for the first character C in the string.
static bool ignoreCallingConv(LibFunc Func)
This class represents an extension of floating point types.
static Constant * getFPExtend(Constant *C, Type *Ty, bool OnlyIfReduced=false)
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
bool hasUnaryFloatFn(const TargetLibraryInfo *TLI, Type *Ty, LibFunc DoubleFn, LibFunc FloatFn, LibFunc LongDoubleFn)
Check whether the overloaded unary floating point function corresponding to Ty is available...
static Value * getPow(Value *InnerChain[33], unsigned Exp, IRBuilder<> &B)
Value * CreateFNeg(Value *V, const Twine &Name="", MDNode *FPMathTag=nullptr)
bool isStructTy() const
True if this is an instance of StructType.
cmpResult compare(const APFloat &RHS) const
bool isArrayTy() const
True if this is an instance of ArrayType.
A wrapper class for inspecting calls to intrinsic functions.
bool PointerMayBeCaptured(const Value *V, bool ReturnCaptures, bool StoreCaptures, unsigned MaxUsesToExplore=DefaultMaxUsesToExplore)
PointerMayBeCaptured - Return true if this pointer value may be captured by the enclosing function (w...