97#include "llvm/IR/IntrinsicsAArch64.h"
98#include "llvm/IR/IntrinsicsAMDGPU.h"
99#include "llvm/IR/IntrinsicsARM.h"
100#include "llvm/IR/IntrinsicsNVPTX.h"
101#include "llvm/IR/IntrinsicsWebAssembly.h"
141 cl::desc(
"Ensure that llvm.experimental.noalias.scope.decl for identical "
142 "scopes are not dominating"));
165 *
OS <<
"; ModuleID = '" << M->getModuleIdentifier() <<
"'\n";
178 V.printAsOperand(*
OS,
true,
MST);
183 void Write(
const DbgRecord *DR) {
199 *
OS <<
"declare_value";
220 template <
class T>
void Write(
const MDTupleTypedArrayWrapper<T> &MD) {
224 void Write(
const NamedMDNode *NMD) {
237 void Write(
const Comdat *
C) {
243 void Write(
const APInt *AI) {
249 void Write(
const unsigned i) { *
OS << i <<
'\n'; }
255 *
OS <<
A->getAsString() <<
'\n';
259 void Write(
const AttributeSet *AS) {
266 void Write(
const AttributeList *AL) {
272 void Write(Printable
P) { *
OS <<
P <<
'\n'; }
274 template <
typename T>
void Write(ArrayRef<T> Vs) {
275 for (
const T &V : Vs)
279 template <
typename T1,
typename... Ts>
280 void WriteTs(
const T1 &
V1,
const Ts &... Vs) {
285 template <
typename... Ts>
void WriteTs() {}
294 *
OS << Message <<
'\n';
302 template <
typename T1,
typename... Ts>
312 *
OS << Message <<
'\n';
318 template <
typename T1,
typename... Ts>
350 Type *LandingPadResultTy;
357 bool HasDebugInfo =
false;
400 SawFrameEscape(
false), TBAAVerifyHelper(this) {
401 TreatBrokenDebugInfoAsError = ShouldTreatBrokenDebugInfoAsError;
404 bool hasBrokenDebugInfo()
const {
return BrokenDebugInfo; }
406 bool verify(
const Function &
F) {
407 llvm::TimeTraceScope timeScope(
"Verifier");
409 "An instance of this class only works with a specific module!");
419 for (
const BasicBlock &BB :
F) {
420 if (!BB.empty() && BB.back().isTerminator())
424 *OS <<
"Basic Block in function '" <<
F.getName()
425 <<
"' does not have terminator!\n";
426 BB.printAsOperand(*OS,
true, MST);
434 DT.recalculate(
const_cast<Function &
>(
F));
436 auto FailureCB = [
this](
const Twine &Message) {
437 this->CheckFailed(Message);
439 ConvergenceVerifyHelper.initialize(OS, FailureCB,
F);
444 verifySiblingFuncletUnwinds();
446 if (ConvergenceVerifyHelper.sawTokens())
447 ConvergenceVerifyHelper.verify(DT);
449 InstsInThisBlock.clear();
451 LandingPadResultTy =
nullptr;
452 SawFrameEscape =
false;
453 SiblingFuncletInfo.clear();
454 verifyNoAliasScopeDecl();
455 NoAliasScopeDecls.clear();
465 for (
const Function &
F : M)
466 if (
F.getIntrinsicID() == Intrinsic::experimental_deoptimize)
467 DeoptimizeDeclarations.push_back(&
F);
471 verifyFrameRecoverIndices();
472 for (
const GlobalVariable &GV :
M.globals())
473 visitGlobalVariable(GV);
475 for (
const GlobalAlias &GA :
M.aliases())
476 visitGlobalAlias(GA);
478 for (
const GlobalIFunc &GI :
M.ifuncs())
479 visitGlobalIFunc(GI);
481 for (
const NamedMDNode &NMD :
M.named_metadata())
482 visitNamedMDNode(NMD);
484 for (
const StringMapEntry<Comdat> &SMEC :
M.getComdatSymbolTable())
485 visitComdat(SMEC.getValue());
489 visitModuleCommandLines();
490 visitModuleErrnoTBAA();
492 verifyCompileUnits();
494 verifyDeoptimizeCallingConvs();
495 DISubprogramAttachments.clear();
501 enum class AreDebugLocsAllowed {
No,
Yes };
505 enum class RangeLikeMetadataKind {
512 void visitGlobalValue(
const GlobalValue &GV);
513 void visitGlobalVariable(
const GlobalVariable &GV);
514 void visitGlobalAlias(
const GlobalAlias &GA);
515 void visitGlobalIFunc(
const GlobalIFunc &GI);
516 void visitAliaseeSubExpr(
const GlobalAlias &
A,
const Constant &
C);
517 void visitAliaseeSubExpr(SmallPtrSetImpl<const GlobalAlias *> &Visited,
518 const GlobalAlias &
A,
const Constant &
C);
519 void visitNamedMDNode(
const NamedMDNode &NMD);
520 void visitMDNode(
const MDNode &MD, AreDebugLocsAllowed AllowLocs);
521 void visitMetadataAsValue(
const MetadataAsValue &MD, Function *
F);
522 void visitValueAsMetadata(
const ValueAsMetadata &MD, Function *
F);
523 void visitDIArgList(
const DIArgList &AL, Function *
F);
524 void visitComdat(
const Comdat &
C);
525 void visitModuleIdents();
526 void visitModuleCommandLines();
527 void visitModuleErrnoTBAA();
528 void visitModuleFlags();
529 void visitModuleFlag(
const MDNode *
Op,
530 DenseMap<const MDString *, const MDNode *> &SeenIDs,
531 SmallVectorImpl<const MDNode *> &Requirements);
532 void visitModuleFlagCGProfileEntry(
const MDOperand &MDO);
533 void visitFunction(
const Function &
F);
534 void visitBasicBlock(BasicBlock &BB);
535 void verifyRangeLikeMetadata(
const Value &V,
const MDNode *
Range,
Type *Ty,
536 RangeLikeMetadataKind Kind);
537 void visitRangeMetadata(Instruction &
I, MDNode *
Range,
Type *Ty);
538 void visitNoFPClassMetadata(Instruction &
I, MDNode *
Range,
Type *Ty);
539 void visitNoaliasAddrspaceMetadata(Instruction &
I, MDNode *
Range,
Type *Ty);
540 void visitDereferenceableMetadata(Instruction &
I, MDNode *MD);
541 void visitNofreeMetadata(Instruction &
I, MDNode *MD);
542 void visitProfMetadata(Instruction &
I, MDNode *MD);
543 void visitCallStackMetadata(MDNode *MD);
544 void visitMemProfMetadata(Instruction &
I, MDNode *MD);
545 void visitCallsiteMetadata(Instruction &
I, MDNode *MD);
546 void visitCalleeTypeMetadata(Instruction &
I, MDNode *MD);
547 void visitDIAssignIDMetadata(Instruction &
I, MDNode *MD);
548 void visitMMRAMetadata(Instruction &
I, MDNode *MD);
549 void visitAnnotationMetadata(MDNode *Annotation);
550 void visitAliasScopeMetadata(
const MDNode *MD);
551 void visitAliasScopeListMetadata(
const MDNode *MD);
552 void visitAccessGroupMetadata(
const MDNode *MD);
553 void visitCapturesMetadata(Instruction &
I,
const MDNode *Captures);
554 void visitAllocTokenMetadata(Instruction &
I, MDNode *MD);
555 void visitInlineHistoryMetadata(Instruction &
I, MDNode *MD);
556 void visitMemCacheHintMetadata(Instruction &
I, MDNode *MD);
558 template <
class Ty>
bool isValidMetadataArray(
const MDTuple &
N);
559#define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS) void visit##CLASS(const CLASS &N);
560#include "llvm/IR/Metadata.def"
561 void visitDIType(
const DIType &
N);
562 void visitDIScope(
const DIScope &
N);
586 void checkPtrToAddr(
Type *SrcTy,
Type *DestTy,
const Value &V);
591 void visitPHINode(
PHINode &PN);
600 void visitVAArgInst(
VAArgInst &VAA) { visitInstruction(VAA); }
601 void visitCallInst(CallInst &CI);
602 void visitInvokeInst(InvokeInst &
II);
603 void visitGetElementPtrInst(GetElementPtrInst &
GEP);
604 void visitLoadInst(LoadInst &LI);
605 void visitStoreInst(StoreInst &SI);
606 void verifyDominatesUse(Instruction &
I,
unsigned i);
607 void visitInstruction(Instruction &
I);
608 void visitTerminator(Instruction &
I);
609 void visitCondBrInst(CondBrInst &BI);
610 void visitReturnInst(ReturnInst &RI);
611 void visitSwitchInst(SwitchInst &SI);
612 void visitIndirectBrInst(IndirectBrInst &BI);
613 void visitCallBrInst(CallBrInst &CBI);
614 void visitSelectInst(SelectInst &SI);
615 void visitUserOp1(Instruction &
I);
616 void visitUserOp2(Instruction &
I) { visitUserOp1(
I); }
618 void visitConstrainedFPIntrinsic(ConstrainedFPIntrinsic &FPI);
619 void visitVPIntrinsic(VPIntrinsic &VPI);
620 void visitDbgLabelIntrinsic(StringRef Kind, DbgLabelInst &DLI);
621 void visitAtomicCmpXchgInst(AtomicCmpXchgInst &CXI);
622 void visitAtomicRMWInst(AtomicRMWInst &RMWI);
623 void visitFenceInst(FenceInst &FI);
624 void visitAllocaInst(AllocaInst &AI);
625 void visitExtractValueInst(ExtractValueInst &EVI);
626 void visitInsertValueInst(InsertValueInst &IVI);
627 void visitEHPadPredecessors(Instruction &
I);
628 void visitLandingPadInst(LandingPadInst &LPI);
629 void visitResumeInst(ResumeInst &RI);
630 void visitCatchPadInst(CatchPadInst &CPI);
631 void visitCatchReturnInst(CatchReturnInst &CatchReturn);
632 void visitCleanupPadInst(CleanupPadInst &CPI);
633 void visitFuncletPadInst(FuncletPadInst &FPI);
634 void visitCatchSwitchInst(CatchSwitchInst &CatchSwitch);
635 void visitCleanupReturnInst(CleanupReturnInst &CRI);
637 void verifySwiftErrorCall(CallBase &
Call,
const Value *SwiftErrorVal);
638 void verifySwiftErrorValue(
const Value *SwiftErrorVal);
639 void verifyTailCCMustTailAttrs(
const AttrBuilder &Attrs, StringRef
Context);
640 void verifyMustTailCall(CallInst &CI);
641 bool verifyAttributeCount(AttributeList Attrs,
unsigned Params);
642 void verifyAttributeTypes(AttributeSet Attrs,
const Value *V);
643 void verifyParameterAttrs(AttributeSet Attrs,
Type *Ty,
const Value *V);
644 void checkUnsignedBaseTenFuncAttr(AttributeList Attrs, StringRef Attr,
646 void verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs,
647 const Value *V,
bool IsIntrinsic,
bool IsInlineAsm);
648 void verifyFunctionMetadata(
ArrayRef<std::pair<unsigned, MDNode *>> MDs);
649 void verifyUnknownProfileMetadata(MDNode *MD);
650 void visitConstantExprsRecursively(
const Constant *EntryC);
651 void visitConstantExpr(
const ConstantExpr *CE);
652 void visitConstantPtrAuth(
const ConstantPtrAuth *CPA);
653 void verifyInlineAsmCall(
const CallBase &
Call);
654 void verifyStatepoint(
const CallBase &
Call);
655 void verifyFrameRecoverIndices();
656 void verifySiblingFuncletUnwinds();
658 void verifyFragmentExpression(
const DbgVariableRecord &
I);
659 template <
typename ValueOrMetadata>
660 void verifyFragmentExpression(
const DIVariable &V,
662 ValueOrMetadata *
Desc);
663 void verifyFnArgs(
const DbgVariableRecord &DVR);
664 void verifyNotEntryValue(
const DbgVariableRecord &
I);
667 void verifyCompileUnits();
671 void verifyDeoptimizeCallingConvs();
673 void verifyAttachedCallBundle(
const CallBase &
Call,
674 const OperandBundleUse &BU);
677 void verifyNoAliasScopeDecl();
683#define Check(C, ...) \
686 CheckFailed(__VA_ARGS__); \
693#define CheckDI(C, ...) \
696 DebugInfoCheckFailed(__VA_ARGS__); \
704 CheckDI(
I.DebugMarker->MarkedInstr == &
I,
705 "Instruction has invalid DebugMarker", &
I);
707 "PHI Node must not have any attached DbgRecords", &
I);
710 "DbgRecord had invalid DebugMarker", &
I, &DR);
713 visitMDNode(*
Loc, AreDebugLocsAllowed::Yes);
718 verifyFragmentExpression(*DVR);
719 verifyNotEntryValue(*DVR);
726void Verifier::visit(Instruction &
I) {
728 for (
unsigned i = 0, e =
I.getNumOperands(); i != e; ++i)
729 Check(
I.getOperand(i) !=
nullptr,
"Operand is null", &
I);
741 while (!WorkList.
empty()) {
743 if (!Visited.
insert(Cur).second)
750void Verifier::visitGlobalValue(
const GlobalValue &GV) {
752 "Global is external, but doesn't have external or weak linkage!", &GV);
755 if (
const MDNode *Associated =
756 GO->getMetadata(LLVMContext::MD_associated)) {
757 Check(Associated->getNumOperands() == 1,
758 "associated metadata must have one operand", &GV, Associated);
759 const Metadata *
Op = Associated->getOperand(0).get();
760 Check(
Op,
"associated metadata must have a global value", GO, Associated);
763 Check(VM,
"associated metadata must be ValueAsMetadata", GO, Associated);
766 "associated value must be pointer typed", GV, Associated);
768 const Value *Stripped = VM->getValue()->stripPointerCastsAndAliases();
770 "associated metadata must point to a GlobalObject", GO, Stripped);
771 Check(Stripped != GO,
772 "global values should not associate to themselves", GO,
778 if (
const MDNode *AbsoluteSymbol =
779 GO->getMetadata(LLVMContext::MD_absolute_symbol)) {
780 verifyRangeLikeMetadata(*GO, AbsoluteSymbol,
781 DL.getIntPtrType(GO->getType()),
782 RangeLikeMetadataKind::AbsoluteSymbol);
785 if (GO->hasMetadata(LLVMContext::MD_implicit_ref)) {
786 Check(!GO->isDeclaration(),
787 "ref metadata must not be placed on a declaration", GO);
790 GO->getMetadata(LLVMContext::MD_implicit_ref, MDs);
791 for (
const MDNode *MD : MDs) {
792 Check(MD->getNumOperands() == 1,
"ref metadata must have one operand",
796 Check(VM,
"ref metadata must be ValueAsMetadata", GO, MD);
799 "ref value must be pointer typed", GV, MD);
803 "ref metadata must point to a GlobalObject", GO, Stripped);
804 Check(Stripped != GO,
"values should not reference themselves", GO,
810 if (
auto *Props = GO->getMetadata(LLVMContext::MD_elf_section_properties)) {
811 Check(Props->getNumOperands() == 2,
812 "elf_section_properties metadata must have two operands", GO,
814 if (Props->getNumOperands() == 2) {
816 Check(
Type,
"type field must be ConstantAsMetadata", GO, Props);
818 Check(TypeInt,
"type field must be ConstantInt", GO, Props);
821 Check(Entsize,
"entsize field must be ConstantAsMetadata", GO, Props);
823 Check(EntsizeInt,
"entsize field must be ConstantInt", GO, Props);
829 "Only global variables can have appending linkage!", &GV);
834 "Only global arrays can have appending linkage!", GVar);
838 Check(!GV.
hasComdat(),
"Declaration may not be in a Comdat!", &GV);
842 "dllexport GlobalValue must have default or protected visibility",
847 "dllimport GlobalValue must have default visibility", &GV);
848 Check(!GV.
isDSOLocal(),
"GlobalValue with DLLImport Storage is dso_local!",
854 "Global is marked as dllimport, but not external", &GV);
859 "GlobalValue with local linkage or non-default "
860 "visibility must be dso_local!",
865 if (!
I->getParent() || !
I->getParent()->getParent())
866 CheckFailed(
"Global is referenced by parentless instruction!", &GV, &M,
868 else if (
I->getParent()->getParent()->getParent() != &M)
869 CheckFailed(
"Global is referenced in a different module!", &GV, &M,
I,
870 I->getParent()->getParent(),
871 I->getParent()->getParent()->getParent());
874 if (
F->getParent() != &M)
875 CheckFailed(
"Global is used by function in a different module", &GV, &M,
883void Verifier::visitGlobalVariable(
const GlobalVariable &GV) {
887 Check(
A->value() <= Value::MaximumAlignment,
888 "huge alignment values are unsupported", &GV);
893 "Global variable initializer type does not match global "
897 "Global variable initializer must be sized", &GV);
903 "'common' global must have a zero initializer!", &GV);
906 Check(!GV.
hasComdat(),
"'common' global may not be in a Comdat!", &GV);
911 GV.
getName() ==
"llvm.global_dtors")) {
913 "invalid linkage for intrinsic global variable", &GV);
915 "invalid uses of intrinsic global variable", &GV);
922 PointerType::get(
Context,
DL.getProgramAddressSpace());
926 "wrong type for intrinsic global variable", &GV);
928 "the third field of the element type is mandatory, "
929 "specify ptr null to migrate from the obsoleted 2-field form");
937 GV.
getName() ==
"llvm.compiler.used")) {
939 "invalid linkage for intrinsic global variable", &GV);
941 "invalid uses of intrinsic global variable", &GV);
945 Check(PTy,
"wrong type for intrinsic global variable", &GV);
949 Check(InitArray,
"wrong initializer for intrinsic global variable",
955 Twine(
"invalid ") + GV.
getName() +
" member", V);
957 Twine(
"members of ") + GV.
getName() +
" must be named", V);
966 for (
auto *MD : MDs) {
968 visitDIGlobalVariableExpression(*GVE);
970 CheckDI(
false,
"!dbg attachment of global variable must be a "
971 "DIGlobalVariableExpression");
981 "Global @" + GV.
getName() +
" has illegal target extension type",
990 "Global variable is too large to fit into the address space", &GV,
994 visitGlobalValue(GV);
1001 visitGlobalValue(GV);
1004void Verifier::visitAliaseeSubExpr(
const GlobalAlias &GA,
const Constant &
C) {
1005 SmallPtrSet<const GlobalAlias*, 4> Visited;
1007 visitAliaseeSubExpr(Visited, GA,
C);
1010void Verifier::visitAliaseeSubExpr(SmallPtrSetImpl<const GlobalAlias*> &Visited,
1011 const GlobalAlias &GA,
const Constant &
C) {
1015 "available_externally alias must point to available_externally "
1026 Check(Visited.
insert(GA2).second,
"Aliases cannot form a cycle", &GA);
1028 Check(!GA2->isInterposable(),
1029 "Alias cannot point to an interposable alias", &GA);
1038 visitConstantExprsRecursively(CE);
1040 for (
const Use &U :
C.operands()) {
1043 visitAliaseeSubExpr(Visited, GA, *GA2->getAliasee());
1045 visitAliaseeSubExpr(Visited, GA, *C2);
1049void Verifier::visitGlobalAlias(
const GlobalAlias &GA) {
1051 "Alias should have private, internal, linkonce, weak, linkonce_odr, "
1052 "weak_odr, external, or available_externally linkage!",
1055 Check(Aliasee,
"Aliasee cannot be NULL!", &GA);
1057 "Alias and aliasee types should match!", &GA);
1060 "Aliasee should be either GlobalValue or ConstantExpr", &GA);
1062 visitAliaseeSubExpr(GA, *Aliasee);
1064 visitGlobalValue(GA);
1067void Verifier::visitGlobalIFunc(
const GlobalIFunc &GI) {
1068 visitGlobalValue(GI);
1072 for (
const auto &
I : MDs) {
1073 CheckDI(
I.first != LLVMContext::MD_dbg,
1074 "an ifunc may not have a !dbg attachment", &GI);
1075 Check(
I.first != LLVMContext::MD_prof,
1076 "an ifunc may not have a !prof attachment", &GI);
1077 visitMDNode(*
I.second, AreDebugLocsAllowed::No);
1081 "IFunc should have private, internal, linkonce, weak, linkonce_odr, "
1082 "weak_odr, or external linkage!",
1087 Check(Resolver,
"IFunc must have a Function resolver", &GI);
1089 "IFunc resolver must be a definition", &GI);
1096 "IFunc resolver must return a pointer", &GI);
1099 "IFunc resolver has incorrect type", &GI);
1102void Verifier::visitNamedMDNode(
const NamedMDNode &NMD) {
1107 "unrecognized named metadata node in the llvm.dbg namespace", &NMD);
1108 for (
const MDNode *MD : NMD.
operands()) {
1109 if (NMD.
getName() ==
"llvm.dbg.cu")
1115 visitMDNode(*MD, AreDebugLocsAllowed::Yes);
1119void Verifier::visitMDNode(
const MDNode &BaseMD,
1120 AreDebugLocsAllowed AllowLocs) {
1123 if (!MDNodes.
insert(&BaseMD).second)
1126 std::queue<const MDNode *> Worklist;
1127 Worklist.push(&BaseMD);
1129 while (!Worklist.empty()) {
1130 const MDNode *CurrentMD = Worklist.front();
1133 "MDNode context does not match Module context!", CurrentMD);
1138 case Metadata::MDTupleKind:
1140#define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS) \
1141 case Metadata::CLASS##Kind: \
1142 visit##CLASS(cast<CLASS>(*CurrentMD)); \
1144#include "llvm/IR/Metadata.def"
1153 "DILocation not allowed within this metadata node", CurrentMD,
1161 visitValueAsMetadata(*V,
nullptr);
1175 "Expected second operand to be an integer constant of type i32 or "
1183 Check(CurrentMD->
isResolved(),
"All nodes should be resolved!", CurrentMD);
1187void Verifier::visitValueAsMetadata(
const ValueAsMetadata &MD, Function *
F) {
1190 "Unexpected metadata round-trip through values", &MD, MD.
getValue());
1196 Check(
F,
"function-local metadata used outside a function", L);
1202 Check(
I->getParent(),
"function-local metadata not in basic block", L,
I);
1208 assert(ActualF &&
"Unimplemented function local metadata case!");
1210 Check(ActualF ==
F,
"function-local metadata used in wrong function", L);
1213void Verifier::visitDIArgList(
const DIArgList &AL, Function *
F) {
1214 for (
const ValueAsMetadata *VAM :
AL.getArgs())
1215 visitValueAsMetadata(*VAM,
F);
1218void Verifier::visitMetadataAsValue(
const MetadataAsValue &MDV, Function *
F) {
1221 visitMDNode(*
N, AreDebugLocsAllowed::No);
1227 if (!MDNodes.
insert(MD).second)
1231 visitValueAsMetadata(*V,
F);
1234 visitDIArgList(*AL,
F);
1242void Verifier::visitDILocation(
const DILocation &
N) {
1244 "location requires a valid scope", &
N,
N.getRawScope());
1245 if (
auto *IA =
N.getRawInlinedAt())
1248 CheckDI(
SP->isDefinition(),
"scope points into the type hierarchy", &
N);
1251void Verifier::visitGenericDINode(
const GenericDINode &
N) {
1255void Verifier::visitDIScope(
const DIScope &
N) {
1256 if (
auto *
F =
N.getRawFile())
1260void Verifier::visitDIType(
const DIType &
N) {
1263 CheckDI(
N.getRawFile() ||
N.getLine() == 0,
"line specified with no file", &
N,
1267void Verifier::visitDISubrangeType(
const DISubrangeType &
N) {
1270 CheckDI(
N.getTag() == dwarf::DW_TAG_subrange_type,
"invalid tag", &
N);
1273 auto *LBound =
N.getRawLowerBound();
1277 "LowerBound must be signed constant or DIVariable or DIExpression or "
1280 auto *UBound =
N.getRawUpperBound();
1284 "UpperBound must be signed constant or DIVariable or DIExpression or "
1287 auto *Stride =
N.getRawStride();
1290 "Stride must be signed constant or DIVariable or DIExpression", &
N);
1291 auto *Bias =
N.getRawBias();
1294 "Bias must be signed constant or DIVariable or DIExpression", &
N);
1296 auto *
Size =
N.getRawSizeInBits();
1298 "SizeInBits must be a constant");
1301void Verifier::visitDISubrange(
const DISubrange &
N) {
1302 CheckDI(
N.getTag() == dwarf::DW_TAG_subrange_type,
"invalid tag", &
N);
1303 CheckDI(!
N.getRawCountNode() || !
N.getRawUpperBound(),
1304 "Subrange can have any one of count or upperBound", &
N);
1305 auto *CBound =
N.getRawCountNode();
1308 "Count must be signed constant or DIVariable or DIExpression", &
N);
1309 auto Count =
N.getCount();
1312 "invalid subrange count", &
N);
1313 auto *LBound =
N.getRawLowerBound();
1316 "LowerBound must be signed constant or DIVariable or DIExpression",
1318 auto *UBound =
N.getRawUpperBound();
1321 "UpperBound must be signed constant or DIVariable or DIExpression",
1323 auto *Stride =
N.getRawStride();
1326 "Stride must be signed constant or DIVariable or DIExpression", &
N);
1329void Verifier::visitDIGenericSubrange(
const DIGenericSubrange &
N) {
1330 CheckDI(
N.getTag() == dwarf::DW_TAG_generic_subrange,
"invalid tag", &
N);
1331 CheckDI(!
N.getRawCountNode() || !
N.getRawUpperBound(),
1332 "GenericSubrange can have any one of count or upperBound", &
N);
1333 auto *CBound =
N.getRawCountNode();
1335 "Count must be signed constant or DIVariable or DIExpression", &
N);
1336 auto *LBound =
N.getRawLowerBound();
1337 CheckDI(LBound,
"GenericSubrange must contain lowerBound", &
N);
1339 "LowerBound must be signed constant or DIVariable or DIExpression",
1341 auto *UBound =
N.getRawUpperBound();
1343 "UpperBound must be signed constant or DIVariable or DIExpression",
1345 auto *Stride =
N.getRawStride();
1346 CheckDI(Stride,
"GenericSubrange must contain stride", &
N);
1348 "Stride must be signed constant or DIVariable or DIExpression", &
N);
1351void Verifier::visitDIEnumerator(
const DIEnumerator &
N) {
1352 CheckDI(
N.getTag() == dwarf::DW_TAG_enumerator,
"invalid tag", &
N);
1355void Verifier::visitDIBasicType(
const DIBasicType &
N) {
1358 CheckDI(
N.getTag() == dwarf::DW_TAG_base_type ||
1359 N.getTag() == dwarf::DW_TAG_unspecified_type ||
1360 N.getTag() == dwarf::DW_TAG_string_type,
1363 auto *
Size =
N.getRawSizeInBits();
1365 "SizeInBits must be a constant");
1368void Verifier::visitDIFixedPointType(
const DIFixedPointType &
N) {
1369 visitDIBasicType(
N);
1371 CheckDI(
N.getTag() == dwarf::DW_TAG_base_type,
"invalid tag", &
N);
1372 CheckDI(
N.getEncoding() == dwarf::DW_ATE_signed_fixed ||
1373 N.getEncoding() == dwarf::DW_ATE_unsigned_fixed,
1374 "invalid encoding", &
N);
1378 "invalid kind", &
N);
1380 N.getFactorRaw() == 0,
1381 "factor should be 0 for rationals", &
N);
1383 (
N.getNumeratorRaw() == 0 &&
N.getDenominatorRaw() == 0),
1384 "numerator and denominator should be 0 for non-rationals", &
N);
1387void Verifier::visitDIStringType(
const DIStringType &
N) {
1390 CheckDI(
N.getTag() == dwarf::DW_TAG_string_type,
"invalid tag", &
N);
1391 CheckDI(!(
N.isBigEndian() &&
N.isLittleEndian()),
"has conflicting flags",
1395void Verifier::visitDIDerivedType(
const DIDerivedType &
N) {
1399 CheckDI(
N.getTag() == dwarf::DW_TAG_typedef ||
1400 N.getTag() == dwarf::DW_TAG_pointer_type ||
1401 N.getTag() == dwarf::DW_TAG_ptr_to_member_type ||
1402 N.getTag() == dwarf::DW_TAG_reference_type ||
1403 N.getTag() == dwarf::DW_TAG_rvalue_reference_type ||
1404 N.getTag() == dwarf::DW_TAG_const_type ||
1405 N.getTag() == dwarf::DW_TAG_immutable_type ||
1406 N.getTag() == dwarf::DW_TAG_volatile_type ||
1407 N.getTag() == dwarf::DW_TAG_restrict_type ||
1408 N.getTag() == dwarf::DW_TAG_atomic_type ||
1409 N.getTag() == dwarf::DW_TAG_LLVM_ptrauth_type ||
1410 N.getTag() == dwarf::DW_TAG_member ||
1411 (
N.getTag() == dwarf::DW_TAG_variable &&
N.isStaticMember()) ||
1412 N.getTag() == dwarf::DW_TAG_inheritance ||
1413 N.getTag() == dwarf::DW_TAG_friend ||
1414 N.getTag() == dwarf::DW_TAG_set_type ||
1415 N.getTag() == dwarf::DW_TAG_template_alias,
1417 if (
N.getTag() == dwarf::DW_TAG_ptr_to_member_type) {
1418 CheckDI(
isType(
N.getRawExtraData()),
"invalid pointer to member type", &
N,
1419 N.getRawExtraData());
1420 }
else if (
N.getTag() == dwarf::DW_TAG_template_alias) {
1422 N.getRawExtraData());
1423 }
else if (
N.getTag() == dwarf::DW_TAG_inheritance ||
1424 N.getTag() == dwarf::DW_TAG_member ||
1425 N.getTag() == dwarf::DW_TAG_variable) {
1426 auto *ExtraData =
N.getRawExtraData();
1427 auto IsValidExtraData = [&]() {
1428 if (ExtraData ==
nullptr)
1434 if (Tuple->getNumOperands() != 1)
1441 "extraData must be ConstantAsMetadata, MDString, DIObjCProperty, "
1442 "or MDTuple with single ConstantAsMetadata operand",
1446 if (
N.getTag() == dwarf::DW_TAG_set_type) {
1447 if (
auto *
T =
N.getRawBaseType()) {
1452 (Enum &&
Enum->getTag() == dwarf::DW_TAG_enumeration_type) ||
1453 (Subrange &&
Subrange->getTag() == dwarf::DW_TAG_subrange_type) ||
1454 (
Basic && (
Basic->getEncoding() == dwarf::DW_ATE_unsigned ||
1455 Basic->getEncoding() == dwarf::DW_ATE_signed ||
1456 Basic->getEncoding() == dwarf::DW_ATE_unsigned_char ||
1457 Basic->getEncoding() == dwarf::DW_ATE_signed_char ||
1458 Basic->getEncoding() == dwarf::DW_ATE_boolean)),
1459 "invalid set base type", &
N,
T);
1464 N.getRawBaseType());
1466 if (
N.getDWARFAddressSpace()) {
1467 CheckDI(
N.getTag() == dwarf::DW_TAG_pointer_type ||
1468 N.getTag() == dwarf::DW_TAG_reference_type ||
1469 N.getTag() == dwarf::DW_TAG_rvalue_reference_type,
1470 "DWARF address space only applies to pointer or reference types",
1474 auto *
Size =
N.getRawSizeInBits();
1477 "SizeInBits must be a constant or DIVariable or DIExpression");
1482 return ((Flags & DINode::FlagLValueReference) &&
1483 (Flags & DINode::FlagRValueReference)) ||
1484 ((Flags & DINode::FlagTypePassByValue) &&
1485 (Flags & DINode::FlagTypePassByReference));
1488void Verifier::visitTemplateParams(
const MDNode &
N,
const Metadata &RawParams) {
1490 CheckDI(Params,
"invalid template params", &
N, &RawParams);
1497void Verifier::visitDICompositeType(
const DICompositeType &
N) {
1501 CheckDI(
N.getTag() == dwarf::DW_TAG_array_type ||
1502 N.getTag() == dwarf::DW_TAG_structure_type ||
1503 N.getTag() == dwarf::DW_TAG_union_type ||
1504 N.getTag() == dwarf::DW_TAG_enumeration_type ||
1505 N.getTag() == dwarf::DW_TAG_class_type ||
1506 N.getTag() == dwarf::DW_TAG_variant_part ||
1507 N.getTag() == dwarf::DW_TAG_variant ||
1508 N.getTag() == dwarf::DW_TAG_namelist,
1512 N.getRawBaseType());
1515 "invalid composite elements", &
N,
N.getRawElements());
1517 N.getRawVTableHolder());
1519 "invalid reference flags", &
N);
1520 unsigned DIBlockByRefStruct = 1 << 4;
1521 CheckDI((
N.getFlags() & DIBlockByRefStruct) == 0,
1522 "DIBlockByRefStruct on DICompositeType is no longer supported", &
N);
1524 "DISubprogram contains null entry in `elements` field", &
N);
1527 const DINodeArray
Elements =
N.getElements();
1529 Elements[0]->getTag() == dwarf::DW_TAG_subrange_type,
1530 "invalid vector, expected one element of type subrange", &
N);
1533 if (
auto *Params =
N.getRawTemplateParams())
1534 visitTemplateParams(
N, *Params);
1536 if (
auto *
D =
N.getRawDiscriminator()) {
1538 "discriminator can only appear on variant part");
1541 if (
N.getRawDataLocation()) {
1542 CheckDI(
N.getTag() == dwarf::DW_TAG_array_type,
1543 "dataLocation can only appear in array type");
1546 if (
N.getRawAssociated()) {
1547 CheckDI(
N.getTag() == dwarf::DW_TAG_array_type,
1548 "associated can only appear in array type");
1551 if (
N.getRawAllocated()) {
1552 CheckDI(
N.getTag() == dwarf::DW_TAG_array_type,
1553 "allocated can only appear in array type");
1556 if (
N.getRawRank()) {
1557 CheckDI(
N.getTag() == dwarf::DW_TAG_array_type,
1558 "rank can only appear in array type");
1561 if (
N.getTag() == dwarf::DW_TAG_array_type) {
1562 CheckDI(
N.getRawBaseType(),
"array types must have a base type", &
N);
1565 auto *
Size =
N.getRawSizeInBits();
1568 "SizeInBits must be a constant or DIVariable or DIExpression");
1571void Verifier::visitDISubroutineType(
const DISubroutineType &
N) {
1573 CheckDI(
N.getTag() == dwarf::DW_TAG_subroutine_type,
"invalid tag", &
N);
1574 if (
auto *Types =
N.getRawTypeArray()) {
1576 for (
Metadata *Ty :
N.getTypeArray()->operands()) {
1577 CheckDI(
isType(Ty),
"invalid subroutine type ref", &
N, Types, Ty);
1581 "invalid reference flags", &
N);
1584void Verifier::visitDIFile(
const DIFile &
N) {
1585 CheckDI(
N.getTag() == dwarf::DW_TAG_file_type,
"invalid tag", &
N);
1586 std::optional<DIFile::ChecksumInfo<StringRef>> Checksum =
N.getChecksum();
1588 CheckDI(Checksum->Kind <= DIFile::ChecksumKind::CSK_Last,
1589 "invalid checksum kind", &
N);
1591 switch (Checksum->Kind) {
1602 CheckDI(Checksum->Value.size() ==
Size,
"invalid checksum length", &
N);
1604 "invalid checksum", &
N);
1608void Verifier::visitDICompileUnit(
const DICompileUnit &
N) {
1609 CheckDI(
N.isDistinct(),
"compile units must be distinct", &
N);
1610 CheckDI(
N.getTag() == dwarf::DW_TAG_compile_unit,
"invalid tag", &
N);
1616 CheckDI(!
N.getFile()->getFilename().empty(),
"invalid filename", &
N,
1620 "invalid emission kind", &
N);
1623 "invalid language dialect", &
N);
1625 if (
auto *Array =
N.getRawEnumTypes()) {
1627 for (
Metadata *
Op :
N.getEnumTypes()->operands()) {
1629 CheckDI(Enum &&
Enum->getTag() == dwarf::DW_TAG_enumeration_type,
1630 "invalid enum type", &
N,
N.getEnumTypes(),
Op);
1632 "function-local enum in a DICompileUnit's enum list", &
N,
1633 N.getEnumTypes(),
Op);
1636 if (
auto *Array =
N.getRawRetainedTypes()) {
1638 for (
Metadata *
Op :
N.getRetainedTypes()->operands()) {
1642 "invalid retained type", &
N,
Op);
1645 if (
auto *Array =
N.getRawGlobalVariables()) {
1647 for (
Metadata *
Op :
N.getGlobalVariables()->operands()) {
1649 "invalid global variable ref", &
N,
Op);
1652 if (
auto *Array =
N.getRawImportedEntities()) {
1654 for (
Metadata *
Op :
N.getImportedEntities()->operands()) {
1656 CheckDI(IE,
"invalid imported entity ref", &
N,
Op);
1658 "function-local imports are not allowed in a DICompileUnit's "
1659 "imported entities list",
1663 if (
auto *Array =
N.getRawMacros()) {
1672void Verifier::visitDISubprogram(
const DISubprogram &
N) {
1673 CheckDI(
N.getTag() == dwarf::DW_TAG_subprogram,
"invalid tag", &
N);
1675 if (
auto *
F =
N.getRawFile())
1678 CheckDI(
N.getLine() == 0,
"line specified with no file", &
N,
N.getLine());
1679 auto *
T =
N.getRawType();
1680 CheckDI(
T,
"DISubprogram requires a non-null type", &
N);
1682 CheckDI(
isType(
N.getRawContainingType()),
"invalid containing type", &
N,
1683 N.getRawContainingType());
1684 if (
auto *Params =
N.getRawTemplateParams())
1685 visitTemplateParams(
N, *Params);
1686 if (
auto *S =
N.getRawDeclaration())
1688 "invalid subprogram declaration", &
N, S);
1689 if (
auto *RawNode =
N.getRawRetainedNodes()) {
1691 CheckDI(Node,
"invalid retained nodes list", &
N, RawNode);
1693 DenseMap<unsigned, DILocalVariable *>
Args;
1695 CheckDI(
Op,
"nullptr in retained nodes", &
N, Node);
1697 auto True = [](
const Metadata *) {
return true; };
1698 auto False = [](
const Metadata *) {
return false; };
1699 bool IsTypeCorrect = DISubprogram::visitRetainedNode<bool>(
1700 Op, True, True, True, True, False);
1702 "invalid retained nodes, expected DILocalVariable, DILabel, "
1703 "DIImportedEntity or DIType",
1710 "invalid retained nodes, retained node is not local", &
N, Node,
1713 DISubprogram *RetainedNodeSP = RetainedNodeScope->getSubprogram();
1714 DICompileUnit *RetainedNodeUnit =
1715 RetainedNodeSP ? RetainedNodeSP->getUnit() :
nullptr;
1717 RetainedNodeSP == &
N,
1718 "invalid retained nodes, retained node does not belong to subprogram",
1719 &
N, Node, RetainedNode, RetainedNodeScope, RetainedNodeSP,
1725 if (
unsigned ArgNum = DV->getArg()) {
1727 CheckDI(Inserted || DV == ArgI->second,
1728 "invalid retained nodes, more than one local variable with the "
1729 "same argument index",
1730 &
N,
N.getUnit(), Node, RetainedNode, Args[ArgNum]);
1735 "invalid reference flags", &
N);
1737 auto *
Unit =
N.getRawUnit();
1738 if (
N.isDefinition()) {
1740 CheckDI(
N.isDistinct(),
"subprogram definitions must be distinct", &
N);
1741 CheckDI(Unit,
"subprogram definitions must have a compile unit", &
N);
1746 if (CT && CT->getRawIdentifier() &&
1747 M.getContext().isODRUniquingDebugTypes())
1749 "definition subprograms cannot be nested within DICompositeType "
1750 "when enabling ODR",
1754 CheckDI(!Unit,
"subprogram declarations must not have a compile unit", &
N);
1756 "subprogram declaration must not have a declaration field");
1759 if (
auto *RawThrownTypes =
N.getRawThrownTypes()) {
1761 CheckDI(ThrownTypes,
"invalid thrown types list", &
N, RawThrownTypes);
1767 if (
N.areAllCallsDescribed())
1769 "DIFlagAllCallsDescribed must be attached to a definition");
1772void Verifier::visitDILexicalBlockBase(
const DILexicalBlockBase &
N) {
1773 CheckDI(
N.getTag() == dwarf::DW_TAG_lexical_block,
"invalid tag", &
N);
1775 "invalid local scope", &
N,
N.getRawScope());
1777 CheckDI(
SP->isDefinition(),
"scope points into the type hierarchy", &
N);
1780void Verifier::visitDILexicalBlock(
const DILexicalBlock &
N) {
1781 visitDILexicalBlockBase(
N);
1784 "cannot have column info without line info", &
N);
1787void Verifier::visitDILexicalBlockFile(
const DILexicalBlockFile &
N) {
1788 visitDILexicalBlockBase(
N);
1791void Verifier::visitDICommonBlock(
const DICommonBlock &
N) {
1792 CheckDI(
N.getTag() == dwarf::DW_TAG_common_block,
"invalid tag", &
N);
1793 if (
auto *S =
N.getRawScope())
1795 if (
auto *S =
N.getRawDecl())
1799void Verifier::visitDINamespace(
const DINamespace &
N) {
1800 CheckDI(
N.getTag() == dwarf::DW_TAG_namespace,
"invalid tag", &
N);
1801 if (
auto *S =
N.getRawScope())
1805void Verifier::visitDIMacro(
const DIMacro &
N) {
1808 "invalid macinfo type", &
N);
1809 CheckDI(!
N.getName().empty(),
"anonymous macro", &
N);
1810 if (!
N.getValue().empty()) {
1811 assert(
N.getValue().data()[0] !=
' ' &&
"Macro value has a space prefix");
1815void Verifier::visitDIMacroFile(
const DIMacroFile &
N) {
1817 "invalid macinfo type", &
N);
1818 if (
auto *
F =
N.getRawFile())
1821 if (
auto *Array =
N.getRawElements()) {
1823 for (
Metadata *
Op :
N.getElements()->operands()) {
1829void Verifier::visitDIModule(
const DIModule &
N) {
1830 CheckDI(
N.getTag() == dwarf::DW_TAG_module,
"invalid tag", &
N);
1831 CheckDI(!
N.getName().empty(),
"anonymous module", &
N);
1834void Verifier::visitDITemplateParameter(
const DITemplateParameter &
N) {
1838void Verifier::visitDITemplateTypeParameter(
const DITemplateTypeParameter &
N) {
1839 visitDITemplateParameter(
N);
1841 CheckDI(
N.getTag() == dwarf::DW_TAG_template_type_parameter,
"invalid tag",
1845void Verifier::visitDITemplateValueParameter(
1846 const DITemplateValueParameter &
N) {
1847 visitDITemplateParameter(
N);
1849 CheckDI(
N.getTag() == dwarf::DW_TAG_template_value_parameter ||
1850 N.getTag() == dwarf::DW_TAG_GNU_template_template_param ||
1851 N.getTag() == dwarf::DW_TAG_GNU_template_parameter_pack,
1855void Verifier::visitDIVariable(
const DIVariable &
N) {
1856 if (
auto *S =
N.getRawScope())
1858 if (
auto *
F =
N.getRawFile())
1862void Verifier::visitDIGlobalVariable(
const DIGlobalVariable &
N) {
1866 CheckDI(
N.getTag() == dwarf::DW_TAG_variable,
"invalid tag", &
N);
1869 if (
N.isDefinition())
1870 CheckDI(
N.getType(),
"missing global variable type", &
N);
1871 if (
auto *Member =
N.getRawStaticDataMemberDeclaration()) {
1873 "invalid static data member declaration", &
N, Member);
1877void Verifier::visitDILocalVariable(
const DILocalVariable &
N) {
1882 CheckDI(
N.getTag() == dwarf::DW_TAG_variable,
"invalid tag", &
N);
1884 "local variable requires a valid scope", &
N,
N.getRawScope());
1885 if (
auto Ty =
N.getType())
1889void Verifier::visitDIAssignID(
const DIAssignID &
N) {
1890 CheckDI(!
N.getNumOperands(),
"DIAssignID has no arguments", &
N);
1891 CheckDI(
N.isDistinct(),
"DIAssignID must be distinct", &
N);
1894void Verifier::visitDILabel(
const DILabel &
N) {
1895 if (
auto *S =
N.getRawScope())
1897 if (
auto *
F =
N.getRawFile())
1900 CheckDI(
N.getTag() == dwarf::DW_TAG_label,
"invalid tag", &
N);
1902 "label requires a valid scope", &
N,
N.getRawScope());
1905void Verifier::visitDIExpression(
const DIExpression &
N) {
1906 CheckDI(
N.isValid(),
"invalid expression", &
N);
1909void Verifier::visitDIGlobalVariableExpression(
1910 const DIGlobalVariableExpression &GVE) {
1913 visitDIGlobalVariable(*Var);
1915 visitDIExpression(*Expr);
1916 if (
auto Fragment = Expr->getFragmentInfo())
1917 verifyFragmentExpression(*GVE.
getVariable(), *Fragment, &GVE);
1921void Verifier::visitDIObjCProperty(
const DIObjCProperty &
N) {
1922 CheckDI(
N.getTag() == dwarf::DW_TAG_APPLE_property,
"invalid tag", &
N);
1923 if (
auto *
T =
N.getRawType())
1925 if (
auto *
F =
N.getRawFile())
1929void Verifier::visitDIImportedEntity(
const DIImportedEntity &
N) {
1930 CheckDI(
N.getTag() == dwarf::DW_TAG_imported_module ||
1931 N.getTag() == dwarf::DW_TAG_imported_declaration,
1933 if (
auto *S =
N.getRawScope())
1939void Verifier::visitComdat(
const Comdat &
C) {
1942 if (
TT.isOSBinFormatCOFF())
1943 if (
const GlobalValue *GV =
M.getNamedValue(
C.getName()))
1948void Verifier::visitModuleIdents() {
1949 const NamedMDNode *Idents =
M.getNamedMetadata(
"llvm.ident");
1955 for (
const MDNode *
N : Idents->
operands()) {
1956 Check(
N->getNumOperands() == 1,
1957 "incorrect number of operands in llvm.ident metadata",
N);
1959 (
"invalid value for llvm.ident metadata entry operand"
1960 "(the operand should be a string)"),
1965void Verifier::visitModuleCommandLines() {
1966 const NamedMDNode *CommandLines =
M.getNamedMetadata(
"llvm.commandline");
1973 for (
const MDNode *
N : CommandLines->
operands()) {
1974 Check(
N->getNumOperands() == 1,
1975 "incorrect number of operands in llvm.commandline metadata",
N);
1977 (
"invalid value for llvm.commandline metadata entry operand"
1978 "(the operand should be a string)"),
1983void Verifier::visitModuleErrnoTBAA() {
1984 const NamedMDNode *ErrnoTBAA =
M.getNamedMetadata(
"llvm.errno.tbaa");
1989 "llvm.errno.tbaa must have at least one operand", ErrnoTBAA);
1991 for (
const MDNode *
N : ErrnoTBAA->
operands())
1995void Verifier::visitModuleFlags() {
1996 const NamedMDNode *
Flags =
M.getModuleFlagsMetadata();
2000 DenseMap<const MDString*, const MDNode*> SeenIDs;
2002 uint64_t PAuthABIPlatform = -1;
2003 uint64_t PAuthABIVersion = -1;
2004 for (
const MDNode *MDN :
Flags->operands()) {
2005 visitModuleFlag(MDN, SeenIDs, Requirements);
2006 if (MDN->getNumOperands() != 3)
2009 if (FlagName->getString() ==
"aarch64-elf-pauthabi-platform") {
2010 if (
const auto *PAP =
2012 PAuthABIPlatform = PAP->getZExtValue();
2013 }
else if (FlagName->getString() ==
"aarch64-elf-pauthabi-version") {
2014 if (
const auto *PAV =
2016 PAuthABIVersion = PAV->getZExtValue();
2021 if ((PAuthABIPlatform == uint64_t(-1)) != (PAuthABIVersion == uint64_t(-1)))
2022 CheckFailed(
"either both or no 'aarch64-elf-pauthabi-platform' and "
2023 "'aarch64-elf-pauthabi-version' module flags must be present");
2026 for (
const MDNode *Requirement : Requirements) {
2028 const Metadata *ReqValue = Requirement->getOperand(1);
2030 const MDNode *
Op = SeenIDs.
lookup(Flag);
2032 CheckFailed(
"invalid requirement on flag, flag is not present in module",
2037 if (
Op->getOperand(2) != ReqValue) {
2038 CheckFailed((
"invalid requirement on flag, "
2039 "flag does not have the required value"),
2047Verifier::visitModuleFlag(
const MDNode *
Op,
2048 DenseMap<const MDString *, const MDNode *> &SeenIDs,
2049 SmallVectorImpl<const MDNode *> &Requirements) {
2053 "incorrect number of operands in module flag",
Op);
2054 Module::ModFlagBehavior MFB;
2055 if (!Module::isValidModFlagBehavior(
Op->getOperand(0), MFB)) {
2057 "invalid behavior operand in module flag (expected constant integer)",
2060 "invalid behavior operand in module flag (unexpected constant)",
2064 Check(
ID,
"invalid ID operand in module flag (expected metadata string)",
2070 case Module::Warning:
2071 case Module::Override:
2077 Check(V &&
V->getValue().isNonNegative(),
2078 "invalid value for 'min' module flag (expected constant non-negative "
2086 "invalid value for 'max' module flag (expected constant integer)",
2091 case Module::Require: {
2096 "invalid value for 'require' module flag (expected metadata pair)",
2099 (
"invalid value for 'require' module flag "
2100 "(first value operand should be a string)"),
2101 Value->getOperand(0));
2109 case Module::Append:
2110 case Module::AppendUnique: {
2113 "invalid value for 'append'-type module flag "
2114 "(expected a metadata node)",
2121 if (MFB != Module::Require) {
2124 "module flag identifiers must be unique (or of 'require' type)",
ID);
2127 if (
ID->getString() ==
"wchar_size") {
2130 Check(
Value,
"wchar_size metadata requires constant integer argument");
2133 if (
ID->getString() ==
"Linker Options") {
2137 Check(
M.getNamedMetadata(
"llvm.linker.options"),
2138 "'Linker Options' named metadata no longer supported");
2141 if (
ID->getString() ==
"SemanticInterposition") {
2142 ConstantInt *
Value =
2145 "SemanticInterposition metadata requires constant integer argument");
2148 if (
ID->getString() ==
"amdgpu.buffer.oob.mode" ||
2149 ID->getString() ==
"amdgpu.tbuffer.oob.mode") {
2150 Check(MFB == Module::Max,
2151 "'" +
ID->getString() +
2152 "' module flag must use 'max' merge behaviour");
2153 ConstantInt *
Value =
2156 "' module flag must have a constant integer value");
2159 "'" +
ID->getString() +
"' module flag must be 0, 1, or 2");
2163 if (
ID->getString() ==
"CG Profile") {
2164 for (
const MDOperand &MDO :
cast<MDNode>(
Op->getOperand(2))->operands())
2165 visitModuleFlagCGProfileEntry(MDO);
2169void Verifier::visitModuleFlagCGProfileEntry(
const MDOperand &MDO) {
2170 auto CheckFunction = [&](
const MDOperand &FuncMDO) {
2175 "expected a Function or null", FuncMDO);
2178 Check(Node &&
Node->getNumOperands() == 3,
"expected a MDNode triple", MDO);
2179 CheckFunction(
Node->getOperand(0));
2180 CheckFunction(
Node->getOperand(1));
2183 "expected an integer constant",
Node->getOperand(2));
2186void Verifier::verifyAttributeTypes(AttributeSet Attrs,
const Value *V) {
2189 if (
A.isStringAttribute()) {
2190#define GET_ATTR_NAMES
2191#define ATTRIBUTE_ENUM(ENUM_NAME, DISPLAY_NAME)
2192#define ATTRIBUTE_STRBOOL(ENUM_NAME, DISPLAY_NAME) \
2193 if (A.getKindAsString() == #DISPLAY_NAME) { \
2194 auto V = A.getValueAsString(); \
2195 if (!(V.empty() || V == "true" || V == "false")) \
2196 CheckFailed("invalid value for '" #DISPLAY_NAME "' attribute: " + V + \
2200#include "llvm/IR/Attributes.inc"
2204 if (
A.isIntAttribute() != Attribute::isIntAttrKind(
A.getKindAsEnum())) {
2205 CheckFailed(
"Attribute '" +
A.getAsString() +
"' should have an Argument",
2214void Verifier::verifyParameterAttrs(AttributeSet Attrs,
Type *Ty,
2216 if (!
Attrs.hasAttributes())
2219 verifyAttributeTypes(Attrs, V);
2222 Check(Attr.isStringAttribute() ||
2223 Attribute::canUseAsParamAttr(Attr.getKindAsEnum()),
2224 "Attribute '" + Attr.getAsString() +
"' does not apply to parameters",
2227 if (
Attrs.hasAttribute(Attribute::ImmArg)) {
2228 unsigned AttrCount =
2229 Attrs.getNumAttributes() -
Attrs.hasAttribute(Attribute::Range);
2230 Check(AttrCount == 1,
2231 "Attribute 'immarg' is incompatible with other attributes except the "
2232 "'range' attribute",
2238 unsigned AttrCount = 0;
2239 AttrCount +=
Attrs.hasAttribute(Attribute::ByVal);
2240 AttrCount +=
Attrs.hasAttribute(Attribute::InAlloca);
2241 AttrCount +=
Attrs.hasAttribute(Attribute::Preallocated);
2242 AttrCount +=
Attrs.hasAttribute(Attribute::StructRet) ||
2243 Attrs.hasAttribute(Attribute::InReg);
2244 AttrCount +=
Attrs.hasAttribute(Attribute::Nest);
2245 AttrCount +=
Attrs.hasAttribute(Attribute::ByRef);
2246 Check(AttrCount <= 1,
2247 "Attributes 'byval', 'inalloca', 'preallocated', 'inreg', 'nest', "
2248 "'byref', and 'sret' are incompatible!",
2251 Check(!(
Attrs.hasAttribute(Attribute::InAlloca) &&
2252 Attrs.hasAttribute(Attribute::ReadOnly)),
2254 "'inalloca and readonly' are incompatible!",
2257 Check(!(
Attrs.hasAttribute(Attribute::StructRet) &&
2258 Attrs.hasAttribute(Attribute::Returned)),
2260 "'sret and returned' are incompatible!",
2263 Check(!(
Attrs.hasAttribute(Attribute::ZExt) &&
2264 Attrs.hasAttribute(Attribute::SExt)),
2266 "'zeroext and signext' are incompatible!",
2269 Check(!(
Attrs.hasAttribute(Attribute::ReadNone) &&
2270 Attrs.hasAttribute(Attribute::ReadOnly)),
2272 "'readnone and readonly' are incompatible!",
2275 Check(!(
Attrs.hasAttribute(Attribute::ReadNone) &&
2276 Attrs.hasAttribute(Attribute::WriteOnly)),
2278 "'readnone and writeonly' are incompatible!",
2281 Check(!(
Attrs.hasAttribute(Attribute::ReadOnly) &&
2282 Attrs.hasAttribute(Attribute::WriteOnly)),
2284 "'readonly and writeonly' are incompatible!",
2287 Check(!(
Attrs.hasAttribute(Attribute::NoInline) &&
2288 Attrs.hasAttribute(Attribute::AlwaysInline)),
2290 "'noinline and alwaysinline' are incompatible!",
2293 Check(!(
Attrs.hasAttribute(Attribute::Writable) &&
2294 Attrs.hasAttribute(Attribute::ReadNone)),
2295 "Attributes writable and readnone are incompatible!", V);
2297 Check(!(
Attrs.hasAttribute(Attribute::Writable) &&
2298 Attrs.hasAttribute(Attribute::ReadOnly)),
2299 "Attributes writable and readonly are incompatible!", V);
2301 AttributeMask IncompatibleAttrs = AttributeFuncs::typeIncompatible(Ty, Attrs);
2303 if (!Attr.isStringAttribute() &&
2304 IncompatibleAttrs.
contains(Attr.getKindAsEnum())) {
2305 CheckFailed(
"Attribute '" + Attr.getAsString() +
2306 "' applied to incompatible type!", V);
2312 if (
Attrs.hasAttribute(Attribute::Alignment)) {
2313 Align AttrAlign =
Attrs.getAlignment().valueOrOne();
2314 Check(AttrAlign.
value() <= Value::MaximumAlignment,
2315 "huge alignment values are unsupported", V);
2317 if (
Attrs.hasAttribute(Attribute::ByVal)) {
2319 SmallPtrSet<Type *, 4> Visited;
2321 "Attribute 'byval' does not support unsized types!", V);
2325 "'byval' argument has illegal target extension type", V);
2326 Check(
DL.getTypeAllocSize(ByValTy).getKnownMinValue() < (1ULL << 32),
2327 "huge 'byval' arguments are unsupported", V);
2329 if (
Attrs.hasAttribute(Attribute::ByRef)) {
2330 SmallPtrSet<Type *, 4> Visited;
2331 Check(
Attrs.getByRefType()->isSized(&Visited),
2332 "Attribute 'byref' does not support unsized types!", V);
2333 Check(
DL.getTypeAllocSize(
Attrs.getByRefType()).getKnownMinValue() <
2335 "huge 'byref' arguments are unsupported", V);
2337 if (
Attrs.hasAttribute(Attribute::InAlloca)) {
2338 SmallPtrSet<Type *, 4> Visited;
2339 Check(
Attrs.getInAllocaType()->isSized(&Visited),
2340 "Attribute 'inalloca' does not support unsized types!", V);
2341 Check(
DL.getTypeAllocSize(
Attrs.getInAllocaType()).getKnownMinValue() <
2343 "huge 'inalloca' arguments are unsupported", V);
2345 if (
Attrs.hasAttribute(Attribute::Preallocated)) {
2346 SmallPtrSet<Type *, 4> Visited;
2347 Check(
Attrs.getPreallocatedType()->isSized(&Visited),
2348 "Attribute 'preallocated' does not support unsized types!", V);
2350 DL.getTypeAllocSize(
Attrs.getPreallocatedType()).getKnownMinValue() <
2352 "huge 'preallocated' arguments are unsupported", V);
2356 if (
Attrs.hasAttribute(Attribute::Initializes)) {
2357 auto Inits =
Attrs.getAttribute(Attribute::Initializes).getInitializes();
2358 Check(!Inits.empty(),
"Attribute 'initializes' does not support empty list",
2361 "Attribute 'initializes' does not support unordered ranges", V);
2364 if (
Attrs.hasAttribute(Attribute::NoFPClass)) {
2365 uint64_t Val =
Attrs.getAttribute(Attribute::NoFPClass).getValueAsInt();
2366 Check(Val != 0,
"Attribute 'nofpclass' must have at least one test bit set",
2369 "Invalid value for 'nofpclass' test mask", V);
2371 if (
Attrs.hasAttribute(Attribute::Range)) {
2372 const ConstantRange &CR =
2373 Attrs.getAttribute(Attribute::Range).getValueAsConstantRange();
2375 "Range bit width must match type bit width!", V);
2379void Verifier::checkUnsignedBaseTenFuncAttr(AttributeList Attrs, StringRef Attr,
2381 if (
Attrs.hasFnAttr(Attr)) {
2382 StringRef S =
Attrs.getFnAttr(Attr).getValueAsString();
2385 CheckFailed(
"\"" + Attr +
"\" takes an unsigned integer: " + S, V);
2391void Verifier::verifyFunctionAttrs(FunctionType *FT, AttributeList Attrs,
2392 const Value *V,
bool IsIntrinsic,
2394 if (
Attrs.isEmpty())
2397 if (AttributeListsVisited.
insert(
Attrs.getRawPointer()).second) {
2399 "Attribute list does not match Module context!", &Attrs, V);
2400 for (
const auto &AttrSet : Attrs) {
2401 Check(!AttrSet.hasAttributes() || AttrSet.hasParentContext(
Context),
2402 "Attribute set does not match Module context!", &AttrSet, V);
2403 for (
const auto &
A : AttrSet) {
2405 "Attribute does not match Module context!", &
A, V);
2410 bool SawNest =
false;
2411 bool SawReturned =
false;
2412 bool SawSRet =
false;
2413 bool SawSwiftSelf =
false;
2414 bool SawSwiftAsync =
false;
2415 bool SawSwiftError =
false;
2418 AttributeSet RetAttrs =
Attrs.getRetAttrs();
2421 Attribute::canUseAsRetAttr(
RetAttr.getKindAsEnum()),
2422 "Attribute '" +
RetAttr.getAsString() +
2423 "' does not apply to function return values",
2426 unsigned MaxParameterWidth = 0;
2427 auto GetMaxParameterWidth = [&MaxParameterWidth](
Type *Ty) {
2430 unsigned Size = VT->getPrimitiveSizeInBits().getFixedValue();
2431 if (
Size > MaxParameterWidth)
2432 MaxParameterWidth =
Size;
2436 GetMaxParameterWidth(FT->getReturnType());
2437 verifyParameterAttrs(RetAttrs, FT->getReturnType(), V);
2440 for (
unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
2441 Type *Ty = FT->getParamType(i);
2442 AttributeSet ArgAttrs =
Attrs.getParamAttrs(i);
2446 "immarg attribute only applies to intrinsics", V);
2449 "Attribute 'elementtype' can only be applied to intrinsics"
2454 verifyParameterAttrs(ArgAttrs, Ty, V);
2455 GetMaxParameterWidth(Ty);
2458 Check(!SawNest,
"More than one parameter has attribute nest!", V);
2463 Check(!SawReturned,
"More than one parameter has attribute returned!", V);
2465 "Incompatible argument and return types for 'returned' attribute",
2471 Check(!SawSRet,
"Cannot have multiple 'sret' parameters!", V);
2472 Check(i == 0 || i == 1,
2473 "Attribute 'sret' is not on first or second parameter!", V);
2478 Check(!SawSwiftSelf,
"Cannot have multiple 'swiftself' parameters!", V);
2479 SawSwiftSelf =
true;
2483 Check(!SawSwiftAsync,
"Cannot have multiple 'swiftasync' parameters!", V);
2484 SawSwiftAsync =
true;
2488 Check(!SawSwiftError,
"Cannot have multiple 'swifterror' parameters!", V);
2489 SawSwiftError =
true;
2493 Check(i == FT->getNumParams() - 1,
2494 "inalloca isn't on the last parameter!", V);
2498 if (!
Attrs.hasFnAttrs())
2501 verifyAttributeTypes(
Attrs.getFnAttrs(), V);
2504 Attribute::canUseAsFnAttr(
FnAttr.getKindAsEnum()),
2505 "Attribute '" +
FnAttr.getAsString() +
2506 "' does not apply to functions!",
2509 Check(!(
Attrs.hasFnAttr(Attribute::NoInline) &&
2510 Attrs.hasFnAttr(Attribute::AlwaysInline)),
2511 "Attributes 'noinline and alwaysinline' are incompatible!", V);
2513 if (
Attrs.hasFnAttr(Attribute::OptimizeNone)) {
2515 "Attribute 'optnone' requires 'noinline'!", V);
2517 Check(!
Attrs.hasFnAttr(Attribute::OptimizeForSize),
2518 "Attributes 'optsize and optnone' are incompatible!", V);
2521 "Attributes 'minsize and optnone' are incompatible!", V);
2523 Check(!
Attrs.hasFnAttr(Attribute::OptimizeForDebugging),
2524 "Attributes 'optdebug and optnone' are incompatible!", V);
2527 Check(!(
Attrs.hasFnAttr(Attribute::SanitizeRealtime) &&
2528 Attrs.hasFnAttr(Attribute::SanitizeRealtimeBlocking)),
2530 "'sanitize_realtime and sanitize_realtime_blocking' are incompatible!",
2533 if (
Attrs.hasFnAttr(Attribute::OptimizeForDebugging)) {
2534 Check(!
Attrs.hasFnAttr(Attribute::OptimizeForSize),
2535 "Attributes 'optsize and optdebug' are incompatible!", V);
2538 "Attributes 'minsize and optdebug' are incompatible!", V);
2541 Check(!
Attrs.hasAttrSomewhere(Attribute::Writable) ||
2542 isModSet(
Attrs.getMemoryEffects().getModRef(IRMemLocation::ArgMem)),
2543 "Attribute writable and memory without argmem: write are incompatible!",
2546 if (
Attrs.hasFnAttr(
"aarch64_pstate_sm_enabled")) {
2547 Check(!
Attrs.hasFnAttr(
"aarch64_pstate_sm_compatible"),
2548 "Attributes 'aarch64_pstate_sm_enabled and "
2549 "aarch64_pstate_sm_compatible' are incompatible!",
2553 Check((
Attrs.hasFnAttr(
"aarch64_new_za") +
Attrs.hasFnAttr(
"aarch64_in_za") +
2554 Attrs.hasFnAttr(
"aarch64_inout_za") +
2555 Attrs.hasFnAttr(
"aarch64_out_za") +
2556 Attrs.hasFnAttr(
"aarch64_preserves_za") +
2557 Attrs.hasFnAttr(
"aarch64_za_state_agnostic")) <= 1,
2558 "Attributes 'aarch64_new_za', 'aarch64_in_za', 'aarch64_out_za', "
2559 "'aarch64_inout_za', 'aarch64_preserves_za' and "
2560 "'aarch64_za_state_agnostic' are mutually exclusive",
2564 Attrs.hasFnAttr(
"aarch64_in_zt0") +
2565 Attrs.hasFnAttr(
"aarch64_inout_zt0") +
2566 Attrs.hasFnAttr(
"aarch64_out_zt0") +
2567 Attrs.hasFnAttr(
"aarch64_preserves_zt0") +
2568 Attrs.hasFnAttr(
"aarch64_za_state_agnostic")) <= 1,
2569 "Attributes 'aarch64_new_zt0', 'aarch64_in_zt0', 'aarch64_out_zt0', "
2570 "'aarch64_inout_zt0', 'aarch64_preserves_zt0' and "
2571 "'aarch64_za_state_agnostic' are mutually exclusive",
2574 if (
Attrs.hasFnAttr(Attribute::JumpTable)) {
2577 "Attribute 'jumptable' requires 'unnamed_addr'", V);
2580 if (
auto Args =
Attrs.getFnAttrs().getAllocSizeArgs()) {
2581 auto CheckParam = [&](StringRef
Name,
unsigned ParamNo) {
2582 if (ParamNo >= FT->getNumParams()) {
2583 CheckFailed(
"'allocsize' " + Name +
" argument is out of bounds", V);
2587 if (!FT->getParamType(ParamNo)->isIntegerTy()) {
2588 CheckFailed(
"'allocsize' " + Name +
2589 " argument must refer to an integer parameter",
2597 if (!CheckParam(
"element size",
Args->first))
2600 if (
Args->second && !CheckParam(
"number of elements", *
Args->second))
2604 if (
Attrs.hasFnAttr(Attribute::AllocKind)) {
2607 K & (AllocFnKind::Alloc | AllocFnKind::Realloc | AllocFnKind::Free);
2609 {AllocFnKind::Alloc, AllocFnKind::Realloc, AllocFnKind::Free},
2612 "'allockind()' requires exactly one of alloc, realloc, and free");
2613 if ((
Type == AllocFnKind::Free) &&
2614 ((K & (AllocFnKind::Uninitialized | AllocFnKind::Zeroed |
2615 AllocFnKind::Aligned)) != AllocFnKind::Unknown))
2616 CheckFailed(
"'allockind(\"free\")' doesn't allow uninitialized, zeroed, "
2617 "or aligned modifiers.");
2618 AllocFnKind ZeroedUninit = AllocFnKind::Uninitialized | AllocFnKind::Zeroed;
2619 if ((K & ZeroedUninit) == ZeroedUninit)
2620 CheckFailed(
"'allockind()' can't be both zeroed and uninitialized");
2624 StringRef S =
A.getValueAsString();
2625 Check(!S.
empty(),
"'alloc-variant-zeroed' must not be empty");
2633 "'alloc-variant-zeroed' must name a function belonging to the "
2634 "same 'alloc-family'");
2637 (
Variant->getFnAttribute(Attribute::AllocKind).getAllocKind() &
2638 AllocFnKind::Zeroed) != AllocFnKind::Unknown,
2639 "'alloc-variant-zeroed' must name a function with "
2640 "'allockind(\"zeroed\")'");
2643 "'alloc-variant-zeroed' must name a function with the same "
2648 "'alloc-variant-zeroed' must name a function with the same "
2649 "calling convention");
2653 if (
Attrs.hasFnAttr(Attribute::VScaleRange)) {
2654 unsigned VScaleMin =
Attrs.getFnAttrs().getVScaleRangeMin();
2656 CheckFailed(
"'vscale_range' minimum must be greater than 0", V);
2658 CheckFailed(
"'vscale_range' minimum must be power-of-two value", V);
2659 std::optional<unsigned> VScaleMax =
Attrs.getFnAttrs().getVScaleRangeMax();
2660 if (VScaleMax && VScaleMin > VScaleMax)
2661 CheckFailed(
"'vscale_range' minimum cannot be greater than maximum", V);
2663 CheckFailed(
"'vscale_range' maximum must be power-of-two value", V);
2666 if (
Attribute FPAttr =
Attrs.getFnAttr(
"frame-pointer"); FPAttr.isValid()) {
2667 StringRef
FP = FPAttr.getValueAsString();
2668 if (
FP !=
"all" &&
FP !=
"non-leaf" &&
FP !=
"none" &&
FP !=
"reserved" &&
2669 FP !=
"non-leaf-no-reserve")
2670 CheckFailed(
"invalid value for 'frame-pointer' attribute: " +
FP, V);
2673 checkUnsignedBaseTenFuncAttr(Attrs,
"patchable-function-prefix", V);
2674 checkUnsignedBaseTenFuncAttr(Attrs,
"patchable-function-entry", V);
2675 if (
Attrs.hasFnAttr(
"patchable-function-entry-section"))
2676 Check(!
Attrs.getFnAttr(
"patchable-function-entry-section")
2679 "\"patchable-function-entry-section\" must not be empty");
2680 checkUnsignedBaseTenFuncAttr(Attrs,
"warn-stack-size", V);
2682 if (
auto A =
Attrs.getFnAttr(
"sign-return-address");
A.isValid()) {
2683 StringRef S =
A.getValueAsString();
2684 if (S !=
"none" && S !=
"all" && S !=
"non-leaf")
2685 CheckFailed(
"invalid value for 'sign-return-address' attribute: " + S, V);
2688 if (
auto A =
Attrs.getFnAttr(
"sign-return-address-key");
A.isValid()) {
2689 StringRef S =
A.getValueAsString();
2690 if (S !=
"a_key" && S !=
"b_key")
2691 CheckFailed(
"invalid value for 'sign-return-address-key' attribute: " + S,
2693 if (
auto AA =
Attrs.getFnAttr(
"sign-return-address"); !AA.isValid()) {
2695 "'sign-return-address-key' present without `sign-return-address`");
2699 if (
auto A =
Attrs.getFnAttr(
"branch-target-enforcement");
A.isValid()) {
2700 StringRef S =
A.getValueAsString();
2701 if (S !=
"" && S !=
"true" && S !=
"false")
2703 "invalid value for 'branch-target-enforcement' attribute: " + S, V);
2706 if (
auto A =
Attrs.getFnAttr(
"branch-protection-pauth-lr");
A.isValid()) {
2707 StringRef S =
A.getValueAsString();
2708 if (S !=
"" && S !=
"true" && S !=
"false")
2710 "invalid value for 'branch-protection-pauth-lr' attribute: " + S, V);
2713 if (
auto A =
Attrs.getFnAttr(
"guarded-control-stack");
A.isValid()) {
2714 StringRef S =
A.getValueAsString();
2715 if (S !=
"" && S !=
"true" && S !=
"false")
2716 CheckFailed(
"invalid value for 'guarded-control-stack' attribute: " + S,
2720 if (
auto A =
Attrs.getFnAttr(
"vector-function-abi-variant");
A.isValid()) {
2721 StringRef S =
A.getValueAsString();
2724 CheckFailed(
"invalid name for a VFABI variant: " + S, V);
2727 if (
auto A =
Attrs.getFnAttr(
"modular-format");
A.isValid()) {
2728 StringRef S =
A.getValueAsString();
2732 "modular-format attribute requires at least 5 arguments", V);
2733 unsigned FirstArgIdx;
2734 Check(!Args[2].getAsInteger(10, FirstArgIdx),
2735 "modular-format attribute first arg index is not an integer", V);
2736 unsigned UpperBound = FT->getNumParams() + (FT->isVarArg() ? 1 : 0);
2737 Check(FirstArgIdx <= UpperBound,
2738 "modular-format attribute first arg index is out of bounds", V);
2741 if (
auto A =
Attrs.getFnAttr(
"target-features");
A.isValid()) {
2742 StringRef S =
A.getValueAsString();
2744 for (
auto FeatureFlag :
split(S,
',')) {
2745 if (FeatureFlag.empty())
2747 "target-features attribute should not contain an empty string");
2749 Check(FeatureFlag[0] ==
'+' || FeatureFlag[0] ==
'-',
2750 "target feature '" + FeatureFlag +
2751 "' must start with a '+' or '-'",
2757void Verifier::verifyUnknownProfileMetadata(MDNode *MD) {
2759 "'unknown' !prof should have a single additional operand", MD);
2762 "'unknown' !prof should have an additional operand of type "
2765 "the 'unknown' !prof operand should not be an empty string");
2768void Verifier::verifyFunctionMetadata(
2769 ArrayRef<std::pair<unsigned, MDNode *>> MDs) {
2770 for (
const auto &Pair : MDs) {
2771 if (Pair.first == LLVMContext::MD_prof) {
2772 MDNode *MD = Pair.second;
2774 "!prof annotations should have no less than 2 operands", MD);
2779 verifyUnknownProfileMetadata(MD);
2784 Check(MD->
getOperand(0) !=
nullptr,
"first operand should not be null",
2787 "expected string with name of the !prof annotation", MD);
2792 "first operand should be 'function_entry_count'"
2793 " or 'synthetic_function_entry_count'",
2797 Check(MD->
getOperand(1) !=
nullptr,
"second operand should not be null",
2800 "expected integer argument to function_entry_count", MD);
2801 }
else if (Pair.first == LLVMContext::MD_kcfi_type) {
2802 MDNode *MD = Pair.second;
2804 "!kcfi_type must have exactly one operand", MD);
2805 Check(MD->
getOperand(0) !=
nullptr,
"!kcfi_type operand must not be null",
2808 "expected a constant operand for !kcfi_type", MD);
2811 "expected a constant integer operand for !kcfi_type", MD);
2813 "expected a 32-bit integer constant operand for !kcfi_type", MD);
2818void Verifier::visitConstantExprsRecursively(
const Constant *EntryC) {
2822 if (!ConstantExprVisited.
insert(EntryC).second)
2826 Stack.push_back(EntryC);
2828 while (!
Stack.empty()) {
2833 visitConstantExpr(CE);
2836 visitConstantPtrAuth(CPA);
2841 Check(GV->
getParent() == &M,
"Referencing global in another module!",
2847 for (
const Use &U :
C->operands()) {
2851 if (!ConstantExprVisited.
insert(OpC).second)
2853 Stack.push_back(OpC);
2858void Verifier::visitConstantExpr(
const ConstantExpr *CE) {
2859 if (
CE->getOpcode() == Instruction::BitCast)
2862 "Invalid bitcast", CE);
2863 else if (
CE->getOpcode() == Instruction::PtrToAddr)
2864 checkPtrToAddr(
CE->getOperand(0)->getType(),
CE->getType(), *CE);
2867void Verifier::visitConstantPtrAuth(
const ConstantPtrAuth *CPA) {
2869 "signed ptrauth constant base pointer must have pointer type");
2872 "signed ptrauth constant must have same type as its base pointer");
2875 "signed ptrauth constant key must be i32 constant integer");
2878 "signed ptrauth constant address discriminator must be a pointer");
2881 "signed ptrauth constant discriminator must be i64 constant integer");
2884 "signed ptrauth constant deactivation symbol must be a pointer");
2888 "signed ptrauth constant deactivation symbol must be a global value "
2892bool Verifier::verifyAttributeCount(AttributeList Attrs,
unsigned Params) {
2895 return Attrs.getNumAttrSets() <= Params + 2;
2898void Verifier::verifyInlineAsmCall(
const CallBase &
Call) {
2901 unsigned LabelNo = 0;
2902 for (
const InlineAsm::ConstraintInfo &CI :
IA->ParseConstraints()) {
2912 if (CI.isIndirect) {
2915 "Operand for indirect constraint must have pointer type", &
Call);
2918 "Operand for indirect constraint must have elementtype attribute",
2922 "Elementtype attribute can only be applied for indirect "
2931 Check(LabelNo == CallBr->getNumIndirectDests(),
2932 "Number of label constraints does not match number of callbr dests",
2935 Check(LabelNo == 0,
"Label constraints can only be used with callbr",
2941void Verifier::verifyStatepoint(
const CallBase &
Call) {
2946 "gc.statepoint must read and write all memory to preserve "
2947 "reordering restrictions required by safepoint semantics",
2950 const int64_t NumPatchBytes =
2953 Check(NumPatchBytes >= 0,
2954 "gc.statepoint number of patchable bytes must be "
2959 Check(TargetElemType,
2960 "gc.statepoint callee argument must have elementtype attribute",
Call);
2962 Check(TargetFuncType,
2963 "gc.statepoint callee elementtype must be function type",
Call);
2966 Check(NumCallArgs >= 0,
2967 "gc.statepoint number of arguments to underlying call "
2970 const int NumParams = (int)TargetFuncType->getNumParams();
2971 if (TargetFuncType->isVarArg()) {
2972 Check(NumCallArgs >= NumParams,
2973 "gc.statepoint mismatch in number of vararg call args",
Call);
2976 Check(TargetFuncType->getReturnType()->isVoidTy(),
2977 "gc.statepoint doesn't support wrapping non-void "
2978 "vararg functions yet",
2981 Check(NumCallArgs == NumParams,
2982 "gc.statepoint mismatch in number of call args",
Call);
2984 const uint64_t
Flags
2986 Check((Flags & ~(uint64_t)StatepointFlags::MaskAll) == 0,
2987 "unknown flag used in gc.statepoint flags argument",
Call);
2992 for (
int i = 0; i < NumParams; i++) {
2993 Type *ParamType = TargetFuncType->getParamType(i);
2995 Check(ArgType == ParamType,
2996 "gc.statepoint call argument does not match wrapped "
3000 if (TargetFuncType->isVarArg()) {
3001 AttributeSet ArgAttrs =
Attrs.getParamAttrs(5 + i);
3003 "Attribute 'sret' cannot be used for vararg call arguments!",
Call);
3007 const int EndCallArgsInx = 4 + NumCallArgs;
3011 "gc.statepoint number of transition arguments "
3012 "must be constant integer",
3014 const int NumTransitionArgs =
3016 Check(NumTransitionArgs == 0,
3017 "gc.statepoint w/inline transition bundle is deprecated",
Call);
3018 const int EndTransitionArgsInx = EndCallArgsInx + 1 + NumTransitionArgs;
3022 "gc.statepoint number of deoptimization arguments "
3023 "must be constant integer",
3026 Check(NumDeoptArgs == 0,
3027 "gc.statepoint w/inline deopt operands is deprecated",
Call);
3029 const int ExpectedNumArgs = 7 + NumCallArgs;
3031 "gc.statepoint too many arguments",
Call);
3038 Check(UserCall,
"illegal use of statepoint token",
Call, U);
3042 "gc.result or gc.relocate are the only value uses "
3043 "of a gc.statepoint",
3047 "gc.result connected to wrong gc.statepoint",
Call, UserCall);
3050 "gc.relocate connected to wrong gc.statepoint",
Call, UserCall);
3064void Verifier::verifyFrameRecoverIndices() {
3065 for (
auto &Counts : FrameEscapeInfo) {
3067 unsigned EscapedObjectCount = Counts.second.first;
3068 unsigned MaxRecoveredIndex = Counts.second.second;
3069 Check(MaxRecoveredIndex <= EscapedObjectCount,
3070 "all indices passed to llvm.localrecover must be less than the "
3071 "number of arguments passed to llvm.localescape in the parent "
3080 UnwindDest =
II->getUnwindDest();
3082 UnwindDest = CSI->getUnwindDest();
3088void Verifier::verifySiblingFuncletUnwinds() {
3089 llvm::TimeTraceScope timeScope(
"Verifier verify sibling funclet unwinds");
3090 SmallPtrSet<Instruction *, 8> Visited;
3091 SmallPtrSet<Instruction *, 8>
Active;
3092 for (
const auto &Pair : SiblingFuncletInfo) {
3094 if (Visited.
count(PredPad))
3100 if (
Active.count(SuccPad)) {
3103 SmallVector<Instruction *, 8> CycleNodes;
3106 Instruction *CycleTerminator = SiblingFuncletInfo[CyclePad];
3107 if (CycleTerminator != CyclePad)
3110 }
while (CyclePad != SuccPad);
3111 Check(
false,
"EH pads can't handle each other's exceptions",
3115 if (!Visited.
insert(SuccPad).second)
3119 auto TermI = SiblingFuncletInfo.find(PredPad);
3120 if (TermI == SiblingFuncletInfo.end())
3133void Verifier::visitFunction(
const Function &
F) {
3134 visitGlobalValue(
F);
3137 FunctionType *FT =
F.getFunctionType();
3138 unsigned NumArgs =
F.arg_size();
3141 "Function context does not match Module context!", &
F);
3143 Check(!
F.hasCommonLinkage(),
"Functions may not have common linkage", &
F);
3144 Check(FT->getNumParams() == NumArgs,
3145 "# formal arguments must match # of arguments for function type!", &
F,
3147 Check(
F.getReturnType()->isFirstClassType() ||
3148 F.getReturnType()->isVoidTy() ||
F.getReturnType()->isStructTy(),
3149 "Functions cannot return aggregate values!", &
F);
3151 Check(!
F.hasStructRetAttr() ||
F.getReturnType()->isVoidTy(),
3152 "Invalid struct return type!", &
F);
3154 if (MaybeAlign
A =
F.getAlign()) {
3155 Check(
A->value() <= Value::MaximumAlignment,
3156 "huge alignment values are unsupported", &
F);
3159 AttributeList
Attrs =
F.getAttributes();
3161 Check(verifyAttributeCount(Attrs, FT->getNumParams()),
3162 "Attribute after last parameter!", &
F);
3164 bool IsIntrinsic =
F.isIntrinsic();
3167 verifyFunctionAttrs(FT, Attrs, &
F, IsIntrinsic,
false);
3173 "Attribute 'builtin' can only be applied to a callsite.", &
F);
3175 Check(!
Attrs.hasAttrSomewhere(Attribute::ElementType),
3176 "Attribute 'elementtype' can only be applied to a callsite.", &
F);
3178 if (
Attrs.hasFnAttr(Attribute::Naked))
3179 for (
const Argument &Arg :
F.args())
3180 Check(Arg.use_empty(),
"cannot use argument of naked function", &Arg);
3185 switch (
F.getCallingConv()) {
3187 case CallingConv::C:
3189 case CallingConv::X86_INTR: {
3190 Check(
F.arg_empty() ||
Attrs.hasParamAttr(0, Attribute::ByVal),
3191 "Calling convention parameter requires byval", &
F);
3194 case CallingConv::AMDGPU_KERNEL:
3195 case CallingConv::SPIR_KERNEL:
3196 case CallingConv::AMDGPU_CS_Chain:
3197 case CallingConv::AMDGPU_CS_ChainPreserve:
3198 Check(
F.getReturnType()->isVoidTy(),
3199 "Calling convention requires void return type", &
F);
3201 case CallingConv::AMDGPU_VS:
3202 case CallingConv::AMDGPU_HS:
3203 case CallingConv::AMDGPU_GS:
3204 case CallingConv::AMDGPU_PS:
3205 case CallingConv::AMDGPU_CS:
3206 Check(!
F.hasStructRetAttr(),
"Calling convention does not allow sret", &
F);
3207 if (
F.getCallingConv() != CallingConv::SPIR_KERNEL) {
3208 const unsigned StackAS =
DL.getAllocaAddrSpace();
3210 for (
const Argument &Arg :
F.args()) {
3211 Check(!
Attrs.hasParamAttr(i, Attribute::ByVal),
3212 "Calling convention disallows byval", &
F);
3213 Check(!
Attrs.hasParamAttr(i, Attribute::Preallocated),
3214 "Calling convention disallows preallocated", &
F);
3215 Check(!
Attrs.hasParamAttr(i, Attribute::InAlloca),
3216 "Calling convention disallows inalloca", &
F);
3218 if (
Attrs.hasParamAttr(i, Attribute::ByRef)) {
3221 Check(Arg.getType()->getPointerAddressSpace() != StackAS,
3222 "Calling convention disallows stack byref", &
F);
3230 case CallingConv::Fast:
3231 case CallingConv::Cold:
3232 case CallingConv::Intel_OCL_BI:
3233 case CallingConv::PTX_Kernel:
3234 case CallingConv::PTX_Device:
3236 "Calling convention does not support varargs or "
3237 "perfect forwarding!",
3240 case CallingConv::AMDGPU_Gfx_WholeWave:
3241 Check(!
F.arg_empty() &&
F.arg_begin()->getType()->isIntegerTy(1),
3242 "Calling convention requires first argument to be i1", &
F);
3243 Check(!
F.arg_begin()->hasInRegAttr(),
3244 "Calling convention requires first argument to not be inreg", &
F);
3246 "Calling convention does not support varargs or "
3247 "perfect forwarding!",
3254 for (
const Argument &Arg :
F.args()) {
3255 Check(Arg.getType() == FT->getParamType(i),
3256 "Argument value does not match function argument type!", &Arg,
3257 FT->getParamType(i));
3258 Check(Arg.getType()->isFirstClassType(),
3259 "Function arguments must have first-class types!", &Arg);
3261 Check(!Arg.getType()->isMetadataTy(),
3262 "Function takes metadata but isn't an intrinsic", &Arg, &
F);
3263 Check(!Arg.getType()->isTokenLikeTy(),
3264 "Function takes token but isn't an intrinsic", &Arg, &
F);
3265 Check(!Arg.getType()->isX86_AMXTy(),
3266 "Function takes x86_amx but isn't an intrinsic", &Arg, &
F);
3270 if (
Attrs.hasParamAttr(i, Attribute::SwiftError)) {
3271 verifySwiftErrorValue(&Arg);
3277 Check(!
F.getReturnType()->isTokenLikeTy(),
3278 "Function returns a token but isn't an intrinsic", &
F);
3279 Check(!
F.getReturnType()->isX86_AMXTy(),
3280 "Function returns a x86_amx but isn't an intrinsic", &
F);
3285 F.getAllMetadata(MDs);
3286 assert(
F.hasMetadata() != MDs.
empty() &&
"Bit out-of-sync");
3287 verifyFunctionMetadata(MDs);
3290 if (
F.hasPersonalityFn()) {
3293 Check(Per->getParent() ==
F.getParent(),
3294 "Referencing personality function in another module!", &
F,
3295 F.getParent(), Per, Per->getParent());
3299 BlockEHFuncletColors.
clear();
3301 if (
F.isMaterializable()) {
3303 Check(MDs.
empty(),
"unmaterialized function cannot have metadata", &
F,
3305 }
else if (
F.isDeclaration()) {
3306 for (
const auto &
I : MDs) {
3308 CheckDI(
I.first != LLVMContext::MD_dbg ||
3310 "function declaration may only have a unique !dbg attachment",
3312 Check(
I.first != LLVMContext::MD_prof,
3313 "function declaration may not have a !prof attachment", &
F);
3316 visitMDNode(*
I.second, AreDebugLocsAllowed::Yes);
3318 Check(!
F.hasPersonalityFn(),
3319 "Function declaration shouldn't have a personality routine", &
F);
3323 Check(!IsIntrinsic,
"llvm intrinsics cannot be defined!", &
F);
3328 "Entry block to function must not have predecessors!", Entry);
3331 if (
Entry->hasAddressTaken()) {
3333 "blockaddress may not be used with the entry block!", Entry);
3336 unsigned NumDebugAttachments = 0, NumProfAttachments = 0,
3337 NumKCFIAttachments = 0;
3339 for (
const auto &
I : MDs) {
3341 auto AllowLocs = AreDebugLocsAllowed::No;
3345 case LLVMContext::MD_dbg: {
3346 ++NumDebugAttachments;
3347 CheckDI(NumDebugAttachments == 1,
3348 "function must have a single !dbg attachment", &
F,
I.second);
3350 "function !dbg attachment must be a subprogram", &
F,
I.second);
3352 "function definition may only have a distinct !dbg attachment",
3356 const Function *&AttachedTo = DISubprogramAttachments[
SP];
3357 CheckDI(!AttachedTo || AttachedTo == &
F,
3358 "DISubprogram attached to more than one function", SP, &
F);
3360 AllowLocs = AreDebugLocsAllowed::Yes;
3363 case LLVMContext::MD_prof:
3364 ++NumProfAttachments;
3365 Check(NumProfAttachments == 1,
3366 "function must have a single !prof attachment", &
F,
I.second);
3368 case LLVMContext::MD_kcfi_type:
3369 ++NumKCFIAttachments;
3370 Check(NumKCFIAttachments == 1,
3371 "function must have a single !kcfi_type attachment", &
F,
3377 visitMDNode(*
I.second, AllowLocs);
3385 if (
F.isIntrinsic() &&
F.getParent()->isMaterialized()) {
3387 if (
F.hasAddressTaken(&U,
false,
true,
false,
3389 Check(
false,
"Invalid user of intrinsic instruction!", U);
3393 switch (
F.getIntrinsicID()) {
3394 case Intrinsic::experimental_gc_get_pointer_base: {
3395 FunctionType *FT =
F.getFunctionType();
3396 Check(FT->getNumParams() == 1,
"wrong number of parameters",
F);
3398 "gc.get.pointer.base must return a pointer",
F);
3399 Check(FT->getParamType(0) ==
F.getReturnType(),
3400 "gc.get.pointer.base operand and result must be of the same type",
F);
3403 case Intrinsic::experimental_gc_get_pointer_offset: {
3404 FunctionType *FT =
F.getFunctionType();
3405 Check(FT->getNumParams() == 1,
"wrong number of parameters",
F);
3407 "gc.get.pointer.offset operand must be a pointer",
F);
3408 Check(
F.getReturnType()->isIntegerTy(),
3409 "gc.get.pointer.offset must return integer",
F);
3414 auto *
N =
F.getSubprogram();
3415 HasDebugInfo = (
N !=
nullptr);
3423 SmallPtrSet<const MDNode *, 32> Seen;
3435 "DILocation's scope must be a DILocalScope",
N, &
F, &
I,
DL, Parent);
3437 DILocalScope *
Scope =
DL->getInlinedAtScope();
3438 Check(Scope,
"Failed to find DILocalScope",
DL);
3440 if (!Seen.
insert(Scope).second)
3443 DISubprogram *
SP =
Scope->getSubprogram();
3447 if ((Scope != SP) && !Seen.
insert(SP).second)
3451 "!dbg attachment points at wrong subprogram for function",
N, &
F,
3455 for (
auto &
I : BB) {
3456 VisitDebugLoc(
I,
I.getDebugLoc().getAsMDNode());
3458 if (
auto MD =
I.getMetadata(LLVMContext::MD_loop))
3461 if (BrokenDebugInfo)
3468void Verifier::visitBasicBlock(BasicBlock &BB) {
3469 InstsInThisBlock.
clear();
3470 ConvergenceVerifyHelper.
visit(BB);
3481 for (
const PHINode &PN : BB.
phis()) {
3482 Check(PN.getNumIncomingValues() == Preds.size(),
3483 "PHINode should have one entry for each predecessor of its "
3484 "parent basic block!",
3489 Values.
reserve(PN.getNumIncomingValues());
3490 for (
unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i)
3492 std::make_pair(PN.getIncomingBlock(i), PN.getIncomingValue(i)));
3495 for (
unsigned i = 0, e = Values.
size(); i != e; ++i) {
3500 Check(i == 0 || Values[i].first != Values[i - 1].first ||
3501 Values[i].second == Values[i - 1].second,
3502 "PHI node has multiple entries for the same basic block with "
3503 "different incoming values!",
3504 &PN, Values[i].first, Values[i].second, Values[i - 1].second);
3508 Check(Values[i].first == Preds[i],
3509 "PHI node entries do not match predecessors!", &PN,
3510 Values[i].first, Preds[i]);
3518 Check(
I.getParent() == &BB,
"Instruction has bogus parent pointer!");
3522 CheckDI(!BB.getTrailingDbgRecords(),
"Basic Block has trailing DbgRecords!",
3526void Verifier::visitTerminator(Instruction &
I) {
3528 Check(&
I ==
I.getParent()->getTerminator(),
3529 "Terminator found in the middle of a basic block!",
I.getParent());
3530 visitInstruction(
I);
3533void Verifier::visitCondBrInst(CondBrInst &BI) {
3535 "Branch condition is not 'i1' type!", &BI, BI.
getCondition());
3536 visitTerminator(BI);
3539void Verifier::visitReturnInst(ReturnInst &RI) {
3542 if (
F->getReturnType()->isVoidTy())
3544 "Found return instr that returns non-void in Function of void "
3546 &RI,
F->getReturnType());
3549 "Function return type does not match operand "
3550 "type of return inst!",
3551 &RI,
F->getReturnType());
3555 visitTerminator(RI);
3558void Verifier::visitSwitchInst(SwitchInst &SI) {
3559 Check(
SI.getType()->isVoidTy(),
"Switch must have void result type!", &SI);
3562 Type *SwitchTy =
SI.getCondition()->getType();
3563 SmallPtrSet<ConstantInt*, 32>
Constants;
3564 for (
auto &Case :
SI.cases()) {
3566 "Case value is not a constant integer.", &SI);
3567 Check(Case.getCaseValue()->getType() == SwitchTy,
3568 "Switch constants must all be same type as switch value!", &SI);
3570 "Duplicate integer as switch case", &SI, Case.getCaseValue());
3573 visitTerminator(SI);
3576void Verifier::visitIndirectBrInst(IndirectBrInst &BI) {
3578 "Indirectbr operand must have pointer type!", &BI);
3581 "Indirectbr destinations must all have pointer type!", &BI);
3583 visitTerminator(BI);
3586void Verifier::visitCallBrInst(CallBrInst &CBI) {
3589 "Callbr: indirect function / invalid signature");
3591 "Callbr for intrinsics currently doesn't support operand bundles");
3594 case Intrinsic::amdgcn_kill: {
3596 "Callbr amdgcn_kill only supports one indirect dest");
3600 Intrinsic::amdgcn_unreachable),
3601 "Callbr amdgcn_kill indirect dest needs to be unreachable");
3606 "Callbr currently only supports asm-goto and selected intrinsics");
3611 Check(!
IA->canThrow(),
"Unwinding from Callbr is not allowed");
3613 verifyInlineAsmCall(CBI);
3615 visitTerminator(CBI);
3618void Verifier::visitSelectInst(SelectInst &SI) {
3621 "Invalid operands for select instruction!", &SI);
3623 Check(
SI.getTrueValue()->getType() ==
SI.getType(),
3624 "Select values must have same type as select instruction!", &SI);
3625 visitInstruction(SI);
3631void Verifier::visitUserOp1(Instruction &
I) {
3632 Check(
false,
"User-defined operators should not live outside of a pass!", &
I);
3635void Verifier::visitTruncInst(TruncInst &
I) {
3637 Type *SrcTy =
I.getOperand(0)->getType();
3638 Type *DestTy =
I.getType();
3647 "trunc source and destination must both be a vector or neither", &
I);
3648 Check(SrcBitSize > DestBitSize,
"DestTy too big for Trunc", &
I);
3650 visitInstruction(
I);
3653void Verifier::visitZExtInst(ZExtInst &
I) {
3655 Type *SrcTy =
I.getOperand(0)->getType();
3656 Type *DestTy =
I.getType();
3662 "zext source and destination must both be a vector or neither", &
I);
3666 Check(SrcBitSize < DestBitSize,
"Type too small for ZExt", &
I);
3668 visitInstruction(
I);
3671void Verifier::visitSExtInst(SExtInst &
I) {
3673 Type *SrcTy =
I.getOperand(0)->getType();
3674 Type *DestTy =
I.getType();
3683 "sext source and destination must both be a vector or neither", &
I);
3684 Check(SrcBitSize < DestBitSize,
"Type too small for SExt", &
I);
3686 visitInstruction(
I);
3689void Verifier::visitFPTruncInst(FPTruncInst &
I) {
3691 Type *SrcTy =
I.getOperand(0)->getType();
3692 Type *DestTy =
I.getType();
3700 "fptrunc source and destination must both be a vector or neither", &
I);
3701 Check(SrcBitSize > DestBitSize,
"DestTy too big for FPTrunc", &
I);
3703 visitInstruction(
I);
3706void Verifier::visitFPExtInst(FPExtInst &
I) {
3708 Type *SrcTy =
I.getOperand(0)->getType();
3709 Type *DestTy =
I.getType();
3718 "fpext source and destination must both be a vector or neither", &
I);
3719 Check(SrcBitSize < DestBitSize,
"DestTy too small for FPExt", &
I);
3721 visitInstruction(
I);
3724void Verifier::visitUIToFPInst(UIToFPInst &
I) {
3726 Type *SrcTy =
I.getOperand(0)->getType();
3727 Type *DestTy =
I.getType();
3732 Check(SrcVec == DstVec,
3733 "UIToFP source and dest must both be vector or scalar", &
I);
3735 "UIToFP source must be integer or integer vector", &
I);
3739 if (SrcVec && DstVec)
3742 "UIToFP source and dest vector length mismatch", &
I);
3744 visitInstruction(
I);
3747void Verifier::visitSIToFPInst(SIToFPInst &
I) {
3749 Type *SrcTy =
I.getOperand(0)->getType();
3750 Type *DestTy =
I.getType();
3755 Check(SrcVec == DstVec,
3756 "SIToFP source and dest must both be vector or scalar", &
I);
3758 "SIToFP source must be integer or integer vector", &
I);
3762 if (SrcVec && DstVec)
3765 "SIToFP source and dest vector length mismatch", &
I);
3767 visitInstruction(
I);
3770void Verifier::visitFPToUIInst(FPToUIInst &
I) {
3772 Type *SrcTy =
I.getOperand(0)->getType();
3773 Type *DestTy =
I.getType();
3778 Check(SrcVec == DstVec,
3779 "FPToUI source and dest must both be vector or scalar", &
I);
3782 "FPToUI result must be integer or integer vector", &
I);
3784 if (SrcVec && DstVec)
3787 "FPToUI source and dest vector length mismatch", &
I);
3789 visitInstruction(
I);
3792void Verifier::visitFPToSIInst(FPToSIInst &
I) {
3794 Type *SrcTy =
I.getOperand(0)->getType();
3795 Type *DestTy =
I.getType();
3800 Check(SrcVec == DstVec,
3801 "FPToSI source and dest must both be vector or scalar", &
I);
3804 "FPToSI result must be integer or integer vector", &
I);
3806 if (SrcVec && DstVec)
3809 "FPToSI source and dest vector length mismatch", &
I);
3811 visitInstruction(
I);
3814void Verifier::checkPtrToAddr(
Type *SrcTy,
Type *DestTy,
const Value &V) {
3823 Check(VSrc->getElementCount() == VDest->getElementCount(),
3824 "PtrToAddr vector length mismatch", V);
3827 Type *AddrTy =
DL.getAddressType(SrcTy);
3828 Check(AddrTy == DestTy,
"PtrToAddr result must be address width", V);
3831void Verifier::visitPtrToAddrInst(PtrToAddrInst &
I) {
3832 checkPtrToAddr(
I.getOperand(0)->getType(),
I.getType(),
I);
3833 visitInstruction(
I);
3836void Verifier::visitPtrToIntInst(PtrToIntInst &
I) {
3838 Type *SrcTy =
I.getOperand(0)->getType();
3839 Type *DestTy =
I.getType();
3850 Check(VSrc->getElementCount() == VDest->getElementCount(),
3851 "PtrToInt Vector length mismatch", &
I);
3854 visitInstruction(
I);
3857void Verifier::visitIntToPtrInst(IntToPtrInst &
I) {
3859 Type *SrcTy =
I.getOperand(0)->getType();
3860 Type *DestTy =
I.getType();
3870 Check(VSrc->getElementCount() == VDest->getElementCount(),
3871 "IntToPtr Vector length mismatch", &
I);
3873 visitInstruction(
I);
3876void Verifier::visitBitCastInst(BitCastInst &
I) {
3879 "Invalid bitcast", &
I);
3880 visitInstruction(
I);
3883void Verifier::visitAddrSpaceCastInst(AddrSpaceCastInst &
I) {
3884 Type *SrcTy =
I.getOperand(0)->getType();
3885 Type *DestTy =
I.getType();
3892 "AddrSpaceCast must be between different address spaces", &
I);
3894 Check(SrcVTy->getElementCount() ==
3896 "AddrSpaceCast vector pointer number of elements mismatch", &
I);
3897 visitInstruction(
I);
3902void Verifier::visitPHINode(PHINode &PN) {
3909 "PHI nodes not grouped at top of basic block!", &PN, PN.
getParent());
3918 "PHI node operands are not the same type as the result!", &PN);
3923 visitInstruction(PN);
3926void Verifier::visitCallBase(CallBase &
Call) {
3928 "Called function must be a pointer!",
Call);
3932 if (FTy->isVarArg())
3934 "Called function requires more parameters than were provided!",
Call);
3937 "Incorrect number of arguments passed to called function!",
Call);
3940 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
3942 "Call parameter type does not match function signature!",
3948 "Attribute after last parameter!",
Call);
3955 "Intrinsic called with incompatible signature",
Call);
3959 "calling convention does not permit calls",
Call);
3965 auto VerifyTypeAlign = [&](
Type *Ty,
const Twine &Message) {
3968 Align ABIAlign =
DL.getABITypeAlign(Ty);
3969 Check(ABIAlign.
value() <= Value::MaximumAlignment,
3970 "Incorrect alignment of " + Message +
" to called function!",
Call);
3974 VerifyTypeAlign(FTy->getReturnType(),
"return type");
3975 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) {
3976 Type *Ty = FTy->getParamType(i);
3977 VerifyTypeAlign(Ty,
"argument passed");
3981 if (
Attrs.hasFnAttr(Attribute::Speculatable)) {
3985 "speculatable attribute may not apply to call sites",
Call);
3988 if (
Attrs.hasFnAttr(Attribute::Preallocated)) {
3990 "preallocated as a call site attribute can only be on "
3991 "llvm.call.preallocated.arg");
3994 Check(!
Attrs.hasFnAttr(Attribute::DenormalFPEnv),
3995 "denormal_fpenv attribute may not apply to call sites",
Call);
4006 Check(AI->isUsedWithInAlloca(),
4007 "inalloca argument for call has mismatched alloca", AI,
Call);
4013 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) {
4017 Check(AI->isSwiftError(),
4018 "swifterror argument for call has mismatched alloca", AI,
Call);
4022 Check(ArgI,
"swifterror argument should come from an alloca or parameter",
4023 SwiftErrorArg,
Call);
4024 Check(ArgI->hasSwiftErrorAttr(),
4025 "swifterror argument for call has mismatched parameter", ArgI,
4029 if (
Attrs.hasParamAttr(i, Attribute::ImmArg)) {
4032 Check(Callee &&
Callee->hasParamAttribute(i, Attribute::ImmArg),
4041 "immarg operand has non-immediate parameter", ArgVal,
Call);
4047 const ConstantRange &CR =
4050 "immarg value " + Twine(CI->getValue().getSExtValue()) +
4063 Check(hasOB != isMustTail,
4064 "preallocated operand either requires a preallocated bundle or "
4065 "the call to be musttail (but not both)",
4070 if (FTy->isVarArg()) {
4072 bool SawNest =
false;
4073 bool SawReturned =
false;
4075 for (
unsigned Idx = 0; Idx < FTy->getNumParams(); ++Idx) {
4076 if (
Attrs.hasParamAttr(Idx, Attribute::Nest))
4078 if (
Attrs.hasParamAttr(Idx, Attribute::Returned))
4083 for (
unsigned Idx = FTy->getNumParams(); Idx <
Call.
arg_size(); ++Idx) {
4085 AttributeSet ArgAttrs =
Attrs.getParamAttrs(Idx);
4086 verifyParameterAttrs(ArgAttrs, Ty, &
Call);
4089 Check(!SawNest,
"More than one parameter has attribute nest!",
Call);
4094 Check(!SawReturned,
"More than one parameter has attribute returned!",
4097 "Incompatible argument and return types for 'returned' "
4107 "Attribute 'sret' cannot be used for vararg call arguments!",
4112 "inalloca isn't on the last argument!",
Call);
4118 for (
Type *ParamTy : FTy->params()) {
4119 Check(!ParamTy->isMetadataTy(),
4120 "Function has metadata parameter but isn't an intrinsic",
Call);
4121 Check(!ParamTy->isTokenLikeTy(),
4122 "Function has token parameter but isn't an intrinsic",
Call);
4128 Check(!FTy->getReturnType()->isTokenLikeTy(),
4129 "Return type cannot be token for indirect call!");
4130 Check(!FTy->getReturnType()->isX86_AMXTy(),
4131 "Return type cannot be x86_amx for indirect call!");
4135 visitIntrinsicCall(
ID,
Call);
4140 bool FoundDeoptBundle =
false, FoundFuncletBundle =
false,
4141 FoundGCTransitionBundle =
false, FoundCFGuardTargetBundle =
false,
4142 FoundPreallocatedBundle =
false, FoundGCLiveBundle =
false,
4143 FoundPtrauthBundle =
false, FoundKCFIBundle =
false,
4144 FoundAttachedCallBundle =
false;
4149 Check(!FoundDeoptBundle,
"Multiple deopt operand bundles",
Call);
4150 FoundDeoptBundle =
true;
4152 Check(!FoundGCTransitionBundle,
"Multiple gc-transition operand bundles",
4154 FoundGCTransitionBundle =
true;
4156 Check(!FoundFuncletBundle,
"Multiple funclet operand bundles",
Call);
4157 FoundFuncletBundle =
true;
4159 "Expected exactly one funclet bundle operand",
Call);
4161 "Funclet bundle operands should correspond to a FuncletPadInst",
4164 Check(!FoundCFGuardTargetBundle,
"Multiple CFGuardTarget operand bundles",
4166 FoundCFGuardTargetBundle =
true;
4168 "Expected exactly one cfguardtarget bundle operand",
Call);
4170 Check(!FoundPtrauthBundle,
"Multiple ptrauth operand bundles",
Call);
4171 FoundPtrauthBundle =
true;
4173 "Expected exactly two ptrauth bundle operands",
Call);
4175 BU.
Inputs[0]->getType()->isIntegerTy(32),
4176 "Ptrauth bundle key operand must be an i32 constant",
Call);
4178 "Ptrauth bundle discriminator operand must be an i64",
Call);
4180 Check(!FoundKCFIBundle,
"Multiple kcfi operand bundles",
Call);
4181 FoundKCFIBundle =
true;
4182 Check(BU.
Inputs.size() == 1,
"Expected exactly one kcfi bundle operand",
4185 BU.
Inputs[0]->getType()->isIntegerTy(32),
4186 "Kcfi bundle operand must be an i32 constant",
Call);
4188 Check(!FoundPreallocatedBundle,
"Multiple preallocated operand bundles",
4190 FoundPreallocatedBundle =
true;
4192 "Expected exactly one preallocated bundle operand",
Call);
4195 Input->getIntrinsicID() == Intrinsic::call_preallocated_setup,
4196 "\"preallocated\" argument must be a token from "
4197 "llvm.call.preallocated.setup",
4200 Check(!FoundGCLiveBundle,
"Multiple gc-live operand bundles",
Call);
4201 FoundGCLiveBundle =
true;
4203 Check(!FoundAttachedCallBundle,
4204 "Multiple \"clang.arc.attachedcall\" operand bundles",
Call);
4205 FoundAttachedCallBundle =
true;
4206 verifyAttachedCallBundle(
Call, BU);
4212 "Direct call cannot have a ptrauth bundle",
Call);
4224 "inlinable function call in a function with "
4225 "debug info must have a !dbg location",
4229 verifyInlineAsmCall(
Call);
4233 visitInstruction(
Call);
4236void Verifier::verifyTailCCMustTailAttrs(
const AttrBuilder &Attrs,
4239 Twine(
"inalloca attribute not allowed in ") +
Context);
4241 Twine(
"inreg attribute not allowed in ") +
Context);
4242 Check(!
Attrs.contains(Attribute::SwiftError),
4243 Twine(
"swifterror attribute not allowed in ") +
Context);
4244 Check(!
Attrs.contains(Attribute::Preallocated),
4245 Twine(
"preallocated attribute not allowed in ") +
Context);
4247 Twine(
"byref attribute not allowed in ") +
Context);
4252 Attribute::StructRet, Attribute::ByVal, Attribute::InAlloca,
4253 Attribute::InReg, Attribute::StackAlignment, Attribute::SwiftSelf,
4254 Attribute::SwiftAsync, Attribute::SwiftError, Attribute::Preallocated,
4256 AttrBuilder Copy(
C);
4257 for (
auto AK : ABIAttrs) {
4258 Attribute Attr = Attrs.getParamAttrs(
I).getAttribute(AK);
4260 Copy.addAttribute(Attr);
4264 if (Attrs.hasParamAttr(
I, Attribute::Alignment) &&
4265 (Attrs.hasParamAttr(
I, Attribute::ByVal) ||
4266 Attrs.hasParamAttr(
I, Attribute::ByRef)))
4267 Copy.addAlignmentAttr(Attrs.getParamAlignment(
I));
4271void Verifier::verifyMustTailCall(CallInst &CI) {
4275 FunctionType *CallerTy =
F->getFunctionType();
4277 Check(CallerTy->isVarArg() == CalleeTy->isVarArg(),
4278 "cannot guarantee tail call due to mismatched varargs", &CI);
4279 Check(CallerTy->getReturnType() == CalleeTy->getReturnType(),
4280 "cannot guarantee tail call due to mismatched return types", &CI);
4284 "cannot guarantee tail call due to mismatched calling conv", &CI);
4292 Check(Ret,
"musttail call must precede a ret", &CI);
4295 "musttail call result must be returned", Ret);
4297 AttributeList CallerAttrs =
F->getAttributes();
4302 CI.
getCallingConv() == CallingConv::Tail ?
"tailcc" :
"swifttailcc";
4306 for (
unsigned I = 0,
E = CallerTy->getNumParams();
I !=
E; ++
I) {
4308 SmallString<32>
Context{CCName, StringRef(
" musttail caller")};
4309 verifyTailCCMustTailAttrs(ABIAttrs,
Context);
4311 for (
unsigned I = 0,
E = CalleeTy->getNumParams();
I !=
E; ++
I) {
4313 SmallString<32>
Context{CCName, StringRef(
" musttail callee")};
4314 verifyTailCCMustTailAttrs(ABIAttrs,
Context);
4317 Check(!CallerTy->isVarArg(), Twine(
"cannot guarantee ") + CCName +
4318 " tail call for varargs function");
4324 Check(CallerTy->getNumParams() == CalleeTy->getNumParams(),
4325 "cannot guarantee tail call due to mismatched parameter counts", &CI);
4326 for (
unsigned I = 0,
E = CallerTy->getNumParams();
I !=
E; ++
I) {
4327 Check(CallerTy->getParamType(
I) == CalleeTy->getParamType(
I),
4328 "cannot guarantee tail call due to mismatched parameter types",
4335 for (
unsigned I = 0,
E = CallerTy->getNumParams();
I !=
E; ++
I) {
4338 Check(CallerABIAttrs == CalleeABIAttrs,
4339 "cannot guarantee tail call due to mismatched ABI impacting "
4340 "function attributes",
4345void Verifier::visitCallInst(CallInst &CI) {
4349 verifyMustTailCall(CI);
4352void Verifier::visitInvokeInst(InvokeInst &
II) {
4358 II.getUnwindDest()->isEHPad(),
4359 "The unwind destination does not have an exception handling instruction!",
4362 visitTerminator(
II);
4367void Verifier::visitUnaryOperator(UnaryOperator &U) {
4368 Check(
U.getType() ==
U.getOperand(0)->getType(),
4369 "Unary operators must have same type for"
4370 "operands and result!",
4373 switch (
U.getOpcode()) {
4376 case Instruction::FNeg:
4377 Check(
U.getType()->isFPOrFPVectorTy(),
4378 "FNeg operator only works with float types!", &U);
4384 visitInstruction(U);
4390void Verifier::visitBinaryOperator(BinaryOperator &
B) {
4391 Check(
B.getOperand(0)->getType() ==
B.getOperand(1)->getType(),
4392 "Both operands to a binary operator are not of the same type!", &
B);
4394 switch (
B.getOpcode()) {
4397 case Instruction::Add:
4398 case Instruction::Sub:
4399 case Instruction::Mul:
4400 case Instruction::SDiv:
4401 case Instruction::UDiv:
4402 case Instruction::SRem:
4403 case Instruction::URem:
4404 Check(
B.getType()->isIntOrIntVectorTy(),
4405 "Integer arithmetic operators only work with integral types!", &
B);
4406 Check(
B.getType() ==
B.getOperand(0)->getType(),
4407 "Integer arithmetic operators must have same type "
4408 "for operands and result!",
4413 case Instruction::FAdd:
4414 case Instruction::FSub:
4415 case Instruction::FMul:
4416 case Instruction::FDiv:
4417 case Instruction::FRem:
4418 Check(
B.getType()->isFPOrFPVectorTy(),
4419 "Floating-point arithmetic operators only work with "
4420 "floating-point types!",
4422 Check(
B.getType() ==
B.getOperand(0)->getType(),
4423 "Floating-point arithmetic operators must have same type "
4424 "for operands and result!",
4428 case Instruction::And:
4429 case Instruction::Or:
4430 case Instruction::Xor:
4431 Check(
B.getType()->isIntOrIntVectorTy(),
4432 "Logical operators only work with integral types!", &
B);
4433 Check(
B.getType() ==
B.getOperand(0)->getType(),
4434 "Logical operators must have same type for operands and result!", &
B);
4436 case Instruction::Shl:
4437 case Instruction::LShr:
4438 case Instruction::AShr:
4439 Check(
B.getType()->isIntOrIntVectorTy(),
4440 "Shifts only work with integral types!", &
B);
4441 Check(
B.getType() ==
B.getOperand(0)->getType(),
4442 "Shift return type must be same as operands!", &
B);
4448 visitInstruction(
B);
4451void Verifier::visitICmpInst(ICmpInst &IC) {
4455 Check(Op0Ty == Op1Ty,
4456 "Both operands to ICmp instruction are not of the same type!", &IC);
4459 "Invalid operand types for ICmp instruction", &IC);
4463 visitInstruction(IC);
4466void Verifier::visitFCmpInst(FCmpInst &FC) {
4468 Type *Op0Ty =
FC.getOperand(0)->getType();
4469 Type *Op1Ty =
FC.getOperand(1)->getType();
4470 Check(Op0Ty == Op1Ty,
4471 "Both operands to FCmp instruction are not of the same type!", &FC);
4476 Check(
FC.isFPPredicate(),
"Invalid predicate in FCmp instruction!", &FC);
4478 visitInstruction(FC);
4481void Verifier::visitExtractElementInst(ExtractElementInst &EI) {
4483 "Invalid extractelement operands!", &EI);
4484 visitInstruction(EI);
4487void Verifier::visitInsertElementInst(InsertElementInst &IE) {
4490 "Invalid insertelement operands!", &IE);
4491 visitInstruction(IE);
4494void Verifier::visitShuffleVectorInst(ShuffleVectorInst &SV) {
4497 "Invalid shufflevector operands!", &SV);
4498 visitInstruction(SV);
4501void Verifier::visitGetElementPtrInst(GetElementPtrInst &
GEP) {
4503 GEP.getModule()->getModuleFlag(
"require-logical-pointer")))
4504 Check(!MD->getZExtValue(),
4505 "Non-logical getelementptr disallowed for this module.");
4507 Type *TargetTy =
GEP.getPointerOperandType()->getScalarType();
4510 "GEP base pointer is not a vector or a vector of pointers", &
GEP);
4511 Check(
GEP.getSourceElementType()->isSized(),
"GEP into unsized type!", &
GEP);
4515 "getelementptr cannot target structure that contains scalable vector"
4520 SmallVector<Value *, 16> Idxs(
GEP.indices());
4522 all_of(Idxs, [](
Value *V) {
return V->getType()->isIntOrIntVectorTy(); }),
4523 "GEP indexes must be integers", &
GEP);
4526 Check(ElTy,
"Invalid indices for GEP pointer type!", &
GEP);
4530 Check(PtrTy &&
GEP.getResultElementType() == ElTy,
4531 "GEP is not of right type for indices!", &
GEP, ElTy);
4535 ElementCount GEPWidth = GEPVTy->getElementCount();
4536 if (
GEP.getPointerOperandType()->isVectorTy())
4540 "Vector GEP result width doesn't match operand's", &
GEP);
4541 for (
Value *Idx : Idxs) {
4542 Type *IndexTy = Idx->getType();
4544 ElementCount IndexWidth = IndexVTy->getElementCount();
4545 Check(IndexWidth == GEPWidth,
"Invalid GEP index vector width", &
GEP);
4548 "All GEP indices should be of integer type");
4555 GTI != GTE; ++GTI) {
4556 if (GTI.isVector()) {
4557 Type *ElemTy = GTI.getIndexedType();
4558 Check(
DL.typeSizeEqualsStoreSize(ElemTy),
4559 "GEP into vector with non-byte-addressable element type", &
GEP);
4563 Check(
GEP.getAddressSpace() == PtrTy->getAddressSpace(),
4564 "GEP address space doesn't match type", &
GEP);
4566 visitInstruction(
GEP);
4570 return A.getUpper() ==
B.getLower() ||
A.getLower() ==
B.getUpper();
4575void Verifier::verifyRangeLikeMetadata(
const Value &
I,
const MDNode *
Range,
4576 Type *Ty, RangeLikeMetadataKind Kind) {
4577 unsigned NumOperands =
Range->getNumOperands();
4578 Check(NumOperands % 2 == 0,
"Unfinished range!",
Range);
4579 unsigned NumRanges = NumOperands / 2;
4580 Check(NumRanges >= 1,
"It should have at least one range!",
Range);
4582 ConstantRange LastRange(1,
true);
4583 for (
unsigned i = 0; i < NumRanges; ++i) {
4586 Check(
Low,
"The lower limit must be an integer!",
Low);
4591 Check(
High->getType() ==
Low->getType(),
"Range pair types must match!",
4594 if (Kind == RangeLikeMetadataKind::NoaliasAddrspace) {
4596 "noalias.addrspace type must be i32!", &
I);
4599 "Range types must match instruction type!", &
I);
4602 APInt HighV =
High->getValue();
4603 APInt LowV =
Low->getValue();
4608 "The upper and lower limits cannot be the same value", &
I);
4610 ConstantRange CurRange(LowV, HighV);
4611 Check(!CurRange.isEmptySet() &&
4612 (Kind == RangeLikeMetadataKind::AbsoluteSymbol ||
4613 !CurRange.isFullSet()),
4614 "Range must not be empty!",
Range);
4616 Check(CurRange.intersectWith(LastRange).isEmptySet(),
4617 "Intervals are overlapping",
Range);
4618 Check(LowV.
sgt(LastRange.getLower()),
"Intervals are not in order",
4623 LastRange = ConstantRange(LowV, HighV);
4625 if (NumRanges > 2) {
4630 ConstantRange FirstRange(FirstLow, FirstHigh);
4631 Check(FirstRange.intersectWith(LastRange).isEmptySet(),
4632 "Intervals are overlapping",
Range);
4638void Verifier::visitRangeMetadata(Instruction &
I, MDNode *
Range,
Type *Ty) {
4640 "precondition violation");
4641 verifyRangeLikeMetadata(
I,
Range, Ty, RangeLikeMetadataKind::Range);
4644void Verifier::visitNoFPClassMetadata(Instruction &
I, MDNode *NoFPClass,
4646 Check(AttributeFuncs::isNoFPClassCompatibleType(Ty),
4647 "nofpclass only applies to floating-point typed loads",
I);
4650 "nofpclass must have exactly one entry", NoFPClass);
4651 ConstantInt *MaskVal =
4654 "nofpclass entry must be a constant i32", NoFPClass);
4656 Check(Val != 0,
"'nofpclass' must have at least one test bit set", NoFPClass,
4660 "Invalid value for 'nofpclass' test mask", NoFPClass,
I);
4663void Verifier::visitNoaliasAddrspaceMetadata(Instruction &
I, MDNode *
Range,
4666 "precondition violation");
4667 verifyRangeLikeMetadata(
I,
Range, Ty,
4668 RangeLikeMetadataKind::NoaliasAddrspace);
4671void Verifier::checkAtomicMemAccessSize(
Type *Ty,
const Instruction *
I) {
4672 unsigned Size =
DL.getTypeSizeInBits(Ty).getFixedValue();
4673 Check(
Size >= 8,
"atomic memory access' size must be byte-sized", Ty,
I);
4675 "atomic memory access' operand must have a power-of-two size", Ty,
I);
4678void Verifier::visitLoadInst(LoadInst &LI) {
4680 Check(PTy,
"Load operand must be a pointer.", &LI);
4683 Check(
A->value() <= Value::MaximumAlignment,
4684 "huge alignment values are unsupported", &LI);
4686 Check(ElTy->
isSized(),
"loading unsized types is not allowed", &LI);
4689 LI.
getOrdering() != AtomicOrdering::AcquireRelease,
4690 "Load cannot have Release ordering", &LI);
4694 "atomic load operand must have integer, byte, pointer, floating "
4695 "point, or vector type!",
4698 checkAtomicMemAccessSize(ElTy, &LI);
4701 "Non-atomic load cannot have SynchronizationScope specified", &LI);
4704 visitInstruction(LI);
4707void Verifier::visitStoreInst(StoreInst &SI) {
4709 Check(PTy,
"Store operand must be a pointer.", &SI);
4710 Type *ElTy =
SI.getOperand(0)->getType();
4711 if (MaybeAlign
A =
SI.getAlign()) {
4712 Check(
A->value() <= Value::MaximumAlignment,
4713 "huge alignment values are unsupported", &SI);
4715 Check(ElTy->
isSized(),
"storing unsized types is not allowed", &SI);
4716 if (
SI.isAtomic()) {
4717 Check(
SI.getOrdering() != AtomicOrdering::Acquire &&
4718 SI.getOrdering() != AtomicOrdering::AcquireRelease,
4719 "Store cannot have Acquire ordering", &SI);
4723 "atomic store operand must have integer, byte, pointer, floating "
4724 "point, or vector type!",
4726 checkAtomicMemAccessSize(ElTy, &SI);
4729 "Non-atomic store cannot have SynchronizationScope specified", &SI);
4731 visitInstruction(SI);
4735void Verifier::verifySwiftErrorCall(CallBase &
Call,
4736 const Value *SwiftErrorVal) {
4738 if (
I.value() == SwiftErrorVal) {
4740 "swifterror value when used in a callsite should be marked "
4741 "with swifterror attribute",
4742 SwiftErrorVal,
Call);
4747void Verifier::verifySwiftErrorValue(
const Value *SwiftErrorVal) {
4750 for (
const User *U : SwiftErrorVal->
users()) {
4753 "swifterror value can only be loaded and stored from, or "
4754 "as a swifterror argument!",
4758 Check(StoreI->getOperand(1) == SwiftErrorVal,
4759 "swifterror value should be the second operand when used "
4763 verifySwiftErrorCall(*
const_cast<CallBase *
>(
Call), SwiftErrorVal);
4767void Verifier::visitAllocaInst(AllocaInst &AI) {
4770 Check(!MD->getZExtValue(),
4771 "Non-logical alloca disallowed for this module.");
4774 SmallPtrSet<Type*, 4> Visited;
4775 Check(Ty->
isSized(&Visited),
"Cannot allocate unsized type", &AI);
4779 "Alloca has illegal target extension type", &AI);
4781 "Alloca array size must have integer type", &AI);
4783 Check(
A->value() <= Value::MaximumAlignment,
4784 "huge alignment values are unsupported", &AI);
4790 "swifterror alloca must not be array allocation", &AI);
4791 verifySwiftErrorValue(&AI);
4794 if (
TT.isAMDGPU()) {
4796 "alloca on amdgpu must be in addrspace(5)", &AI);
4799 visitInstruction(AI);
4802void Verifier::visitAtomicCmpXchgInst(AtomicCmpXchgInst &CXI) {
4805 "cmpxchg operand must have integer or pointer type", ElTy, &CXI);
4806 checkAtomicMemAccessSize(ElTy, &CXI);
4807 visitInstruction(CXI);
4810void Verifier::visitAtomicRMWInst(AtomicRMWInst &RMWI) {
4812 "atomicrmw instructions cannot be unordered.", &RMWI);
4815 Type *ScalarTy = ElTy;
4818 Check(VecTy,
"atomicrmw elementwise operand must have fixed vector type!",
4821 ScalarTy = VecTy->getElementType();
4828 " operand must have integer or floating point type!",
4833 " operand must have floating-point or fixed vector of "
4840 " operand must have integer type!",
4843 checkAtomicMemAccessSize(ElTy, &RMWI);
4845 "Invalid binary operation!", &RMWI);
4846 visitInstruction(RMWI);
4849void Verifier::visitFenceInst(FenceInst &FI) {
4851 Check(Ordering == AtomicOrdering::Acquire ||
4852 Ordering == AtomicOrdering::Release ||
4853 Ordering == AtomicOrdering::AcquireRelease ||
4854 Ordering == AtomicOrdering::SequentiallyConsistent,
4855 "fence instructions may only have acquire, release, acq_rel, or "
4856 "seq_cst ordering.",
4858 visitInstruction(FI);
4861void Verifier::visitExtractValueInst(ExtractValueInst &EVI) {
4864 "Invalid ExtractValueInst operands!", &EVI);
4866 visitInstruction(EVI);
4869void Verifier::visitInsertValueInst(InsertValueInst &IVI) {
4873 "Invalid InsertValueInst operands!", &IVI);
4875 visitInstruction(IVI);
4880 return FPI->getParentPad();
4885void Verifier::visitEHPadPredecessors(Instruction &
I) {
4891 Check(BB != &
F->getEntryBlock(),
"EH pad cannot be in entry block.", &
I);
4899 Check(
II &&
II->getUnwindDest() == BB &&
II->getNormalDest() != BB,
4900 "Block containing LandingPadInst must be jumped to "
4901 "only by the unwind edge of an invoke.",
4909 "Block containg CatchPadInst must be jumped to "
4910 "only by its catchswitch.",
4912 Check(BB != CPI->getCatchSwitch()->getUnwindDest(),
4913 "Catchswitch cannot unwind to one of its catchpads",
4914 CPI->getCatchSwitch(), CPI);
4926 Check(
II->getUnwindDest() == BB &&
II->getNormalDest() != BB,
4927 "EH pad must be jumped to via an unwind edge", ToPad,
II);
4930 if (CalledFn && CalledFn->isIntrinsic() &&
II->doesNotThrow() &&
4934 FromPad = Bundle->Inputs[0];
4938 FromPad = CRI->getOperand(0);
4939 Check(FromPad != ToPadParent,
"A cleanupret must exit its cleanup", CRI);
4943 Check(
false,
"EH pad must be jumped to via an unwind edge", ToPad, TI);
4947 SmallPtrSet<Value *, 8> Seen;
4949 Check(FromPad != ToPad,
4950 "EH pad cannot handle exceptions raised within it", FromPad, TI);
4951 if (FromPad == ToPadParent) {
4956 "A single unwind edge may only enter one EH pad", TI);
4957 Check(Seen.
insert(FromPad).second,
"EH pad jumps through a cycle of pads",
4963 "Parent pad must be catchpad/cleanuppad/catchswitch", TI);
4968void Verifier::visitLandingPadInst(LandingPadInst &LPI) {
4972 "LandingPadInst needs at least one clause or to be a cleanup.", &LPI);
4974 visitEHPadPredecessors(LPI);
4976 if (!LandingPadResultTy)
4977 LandingPadResultTy = LPI.
getType();
4980 "The landingpad instruction should have a consistent result type "
4981 "inside a function.",
4985 Check(
F->hasPersonalityFn(),
4986 "LandingPadInst needs to be in a function with a personality.", &LPI);
4991 "LandingPadInst not the first non-PHI instruction in the block.", &LPI);
4997 "Catch operand does not have pointer type!", &LPI);
4999 Check(LPI.
isFilter(i),
"Clause is neither catch nor filter!", &LPI);
5001 "Filter operand is not an array of constants!", &LPI);
5005 visitInstruction(LPI);
5008void Verifier::visitResumeInst(ResumeInst &RI) {
5010 "ResumeInst needs to be in a function with a personality.", &RI);
5012 if (!LandingPadResultTy)
5016 "The resume instruction should have a consistent result type "
5017 "inside a function.",
5020 visitTerminator(RI);
5023void Verifier::visitCatchPadInst(CatchPadInst &CPI) {
5027 Check(
F->hasPersonalityFn(),
5028 "CatchPadInst needs to be in a function with a personality.", &CPI);
5031 "CatchPadInst needs to be directly nested in a CatchSwitchInst.",
5037 "CatchPadInst not the first non-PHI instruction in the block.", &CPI);
5042 return isa<Constant>(V) || isa<AllocaInst>(V);
5044 "Argument operand must be alloca or constant.", &CPI);
5046 visitEHPadPredecessors(CPI);
5047 visitFuncletPadInst(CPI);
5050void Verifier::visitCatchReturnInst(CatchReturnInst &CatchReturn) {
5052 "CatchReturnInst needs to be provided a CatchPad", &CatchReturn,
5055 visitTerminator(CatchReturn);
5058void Verifier::visitCleanupPadInst(CleanupPadInst &CPI) {
5062 Check(
F->hasPersonalityFn(),
5063 "CleanupPadInst needs to be in a function with a personality.", &CPI);
5068 "CleanupPadInst not the first non-PHI instruction in the block.", &CPI);
5072 "CleanupPadInst has an invalid parent.", &CPI);
5074 visitEHPadPredecessors(CPI);
5075 visitFuncletPadInst(CPI);
5078void Verifier::visitFuncletPadInst(FuncletPadInst &FPI) {
5079 User *FirstUser =
nullptr;
5080 Value *FirstUnwindPad =
nullptr;
5082 SmallPtrSet<FuncletPadInst *, 8> Seen;
5084 while (!Worklist.empty()) {
5085 FuncletPadInst *CurrentPad = Worklist.pop_back_val();
5087 "FuncletPadInst must not be nested within itself", CurrentPad);
5088 Value *UnresolvedAncestorPad =
nullptr;
5089 for (User *U : CurrentPad->
users()) {
5092 UnwindDest = CRI->getUnwindDest();
5098 if (CSI->unwindsToCaller())
5100 UnwindDest = CSI->getUnwindDest();
5102 UnwindDest =
II->getUnwindDest();
5112 Worklist.push_back(CPI);
5127 if (UnwindParent == CurrentPad)
5133 Value *ExitedPad = CurrentPad;
5136 if (ExitedPad == &FPI) {
5141 UnresolvedAncestorPad = &FPI;
5145 if (ExitedParent == UnwindParent) {
5149 UnresolvedAncestorPad = ExitedParent;
5152 ExitedPad = ExitedParent;
5158 UnresolvedAncestorPad = &FPI;
5165 Check(UnwindPad == FirstUnwindPad,
5166 "Unwind edges out of a funclet "
5167 "pad must have the same unwind "
5169 &FPI, U, FirstUser);
5172 FirstUnwindPad = UnwindPad;
5181 if (CurrentPad != &FPI)
5184 if (UnresolvedAncestorPad) {
5185 if (CurrentPad == UnresolvedAncestorPad) {
5189 assert(CurrentPad == &FPI);
5197 Value *ResolvedPad = CurrentPad;
5198 while (!Worklist.empty()) {
5199 Value *UnclePad = Worklist.back();
5203 while (ResolvedPad != AncestorPad) {
5205 if (ResolvedParent == UnresolvedAncestorPad) {
5208 ResolvedPad = ResolvedParent;
5212 if (ResolvedPad != AncestorPad)
5215 Worklist.pop_back();
5220 if (FirstUnwindPad) {
5222 BasicBlock *SwitchUnwindDest = CatchSwitch->getUnwindDest();
5223 Value *SwitchUnwindPad;
5224 if (SwitchUnwindDest)
5228 Check(SwitchUnwindPad == FirstUnwindPad,
5229 "Unwind edges out of a catch must have the same unwind dest as "
5230 "the parent catchswitch",
5231 &FPI, FirstUser, CatchSwitch);
5235 visitInstruction(FPI);
5238void Verifier::visitCatchSwitchInst(CatchSwitchInst &CatchSwitch) {
5242 Check(
F->hasPersonalityFn(),
5243 "CatchSwitchInst needs to be in a function with a personality.",
5249 "CatchSwitchInst not the first non-PHI instruction in the block.",
5254 "CatchSwitchInst has an invalid parent.", ParentPad);
5259 "CatchSwitchInst must unwind to an EH block which is not a "
5265 SiblingFuncletInfo[&CatchSwitch] = &CatchSwitch;
5269 "CatchSwitchInst cannot have empty handler list", &CatchSwitch);
5271 for (BasicBlock *Handler : CatchSwitch.
handlers()) {
5273 "CatchSwitchInst handlers must be catchpads", &CatchSwitch, Handler);
5276 visitEHPadPredecessors(CatchSwitch);
5277 visitTerminator(CatchSwitch);
5280void Verifier::visitCleanupReturnInst(CleanupReturnInst &CRI) {
5282 "CleanupReturnInst needs to be provided a CleanupPad", &CRI,
5288 "CleanupReturnInst must unwind to an EH block which is not a "
5293 visitTerminator(CRI);
5296void Verifier::verifyDominatesUse(Instruction &
I,
unsigned i) {
5302 if (
II->getNormalDest() ==
II->getUnwindDest())
5316 const Use &
U =
I.getOperandUse(i);
5317 Check(DT.dominates(
Op, U),
"Instruction does not dominate all uses!",
Op, &
I);
5320void Verifier::visitDereferenceableMetadata(Instruction&
I, MDNode* MD) {
5321 Check(
I.getType()->isPointerTy(),
5322 "dereferenceable, dereferenceable_or_null "
5323 "apply only to pointer types",
5326 "dereferenceable, dereferenceable_or_null apply only to load"
5327 " and inttoptr instructions, use attributes for calls or invokes",
5330 "dereferenceable, dereferenceable_or_null "
5331 "take one operand!",
5336 "dereferenceable_or_null metadata value must be an i64!",
5340void Verifier::visitNofreeMetadata(Instruction &
I, MDNode *MD) {
5341 Check(
I.getType()->isPointerTy(),
"nofree applies only to pointer types", &
I);
5347void Verifier::visitProfMetadata(Instruction &
I, MDNode *MD) {
5348 auto GetBranchingTerminatorNumOperands = [&]() {
5349 unsigned ExpectedNumOperands = 0;
5353 ExpectedNumOperands =
SI->getNumSuccessors();
5355 ExpectedNumOperands = 1;
5357 ExpectedNumOperands = IBI->getNumDestinations();
5359 ExpectedNumOperands = 2;
5362 return ExpectedNumOperands;
5365 "!prof annotations should have at least 1 operand", MD);
5367 Check(MD->
getOperand(0) !=
nullptr,
"first operand should not be null", MD);
5369 "expected string with name of the !prof annotation", MD);
5375 "'unknown' !prof should only appear on instructions on which "
5376 "'branch_weights' would",
5378 verifyUnknownProfileMetadata(MD);
5383 "!prof annotations should have no less than 2 operands", MD);
5389 Check(NumBranchWeights == 1 || NumBranchWeights == 2,
5390 "Wrong number of InvokeInst branch_weights operands", MD);
5392 const unsigned ExpectedNumOperands = GetBranchingTerminatorNumOperands();
5393 if (ExpectedNumOperands == 0)
5394 CheckFailed(
"!prof branch_weights are not allowed for this instruction",
5397 Check(NumBranchWeights == ExpectedNumOperands,
"Wrong number of operands",
5403 Check(MDO,
"second operand should not be null", MD);
5405 "!prof brunch_weights operand is not a const int");
5410 Check(KindInt,
"VP !prof missing kind argument", MD);
5413 Check(Kind >= InstrProfValueKind::IPVK_First &&
5414 Kind <= InstrProfValueKind::IPVK_Last,
5415 "Invalid VP !prof kind", MD);
5417 "VP !prof should have an even number "
5418 "of arguments after 'VP'",
5420 if (Kind == InstrProfValueKind::IPVK_IndirectCallTarget ||
5421 Kind == InstrProfValueKind::IPVK_MemOPSize)
5423 "VP !prof indirect call or memop size expected to be applied to "
5424 "CallBase instructions only",
5427 DenseSet<uint64_t> ProfileValues;
5429 ConstantInt *ProfileValue =
5431 Check(ProfileValue,
"VP !prof value operand is not a const int", MD);
5432 uint64_t ProfileValueInt = ProfileValue->
getZExtValue();
5433 auto [ValueIt,
Inserted] = ProfileValues.
insert(ProfileValueInt);
5434 Check(Inserted,
"VP !prof should not have duplicate profile values", MD);
5437 CheckFailed(
"expected either branch_weights or VP profile name", MD);
5441void Verifier::visitDIAssignIDMetadata(Instruction &
I, MDNode *MD) {
5442 assert(
I.hasMetadata(LLVMContext::MD_DIAssignID));
5447 bool ExpectedInstTy =
5449 CheckDI(ExpectedInstTy,
"!DIAssignID attached to unexpected instruction kind",
5454 for (
auto *User : AsValue->users()) {
5456 "!DIAssignID should only be used by llvm.dbg.assign intrinsics",
5460 CheckDI(DAI->getFunction() ==
I.getFunction(),
5461 "dbg.assign not in same function as inst", DAI, &
I);
5464 for (DbgVariableRecord *DVR :
5467 "!DIAssignID should only be used by Assign DVRs.", MD, DVR);
5468 CheckDI(DVR->getFunction() ==
I.getFunction(),
5469 "DVRAssign not in same function as inst", DVR, &
I);
5473void Verifier::visitMMRAMetadata(Instruction &
I, MDNode *MD) {
5475 "!mmra metadata attached to unexpected instruction kind",
I, MD);
5486 for (
const MDOperand &MDOp : MD->
operands())
5488 "!mmra metadata tuple operand is not an MMRA tag",
I, MDOp.get());
5491void Verifier::visitCallStackMetadata(MDNode *MD) {
5495 "call stack metadata should have at least 1 operand", MD);
5499 "call stack metadata operand should be constant integer",
Op);
5502void Verifier::visitMemProfMetadata(Instruction &
I, MDNode *MD) {
5505 "!memprof annotations should have at least 1 metadata operand "
5510 for (
auto &MIBOp : MD->
operands()) {
5516 "Each !memprof MemInfoBlock should have at least 2 operands", MIB);
5520 "!memprof MemInfoBlock first operand should not be null", MIB);
5522 "!memprof MemInfoBlock first operand should be an MDNode", MIB);
5524 visitCallStackMetadata(StackMD);
5528 "!memprof MemInfoBlock second operand should be an MDString", MIB);
5533 Check(OpNode,
"Not all !memprof MemInfoBlock operands 2 to N are MDNode",
5536 "Not all !memprof MemInfoBlock operands 2 to N are MDNode with 2 "
5541 [](
const MDOperand &
Op) {
5542 return mdconst::hasa<ConstantInt>(Op);
5544 "Not all !memprof MemInfoBlock operands 2 to N are MDNode with "
5545 "ConstantInt operands",
5551void Verifier::visitCallsiteMetadata(Instruction &
I, MDNode *MD) {
5555 visitCallStackMetadata(MD);
5564void Verifier::visitCalleeTypeMetadata(Instruction &
I, MDNode *MD) {
5569 "The callee_type metadata must be a list of type metadata nodes",
Op);
5571 Check(TypeMD->getNumOperands() == 2,
5572 "Well-formed generalized type metadata must contain exactly two "
5577 "The first operand of type metadata for functions must be zero",
Op);
5578 Check(TypeMD->hasGeneralizedMDString(),
5579 "Only generalized type metadata can be part of the callee_type "
5585void Verifier::visitAnnotationMetadata(MDNode *Annotation) {
5588 "annotation must have at least one operand");
5590 bool TupleOfStrings =
5596 "operands must be a string or a tuple of strings");
5600void Verifier::visitAliasScopeMetadata(
const MDNode *MD) {
5605 "first scope operand must be self-referential or string", MD);
5608 "third scope operand must be string (if used)", MD);
5611 Check(
Domain !=
nullptr,
"second scope operand must be MDNode", MD);
5613 unsigned NumDomainOps =
Domain->getNumOperands();
5614 Check(NumDomainOps >= 1 && NumDomainOps <= 2,
5615 "domain must have one or two operands",
Domain);
5618 "first domain operand must be self-referential or string",
Domain);
5619 if (NumDomainOps == 2)
5621 "second domain operand must be string (if used)",
Domain);
5624void Verifier::visitAliasScopeListMetadata(
const MDNode *MD) {
5627 Check(OpMD !=
nullptr,
"scope list must consist of MDNodes", MD);
5628 visitAliasScopeMetadata(OpMD);
5632void Verifier::visitAccessGroupMetadata(
const MDNode *MD) {
5633 auto IsValidAccessScope = [](
const MDNode *MD) {
5638 if (IsValidAccessScope(MD))
5644 Check(OpMD !=
nullptr,
"Access scope list must consist of MDNodes", MD);
5645 Check(IsValidAccessScope(OpMD),
5646 "Access scope list contains invalid access scope", MD);
5650void Verifier::visitCapturesMetadata(Instruction &
I,
const MDNode *Captures) {
5651 static const char *ValidArgs[] = {
"address_is_null",
"address",
5652 "read_provenance",
"provenance"};
5655 Check(SI,
"!captures metadata can only be applied to store instructions", &
I);
5656 Check(
SI->getValueOperand()->getType()->isPointerTy(),
5657 "!captures metadata can only be applied to store with value operand of "
5665 Check(Str,
"!captures metadata must be a list of strings", &
I);
5667 "invalid entry in !captures metadata", &
I, Str);
5671void Verifier::visitAllocTokenMetadata(Instruction &
I, MDNode *MD) {
5676 "expected integer constant", MD);
5679void Verifier::visitInlineHistoryMetadata(Instruction &
I, MDNode *MD) {
5688 ->stripPointerCastsAndAliases()),
5689 "!inline_history operands must be functions or null", MD);
5693void Verifier::visitMemCacheHintMetadata(Instruction &
I, MDNode *MD) {
5694 Check(
I.mayReadOrWriteMemory(),
5695 "!mem.cache_hint is only valid on memory operations", &
I);
5698 "!mem.cache_hint must have even number of operands "
5699 "(operand_no, hint_node pairs)",
5705 "!mem.cache_hint is not supported on non-intrinsic calls", &
I);
5707 unsigned NumOperands = CB ? CB->arg_size() :
I.getNumOperands();
5709 SmallDenseSet<unsigned, 4> SeenOperandNos;
5710 std::optional<uint64_t> LastOperandNo;
5716 "!mem.cache_hint must alternate between i32 operand numbers and "
5717 "metadata hint nodes",
5720 Check(OpNoCI->getValue().isNonNegative(),
5721 "!mem.cache_hint operand number must be non-negative", MD);
5723 uint64_t OperandNo = OpNoCI->getZExtValue();
5724 Check(OperandNo < NumOperands,
5725 "!mem.cache_hint operand number is out of range", &
I);
5728 CB ? CB->getArgOperand(OperandNo) :
I.getOperand(OperandNo);
5730 "!mem.cache_hint operand number must refer to a pointer operand", &
I);
5733 Check(Inserted,
"!mem.cache_hint contains duplicate operand number", MD);
5735 Check(!Inserted || !LastOperandNo || OperandNo > *LastOperandNo,
5736 "!mem.cache_hint operand numbers must be in increasing order", MD);
5737 LastOperandNo = OperandNo;
5741 "!mem.cache_hint must alternate between i32 operand numbers and "
5742 "metadata hint nodes",
5746 "!mem.cache_hint hint node must have even number of operands "
5747 "(key-value pairs)",
5750 StringSet<> SeenKeys;
5751 for (
unsigned K = 0;
K + 1 <
Node->getNumOperands();
K += 2) {
5753 Check(
Key,
"!mem.cache_hint key must be a string", Node);
5755 StringRef KeyStr =
Key->getString();
5757 "!mem.cache_hint hint node contains duplicate key", Node);
5762 "!mem.cache_hint value must be a string or integer", Node);
5769void Verifier::visitInstruction(Instruction &
I) {
5771 Check(BB,
"Instruction not embedded in basic block!", &
I);
5774 for (User *U :
I.users()) {
5775 Check(U != (User *)&
I || !DT.isReachableFromEntry(BB),
5776 "Only PHI nodes may reference their own value!", &
I);
5781 Check(!
I.getType()->isVoidTy() || !
I.hasName(),
5782 "Instruction has a name, but provides a void value!", &
I);
5786 Check(
I.getType()->isVoidTy() ||
I.getType()->isFirstClassType(),
5787 "Instruction returns a non-scalar type!", &
I);
5792 "Invalid use of metadata!", &
I);
5797 for (Use &U :
I.uses()) {
5800 "Instruction referencing"
5801 " instruction not embedded in a basic block!",
5804 CheckFailed(
"Use of instruction is not an instruction!", U);
5813 for (
unsigned i = 0, e =
I.getNumOperands(); i != e; ++i) {
5814 Check(
I.getOperand(i) !=
nullptr,
"Instruction has null operand!", &
I);
5818 if (!
I.getOperand(i)->getType()->isFirstClassType()) {
5819 Check(
false,
"Instruction operands must be first-class values!", &
I);
5825 auto IsAttachedCallOperand = [](
Function *
F,
const CallBase *CBI,
5827 return CBI && CBI->isOperandBundleOfType(
5835 Check((!
F->isIntrinsic() ||
5836 (CBI && &CBI->getCalledOperandUse() == &
I.getOperandUse(i)) ||
5837 IsAttachedCallOperand(
F, CBI, i)),
5838 "Cannot take the address of an intrinsic!", &
I);
5840 F->getIntrinsicID() == Intrinsic::donothing ||
5841 F->getIntrinsicID() == Intrinsic::seh_try_begin ||
5842 F->getIntrinsicID() == Intrinsic::seh_try_end ||
5843 F->getIntrinsicID() == Intrinsic::seh_scope_begin ||
5844 F->getIntrinsicID() == Intrinsic::seh_scope_end ||
5845 F->getIntrinsicID() == Intrinsic::coro_resume ||
5846 F->getIntrinsicID() == Intrinsic::coro_destroy ||
5847 F->getIntrinsicID() == Intrinsic::coro_await_suspend_void ||
5848 F->getIntrinsicID() == Intrinsic::coro_await_suspend_bool ||
5849 F->getIntrinsicID() == Intrinsic::coro_await_suspend_handle ||
5850 F->getIntrinsicID() ==
5851 Intrinsic::experimental_patchpoint_void ||
5852 F->getIntrinsicID() == Intrinsic::experimental_patchpoint ||
5853 F->getIntrinsicID() == Intrinsic::fake_use ||
5854 F->getIntrinsicID() == Intrinsic::experimental_gc_statepoint ||
5855 F->getIntrinsicID() == Intrinsic::wasm_throw ||
5856 F->getIntrinsicID() == Intrinsic::wasm_rethrow ||
5857 IsAttachedCallOperand(
F, CBI, i),
5858 "Cannot invoke an intrinsic other than donothing, patchpoint, "
5859 "statepoint, coro_resume, coro_destroy, clang.arc.attachedcall or "
5862 Check(
F->getParent() == &M,
"Referencing function in another module!", &
I,
5863 &M,
F,
F->getParent());
5866 "Referring to a basic block in another function!", &
I);
5869 "Referring to an argument in another function!", &
I);
5871 Check(GV->
getParent() == &M,
"Referencing global in another module!", &
I,
5875 "Referring to an instruction in another function!", &
I);
5876 verifyDominatesUse(
I, i);
5878 Check(CBI && &CBI->getCalledOperandUse() == &
I.getOperandUse(i),
5879 "Cannot take the address of an inline asm!", &
I);
5881 visitConstantExprsRecursively(
C);
5885 if (MDNode *MD =
I.getMetadata(LLVMContext::MD_fpmath)) {
5887 "fpmath requires a floating point result!", &
I);
5889 if (ConstantFP *CFP0 =
5891 const APFloat &Accuracy = CFP0->getValueAPF();
5893 "fpmath accuracy must have float type", &
I);
5895 "fpmath accuracy not a positive number!", &
I);
5897 Check(
false,
"invalid fpmath accuracy!", &
I);
5901 if (MDNode *
Range =
I.getMetadata(LLVMContext::MD_range)) {
5903 "Ranges are only for loads, calls and invokes!", &
I);
5904 visitRangeMetadata(
I,
Range,
I.getType());
5907 if (MDNode *MD =
I.getMetadata(LLVMContext::MD_nofpclass)) {
5909 visitNoFPClassMetadata(
I, MD,
I.getType());
5912 if (MDNode *
Range =
I.getMetadata(LLVMContext::MD_noalias_addrspace)) {
5915 "noalias.addrspace are only for memory operations!", &
I);
5916 visitNoaliasAddrspaceMetadata(
I,
Range,
I.getType());
5919 if (
I.hasMetadata(LLVMContext::MD_invariant_group)) {
5921 "invariant.group metadata is only for loads and stores", &
I);
5924 if (MDNode *MD =
I.getMetadata(LLVMContext::MD_nonnull)) {
5925 Check(
I.getType()->isPointerTy(),
"nonnull applies only to pointer types",
5928 "nonnull applies only to load instructions, use attributes"
5929 " for calls or invokes",
5934 if (MDNode *MD =
I.getMetadata(LLVMContext::MD_dereferenceable))
5935 visitDereferenceableMetadata(
I, MD);
5937 if (MDNode *MD =
I.getMetadata(LLVMContext::MD_dereferenceable_or_null))
5938 visitDereferenceableMetadata(
I, MD);
5940 if (MDNode *MD =
I.getMetadata(LLVMContext::MD_nofree))
5941 visitNofreeMetadata(
I, MD);
5943 if (MDNode *TBAA =
I.getMetadata(LLVMContext::MD_tbaa))
5946 if (MDNode *MD =
I.getMetadata(LLVMContext::MD_noalias))
5947 visitAliasScopeListMetadata(MD);
5948 if (MDNode *MD =
I.getMetadata(LLVMContext::MD_alias_scope))
5949 visitAliasScopeListMetadata(MD);
5951 if (MDNode *MD =
I.getMetadata(LLVMContext::MD_access_group))
5952 visitAccessGroupMetadata(MD);
5954 if (MDNode *AlignMD =
I.getMetadata(LLVMContext::MD_align)) {
5955 Check(
I.getType()->isPointerTy(),
"align applies only to pointer types",
5958 "align applies only to load instructions, "
5959 "use attributes for calls or invokes",
5961 Check(AlignMD->getNumOperands() == 1,
"align takes one operand!", &
I);
5964 "align metadata value must be an i64!", &
I);
5968 Check(Align <= Value::MaximumAlignment,
5969 "alignment is larger that implementation defined limit", &
I);
5972 if (MDNode *MD =
I.getMetadata(LLVMContext::MD_prof))
5973 visitProfMetadata(
I, MD);
5975 if (MDNode *MD =
I.getMetadata(LLVMContext::MD_memprof))
5976 visitMemProfMetadata(
I, MD);
5978 if (MDNode *MD =
I.getMetadata(LLVMContext::MD_callsite))
5979 visitCallsiteMetadata(
I, MD);
5981 if (MDNode *MD =
I.getMetadata(LLVMContext::MD_callee_type))
5982 visitCalleeTypeMetadata(
I, MD);
5984 if (MDNode *MD =
I.getMetadata(LLVMContext::MD_DIAssignID))
5985 visitDIAssignIDMetadata(
I, MD);
5987 if (MDNode *MMRA =
I.getMetadata(LLVMContext::MD_mmra))
5988 visitMMRAMetadata(
I, MMRA);
5990 if (MDNode *Annotation =
I.getMetadata(LLVMContext::MD_annotation))
5991 visitAnnotationMetadata(Annotation);
5993 if (MDNode *Captures =
I.getMetadata(LLVMContext::MD_captures))
5994 visitCapturesMetadata(
I, Captures);
5996 if (MDNode *MD =
I.getMetadata(LLVMContext::MD_alloc_token))
5997 visitAllocTokenMetadata(
I, MD);
5999 if (MDNode *MD =
I.getMetadata(LLVMContext::MD_inline_history))
6000 visitInlineHistoryMetadata(
I, MD);
6002 if (MDNode *MD =
I.getMetadata(LLVMContext::MD_mem_cache_hint))
6003 visitMemCacheHintMetadata(
I, MD);
6005 if (MDNode *
N =
I.getDebugLoc().getAsMDNode()) {
6007 visitMDNode(*
N, AreDebugLocsAllowed::Yes);
6010 if (
DL->getAtomGroup()) {
6011 CheckDI(
DL->getScope()->getSubprogram()->getKeyInstructionsEnabled(),
6012 "DbgLoc uses atomGroup but DISubprogram doesn't have Key "
6013 "Instructions enabled",
6014 DL,
DL->getScope()->getSubprogram());
6020 I.getAllMetadata(MDs);
6021 for (
auto Attachment : MDs) {
6022 unsigned Kind = Attachment.first;
6024 (
Kind == LLVMContext::MD_dbg ||
Kind == LLVMContext::MD_loop)
6025 ? AreDebugLocsAllowed::Yes
6026 : AreDebugLocsAllowed::
No;
6027 visitMDNode(*Attachment.second, AllowLocs);
6045 raw_string_ostream ErrOS(ErrMsg);
6048 Check(IsValid, ErrMsg, IF);
6054 const std::string ExpectedName =
6057 "Intrinsic name not mangled correctly for type arguments! "
6069 "const x86_amx is not allowed in argument!");
6075 case Intrinsic::assume: {
6079 "assume with operand bundles must have i1 true condition",
Call);
6085 auto GetTypeAt = [&](
unsigned Index) {
6086 return OBU.Inputs[
Index]->getType();
6091 CheckFailed(
"tags must be valid attribute names",
Call);
6093 case BundleAttr::Align:
6094 Check(OBU.Inputs.size() >= 2 && OBU.Inputs.size() <= 3,
6095 "alignment assumptions should have 2 or 3 arguments",
Call);
6098 Check(GetTypeAt(1)->isIntegerTy() &&
6099 GetTypeAt(1)->getIntegerBitWidth() <= 64,
6100 "second argument should be an integer with a maximum width of 64 "
6103 Check(OBU.Inputs.size() < 3 ||
6104 GetTypeAt(2)->isIntegerTy() &&
6105 GetTypeAt(2)->getIntegerBitWidth() <= 64,
6106 "third argument should be an integer with a maximum width of 64 "
6110 case BundleAttr::Cold:
6111 Check(OBU.Inputs.size() == 0,
6112 "cold assumptions should have no arguments",
Call);
6114 case BundleAttr::Dereferenceable:
6115 case BundleAttr::DereferenceableOrNull:
6116 Check(OBU.Inputs.size() == 2,
6117 "dereferenceable assumptions should have 2 arguments",
Call);
6120 Check(GetTypeAt(1)->isIntegerTy() &&
6121 GetTypeAt(1)->getIntegerBitWidth() <= 64,
6122 "second argument should be an integer with a maximum width of 64 "
6126 case BundleAttr::Ignore:
6128 case BundleAttr::NonNull:
6129 Check(OBU.Inputs.size() == 1,
6130 "nonnull assumptions should have 1 argument",
Call);
6134 case BundleAttr::NoUndef:
6135 Check(OBU.Inputs.size() == 1,
6136 "noundef assumptions should have 1 argument",
Call);
6138 case BundleAttr::SeparateStorage:
6139 Check(OBU.Inputs.size() == 2,
6140 "separate_storage assumptions should have 2 arguments",
Call);
6142 "arguments to separate_storage assumptions should be pointers",
6149 case Intrinsic::ucmp:
6150 case Intrinsic::scmp: {
6155 "result type must be at least 2 bits wide",
Call);
6157 bool IsDestTypeVector = DestTy->
isVectorTy();
6159 "ucmp/scmp argument and result types must both be either vector or "
6162 if (IsDestTypeVector) {
6165 Check(SrcVecLen == DestVecLen,
6166 "return type and arguments must have the same number of "
6172 case Intrinsic::coro_begin:
6173 case Intrinsic::coro_begin_custom_abi:
6175 "id argument of llvm.coro.begin must refer to coro.id");
6177 case Intrinsic::coro_id: {
6179 "align argument only accepts constants");
6182 "promise argument must refer to an alloca");
6187 "coro argument must refer to a function");
6191 if (BeforeCoroSplit)
6194 Check(!BeforeCoroEarly,
"cannot run CoroSplit before CoroEarly");
6197 "info argument of llvm.coro.id must refer to an initialized "
6201 "info argument of llvm.coro.id must refer to either a struct or "
6205 case Intrinsic::is_fpclass: {
6208 "unsupported bits for llvm.is.fpclass test mask");
6211 case Intrinsic::fptrunc_round: {
6216 MD = MAV->getMetadata();
6218 Check(MD !=
nullptr,
"missing rounding mode argument",
Call);
6221 (
"invalid value for llvm.fptrunc.round metadata operand"
6222 " (the operand should be a string)"),
6225 std::optional<RoundingMode> RoundMode =
6227 Check(RoundMode && *RoundMode != RoundingMode::Dynamic,
6228 "unsupported rounding mode argument",
Call);
6231 case Intrinsic::convert_to_arbitrary_fp: {
6239 "if floating-point operand is a vector, integer operand must also "
6242 Check(ValueVecTy->getElementCount() == IntVecTy->getElementCount(),
6243 "floating-point and integer vector operands must have the same "
6250 Check(InterpMAV,
"missing interpretation metadata operand",
Call);
6252 Check(InterpStr,
"interpretation metadata operand must be a string",
Call);
6253 StringRef Interp = InterpStr->getString();
6255 Check(!Interp.
empty(),
"interpretation metadata string must not be empty",
6260 "unsupported interpretation metadata string",
Call);
6264 Check(RoundingMAV,
"missing rounding mode metadata operand",
Call);
6266 Check(RoundingStr,
"rounding mode metadata operand must be a string",
Call);
6268 std::optional<RoundingMode>
RM =
6270 Check(RM && *RM != RoundingMode::Dynamic,
6271 "unsupported rounding mode argument",
Call);
6274 case Intrinsic::convert_from_arbitrary_fp: {
6282 "if floating-point operand is a vector, integer operand must also "
6285 Check(ValueVecTy->getElementCount() == IntVecTy->getElementCount(),
6286 "floating-point and integer vector operands must have the same "
6293 Check(InterpMAV,
"missing interpretation metadata operand",
Call);
6295 Check(InterpStr,
"interpretation metadata operand must be a string",
Call);
6296 StringRef Interp = InterpStr->getString();
6298 Check(!Interp.
empty(),
"interpretation metadata string must not be empty",
6303 "unsupported interpretation metadata string",
Call);
6306#define BEGIN_REGISTER_VP_INTRINSIC(VPID, ...) case Intrinsic::VPID:
6307#include "llvm/IR/VPIntrinsics.def"
6308#undef BEGIN_REGISTER_VP_INTRINSIC
6311#define INSTRUCTION(NAME, NARGS, ROUND_MODE, INTRINSIC) \
6312 case Intrinsic::INTRINSIC:
6313#include "llvm/IR/ConstrainedOps.def"
6317 case Intrinsic::dbg_declare:
6318 case Intrinsic::dbg_value:
6319 case Intrinsic::dbg_assign:
6320 case Intrinsic::dbg_label:
6327 case Intrinsic::memcpy:
6328 case Intrinsic::memcpy_inline:
6329 case Intrinsic::memmove:
6330 case Intrinsic::memset:
6331 case Intrinsic::memset_inline:
6333 case Intrinsic::experimental_memset_pattern: {
6335 Check(Memset->getValue()->getType()->isSized(),
6336 "unsized types cannot be used as memset patterns",
Call);
6339 case Intrinsic::memcpy_element_unordered_atomic:
6340 case Intrinsic::memmove_element_unordered_atomic:
6341 case Intrinsic::memset_element_unordered_atomic: {
6344 ConstantInt *ElementSizeCI =
6346 const APInt &ElementSizeVal = ElementSizeCI->
getValue();
6348 "element size of the element-wise atomic memory intrinsic "
6349 "must be a power of 2",
6352 auto IsValidAlignment = [&](MaybeAlign Alignment) {
6353 return Alignment && ElementSizeVal.
ule(Alignment->value());
6355 Check(IsValidAlignment(AMI->getDestAlign()),
6356 "incorrect alignment of the destination argument",
Call);
6358 Check(IsValidAlignment(AMT->getSourceAlign()),
6359 "incorrect alignment of the source argument",
Call);
6363 case Intrinsic::call_preallocated_setup: {
6365 bool FoundCall =
false;
6368 Check(UseCall !=
nullptr,
6369 "Uses of llvm.call.preallocated.setup must be calls");
6371 if (IID == Intrinsic::call_preallocated_arg) {
6373 Check(AllocArgIndex !=
nullptr,
6374 "llvm.call.preallocated.alloc arg index must be a constant");
6375 auto AllocArgIndexInt = AllocArgIndex->getValue();
6376 Check(AllocArgIndexInt.sge(0) &&
6377 AllocArgIndexInt.slt(NumArgs->getValue()),
6378 "llvm.call.preallocated.alloc arg index must be between 0 and "
6380 "llvm.call.preallocated.setup's argument count");
6381 }
else if (IID == Intrinsic::call_preallocated_teardown) {
6384 Check(!FoundCall,
"Can have at most one call corresponding to a "
6385 "llvm.call.preallocated.setup");
6387 size_t NumPreallocatedArgs = 0;
6388 for (
unsigned i = 0; i < UseCall->arg_size(); i++) {
6389 if (UseCall->paramHasAttr(i, Attribute::Preallocated)) {
6390 ++NumPreallocatedArgs;
6393 Check(NumPreallocatedArgs != 0,
6394 "cannot use preallocated intrinsics on a call without "
6395 "preallocated arguments");
6396 Check(NumArgs->equalsInt(NumPreallocatedArgs),
6397 "llvm.call.preallocated.setup arg size must be equal to number "
6398 "of preallocated arguments "
6408 auto PreallocatedBundle =
6410 Check(PreallocatedBundle,
6411 "Use of llvm.call.preallocated.setup outside intrinsics "
6412 "must be in \"preallocated\" operand bundle");
6413 Check(PreallocatedBundle->Inputs.front().get() == &
Call,
6414 "preallocated bundle must have token from corresponding "
6415 "llvm.call.preallocated.setup");
6420 case Intrinsic::call_preallocated_arg: {
6423 Token->getIntrinsicID() == Intrinsic::call_preallocated_setup,
6424 "llvm.call.preallocated.arg token argument must be a "
6425 "llvm.call.preallocated.setup");
6427 "llvm.call.preallocated.arg must be called with a \"preallocated\" "
6428 "call site attribute");
6431 case Intrinsic::call_preallocated_teardown: {
6434 Token->getIntrinsicID() == Intrinsic::call_preallocated_setup,
6435 "llvm.call.preallocated.teardown token argument must be a "
6436 "llvm.call.preallocated.setup");
6439 case Intrinsic::gcroot:
6440 case Intrinsic::gcwrite:
6441 case Intrinsic::gcread:
6442 if (
ID == Intrinsic::gcroot) {
6445 Check(AI,
"llvm.gcroot parameter #1 must be an alloca.",
Call);
6447 "llvm.gcroot parameter #2 must be a constant.",
Call);
6450 "llvm.gcroot parameter #1 must either be a pointer alloca, "
6451 "or argument #2 must be a non-null constant.",
6457 "Enclosing function does not use GC.",
Call);
6459 case Intrinsic::init_trampoline:
6461 "llvm.init_trampoline parameter #2 must resolve to a function.",
6464 case Intrinsic::prefetch:
6466 "rw argument to llvm.prefetch must be 0-1",
Call);
6468 "locality argument to llvm.prefetch must be 0-3",
Call);
6470 "cache type argument to llvm.prefetch must be 0-1",
Call);
6472 case Intrinsic::reloc_none: {
6475 "llvm.reloc.none argument must be a metadata string", &
Call);
6478 case Intrinsic::stackprotector:
6480 "llvm.stackprotector parameter #2 must resolve to an alloca.",
Call);
6482 case Intrinsic::localescape: {
6486 Check(!SawFrameEscape,
"multiple calls to llvm.localescape in one function",
6493 "llvm.localescape only accepts static allocas",
Call);
6496 SawFrameEscape =
true;
6499 case Intrinsic::localrecover: {
6503 "llvm.localrecover first "
6504 "argument must be function defined in this module",
6507 auto &
Entry = FrameEscapeInfo[Fn];
6508 Entry.second = unsigned(
6509 std::max(uint64_t(
Entry.second), IdxArg->getLimitedValue(~0U) + 1));
6513 case Intrinsic::experimental_gc_statepoint:
6515 Check(!CI->isInlineAsm(),
6516 "gc.statepoint support for inline assembly unimplemented", CI);
6518 "Enclosing function does not use GC.",
Call);
6520 verifyStatepoint(
Call);
6522 case Intrinsic::experimental_gc_result: {
6524 "Enclosing function does not use GC.",
Call);
6532 Check(StatepointCall && StatepointCall->getIntrinsicID() ==
6533 Intrinsic::experimental_gc_statepoint,
6534 "gc.result operand #1 must be from a statepoint",
Call,
6538 auto *TargetFuncType =
6541 "gc.result result type does not match wrapped callee",
Call);
6544 case Intrinsic::experimental_gc_relocate: {
6548 "gc.relocate must return a pointer or a vector of pointers",
Call);
6553 if (LandingPadInst *LandingPad =
6557 LandingPad->getParent()->getUniquePredecessor();
6561 Check(InvokeBB,
"safepoints should have unique landingpads",
6562 LandingPad->getParent());
6566 "gc relocate should be linked to a statepoint", InvokeBB);
6573 "gc relocate is incorrectly tied to the statepoint",
Call, Token);
6582 "gc.relocate operand #2 must be integer offset",
Call);
6586 "gc.relocate operand #3 must be integer offset",
Call);
6596 Check(BaseIndex < Opt->Inputs.size(),
6597 "gc.relocate: statepoint base index out of bounds",
Call);
6598 Check(DerivedIndex < Opt->Inputs.size(),
6599 "gc.relocate: statepoint derived index out of bounds",
Call);
6612 "gc.relocate: relocated value must be a pointer",
Call);
6613 Check(DerivedType->isPtrOrPtrVectorTy(),
6614 "gc.relocate: relocated value must be a pointer",
Call);
6616 Check(ResultType->isVectorTy() == DerivedType->isVectorTy(),
6617 "gc.relocate: vector relocates to vector and pointer to pointer",
6620 ResultType->getPointerAddressSpace() ==
6621 DerivedType->getPointerAddressSpace(),
6622 "gc.relocate: relocating a pointer shouldn't change its address space",
6626 Check(GC,
"gc.relocate: calling function must have GCStrategy",
6629 auto isGCPtr = [&
GC](
Type *PTy) {
6630 return GC->isGCManagedPointer(PTy->getScalarType()).value_or(
true);
6632 Check(isGCPtr(ResultType),
"gc.relocate: must return gc pointer",
Call);
6634 "gc.relocate: relocated value must be a gc pointer",
Call);
6635 Check(isGCPtr(DerivedType),
6636 "gc.relocate: relocated value must be a gc pointer",
Call);
6640 case Intrinsic::experimental_patchpoint: {
6643 "patchpoint: invalid return type used with anyregcc",
Call);
6647 case Intrinsic::eh_exceptioncode:
6648 case Intrinsic::eh_exceptionpointer: {
6650 "eh.exceptionpointer argument must be a catchpad",
Call);
6653 case Intrinsic::get_active_lane_mask: {
6655 "get_active_lane_mask: must return a "
6659 Check(ElemTy->isIntegerTy(1),
6660 "get_active_lane_mask: element type is not "
6665 case Intrinsic::experimental_get_vector_length: {
6668 "get_vector_length: VF must be positive",
Call);
6671 case Intrinsic::masked_load: {
6677 Check(
Mask->getType()->isVectorTy(),
"masked_load: mask must be vector",
6680 "masked_load: pass through and return type must match",
Call);
6683 "masked_load: vector mask must be same length as return",
Call);
6686 case Intrinsic::masked_store: {
6689 Check(
Mask->getType()->isVectorTy(),
"masked_store: mask must be vector",
6693 "masked_store: vector mask must be same length as value",
Call);
6696 case Intrinsic::experimental_guard: {
6699 "experimental_guard must have exactly one "
6700 "\"deopt\" operand bundle");
6704 case Intrinsic::experimental_deoptimize: {
6708 "experimental_deoptimize must have exactly one "
6709 "\"deopt\" operand bundle");
6711 "experimental_deoptimize return type must match caller return type");
6716 "calls to experimental_deoptimize must be followed by a return");
6720 "calls to experimental_deoptimize must be followed by a return "
6721 "of the value computed by experimental_deoptimize");
6726 case Intrinsic::vastart: {
6728 "va_start called in a non-varargs function");
6731 case Intrinsic::get_dynamic_area_offset: {
6733 Check(IntTy &&
DL.getPointerSizeInBits(
DL.getAllocaAddrSpace()) ==
6734 IntTy->getBitWidth(),
6735 "get_dynamic_area_offset result type must be scalar integer matching "
6736 "alloca address space width",
6740 case Intrinsic::masked_udiv:
6741 case Intrinsic::masked_sdiv:
6742 case Intrinsic::masked_urem:
6743 case Intrinsic::masked_srem:
6744 case Intrinsic::vector_reduce_and:
6745 case Intrinsic::vector_reduce_or:
6746 case Intrinsic::vector_reduce_xor:
6747 case Intrinsic::vector_reduce_add:
6748 case Intrinsic::vector_reduce_mul:
6749 case Intrinsic::vector_reduce_smax:
6750 case Intrinsic::vector_reduce_smin:
6751 case Intrinsic::vector_reduce_umax:
6752 case Intrinsic::vector_reduce_umin: {
6755 "intrinsic has incorrect argument type!");
6758 case Intrinsic::vector_reduce_fmax:
6759 case Intrinsic::vector_reduce_fmin: {
6762 "intrinsic has incorrect argument type!");
6765 case Intrinsic::vector_reduce_fadd:
6766 case Intrinsic::vector_reduce_fmul: {
6771 "intrinsic has incorrect argument type!");
6774 case Intrinsic::smul_fix:
6775 case Intrinsic::smul_fix_sat:
6776 case Intrinsic::umul_fix:
6777 case Intrinsic::umul_fix_sat:
6778 case Intrinsic::sdiv_fix:
6779 case Intrinsic::sdiv_fix_sat:
6780 case Intrinsic::udiv_fix:
6781 case Intrinsic::udiv_fix_sat: {
6785 if (
ID == Intrinsic::smul_fix ||
ID == Intrinsic::smul_fix_sat ||
6786 ID == Intrinsic::sdiv_fix ||
ID == Intrinsic::sdiv_fix_sat) {
6788 "the scale of s[mul|div]_fix[_sat] must be less than the width of "
6792 "the scale of u[mul|div]_fix[_sat] must be less than or equal "
6793 "to the width of the operands");
6797 case Intrinsic::lrint:
6798 case Intrinsic::llrint:
6799 case Intrinsic::lround:
6800 case Intrinsic::llround: {
6804 ExpectedName +
": argument and result disagree on vector use", &
Call);
6807 Check(VTy->getElementCount() == RTy->getElementCount(),
6808 ExpectedName +
": argument must be same length as result", &
Call);
6812 case Intrinsic::bswap: {
6815 Check(
Size % 16 == 0,
"bswap must be an even number of bytes", &
Call);
6818 case Intrinsic::invariant_start: {
6820 Check(InvariantSize &&
6822 "invariant_start parameter must be -1, 0 or a positive number",
6826 case Intrinsic::matrix_multiply:
6827 case Intrinsic::matrix_transpose:
6828 case Intrinsic::matrix_column_major_load:
6829 case Intrinsic::matrix_column_major_store: {
6831 ConstantInt *Stride =
nullptr;
6832 ConstantInt *NumRows;
6833 ConstantInt *NumColumns;
6835 Type *Op0ElemTy =
nullptr;
6836 Type *Op1ElemTy =
nullptr;
6838 case Intrinsic::matrix_multiply: {
6843 ->getNumElements() ==
6845 "First argument of a matrix operation does not match specified "
6848 ->getNumElements() ==
6850 "Second argument of a matrix operation does not match specified "
6860 case Intrinsic::matrix_transpose:
6867 case Intrinsic::matrix_column_major_load: {
6874 case Intrinsic::matrix_column_major_store: {
6887 Check(ResultTy->getElementType()->isIntegerTy() ||
6888 ResultTy->getElementType()->isFloatingPointTy(),
6889 "Result type must be an integer or floating-point type!", IF);
6892 Check(ResultTy->getElementType() == Op0ElemTy,
6893 "Vector element type mismatch of the result and first operand "
6898 Check(ResultTy->getElementType() == Op1ElemTy,
6899 "Vector element type mismatch of the result and second operand "
6905 "Result of a matrix operation does not fit in the returned vector!");
6911 "Stride must be greater or equal than the number of rows!", IF);
6916 case Intrinsic::stepvector: {
6918 Check(VecTy && VecTy->getScalarType()->isIntegerTy() &&
6919 VecTy->getScalarSizeInBits() >= 8,
6920 "stepvector only supported for vectors of integers "
6921 "with a bitwidth of at least 8.",
6925 case Intrinsic::experimental_vector_match: {
6934 Check(Op1Ty && Op2Ty && MaskTy,
"Operands must be vectors.", &
Call);
6936 "Second operand must be a fixed length vector.", &
Call);
6937 Check(Op1Ty->getElementType()->isIntegerTy(),
6938 "First operand must be a vector of integers.", &
Call);
6939 Check(Op1Ty->getElementType() == Op2Ty->getElementType(),
6940 "First two operands must have the same element type.", &
Call);
6941 Check(Op1Ty->getElementCount() == MaskTy->getElementCount(),
6942 "First operand and mask must have the same number of elements.",
6944 Check(MaskTy->getElementType()->isIntegerTy(1),
6945 "Mask must be a vector of i1's.", &
Call);
6950 case Intrinsic::vector_insert: {
6959 ElementCount VecEC = VecTy->getElementCount();
6960 ElementCount SubVecEC = SubVecTy->getElementCount();
6961 Check(VecTy->getElementType() == SubVecTy->getElementType(),
6962 "vector_insert parameters must have the same element "
6966 "vector_insert index must be a constant multiple of "
6967 "the subvector's known minimum vector length.");
6975 "subvector operand of vector_insert would overrun the "
6976 "vector being inserted into.");
6980 case Intrinsic::vector_extract: {
6988 ElementCount VecEC = VecTy->getElementCount();
6989 ElementCount ResultEC = ResultTy->getElementCount();
6991 Check(ResultTy->getElementType() == VecTy->getElementType(),
6992 "vector_extract result must have the same element "
6993 "type as the input vector.",
6996 "vector_extract index must be a constant multiple of "
6997 "the result type's known minimum vector length.");
7005 "vector_extract would overrun.");
7009 case Intrinsic::vector_partial_reduce_fadd:
7010 case Intrinsic::vector_partial_reduce_add: {
7014 unsigned VecWidth = VecTy->getElementCount().getKnownMinValue();
7015 unsigned AccWidth = AccTy->getElementCount().getKnownMinValue();
7017 Check((VecWidth % AccWidth) == 0,
7018 "Invalid vector widths for partial "
7019 "reduction. The width of the input vector "
7020 "must be a positive integer multiple of "
7021 "the width of the accumulator vector.");
7024 case Intrinsic::experimental_noalias_scope_decl: {
7028 case Intrinsic::preserve_array_access_index:
7029 case Intrinsic::preserve_struct_access_index:
7030 case Intrinsic::aarch64_ldaxr:
7031 case Intrinsic::aarch64_ldxr:
7032 case Intrinsic::arm_ldaex:
7033 case Intrinsic::arm_ldrex: {
7035 Check(ElemTy,
"Intrinsic requires elementtype attribute on first argument.",
7039 case Intrinsic::aarch64_stlxr:
7040 case Intrinsic::aarch64_stxr:
7041 case Intrinsic::arm_stlex:
7042 case Intrinsic::arm_strex: {
7045 "Intrinsic requires elementtype attribute on second argument.",
7049 case Intrinsic::aarch64_prefetch: {
7051 "write argument to llvm.aarch64.prefetch must be 0 or 1",
Call);
7053 "target argument to llvm.aarch64.prefetch must be 0-3",
Call);
7055 "stream argument to llvm.aarch64.prefetch must be 0 or 1",
Call);
7057 "isdata argument to llvm.aarch64.prefetch must be 0 or 1",
Call);
7060 case Intrinsic::aarch64_range_prefetch: {
7062 "write argument to llvm.aarch64.range.prefetch must be 0 or 1",
Call);
7064 "stream argument to llvm.aarch64.range.prefetch must be 0 or 1",
7068 case Intrinsic::callbr_landingpad: {
7070 Check(CBR,
"intrinstic requires callbr operand", &
Call);
7077 CheckFailed(
"Intrinsic in block must have 1 unique predecessor", &
Call);
7081 CheckFailed(
"Intrinsic must have corresponding callbr in predecessor",
7086 "Intrinsic's corresponding callbr must have intrinsic's parent basic "
7087 "block in indirect destination list",
7090 Check(&
First == &
Call,
"No other instructions may proceed intrinsic",
7094 case Intrinsic::structured_gep: {
7100 "Intrinsic first parameter is missing an ElementType attribute",
7108 "Index operand type must be an integer", &
Call);
7111 T = AT->getElementType();
7113 Check(CI,
"Indexing into a struct requires a constant int", &
Call);
7115 "Indexing in a struct should be inbounds", &
Call);
7118 T = VT->getElementType();
7120 CheckFailed(
"Reached a non-composite type with more indices to process",
7126 case Intrinsic::structured_alloca:
7128 "@llvm.structured.alloca calls require elementtype attribute.",
7131 case Intrinsic::amdgcn_cs_chain: {
7134 case CallingConv::AMDGPU_CS:
7135 case CallingConv::AMDGPU_CS_Chain:
7136 case CallingConv::AMDGPU_CS_ChainPreserve:
7137 case CallingConv::AMDGPU_ES:
7138 case CallingConv::AMDGPU_GS:
7139 case CallingConv::AMDGPU_HS:
7140 case CallingConv::AMDGPU_LS:
7141 case CallingConv::AMDGPU_VS:
7144 CheckFailed(
"Intrinsic cannot be called from functions with this "
7145 "calling convention",
7151 "SGPR arguments must have the `inreg` attribute", &
Call);
7153 "VGPR arguments must not have the `inreg` attribute", &
Call);
7158 Intrinsic::amdgcn_unreachable;
7160 "llvm.amdgcn.cs.chain must be followed by unreachable", &
Call);
7163 case Intrinsic::amdgcn_init_exec_from_input: {
7166 "only inreg arguments to the parent function are valid as inputs to "
7171 case Intrinsic::amdgcn_set_inactive_chain_arg: {
7174 case CallingConv::AMDGPU_CS_Chain:
7175 case CallingConv::AMDGPU_CS_ChainPreserve:
7178 CheckFailed(
"Intrinsic can only be used from functions with the "
7179 "amdgpu_cs_chain or amdgpu_cs_chain_preserve "
7180 "calling conventions",
7185 unsigned InactiveIdx = 1;
7187 "Value for inactive lanes must not have the `inreg` attribute",
7190 "Value for inactive lanes must be a function argument", &
Call);
7192 "Value for inactive lanes must be a VGPR function argument", &
Call);
7195 case Intrinsic::amdgcn_call_whole_wave: {
7197 Check(
F,
"Indirect whole wave calls are not allowed", &
Call);
7199 CallingConv::ID CC =
F->getCallingConv();
7200 Check(CC == CallingConv::AMDGPU_Gfx_WholeWave,
7201 "Callee must have the amdgpu_gfx_whole_wave calling convention",
7204 Check(!
F->isVarArg(),
"Variadic whole wave calls are not allowed", &
Call);
7207 "Call argument count must match callee argument count", &
Call);
7211 Check(
F->arg_begin()->getType()->isIntegerTy(1),
7212 "Callee must have i1 as its first argument", &
Call);
7213 for (
auto [CallArg, FuncArg] :
7215 Check(CallArg->getType() == FuncArg.getType(),
7216 "Argument types must match", &
Call);
7220 FuncArg.hasInRegAttr(),
7221 "Argument inreg attributes must match", &
Call);
7225 case Intrinsic::amdgcn_s_prefetch_data: {
7229 "llvm.amdgcn.s.prefetch.data only supports global or constant memory");
7232 case Intrinsic::amdgcn_load_to_lds:
7233 case Intrinsic::amdgcn_load_async_to_lds:
7234 case Intrinsic::amdgcn_global_load_lds:
7235 case Intrinsic::amdgcn_global_load_async_lds:
7236 case Intrinsic::amdgcn_raw_buffer_load_lds:
7237 case Intrinsic::amdgcn_raw_buffer_load_async_lds:
7238 case Intrinsic::amdgcn_raw_ptr_buffer_load_lds:
7239 case Intrinsic::amdgcn_raw_ptr_buffer_load_async_lds:
7240 case Intrinsic::amdgcn_struct_buffer_load_lds:
7241 case Intrinsic::amdgcn_struct_buffer_load_async_lds:
7242 case Intrinsic::amdgcn_struct_ptr_buffer_load_lds:
7243 case Intrinsic::amdgcn_struct_ptr_buffer_load_async_lds: {
7247 "invalid data size for load-to-LDS intrinsic; must be 1, 2, 4, 12, "
7252 case Intrinsic::amdgcn_mfma_scale_f32_16x16x128_f8f6f4:
7253 case Intrinsic::amdgcn_mfma_scale_f32_32x32x64_f8f6f4: {
7259 Check(CBSZ <= 4,
"invalid value for cbsz format",
Call,
7261 Check(BLGP <= 4,
"invalid value for blgp format",
Call,
7265 auto getFormatNumRegs = [](
unsigned FormatVal) {
7266 switch (FormatVal) {
7280 auto isValidSrcASrcBVector = [](FixedVectorType *Ty) {
7281 if (!Ty || !Ty->getElementType()->
isIntegerTy(32))
7283 unsigned NumElts = Ty->getNumElements();
7284 return NumElts == 4 || NumElts == 6 || NumElts == 8;
7289 Check(isValidSrcASrcBVector(Src0Ty),
7290 "operand 0 must be 4, 6 or 8 element i32 vector", &
Call, Src0);
7291 Check(isValidSrcASrcBVector(Src1Ty),
7292 "operand 1 must be 4, 6 or 8 element i32 vector", &
Call, Src1);
7295 Check(Src0Ty->getNumElements() >= getFormatNumRegs(CBSZ),
7297 Check(Src1Ty->getNumElements() >= getFormatNumRegs(BLGP),
7301 case Intrinsic::amdgcn_wmma_f32_16x16x128_f8f6f4:
7302 case Intrinsic::amdgcn_wmma_scale_f32_16x16x128_f8f6f4:
7303 case Intrinsic::amdgcn_wmma_scale16_f32_16x16x128_f8f6f4: {
7309 Check(FmtA <= 4,
"invalid value for matrix format",
Call,
7311 Check(FmtB <= 4,
"invalid value for matrix format",
Call,
7315 auto getFormatNumRegs = [](
unsigned FormatVal) {
7316 switch (FormatVal) {
7330 auto isValidSrcASrcBVector = [](FixedVectorType *Ty) {
7331 if (!Ty || !Ty->getElementType()->
isIntegerTy(32))
7333 unsigned NumElts = Ty->getNumElements();
7334 return NumElts == 16 || NumElts == 12 || NumElts == 8;
7339 Check(isValidSrcASrcBVector(Src0Ty),
7340 "operand 1 must be 8, 12 or 16 element i32 vector", &
Call, Src0);
7341 Check(isValidSrcASrcBVector(Src1Ty),
7342 "operand 3 must be 8, 12 or 16 element i32 vector", &
Call, Src1);
7345 Check(Src0Ty->getNumElements() >= getFormatNumRegs(FmtA),
7347 Check(Src1Ty->getNumElements() >= getFormatNumRegs(FmtB),
7351 case Intrinsic::amdgcn_cooperative_atomic_load_32x4B:
7352 case Intrinsic::amdgcn_cooperative_atomic_load_16x8B:
7353 case Intrinsic::amdgcn_cooperative_atomic_load_8x16B:
7354 case Intrinsic::amdgcn_cooperative_atomic_store_32x4B:
7355 case Intrinsic::amdgcn_cooperative_atomic_store_16x8B:
7356 case Intrinsic::amdgcn_cooperative_atomic_store_8x16B: {
7361 "cooperative atomic intrinsics require a generic or global pointer",
7368 "cooperative atomic intrinsics require that the last argument is a "
7373 case Intrinsic::amdgcn_av_load_b128:
7374 case Intrinsic::amdgcn_av_store_b128: {
7379 "the last argument to av load/store intrinsics must be a "
7384 case Intrinsic::nvvm_setmaxnreg_inc_sync_aligned_u32:
7385 case Intrinsic::nvvm_setmaxnreg_dec_sync_aligned_u32: {
7388 Check(RegCount % 8 == 0,
7389 "reg_count argument to nvvm.setmaxnreg must be in multiples of 8");
7392 case Intrinsic::experimental_convergence_entry:
7393 case Intrinsic::experimental_convergence_anchor:
7395 case Intrinsic::experimental_convergence_loop:
7397 case Intrinsic::ptrmask: {
7401 "llvm.ptrmask intrinsic first argument must be pointer or vector "
7406 "llvm.ptrmask intrinsic arguments must be both scalars or both vectors",
7411 "llvm.ptrmask intrinsic arguments must have the same number of "
7415 "llvm.ptrmask intrinsic second argument bitwidth must match "
7416 "pointer index type size of first argument",
7420 case Intrinsic::thread_pointer: {
7422 DL.getDefaultGlobalsAddressSpace(),
7423 "llvm.thread.pointer intrinsic return type must be for the globals "
7428 case Intrinsic::threadlocal_address: {
7431 "llvm.threadlocal.address first argument must be a GlobalValue");
7433 "llvm.threadlocal.address operand isThreadLocal() must be true");
7436 case Intrinsic::lifetime_start:
7437 case Intrinsic::lifetime_end: {
7441 (
II &&
II->getIntrinsicID() == Intrinsic::structured_alloca),
7442 "llvm.lifetime.start/end can only be used on alloca or poison",
7446 case Intrinsic::sponentry: {
7447 const unsigned StackAS =
DL.getAllocaAddrSpace();
7450 "llvm.sponentry must return a pointer to the stack", &
Call);
7453 case Intrinsic::write_volatile_register: {
7457 "llvm.write_volatile_register metadata must be a single MDString",
7466 if (
F->hasPersonalityFn() &&
7470 if (BlockEHFuncletColors.
empty())
7474 bool InEHFunclet =
false;
7478 for (BasicBlock *ColorFirstBB : CV)
7479 if (
auto It = ColorFirstBB->getFirstNonPHIIt();
7480 It != ColorFirstBB->end())
7485 bool HasToken =
false;
7492 Check(HasToken,
"Missing funclet token on intrinsic call", &
Call);
7516void Verifier::visit(DbgLabelRecord &DLR) {
7518 "invalid #dbg_label intrinsic variable", &DLR, DLR.
getRawLabel());
7531 CheckDI(Loc,
"#dbg_label record requires a !dbg attachment", &DLR, BB,
F);
7535 if (!LabelSP || !LocSP)
7539 "mismatched subprogram between #dbg_label label and !dbg attachment",
7540 &DLR, BB,
F, Label,
Label->getScope()->getSubprogram(), Loc,
7541 Loc->getScope()->getSubprogram());
7544void Verifier::visit(DbgVariableRecord &DVR) {
7548 CheckDI(DVR.
getType() == DbgVariableRecord::LocationType::Value ||
7549 DVR.
getType() == DbgVariableRecord::LocationType::Declare ||
7550 DVR.
getType() == DbgVariableRecord::LocationType::DeclareValue ||
7551 DVR.
getType() == DbgVariableRecord::LocationType::Assign,
7552 "invalid #dbg record type", &DVR, DVR.
getType(), BB,
F);
7560 "invalid #dbg record address/value", &DVR, MD, BB,
F);
7562 visitValueAsMetadata(*VAM,
F);
7565 Type *Ty = VAM->getValue()->getType();
7567 "location of #dbg_declare must be a pointer or int", &DVR, MD, BB,
7571 visitDIArgList(*AL,
F);
7585 "invalid #dbg_assign DIAssignID", &DVR, DVR.
getRawAssignID(), BB,
7588 AreDebugLocsAllowed::No);
7597 "invalid #dbg_assign address", &DVR, DVR.
getRawAddress(), BB,
F);
7599 visitValueAsMetadata(*VAM,
F);
7602 "invalid #dbg_assign address expression", &DVR,
7609 "inst not in same function as #dbg_assign",
I, &DVR, BB,
F);
7619 &DVR, DLNode, BB,
F);
7625 if (!VarSP || !LocSP)
7629 "mismatched subprogram between #dbg record variable and DILocation",
7631 Loc->getScope()->getSubprogram(), BB,
F);
7636void Verifier::visitVPIntrinsic(VPIntrinsic &VPI) {
7640 Check(RetTy->getElementCount() == ValTy->getElementCount(),
7641 "VP cast intrinsic first argument and result vector lengths must be "
7645 switch (VPCast->getIntrinsicID()) {
7648 case Intrinsic::vp_trunc:
7650 "llvm.vp.trunc intrinsic first argument and result element type "
7654 "llvm.vp.trunc intrinsic the bit size of first argument must be "
7655 "larger than the bit size of the return type",
7658 case Intrinsic::vp_zext:
7659 case Intrinsic::vp_sext:
7661 "llvm.vp.zext or llvm.vp.sext intrinsic first argument and result "
7662 "element type must be integer",
7665 "llvm.vp.zext or llvm.vp.sext intrinsic the bit size of first "
7666 "argument must be smaller than the bit size of the return type",
7669 case Intrinsic::vp_fptoui:
7670 case Intrinsic::vp_fptosi:
7671 case Intrinsic::vp_lrint:
7672 case Intrinsic::vp_llrint:
7675 "llvm.vp.fptoui, llvm.vp.fptosi, llvm.vp.lrint or llvm.vp.llrint" "intrinsic first argument element "
7676 "type must be floating-point and result element type must be integer",
7679 case Intrinsic::vp_uitofp:
7680 case Intrinsic::vp_sitofp:
7683 "llvm.vp.uitofp or llvm.vp.sitofp intrinsic first argument element "
7684 "type must be integer and result element type must be floating-point",
7687 case Intrinsic::vp_fptrunc:
7689 "llvm.vp.fptrunc intrinsic first argument and result element type "
7690 "must be floating-point",
7693 "llvm.vp.fptrunc intrinsic the bit size of first argument must be "
7694 "larger than the bit size of the return type",
7697 case Intrinsic::vp_fpext:
7699 "llvm.vp.fpext intrinsic first argument and result element type "
7700 "must be floating-point",
7703 "llvm.vp.fpext intrinsic the bit size of first argument must be "
7704 "smaller than the bit size of the return type",
7707 case Intrinsic::vp_ptrtoint:
7709 "llvm.vp.ptrtoint intrinsic first argument element type must be "
7710 "pointer and result element type must be integer",
7713 case Intrinsic::vp_inttoptr:
7715 "llvm.vp.inttoptr intrinsic first argument element type must be "
7716 "integer and result element type must be pointer",
7723 case Intrinsic::vp_fcmp: {
7726 "invalid predicate for VP FP comparison intrinsic", &VPI);
7729 case Intrinsic::vp_icmp: {
7732 "invalid predicate for VP integer comparison intrinsic", &VPI);
7735 case Intrinsic::vp_is_fpclass: {
7738 "unsupported bits for llvm.vp.is.fpclass test mask");
7741 case Intrinsic::experimental_vp_splice: {
7744 int64_t KnownMinNumElements = VecTy->getElementCount().getKnownMinValue();
7746 AttributeList
Attrs = VPI.
getParent()->getParent()->getAttributes();
7747 if (
Attrs.hasFnAttr(Attribute::VScaleRange))
7748 KnownMinNumElements *=
Attrs.getFnAttrs().getVScaleRangeMin();
7750 Check((Idx < 0 && std::abs(Idx) <= KnownMinNumElements) ||
7751 (Idx >= 0 && Idx < KnownMinNumElements),
7752 "The splice index exceeds the range [-VL, VL-1] where VL is the "
7753 "known minimum number of elements in the vector. For scalable "
7754 "vectors the minimum number of elements is determined from "
7762void Verifier::visitConstrainedFPIntrinsic(ConstrainedFPIntrinsic &FPI) {
7764 bool HasRoundingMD =
7768 NumOperands += (1 + HasRoundingMD);
7774 "invalid arguments for constrained FP intrinsic", &FPI);
7777 case Intrinsic::experimental_constrained_lrint:
7778 case Intrinsic::experimental_constrained_llrint: {
7782 "Intrinsic does not support vectors", &FPI);
7786 case Intrinsic::experimental_constrained_lround:
7787 case Intrinsic::experimental_constrained_llround: {
7791 "Intrinsic does not support vectors", &FPI);
7795 case Intrinsic::experimental_constrained_fcmp:
7796 case Intrinsic::experimental_constrained_fcmps: {
7799 "invalid predicate for constrained FP comparison intrinsic", &FPI);
7803 case Intrinsic::experimental_constrained_fptosi:
7804 case Intrinsic::experimental_constrained_fptoui: {
7808 "Intrinsic first argument must be floating point", &FPI);
7815 "Intrinsic first argument and result disagree on vector use", &FPI);
7817 "Intrinsic result must be an integer", &FPI);
7820 "Intrinsic first argument and result vector lengths must be equal",
7826 case Intrinsic::experimental_constrained_sitofp:
7827 case Intrinsic::experimental_constrained_uitofp: {
7831 "Intrinsic first argument must be integer", &FPI);
7838 "Intrinsic first argument and result disagree on vector use", &FPI);
7840 "Intrinsic result must be a floating point", &FPI);
7843 "Intrinsic first argument and result vector lengths must be equal",
7849 case Intrinsic::experimental_constrained_fptrunc:
7850 case Intrinsic::experimental_constrained_fpext: {
7856 "Intrinsic first argument must be FP or FP vector", &FPI);
7858 "Intrinsic result must be FP or FP vector", &FPI);
7860 "Intrinsic first argument and result disagree on vector use", &FPI);
7864 "Intrinsic first argument and result vector lengths must be equal",
7867 if (FPI.
getIntrinsicID() == Intrinsic::experimental_constrained_fptrunc) {
7869 "Intrinsic first argument's type must be larger than result type",
7873 "Intrinsic first argument's type must be smaller than result type",
7889 "invalid exception behavior argument", &FPI);
7890 if (HasRoundingMD) {
7896void Verifier::verifyFragmentExpression(
const DbgVariableRecord &DVR) {
7901 if (!V || !
E || !
E->isValid())
7905 auto Fragment =
E->getFragmentInfo();
7915 if (
V->isArtificial())
7918 verifyFragmentExpression(*V, *Fragment, &DVR);
7921template <
typename ValueOrMetadata>
7922void Verifier::verifyFragmentExpression(
const DIVariable &V,
7924 ValueOrMetadata *
Desc) {
7927 auto VarSize =
V.getSizeInBits();
7933 CheckDI(FragSize + FragOffset <= *VarSize,
7934 "fragment is larger than or outside of variable",
Desc, &V);
7935 CheckDI(FragSize != *VarSize,
"fragment covers entire variable",
Desc, &V);
7938void Verifier::verifyFnArgs(
const DbgVariableRecord &DVR) {
7950 CheckDI(Var,
"#dbg record without variable");
7952 unsigned ArgNo = Var->
getArg();
7958 if (DebugFnArgs.
size() < ArgNo)
7959 DebugFnArgs.
resize(ArgNo,
nullptr);
7961 auto *Prev = DebugFnArgs[ArgNo - 1];
7962 DebugFnArgs[ArgNo - 1] = Var;
7963 CheckDI(!Prev || (Prev == Var),
"conflicting debug info for argument", &DVR,
7967void Verifier::verifyNotEntryValue(
const DbgVariableRecord &DVR) {
7971 if (!
E || !
E->isValid())
7981 ArgLoc && ArgLoc->hasAttribute(Attribute::SwiftAsync))
7986 "Entry values are only allowed in MIR unless they target a "
7987 "swiftasync Argument",
7991void Verifier::verifyCompileUnits() {
7995 if (
M.getContext().isODRUniquingDebugTypes())
7997 auto *CUs =
M.getNamedMetadata(
"llvm.dbg.cu");
7998 SmallPtrSet<const Metadata *, 2> Listed;
8001 for (
const auto *CU : CUVisited)
8002 CheckDI(Listed.
count(CU),
"DICompileUnit not listed in llvm.dbg.cu", CU);
8006void Verifier::verifyDeoptimizeCallingConvs() {
8007 if (DeoptimizeDeclarations.
empty())
8011 for (
const auto *
F :
ArrayRef(DeoptimizeDeclarations).slice(1)) {
8012 Check(
First->getCallingConv() ==
F->getCallingConv(),
8013 "All llvm.experimental.deoptimize declarations must have the same "
8014 "calling convention",
8019void Verifier::verifyAttachedCallBundle(
const CallBase &
Call,
8020 const OperandBundleUse &BU) {
8023 Check((FTy->getReturnType()->isPointerTy() ||
8025 "a call with operand bundle \"clang.arc.attachedcall\" must call a "
8026 "function returning a pointer or a non-returning function that has a "
8031 "operand bundle \"clang.arc.attachedcall\" requires one function as "
8039 Check((IID == Intrinsic::objc_retainAutoreleasedReturnValue ||
8040 IID == Intrinsic::objc_claimAutoreleasedReturnValue ||
8041 IID == Intrinsic::objc_unsafeClaimAutoreleasedReturnValue),
8042 "invalid function argument",
Call);
8044 StringRef FnName = Fn->
getName();
8045 Check((FnName ==
"objc_retainAutoreleasedReturnValue" ||
8046 FnName ==
"objc_claimAutoreleasedReturnValue" ||
8047 FnName ==
"objc_unsafeClaimAutoreleasedReturnValue"),
8048 "invalid function argument",
Call);
8052void Verifier::verifyNoAliasScopeDecl() {
8053 if (NoAliasScopeDecls.
empty())
8057 for (
auto *
II : NoAliasScopeDecls) {
8058 assert(
II->getIntrinsicID() == Intrinsic::experimental_noalias_scope_decl &&
8059 "Not a llvm.experimental.noalias.scope.decl ?");
8062 Check(ScopeListMV !=
nullptr,
8063 "llvm.experimental.noalias.scope.decl must have a MetadataAsValue "
8068 Check(ScopeListMD !=
nullptr,
"!id.scope.list must point to an MDNode",
II);
8069 Check(ScopeListMD->getNumOperands() == 1,
8070 "!id.scope.list must point to a list with a single scope",
II);
8071 visitAliasScopeListMetadata(ScopeListMD);
8081 auto GetScope = [](IntrinsicInst *
II) {
8084 return &
cast<MDNode>(ScopeListMV->getMetadata())->getOperand(0);
8089 auto Compare = [GetScope](IntrinsicInst *Lhs, IntrinsicInst *Rhs) {
8090 return GetScope(Lhs) < GetScope(Rhs);
8097 auto ItCurrent = NoAliasScopeDecls.begin();
8098 while (ItCurrent != NoAliasScopeDecls.end()) {
8099 auto CurScope = GetScope(*ItCurrent);
8100 auto ItNext = ItCurrent;
8103 }
while (ItNext != NoAliasScopeDecls.end() &&
8104 GetScope(*ItNext) == CurScope);
8109 if (ItNext - ItCurrent < 32)
8113 Check(!DT.dominates(
I, J),
8114 "llvm.experimental.noalias.scope.decl dominates another one "
8115 "with the same scope",
8129 Verifier V(OS,
true, *f.getParent());
8133 return !V.verify(
F);
8137 bool *BrokenDebugInfo) {
8139 Verifier V(OS, !BrokenDebugInfo, M);
8141 bool Broken =
false;
8143 Broken |= !V.verify(
F);
8145 Broken |= !V.verify();
8146 if (BrokenDebugInfo)
8147 *BrokenDebugInfo = V.hasBrokenDebugInfo();
8158 std::unique_ptr<Verifier> V;
8159 bool FatalErrors =
true;
8162 explicit VerifierLegacyPass(
bool FatalErrors)
8163 : FunctionPass(
ID), FatalErrors(FatalErrors) {}
8165 bool doInitialization(
Module &M)
override {
8166 V = std::make_unique<Verifier>(
8172 if (!
V->verify(
F) && FatalErrors) {
8173 errs() <<
"in function " <<
F.getName() <<
'\n';
8179 bool doFinalization(
Module &M)
override {
8180 bool HasErrors =
false;
8181 for (Function &
F : M)
8182 if (
F.isDeclaration())
8183 HasErrors |= !
V->verify(
F);
8185 HasErrors |= !
V->verify();
8186 if (FatalErrors && (HasErrors ||
V->hasBrokenDebugInfo()))
8191 void getAnalysisUsage(AnalysisUsage &AU)
const override {
8199template <
typename... Tys>
void TBAAVerifier::CheckFailed(Tys &&... Args) {
8201 return Diagnostic->CheckFailed(
Args...);
8204#define CheckTBAA(C, ...) \
8207 CheckFailed(__VA_ARGS__); \
8215TBAAVerifier::TBAABaseNodeSummary
8219 CheckFailed(
"Base nodes must have at least two operands",
I, BaseNode);
8223 auto Itr = TBAABaseNodes.find(BaseNode);
8224 if (Itr != TBAABaseNodes.end())
8227 auto Result = verifyTBAABaseNodeImpl(
I, BaseNode, IsNewFormat);
8228 auto InsertResult = TBAABaseNodes.insert({BaseNode, Result});
8230 assert(InsertResult.second &&
"We just checked!");
8234TBAAVerifier::TBAABaseNodeSummary
8235TBAAVerifier::verifyTBAABaseNodeImpl(
const Instruction *
I,
8236 const MDNode *BaseNode,
bool IsNewFormat) {
8237 const TBAAVerifier::TBAABaseNodeSummary InvalidNode = {
true, ~0
u};
8241 return isValidScalarTBAANode(BaseNode)
8242 ? TBAAVerifier::TBAABaseNodeSummary({
false, 0})
8248 CheckFailed(
"Access tag nodes must have the number of operands that is a "
8249 "multiple of 3!", BaseNode);
8254 CheckFailed(
"Struct tag nodes must have an odd number of operands!",
8264 if (!TypeSizeNode) {
8265 CheckFailed(
"Type size nodes must be constants!",
I, BaseNode);
8272 CheckFailed(
"Struct tag nodes have a string as their first operand",
8279 std::optional<APInt> PrevOffset;
8284 unsigned FirstFieldOpNo = IsNewFormat ? 3 : 1;
8285 unsigned NumOpsPerField = IsNewFormat ? 3 : 2;
8286 for (
unsigned Idx = FirstFieldOpNo; Idx < BaseNode->
getNumOperands();
8287 Idx += NumOpsPerField) {
8288 const MDOperand &FieldTy = BaseNode->
getOperand(Idx);
8289 const MDOperand &FieldOffset = BaseNode->
getOperand(Idx + 1);
8291 CheckFailed(
"Incorrect field entry in struct type node!",
I, BaseNode);
8296 auto *OffsetEntryCI =
8298 if (!OffsetEntryCI) {
8299 CheckFailed(
"Offset entries must be constants!",
I, BaseNode);
8305 BitWidth = OffsetEntryCI->getBitWidth();
8307 if (OffsetEntryCI->getBitWidth() !=
BitWidth) {
8309 "Bitwidth between the offsets and struct type entries must match",
I,
8321 !PrevOffset || PrevOffset->ule(OffsetEntryCI->getValue());
8324 CheckFailed(
"Offsets must be increasing!",
I, BaseNode);
8328 PrevOffset = OffsetEntryCI->getValue();
8333 if (!MemberSizeNode) {
8334 CheckFailed(
"Member size entries must be constants!",
I, BaseNode);
8341 return Failed ? InvalidNode
8342 : TBAAVerifier::TBAABaseNodeSummary(
false,
BitWidth);
8364 return Parent && Visited.
insert(Parent).second &&
8368bool TBAAVerifier::isValidScalarTBAANode(
const MDNode *MD) {
8369 auto ResultIt = TBAAScalarNodes.find(MD);
8370 if (ResultIt != TBAAScalarNodes.end())
8371 return ResultIt->second;
8373 SmallPtrSet<const MDNode *, 4> Visited;
8375 auto InsertResult = TBAAScalarNodes.insert({MD,
Result});
8377 assert(InsertResult.second &&
"Just checked!");
8386MDNode *TBAAVerifier::getFieldNodeFromTBAABaseNode(
const Instruction *
I,
8387 const MDNode *BaseNode,
8398 unsigned FirstFieldOpNo = IsNewFormat ? 3 : 1;
8399 unsigned NumOpsPerField = IsNewFormat ? 3 : 2;
8400 for (
unsigned Idx = FirstFieldOpNo; Idx < BaseNode->
getNumOperands();
8401 Idx += NumOpsPerField) {
8402 auto *OffsetEntryCI =
8404 if (OffsetEntryCI->getValue().ugt(
Offset)) {
8405 if (Idx == FirstFieldOpNo) {
8406 CheckFailed(
"Could not find TBAA parent in struct type node",
I,
8411 unsigned PrevIdx = Idx - NumOpsPerField;
8412 auto *PrevOffsetEntryCI =
8414 Offset -= PrevOffsetEntryCI->getValue();
8422 Offset -= LastOffsetEntryCI->getValue();
8427 if (!
Type ||
Type->getNumOperands() < 3)
8443 "This instruction shall not have a TBAA access tag!",
I);
8445 bool IsStructPathTBAA =
8449 "Old-style TBAA is no longer allowed, use struct-path TBAA instead",
8459 "Access tag metadata must have either 4 or 5 operands",
I, MD);
8462 "Struct tag metadata must have either 3 or 4 operands",
I, MD);
8469 CheckTBAA(AccessSizeNode,
"Access size field must be a constant",
I, MD);
8473 unsigned ImmutabilityFlagOpNo = IsNewFormat ? 4 : 3;
8478 "Immutability tag on struct tag metadata must be a constant",
I,
8481 IsImmutableCI->isZero() || IsImmutableCI->isOne(),
8482 "Immutability part of the struct tag metadata must be either 0 or 1",
I,
8487 "Malformed struct tag metadata: base and access-type "
8488 "should be non-null and point to Metadata nodes",
8489 I, MD, BaseNode, AccessType);
8492 CheckTBAA(isValidScalarTBAANode(AccessType),
8493 "Access type node must be a valid scalar type",
I, MD,
8498 CheckTBAA(OffsetCI,
"Offset must be constant integer",
I, MD);
8501 bool SeenAccessTypeInPath =
false;
8507 getFieldNodeFromTBAABaseNode(
I, BaseNode,
Offset, IsNewFormat)) {
8508 if (!StructPath.
insert(BaseNode).second) {
8509 CheckFailed(
"Cycle detected in struct path",
I, MD);
8514 unsigned BaseNodeBitWidth;
8515 std::tie(
Invalid, BaseNodeBitWidth) =
8516 verifyTBAABaseNode(
I, BaseNode, IsNewFormat);
8523 SeenAccessTypeInPath |= BaseNode == AccessType;
8525 if (isValidScalarTBAANode(BaseNode) || BaseNode == AccessType)
8530 (BaseNodeBitWidth == 0 &&
Offset == 0) ||
8531 (IsNewFormat && BaseNodeBitWidth == ~0u),
8532 "Access bit-width not the same as description bit-width",
I, MD,
8533 BaseNodeBitWidth,
Offset.getBitWidth());
8535 if (IsNewFormat && SeenAccessTypeInPath)
8539 CheckTBAA(SeenAccessTypeInPath,
"Did not see access type in access path!",
I,
8544char VerifierLegacyPass::ID = 0;
8545INITIALIZE_PASS(VerifierLegacyPass,
"verify",
"Module Verifier",
false,
false)
8548 return new VerifierLegacyPass(FatalErrors);
8566 if (FatalErrors && (Res.IRBroken || Res.DebugInfoBroken))
8574 if (res.IRBroken && FatalErrors)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU address space definition.
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements a class to represent arbitrary precision integral constant values and operations...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Atomic ordering constants.
This file contains the simple types necessary to represent the attributes associated with functions a...
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
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...
This file declares the LLVM IR specialization of the GenericConvergenceVerifier template.
static DISubprogram * getSubprogram(bool IsDistinct, Ts &&...Args)
This file defines the DenseMap class.
This file contains constants used for implementing Dwarf debug support.
static bool runOnFunction(Function &F, bool PostInlining)
This file contains the declarations of entities that describe floating point environment and related ...
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
Module.h This file contains the declarations for the Module class.
This header defines various interfaces for pass management in LLVM.
This defines the Use class.
static constexpr Value * getValue(Ty &ValueOrUse)
const size_t AbstractManglingParser< Derived, Alloc >::NumOps
Machine Check Debug Module
This file implements a map that provides insertion order iteration.
This file provides utility for Memory Model Relaxation Annotations (MMRAs).
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
uint64_t IntrinsicInst * II
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
This file contains the declarations for profiling metadata utility functions.
const SmallVectorImpl< MachineOperand > & Cond
static unsigned getNumElements(Type *Ty)
static void visit(BasicBlock &Start, std::function< bool(BasicBlock *)> op)
verify safepoint Safepoint IR Verifier
BaseType
A given derived pointer can have multiple base pointers through phi/selects.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
static bool IsScalarTBAANodeImpl(const MDNode *MD, SmallPtrSetImpl< const MDNode * > &Visited)
static bool isType(const Metadata *MD)
static Instruction * getSuccPad(Instruction *Terminator)
static bool isMDTuple(const Metadata *MD)
static bool isNewFormatTBAATypeNode(llvm::MDNode *Type)
#define CheckDI(C,...)
We know that a debug info condition should be true, if not print an error message.
static void forEachUser(const Value *User, SmallPtrSet< const Value *, 32 > &Visited, llvm::function_ref< bool(const Value *)> Callback)
static bool isDINode(const Metadata *MD)
static bool isScope(const Metadata *MD)
static cl::opt< bool > VerifyNoAliasScopeDomination("verify-noalias-scope-decl-dom", cl::Hidden, cl::init(false), cl::desc("Ensure that llvm.experimental.noalias.scope.decl for identical " "scopes are not dominating"))
static bool isConstantIntMetadataOperand(const Metadata *MD)
static bool IsRootTBAANode(const MDNode *MD)
static Value * getParentPad(Value *EHPad)
static bool hasConflictingReferenceFlags(unsigned Flags)
Detect mutually exclusive flags.
static AttrBuilder getParameterABIAttributes(LLVMContext &C, unsigned I, AttributeList Attrs)
static const char PassName[]
static LLVM_ABI bool isValidArbitraryFPFormat(StringRef Format)
Returns true if the given string is a valid arbitrary floating-point format interpretation for llvm....
bool isFiniteNonZero() const
const fltSemantics & getSemantics() const
Class for arbitrary precision integers.
bool sgt(const APInt &RHS) const
Signed greater than comparison.
bool isMinValue() const
Determine if this is the smallest unsigned value.
bool ule(const APInt &RHS) const
Unsigned less or equal comparison.
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
int64_t getSExtValue() const
Get sign extended value.
bool isMaxValue() const
Determine if this is the largest unsigned value.
This class represents a conversion between pointers from one address space to another.
bool isSwiftError() const
Return true if this alloca is used as a swifterror argument to a call.
LLVM_ABI bool isStaticAlloca() const
Return true if this alloca is in the entry block of the function and is a constant size.
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
unsigned getAddressSpace() const
Return the address space for the allocation.
LLVM_ABI bool isArrayAllocation() const
Return true if there is an allocation size parameter to the allocation instruction that is not 1.
const Value * getArraySize() const
Get the number of elements allocated.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
void setPreservesAll()
Set by analyses that do not transform their input at all.
LLVM_ABI bool hasInRegAttr() const
Return true if this argument has the inreg attribute.
bool isElementwise() const
Return true if this RMW has elementwise vector semantics.
static bool isFPOperation(BinOp Op)
BinOp getOperation() const
static LLVM_ABI StringRef getOperationName(BinOp Op)
AtomicOrdering getOrdering() const
Returns the ordering constraint of this rmw instruction.
bool contains(Attribute::AttrKind A) const
Return true if the builder has the specified attribute.
LLVM_ABI bool hasAttribute(Attribute::AttrKind Kind) const
Return true if the attribute exists in this set.
LLVM_ABI std::string getAsString(bool InAttrGrp=false) const
Functions, function parameters, and return types can have attributes to indicate how they should be t...
LLVM_ABI const ConstantRange & getValueAsConstantRange() const
Return the attribute's value as a ConstantRange.
LLVM_ABI StringRef getValueAsString() const
Return the attribute's value as a string.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
bool isValid() const
Return true if the attribute is any kind of attribute.
LLVM_ABI Type * getValueAsType() const
Return the attribute's value as a Type.
LLVM Basic Block Representation.
iterator begin()
Instruction iterator methods.
iterator_range< const_phi_iterator > phis() const
Returns a range that iterates over the phis in the basic block.
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 bool isEntryBlock() const
Return true if this is the entry block of the containing function.
const Instruction & front() const
LLVM_ABI const BasicBlock * getUniquePredecessor() const
Return the predecessor of this block if it has a unique predecessor block.
InstListType::iterator iterator
Instruction iterators...
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction; assumes that the block is well-formed.
This class represents a no-op cast from one type to another.
static LLVM_ABI BlockAddress * lookup(const BasicBlock *BB)
Lookup an existing BlockAddress constant for the given BasicBlock.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
bool isInlineAsm() const
Check if this call is an inline asm statement.
auto operand_bundles() const
bool hasInAllocaArgument() const
Determine if there are is an inalloca argument.
OperandBundleUse getOperandBundleAt(unsigned Index) const
Return the operand bundle at a specific index.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation or the function signa...
bool doesNotAccessMemory(unsigned OpNo) const
bool hasFnAttr(Attribute::AttrKind Kind) const
Determine whether this call has the given attribute.
bool hasRetAttr(Attribute::AttrKind Kind) const
Determine whether the return value has the given attribute.
unsigned getNumOperandBundles() const
Return the number of operand bundles associated with this User.
CallingConv::ID getCallingConv() const
LLVM_ABI bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Determine whether the argument or parameter has the given attribute.
Attribute getParamAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Get the attribute of a given kind from a given arg.
unsigned countOperandBundlesOfType(StringRef Name) const
Return the number of operand bundles with the tag Name attached to this instruction.
bool onlyReadsMemory(unsigned OpNo) const
Value * getCalledOperand() const
Type * getParamElementType(unsigned ArgNo) const
Extract the elementtype type for a parameter.
Value * getArgOperand(unsigned i) const
FunctionType * getFunctionType() const
LLVM_ABI Intrinsic::ID getIntrinsicID() const
Returns the intrinsic ID of the intrinsic called or Intrinsic::not_intrinsic if the called function i...
iterator_range< User::op_iterator > args()
Iteration adapter for range-for loops.
bool doesNotReturn() const
Determine if the call cannot return.
LLVM_ABI bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
unsigned arg_size() const
AttributeList getAttributes() const
Return the attributes for this call.
bool hasOperandBundles() const
Return true if this User has any operand bundles.
LLVM_ABI Function * getCaller()
Helper to get the caller (the parent function).
BasicBlock * getIndirectDest(unsigned i) const
unsigned getNumIndirectDests() const
Return the number of callbr indirect dest labels.
bool isMustTailCall() const
static LLVM_ABI bool castIsValid(Instruction::CastOps op, Type *SrcTy, Type *DstTy)
This method can be used to determine if a cast from SrcTy to DstTy using Opcode op is valid or not.
unsigned getNumHandlers() const
return the number of 'handlers' in this catchswitch instruction, except the default handler
Value * getParentPad() const
BasicBlock * getUnwindDest() const
handler_range handlers()
iteration adapter for range-for loops.
BasicBlock * getUnwindDest() const
bool isFPPredicate() const
bool isIntPredicate() const
static bool isIntPredicate(Predicate P)
Value * getCondition() const
bool isMinusOne() const
This function will return true iff every bit in this constant is set to true.
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
unsigned getBitWidth() const
getBitWidth - Return the scalar bitwidth of this constant.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
const APInt & getValue() const
Return the constant as an APInt value reference.
Constant * getAddrDiscriminator() const
The address discriminator if any, or the null constant.
Constant * getPointer() const
The pointer that is signed in this ptrauth signed pointer.
ConstantInt * getKey() const
The Key ID, an i32 constant.
Constant * getDeactivationSymbol() const
ConstantInt * getDiscriminator() const
The integer discriminator, an i64 constant, or 0.
static LLVM_ABI bool isOrderedRanges(ArrayRef< ConstantRange > RangesRef)
This class represents a range of values.
const APInt & getLower() const
Return the lower value for this range.
const APInt & getUpper() const
Return the upper value for this range.
LLVM_ABI bool contains(const APInt &Val) const
Return true if the specified value is in the set.
uint32_t getBitWidth() const
Get the bit width of this ConstantRange.
static LLVM_ABI ConstantTokenNone * get(LLVMContext &Context)
Return the ConstantTokenNone.
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
LLVM_ABI std::optional< fp::ExceptionBehavior > getExceptionBehavior() const
LLVM_ABI std::optional< RoundingMode > getRoundingMode() const
LLVM_ABI unsigned getNonMetadataArgCount() const
DbgVariableFragmentInfo FragmentInfo
@ FixedPointBinary
Scale factor 2^Factor.
@ FixedPointDecimal
Scale factor 10^Factor.
@ FixedPointRational
Arbitrary rational scale factor.
DIGlobalVariable * getVariable() const
DIExpression * getExpression() const
LLVM_ABI DISubprogram * getSubprogram() const
Get the subprogram for this scope.
DILocalScope * getScope() const
Get the local scope for this variable.
Metadata * getRawScope() const
Base class for scope-like contexts.
Subprogram description. Uses SubclassData1.
static const DIScope * getRawRetainedNodeScope(const MDNode *N)
Base class for template parameters.
Base class for variables.
Metadata * getRawType() const
Metadata * getRawScope() const
uint64_t getNumOperands() const
A parsed version of the target data layout string in and methods for querying it.
Records a position in IR for a source label (DILabel).
MDNode * getRawLabel() const
DILabel * getLabel() const
Base class for non-instruction debug metadata records that have positions within IR.
LLVM_ABI void print(raw_ostream &O, bool IsForDebug=false) const
DebugLoc getDebugLoc() const
LLVM_ABI const BasicBlock * getParent() const
LLVM_ABI Function * getFunction()
Record of a variable value-assignment, aka a non instruction representation of the dbg....
LocationType getType() const
MDNode * getRawExpression() const
MDNode * getRawAddressExpression() const
LLVM_ABI Value * getVariableLocationOp(unsigned OpIdx) const
DIExpression * getExpression() const
Metadata * getRawAssignID() const
MDNode * getRawVariable() const
DILocalVariable * getVariable() const
Metadata * getRawLocation() const
Returns the metadata operand for the first location description.
bool isDbgDeclare() const
Metadata * getRawAddress() const
@ End
Marks the end of the concrete types.
@ Any
To indicate all LocationTypes in searches.
DIExpression * getAddressExpression() const
LLVM_ABI MDNode * getAsMDNode() const
Return this as a bar MDNode.
ValueT lookup(const_arg_type_t< KeyT > Val) const
Return the entry for the specified key, or a default constructed value if no such entry exists.
iterator find(const_arg_type_t< KeyT > Val)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
This instruction compares its operands according to the predicate given to the constructor.
This class represents an extension of floating point types.
static bool isSupportedFloatingPointType(Type *Ty)
Returns true if Ty is a supported floating-point type for phi, select, or call FPMathOperators.
This class represents a cast from floating point to signed integer.
This class represents a cast from floating point to unsigned integer.
This class represents a truncation of floating point types.
AtomicOrdering getOrdering() const
Returns the ordering constraint of this fence instruction.
op_range arg_operands()
arg_operands - iteration adapter for range-for loops.
Value * getParentPad() const
Convenience accessors.
FunctionPass class - This class is used to implement most global optimizations.
Type * getReturnType() const
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
DISubprogram * getSubprogram() const
Get the attached subprogram.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
bool hasPersonalityFn() const
Check whether this function has a personality function.
const Function & getFunction() const
const std::string & getGC() const
Type * getReturnType() const
Returns the type of the ret val.
bool isVarArg() const
isVarArg - Return true if this function takes a variable number of arguments.
LLVM_ABI Value * getBasePtr() const
LLVM_ABI Value * getDerivedPtr() const
void visit(const BlockT &BB)
static LLVM_ABI Type * getIndexedType(Type *Ty, ArrayRef< Value * > IdxList)
Returns the result type of a getelementptr with the given source element type and indexes.
static bool isValidLinkage(LinkageTypes L)
const Constant * getAliasee() const
LLVM_ABI const Function * getResolverFunction() const
static bool isValidLinkage(LinkageTypes L)
const Constant * getResolver() const
LLVM_ABI void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
Appends all metadata attached to this value to MDs, sorting by KindID.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this GlobalObject.
bool hasExternalLinkage() const
bool isImplicitDSOLocal() const
LLVM_ABI bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
bool hasValidDeclarationLinkage() const
LinkageTypes getLinkage() const
bool hasDefaultVisibility() const
bool hasPrivateLinkage() const
bool hasHiddenVisibility() const
bool hasExternalWeakLinkage() const
bool hasDLLImportStorageClass() const
bool hasDLLExportStorageClass() const
bool isDeclarationForLinker() const
unsigned getAddressSpace() const
Module * getParent()
Get the module that this global value is contained inside of...
PointerType * getType() const
Global values are always pointers.
LLVM_ABI bool isInterposable() const
Return true if this global's definition can be substituted with an arbitrary definition at link time ...
bool hasCommonLinkage() const
bool hasGlobalUnnamedAddr() const
bool hasAppendingLinkage() const
bool hasAvailableExternallyLinkage() const
Type * getValueType() const
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
bool hasInitializer() const
Definitions have initializers, declarations don't.
MaybeAlign getAlign() const
Returns the alignment of the given variable.
LLVM_ABI uint64_t getGlobalSize(const DataLayout &DL) const
Get the size of this global variable in bytes.
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
bool hasDefinitiveInitializer() const
hasDefinitiveInitializer - Whether the global variable has an initializer, and any other instances of...
This instruction compares its operands according to the predicate given to the constructor.
BasicBlock * getDestination(unsigned i)
Return the specified destination.
unsigned getNumDestinations() const
return the number of possible destinations in this indirectbr instruction.
unsigned getNumSuccessors() const
This instruction inserts a single (scalar) element into a VectorType value.
static LLVM_ABI bool isValidOperands(const Value *Vec, const Value *NewElt, const Value *Idx)
Return true if an insertelement instruction can be formed with the specified operands.
Value * getAggregateOperand()
ArrayRef< unsigned > getIndices() const
Base class for instruction visitors.
void visit(Iterator Start, Iterator End)
LLVM_ABI unsigned getNumSuccessors() const LLVM_READONLY
Return the number of successors that this instruction has.
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 bool isAtomic() const LLVM_READONLY
Return true if this instruction has an AtomicOrdering of unordered or higher.
LLVM_ABI const Function * getFunction() const
Return the function this instruction belongs to.
This class represents a cast from an integer to a pointer.
static LLVM_ABI bool mayLowerToFunctionCall(Intrinsic::ID IID)
Check if the intrinsic might lower into a regular function call in the course of IR transformations.
Intrinsic::ID getIntrinsicID() const
Return the intrinsic ID of this intrinsic.
This is an important class for using LLVM in a threaded context.
@ OB_clang_arc_attachedcall
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.
AtomicOrdering getOrdering() const
Returns the ordering constraint of this load instruction.
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this load instruction.
Align getAlign() const
Return the alignment of the access that is being performed.
const MDOperand & getOperand(unsigned I) const
ArrayRef< MDOperand > operands() const
unsigned getNumOperands() const
Return number of MDNode operands.
bool isResolved() const
Check if node is fully resolved.
LLVMContext & getContext() const
bool equalsStr(StringRef Str) const
LLVM_ABI StringRef getString() const
This class implements a map that also provides access to all stored values in a deterministic order.
Manage lifetime of a slot tracker for printing IR.
A Module instance is used to store all the information related to an LLVM module.
Metadata * getModuleFlag(StringRef Key) const
Return the corresponding value if Key appears in module flags, otherwise return null.
LLVM_ABI StringRef getName() const
LLVM_ABI void print(raw_ostream &ROS, bool IsForDebug=false) const
LLVM_ABI unsigned getNumOperands() const
iterator_range< op_iterator > operands()
op_range incoming_values()
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
This class represents a cast from a pointer to an address (non-capturing ptrtoint).
This class represents a cast from a pointer to an integer.
Value * getValue() const
Convenience accessor.
Value * getReturnValue() const
Convenience accessor. Returns null if there is no return value.
This class represents a sign extension of integer types.
This class represents a cast from signed integer to floating point.
static LLVM_ABI const char * areInvalidOperands(Value *Cond, Value *True, Value *False)
Return a string if the specified operands are invalid for a select operation, otherwise return null.
This instruction constructs a fixed permutation of two input vectors.
static LLVM_ABI bool isValidOperands(const Value *V1, const Value *V2, const Value *Mask)
Return true if a shufflevector instruction can be formed with the specified operands.
static LLVM_ABI void getShuffleMask(const Constant *Mask, SmallVectorImpl< int > &Result)
Convert the input shuffle mask operand to a vector of integers.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
void insert_range(Range &&R)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
void reserve(size_type N)
iterator insert(iterator I, T &&Elt)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
std::pair< StringRef, StringRef > split(char Separator) const
Split into two substrings around the first occurrence of a separator character.
static constexpr size_t npos
bool getAsInteger(unsigned Radix, T &Result) const
Parse the current string as an integer of the specified radix.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
constexpr bool empty() const
Check if the string is empty.
std::pair< typename Base::iterator, bool > insert(StringRef key)
unsigned getNumElements() const
Random access to the elements.
LLVM_ABI Type * getTypeAtIndex(const Value *V) const
Given an index value into the type, return the type of the element.
LLVM_ABI bool isScalableTy(SmallPtrSetImpl< const Type * > &Visited) const
Returns true if this struct contains a scalable vector.
Verify that the TBAA Metadatas are valid.
LLVM_ABI bool visitTBAAMetadata(const Instruction *I, const MDNode *MD)
Visit an instruction, or a TBAA node itself as part of a metadata, and return true if it is valid,...
Triple - Helper class for working with autoconf configuration names.
This class represents a truncation of integer types.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
bool isByteTy() const
True if this is an instance of ByteType.
bool isVectorTy() const
True if this is an instance of VectorType.
LLVM_ABI bool containsNonGlobalTargetExtType(SmallPtrSetImpl< const Type * > &Visited) const
Return true if this type is or contains a target extension type that disallows being used as a global...
bool isArrayTy() const
True if this is an instance of ArrayType.
LLVM_ABI bool containsNonLocalTargetExtType(SmallPtrSetImpl< const Type * > &Visited) const
Return true if this type is or contains a target extension type that disallows being used as a local.
LLVM_ABI bool isScalableTy(SmallPtrSetImpl< const Type * > &Visited) const
Return true if this is a type whose size is a known multiple of vscale.
bool isLabelTy() const
Return true if this is 'label'.
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
bool isPointerTy() const
True if this is an instance of PointerType.
LLVM_ABI bool isTokenLikeTy() const
Returns true if this is 'token' or a token-like target type.s.
LLVM_ABI unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
bool isSingleValueType() const
Return true if the type is a valid type for a register in codegen.
LLVM_ABI bool canLosslesslyBitCastTo(Type *Ty) const
Return true if this type could be converted with a lossless BitCast to type 'Ty'.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
bool isIntOrPtrTy() const
Return true if this is an integer type or a pointer type.
bool isIntegerTy() const
True if this is an instance of IntegerType.
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
bool isVoidTy() const
Return true if this is 'void'.
bool isMetadataTy() const
Return true if this is 'metadata'.
This class represents a cast unsigned integer to floating point.
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
LLVM Value Representation.
iterator_range< user_iterator > materialized_users()
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI const Value * stripPointerCastsAndAliases() const
Strip off pointer casts, all-zero GEPs, address space casts, and aliases.
LLVMContext & getContext() const
All values hold a context through their type.
LLVM_ABI const Value * stripInBoundsOffsets(function_ref< void(const Value *)> Func=[](const Value *) {}) const
Strip off pointer casts and inbounds GEPs.
iterator_range< user_iterator > users()
bool materialized_use_empty() const
LLVM_ABI const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs and address space casts.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
Check a module for errors, and report separate error states for IR and debug info errors.
LLVM_ABI Result run(Module &M, ModuleAnalysisManager &)
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
This class represents zero extension of integer types.
std::pair< iterator, bool > insert(const ValueT &V)
constexpr bool isNonZero() const
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
An efficient, type-erasing, non-owning reference to a callable.
const ParentTy * getParent() const
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
This class implements an extremely fast bulk output stream that can only output to a stream.
This file contains the declaration of the Comdat class, which represents a single COMDAT in LLVM.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ FLAT_ADDRESS
Address space for flat memory.
@ GLOBAL_ADDRESS
Address space for global memory (RAT0, VTX0).
@ PRIVATE_ADDRESS
Address space for private memory.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
bool isFlatGlobalAddrSpace(unsigned AS)
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
@ BasicBlock
Various leaf nodes.
LLVM_ABI bool hasConstrainedFPRoundingModeOperand(ID QID)
Returns true if the intrinsic ID is for one of the "ConstrainedFloating-Point Intrinsics" that take r...
LLVM_ABI StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
static const int NoAliasScopeDeclScopeArg
LLVM_ABI bool isSignatureValid(Intrinsic::ID ID, FunctionType *FT, SmallVectorImpl< Type * > &OverloadTys, raw_ostream &OS=nulls())
Returns true if FT is a valid function type for intrinsic ID.
std::variant< std::monostate, Loc::Single, Loc::Multi, Loc::MMI, Loc::EntryValue > Variant
Alias for the std::variant specialization base class of DbgVariable.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
@ System
Synchronized with respect to all concurrently executing threads.
LLVM_ABI std::optional< VFInfo > tryDemangleForVFABI(StringRef MangledName, const FunctionType *FTy)
Function to construct a VFInfo out of a mangled names in the following format:
@ CE
Windows NT (Windows on ARM)
LLVM_ABI AssignmentInstRange getAssignmentInsts(DIAssignID *ID)
Return a range of instructions (typically just one) that have ID as an attachment.
initializer< Ty > init(const Ty &Val)
@ DW_LLVM_LANG_DIALECT_max
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract_or_null(Y &&MD)
Extract a Value from Metadata, if any, allowing null.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract_or_null(Y &&MD)
Extract a Value from Metadata, allowing null.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > dyn_extract(Y &&MD)
Extract a Value from Metadata, if any.
std::enable_if_t< detail::IsValidPointer< X, Y >::value, X * > extract(Y &&MD)
Extract a Value from Metadata.
@ User
could "use" a pointer
NodeAddr< UseNode * > Use
NodeAddr< NodeBase * > Node
friend class Instruction
Iterator for Instructions in a `BasicBlock.
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.
@ Low
Lower the current thread's priority such that it does not affect foreground tasks significantly.
FunctionAddr VTableAddr Value
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI bool canInstructionHaveMMRAs(const Instruction &I)
detail::zippy< detail::zip_first, T, U, Args... > zip_equal(T &&t, U &&u, Args &&...args)
zip iterator that assumes that all iteratees have the same length.
LLVM_ABI unsigned getBranchWeightOffset(const MDNode *ProfileData)
Return the offset to the first branch weight data.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
BundleAttr getBundleAttrFromOBU(OperandBundleUse OBU)
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI bool verifyFunction(const Function &F, raw_ostream *OS=nullptr)
Check a function for errors, useful for use when debugging a pass.
testing::Matcher< const detail::ErrorHolder & > Failed()
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
LLVM_ABI DenseMap< BasicBlock *, ColorVector > colorEHFunclets(Function &F)
If an EH funclet personality is in use (see isFuncletEHPersonality), this will recompute which blocks...
constexpr bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
gep_type_iterator gep_type_end(const User *GEP)
bool isa_and_nonnull(const Y &Val)
bool isScopedEHPersonality(EHPersonality Pers)
Returns true if this personality uses scope-style EH IR instructions: catchswitch,...
auto dyn_cast_or_null(const Y &Val)
GenericConvergenceVerifier< SSAContext > ConvergenceVerifier
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
bool isModSet(const ModRefInfo MRI)
void sort(IteratorTy Start, IteratorTy End)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isPointerTy(const Type *T)
LLVM_ABI void report_fatal_error(Error Err, bool gen_crash_diag=true)
generic_gep_type_iterator<> gep_type_iterator
FunctionAddr VTableAddr Count
LLVM_ABI EHPersonality classifyEHPersonality(const Value *Pers)
See if the given exception handling personality function is one that we understand.
iterator_range< SplittingIterator > split(StringRef Str, StringRef Separator)
Split the specified string over a separator and return a range-compatible iterable over its partition...
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
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...
LLVM_ABI bool isValueProfileMD(const MDNode *ProfileData)
Checks if an MDNode contains value profiling Metadata.
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
LLVM_ABI raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
LLVM_ABI unsigned getNumBranchWeights(const MDNode &ProfileData)
AtomicOrdering
Atomic ordering for LLVM's memory model.
@ First
Helpers to iterate all locations in the MemoryEffectsBase class.
LLVM_ABI FunctionPass * createVerifierPass(bool FatalErrors=true)
FunctionAddr VTableAddr Next
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
constexpr unsigned BitWidth
TinyPtrVector< BasicBlock * > ColorVector
LLVM_ABI const char * LLVMLoopEstimatedTripCount
Profile-based loop metadata that should be accessed only by using llvm::getLoopEstimatedTripCount and...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI std::optional< RoundingMode > convertStrToRoundingMode(StringRef)
Returns a valid RoundingMode enumerator when given a string that is valid as input in constrained int...
gep_type_iterator gep_type_begin(const User *GEP)
LLVM_ABI std::unique_ptr< GCStrategy > getGCStrategy(const StringRef Name)
Lookup the GCStrategy object associated with the given gc name.
auto predecessors(const MachineBasicBlock *BB)
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
bool pred_empty(const BasicBlock *BB)
bool isHexDigit(char C)
Checks if character C is a hexadecimal numeric character.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
constexpr bool isCallableCC(CallingConv::ID CC)
LLVM_ABI bool verifyModule(const Module &M, raw_ostream *OS=nullptr, bool *BrokenDebugInfo=nullptr)
Check a module for errors.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
constexpr uint64_t value() const
This is a hole in the type system and should not be abused.
A special type used by analysis passes to provide an address that identifies that particular analysis...
static LLVM_ABI const char * SyntheticFunctionEntryCount
static LLVM_ABI const char * UnknownBranchWeightsMarker
static LLVM_ABI const char * ValueProfile
static LLVM_ABI const char * FunctionEntryCount
static LLVM_ABI const char * BranchWeights
uint32_t getTagID() const
Return the tag of this operand bundle as an integer.
void DebugInfoCheckFailed(const Twine &Message)
A debug info check failed.
VerifierSupport(raw_ostream *OS, const Module &M)
bool Broken
Track the brokenness of the module while recursively visiting.
void CheckFailed(const Twine &Message, const T1 &V1, const Ts &... Vs)
A check failed (with values to print).
bool BrokenDebugInfo
Broken debug info can be "recovered" from by stripping the debug info.
bool TreatBrokenDebugInfoAsError
Whether to treat broken debug info as an error.
void CheckFailed(const Twine &Message)
A check failed, so printout out the condition and the message.
void DebugInfoCheckFailed(const Twine &Message, const T1 &V1, const Ts &... Vs)
A debug info check failed (with values to print).