26 using namespace PatternMatch;
28 #define DEBUG_TYPE "instcombine"
30 STATISTIC(NumSimplified,
"Number of library calls simplified");
36 if (ITy->getBitWidth() < 32)
46 if (
StructType *STy = dyn_cast<StructType>(T)) {
47 if (STy->getNumElements() == 1)
48 T = STy->getElementType(0);
51 }
else if (
ArrayType *ATy = dyn_cast<ArrayType>(T)) {
52 if (ATy->getNumElements() == 1)
53 T = ATy->getElementType();
67 unsigned CopyAlign = MI->getAlignment();
69 if (CopyAlign < MinAlign) {
78 if (!MemOpLength)
return nullptr;
85 assert(Size &&
"0-sized memory transferring should be removed already.");
87 if (Size > 8 || (Size&(Size-1)))
92 cast<PointerType>(MI->getArgOperand(1)->getType())->getAddressSpace();
94 cast<PointerType>(MI->getArgOperand(0)->getType())->getAddressSpace();
108 if (StrippedDest != MI->getArgOperand(0)) {
109 Type *SrcETy = cast<PointerType>(StrippedDest->
getType())
111 if (SrcETy->
isSized() &&
DL.getTypeStoreSize(SrcETy) == Size) {
123 if (M->getNumOperands() == 3 && M->getOperand(0) &&
124 mdconst::hasa<ConstantInt>(M->getOperand(0)) &&
125 mdconst::extract<ConstantInt>(M->getOperand(0))->isNullValue() &&
127 mdconst::hasa<ConstantInt>(M->getOperand(1)) &&
128 mdconst::extract<ConstantInt>(M->getOperand(1))->getValue() ==
130 M->getOperand(2) && isa<MDNode>(M->getOperand(2)))
131 CopyMD = cast<MDNode>(M->getOperand(2));
139 SrcAlign = std::max(SrcAlign, CopyAlign);
140 DstAlign = std::max(DstAlign, CopyAlign);
142 Value *Src = Builder->CreateBitCast(MI->getArgOperand(1), NewSrcPtrTy);
143 Value *Dest = Builder->CreateBitCast(MI->getArgOperand(0), NewDstPtrTy);
144 LoadInst *L = Builder->CreateLoad(Src, MI->isVolatile());
148 StoreInst *S = Builder->CreateStore(L, Dest, MI->isVolatile());
160 if (MI->getAlignment() < Alignment) {
172 Alignment = MI->getAlignment();
173 assert(Len &&
"0-sized memory setting should be removed already.");
179 Value *Dest = MI->getDest();
180 unsigned DstAddrSp = cast<PointerType>(Dest->getType())->getAddressSpace();
182 Dest = Builder->CreateBitCast(Dest, NewDstPtrTy);
185 if (Alignment == 0) Alignment = 1;
188 uint64_t Fill = FillC->getZExtValue()*0x0101010101010101ULL;
203 if (
auto *CInt = dyn_cast<ConstantInt>(II.
getArgOperand(2))) {
205 assert(VecTy->
getNumElements() == 4 &&
"insertps with wrong vector type");
212 uint8_t Imm = CInt->getZExtValue();
213 uint8_t ZMask = Imm & 0xf;
214 uint8_t DestLane = (Imm >> 4) & 0x3;
215 uint8_t SourceLane = (Imm >> 6) & 0x3;
225 int ShuffleMask[4] = { 0, 1, 2, 3 };
234 (ZMask & (1 << DestLane))) {
238 ShuffleMask[DestLane] = SourceLane;
240 for (
unsigned i = 0; i < 4; ++i)
241 if ((ZMask >> i) & 0x1)
242 ShuffleMask[i] = i + 4;
249 ShuffleMask[DestLane] = SourceLane + 4;
262 if (
auto *CInt = dyn_cast<ConstantInt>(II.
getArgOperand(2))) {
274 uint8_t Imm = CInt->getZExtValue();
276 bool LowHalfZero = Imm & 0x08;
277 bool HighHalfZero = Imm & 0x80;
281 if (LowHalfZero && HighHalfZero)
286 unsigned HalfSize = NumElts / 2;
290 bool LowInputSelect = Imm & 0x02;
291 bool HighInputSelect = Imm & 0x20;
295 bool LowHalfSelect = Imm & 0x01;
296 bool HighHalfSelect = Imm & 0x10;
303 V0 = LowHalfZero ? ZeroVector : V0;
304 V1 = HighHalfZero ? ZeroVector : V1;
307 unsigned StartIndex = LowHalfSelect ? HalfSize : 0;
308 for (
unsigned i = 0; i < HalfSize; ++i)
309 ShuffleMask[i] = StartIndex + i;
312 StartIndex = HighHalfSelect ? HalfSize : 0;
313 StartIndex += NumElts;
314 for (
unsigned i = 0; i < HalfSize; ++i)
315 ShuffleMask[i + HalfSize] = StartIndex + i;
330 return ReplaceInstUsesWith(CI, V);
333 return visitFree(CI);
344 if (!II)
return visitCallSite(&CI);
349 bool Changed =
false;
352 if (
Constant *NumBytes = dyn_cast<Constant>(MI->getLength())) {
353 if (NumBytes->isNullValue())
354 return EraseInstFromFunction(CI);
356 if (
ConstantInt *CI = dyn_cast<ConstantInt>(NumBytes))
357 if (CI->getZExtValue() == 1) {
365 if (MI->isVolatile())
371 if (
MemMoveInst *MMI = dyn_cast<MemMoveInst>(MI)) {
372 if (
GlobalVariable *GVSrc = dyn_cast<GlobalVariable>(MMI->getSource()))
373 if (GVSrc->isConstant()) {
386 if (MTI->getSource() == MTI->getDest())
387 return EraseInstFromFunction(CI);
392 if (isa<MemTransferInst>(MI)) {
395 }
else if (
MemSetInst *MSI = dyn_cast<MemSetInst>(MI)) {
400 if (Changed)
return II;
405 case Intrinsic::objectsize: {
411 case Intrinsic::bswap: {
417 return ReplaceInstUsesWith(CI, X);
424 Value *V = Builder->CreateLShr(X, CV);
430 case Intrinsic::powi:
439 if (Power->isAllOnesValue())
444 case Intrinsic::cttz: {
451 APInt KnownZero(BitWidth, 0);
452 APInt KnownOne(BitWidth, 0);
454 unsigned TrailingZeros = KnownOne.countTrailingZeros();
456 if ((Mask & KnownZero) == Mask)
458 APInt(BitWidth, TrailingZeros)));
462 case Intrinsic::ctlz: {
469 APInt KnownZero(BitWidth, 0);
470 APInt KnownOne(BitWidth, 0);
472 unsigned LeadingZeros = KnownOne.countLeadingZeros();
474 if ((Mask & KnownZero) == Mask)
476 APInt(BitWidth, LeadingZeros)));
481 case Intrinsic::uadd_with_overflow:
482 case Intrinsic::sadd_with_overflow:
483 case Intrinsic::umul_with_overflow:
484 case Intrinsic::smul_with_overflow:
495 case Intrinsic::usub_with_overflow:
496 case Intrinsic::ssub_with_overflow: {
501 Value *OperationResult =
nullptr;
505 return CreateOverflowTuple(II, OperationResult, OverflowResult);
517 return ReplaceInstUsesWith(CI, Arg0);
530 if (C1 && C1->isNaN())
531 return ReplaceInstUsesWith(CI, Arg0);
537 if (isa<UndefValue>(Arg0))
538 return ReplaceInstUsesWith(CI, Arg1);
541 if (isa<UndefValue>(Arg1))
542 return ReplaceInstUsesWith(CI, Arg0);
550 if (Arg0 == X || Arg0 == Y)
551 return ReplaceInstUsesWith(CI, Arg1);
557 if (Arg1 == X || Arg1 == Y)
558 return ReplaceInstUsesWith(CI, Arg0);
563 if (C1 && C1->isInfinity()) {
565 if (C1->isNegative())
566 return ReplaceInstUsesWith(CI, Arg1);
573 if (Arg0 == X || Arg0 == Y)
574 return ReplaceInstUsesWith(CI, Arg1);
580 if (Arg1 == X || Arg1 == Y)
581 return ReplaceInstUsesWith(CI, Arg0);
586 if (C1 && C1->isInfinity()) {
588 if (!C1->isNegative())
589 return ReplaceInstUsesWith(CI, Arg1);
594 case Intrinsic::ppc_altivec_lvx:
595 case Intrinsic::ppc_altivec_lvxl:
599 Value *Ptr = Builder->CreateBitCast(II->getArgOperand(0),
604 case Intrinsic::ppc_vsx_lxvw4x:
605 case Intrinsic::ppc_vsx_lxvd2x: {
607 Value *Ptr = Builder->CreateBitCast(II->getArgOperand(0),
611 case Intrinsic::ppc_altivec_stvx:
612 case Intrinsic::ppc_altivec_stvxl:
618 Value *Ptr = Builder->CreateBitCast(II->getArgOperand(1), OpPtrTy);
619 return new StoreInst(II->getArgOperand(0), Ptr);
622 case Intrinsic::ppc_vsx_stxvw4x:
623 case Intrinsic::ppc_vsx_stxvd2x: {
626 Value *Ptr = Builder->CreateBitCast(II->getArgOperand(1), OpPtrTy);
627 return new StoreInst(II->getArgOperand(0), Ptr,
false, 1);
629 case Intrinsic::ppc_qpx_qvlfs:
634 II->getType()->getVectorNumElements());
635 Value *Ptr = Builder->CreateBitCast(II->getArgOperand(0),
641 case Intrinsic::ppc_qpx_qvlfd:
645 Value *Ptr = Builder->CreateBitCast(II->getArgOperand(0),
650 case Intrinsic::ppc_qpx_qvstfs:
655 II->getArgOperand(0)->getType()->getVectorNumElements());
656 Value *TOp = Builder->CreateFPTrunc(II->getArgOperand(0), VTy);
658 Value *Ptr = Builder->CreateBitCast(II->getArgOperand(1), OpPtrTy);
662 case Intrinsic::ppc_qpx_qvstfd:
668 Value *Ptr = Builder->CreateBitCast(II->getArgOperand(1), OpPtrTy);
669 return new StoreInst(II->getArgOperand(0), Ptr);
672 case Intrinsic::x86_sse_storeu_ps:
673 case Intrinsic::x86_sse2_storeu_pd:
674 case Intrinsic::x86_sse2_storeu_dq:
680 Value *Ptr = Builder->CreateBitCast(II->getArgOperand(0), OpPtrTy);
681 return new StoreInst(II->getArgOperand(1), Ptr);
685 case Intrinsic::x86_sse_cvtss2si:
686 case Intrinsic::x86_sse_cvtss2si64:
687 case Intrinsic::x86_sse_cvttss2si:
688 case Intrinsic::x86_sse_cvttss2si64:
689 case Intrinsic::x86_sse2_cvtsd2si:
690 case Intrinsic::x86_sse2_cvtsd2si64:
691 case Intrinsic::x86_sse2_cvttsd2si:
692 case Intrinsic::x86_sse2_cvttsd2si64: {
696 cast<VectorType>(II->getArgOperand(0)->getType())->getNumElements();
697 APInt DemandedElts(VWidth, 1);
698 APInt UndefElts(VWidth, 0);
699 if (
Value *V = SimplifyDemandedVectorElts(II->getArgOperand(0),
700 DemandedElts, UndefElts)) {
701 II->setArgOperand(0, V);
710 case Intrinsic::x86_sse2_psll_d:
711 case Intrinsic::x86_sse2_psll_q:
712 case Intrinsic::x86_sse2_psll_w:
713 case Intrinsic::x86_sse2_pslli_d:
714 case Intrinsic::x86_sse2_pslli_q:
715 case Intrinsic::x86_sse2_pslli_w:
716 case Intrinsic::x86_avx2_psll_d:
717 case Intrinsic::x86_avx2_psll_q:
718 case Intrinsic::x86_avx2_psll_w:
719 case Intrinsic::x86_avx2_pslli_d:
720 case Intrinsic::x86_avx2_pslli_q:
721 case Intrinsic::x86_avx2_pslli_w:
722 case Intrinsic::x86_sse2_psrl_d:
723 case Intrinsic::x86_sse2_psrl_q:
724 case Intrinsic::x86_sse2_psrl_w:
725 case Intrinsic::x86_sse2_psrli_d:
726 case Intrinsic::x86_sse2_psrli_q:
727 case Intrinsic::x86_sse2_psrli_w:
728 case Intrinsic::x86_avx2_psrl_d:
729 case Intrinsic::x86_avx2_psrl_q:
730 case Intrinsic::x86_avx2_psrl_w:
731 case Intrinsic::x86_avx2_psrli_d:
732 case Intrinsic::x86_avx2_psrli_q:
733 case Intrinsic::x86_avx2_psrli_w: {
742 Count = cast<ConstantInt>(CDV->getElementAsConstant(0));
746 auto Vec = II->getArgOperand(0);
747 auto VT = cast<VectorType>(Vec->getType());
748 if (Count->getZExtValue() >
749 VT->getElementType()->getPrimitiveSizeInBits() - 1)
750 return ReplaceInstUsesWith(
753 bool isPackedShiftLeft =
true;
754 switch (II->getIntrinsicID()) {
756 case Intrinsic::x86_sse2_psrl_d:
757 case Intrinsic::x86_sse2_psrl_q:
758 case Intrinsic::x86_sse2_psrl_w:
759 case Intrinsic::x86_sse2_psrli_d:
760 case Intrinsic::x86_sse2_psrli_q:
761 case Intrinsic::x86_sse2_psrli_w:
762 case Intrinsic::x86_avx2_psrl_d:
763 case Intrinsic::x86_avx2_psrl_q:
764 case Intrinsic::x86_avx2_psrl_w:
765 case Intrinsic::x86_avx2_psrli_d:
766 case Intrinsic::x86_avx2_psrli_q:
767 case Intrinsic::x86_avx2_psrli_w: isPackedShiftLeft =
false;
break;
770 unsigned VWidth = VT->getNumElements();
773 if (isPackedShiftLeft)
774 return BinaryOperator::CreateShl(Vec,
775 Builder->CreateVectorSplat(VWidth, VTCI));
777 return BinaryOperator::CreateLShr(Vec,
778 Builder->CreateVectorSplat(VWidth, VTCI));
781 case Intrinsic::x86_sse41_pmovsxbw:
782 case Intrinsic::x86_sse41_pmovsxwd:
783 case Intrinsic::x86_sse41_pmovsxdq:
784 case Intrinsic::x86_sse41_pmovzxbw:
785 case Intrinsic::x86_sse41_pmovzxwd:
786 case Intrinsic::x86_sse41_pmovzxdq: {
789 cast<VectorType>(II->getArgOperand(0)->getType())->getNumElements();
790 unsigned LowHalfElts = VWidth / 2;
792 APInt UndefElts(VWidth, 0);
793 if (
Value *TmpV = SimplifyDemandedVectorElts(
794 II->getArgOperand(0), InputDemandedElts, UndefElts)) {
795 II->setArgOperand(0, TmpV);
800 case Intrinsic::x86_sse41_insertps:
802 return ReplaceInstUsesWith(*II, V);
805 case Intrinsic::x86_sse4a_insertqi: {
809 if (
auto CIWidth = dyn_cast<ConstantInt>(II->getArgOperand(2))) {
810 if (
auto CIStart = dyn_cast<ConstantInt>(II->getArgOperand(3))) {
811 unsigned Index = CIStart->getZExtValue();
814 unsigned Length = CIWidth->equalsInt(0) ? 64 : CIWidth->getZExtValue();
823 if ((Index + Length) > 64)
826 if (Length == 64 && Index == 0) {
827 Value *Vec = II->getArgOperand(1);
829 const uint32_t Mask[] = { 0, 2 };
830 return ReplaceInstUsesWith(
832 Builder->CreateShuffleVector(
837 dyn_cast<IntrinsicInst>(II->getArgOperand(0))) {
838 if (
Source->hasOneUse() &&
839 Source->getArgOperand(1) == II->getArgOperand(1)) {
847 if (CISourceStart && CISourceWidth) {
849 unsigned Width = CIWidth->getZExtValue();
850 unsigned End = Start + Width;
851 unsigned SourceStart = CISourceStart->getZExtValue();
852 unsigned SourceWidth = CISourceWidth->getZExtValue();
853 unsigned SourceEnd = SourceStart + SourceWidth;
854 unsigned NewStart, NewWidth;
855 bool ShouldReplace =
false;
856 if (Start <= SourceStart && SourceStart <= End) {
858 NewWidth = std::max(End, SourceEnd) - NewStart;
859 ShouldReplace =
true;
860 }
else if (SourceStart <= Start && Start <= SourceEnd) {
861 NewStart = SourceStart;
862 NewWidth = std::max(SourceEnd, End) - NewStart;
863 ShouldReplace =
true;
868 II->getArgOperand(2)->getType(), NewWidth,
false);
870 II->getArgOperand(3)->getType(), NewStart,
false);
872 II->getArgOperand(1), ConstantWidth,
877 return ReplaceInstUsesWith(CI, Builder->CreateCall(F, Args));
887 case Intrinsic::x86_sse41_pblendvb:
888 case Intrinsic::x86_sse41_blendvps:
889 case Intrinsic::x86_sse41_blendvpd:
890 case Intrinsic::x86_avx_blendv_ps_256:
891 case Intrinsic::x86_avx_blendv_pd_256:
892 case Intrinsic::x86_avx2_pblendvb: {
897 Value *Mask = II->getArgOperand(2);
898 if (
auto C = dyn_cast<ConstantDataVector>(Mask)) {
899 auto Tyi1 = Builder->getInt1Ty();
900 auto SelectorType = cast<VectorType>(Mask->
getType());
901 auto EltTy = SelectorType->getElementType();
902 unsigned Size = SelectorType->getNumElements();
906 : (EltTy->isDoubleTy() ? 64 : EltTy->getIntegerBitWidth());
907 assert((BitWidth == 64 || BitWidth == 32 || BitWidth == 8) &&
908 "Wrong arguments for variable blend intrinsic");
910 for (
unsigned I = 0;
I < Size; ++
I) {
914 Selector = C->getElementAsInteger(
I);
916 Selector = C->getElementAsAPFloat(
I).bitcastToAPInt().getZExtValue();
921 II->getArgOperand(0),
"blendv");
927 case Intrinsic::x86_avx_vpermilvar_ps:
928 case Intrinsic::x86_avx_vpermilvar_ps_256:
929 case Intrinsic::x86_avx_vpermilvar_pd:
930 case Intrinsic::x86_avx_vpermilvar_pd_256: {
932 Value *V = II->getArgOperand(1);
933 unsigned Size = cast<VectorType>(V->
getType())->getNumElements();
934 assert(Size == 8 || Size == 4 || Size == 2);
936 if (
auto C = dyn_cast<ConstantDataVector>(V)) {
938 for (
unsigned I = 0;
I < Size; ++
I) {
939 uint32_t Index = C->getElementAsInteger(
I) & 0x3;
940 if (II->getIntrinsicID() == Intrinsic::x86_avx_vpermilvar_pd ||
941 II->getIntrinsicID() == Intrinsic::x86_avx_vpermilvar_pd_256)
945 }
else if (isa<ConstantAggregateZero>(V)) {
946 for (
unsigned I = 0;
I < Size; ++
I)
954 if (II->getIntrinsicID() == Intrinsic::x86_avx_vpermilvar_ps_256 ||
955 II->getIntrinsicID() == Intrinsic::x86_avx_vpermilvar_pd_256) {
956 for (
unsigned I = Size / 2;
I < Size; ++
I)
957 Indexes[
I] += Size / 2;
961 auto V1 = II->getArgOperand(0);
963 auto Shuffle = Builder->CreateShuffleVector(V1,
V2, NewC);
964 return ReplaceInstUsesWith(CI, Shuffle);
967 case Intrinsic::x86_avx_vperm2f128_pd_256:
968 case Intrinsic::x86_avx_vperm2f128_ps_256:
969 case Intrinsic::x86_avx_vperm2f128_si_256:
970 case Intrinsic::x86_avx2_vperm2i128:
972 return ReplaceInstUsesWith(*II, V);
975 case Intrinsic::ppc_altivec_vperm:
982 if (
Constant *Mask = dyn_cast<Constant>(II->getArgOperand(2))) {
983 assert(Mask->getType()->getVectorNumElements() == 16 &&
984 "Bad type for intrinsic!");
987 bool AllEltsOk =
true;
988 for (
unsigned i = 0; i != 16; ++i) {
990 if (!Elt || !(isa<ConstantInt>(Elt) || isa<UndefValue>(Elt))) {
998 Value *Op0 = Builder->CreateBitCast(II->getArgOperand(0),
1000 Value *Op1 = Builder->CreateBitCast(II->getArgOperand(1),
1005 Value *ExtractedElts[32];
1006 memset(ExtractedElts, 0,
sizeof(ExtractedElts));
1008 for (
unsigned i = 0; i != 16; ++i) {
1009 if (isa<UndefValue>(Mask->getAggregateElement(i)))
1012 cast<ConstantInt>(Mask->getAggregateElement(i))->getZExtValue();
1014 if (
DL.isLittleEndian())
1017 if (!ExtractedElts[Idx]) {
1018 Value *Op0ToUse = (
DL.isLittleEndian()) ? Op1 : Op0;
1019 Value *Op1ToUse = (
DL.isLittleEndian()) ? Op0 : Op1;
1020 ExtractedElts[Idx] =
1021 Builder->CreateExtractElement(Idx < 16 ? Op0ToUse : Op1ToUse,
1022 Builder->getInt32(Idx&15));
1026 Result = Builder->CreateInsertElement(Result, ExtractedElts[Idx],
1027 Builder->getInt32(i));
1034 case Intrinsic::arm_neon_vld1:
1035 case Intrinsic::arm_neon_vld2:
1036 case Intrinsic::arm_neon_vld3:
1037 case Intrinsic::arm_neon_vld4:
1038 case Intrinsic::arm_neon_vld2lane:
1039 case Intrinsic::arm_neon_vld3lane:
1040 case Intrinsic::arm_neon_vld4lane:
1041 case Intrinsic::arm_neon_vst1:
1042 case Intrinsic::arm_neon_vst2:
1043 case Intrinsic::arm_neon_vst3:
1044 case Intrinsic::arm_neon_vst4:
1045 case Intrinsic::arm_neon_vst2lane:
1046 case Intrinsic::arm_neon_vst3lane:
1047 case Intrinsic::arm_neon_vst4lane: {
1049 unsigned AlignArg = II->getNumArgOperands() - 1;
1051 if (IntrAlign && IntrAlign->
getZExtValue() < MemAlign) {
1052 II->setArgOperand(AlignArg,
1060 case Intrinsic::arm_neon_vmulls:
1061 case Intrinsic::arm_neon_vmullu:
1062 case Intrinsic::aarch64_neon_smull:
1063 case Intrinsic::aarch64_neon_umull: {
1064 Value *Arg0 = II->getArgOperand(0);
1065 Value *Arg1 = II->getArgOperand(1);
1068 if (isa<ConstantAggregateZero>(Arg0) || isa<ConstantAggregateZero>(Arg1)) {
1073 bool Zext = (II->getIntrinsicID() == Intrinsic::arm_neon_vmullu ||
1074 II->getIntrinsicID() == Intrinsic::aarch64_neon_umull);
1075 VectorType *NewVT = cast<VectorType>(II->getType());
1076 if (
Constant *CV0 = dyn_cast<Constant>(Arg0)) {
1077 if (
Constant *CV1 = dyn_cast<Constant>(Arg1)) {
1089 if (
Constant *CV1 = dyn_cast<Constant>(Arg1))
1091 dyn_cast_or_null<ConstantInt>(CV1->getSplatValue()))
1099 case Intrinsic::AMDGPU_rcp: {
1100 if (
const ConstantFP *C = dyn_cast<ConstantFP>(II->getArgOperand(0))) {
1101 const APFloat &ArgVal = C->getValueAPF();
1108 return ReplaceInstUsesWith(CI,
ConstantFP::get(II->getContext(), Val));
1113 case Intrinsic::stackrestore: {
1116 if (
IntrinsicInst *
SS = dyn_cast<IntrinsicInst>(II->getArgOperand(0))) {
1117 if (
SS->getIntrinsicID() == Intrinsic::stacksave) {
1120 return EraseInstFromFunction(CI);
1128 bool CannotRemove =
false;
1129 for (++BI; &*BI != TI; ++BI) {
1130 if (isa<AllocaInst>(BI)) {
1131 CannotRemove =
true;
1134 if (
CallInst *BCI = dyn_cast<CallInst>(BI)) {
1137 if (II->getIntrinsicID() == Intrinsic::stackrestore)
1138 return EraseInstFromFunction(CI);
1143 CannotRemove =
true;
1152 if (!CannotRemove && (isa<ReturnInst>(TI) || isa<ResumeInst>(TI)))
1153 return EraseInstFromFunction(CI);
1156 case Intrinsic::assume: {
1160 Value *IIOperand = II->getArgOperand(0), *
A, *B,
1161 *AssumeIntrinsic = II->getCalledValue();
1163 Builder->CreateCall(AssumeIntrinsic,
A, II->getName());
1164 Builder->CreateCall(AssumeIntrinsic, B, II->getName());
1165 return EraseInstFromFunction(*II);
1169 Builder->CreateCall(AssumeIntrinsic, Builder->CreateNot(
A),
1171 Builder->CreateCall(AssumeIntrinsic, Builder->CreateNot(B),
1173 return EraseInstFromFunction(*II);
1178 if (
ICmpInst* ICmp = dyn_cast<ICmpInst>(IIOperand)) {
1179 Value *LHS = ICmp->getOperand(0);
1180 Value *RHS = ICmp->getOperand(1);
1182 isa<LoadInst>(LHS) &&
1183 isa<Constant>(RHS) &&
1185 cast<Constant>(RHS)->isNullValue()) {
1186 LoadInst* LI = cast<LoadInst>(LHS);
1190 return EraseInstFromFunction(*II);
1198 APInt KnownZero(1, 0), KnownOne(1, 0);
1201 return EraseInstFromFunction(*II);
1205 case Intrinsic::experimental_gc_relocate: {
1211 auto *GCRelocateType = cast<PointerType>(II->getType());
1215 if (II->use_empty())
1216 return EraseInstFromFunction(*II);
1222 if (isa<UndefValue>(DerivedPtr)) {
1230 if (isa<ConstantPointerNull>(DerivedPtr)) {
1241 if (
Argument *
A = dyn_cast<Argument>(DerivedPtr)) {
1242 uint64_t Bytes =
A->getDereferenceableBytes();
1254 return visitCallSite(II);
1260 return visitCallSite(&II);
1288 Type* DstTy = cast<PointerType>(CI->
getType())->getElementType();
1304 ReplaceInstUsesWith(*From, With);
1307 if (
Value *With = Simplifier.optimizeCall(CI)) {
1309 return CI->
use_empty() ? CI : ReplaceInstUsesWith(*CI, With);
1319 if (Underlying != TrampMem &&
1322 if (!isa<AllocaInst>(Underlying))
1334 InitTrampoline = II;
1344 if (!InitTrampoline)
1348 if (InitTrampoline->
getOperand(0) != TrampMem)
1351 return InitTrampoline;
1362 if (II->getIntrinsicID() == Intrinsic::init_trampoline &&
1363 II->getOperand(0) == TrampMem)
1398 bool Changed =
false;
1415 assert(ArgNo == CS.
arg_size() &&
"sanity check");
1420 if (!isa<Function>(Callee) && transformConstExprCastCall(CS))
1423 if (
Function *CalleeF = dyn_cast<Function>(Callee))
1430 !CalleeF->isDeclaration()) {
1439 if (isa<CallInst>(OldCall))
1440 return EraseInstFromFunction(*OldCall);
1444 cast<InvokeInst>(OldCall)->setCalledFunction(
1449 if (isa<ConstantPointerNull>(Callee) || isa<UndefValue>(Callee)) {
1472 return transformCallThroughTrampoline(CS, II);
1474 PointerType *PTy = cast<PointerType>(Callee->getType());
1476 if (FTy->isVarArg()) {
1503 if (I)
return EraseInstFromFunction(*I);
1512 bool InstCombiner::transformConstExprCastCall(
CallSite CS) {
1533 if (OldRetTy != NewRetTy) {
1559 if (
InvokeInst *II = dyn_cast<InvokeInst>(Caller))
1561 if (
PHINode *PN = dyn_cast<PHINode>(U))
1562 if (PN->getParent() == II->getNormalDest() ||
1563 PN->getParent() == II->getUnwindDest())
1567 unsigned NumActualArgs = CS.
arg_size();
1583 for (
unsigned i = 0, e = NumCommonArgs; i != e; ++i, ++AI) {
1585 Type *ActTy = (*AI)->getType();
1599 if (ParamTy != ActTy &&
1607 if (
DL.getTypeAllocSize(CurElTy) !=
1640 for (
unsigned i = CallerPAL.
getNumSlots(); i; --i) {
1642 if (Index <= FT->getNumParams())
1654 std::vector<Value*> Args;
1655 Args.reserve(NumActualArgs);
1657 attrVec.
reserve(NumCommonArgs);
1667 if (RAttrs.hasAttributes())
1672 for (
unsigned i = 0; i != NumCommonArgs; ++i, ++AI) {
1675 if ((*AI)->getType() == ParamTy) {
1676 Args.push_back(*AI);
1678 Args.push_back(Builder->CreateBitOrPointerCast(*AI, ParamTy));
1690 for (
unsigned i = NumCommonArgs; i != FT->
getNumParams(); ++i)
1698 for (
unsigned i = FT->
getNumParams(); i != NumActualArgs; ++i, ++AI) {
1700 if (PTy != (*AI)->getType()) {
1704 Args.push_back(Builder->CreateCast(opcode, *AI, PTy));
1706 Args.push_back(*AI);
1729 if (
InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
1730 NC = Builder->CreateInvoke(Callee, II->getNormalDest(),
1731 II->getUnwindDest(), Args);
1733 cast<InvokeInst>(
NC)->setCallingConv(II->getCallingConv());
1734 cast<InvokeInst>(
NC)->setAttributes(NewCallerPAL);
1736 CallInst *CI = cast<CallInst>(Caller);
1737 NC = Builder->CreateCall(Callee, Args);
1740 cast<CallInst>(NC)->setTailCall();
1742 cast<CallInst>(
NC)->setAttributes(NewCallerPAL);
1754 if (
InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
1756 InsertNewInstBefore(NC, *I);
1759 InsertNewInstBefore(NC, *Caller);
1761 Worklist.AddUsersToWorkList(*Caller);
1768 ReplaceInstUsesWith(*Caller, NV);
1770 if (OldRetTy == NV->
getType())
1778 EraseInstFromFunction(*Caller);
1787 InstCombiner::transformCallThroughTrampoline(
CallSite CS,
1800 "transformCallThroughTrampoline called with incorrect CallSite.");
1804 FunctionType *NestFTy = cast<FunctionType>(NestFPTy->getElementType());
1807 if (!NestAttrs.isEmpty()) {
1808 unsigned NestIdx = 1;
1809 Type *NestTy =
nullptr;
1814 E = NestFTy->param_end(); I != E; ++NestIdx, ++
I)
1824 std::vector<Value*> NewArgs;
1825 NewArgs.reserve(CS.
arg_size() + 1);
1828 NewAttrs.
reserve(Attrs.getNumSlots() + 1);
1836 Attrs.getRetAttributes()));
1842 if (Idx == NestIdx) {
1845 if (NestVal->
getType() != NestTy)
1846 NestVal = Builder->CreateBitCast(NestVal, NestTy,
"nest");
1847 NewArgs.push_back(NestVal);
1856 NewArgs.push_back(*I);
1861 Idx + (Idx >= NestIdx), B));
1870 NewAttrs.
push_back(AttributeSet::get(FTy->getContext(),
1871 Attrs.getFnAttributes()));
1877 std::vector<Type*> NewTypes;
1878 NewTypes.reserve(FTy->getNumParams()+1);
1885 E = FTy->param_end();
1890 NewTypes.push_back(NestTy);
1896 NewTypes.push_back(*I);
1911 AttributeSet::get(FTy->getContext(), NewAttrs);
1914 if (
InvokeInst *II = dyn_cast<InvokeInst>(Caller)) {
1916 II->getNormalDest(), II->getUnwindDest(),
1918 cast<InvokeInst>(NewCaller)->setCallingConv(II->getCallingConv());
1919 cast<InvokeInst>(NewCaller)->setAttributes(NewPAL);
1922 if (cast<CallInst>(Caller)->isTailCall())
1923 cast<CallInst>(NewCaller)->setTailCall();
1924 cast<CallInst>(NewCaller)->
1925 setCallingConv(cast<CallInst>(Caller)->getCallingConv());
1926 cast<CallInst>(NewCaller)->setAttributes(NewPAL);
1937 NestF->
getType() == PTy ? NestF :
ConstantDataVector - A vector constant whose element type is a simple 1/2/4/8-byte integer or float/d...
BinaryOp_match< LHS, RHS, Instruction::And > m_And(const LHS &L, const RHS &R)
LibCallSimplifier - This class implements a collection of optimizations that replace well formed call...
opStatus divide(const APFloat &, roundingMode)
const Value * getCalledValue() const
getCalledValue - Get a pointer to the function that is invoked by this instruction.
void push_back(const T &Elt)
m_Intrinsic_Ty< Opnd0, Opnd1 >::Ty m_FMin(const Opnd0 &Op0, const Opnd1 &Op1)
A parsed version of the target data layout string in and methods for querying it. ...
IntegerType * getType() const
getType - Specialize the getType() method to always return an IntegerType, which reduces the amount o...
class_match< Value > m_Value()
Match an arbitrary value and ignore it.
static void ValueIsDeleted(Value *V)
Value * SimplifyCall(Value *V, User::op_iterator ArgBegin, User::op_iterator ArgEnd, const DataLayout &DL, const TargetLibraryInfo *TLI=nullptr, const DominatorTree *DT=nullptr, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr)
Given a function and iterators over arguments, see if we can fold the result.
unsigned getOrEnforceKnownAlignment(Value *V, unsigned PrefAlign, const DataLayout &DL, const Instruction *CxtI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr)
getOrEnforceKnownAlignment - If the specified pointer has an alignment that we can determine...
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
LLVM Argument representation.
STATISTIC(NumFunctions,"Total number of functions")
AttributeSet getParamAttributes(unsigned Index) const
The attributes for the specified index are returned.
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. ...
Instruction * visitCallInst(CallInst &CI)
visitCallInst - CallInst simplification.
m_Intrinsic_Ty< Opnd0, Opnd1 >::Ty m_FMax(const Opnd0 &Op0, const Opnd1 &Op1)
static CastInst * CreateBitOrPointerCast(Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=0)
Create a BitCast, a PtrToInt, or an IntToPTr cast instruction.
InstrTy * getInstruction() const
Intrinsic::ID getIntrinsicID() const
getIntrinsicID - Return the intrinsic ID of this intrinsic.
Nested function static chain.
static ConstantAggregateZero * get(Type *Ty)
Type::subtype_iterator param_iterator
bool getObjectSize(const Value *Ptr, uint64_t &Size, const DataLayout &DL, const TargetLibraryInfo *TLI, bool RoundToAlign=false)
Compute the size of the object pointed by Ptr.
CallInst - This class represents a function call, abstracting a target machine's calling convention...
static APInt getLowBitsSet(unsigned numBits, unsigned loBitsSet)
Get a value with low bits set.
void computeKnownBits(Value *V, APInt &KnownZero, APInt &KnownOne, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr)
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOn...
static PointerType * get(Type *ElementType, unsigned AddressSpace)
PointerType::get - This constructs a pointer to an object of the specified type in a numbered address...
m_Intrinsic_Ty< Opnd0 >::Ty m_BSwap(const Opnd0 &Op0)
opStatus
IEEE-754R 7: Default exception handling.
MemSetInst - This class wraps the llvm.memset intrinsic.
void setAttributes(const AttributeSet &PAL)
const Function * getParent() const
Return the enclosing method, or null if none.
bool isValidAssumeForContext(const Instruction *I, const Instruction *CxtI, const DominatorTree *DT=nullptr)
Return true if it is valid to use the assumptions provided by an assume intrinsic, I, at the point in the control-flow identified by the context instruction, CxtI.
LoadInst - an instruction for reading from memory.
unsigned getBitWidth() const
Get the number of bits in this IntegerType.
User::op_iterator arg_iterator
arg_iterator - The type of iterator to use when looping over actual arguments at this call site...
static OverflowCheckFlavor IntrinsicIDToOverflowCheckFlavor(unsigned ID)
Returns the OverflowCheckFlavor corresponding to a overflow_with_op intrinsic.
void reserve(size_type N)
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
Value * CreateShuffleVector(Value *V1, Value *V2, Value *Mask, const Twine &Name="")
bool isByValOrInAllocaArgument(unsigned ArgNo) const
Determine whether this argument is passed by value or in an alloca.
Type * getPointerElementType() const
const CallInst * isFreeCall(const Value *I, const TargetLibraryInfo *TLI)
isFreeCall - Returns non-null if the value is a call to the builtin free()
static Constant * getNullValue(Type *Ty)
static bool isBitOrNoopPointerCastable(Type *SrcTy, Type *DestTy, const DataLayout &DL)
Check whether a bitcast, inttoptr, or ptrtoint cast between these types is valid and a no-op...
iterator begin()
Instruction iterator methods.
bool isSingleValueType() const
isSingleValueType - Return true if the type is a valid type for a register in codegen.
bool match(Val *V, const Pattern &P)
Instruction * visitInvokeInst(InvokeInst &II)
static Constant * getIntegerCast(Constant *C, Type *Ty, bool isSigned)
Create a ZExt, Bitcast or Trunc for integer -> integer casts.
bool doesNotThrow() const
Determine if the function cannot unwind.
OverflowCheckFlavor
Specific patterns of overflow check idioms that we match.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static CallInst * Create(Value *Func, ArrayRef< Value * > Args, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static cl::opt< ITMode > IT(cl::desc("IT block support"), cl::Hidden, cl::init(DefaultIT), cl::ZeroOrMore, cl::values(clEnumValN(DefaultIT,"arm-default-it","Generate IT block based on arch"), clEnumValN(RestrictedIT,"arm-restrict-it","Disallow deprecated IT based on ARMv8"), clEnumValN(NoRestrictedIT,"arm-no-restrict-it","Allow IT blocks based on ARMv7"), clEnumValEnd))
This is the base class for all instructions that perform data casts.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
MemMoveInst - This class wraps the llvm.memmove intrinsic.
StructType - Class to represent struct types.
bool isDereferenceablePointer(const Value *V, const DataLayout &DL, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr, const TargetLibraryInfo *TLI=nullptr)
isDereferenceablePointer - Return true if this is always a dereferenceable pointer.
CastClass_match< OpTy, Instruction::Trunc > m_Trunc(const OpTy &Op)
Matches Trunc.
static Constant * get(ArrayRef< Constant * > V)
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
static bool isSafeToEliminateVarargsCast(const CallSite CS, const DataLayout &DL, const CastInst *const CI, const int ix)
isSafeToEliminateVarargsCast - If this cast does not affect the value passed through the varargs area...
bool doesNotThrow() const
Determine if the call cannot unwind.
bool isSized(SmallPtrSetImpl< const Type * > *Visited=nullptr) const
isSized - Return true if it makes sense to take the size of this type.
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
void setName(const Twine &Name)
Change the name of the value.
Hidden pointer to structure to return.
not_match< LHS > m_Not(const LHS &L)
static IntrinsicInst * FindInitTrampolineFromBB(IntrinsicInst *AdjustTramp, Value *TrampMem)
bool doesNotThrow() const
Determine if the call cannot unwind.
ConstantAggregateZero - All zero aggregate value.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
bool isStatepoint(const ImmutableCallSite &CS)
iterator_range< IterTy > args() const
FunctionType - Class to represent function types.
static IntrinsicInst * FindInitTrampoline(Value *Callee)
static SelectInst * Create(Value *C, Value *S1, Value *S2, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
LLVMContext & getContext() const
getContext - Return the LLVMContext in which this type was uniqued.
ValTy * getCalledValue() const
getCalledValue - Return the pointer to function that is being called.
ArrayType - Class to represent array types.
uint64_t getLimitedValue(uint64_t Limit=~0ULL) const
getLimitedValue - If the value is smaller than the specified limit, return it, otherwise return the l...
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
FunctionType::get - This static method is the primary way of constructing a FunctionType.
Function * getDeclaration(Module *M, ID id, ArrayRef< Type * > Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
StoreInst - an instruction for storing to memory.
static void ValueIsRAUWd(Value *Old, Value *New)
unsigned getNumElements() const
Return the number of elements in the Vector type.
void takeName(Value *V)
Transfer the name from V to this value.
Type * getElementType() const
This class represents a truncation of integer types.
static unsigned getKnownAlignment(Value *V, const DataLayout &DL, const Instruction *CxtI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr)
getKnownAlignment - Try to infer an alignment for the specified pointer.
PointerType - Class to represent pointers.
static APInt getHighBitsSet(unsigned numBits, unsigned hiBitsSet)
Get a value with high bits set.
static Constant * getBitCast(Constant *C, Type *Ty, bool OnlyIfReduced=false)
A self-contained host- and target-independent arbitrary-precision floating-point software implementat...
unsigned getNumSlots() const
Return the number of slots used in this attribute list.
Type * getParamType(unsigned i) const
Parameter type accessors.
bool isLosslessCast() const
A lossless cast is one that does not alter the basic value.
Subclasses of this class are all able to terminate a basic block.
static ConstantPointerNull * get(PointerType *T)
get() - Static factory methods - Return objects of the specified value
The instances of the Type class are immutable: once they are created, they are never changed...
BinaryOp_match< LHS, RHS, Instruction::Or > m_Or(const LHS &L, const RHS &R)
AttributeSet getSlotAttributes(unsigned Slot) const
Return the attributes at the given slot.
static Type * reduceToSingleValueType(Type *T)
reduceToSingleValueType - Given an aggregate type which ultimately holds a single scalar element...
This is an important base class in LLVM.
bool isGCRelocate(const Value *V)
ConstantFP - Floating Point Values [float, double].
const DebugLoc & getDebugLoc() const
getDebugLoc - Return the debug location for this node as a DebugLoc.
Pass structure in an alloca.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
This instruction compares its operands according to the predicate given to the constructor.
Value * getOperand(unsigned i) const
Class to represent integer types.
bool hasValueHandle() const
Return true if there is a value handle associated with this value.
Wraps a call to a gc.relocate and provides access to it's operands.
Constant * getAggregateElement(unsigned Elt) const
getAggregateElement - For aggregates (struct/array/vector) return the constant that corresponds to th...
void setAlignment(unsigned Align)
bool isPointerTy() const
isPointerTy - True if this is an instance of PointerType.
static UndefValue * get(Type *T)
get() - Static factory methods - Return an 'undef' object of the specified type.
LLVMContext & getContext() const
All values hold a context through their type.
void setMetadata(unsigned KindID, MDNode *Node)
setMetadata - Set the metadata of the specified kind to the specified node.
LLVM_READONLY APFloat maxnum(const APFloat &A, const APFloat &B)
Implements IEEE maxNum semantics.
bool mayWriteToMemory() const
mayWriteToMemory - Return true if this instruction may modify memory.
Pointer is known to be not null.
static IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
static InvokeInst * Create(Value *Func, BasicBlock *IfNormal, BasicBlock *IfException, ArrayRef< Value * > Args, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static CastInst * CreateIntegerCast(Value *S, Type *Ty, bool isSigned, const Twine &Name="", Instruction *InsertBefore=nullptr)
Create a ZExt, BitCast, or Trunc for int -> int casts.
MemIntrinsic - This is the common base class for memset/memcpy/memmove.
static PointerType * getInt1PtrTy(LLVMContext &C, unsigned AS=0)
static PointerType * getUnqual(Type *ElementType)
PointerType::getUnqual - This constructs a pointer to an object of the specified type in the generic ...
This is the shared class of boolean and integer constants.
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
bool paramHasAttr(unsigned i, Attribute::AttrKind A) const
Return true if the call or the callee has the given attribute.
Value * getDest() const
getDest - This is just like getRawDest, but it strips off any cast instructions that feed it...
Type * getType() const
All values are typed, get the type of this value.
static IntrinsicInst * FindInitTrampolineFromAlloca(Value *TrampMem)
unsigned arg_size() 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...
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.
bool isInAllocaArgument(unsigned ArgNo) const
Determine whether this argument is passed in an alloca.
static Value * SimplifyX86vperm2(const IntrinsicInst &II, InstCombiner::BuilderTy &Builder)
The shuffle mask for a perm2*128 selects any two halves of two 256-bit source vectors, unless a zero bit is set.
static ConstantInt * getTrue(LLVMContext &Context)
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
AttributeSet getAttributes() const
Return the attribute list for this Function.
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
VectorType - Class to represent vector types.
Class for arbitrary precision integers.
bool isIntegerTy() const
isIntegerTy - True if this is an instance of IntegerType.
iterator_range< user_iterator > users()
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)
bool isKnownNonNull(const Value *V, const TargetLibraryInfo *TLI=nullptr)
isKnownNonNull - Return true if this pointer couldn't possibly be null by its definition.
static APInt getBitsSet(unsigned numBits, unsigned loBit, unsigned hiBit)
Get a value with a block of bits set.
static Value * SimplifyX86insertps(const IntrinsicInst &II, InstCombiner::BuilderTy &Builder)
bool isStructTy() const
isStructTy - True if this is an instance of StructType.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
bool isAllOnesValue() const
Determine if all bits are set.
static CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", Instruction *InsertBefore=nullptr)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's ...
uint64_t MinAlign(uint64_t A, uint64_t B)
MinAlign - A and B are either alignments or offsets.
PointerType * getType() const
Global values are always pointers.
void setCalledFunction(Value *Fn)
setCalledFunction - Set the function called.
MemTransferInst - This class wraps the llvm.memcpy/memmove intrinsics.
AttributeSet addAttribute(LLVMContext &C, unsigned Index, Attribute::AttrKind Attr) const
Add an attribute to the attribute set at the given index.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Return true if the function has the attribute.
static IntegerType * getInt32Ty(LLVMContext &C)
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
unsigned getSlotIndex(unsigned Slot) const
Return the index for the given slot.
bool hasAttrSomewhere(Attribute::AttrKind Attr) const
Return true if the specified attribute is set for at least one parameter or for the return value...
void setCalledFunction(Value *V)
setCalledFunction - Set the callee to the specified value.
bool hasAttributes(unsigned Index) const
Return true if attribute exists at the given index.
AttrBuilder typeIncompatible(const Type *Ty)
Which attributes cannot be applied to a type.
static Instruction::CastOps getCastOpcode(const Value *Val, bool SrcIsSigned, Type *Ty, bool DstIsSigned)
Returns the opcode necessary to cast Val into Ty using usual casting rules.
CallingConv::ID getCallingConv() const
getCallingConv/setCallingConv - get or set the calling convention of the call.
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
FunctionType * getFunctionType() const
bool hasOneUse() const
Return true if there is exactly one user of this value.
void setArgOperand(unsigned i, Value *v)
bool isAllocLikeFn(const Value *V, const TargetLibraryInfo *TLI, bool LookThroughBitCast=false)
Tests if a value is a call or invoke to a library function that allocates memory (either malloc...
const AttributeSet & getAttributes() const
getAttributes/setAttributes - get or set the parameter attributes of the call.
iterator_range< op_iterator > arg_operands()
arg_operands - iteration adapter for range-for loops.
Type * getReturnType() const
unsigned getPrimitiveSizeInBits() const LLVM_READONLY
getPrimitiveSizeInBits - 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.
void setAlignment(unsigned Align)
This file provides internal interfaces used to implement the InstCombine.
static VectorType * get(Type *ElementType, unsigned NumElements)
VectorType::get - This static method is the primary way to construct an VectorType.
InvokeInst - Invoke instruction.
IterTy arg_begin() const
arg_begin/arg_end - Return iterators corresponding to the actual argument list for a call site...
bool isPowerOf2_32(uint32_t Value)
isPowerOf2_32 - This function returns true if the argument is a power of two > 0. ...
CallingConv::ID getCallingConv() const
getCallingConv/setCallingConv - Get or set the calling convention of this function call...
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml","ocaml 3.10-compatible collector")
static Constant * getMul(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
bool isGCResult(const Value *V)
static Constant * get(LLVMContext &Context, ArrayRef< uint8_t > Elts)
get() constructors - Return a constant with vector type with an element count and element type matchi...
This class represents an extension of floating point types.
bool isEmpty() const
Return true if there are no attributes.
const fltSemantics & getSemantics() const
static Type * getPromotedType(Type *Ty)
getPromotedType - Return the specified type promoted as it would be to pass though a va_arg area...
const BasicBlock * getParent() const
LLVM_READONLY APFloat minnum(const APFloat &A, const APFloat &B)
Implements IEEE minNum semantics.
IntrinsicInst - A useful wrapper class for inspecting calls to intrinsic functions.
bool isVoidTy() const
isVoidTy - Return true if this is 'void'.
AttributeSet getFnAttributes() const
The function attributes are returned.