41 "Disable metadata propagation fixes discovered through Issue #147390"));
46 : InsertAt(InsertAtEnd ? InsertAtEnd->
end() : InstListType::iterator()) {}
52 if (InstListType::iterator InsertIt = InsertBefore; InsertIt.isValid()) {
54 assert(BB &&
"Instruction to insert before is not in a basic block!");
55 insertInto(BB, InsertBefore);
71 if (isUsedByMetadata())
78 updateDIAssignIDMapping(
nullptr);
92 return getModule()->getDataLayout();
97 handleMarkerRemoval();
99 getParent()->getInstList().remove(getIterator());
106 DebugMarker->removeMarker();
110 handleMarkerRemoval();
111 return getParent()->getInstList().erase(getIterator());
117 insertBefore(*InsertPos->getParent(), InsertPos);
131 DestParent->getInstList().
insertAfter(InsertPos,
this);
137 assert((It == ParentBB->
end() || It->getParent() == ParentBB) &&
138 "It not in ParentBB");
139 insertBefore(*ParentBB, It);
140 return getIterator();
144 InstListType::iterator InsertPos) {
147 BB.getInstList().
insert(InsertPos,
this);
152 bool InsertAtHead = InsertPos.getHeadBit();
155 if (SrcMarker && !SrcMarker->
empty()) {
168 adoptDbgRecords(&BB, InsertPos,
false);
176 getParent()->flushTerminatorDbgRecords();
182 moveBeforeImpl(*MovePos->getParent(), MovePos,
false);
186 moveBeforeImpl(*MovePos->getParent(), MovePos,
true);
193 NextIt.setHeadBit(
true);
194 moveBeforeImpl(*MovePos->
getParent(), NextIt,
false);
200 MovePos.setHeadBit(
true);
201 moveBeforeImpl(*MovePos->getParent(), MovePos,
false);
208 NextIt.setHeadBit(
true);
209 moveBeforeImpl(*MovePos->
getParent(), NextIt,
true);
213 moveBeforeImpl(BB,
I,
false);
217 InstListType::iterator
I) {
218 moveBeforeImpl(BB,
I,
true);
221void Instruction::moveBeforeImpl(
BasicBlock &BB, InstListType::iterator
I,
224 bool InsertAtHead =
I.getHeadBit();
228 if (DebugMarker && !Preserve) {
229 if (
I != this->getIterator() || InsertAtHead) {
232 handleMarkerRemoval();
245 if (!InsertAtHead && NextMarker && !NextMarker->
empty()) {
246 adoptDbgRecords(&BB,
I,
false);
251 getParent()->flushTerminatorDbgRecords();
255 const Instruction *From, std::optional<DbgRecord::self_iterator> FromHere,
257 if (!From->DebugMarker)
263 return DebugMarker->cloneDebugInfoFrom(From->DebugMarker, FromHere,
267std::optional<DbgRecord::self_iterator>
286 auto ReleaseTrailingDbgRecords = [BB, It, SrcMarker]() {
287 if (BB->
end() == It) {
294 ReleaseTrailingDbgRecords();
301 if (DebugMarker || It == BB->
end()) {
304 DebugMarker->absorbDebugValues(*SrcMarker, InsertAtHead);
315 ReleaseTrailingDbgRecords();
320 DebugMarker = SrcMarker;
322 It->DebugMarker =
nullptr;
328 DebugMarker->dropDbgRecords();
332 DebugMarker->dropOneDbgRecord(DVR);
337 "instructions without BB parents have no order");
339 "cross-BB instruction order comparison");
342 return Order <
Other->Order;
346 assert(!
getType()->isVoidTy() &&
"Instruction must define result");
353 InsertBB =
II->getNormalDest();
360 assert(!isTerminator() &&
"Only invoke/callbr terminators return value");
362 InsertPt = std::next(getIterator());
366 InsertPt.setHeadBit(
true);
371 if (InsertPt == InsertBB->
end())
377 return any_of(operands(), [](
const Value *
V) {
return V->hasOneUser(); });
382 Inst->setHasNoUnsignedWrap(b);
389 Inst->setHasNoSignedWrap(b);
406 return Inst->hasNoUnsignedWrap();
413 return Inst->hasNoSignedWrap();
429 case Instruction::Add:
430 case Instruction::Sub:
431 case Instruction::Mul:
432 case Instruction::Shl:
437 case Instruction::UDiv:
438 case Instruction::SDiv:
439 case Instruction::AShr:
440 case Instruction::LShr:
444 case Instruction::Or:
448 case Instruction::GetElementPtr:
452 case Instruction::UIToFP:
453 case Instruction::ZExt:
457 case Instruction::Trunc:
462 case Instruction::ICmp:
466 case Instruction::AddrSpaceCast:
470 case Instruction::Call: {
472 switch (
II->getIntrinsicID()) {
473 case Intrinsic::ctlz:
474 case Intrinsic::cttz:
489 assert(!hasPoisonGeneratingFlags() &&
"must be kept in sync");
494 [
this](
unsigned ID) {
return hasMetadata(ID); });
500 if (!hasMetadata(LLVMContext::MD_loop))
504 MDNode *LoopMD = getMetadata(LLVMContext::MD_loop);
527 AttributeMask AM = AttributeFuncs::getPoisonGeneratingAttributes();
531 if (HasPoisonGeneratingAttributes(CB->getRetAttributes()))
533 for (
unsigned ArgNo = 0; ArgNo < CB->arg_size(); ArgNo++)
534 if (HasPoisonGeneratingAttributes(CB->getParamAttributes(ArgNo)))
542 AttributeMask AM = AttributeFuncs::getPoisonGeneratingAttributes();
543 CB->removeRetAttrs(AM);
544 for (
unsigned ArgNo = 0; ArgNo < CB->arg_size(); ArgNo++)
545 CB->removeParamAttrs(ArgNo, AM);
547 assert(!hasPoisonGeneratingAttributes() &&
"must be kept in sync");
552 dropUnknownNonDebugMetadata(KnownIDs);
563 AttributeFuncs::getUBImplyingAttributes();
564 for (
unsigned ArgNo = 0; ArgNo < CB->arg_size(); ArgNo++)
565 CB->removeParamAttrs(ArgNo, UBImplyingAttributes);
566 CB->removeRetAttrs(UBImplyingAttributes);
578 static const unsigned KnownIDs[] = {
579 LLVMContext::MD_annotation, LLVMContext::MD_range,
580 LLVMContext::MD_nonnull, LLVMContext::MD_align,
581 LLVMContext::MD_fpmath, LLVMContext::MD_prof,
582 LLVMContext::MD_mem_cache_hint, LLVMContext::MD_nofpclass,
583 LLVMContext::MD_pcsections};
585 KeepIDs.
reserve(
Keep.size() + std::size(KnownIDs));
588 dropUBImplyingAttrsAndUnknownMetadata(KeepIDs);
597 for (
unsigned ArgNo = 0; ArgNo < CB->arg_size(); ArgNo++)
598 if (CB->isPassingUndefUB(ArgNo))
600 return CB->hasRetAttr(Attribute::NoUndef) ||
601 CB->hasRetAttr(Attribute::Dereferenceable) ||
602 CB->hasRetAttr(Attribute::DereferenceableOrNull);
711 copyFastMathFlags(
I->getFastMathFlags());
718 setHasNoSignedWrap(
OB->hasNoSignedWrap());
719 setHasNoUnsignedWrap(
OB->hasNoUnsignedWrap());
725 setHasNoSignedWrap(TI->hasNoSignedWrap());
726 setHasNoUnsignedWrap(TI->hasNoUnsignedWrap());
733 setIsExact(PE->isExact());
737 DestPD->setIsDisjoint(SrcPD->isDisjoint());
742 copyFastMathFlags(
FP->getFastMathFlags());
746 DestGEP->setNoWrapFlags(SrcGEP->getNoWrapFlags() |
747 DestGEP->getNoWrapFlags());
751 setNonNeg(NNI->hasNonNeg());
755 DestICmp->setSameSign(SrcICmp->hasSameSign());
759 assert(DestASC->getSrcAddressSpace() == SrcASC->getSrcAddressSpace() &&
760 "nonull flag cannot be safely preserved with different source "
762 DestASC->setNonNull(SrcASC->hasNonNull());
783 setIsExact(isExact() && PE->isExact());
787 DestPD->setIsDisjoint(DestPD->isDisjoint() && SrcPD->isDisjoint());
792 FM &=
FP->getFastMathFlags();
793 copyFastMathFlags(FM);
799 DestGEP->setNoWrapFlags(SrcGEP->getNoWrapFlags() &
800 DestGEP->getNoWrapFlags());
804 setNonNeg(hasNonNeg() && NNI->hasNonNeg());
808 DestICmp->setSameSign(DestICmp->hasSameSign() && SrcICmp->hasSameSign());
812 assert(DestASC->getSrcAddressSpace() == SrcASC->getSrcAddressSpace() &&
813 "nonull flag cannot be safely preserved with different source "
815 DestASC->setNonNull(DestASC->hasNonNull() && SrcASC->hasNonNull());
823 case Ret:
return "ret";
824 case UncondBr:
return "br";
825 case CondBr:
return "br";
826 case Switch:
return "switch";
827 case IndirectBr:
return "indirectbr";
828 case Invoke:
return "invoke";
829 case Resume:
return "resume";
830 case Unreachable:
return "unreachable";
831 case CleanupRet:
return "cleanupret";
832 case CatchRet:
return "catchret";
833 case CatchPad:
return "catchpad";
834 case CatchSwitch:
return "catchswitch";
835 case CallBr:
return "callbr";
838 case FNeg:
return "fneg";
841 case Add:
return "add";
842 case FAdd:
return "fadd";
843 case Sub:
return "sub";
844 case FSub:
return "fsub";
845 case Mul:
return "mul";
846 case FMul:
return "fmul";
847 case UDiv:
return "udiv";
848 case SDiv:
return "sdiv";
849 case FDiv:
return "fdiv";
850 case URem:
return "urem";
851 case SRem:
return "srem";
852 case FRem:
return "frem";
855 case And:
return "and";
856 case Or :
return "or";
857 case Xor:
return "xor";
860 case Alloca:
return "alloca";
861 case Load:
return "load";
862 case Store:
return "store";
863 case AtomicCmpXchg:
return "cmpxchg";
864 case AtomicRMW:
return "atomicrmw";
865 case Fence:
return "fence";
866 case GetElementPtr:
return "getelementptr";
869 case Trunc:
return "trunc";
870 case ZExt:
return "zext";
871 case SExt:
return "sext";
872 case FPTrunc:
return "fptrunc";
873 case FPExt:
return "fpext";
874 case FPToUI:
return "fptoui";
875 case FPToSI:
return "fptosi";
876 case UIToFP:
return "uitofp";
877 case SIToFP:
return "sitofp";
878 case IntToPtr:
return "inttoptr";
879 case PtrToAddr:
return "ptrtoaddr";
880 case PtrToInt:
return "ptrtoint";
881 case BitCast:
return "bitcast";
882 case AddrSpaceCast:
return "addrspacecast";
885 case ICmp:
return "icmp";
886 case FCmp:
return "fcmp";
887 case PHI:
return "phi";
888 case Select:
return "select";
889 case Call:
return "call";
890 case Shl:
return "shl";
891 case LShr:
return "lshr";
892 case AShr:
return "ashr";
893 case VAArg:
return "va_arg";
894 case ExtractElement:
return "extractelement";
895 case InsertElement:
return "insertelement";
896 case ShuffleVector:
return "shufflevector";
897 case ExtractValue:
return "extractvalue";
898 case InsertValue:
return "insertvalue";
899 case LandingPad:
return "landingpad";
900 case CleanupPad:
return "cleanuppad";
901 case Freeze:
return "freeze";
902 case BitInsert:
return "bitinsert";
903 case BitExtract:
return "bitextract";
905 default:
return "<Invalid operator> ";
913 bool IgnoreAlignment,
914 bool IntersectAttrs)
const {
915 const auto *
I1 =
this;
917 "Can not compare special state of different instructions");
919 auto CheckAttrsSame = [IntersectAttrs](
const CallBase *CB0,
921 return IntersectAttrs
923 .intersectWith(CB0->
getContext(), CB1->getAttributes())
929 return AI->getAllocatedType() ==
cast<AllocaInst>(I2)->getAllocatedType() &&
947 return CI->getPredicate() ==
cast<CmpInst>(I2)->getPredicate();
966 if (Case1.getCaseValue() != Case2.getCaseValue())
982 CXI->getSuccessOrdering() ==
984 CXI->getFailureOrdering() ==
986 CXI->getSyncScopeID() ==
997 return SVI->getShuffleMask() ==
1000 return GEP->getSourceElementType() ==
1009 if (!isIdenticalToWhenDefined(
I) ||
1010 SubclassOptionalData !=
I->SubclassOptionalData)
1020 bool IntersectAttrs)
const {
1022 getNumOperands() !=
I->getNumOperands() ||
getType() !=
I->getType())
1026 if (getNumOperands() == 0 &&
I->getNumOperands() == 0)
1027 return this->hasSameSpecialState(
I,
false,
1032 if (!
equal(operands(),
I->operands()))
1041 return this->hasSameSpecialState(
I,
false,
1048 unsigned flags)
const {
1049 bool IgnoreAlignment = flags & CompareIgnoringAlignment;
1050 bool UseScalarTypes = flags & CompareUsingScalarTypes;
1051 bool IntersectAttrs = flags & CompareUsingIntersectedAttrs;
1052 bool CheckCallTargets = flags & CompareCallTargets;
1055 getNumOperands() !=
I->getNumOperands() ||
1057 getType()->getScalarType() !=
I->getType()->getScalarType() :
1063 for (
unsigned i = 0, e = getNumOperands(); i !=
e; ++i)
1064 if (UseScalarTypes ?
1065 getOperand(i)->
getType()->getScalarType() !=
1066 I->getOperand(i)->getType()->getScalarType() :
1067 getOperand(i)->
getType() !=
I->getOperand(i)->getType())
1070 if (CheckCallTargets)
1075 return this->hasSameSpecialState(
I, IgnoreAlignment, IntersectAttrs);
1079 for (
const Use &U : uses()) {
1085 if (
I->getParent() != BB)
1097 auto GetEffects = [](ModRefInfo BaseMR, AtomicOrdering
Ordering,
1113 case Instruction::VAArg:
1115 case Instruction::CatchPad:
1116 case Instruction::CatchRet:
1117 case Instruction::Fence:
1119 case Instruction::Call:
1120 case Instruction::Invoke:
1121 case Instruction::CallBr:
1123 case Instruction::Load: {
1125 return GetEffects(
ModRefInfo::Ref, LI->getOrdering(), LI->isVolatile());
1127 case Instruction::Store: {
1131 case Instruction::AtomicRMW: {
1136 case Instruction::AtomicCmpXchg: {
1150 default:
return false;
1151 case Instruction::VAArg:
1152 case Instruction::Load:
1153 case Instruction::Fence:
1154 case Instruction::AtomicCmpXchg:
1155 case Instruction::AtomicRMW:
1156 case Instruction::CatchPad:
1157 case Instruction::CatchRet:
1159 case Instruction::Call:
1160 case Instruction::Invoke:
1161 case Instruction::CallBr:
1163 case Instruction::Store:
1170 default:
return false;
1171 case Instruction::Fence:
1172 case Instruction::Store:
1173 case Instruction::VAArg:
1174 case Instruction::AtomicCmpXchg:
1175 case Instruction::AtomicRMW:
1176 case Instruction::CatchPad:
1177 case Instruction::CatchRet:
1179 case Instruction::Call:
1180 case Instruction::Invoke:
1181 case Instruction::CallBr:
1183 case Instruction::Load:
1193 case Instruction::VAArg:
1194 case Instruction::Load:
1195 case Instruction::Store:
1196 case Instruction::Fence:
1197 case Instruction::AtomicCmpXchg:
1198 case Instruction::AtomicRMW:
1199 case Instruction::CatchPad:
1200 case Instruction::CatchRet:
1202 case Instruction::Call:
1203 case Instruction::Invoke:
1204 case Instruction::CallBr:
1213 case Instruction::AtomicCmpXchg:
1214 case Instruction::AtomicRMW:
1215 case Instruction::Fence:
1217 case Instruction::Load:
1219 case Instruction::Store:
1229 case Instruction::AtomicCmpXchg:
1230 case Instruction::AtomicRMW:
1231 case Instruction::Load:
1241 case Instruction::AtomicCmpXchg:
1242 case Instruction::AtomicRMW:
1243 case Instruction::Store:
1252 case Instruction::AtomicRMW:
1254 case Instruction::Store:
1256 case Instruction::Load:
1258 case Instruction::AtomicCmpXchg:
1260 case Instruction::Call:
1261 case Instruction::Invoke:
1271 case Instruction::Fence: {
1276 case Instruction::AtomicRMW:
1278 case Instruction::AtomicCmpXchg: {
1283 case Instruction::Store:
1285 case Instruction::Load:
1287 case Instruction::Call:
1288 case Instruction::Invoke:
1289 case Instruction::CallBr:
1296 case Instruction::Store:
1298 case Instruction::Load:
1299 case Instruction::AtomicRMW:
1301 case Instruction::AtomicCmpXchg:
1303 case Instruction::Call:
1304 case Instruction::Invoke:
1306 switch (
II->getIntrinsicID()) {
1307 case Intrinsic::masked_load:
1308 case Intrinsic::masked_gather:
1309 case Intrinsic::masked_expandload:
1310 case Intrinsic::vp_load:
1311 case Intrinsic::vp_gather:
1312 case Intrinsic::experimental_vp_strided_load:
1313 return II->getType();
1314 case Intrinsic::masked_store:
1315 case Intrinsic::masked_scatter:
1316 case Intrinsic::masked_compressstore:
1317 case Intrinsic::vp_store:
1318 case Intrinsic::vp_scatter:
1319 case Intrinsic::experimental_vp_strided_store:
1320 return II->getOperand(0)->getType();
1331 bool IncludePhaseOneUnwind) {
1335 return IncludePhaseOneUnwind;
1343 if (LP->
isFilter(
I) && Clause->getType()->getArrayNumElements() == 0)
1354 case Instruction::Call:
1356 case Instruction::CleanupRet:
1358 case Instruction::CatchSwitch:
1360 case Instruction::Resume:
1362 case Instruction::Invoke: {
1371 case Instruction::CleanupPad:
1373 return IncludePhaseOneUnwind;
1381 case Instruction::Call:
1382 case Instruction::Invoke:
1383 case Instruction::CallBr:
1384 return mayWriteToMemory() ||
mayThrow() || !willReturn();
1385 case Instruction::Load:
1388 case Instruction::CleanupRet:
1390 case Instruction::CatchSwitch:
1392 case Instruction::Store:
1393 case Instruction::VAArg:
1394 case Instruction::Fence:
1395 case Instruction::AtomicCmpXchg:
1396 case Instruction::AtomicRMW:
1397 case Instruction::CatchPad:
1398 case Instruction::CatchRet:
1399 case Instruction::Resume:
1403 "missing instruction with side effects");
1410 !this->isTerminator() && !this->isEHPad();
1416 return CB->hasFnAttr(Attribute::WillReturn) && !isVolatile();
1417 return !isVolatile();
1425 return ID == Intrinsic::lifetime_start || ID == Intrinsic::lifetime_end;
1434 return II->isAssociative();
1452 return II->isCommutative();
1459 return II->isCommutableOperand(
Op);
1466#define HANDLE_TERM_INST(N, OPC, CLASS) \
1467 case Instruction::OPC: \
1468 return static_cast<const CLASS *>(this)->getNumSuccessors();
1469#include "llvm/IR/Instruction.def"
1478#define HANDLE_TERM_INST(N, OPC, CLASS) \
1479 case Instruction::OPC: \
1480 return static_cast<const CLASS *>(this)->getSuccessor(idx);
1481#include "llvm/IR/Instruction.def"
1490#define HANDLE_TERM_INST(N, OPC, CLASS) \
1491 case Instruction::OPC: \
1492 return static_cast<CLASS *>(this)->setSuccessor(idx, B);
1493#include "llvm/IR/Instruction.def"
1503#define HANDLE_TERM_INST(N, OPC, CLASS) \
1504 case Instruction::OPC: \
1505 return static_cast<const CLASS *>(this)->successors();
1506#include "llvm/IR/Instruction.def"
1515 for (
auto I = Succs.begin(),
E = Succs.end();
I !=
E; ++
I)
1517 I.getUse()->set(NewBB);
1532 unsigned SecondIdx = FirstIdx + 1;
1537 for (
unsigned Idx = 0;
Idx < FirstIdx; ++
Idx) {
1543 setMetadata(LLVMContext::MD_prof,
1549 static const unsigned SafeIDs[] = {
1550 LLVMContext::MD_dbg, LLVMContext::MD_prof, LLVMContext::MD_memprof,
1551 LLVMContext::MD_callsite};
1552 copyMetadata(SrcInst, SafeIDs);
1569 for (
const auto &MD : TheMDs) {
1570 if (WL.
empty() || WLS.count(MD.first))
1571 setMetadata(MD.first, MD.second);
1580#define HANDLE_INST(num, opc, clas) \
1581 case Instruction::opc: \
1582 New = cast<clas>(this)->cloneImpl(); \
1584#include "llvm/IR/Instruction.def"
1588 New->SubclassOptionalData = SubclassOptionalData;
1589 New->copyMetadata(*
this);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Register Bank Select
This file contains the simple types necessary to represent the attributes associated with functions a...
static const Function * getParent(const Value *V)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
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...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
This file defines the DenseSet and SmallDenseSet classes.
static MaybeAlign getAlign(Value *Ptr)
Module.h This file contains the declarations for the Module class.
static bool hasNoSignedWrap(BinaryOperator &I)
static bool hasNoUnsignedWrap(BinaryOperator &I)
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
static bool isAtomic(MachineBasicBlock::iterator I)
Machine Check Debug Module
static DebugLoc getDebugLoc(MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
Return the first DebugLoc that has line number information, given a range of instructions.
This file provides utility for Memory Model Relaxation Annotations (MMRAs).
uint64_t IntrinsicInst * II
StandardInstrumentations SI(Mod->getContext(), Debug, VerifyEach)
This file contains the declarations for profiling metadata utility functions.
static bool mayHaveSideEffects(MachineInstr &MI)
Func getContext().diagnose(DiagnosticInfoUnsupported(Func
static unsigned getFastMathFlags(const MachineInstr &I, const SPIRVSubtarget &ST)
static bool canUnwindPastLandingPad(const LandingPadInst *LP, bool IncludePhaseOneUnwind)
static SymbolRef::Type getType(const Symbol *Sym)
static bool isAssociative(const COFFSection &Section)
an instruction to allocate memory on the stack
Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool empty() const
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,...
This class stores enough information to efficiently remove some attributes from an existing AttrBuild...
bool contains(Attribute::AttrKind A) const
Return true if the builder has the specified attribute.
This class holds the attributes for a particular argument, parameter, function, or return value.
LLVM Basic Block Representation.
LLVM_ABI void deleteTrailingDbgRecords()
Delete any trailing DbgRecords at the end of this block, see setTrailingDbgRecords.
LLVM_ABI const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
const Function * getParent() const
Return the enclosing method, or null if none.
LLVM_ABI InstListType::const_iterator getFirstNonPHIIt() const
Returns an iterator to the first instruction in this block that is not a PHINode instruction.
LLVM_ABI DbgMarker * getMarker(InstListType::iterator It)
Return the DbgMarker for the position given by It, so that DbgRecords can be inserted there.
InstListType::iterator iterator
Instruction iterators...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
AttributeList getAttributes() const
Return the attributes for this call.
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.
static LLVM_ABI ConstantInt * getFalse(LLVMContext &Context)
A parsed version of the target data layout string in and methods for querying it.
Per-instruction record of debug-info.
static iterator_range< simple_ilist< DbgRecord >::iterator > getEmptyDbgRecordRange()
Instruction * MarkedInstr
Link back to the Instruction that owns this marker.
LLVM_ABI void eraseFromParent()
simple_ilist< DbgRecord > StoredDbgRecords
List of DbgRecords, the non-instruction equivalent of llvm.dbg.
Base class for non-instruction debug metadata records that have positions within IR.
DebugLoc orElse(DebugLoc Other) const
If this DebugLoc is non-empty, returns this DebugLoc; otherwise, selects Other.
Convenience struct for specifying and reasoning about fast-math flags.
An instruction for ordering other memory operations.
static GEPNoWrapFlags none()
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
InsertPosition(std::nullptr_t)
This instruction inserts a struct field of array element value into an aggregate value.
LLVM_ABI const DebugLoc & getStableDebugLoc() const
Fetch the debug location for this node, unless this is a debug intrinsic, in which case fetch the deb...
LLVM_ABI void dropUBImplyingAttrsAndMetadata(ArrayRef< unsigned > Keep={})
Drop any attributes or metadata that can cause immediate undefined behavior.
LLVM_ABI MemoryEffects getMemoryEffects() const LLVM_READONLY
Return memory effects of the instruction.
LLVM_ABI bool mayThrow(bool IncludePhaseOneUnwind=false) const LLVM_READONLY
Return true if this instruction may throw an exception.
LLVM_ABI Instruction * clone() const
Create a copy of 'this' instruction that is identical in all ways except the following:
LLVM_ABI void setHasNoUnsignedWrap(bool b=true)
Set or clear the nuw flag on this instruction, which must be an operator which supports this flag.
LLVM_ABI bool hasNoNaNs() const LLVM_READONLY
Determine whether the no-NaNs flag is set.
LLVM_ABI void removeFromParent()
This method unlinks 'this' from the containing basic block, but does not delete it.
LLVM_ABI bool hasNoUnsignedWrap() const LLVM_READONLY
Determine whether the no unsigned wrap flag is set.
LLVM_ABI bool hasNoInfs() const LLVM_READONLY
Determine whether the no-infs flag is set.
LLVM_ABI bool isLifetimeStartOrEnd() const LLVM_READONLY
Return true if the instruction is a llvm.lifetime.start or llvm.lifetime.end marker.
LLVM_ABI bool hasPoisonGeneratingAttributes() const LLVM_READONLY
Return true if this instruction has poison-generating attribute.
LLVM_ABI void copyFastMathFlags(FastMathFlags FMF)
Convenience function for transferring all fast-math flag values to this instruction,...
LLVM_ABI 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.
LLVM_ABI void setHasNoSignedZeros(bool B)
Set or clear the no-signed-zeros flag on this instruction, which must be an operator which supports t...
LLVM_ABI bool hasNoSignedZeros() const LLVM_READONLY
Determine whether the no-signed-zeros flag is set.
LLVM_ABI 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.
LLVM_ABI FastMathFlags getFastMathFlagsOrNone() const LLVM_READONLY
Convenience function for getting fast-math flags, or default-constructed FastMathFlags when not a FPM...
LLVM_ABI void copyProfileAndDebugMetadata(const Instruction &SrcInst)
Copy debug, profile, and memprof metadata from SrcInst to this instruction without copying alias-anal...
LLVM_ABI unsigned getNumSuccessors() const LLVM_READONLY
Return the number of successors that this instruction has.
LLVM_ABI bool hasNoSignedWrap() const LLVM_READONLY
Determine whether the no signed wrap flag is set.
LLVM_ABI bool mayWriteToMemory() const LLVM_READONLY
Return true if this instruction may modify memory.
LLVM_ABI void copyIRFlags(const Value *V, bool IncludeWrapFlags=true)
Convenience method to copy supported exact, fast-math, and (optionally) wrapping flags from V to this...
LLVM_ABI void setHasAllowContract(bool B)
Set or clear the allow-contract flag on this instruction, which must be an operator which supports th...
LLVM_ABI bool hasAtomicStore() const LLVM_READONLY
Return true if this atomic instruction stores to memory.
LLVM_ABI void setHasNoSignedWrap(bool b=true)
Set or clear the nsw flag on this instruction, which must be an operator which supports this flag.
LLVM_ABI bool isOnlyUserOfAnyOperand()
It checks if this instruction is the only user of at least one of its operands.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
LLVM_ABI const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
LLVM_ABI void andIRFlags(const Value *V)
Logical 'and' of any supported wrapping, exact, and fast-math flags of V and this instruction.
LLVM_ABI void setHasNoNaNs(bool B)
Set or clear the no-nans flag on this instruction, which must be an operator which supports this flag...
LLVM_ABI bool isAssociative() const LLVM_READONLY
Return true if the instruction is associative:
LLVM_ABI void setHasApproxFunc(bool B)
Set or clear the approximate-math-functions flag on this instruction, which must be an operator which...
LLVM_ABI void moveAfter(Instruction *MovePos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
LLVM_ABI 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.
LLVM_ABI bool hasSameSpecialState(const Instruction *I2, bool IgnoreAlignment=false, bool IntersectAttrs=false) const LLVM_READONLY
This function determines if the speficied instruction has the same "special" characteristics as the c...
LLVM_ABI void moveBefore(InstListType::iterator InsertPos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
LLVM_ABI bool isAtomic() const LLVM_READONLY
Return true if this instruction has an AtomicOrdering of unordered or higher.
LLVM_ABI void setHasAllowReassoc(bool B)
Set or clear the reassociation flag on this instruction, which must be an operator which supports thi...
LLVM_ABI void insertBefore(InstListType::iterator InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified position.
LLVM_ABI void setFastMathFlags(FastMathFlags FMF)
Convenience function for setting multiple fast-math flags on this instruction, which must be an opera...
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
LLVM_ABI bool isIdenticalToWhenDefined(const Instruction *I, bool IntersectAttrs=false) const LLVM_READONLY
This is like isIdenticalTo, except that it ignores the SubclassOptionalData flags,...
LLVM_ABI bool isFast() const LLVM_READONLY
Determine whether all fast-math-flags are set.
LLVM_ABI void replaceSuccessorWith(BasicBlock *OldBB, BasicBlock *NewBB)
Replace specified successor OldBB to point at the provided block.
LLVM_ABI bool isExact() const LLVM_READONLY
Determine whether the exact flag is set.
LLVM_ABI const Function * getFunction() const
Return the function this instruction belongs to.
LLVM_ABI void swapProfMetadata()
If the instruction has "branch_weights" MD_prof metadata and the MDNode has three operands (including...
LLVM_ABI BasicBlock * getSuccessor(unsigned Idx) const LLVM_READONLY
Return the specified successor. This instruction must be a terminator.
LLVM_ABI bool mayHaveSideEffects() const LLVM_READONLY
Return true if the instruction may have side effects.
LLVM_ABI void dropOneDbgRecord(DbgRecord *I)
Erase a single DbgRecord I that is attached to this instruction.
LLVM_ABI void setNonNeg(bool b=true)
Set or clear the nneg flag on this instruction, which must be a zext instruction.
LLVM_ABI Type * getAccessType() const LLVM_READONLY
Return the type this instruction accesses in memory, if any.
LLVM_ABI bool hasAllowReciprocal() const LLVM_READONLY
Determine whether the allow-reciprocal flag is set.
LLVM_ABI bool comesBefore(const Instruction *Other) const
Given an instruction Other in the same basic block as this instruction, return true if this instructi...
LLVM_ABI bool hasNonNeg() const LLVM_READONLY
Determine whether the the nneg flag is set.
LLVM_ABI bool maySynchronize() const LLVM_READONLY
Return true if this instruction may synchronize, in the sense that it may introduce a synchronizes-wi...
LLVM_ABI bool hasPoisonGeneratingFlags() const LLVM_READONLY
Return true if this operator has flags which may cause this instruction to evaluate to poison despite...
LLVM_ABI bool mayReadFromMemory() const LLVM_READONLY
Return true if this instruction may read memory.
LLVM_ABI 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.
LLVM_ABI bool isVolatile() const LLVM_READONLY
Return true if this instruction has a volatile memory access.
LLVM_ABI void setHasNoInfs(bool B)
Set or clear the no-infs flag on this instruction, which must be an operator which supports this flag...
LLVM_ABI iterator_range< const_succ_iterator > successors() const LLVM_READONLY
LLVM_ABI 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 ...
LLVM_ABI 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
LLVM_ABI bool willReturn() const LLVM_READONLY
Return true if the instruction will return (unwinding is considered as a form of returning control fl...
LLVM_ABI bool hasNonDebugLocLoopMetadata() const
LLVM_ABI bool hasApproxFunc() const LLVM_READONLY
Determine whether the approximate-math-functions flag is set.
void getAllMetadataOtherThanDebugLoc(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
This does the same thing as getAllMetadata, except that it filters out the debug location.
LLVM_ABI void moveAfterPreserving(Instruction *MovePos)
See moveBeforePreserving .
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
LLVM_ABI bool hasAtomicLoad() const LLVM_READONLY
Return true if this atomic instruction loads from memory.
LLVM_ABI void setIsExact(bool b=true)
Set or clear the exact flag on this instruction, which must be an operator which supports this flag.
LLVM_ABI void dropPoisonGeneratingMetadata()
Drops metadata that may generate poison.
LLVM_ABI bool mayReadOrWriteMemory() const LLVM_READONLY
Return true if this instruction may read or write memory.
LLVM_ABI void setHasAllowReciprocal(bool B)
Set or clear the allow-reciprocal flag on this instruction, which must be an operator which supports ...
LLVM_ABI void handleMarkerRemoval()
Handle the debug-info implications of this instruction being removed.
LLVM_ABI bool hasUBImplyingAttrs() const LLVM_READONLY
Return true if this instruction has UB-implying attributes that can cause immediate undefined behavio...
LLVM_ABI std::optional< InstListType::iterator > getInsertionPointAfterDef()
Get the first insertion point at which the result of this instruction is defined.
LLVM_ABI void dropPoisonGeneratingFlags()
Drops flags that may cause this instruction to evaluate to poison despite having non-poison inputs.
LLVM_ABI void dropPoisonGeneratingAttributes()
Drops attributes that may generate poison.
LLVM_ABI void dropUBImplyingAttrsAndUnknownMetadata(ArrayRef< unsigned > KnownIDs={})
This function drops non-debug unknown metadata (through dropUnknownNonDebugMetadata).
LLVM_ABI bool isIdenticalTo(const Instruction *I) const LLVM_READONLY
Return true if the specified instruction is exactly identical to the current one.
LLVM_ABI std::optional< simple_ilist< DbgRecord >::iterator > getDbgReinsertionPosition()
Return an iterator to the position of the "Next" DbgRecord after this instruction,...
LLVM_ABI bool hasAllowContract() const LLVM_READONLY
Determine whether the allow-contract flag is set.
LLVM_ABI void moveBeforePreserving(InstListType::iterator MovePos)
Perform a moveBefore operation, while signalling that the caller intends to preserve the original ord...
LLVM_ABI bool hasPoisonGeneratingMetadata() const LLVM_READONLY
Return true if this instruction has poison-generating metadata.
Instruction(const Instruction &)=delete
LLVM_ABI void setSuccessor(unsigned Idx, BasicBlock *BB)
Update the specified successor to point at the provided block.
LLVM_ABI bool isCommutableOperand(unsigned Op) const LLVM_READONLY
Checks if the operand is commutative.
LLVM_ABI void copyMetadata(const Instruction &SrcInst, ArrayRef< unsigned > WL=ArrayRef< unsigned >())
Copy metadata from SrcInst to this instruction.
LLVM_ABI void setFast(bool B)
Set or clear all fast-math-flags on this instruction, which must be an operator which supports this f...
LLVM_ABI bool hasAllowReassoc() const LLVM_READONLY
Determine whether the allow-reassociation flag is set.
LLVM_ABI void dropDbgRecords()
Erase any DbgRecords attached to this instruction.
LLVM_ABI void insertAfter(Instruction *InsertPos)
Insert an unlinked instruction into a basic block immediately after the specified instruction.
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this instruction belongs to.
LLVM_ABI bool isSafeToRemove() const LLVM_READONLY
Return true if the instruction can be removed if the result is unused.
LLVM_ABI InstListType::iterator insertInto(BasicBlock *ParentBB, InstListType::iterator It)
Inserts an unlinked instruction into ParentBB at position It and returns the iterator of the inserted...
LLVM_ABI 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
ArrayRef< MDOperand > operands() const
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
unsigned getNumOperands() const
Return number of MDNode operands.
LLVMContext & getContext() const
Tracking metadata reference owned by Metadata.
static MemoryEffectsBase argMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
static MemoryEffectsBase inaccessibleOrArgMemOnly(ModRefInfo MR=ModRefInfo::ModRef)
static MemoryEffectsBase none()
static MemoryEffectsBase unknown()
iterator_range< const_block_iterator > blocks() const
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
Instruction that can have a nneg flag (zext/uitofp).
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.
void reserve(size_type N)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
A Use represents the edge between a Value definition and its users.
LLVMContext & getContext() const
All values hold a context through their type.
const ParentTy * getParent() const
self_iterator getIterator()
void splice(iterator where, iplist_impl &L2)
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.
constexpr char IsVolatile[]
Key for Kernel::Arg::Metadata::mIsVolatile.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
@ SingleThread
Synchronized with respect to signal handlers executing in the same thread.
bool mayThrow(const MachineInstr &MI)
@ OB
OB - OneByte - Set if this instruction has a one byte opcode.
initializer< Ty > init(const Ty &Val)
@ Switch
The "resume-switch" lowering, where there are separate resume and destroy functions that are shared b...
NodeAddr< PhiNode * > Phi
bool isCommutative(const Instruction *I, const Value *ValWithUses, bool IsCopyable)
unsigned getOpcode(const VPValue *V)
Return the instruction opcode for the recipe defining V or 0 for unsupported recipes and VPValues not...
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
detail::zippy< detail::zip_shortest, T, U, Args... > zip(T &&t, U &&u, Args &&...args)
zip iterator for two or more iteratable types.
LLVM_ABI cl::opt< bool > ProfcheckDisableMetadataFixes
LLVM_ABI unsigned getBranchWeightOffset(const MDNode *ProfileData)
Return the offset to the first branch weight data.
bool isStrongerThanMonotonic(AtomicOrdering AO)
auto successors(const MachineBasicBlock *BB)
@ Load
The value being inserted comes from a load (InsertElement only).
@ Store
The extracted value is stored (ExtractElement only).
LLVM_ABI MDNode * getBranchWeightMDNode(const Instruction &I)
Get the branch weights metadata node.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
bool isStrongerThanUnordered(AtomicOrdering AO)
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
iterator_range< simple_ilist< DbgRecord >::iterator > getDbgRecordRange(DbgMarker *DebugMarker)
Inline helper to return a range of DbgRecords attached to a marker.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
@ Ref
The access may reference the value stored in memory.
@ ModRef
The access may reference and may modify the value stored in memory.
@ Mod
The access may modify the value stored in memory.
@ FSub
Subtraction of floats.
@ Xor
Bitwise or logical XOR of integers.
@ Sub
Subtraction of integers.
DWARFExpression::Operation Op
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
bool equal(L &&LRange, R &&RRange)
Wrapper function around std::equal to detect if pair-wise elements between two ranges are the same.
@ Keep
No function return thunk.
Summary of memprof metadata on allocations.