26 :
User(ty,
Value::InstructionVal + it, Ops, NumOps), Parent(nullptr) {
31 assert(BB &&
"Instruction to insert before is not in a basic block!");
38 :
User(ty,
Value::InstructionVal + it, Ops, NumOps), Parent(nullptr) {
41 assert(InsertAtEnd &&
"Basic block to append to may not be NULL!");
46 assert(!Parent &&
"Instruction still linked in the program!");
101 assert((It == ParentBB->
end() || It->getParent() == ParentBB) &&
102 "It not in ParentBB");
103 return ParentBB->getInstList().
insert(It,
this);
124 "instructions without BB parents have no order");
125 assert(Parent ==
Other->Parent &&
"cross-BB instruction order comparison");
128 return Order <
Other->Order;
132 assert(!
getType()->isVoidTy() &&
"Instruction must define result");
135 if (
auto *PN = dyn_cast<PHINode>(
this)) {
138 }
else if (
auto *II = dyn_cast<InvokeInst>(
this)) {
139 InsertBB = II->getNormalDest();
141 }
else if (isa<CallBrInst>(
this)) {
153 if (InsertPt == InsertBB->
end())
163 cast<OverflowingBinaryOperator>(
this)->setHasNoUnsignedWrap(b);
167 cast<OverflowingBinaryOperator>(
this)->setHasNoSignedWrap(b);
171 cast<PossiblyExactOperator>(
this)->setIsExact(b);
175 return cast<OverflowingBinaryOperator>(
this)->hasNoUnsignedWrap();
179 return cast<OverflowingBinaryOperator>(
this)->hasNoSignedWrap();
183 return cast<Operator>(
this)->hasPoisonGeneratingFlags();
188 case Instruction::Add:
189 case Instruction::Sub:
190 case Instruction::Mul:
191 case Instruction::Shl:
192 cast<OverflowingBinaryOperator>(
this)->setHasNoUnsignedWrap(
false);
193 cast<OverflowingBinaryOperator>(
this)->setHasNoSignedWrap(
false);
196 case Instruction::UDiv:
197 case Instruction::SDiv:
198 case Instruction::AShr:
199 case Instruction::LShr:
200 cast<PossiblyExactOperator>(
this)->setIsExact(
false);
203 case Instruction::GetElementPtr:
204 cast<GetElementPtrInst>(
this)->setIsInBounds(
false);
207 if (isa<FPMathOperator>(
this)) {
230 auto *CB = dyn_cast<CallBase>(
this);
241 for (
unsigned ArgNo = 0; ArgNo < CB->arg_size(); ArgNo++)
242 CB->removeParamAttrs(ArgNo, UBImplyingAttributes);
243 CB->removeRetAttrs(UBImplyingAttributes);
251 unsigned KnownIDs[] = {LLVMContext::MD_annotation, LLVMContext::MD_range,
252 LLVMContext::MD_nonnull, LLVMContext::MD_align};
257 return cast<PossiblyExactOperator>(
this)->isExact();
261 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
262 cast<FPMathOperator>(
this)->setFast(
B);
266 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
267 cast<FPMathOperator>(
this)->setHasAllowReassoc(
B);
271 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
272 cast<FPMathOperator>(
this)->setHasNoNaNs(
B);
276 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
277 cast<FPMathOperator>(
this)->setHasNoInfs(
B);
281 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
282 cast<FPMathOperator>(
this)->setHasNoSignedZeros(
B);
286 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
287 cast<FPMathOperator>(
this)->setHasAllowReciprocal(
B);
291 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
292 cast<FPMathOperator>(
this)->setHasAllowContract(
B);
296 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
297 cast<FPMathOperator>(
this)->setHasApproxFunc(
B);
301 assert(isa<FPMathOperator>(
this) &&
"setting fast-math flag on invalid op");
302 cast<FPMathOperator>(
this)->setFastMathFlags(FMF);
306 assert(isa<FPMathOperator>(
this) &&
"copying fast-math flag on invalid op");
307 cast<FPMathOperator>(
this)->copyFastMathFlags(FMF);
311 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
312 return cast<FPMathOperator>(
this)->isFast();
316 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
317 return cast<FPMathOperator>(
this)->hasAllowReassoc();
321 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
322 return cast<FPMathOperator>(
this)->hasNoNaNs();
326 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
327 return cast<FPMathOperator>(
this)->hasNoInfs();
331 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
332 return cast<FPMathOperator>(
this)->hasNoSignedZeros();
336 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
337 return cast<FPMathOperator>(
this)->hasAllowReciprocal();
341 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
342 return cast<FPMathOperator>(
this)->hasAllowContract();
346 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
347 return cast<FPMathOperator>(
this)->hasApproxFunc();
351 assert(isa<FPMathOperator>(
this) &&
"getting fast-math flag on invalid op");
352 return cast<FPMathOperator>(
this)->getFastMathFlags();
361 if (IncludeWrapFlags && isa<OverflowingBinaryOperator>(
this)) {
362 if (
auto *OB = dyn_cast<OverflowingBinaryOperator>(V)) {
369 if (
auto *PE = dyn_cast<PossiblyExactOperator>(V))
370 if (isa<PossiblyExactOperator>(
this))
374 if (
auto *
FP = dyn_cast<FPMathOperator>(V))
375 if (isa<FPMathOperator>(
this))
378 if (
auto *SrcGEP = dyn_cast<GetElementPtrInst>(V))
379 if (
auto *DestGEP = dyn_cast<GetElementPtrInst>(
this))
380 DestGEP->setIsInBounds(SrcGEP->isInBounds() || DestGEP->isInBounds());
384 if (
auto *OB = dyn_cast<OverflowingBinaryOperator>(V)) {
385 if (isa<OverflowingBinaryOperator>(
this)) {
391 if (
auto *PE = dyn_cast<PossiblyExactOperator>(V))
392 if (isa<PossiblyExactOperator>(
this))
395 if (
auto *
FP = dyn_cast<FPMathOperator>(V)) {
396 if (isa<FPMathOperator>(
this)) {
398 FM &=
FP->getFastMathFlags();
403 if (
auto *SrcGEP = dyn_cast<GetElementPtrInst>(V))
404 if (
auto *DestGEP = dyn_cast<GetElementPtrInst>(
this))
405 DestGEP->setIsInBounds(SrcGEP->isInBounds() && DestGEP->isInBounds());
411 case Ret:
return "ret";
412 case Br:
return "br";
413 case Switch:
return "switch";
414 case IndirectBr:
return "indirectbr";
415 case Invoke:
return "invoke";
416 case Resume:
return "resume";
417 case Unreachable:
return "unreachable";
418 case CleanupRet:
return "cleanupret";
419 case CatchRet:
return "catchret";
420 case CatchPad:
return "catchpad";
421 case CatchSwitch:
return "catchswitch";
422 case CallBr:
return "callbr";
425 case FNeg:
return "fneg";
428 case Add:
return "add";
429 case FAdd:
return "fadd";
430 case Sub:
return "sub";
431 case FSub:
return "fsub";
432 case Mul:
return "mul";
433 case FMul:
return "fmul";
434 case UDiv:
return "udiv";
435 case SDiv:
return "sdiv";
436 case FDiv:
return "fdiv";
437 case URem:
return "urem";
438 case SRem:
return "srem";
439 case FRem:
return "frem";
442 case And:
return "and";
443 case Or :
return "or";
444 case Xor:
return "xor";
447 case Alloca:
return "alloca";
448 case Load:
return "load";
449 case Store:
return "store";
450 case AtomicCmpXchg:
return "cmpxchg";
451 case AtomicRMW:
return "atomicrmw";
452 case Fence:
return "fence";
453 case GetElementPtr:
return "getelementptr";
456 case Trunc:
return "trunc";
457 case ZExt:
return "zext";
458 case SExt:
return "sext";
459 case FPTrunc:
return "fptrunc";
460 case FPExt:
return "fpext";
461 case FPToUI:
return "fptoui";
462 case FPToSI:
return "fptosi";
463 case UIToFP:
return "uitofp";
464 case SIToFP:
return "sitofp";
465 case IntToPtr:
return "inttoptr";
466 case PtrToInt:
return "ptrtoint";
467 case BitCast:
return "bitcast";
468 case AddrSpaceCast:
return "addrspacecast";
471 case ICmp:
return "icmp";
472 case FCmp:
return "fcmp";
473 case PHI:
return "phi";
474 case Select:
return "select";
475 case Call:
return "call";
476 case Shl:
return "shl";
477 case LShr:
return "lshr";
478 case AShr:
return "ashr";
479 case VAArg:
return "va_arg";
480 case ExtractElement:
return "extractelement";
481 case InsertElement:
return "insertelement";
482 case ShuffleVector:
return "shufflevector";
483 case ExtractValue:
return "extractvalue";
484 case InsertValue:
return "insertvalue";
485 case LandingPad:
return "landingpad";
486 case CleanupPad:
return "cleanuppad";
487 case Freeze:
return "freeze";
489 default:
return "<Invalid operator> ";
496 bool IgnoreAlignment)
const {
499 "Can not compare special state of different instructions");
501 if (
const AllocaInst *AI = dyn_cast<AllocaInst>(I1))
502 return AI->getAllocatedType() == cast<AllocaInst>(I2)->getAllocatedType() &&
503 (AI->getAlign() == cast<AllocaInst>(I2)->getAlign() ||
505 if (
const LoadInst *LI = dyn_cast<LoadInst>(I1))
506 return LI->isVolatile() == cast<LoadInst>(I2)->isVolatile() &&
507 (LI->getAlign() == cast<LoadInst>(I2)->getAlign() ||
509 LI->getOrdering() == cast<LoadInst>(I2)->getOrdering() &&
510 LI->getSyncScopeID() == cast<LoadInst>(I2)->getSyncScopeID();
512 return SI->isVolatile() == cast<StoreInst>(I2)->isVolatile() &&
513 (
SI->getAlign() == cast<StoreInst>(I2)->getAlign() ||
515 SI->getOrdering() == cast<StoreInst>(I2)->getOrdering() &&
516 SI->getSyncScopeID() == cast<StoreInst>(I2)->getSyncScopeID();
517 if (
const CmpInst *CI = dyn_cast<CmpInst>(I1))
518 return CI->getPredicate() == cast<CmpInst>(I2)->getPredicate();
519 if (
const CallInst *CI = dyn_cast<CallInst>(I1))
520 return CI->isTailCall() == cast<CallInst>(I2)->isTailCall() &&
521 CI->getCallingConv() == cast<CallInst>(I2)->getCallingConv() &&
522 CI->getAttributes() == cast<CallInst>(I2)->getAttributes() &&
523 CI->hasIdenticalOperandBundleSchema(*cast<CallInst>(I2));
524 if (
const InvokeInst *CI = dyn_cast<InvokeInst>(I1))
525 return CI->getCallingConv() == cast<InvokeInst>(I2)->getCallingConv() &&
526 CI->getAttributes() == cast<InvokeInst>(I2)->getAttributes() &&
527 CI->hasIdenticalOperandBundleSchema(*cast<InvokeInst>(I2));
528 if (
const CallBrInst *CI = dyn_cast<CallBrInst>(I1))
529 return CI->getCallingConv() == cast<CallBrInst>(I2)->getCallingConv() &&
530 CI->getAttributes() == cast<CallBrInst>(I2)->getAttributes() &&
531 CI->hasIdenticalOperandBundleSchema(*cast<CallBrInst>(I2));
533 return IVI->getIndices() == cast<InsertValueInst>(I2)->getIndices();
535 return EVI->getIndices() == cast<ExtractValueInst>(I2)->getIndices();
536 if (
const FenceInst *FI = dyn_cast<FenceInst>(I1))
537 return FI->getOrdering() == cast<FenceInst>(I2)->getOrdering() &&
538 FI->getSyncScopeID() == cast<FenceInst>(I2)->getSyncScopeID();
540 return CXI->isVolatile() == cast<AtomicCmpXchgInst>(I2)->isVolatile() &&
541 CXI->isWeak() == cast<AtomicCmpXchgInst>(I2)->isWeak() &&
542 CXI->getSuccessOrdering() ==
543 cast<AtomicCmpXchgInst>(I2)->getSuccessOrdering() &&
544 CXI->getFailureOrdering() ==
545 cast<AtomicCmpXchgInst>(I2)->getFailureOrdering() &&
546 CXI->getSyncScopeID() ==
547 cast<AtomicCmpXchgInst>(I2)->getSyncScopeID();
549 return RMWI->getOperation() == cast<AtomicRMWInst>(I2)->getOperation() &&
550 RMWI->isVolatile() == cast<AtomicRMWInst>(I2)->isVolatile() &&
551 RMWI->getOrdering() == cast<AtomicRMWInst>(I2)->getOrdering() &&
552 RMWI->getSyncScopeID() == cast<AtomicRMWInst>(I2)->getSyncScopeID();
554 return SVI->getShuffleMask() ==
555 cast<ShuffleVectorInst>(I2)->getShuffleMask();
557 return GEP->getSourceElementType() ==
558 cast<GetElementPtrInst>(I2)->getSourceElementType();
584 if (
const PHINode *thisPHI = dyn_cast<PHINode>(
this)) {
585 const PHINode *otherPHI = cast<PHINode>(
I);
586 return std::equal(thisPHI->block_begin(), thisPHI->block_end(),
596 unsigned flags)
const {
603 getType()->getScalarType() !=
I->getType()->getScalarType() :
612 I->getOperand(i)->getType()->getScalarType() :
624 const PHINode *PN = dyn_cast<PHINode>(
I);
626 if (
I->getParent() != BB)
639 default:
return false;
640 case Instruction::VAArg:
641 case Instruction::Load:
642 case Instruction::Fence:
643 case Instruction::AtomicCmpXchg:
644 case Instruction::AtomicRMW:
645 case Instruction::CatchPad:
646 case Instruction::CatchRet:
648 case Instruction::Call:
649 case Instruction::Invoke:
650 case Instruction::CallBr:
651 return !cast<CallBase>(
this)->onlyWritesMemory();
652 case Instruction::Store:
653 return !cast<StoreInst>(
this)->isUnordered();
659 default:
return false;
660 case Instruction::Fence:
661 case Instruction::Store:
662 case Instruction::VAArg:
663 case Instruction::AtomicCmpXchg:
664 case Instruction::AtomicRMW:
665 case Instruction::CatchPad:
666 case Instruction::CatchRet:
668 case Instruction::Call:
669 case Instruction::Invoke:
670 case Instruction::CallBr:
671 return !cast<CallBase>(
this)->onlyReadsMemory();
672 case Instruction::Load:
673 return !cast<LoadInst>(
this)->isUnordered();
681 case Instruction::AtomicCmpXchg:
682 case Instruction::AtomicRMW:
683 case Instruction::Fence:
685 case Instruction::Load:
687 case Instruction::Store:
697 case Instruction::AtomicCmpXchg:
698 case Instruction::AtomicRMW:
699 case Instruction::Load:
709 case Instruction::AtomicCmpXchg:
710 case Instruction::AtomicRMW:
711 case Instruction::Store:
720 case Instruction::AtomicRMW:
721 return cast<AtomicRMWInst>(
this)->isVolatile();
722 case Instruction::Store:
723 return cast<StoreInst>(
this)->isVolatile();
724 case Instruction::Load:
725 return cast<LoadInst>(
this)->isVolatile();
726 case Instruction::AtomicCmpXchg:
727 return cast<AtomicCmpXchgInst>(
this)->isVolatile();
728 case Instruction::Call:
729 case Instruction::Invoke:
731 if (
auto *II = dyn_cast<IntrinsicInst>(
this)) {
732 if (
auto *
MI = dyn_cast<MemIntrinsic>(II))
733 return MI->isVolatile();
734 switch (II->getIntrinsicID()) {
736 case Intrinsic::matrix_column_major_load:
737 return cast<ConstantInt>(II->getArgOperand(2))->isOne();
738 case Intrinsic::matrix_column_major_store:
739 return cast<ConstantInt>(II->getArgOperand(3))->isOne();
747 bool IncludePhaseOneUnwind) {
751 return IncludePhaseOneUnwind;
770 case Instruction::Call:
771 return !cast<CallInst>(
this)->doesNotThrow();
772 case Instruction::CleanupRet:
773 return cast<CleanupReturnInst>(
this)->unwindsToCaller();
774 case Instruction::CatchSwitch:
775 return cast<CatchSwitchInst>(
this)->unwindsToCaller();
776 case Instruction::Resume:
778 case Instruction::Invoke: {
781 BasicBlock *UnwindDest = cast<InvokeInst>(
this)->getUnwindDest();
783 if (
auto *LP = dyn_cast<LandingPadInst>(Pad))
787 case Instruction::CleanupPad:
789 return IncludePhaseOneUnwind;
806 if (
auto *
SI = dyn_cast<StoreInst>(
this))
807 return !
SI->isVolatile();
809 if (
const auto *CB = dyn_cast<CallBase>(
this))
810 return CB->hasFnAttr(Attribute::WillReturn);
815 auto *II = dyn_cast<IntrinsicInst>(
this);
819 return ID == Intrinsic::lifetime_start ||
ID == Intrinsic::lifetime_end;
823 auto *II = dyn_cast<IntrinsicInst>(
this);
827 return ID == Intrinsic::launder_invariant_group ||
828 ID == Intrinsic::strip_invariant_group;
832 return isa<DbgInfoIntrinsic>(
this) || isa<PseudoProbeInst>(
this);
838 if (!isa<DbgInfoIntrinsic>(
I) && !(SkipPseudoOp && isa<PseudoProbeInst>(
I)))
846 if (!isa<DbgInfoIntrinsic>(
I) && !(SkipPseudoOp && isa<PseudoProbeInst>(
I)))
859 return cast<FPMathOperator>(
this)->hasAllowReassoc() &&
860 cast<FPMathOperator>(
this)->hasNoSignedZeros();
867 if (
auto *II = dyn_cast<IntrinsicInst>(
this))
868 return II->isCommutative();
875#define HANDLE_TERM_INST(N, OPC, CLASS) \
876 case Instruction::OPC: \
877 return static_cast<const CLASS *>(this)->getNumSuccessors();
878#include "llvm/IR/Instruction.def"
887#define HANDLE_TERM_INST(N, OPC, CLASS) \
888 case Instruction::OPC: \
889 return static_cast<const CLASS *>(this)->getSuccessor(idx);
890#include "llvm/IR/Instruction.def"
899#define HANDLE_TERM_INST(N, OPC, CLASS) \
900 case Instruction::OPC: \
901 return static_cast<CLASS *>(this)->setSuccessor(idx, B);
902#include "llvm/IR/Instruction.def"
911 Idx != NumSuccessors; ++
Idx)
938 for (
unsigned M : WL)
945 for (
const auto &MD : TheMDs) {
946 if (WL.
empty() || WLS.count(MD.first))
949 if (WL.
empty() || WLS.count(LLVMContext::MD_dbg))
958#define HANDLE_INST(num, opc, clas) \
959 case Instruction::opc: \
960 New = cast<clas>(this)->cloneImpl(); \
962#include "llvm/IR/Instruction.def"
967 New->copyMetadata(*
this);
amdgpu AMDGPU Register Bank Select
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)
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.
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.
const Function * getParent() const
Return the enclosing method, or null if none.
InstListType::iterator iterator
Instruction iterators...
bool isInstrOrderValid() const
Returns true if the Order field of child Instructions is valid.
void splice(BasicBlock::iterator ToIt, BasicBlock *FromBB)
Transfer all instructions from FromBB to this basic block at ToIt.
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.
Implements a dense probed hash-table based set.
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.
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...
bool hasNoSignedZeros() const LLVM_READONLY
Determine whether the no-signed-zeros flag is set.
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.
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
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.
bool isTerminator() const
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 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...
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.
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.
Instruction * getInsertionPointAfterDef()
Get the first insertion point at which the result of this instruction is defined.
void setHasAllowReciprocal(bool B)
Set or clear the allow-reciprocal flag on this instruction, which must be an operator which supports ...
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.
SymbolTableList< Instruction >::iterator insertInto(BasicBlock *ParentBB, SymbolTableList< Instruction >::iterator It)
Inserts an unlinked instruction into ParentBB at position It and returns the iterator of the inserted...
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.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
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 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.
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.
This instruction constructs a fixed permutation of two input vectors.
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()
Iterator for intrusive lists based on ilist_node.
self_iterator getIterator()
Instruction * getPrevNode()
Instruction * getNextNode()
Get the next node, or nullptr for the list tail.
iterator erase(iterator where)
pointer remove(iterator &IT)
iterator insert(iterator where, pointer New)
#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.