27 :
User(ty,
Value::InstructionVal + it, Ops, NumOps), Parent(nullptr) {
31 assert(BB &&
"Instruction to insert before is not in a basic block!");
37 :
User(ty,
Value::InstructionVal + it, Ops, NumOps), Parent(nullptr) {
42 assert(BB &&
"Instruction to insert before is not in a basic block!");
49 :
User(ty,
Value::InstructionVal + it, Ops, NumOps), Parent(nullptr) {
57 assert(!Parent &&
"Instruction still linked in the program!");
128 assert((It == ParentBB->
end() || It->getParent() == ParentBB) &&
129 "It not in ParentBB");
140 BB.getInstList().
insert(InsertPos,
this);
148 bool InsertAtHead = InsertPos.getHeadBit();
151 if (SrcMarker && !SrcMarker->
empty()) {
163 assert(!isa<PHINode>(
this) &&
"Inserting PHI after debug-records!");
189 NextIt.setHeadBit(
true);
190 moveBeforeImpl(*MovePos->
getParent(), NextIt,
false);
197 NextIt.setHeadBit(
true);
198 moveBeforeImpl(*MovePos->
getParent(), NextIt,
true);
202 moveBeforeImpl(BB,
I,
false);
207 moveBeforeImpl(BB,
I,
true);
210void Instruction::moveBeforeImpl(
BasicBlock &BB, InstListType::iterator
I,
213 bool InsertAtHead =
I.getHeadBit();
234 if (!InsertAtHead && NextMarker && !NextMarker->
empty()) {
244 const Instruction *
From, std::optional<DbgRecord::self_iterator> FromHere,
246 if (!
From->DbgMarker)
251 From->getParent()->IsNewDbgInfoFormat);
259std::optional<DbgRecord::self_iterator>
278 auto ReleaseTrailingDbgRecords = [BB, It, SrcMarker]() {
279 if (BB->
end() == It) {
286 ReleaseTrailingDbgRecords();
307 ReleaseTrailingDbgRecords();
329 "instructions without BB parents have no order");
330 assert(Parent ==
Other->Parent &&
"cross-BB instruction order comparison");
333 return Order <
Other->Order;
337 assert(!
getType()->isVoidTy() &&
"Instruction must define result");
340 if (
auto *PN = dyn_cast<PHINode>(
this)) {
343 }
else if (
auto *II = dyn_cast<InvokeInst>(
this)) {
344 InsertBB = II->getNormalDest();
346 }
else if (isa<CallBrInst>(
this)) {
357 InsertPt.setHeadBit(
true);
362 if (InsertPt == InsertBB->
end())
372 cast<OverflowingBinaryOperator>(
this)->setHasNoUnsignedWrap(b);
376 cast<OverflowingBinaryOperator>(
this)->setHasNoSignedWrap(b);
380 cast<PossiblyExactOperator>(
this)->setIsExact(b);
384 assert(isa<PossiblyNonNegInst>(
this) &&
"Must be zext");
390 return cast<OverflowingBinaryOperator>(
this)->hasNoUnsignedWrap();
394 return cast<OverflowingBinaryOperator>(
this)->hasNoSignedWrap();
398 assert(isa<PossiblyNonNegInst>(
this) &&
"Must be zext");
403 return cast<Operator>(
this)->hasPoisonGeneratingFlags();
408 case Instruction::Add:
409 case Instruction::Sub:
410 case Instruction::Mul:
411 case Instruction::Shl:
412 cast<OverflowingBinaryOperator>(
this)->setHasNoUnsignedWrap(
false);
413 cast<OverflowingBinaryOperator>(
this)->setHasNoSignedWrap(
false);
416 case Instruction::UDiv:
417 case Instruction::SDiv:
418 case Instruction::AShr:
419 case Instruction::LShr:
420 cast<PossiblyExactOperator>(
this)->setIsExact(
false);
423 case Instruction::Or:
424 cast<PossiblyDisjointInst>(
this)->setIsDisjoint(
false);
427 case Instruction::GetElementPtr:
428 cast<GetElementPtrInst>(
this)->setIsInBounds(
false);
431 case Instruction::ZExt:
436 if (isa<FPMathOperator>(
this)) {
459 auto *CB = dyn_cast<CallBase>(
this);
470 for (
unsigned ArgNo = 0; ArgNo < CB->arg_size(); ArgNo++)
471 CB->removeParamAttrs(ArgNo, UBImplyingAttributes);
472 CB->removeRetAttrs(UBImplyingAttributes);
480 unsigned KnownIDs[] = {LLVMContext::MD_annotation, LLVMContext::MD_range,
481 LLVMContext::MD_nonnull, LLVMContext::MD_align};
486 return cast<PossiblyExactOperator>(
this)->isExact();
490 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
491 cast<FPMathOperator>(
this)->setFast(
B);
495 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
496 cast<FPMathOperator>(
this)->setHasAllowReassoc(
B);
500 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
501 cast<FPMathOperator>(
this)->setHasNoNaNs(
B);
505 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
506 cast<FPMathOperator>(
this)->setHasNoInfs(
B);
510 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
511 cast<FPMathOperator>(
this)->setHasNoSignedZeros(
B);
515 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
516 cast<FPMathOperator>(
this)->setHasAllowReciprocal(
B);
520 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
521 cast<FPMathOperator>(
this)->setHasAllowContract(
B);
525 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
526 cast<FPMathOperator>(
this)->setHasApproxFunc(
B);
530 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
531 cast<FPMathOperator>(
this)->setFastMathFlags(FMF);
535 assert(isa<FPMathOperator>(
this) &&
"copying fast-math flag on invalid op");
536 cast<FPMathOperator>(
this)->copyFastMathFlags(FMF);
540 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
541 return cast<FPMathOperator>(
this)->isFast();
545 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
546 return cast<FPMathOperator>(
this)->hasAllowReassoc();
550 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
551 return cast<FPMathOperator>(
this)->hasNoNaNs();
555 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
556 return cast<FPMathOperator>(
this)->hasNoInfs();
560 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
561 return cast<FPMathOperator>(
this)->hasNoSignedZeros();
565 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
566 return cast<FPMathOperator>(
this)->hasAllowReciprocal();
570 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
571 return cast<FPMathOperator>(
this)->hasAllowContract();
575 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
576 return cast<FPMathOperator>(
this)->hasApproxFunc();
580 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
581 return cast<FPMathOperator>(
this)->getFastMathFlags();
590 if (IncludeWrapFlags && isa<OverflowingBinaryOperator>(
this)) {
591 if (
auto *OB = dyn_cast<OverflowingBinaryOperator>(V)) {
598 if (
auto *PE = dyn_cast<PossiblyExactOperator>(V))
599 if (isa<PossiblyExactOperator>(
this))
602 if (
auto *SrcPD = dyn_cast<PossiblyDisjointInst>(V))
603 if (
auto *DestPD = dyn_cast<PossiblyDisjointInst>(
this))
604 DestPD->setIsDisjoint(SrcPD->isDisjoint());
607 if (
auto *
FP = dyn_cast<FPMathOperator>(V))
608 if (isa<FPMathOperator>(
this))
611 if (
auto *SrcGEP = dyn_cast<GetElementPtrInst>(V))
612 if (
auto *DestGEP = dyn_cast<GetElementPtrInst>(
this))
613 DestGEP->setIsInBounds(SrcGEP->isInBounds() || DestGEP->isInBounds());
615 if (
auto *NNI = dyn_cast<PossiblyNonNegInst>(V))
616 if (isa<PossiblyNonNegInst>(
this))
621 if (
auto *OB = dyn_cast<OverflowingBinaryOperator>(V)) {
622 if (isa<OverflowingBinaryOperator>(
this)) {
628 if (
auto *PE = dyn_cast<PossiblyExactOperator>(V))
629 if (isa<PossiblyExactOperator>(
this))
632 if (
auto *SrcPD = dyn_cast<PossiblyDisjointInst>(V))
633 if (
auto *DestPD = dyn_cast<PossiblyDisjointInst>(
this))
634 DestPD->setIsDisjoint(DestPD->isDisjoint() && SrcPD->isDisjoint());
636 if (
auto *
FP = dyn_cast<FPMathOperator>(V)) {
637 if (isa<FPMathOperator>(
this)) {
639 FM &=
FP->getFastMathFlags();
644 if (
auto *SrcGEP = dyn_cast<GetElementPtrInst>(V))
645 if (
auto *DestGEP = dyn_cast<GetElementPtrInst>(
this))
646 DestGEP->setIsInBounds(SrcGEP->isInBounds() && DestGEP->isInBounds());
648 if (
auto *NNI = dyn_cast<PossiblyNonNegInst>(V))
649 if (isa<PossiblyNonNegInst>(
this))
656 case Ret:
return "ret";
657 case Br:
return "br";
658 case Switch:
return "switch";
659 case IndirectBr:
return "indirectbr";
660 case Invoke:
return "invoke";
661 case Resume:
return "resume";
662 case Unreachable:
return "unreachable";
663 case CleanupRet:
return "cleanupret";
664 case CatchRet:
return "catchret";
665 case CatchPad:
return "catchpad";
666 case CatchSwitch:
return "catchswitch";
667 case CallBr:
return "callbr";
670 case FNeg:
return "fneg";
673 case Add:
return "add";
674 case FAdd:
return "fadd";
675 case Sub:
return "sub";
676 case FSub:
return "fsub";
677 case Mul:
return "mul";
678 case FMul:
return "fmul";
679 case UDiv:
return "udiv";
680 case SDiv:
return "sdiv";
681 case FDiv:
return "fdiv";
682 case URem:
return "urem";
683 case SRem:
return "srem";
684 case FRem:
return "frem";
687 case And:
return "and";
688 case Or :
return "or";
689 case Xor:
return "xor";
692 case Alloca:
return "alloca";
693 case Load:
return "load";
694 case Store:
return "store";
695 case AtomicCmpXchg:
return "cmpxchg";
696 case AtomicRMW:
return "atomicrmw";
697 case Fence:
return "fence";
698 case GetElementPtr:
return "getelementptr";
701 case Trunc:
return "trunc";
702 case ZExt:
return "zext";
703 case SExt:
return "sext";
704 case FPTrunc:
return "fptrunc";
705 case FPExt:
return "fpext";
706 case FPToUI:
return "fptoui";
707 case FPToSI:
return "fptosi";
708 case UIToFP:
return "uitofp";
709 case SIToFP:
return "sitofp";
710 case IntToPtr:
return "inttoptr";
711 case PtrToInt:
return "ptrtoint";
712 case BitCast:
return "bitcast";
713 case AddrSpaceCast:
return "addrspacecast";
716 case ICmp:
return "icmp";
717 case FCmp:
return "fcmp";
718 case PHI:
return "phi";
719 case Select:
return "select";
720 case Call:
return "call";
721 case Shl:
return "shl";
722 case LShr:
return "lshr";
723 case AShr:
return "ashr";
724 case VAArg:
return "va_arg";
725 case ExtractElement:
return "extractelement";
726 case InsertElement:
return "insertelement";
727 case ShuffleVector:
return "shufflevector";
728 case ExtractValue:
return "extractvalue";
729 case InsertValue:
return "insertvalue";
730 case LandingPad:
return "landingpad";
731 case CleanupPad:
return "cleanuppad";
732 case Freeze:
return "freeze";
734 default:
return "<Invalid operator> ";
741 bool IgnoreAlignment)
const {
744 "Can not compare special state of different instructions");
746 if (
const AllocaInst *AI = dyn_cast<AllocaInst>(I1))
747 return AI->getAllocatedType() == cast<AllocaInst>(I2)->getAllocatedType() &&
748 (AI->getAlign() == cast<AllocaInst>(I2)->getAlign() ||
750 if (
const LoadInst *LI = dyn_cast<LoadInst>(I1))
751 return LI->isVolatile() == cast<LoadInst>(I2)->isVolatile() &&
752 (LI->getAlign() == cast<LoadInst>(I2)->getAlign() ||
754 LI->getOrdering() == cast<LoadInst>(I2)->getOrdering() &&
755 LI->getSyncScopeID() == cast<LoadInst>(I2)->getSyncScopeID();
756 if (
const StoreInst *SI = dyn_cast<StoreInst>(I1))
757 return SI->isVolatile() == cast<StoreInst>(I2)->isVolatile() &&
758 (SI->getAlign() == cast<StoreInst>(I2)->getAlign() ||
760 SI->getOrdering() == cast<StoreInst>(I2)->getOrdering() &&
761 SI->getSyncScopeID() == cast<StoreInst>(I2)->getSyncScopeID();
762 if (
const CmpInst *CI = dyn_cast<CmpInst>(I1))
763 return CI->getPredicate() == cast<CmpInst>(I2)->getPredicate();
764 if (
const CallInst *CI = dyn_cast<CallInst>(I1))
765 return CI->isTailCall() == cast<CallInst>(I2)->isTailCall() &&
766 CI->getCallingConv() == cast<CallInst>(I2)->getCallingConv() &&
767 CI->getAttributes() == cast<CallInst>(I2)->getAttributes() &&
768 CI->hasIdenticalOperandBundleSchema(*cast<CallInst>(I2));
769 if (
const InvokeInst *CI = dyn_cast<InvokeInst>(I1))
770 return CI->getCallingConv() == cast<InvokeInst>(I2)->getCallingConv() &&
771 CI->getAttributes() == cast<InvokeInst>(I2)->getAttributes() &&
772 CI->hasIdenticalOperandBundleSchema(*cast<InvokeInst>(I2));
773 if (
const CallBrInst *CI = dyn_cast<CallBrInst>(I1))
774 return CI->getCallingConv() == cast<CallBrInst>(I2)->getCallingConv() &&
775 CI->getAttributes() == cast<CallBrInst>(I2)->getAttributes() &&
776 CI->hasIdenticalOperandBundleSchema(*cast<CallBrInst>(I2));
778 return IVI->getIndices() == cast<InsertValueInst>(I2)->getIndices();
780 return EVI->getIndices() == cast<ExtractValueInst>(I2)->getIndices();
781 if (
const FenceInst *FI = dyn_cast<FenceInst>(I1))
782 return FI->getOrdering() == cast<FenceInst>(I2)->getOrdering() &&
783 FI->getSyncScopeID() == cast<FenceInst>(I2)->getSyncScopeID();
785 return CXI->isVolatile() == cast<AtomicCmpXchgInst>(I2)->isVolatile() &&
786 CXI->isWeak() == cast<AtomicCmpXchgInst>(I2)->isWeak() &&
787 CXI->getSuccessOrdering() ==
788 cast<AtomicCmpXchgInst>(I2)->getSuccessOrdering() &&
789 CXI->getFailureOrdering() ==
790 cast<AtomicCmpXchgInst>(I2)->getFailureOrdering() &&
791 CXI->getSyncScopeID() ==
792 cast<AtomicCmpXchgInst>(I2)->getSyncScopeID();
794 return RMWI->getOperation() == cast<AtomicRMWInst>(I2)->getOperation() &&
795 RMWI->isVolatile() == cast<AtomicRMWInst>(I2)->isVolatile() &&
796 RMWI->getOrdering() == cast<AtomicRMWInst>(I2)->getOrdering() &&
797 RMWI->getSyncScopeID() == cast<AtomicRMWInst>(I2)->getSyncScopeID();
799 return SVI->getShuffleMask() ==
800 cast<ShuffleVectorInst>(I2)->getShuffleMask();
802 return GEP->getSourceElementType() ==
803 cast<GetElementPtrInst>(I2)->getSourceElementType();
829 if (
const PHINode *thisPHI = dyn_cast<PHINode>(
this)) {
830 const PHINode *otherPHI = cast<PHINode>(
I);
831 return std::equal(thisPHI->block_begin(), thisPHI->block_end(),
841 unsigned flags)
const {
848 getType()->getScalarType() !=
I->getType()->getScalarType() :
857 I->getOperand(i)->getType()->getScalarType() :
869 const PHINode *PN = dyn_cast<PHINode>(
I);
871 if (
I->getParent() != BB)
884 default:
return false;
885 case Instruction::VAArg:
886 case Instruction::Load:
887 case Instruction::Fence:
888 case Instruction::AtomicCmpXchg:
889 case Instruction::AtomicRMW:
890 case Instruction::CatchPad:
891 case Instruction::CatchRet:
893 case Instruction::Call:
894 case Instruction::Invoke:
895 case Instruction::CallBr:
896 return !cast<CallBase>(
this)->onlyWritesMemory();
897 case Instruction::Store:
898 return !cast<StoreInst>(
this)->isUnordered();
904 default:
return false;
905 case Instruction::Fence:
906 case Instruction::Store:
907 case Instruction::VAArg:
908 case Instruction::AtomicCmpXchg:
909 case Instruction::AtomicRMW:
910 case Instruction::CatchPad:
911 case Instruction::CatchRet:
913 case Instruction::Call:
914 case Instruction::Invoke:
915 case Instruction::CallBr:
916 return !cast<CallBase>(
this)->onlyReadsMemory();
917 case Instruction::Load:
918 return !cast<LoadInst>(
this)->isUnordered();
926 case Instruction::AtomicCmpXchg:
927 case Instruction::AtomicRMW:
928 case Instruction::Fence:
930 case Instruction::Load:
932 case Instruction::Store:
942 case Instruction::AtomicCmpXchg:
943 case Instruction::AtomicRMW:
944 case Instruction::Load:
954 case Instruction::AtomicCmpXchg:
955 case Instruction::AtomicRMW:
956 case Instruction::Store:
965 case Instruction::AtomicRMW:
966 return cast<AtomicRMWInst>(
this)->isVolatile();
967 case Instruction::Store:
968 return cast<StoreInst>(
this)->isVolatile();
969 case Instruction::Load:
970 return cast<LoadInst>(
this)->isVolatile();
971 case Instruction::AtomicCmpXchg:
972 return cast<AtomicCmpXchgInst>(
this)->isVolatile();
973 case Instruction::Call:
974 case Instruction::Invoke:
976 if (
auto *II = dyn_cast<IntrinsicInst>(
this)) {
977 if (
auto *
MI = dyn_cast<MemIntrinsic>(II))
978 return MI->isVolatile();
979 switch (II->getIntrinsicID()) {
981 case Intrinsic::matrix_column_major_load:
982 return cast<ConstantInt>(II->getArgOperand(2))->isOne();
983 case Intrinsic::matrix_column_major_store:
984 return cast<ConstantInt>(II->getArgOperand(3))->isOne();
993 case Instruction::Store:
994 return cast<StoreInst>(
this)->getValueOperand()->getType();
995 case Instruction::Load:
996 case Instruction::AtomicRMW:
998 case Instruction::AtomicCmpXchg:
999 return cast<AtomicCmpXchgInst>(
this)->getNewValOperand()->getType();
1000 case Instruction::Call:
1001 case Instruction::Invoke:
1002 if (
const IntrinsicInst *II = dyn_cast<IntrinsicInst>(
this)) {
1003 switch (II->getIntrinsicID()) {
1004 case Intrinsic::masked_load:
1005 case Intrinsic::masked_gather:
1006 case Intrinsic::masked_expandload:
1007 case Intrinsic::vp_load:
1008 case Intrinsic::vp_gather:
1009 case Intrinsic::experimental_vp_strided_load:
1010 return II->getType();
1011 case Intrinsic::masked_store:
1012 case Intrinsic::masked_scatter:
1013 case Intrinsic::masked_compressstore:
1014 case Intrinsic::vp_store:
1015 case Intrinsic::vp_scatter:
1016 case Intrinsic::experimental_vp_strided_store:
1017 return II->getOperand(0)->getType();
1028 bool IncludePhaseOneUnwind) {
1032 return IncludePhaseOneUnwind;
1051 case Instruction::Call:
1052 return !cast<CallInst>(
this)->doesNotThrow();
1053 case Instruction::CleanupRet:
1054 return cast<CleanupReturnInst>(
this)->unwindsToCaller();
1055 case Instruction::CatchSwitch:
1056 return cast<CatchSwitchInst>(
this)->unwindsToCaller();
1057 case Instruction::Resume:
1059 case Instruction::Invoke: {
1062 BasicBlock *UnwindDest = cast<InvokeInst>(
this)->getUnwindDest();
1064 if (
auto *LP = dyn_cast<LandingPadInst>(Pad))
1068 case Instruction::CleanupPad:
1070 return IncludePhaseOneUnwind;
1087 if (
auto *SI = dyn_cast<StoreInst>(
this))
1088 return !SI->isVolatile();
1090 if (
const auto *CB = dyn_cast<CallBase>(
this))
1091 return CB->hasFnAttr(Attribute::WillReturn);
1096 auto *II = dyn_cast<IntrinsicInst>(
this);
1100 return ID == Intrinsic::lifetime_start ||
ID == Intrinsic::lifetime_end;
1104 auto *II = dyn_cast<IntrinsicInst>(
this);
1108 return ID == Intrinsic::launder_invariant_group ||
1109 ID == Intrinsic::strip_invariant_group;
1113 return isa<DbgInfoIntrinsic>(
this) || isa<PseudoProbeInst>(
this);
1119 if (!isa<DbgInfoIntrinsic>(
I) && !(SkipPseudoOp && isa<PseudoProbeInst>(
I)))
1127 if (!isa<DbgInfoIntrinsic>(
I) && !(SkipPseudoOp && isa<PseudoProbeInst>(
I)))
1133 if (isa<DbgInfoIntrinsic>(
this))
1135 return Next->getDebugLoc();
1140 if (
auto *II = dyn_cast<IntrinsicInst>(
this))
1141 return II->isAssociative();
1149 return cast<FPMathOperator>(
this)->hasAllowReassoc() &&
1150 cast<FPMathOperator>(
this)->hasNoSignedZeros();
1157 if (
auto *II = dyn_cast<IntrinsicInst>(
this))
1158 return II->isCommutative();
1165#define HANDLE_TERM_INST(N, OPC, CLASS) \
1166 case Instruction::OPC: \
1167 return static_cast<const CLASS *>(this)->getNumSuccessors();
1168#include "llvm/IR/Instruction.def"
1177#define HANDLE_TERM_INST(N, OPC, CLASS) \
1178 case Instruction::OPC: \
1179 return static_cast<const CLASS *>(this)->getSuccessor(idx);
1180#include "llvm/IR/Instruction.def"
1189#define HANDLE_TERM_INST(N, OPC, CLASS) \
1190 case Instruction::OPC: \
1191 return static_cast<CLASS *>(this)->setSuccessor(idx, B);
1192#include "llvm/IR/Instruction.def"
1201 Idx != NumSuccessors; ++
Idx)
1233 for (
const auto &MD : TheMDs) {
1234 if (WL.
empty() || WLS.count(MD.first))
1237 if (WL.
empty() || WLS.count(LLVMContext::MD_dbg))
1246#define HANDLE_INST(num, opc, clas) \
1247 case Instruction::opc: \
1248 New = cast<clas>(this)->cloneImpl(); \
1250#include "llvm/IR/Instruction.def"
1255 New->copyMetadata(*
this);
amdgpu AMDGPU Register Bank Select
BlockVerifier::State From
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file defines the DenseSet and SmallDenseSet classes.
static bool canUnwindPastLandingPad(const LandingPadInst *LP, bool IncludePhaseOneUnwind)
llvm::cl::opt< bool > UseNewDbgInfoFormat
This file contains the declarations for profiling metadata utility functions.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
an instruction to allocate memory on the stack
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
empty - Check if the array is empty.
An instruction that atomically checks whether a specified value is in a memory location,...
an instruction that atomically reads a memory location, combines it with another value,...
LLVM Basic Block Representation.
DPMarker * getMarker(InstListType::iterator It)
Return the DPMarker for the position given by It, so that DbgRecords can be inserted there.
void deleteTrailingDbgRecords()
Delete any trailing DbgRecords at the end of this block, see setTrailingDbgRecords.
const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
void renumberInstructions()
Renumber instructions and mark the ordering as valid.
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
DPMarker * createMarker(Instruction *I)
Attach a DPMarker to the given instruction.
void flushTerminatorDbgRecords()
Eject any debug-info trailing at the end of a block.
const Function * getParent() const
Return the enclosing method, or null if none.
InstListType::iterator iterator
Instruction iterators...
bool IsNewDbgInfoFormat
Flag recording whether or not this block stores debug-info in the form of intrinsic instructions (fal...
DPMarker * getNextMarker(Instruction *I)
Return the DPMarker for the position that comes after I.
bool isInstrOrderValid() const
Returns true if the Order field of child Instructions is valid.
const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr if the function does no...
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
This class represents a function call, abstracting a target machine's calling convention.
This class is the base class for the comparison instructions.
This is an important base class in LLVM.
Per-instruction record of debug-info.
void dropDbgRecords()
Erase all DbgRecords in this DPMarker.
Instruction * MarkedInstr
Link back to the Instruction that owns this marker.
void dropOneDbgRecord(DbgRecord *DR)
Erase a single DbgRecord from this marker.
static iterator_range< simple_ilist< DbgRecord >::iterator > getEmptyDbgRecordRange()
void absorbDebugValues(DPMarker &Src, bool InsertAtHead)
Transfer any DbgRecords from Src into this DPMarker.
simple_ilist< DbgRecord > StoredDbgRecords
List of DbgRecords, the non-instruction equivalent of llvm.dbg.
iterator_range< simple_ilist< DbgRecord >::iterator > cloneDebugInfoFrom(DPMarker *From, std::optional< simple_ilist< DbgRecord >::iterator > FromHere, bool InsertAtHead=false)
Clone all DPMarkers from From into this marker.
void removeMarker()
Handle the removal of a marker: the position of debug-info has gone away, but the stored debug record...
Base class for non-instruction debug metadata records that have positions within IR.
Convenience struct for specifying and reasoning about fast-math flags.
An instruction for ordering other memory operations.
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
This instruction inserts a struct field of array element value into an aggregate value.
const DebugLoc & getStableDebugLoc() const
Fetch the debug location for this node, unless this is a debug intrinsic, in which case fetch the deb...
bool mayThrow(bool IncludePhaseOneUnwind=false) const LLVM_READONLY
Return true if this instruction may throw an exception.
Instruction * clone() const
Create a copy of 'this' instruction that is identical in all ways except the following:
void setHasNoUnsignedWrap(bool b=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag.
bool hasNoNaNs() const LLVM_READONLY
Determine whether the no-NaNs flag is set.
void removeFromParent()
This method unlinks 'this' from the containing basic block, but does not delete it.
bool hasNoUnsignedWrap() const LLVM_READONLY
Determine whether the no unsigned wrap flag is set.
bool hasNoInfs() const LLVM_READONLY
Determine whether the no-infs flag is set.
bool isLifetimeStartOrEnd() const LLVM_READONLY
Return true if the instruction is a llvm.lifetime.start or llvm.lifetime.end marker.
void copyFastMathFlags(FastMathFlags FMF)
Convenience function for transferring all fast-math flag values to this instruction,...
bool isSameOperationAs(const Instruction *I, unsigned flags=0) const LLVM_READONLY
This function determines if the specified instruction executes the same operation as the current one.
void setHasNoSignedZeros(bool B)
Set or clear the no-signed-zeros flag on this instruction, which must be an operator which supports t...
void moveBeforePreserving(Instruction *MovePos)
Perform a moveBefore operation, while signalling that the caller intends to preserve the original ord...
bool hasNoSignedZeros() const LLVM_READONLY
Determine whether the no-signed-zeros flag is set.
iterator_range< simple_ilist< DbgRecord >::iterator > cloneDebugInfoFrom(const Instruction *From, std::optional< simple_ilist< DbgRecord >::iterator > FromHere=std::nullopt, bool InsertAtHead=false)
Clone any debug-info attached to From onto this instruction.
DPMarker * DbgMarker
Optional marker recording the position for debugging information that takes effect immediately before...
bool isDebugOrPseudoInst() const LLVM_READONLY
Return true if the instruction is a DbgInfoIntrinsic or PseudoProbeInst.
unsigned getNumSuccessors() const LLVM_READONLY
Return the number of successors that this instruction has.
bool hasNoSignedWrap() const LLVM_READONLY
Determine whether the no signed wrap flag is set.
bool mayWriteToMemory() const LLVM_READONLY
Return true if this instruction may modify memory.
void copyIRFlags(const Value *V, bool IncludeWrapFlags=true)
Convenience method to copy supported exact, fast-math, and (optionally) wrapping flags from V to this...
void setHasAllowContract(bool B)
Set or clear the allow-contract flag on this instruction, which must be an operator which supports th...
bool hasAtomicStore() const LLVM_READONLY
Return true if this atomic instruction stores to memory.
void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag.
bool isOnlyUserOfAnyOperand()
It checks if this instruction is the only user of at least one of its operands.
iterator_range< simple_ilist< DbgRecord >::iterator > getDbgRecordRange() const
Return a range over the DbgRecords attached to this instruction.
void insertBefore(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified instruction.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
void andIRFlags(const Value *V)
Logical 'and' of any supported wrapping, exact, and fast-math flags of V and this instruction.
void setHasNoNaNs(bool B)
Set or clear the no-nans flag on this instruction, which must be an operator which supports this flag...
bool isAssociative() const LLVM_READONLY
Return true if the instruction is associative:
const Instruction * getPrevNonDebugInstruction(bool SkipPseudoOp=false) const
Return a pointer to the previous non-debug instruction in the same basic block as 'this',...
void setHasApproxFunc(bool B)
Set or clear the approximate-math-functions flag on this instruction, which must be an operator which...
void moveAfter(Instruction *MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
bool isCommutative() const LLVM_READONLY
Return true if the instruction is commutative:
bool hasMetadata() const
Return true if this instruction has any metadata attached to it.
bool isAtomic() const LLVM_READONLY
Return true if this instruction has an AtomicOrdering of unordered or higher.
void setHasAllowReassoc(bool B)
Set or clear the reassociation flag on this instruction, which must be an operator which supports thi...
void setFastMathFlags(FastMathFlags FMF)
Convenience function for setting multiple fast-math flags on this instruction, which must be an opera...
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
const BasicBlock * getParent() const
InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
bool isFast() const LLVM_READONLY
Determine whether all fast-math-flags are set.
void replaceSuccessorWith(BasicBlock *OldBB, BasicBlock *NewBB)
Replace specified successor OldBB to point at the provided block.
bool isExact() const LLVM_READONLY
Determine whether the exact flag is set.
bool isIdenticalToWhenDefined(const Instruction *I) const LLVM_READONLY
This is like isIdenticalTo, except that it ignores the SubclassOptionalData flags,...
const Function * getFunction() const
Return the function this instruction belongs to.
void swapProfMetadata()
If the instruction has "branch_weights" MD_prof metadata and the MDNode has three operands (including...
BasicBlock * getSuccessor(unsigned Idx) const LLVM_READONLY
Return the specified successor. This instruction must be a terminator.
bool mayHaveSideEffects() const LLVM_READONLY
Return true if the instruction may have side effects.
void dropOneDbgRecord(DbgRecord *I)
Erase a single DbgRecord I that is attached to this instruction.
void setNonNeg(bool b=true)
Set or clear the nneg flag on this instruction, which must be a zext instruction.
bool isTerminator() const
Type * getAccessType() const LLVM_READONLY
Return the type this instruction accesses in memory, if any.
bool hasSameSpecialState(const Instruction *I2, bool IgnoreAlignment=false) const LLVM_READONLY
This function determines if the speficied instruction has the same "special" characteristics as the c...
bool hasAllowReciprocal() const LLVM_READONLY
Determine whether the allow-reciprocal flag is set.
bool comesBefore(const Instruction *Other) const
Given an instruction Other in the same basic block as this instruction, return true if this instructi...
void dropUBImplyingAttrsAndMetadata()
Drop any attributes or metadata that can cause immediate undefined behavior.
bool hasNonNeg() const LLVM_READONLY
Determine whether the the nneg flag is set.
bool hasPoisonGeneratingFlags() const LLVM_READONLY
Return true if this operator has flags which may cause this instruction to evaluate to poison despite...
bool mayReadFromMemory() const LLVM_READONLY
Return true if this instruction may read memory.
const Instruction * getNextNonDebugInstruction(bool SkipPseudoOp=false) const
Return a pointer to the next non-debug instruction in the same basic block as 'this',...
bool isUsedOutsideOfBlock(const BasicBlock *BB) const LLVM_READONLY
Return true if there are any uses of this instruction in blocks other than the specified block.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
bool isVolatile() const LLVM_READONLY
Return true if this instruction has a volatile memory access.
void setHasNoInfs(bool B)
Set or clear the no-infs flag on this instruction, which must be an operator which supports this flag...
void adoptDbgRecords(BasicBlock *BB, InstListType::iterator It, bool InsertAtHead)
Transfer any DbgRecords on the position It onto this instruction, by simply adopting the sequence of ...
FastMathFlags getFastMathFlags() const LLVM_READONLY
Convenience function for getting all the fast-math flags, which must be an operator which supports th...
const char * getOpcodeName() const
bool willReturn() const LLVM_READONLY
Return true if the instruction will return (unwinding is considered as a form of returning control fl...
bool hasApproxFunc() const LLVM_READONLY
Determine whether the approximate-math-functions flag is set.
@ CompareIgnoringAlignment
Check for equivalence ignoring load/store alignment.
@ CompareUsingScalarTypes
Check for equivalence treating a type and a vector of that type as equivalent.
void getAllMetadataOtherThanDebugLoc(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
This does the same thing as getAllMetadata, except that it filters out the debug location.
void moveAfterPreserving(Instruction *MovePos)
See moveBeforePreserving .
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
bool hasAtomicLoad() const LLVM_READONLY
Return true if this atomic instruction loads from memory.
void dropUnknownNonDebugMetadata()
void setIsExact(bool b=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag.
void dropPoisonGeneratingMetadata()
Drops metadata that may generate poison.
void setHasAllowReciprocal(bool B)
Set or clear the allow-reciprocal flag on this instruction, which must be an operator which supports ...
void handleMarkerRemoval()
Handle the debug-info implications of this instruction being removed.
std::optional< InstListType::iterator > getInsertionPointAfterDef()
Get the first insertion point at which the result of this instruction is defined.
void dropPoisonGeneratingFlags()
Drops flags that may cause this instruction to evaluate to poison despite having non-poison inputs.
void dropUBImplyingAttrsAndUnknownMetadata(ArrayRef< unsigned > KnownIDs={})
This function drops non-debug unknown metadata (through dropUnknownNonDebugMetadata).
bool isIdenticalTo(const Instruction *I) const LLVM_READONLY
Return true if the specified instruction is exactly identical to the current one.
std::optional< simple_ilist< DbgRecord >::iterator > getDbgReinsertionPosition()
Return an iterator to the position of the "Next" DbgRecord after this instruction,...
bool isLaunderOrStripInvariantGroup() const LLVM_READONLY
Return true if the instruction is a llvm.launder.invariant.group or llvm.strip.invariant....
bool hasAllowContract() const LLVM_READONLY
Determine whether the allow-contract flag is set.
bool hasPoisonGeneratingMetadata() const LLVM_READONLY
Return true if this instruction has poison-generating metadata.
Instruction(const Instruction &)=delete
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
void setSuccessor(unsigned Idx, BasicBlock *BB)
Update the specified successor to point at the provided block.
void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
void setFast(bool B)
Set or clear all fast-math-flags on this instruction, which must be an operator which supports this f...
bool hasAllowReassoc() const LLVM_READONLY
Determine whether the allow-reassociation flag is set.
void dropDbgRecords()
Erase any DbgRecords attached to this instruction.
void insertAfter(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately after the specified instruction.
void moveBefore(Instruction *MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
bool isSafeToRemove() const LLVM_READONLY
Return true if the instruction can be removed if the result is unused.
InstListType::iterator insertInto(BasicBlock *ParentBB, InstListType::iterator It)
Inserts an unlinked instruction into ParentBB at position It and returns the iterator of the inserted...
bool hasDbgRecords() const
Returns true if any DbgRecords are attached to this instruction.
A wrapper class for inspecting calls to intrinsic functions.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
bool isCatch(unsigned Idx) const
Return 'true' if the clause and index Idx is a catch clause.
bool isFilter(unsigned Idx) const
Return 'true' if the clause and index Idx is a filter clause.
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
An instruction for reading from memory.
const MDOperand & getOperand(unsigned I) const
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
unsigned getNumOperands() const
Return number of MDNode operands.
LLVMContext & getContext() const
A Module instance is used to store all the information related to an LLVM module.
const_block_iterator block_begin() const
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
Instruction that can have a nneg flag (only zext).
This instruction constructs a fixed permutation of two input vectors.
Implements a dense probed hash-table based set with some number of buckets stored inline.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
The instances of the Type class are immutable: once they are created, they are never changed.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
A Use represents the edge between a Value definition and its users.
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
unsigned char SubclassOptionalData
Hold subclass data that can be dropped.
bool isUsedByMetadata() const
Return true if there is metadata referencing this value.
bool eraseMetadata(unsigned KindID)
Erase all metadata attachments with the given kind.
iterator_range< use_iterator > uses()
self_iterator getIterator()
Instruction * getPrevNode()
Instruction * getNextNode()
Get the next node, or nullptr for the list tail.
void splice(iterator where, iplist_impl &L2)
base_list_type::iterator iterator
iterator erase(iterator where)
pointer remove(iterator &IT)
iterator insertAfter(iterator where, pointer New)
iterator insert(iterator where, pointer New)
A range adaptor for a pair of iterators.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
AttributeMask getUBImplyingAttributes()
Get param/return attributes which imply immediate undefined behavior if an invalid value is passed.
This is an optimization pass for GlobalISel generic memory operations.
MDNode * getBranchWeightMDNode(const Instruction &I)
Get the branch weights metadata node.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
@ Or
Bitwise or logical OR of integers.
@ Mul
Product of integers.
@ Xor
Bitwise or logical XOR of integers.
@ And
Bitwise or logical AND of integers.