115 using namespace llvm;
134 : OS(OS), M(M), MST(&M), DL(M.getDataLayout()), Context(M.getContext()) {}
137 void Write(
const Module *M) {
141 void Write(
const Value *V) {
146 void Write(
const Value &V) {
147 if (isa<Instruction>(V)) {
159 MD->
print(*OS, MST, &M);
170 NMD->
print(*OS, MST);
174 void Write(
Type *
T) {
186 void Write(
const APInt *AI) {
192 void Write(
const unsigned i) { *OS << i <<
'\n'; }
195 for (
const T &V : Vs)
199 template <
typename T1,
typename... Ts>
200 void WriteTs(
const T1 &V1,
const Ts &... Vs) {
205 template <
typename... Ts>
void WriteTs() {}
214 *OS << Message <<
'\n';
222 template <
typename T1,
typename... Ts>
232 *OS << Message <<
'\n';
234 BrokenDebugInfo =
true;
238 template <
typename T1,
typename... Ts>
273 Type *LandingPadResultTy;
280 bool HasDebugInfo =
false;
316 SawFrameEscape(
false), TBAAVerifyHelper(
this) {
324 "An instance of this class only works with a specific module!");
333 DT.recalculate(const_cast<Function &>(F));
336 if (!BB.empty() && BB.back().isTerminator())
340 *OS <<
"Basic Block in function '" << F.getName()
341 <<
"' does not have terminator!\n";
342 BB.printAsOperand(*OS,
true,
MST);
350 visit(const_cast<Function &>(F));
351 verifySiblingFuncletUnwinds();
352 InstsInThisBlock.
clear();
354 LandingPadResultTy =
nullptr;
355 SawFrameEscape =
false;
356 SiblingFuncletInfo.
clear();
372 verifyFrameRecoverIndices();
374 visitGlobalVariable(GV);
377 visitGlobalAlias(GA);
380 visitNamedMDNode(NMD);
383 visitComdat(SMEC.getValue());
386 visitModuleIdents(M);
387 visitModuleCommandLines(M);
389 verifyCompileUnits();
391 verifyDeoptimizeCallingConvs();
392 DISubprogramAttachments.
clear();
405 void visitMDNode(
const MDNode &MD);
408 void visitComdat(
const Comdat &C);
409 void visitModuleIdents(
const Module &M);
410 void visitModuleCommandLines(
const Module &M);
411 void visitModuleFlags(
const Module &M);
412 void visitModuleFlag(
const MDNode *
Op,
415 void visitModuleFlagCGProfileEntry(
const MDOperand &MDO);
416 void visitFunction(
const Function &F);
421 template <
class Ty>
bool isValidMetadataArray(
const MDTuple &
N);
422 #define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS) void visit##CLASS(const CLASS &N); 423 #include "llvm/IR/Metadata.def" 424 void visitDIScope(
const DIScope &N);
429 void visitTemplateParams(
const MDNode &N,
const Metadata &RawParams);
448 void visitPHINode(
PHINode &PN);
457 void visitVAArgInst(
VAArgInst &VAA) { visitInstruction(VAA); }
463 void verifyDominatesUse(
Instruction &I,
unsigned i);
472 void visitUserOp2(
Instruction &I) { visitUserOp1(I); }
494 void verifySwiftErrorValue(
const Value *SwiftErrorVal);
495 void verifyMustTailCall(
CallInst &CI);
497 unsigned ArgNo, std::string &Suffix);
504 void verifyFunctionMetadata(
ArrayRef<std::pair<unsigned, MDNode *>> MDs);
506 void visitConstantExprsRecursively(
const Constant *EntryC);
509 void verifyFrameRecoverIndices();
510 void verifySiblingFuncletUnwinds();
513 template <
typename ValueOrMetadata>
514 void verifyFragmentExpression(
const DIVariable &V,
516 ValueOrMetadata *Desc);
520 void verifyCompileUnits();
524 void verifyDeoptimizeCallingConvs();
533 #define Assert(C, ...) \ 534 do { if (!(C)) { CheckFailed(__VA_ARGS__); return; } } while (false) 538 #define AssertDI(C, ...) \ 539 do { if (!(C)) { DebugInfoCheckFailed(__VA_ARGS__); return; } } while (false) 553 if (!Visited.
insert(User).second)
556 if (Callback(TheNextUser))
560 void Verifier::visitGlobalValue(
const GlobalValue &GV) {
562 "Global is external, but doesn't have external or weak linkage!", &GV);
565 "huge alignment values are unsupported", &GV);
567 "Only global variables can have appending linkage!", &GV);
572 "Only global arrays can have appending linkage!", GVar);
580 "GlobalValue with DLLImport Storage is dso_local!", &GV);
584 "Global is marked as dllimport, but not external", &GV);
589 "GlobalValue with private or internal linkage must be dso_local!",
594 "GlobalValue with non default visibility must be dso_local!", &GV);
598 if (!
I->getParent() || !
I->getParent()->getParent())
599 CheckFailed(
"Global is referenced by parentless instruction!", &GV, &
M,
601 else if (
I->getParent()->getParent()->getParent() != &
M)
602 CheckFailed(
"Global is referenced in a different module!", &GV, &
M,
I,
603 I->getParent()->getParent(),
604 I->getParent()->getParent()->getParent());
606 }
else if (
const Function *
F = dyn_cast<Function>(V)) {
607 if (
F->getParent() != &
M)
608 CheckFailed(
"Global is used by function in a different module", &GV, &
M,
619 "Global variable initializer type does not match global " 626 "'common' global must have a zero initializer!", &GV);
629 Assert(!GV.
hasComdat(),
"'common' global may not be in a Comdat!", &GV);
634 GV.
getName() ==
"llvm.global_dtors")) {
636 "invalid linkage for intrinsic global variable", &GV);
649 "wrong type for intrinsic global variable", &GV);
653 cast<PointerType>(ETy)->getElementType()->isIntegerTy(8),
654 "wrong type for intrinsic global variable", &GV);
660 GV.
getName() ==
"llvm.compiler.used")) {
662 "invalid linkage for intrinsic global variable", &GV);
664 if (
ArrayType *ATy = dyn_cast<ArrayType>(GVType)) {
666 Assert(PTy,
"wrong type for intrinsic global variable", &GV);
670 Assert(InitArray,
"wrong initalizer for intrinsic global variable",
673 Value *V =
Op->stripPointerCastsNoFollowAliases();
674 Assert(isa<GlobalVariable>(V) || isa<Function>(V) ||
676 "invalid llvm.used member", V);
677 Assert(V->
hasName(),
"members of llvm.used must be named", V);
686 for (
auto *MD : MDs) {
687 if (
auto *GVE = dyn_cast<DIGlobalVariableExpression>(MD))
688 visitDIGlobalVariableExpression(*GVE);
690 AssertDI(
false,
"!dbg attachment of global variable must be a " 691 "DIGlobalVariableExpression");
695 visitGlobalValue(GV);
702 visitGlobalValue(GV);
708 visitAliaseeSubExpr(Visited, GA, C);
713 if (
const auto *GV = dyn_cast<GlobalValue>(&C)) {
717 if (
const auto *GA2 = dyn_cast<GlobalAlias>(GV)) {
718 Assert(Visited.
insert(GA2).second,
"Aliases cannot form a cycle", &GA);
720 Assert(!GA2->isInterposable(),
"Alias cannot point to an interposable alias",
729 if (
const auto *CE = dyn_cast<ConstantExpr>(&C))
730 visitConstantExprsRecursively(CE);
734 if (
const auto *GA2 = dyn_cast<GlobalAlias>(V))
735 visitAliaseeSubExpr(Visited, GA, *GA2->
getAliasee());
736 else if (
const auto *C2 = dyn_cast<Constant>(V))
737 visitAliaseeSubExpr(Visited, GA, *C2);
741 void Verifier::visitGlobalAlias(
const GlobalAlias &GA) {
743 "Alias should have private, internal, linkonce, weak, linkonce_odr, " 744 "weak_odr, or external linkage!",
747 Assert(Aliasee,
"Aliasee cannot be NULL!", &GA);
749 "Alias and aliasee types should match!", &GA);
751 Assert(isa<GlobalValue>(Aliasee) || isa<ConstantExpr>(Aliasee),
752 "Aliasee should be either GlobalValue or ConstantExpr", &GA);
754 visitAliaseeSubExpr(GA, *Aliasee);
756 visitGlobalValue(GA);
759 void Verifier::visitNamedMDNode(
const NamedMDNode &NMD) {
764 "unrecognized named metadata node in the llvm.dbg namespace",
767 if (NMD.
getName() ==
"llvm.dbg.cu")
768 AssertDI(MD && isa<DICompileUnit>(MD),
"invalid compile unit", &NMD, MD);
777 void Verifier::visitMDNode(
const MDNode &MD) {
780 if (!MDNodes.insert(&MD).second)
786 case Metadata::MDTupleKind:
788 #define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS) \ 789 case Metadata::CLASS##Kind: \ 790 visit##CLASS(cast<CLASS>(MD)); \ 792 #include "llvm/IR/Metadata.def" 798 Assert(!isa<LocalAsMetadata>(
Op),
"Invalid operand for global metadata!",
800 if (
auto *
N = dyn_cast<MDNode>(
Op)) {
804 if (
auto *V = dyn_cast<ValueAsMetadata>(
Op)) {
805 visitValueAsMetadata(*V,
nullptr);
818 "Unexpected metadata round-trip through values", &MD, MD.
getValue());
824 Assert(F,
"function-local metadata used outside a function", L);
829 if (
Instruction *
I = dyn_cast<Instruction>(L->getValue())) {
830 Assert(
I->getParent(),
"function-local metadata not in basic block", L,
I);
831 ActualF =
I->getParent()->getParent();
832 }
else if (
BasicBlock *BB = dyn_cast<BasicBlock>(L->getValue()))
834 else if (
Argument *
A = dyn_cast<Argument>(L->getValue()))
835 ActualF =
A->getParent();
836 assert(ActualF &&
"Unimplemented function local metadata case!");
838 Assert(ActualF == F,
"function-local metadata used in wrong function", L);
843 if (
auto *
N = dyn_cast<MDNode>(MD)) {
850 if (!MDNodes.insert(MD).second)
853 if (
auto *V = dyn_cast<ValueAsMetadata>(MD))
854 visitValueAsMetadata(*V, F);
861 void Verifier::visitDILocation(
const DILocation &
N) {
863 "location requires a valid scope", &N, N.
getRawScope());
865 AssertDI(isa<DILocation>(IA),
"inlined-at should be a location", &
N, IA);
867 AssertDI(
SP->isDefinition(),
"scope points into the type hierarchy", &
N);
874 void Verifier::visitDIScope(
const DIScope &N) {
876 AssertDI(isa<DIFile>(F),
"invalid file", &
N,
F);
879 void Verifier::visitDISubrange(
const DISubrange &N) {
880 AssertDI(N.
getTag() == dwarf::DW_TAG_subrange_type,
"invalid tag", &
N);
882 AssertDI(Count,
"Count must either be a signed constant or a DIVariable",
886 "invalid subrange count", &
N);
889 void Verifier::visitDIEnumerator(
const DIEnumerator &N) {
893 void Verifier::visitDIBasicType(
const DIBasicType &N) {
895 N.
getTag() == dwarf::DW_TAG_unspecified_type,
898 "has conflicting flags", &N);
906 N.
getTag() == dwarf::DW_TAG_pointer_type ||
907 N.
getTag() == dwarf::DW_TAG_ptr_to_member_type ||
908 N.
getTag() == dwarf::DW_TAG_reference_type ||
909 N.
getTag() == dwarf::DW_TAG_rvalue_reference_type ||
910 N.
getTag() == dwarf::DW_TAG_const_type ||
911 N.
getTag() == dwarf::DW_TAG_volatile_type ||
912 N.
getTag() == dwarf::DW_TAG_restrict_type ||
913 N.
getTag() == dwarf::DW_TAG_atomic_type ||
914 N.
getTag() == dwarf::DW_TAG_member ||
915 N.
getTag() == dwarf::DW_TAG_inheritance ||
916 N.
getTag() == dwarf::DW_TAG_friend,
918 if (N.
getTag() == dwarf::DW_TAG_ptr_to_member_type) {
919 AssertDI(
isType(N.getRawExtraData()),
"invalid pointer to member type", &N,
920 N.getRawExtraData());
927 if (N.getDWARFAddressSpace()) {
929 N.
getTag() == dwarf::DW_TAG_reference_type,
930 "DWARF address space only applies to pointer or reference types",
937 return ((Flags & DINode::FlagLValueReference) &&
938 (Flags & DINode::FlagRValueReference)) ||
939 ((Flags & DINode::FlagTypePassByValue) &&
940 (Flags & DINode::FlagTypePassByReference));
943 void Verifier::visitTemplateParams(
const MDNode &N,
const Metadata &RawParams) {
945 AssertDI(Params,
"invalid template params", &N, &RawParams);
947 AssertDI(
Op && isa<DITemplateParameter>(
Op),
"invalid template parameter",
957 N.
getTag() == dwarf::DW_TAG_structure_type ||
958 N.
getTag() == dwarf::DW_TAG_union_type ||
959 N.
getTag() == dwarf::DW_TAG_enumeration_type ||
960 N.
getTag() == dwarf::DW_TAG_class_type ||
961 N.
getTag() == dwarf::DW_TAG_variant_part,
973 "invalid reference flags", &N);
978 Elements[0]->getTag() == dwarf::DW_TAG_subrange_type,
979 "invalid vector, expected one element of type subrange", &
N);
983 visitTemplateParams(N, *Params);
985 if (N.
getTag() == dwarf::DW_TAG_class_type ||
986 N.
getTag() == dwarf::DW_TAG_union_type) {
988 "class/union requires a filename", &
N, N.
getFile());
992 AssertDI(isa<DIDerivedType>(
D) && N.
getTag() == dwarf::DW_TAG_variant_part,
993 "discriminator can only appear on variant part");
998 AssertDI(N.
getTag() == dwarf::DW_TAG_subroutine_type,
"invalid tag", &
N);
1000 AssertDI(isa<MDTuple>(Types),
"invalid composite elements", &N, Types);
1002 AssertDI(
isType(Ty),
"invalid subroutine type ref", &N, Types, Ty);
1006 "invalid reference flags", &N);
1009 void Verifier::visitDIFile(
const DIFile &N) {
1013 AssertDI(Checksum->Kind <= DIFile::ChecksumKind::CSK_Last,
1014 "invalid checksum kind", &N);
1016 switch (Checksum->Kind) {
1024 AssertDI(Checksum->Value.size() ==
Size,
"invalid checksum length", &
N);
1026 "invalid checksum", &
N);
1032 AssertDI(N.
getTag() == dwarf::DW_TAG_compile_unit,
"invalid tag", &
N);
1041 verifySourceDebugInfo(N, *N.
getFile());
1044 "invalid emission kind", &N);
1047 AssertDI(isa<MDTuple>(Array),
"invalid enum list", &N, Array);
1049 auto *Enum = dyn_cast_or_null<DICompositeType>(
Op);
1050 AssertDI(Enum && Enum->getTag() == dwarf::DW_TAG_enumeration_type,
1051 "invalid enum type", &
N, N.getEnumTypes(),
Op);
1055 AssertDI(isa<MDTuple>(Array),
"invalid retained type list", &N, Array);
1058 (isa<DISubprogram>(
Op) &&
1059 !cast<DISubprogram>(
Op)->isDefinition())),
1060 "invalid retained type", &N,
Op);
1064 AssertDI(isa<MDTuple>(Array),
"invalid global variable list", &N, Array);
1067 "invalid global variable ref", &N,
Op);
1071 AssertDI(isa<MDTuple>(Array),
"invalid imported entity list", &N, Array);
1073 AssertDI(
Op && isa<DIImportedEntity>(
Op),
"invalid imported entity ref",
1078 AssertDI(isa<MDTuple>(Array),
"invalid macro list", &N, Array);
1080 AssertDI(
Op && isa<DIMacroNode>(
Op),
"invalid macro ref", &N,
Op);
1083 CUVisited.insert(&N);
1086 void Verifier::visitDISubprogram(
const DISubprogram &N) {
1088 AssertDI(
isScope(N.getRawScope()),
"invalid scope", &N, N.getRawScope());
1090 AssertDI(isa<DIFile>(F),
"invalid file", &
N,
F);
1092 AssertDI(N.getLine() == 0,
"line specified with no file", &
N, N.getLine());
1093 if (
auto *
T = N.getRawType())
1094 AssertDI(isa<DISubroutineType>(
T),
"invalid subroutine type", &
N,
T);
1095 AssertDI(
isType(N.getRawContainingType()),
"invalid containing type", &N,
1096 N.getRawContainingType());
1097 if (
auto *Params = N.getRawTemplateParams())
1098 visitTemplateParams(N, *Params);
1099 if (
auto *S = N.getRawDeclaration())
1100 AssertDI(isa<DISubprogram>(S) && !cast<DISubprogram>(S)->isDefinition(),
1101 "invalid subprogram declaration", &
N, S);
1102 if (
auto *RawNode = N.getRawRetainedNodes()) {
1104 AssertDI(Node,
"invalid retained nodes list", &N, RawNode);
1107 "invalid retained nodes, expected DILocalVariable or DILabel",
1112 "invalid reference flags", &N);
1114 auto *
Unit = N.getRawUnit();
1115 if (N.isDefinition()) {
1118 AssertDI(
Unit,
"subprogram definitions must have a compile unit", &N);
1121 verifySourceDebugInfo(*N.getUnit(), *N.
getFile());
1124 AssertDI(!
Unit,
"subprogram declarations must not have a compile unit", &N);
1127 if (
auto *RawThrownTypes = N.getRawThrownTypes()) {
1129 AssertDI(ThrownTypes,
"invalid thrown types list", &N, RawThrownTypes);
1131 AssertDI(
Op && isa<DIType>(
Op),
"invalid thrown type", &
N, ThrownTypes,
1135 if (N.areAllCallsDescribed())
1137 "DIFlagAllCallsDescribed must be attached to a definition");
1141 AssertDI(N.
getTag() == dwarf::DW_TAG_lexical_block,
"invalid tag", &
N);
1145 AssertDI(
SP->isDefinition(),
"scope points into the type hierarchy", &
N);
1149 visitDILexicalBlockBase(N);
1152 "cannot have column info without line info", &
N);
1156 visitDILexicalBlockBase(N);
1159 void Verifier::visitDINamespace(
const DINamespace &N) {
1162 AssertDI(isa<DIScope>(S),
"invalid scope ref", &
N, S);
1165 void Verifier::visitDIMacro(
const DIMacro &N) {
1168 "invalid macinfo type", &
N);
1175 void Verifier::visitDIMacroFile(
const DIMacroFile &N) {
1177 "invalid macinfo type", &
N);
1179 AssertDI(isa<DIFile>(F),
"invalid file", &
N,
F);
1182 AssertDI(isa<MDTuple>(Array),
"invalid macro list", &N, Array);
1184 AssertDI(
Op && isa<DIMacroNode>(
Op),
"invalid macro ref", &N,
Op);
1189 void Verifier::visitDIModule(
const DIModule &N) {
1199 visitDITemplateParameter(N);
1201 AssertDI(N.
getTag() == dwarf::DW_TAG_template_type_parameter,
"invalid tag",
1205 void Verifier::visitDITemplateValueParameter(
1207 visitDITemplateParameter(N);
1210 N.
getTag() == dwarf::DW_TAG_GNU_template_template_param ||
1211 N.
getTag() == dwarf::DW_TAG_GNU_template_parameter_pack,
1215 void Verifier::visitDIVariable(
const DIVariable &N) {
1217 AssertDI(isa<DIScope>(S),
"invalid scope", &
N, S);
1219 AssertDI(isa<DIFile>(F),
"invalid file", &
N,
F);
1231 AssertDI(isa<DIDerivedType>(Member),
1232 "invalid static data member declaration", &N, Member);
1243 "local variable requires a valid scope", &N, N.
getRawScope());
1248 void Verifier::visitDILabel(
const DILabel &N) {
1250 AssertDI(isa<DIScope>(S),
"invalid scope", &
N, S);
1252 AssertDI(isa<DIFile>(F),
"invalid file", &
N,
F);
1256 "label requires a valid scope", &N, N.
getRawScope());
1259 void Verifier::visitDIExpression(
const DIExpression &N) {
1263 void Verifier::visitDIGlobalVariableExpression(
1267 visitDIGlobalVariable(*Var);
1269 visitDIExpression(*Expr);
1270 if (
auto Fragment = Expr->getFragmentInfo())
1271 verifyFragmentExpression(*GVE.
getVariable(), *Fragment, &GVE);
1276 AssertDI(N.
getTag() == dwarf::DW_TAG_APPLE_property,
"invalid tag", &
N);
1280 AssertDI(isa<DIFile>(F),
"invalid file", &
N,
F);
1285 N.
getTag() == dwarf::DW_TAG_imported_declaration,
1288 AssertDI(isa<DIScope>(S),
"invalid scope for imported entity", &
N, S);
1293 void Verifier::visitComdat(
const Comdat &C) {
1301 void Verifier::visitModuleIdents(
const Module &
M) {
1310 "incorrect number of operands in llvm.ident metadata",
N);
1312 (
"invalid value for llvm.ident metadata entry operand" 1313 "(the operand should be a string)"),
1318 void Verifier::visitModuleCommandLines(
const Module &M) {
1328 "incorrect number of operands in llvm.commandline metadata",
N);
1330 (
"invalid value for llvm.commandline metadata entry operand" 1331 "(the operand should be a string)"),
1336 void Verifier::visitModuleFlags(
const Module &M) {
1344 visitModuleFlag(MDN, SeenIDs, Requirements);
1347 for (
const MDNode *Requirement : Requirements) {
1348 const MDString *
Flag = cast<MDString>(Requirement->getOperand(0));
1349 const Metadata *ReqValue = Requirement->getOperand(1);
1353 CheckFailed(
"invalid requirement on flag, flag is not present in module",
1360 "flag does not have the required value"),
1368 Verifier::visitModuleFlag(
const MDNode *
Op,
1374 "incorrect number of operands in module flag",
Op);
1378 mdconst::dyn_extract_or_null<ConstantInt>(Op->
getOperand(0)),
1379 "invalid behavior operand in module flag (expected constant integer)",
1382 "invalid behavior operand in module flag (unexpected constant)",
1386 Assert(ID,
"invalid ID operand in module flag (expected metadata string)",
1399 "invalid value for 'max' module flag (expected constant integer)",
1409 "invalid value for 'require' module flag (expected metadata pair)",
1412 (
"invalid value for 'require' module flag " 1413 "(first value operand should be a string)"),
1426 "invalid value for 'append'-type module flag " 1427 "(expected a metadata node)",
1435 bool Inserted = SeenIDs.
insert(std::make_pair(ID, Op)).second;
1437 "module flag identifiers must be unique (or of 'require' type)", ID);
1440 if (ID->getString() ==
"wchar_size") {
1442 = mdconst::dyn_extract_or_null<ConstantInt>(Op->
getOperand(2));
1443 Assert(Value,
"wchar_size metadata requires constant integer argument");
1446 if (ID->getString() ==
"Linker Options") {
1451 "'Linker Options' named metadata no longer supported");
1454 if (ID->getString() ==
"CG Profile") {
1456 visitModuleFlagCGProfileEntry(MDO);
1460 void Verifier::visitModuleFlagCGProfileEntry(
const MDOperand &MDO) {
1461 auto CheckFunction = [&](
const MDOperand &FuncMDO) {
1465 Assert(F && isa<Function>(F->getValue()),
"expected a Function or null",
1468 auto Node = dyn_cast_or_null<MDNode>(MDO);
1469 Assert(Node && Node->getNumOperands() == 3,
"expected a MDNode triple", MDO);
1470 CheckFunction(Node->getOperand(0));
1471 CheckFunction(Node->getOperand(1));
1472 auto Count = dyn_cast_or_null<ConstantAsMetadata>(Node->getOperand(2));
1473 Assert(Count && Count->getType()->isIntegerTy(),
1474 "expected an integer constant", Node->getOperand(2));
1537 if (
A.isStringAttribute())
1543 "' only applies to functions!",
1549 "' does not apply to functions!",
1563 verifyAttributeTypes(Attrs,
false, V);
1567 unsigned AttrCount = 0;
1573 Assert(AttrCount <= 1,
"Attributes 'byval', 'inalloca', 'inreg', 'nest', " 1574 "and 'sret' are incompatible!",
1580 "'inalloca and readonly' are incompatible!",
1586 "'sret and returned' are incompatible!",
1592 "'zeroext and signext' are incompatible!",
1598 "'readnone and readonly' are incompatible!",
1604 "'readnone and writeonly' are incompatible!",
1610 "'readonly and writeonly' are incompatible!",
1616 "'noinline and alwaysinline' are incompatible!",
1621 "Wrong types for attribute: " +
1625 if (
PointerType *PTy = dyn_cast<PointerType>(Ty)) {
1627 if (!PTy->getElementType()->isSized(&Visited)) {
1630 "Attributes 'byval' and 'inalloca' do not support unsized types!",
1633 if (!isa<PointerType>(PTy->getElementType()))
1635 "Attribute 'swifterror' only applies to parameters " 1636 "with pointer to pointer type!",
1640 "Attribute 'byval' only applies to parameters with pointer type!",
1643 "Attribute 'swifterror' only applies to parameters " 1644 "with pointer type!",
1656 bool SawNest =
false;
1657 bool SawReturned =
false;
1658 bool SawSRet =
false;
1659 bool SawSwiftSelf =
false;
1660 bool SawSwiftError =
false;
1672 "Attributes 'byval', 'inalloca', 'nest', 'sret', 'nocapture', " 1673 "'returned', 'swiftself', and 'swifterror' do not apply to return " 1680 "' does not apply to function returns",
1685 for (
unsigned i = 0, e = FT->
getNumParams(); i != e; ++i) {
1689 verifyParameterAttrs(ArgAttrs, Ty, V);
1692 Assert(!SawNest,
"More than one parameter has attribute nest!", V);
1697 Assert(!SawReturned,
"More than one parameter has attribute returned!",
1700 "Incompatible argument and return types for 'returned' attribute",
1706 Assert(!SawSRet,
"Cannot have multiple 'sret' parameters!", V);
1708 "Attribute 'sret' is not on first or second parameter!", V);
1713 Assert(!SawSwiftSelf,
"Cannot have multiple 'swiftself' parameters!", V);
1714 SawSwiftSelf =
true;
1718 Assert(!SawSwiftError,
"Cannot have multiple 'swifterror' parameters!",
1720 SawSwiftError =
true;
1725 "inalloca isn't on the last parameter!", V);
1736 "Attributes 'readnone and readonly' are incompatible!", V);
1740 "Attributes 'readnone and writeonly' are incompatible!", V);
1744 "Attributes 'readonly and writeonly' are incompatible!", V);
1748 "Attributes 'readnone and inaccessiblemem_or_argmemonly' are " 1754 "Attributes 'readnone and inaccessiblememonly' are incompatible!", V);
1758 "Attributes 'noinline and alwaysinline' are incompatible!", V);
1762 "Attribute 'optnone' requires 'noinline'!", V);
1765 "Attributes 'optsize and optnone' are incompatible!", V);
1768 "Attributes 'minsize and optnone' are incompatible!", V);
1774 "Attribute 'jumptable' requires 'unnamed_addr'", V);
1778 std::pair<unsigned, Optional<unsigned>>
Args =
1783 CheckFailed(
"'allocsize' " + Name +
" argument is out of bounds", V);
1789 " argument must refer to an integer parameter",
1797 if (!CheckParam(
"element size", Args.first))
1800 if (Args.second && !CheckParam(
"number of elements", *Args.second))
1805 void Verifier::verifyFunctionMetadata(
1806 ArrayRef<std::pair<unsigned, MDNode *>> MDs) {
1807 for (
const auto &Pair : MDs) {
1809 MDNode *MD = Pair.second;
1811 "!prof annotations should have no less than 2 operands", MD);
1817 "expected string with name of the !prof annotation", MD);
1820 Assert(ProfName.equals(
"function_entry_count") ||
1821 ProfName.equals(
"synthetic_function_entry_count"),
1822 "first operand should be 'function_entry_count'" 1823 " or 'synthetic_function_entry_count'",
1830 "expected integer argument to function_entry_count", MD);
1835 void Verifier::visitConstantExprsRecursively(
const Constant *EntryC) {
1836 if (!ConstantExprVisited.insert(EntryC).second)
1842 while (!Stack.
empty()) {
1846 if (
const auto *CE = dyn_cast<ConstantExpr>(C))
1847 visitConstantExpr(CE);
1849 if (
const auto *GV = dyn_cast<GlobalValue>(C)) {
1862 if (!ConstantExprVisited.insert(OpC).second)
1869 void Verifier::visitConstantExpr(
const ConstantExpr *CE) {
1870 if (CE->
getOpcode() == Instruction::BitCast)
1873 "Invalid bitcast", CE);
1875 if (CE->
getOpcode() == Instruction::IntToPtr ||
1876 CE->
getOpcode() == Instruction::PtrToInt) {
1877 auto *PtrTy = CE->
getOpcode() == Instruction::IntToPtr
1881 ?
"inttoptr not supported for non-integral pointers" 1882 :
"ptrtoint not supported for non-integral pointers";
1889 bool Verifier::verifyAttributeCount(
AttributeList Attrs,
unsigned Params) {
1896 void Verifier::verifyStatepoint(
const CallBase &
Call) {
1903 "gc.statepoint must read and write all memory to preserve " 1904 "reordering restrictions required by safepoint semantics",
1908 Assert(isa<ConstantInt>(IDV),
"gc.statepoint ID must be a constant integer",
1912 Assert(isa<ConstantInt>(NumPatchBytesV),
1913 "gc.statepoint number of patchable bytes must be a constant integer",
1915 const int64_t NumPatchBytes =
1916 cast<ConstantInt>(NumPatchBytesV)->getSExtValue();
1918 Assert(NumPatchBytes >= 0,
1919 "gc.statepoint number of patchable bytes must be " 1925 Assert(PT && PT->getElementType()->isFunctionTy(),
1926 "gc.statepoint callee must be of function pointer type",
Call, Target);
1927 FunctionType *TargetFuncType = cast<FunctionType>(PT->getElementType());
1930 Assert(isa<ConstantInt>(NumCallArgsV),
1931 "gc.statepoint number of arguments to underlying call " 1932 "must be constant integer",
1934 const int NumCallArgs = cast<ConstantInt>(NumCallArgsV)->getZExtValue();
1936 "gc.statepoint number of arguments to underlying call " 1939 const int NumParams = (int)TargetFuncType->getNumParams();
1940 if (TargetFuncType->isVarArg()) {
1941 Assert(NumCallArgs >= NumParams,
1942 "gc.statepoint mismatch in number of vararg call args", Call);
1945 Assert(TargetFuncType->getReturnType()->isVoidTy(),
1946 "gc.statepoint doesn't support wrapping non-void " 1947 "vararg functions yet",
1950 Assert(NumCallArgs == NumParams,
1951 "gc.statepoint mismatch in number of call args", Call);
1954 Assert(isa<ConstantInt>(FlagsV),
1955 "gc.statepoint flags must be constant integer", Call);
1956 const uint64_t Flags = cast<ConstantInt>(FlagsV)->getZExtValue();
1958 "unknown flag used in gc.statepoint flags argument", Call);
1963 for (
int i = 0; i < NumParams; i++) {
1964 Type *ParamType = TargetFuncType->getParamType(i);
1966 Assert(ArgType == ParamType,
1967 "gc.statepoint call argument does not match wrapped " 1971 if (TargetFuncType->isVarArg()) {
1974 "Attribute 'sret' cannot be used for vararg call arguments!",
1979 const int EndCallArgsInx = 4 + NumCallArgs;
1982 Assert(isa<ConstantInt>(NumTransitionArgsV),
1983 "gc.statepoint number of transition arguments " 1984 "must be constant integer",
1986 const int NumTransitionArgs =
1987 cast<ConstantInt>(NumTransitionArgsV)->getZExtValue();
1988 Assert(NumTransitionArgs >= 0,
1989 "gc.statepoint number of transition arguments must be positive", Call);
1990 const int EndTransitionArgsInx = EndCallArgsInx + 1 + NumTransitionArgs;
1993 Assert(isa<ConstantInt>(NumDeoptArgsV),
1994 "gc.statepoint number of deoptimization arguments " 1995 "must be constant integer",
1997 const int NumDeoptArgs = cast<ConstantInt>(NumDeoptArgsV)->getZExtValue();
1998 Assert(NumDeoptArgs >= 0,
1999 "gc.statepoint number of deoptimization arguments " 2003 const int ExpectedNumArgs =
2004 7 + NumCallArgs + NumTransitionArgs + NumDeoptArgs;
2006 "gc.statepoint too few arguments according to length fields",
Call);
2011 for (
const User *U : Call.
users()) {
2013 Assert(UserCall,
"illegal use of statepoint token", Call, U);
2016 Assert(isa<GCRelocateInst>(UserCall) || isa<GCResultInst>(UserCall),
2017 "gc.result or gc.relocate are the only value uses " 2018 "of a gc.statepoint",
2020 if (isa<GCResultInst>(UserCall)) {
2022 "gc.result connected to wrong gc.statepoint",
Call, UserCall);
2023 }
else if (isa<GCRelocateInst>(Call)) {
2025 "gc.relocate connected to wrong gc.statepoint",
Call, UserCall);
2039 void Verifier::verifyFrameRecoverIndices() {
2040 for (
auto &Counts : FrameEscapeInfo) {
2042 unsigned EscapedObjectCount = Counts.second.first;
2043 unsigned MaxRecoveredIndex = Counts.second.second;
2044 Assert(MaxRecoveredIndex <= EscapedObjectCount,
2045 "all indices passed to llvm.localrecover must be less than the " 2046 "number of arguments passed ot llvm.localescape in the parent " 2054 if (
auto *II = dyn_cast<InvokeInst>(Terminator))
2055 UnwindDest = II->getUnwindDest();
2056 else if (
auto *CSI = dyn_cast<CatchSwitchInst>(Terminator))
2057 UnwindDest = CSI->getUnwindDest();
2059 UnwindDest = cast<CleanupReturnInst>(
Terminator)->getUnwindDest();
2063 void Verifier::verifySiblingFuncletUnwinds() {
2066 for (
const auto &Pair : SiblingFuncletInfo) {
2068 if (Visited.
count(PredPad))
2074 if (Active.
count(SuccPad)) {
2080 Instruction *CycleTerminator = SiblingFuncletInfo[CyclePad];
2081 if (CycleTerminator != CyclePad)
2084 }
while (CyclePad != SuccPad);
2085 Assert(
false,
"EH pads can't handle each other's exceptions",
2089 if (!Visited.
insert(SuccPad).second)
2093 auto TermI = SiblingFuncletInfo.find(PredPad);
2094 if (TermI == SiblingFuncletInfo.end())
2096 Terminator = TermI->second;
2107 void Verifier::visitFunction(
const Function &F) {
2108 visitGlobalValue(F);
2115 "Function context does not match Module context!", &
F);
2119 "# formal arguments must match # of arguments for function type!", &
F,
2121 Assert(F.getReturnType()->isFirstClassType() ||
2122 F.getReturnType()->isVoidTy() || F.getReturnType()->isStructTy(),
2123 "Functions cannot return aggregate values!", &
F);
2125 Assert(!F.hasStructRetAttr() || F.getReturnType()->isVoidTy(),
2126 "Invalid struct return type!", &
F);
2131 "Attribute after last parameter!", &F);
2134 verifyFunctionAttrs(FT, Attrs, &F);
2140 "Attribute 'builtin' can only be applied to a callsite.", &
F);
2145 switch (F.getCallingConv()) {
2151 Assert(F.getReturnType()->isVoidTy(),
2152 "Calling convention requires void return type", &
F);
2159 Assert(!F.hasStructRetAttr(),
2160 "Calling convention does not allow sret", &
F);
2167 Assert(!F.isVarArg(),
"Calling convention does not support varargs or " 2168 "perfect forwarding!",
2173 bool isLLVMdotName = F.getName().size() >= 5 &&
2174 F.getName().substr(0, 5) ==
"llvm.";
2180 "Argument value does not match function argument type!", &
Arg,
2183 "Function arguments must have first-class types!", &
Arg);
2184 if (!isLLVMdotName) {
2186 "Function takes metadata but isn't an intrinsic", &
Arg, &
F);
2188 "Function takes token but isn't an intrinsic", &
Arg, &
F);
2193 verifySwiftErrorValue(&
Arg);
2199 Assert(!F.getReturnType()->isTokenTy(),
2200 "Functions returns a token but isn't an intrinsic", &
F);
2204 F.getAllMetadata(MDs);
2205 assert(F.hasMetadata() != MDs.empty() &&
"Bit out-of-sync");
2206 verifyFunctionMetadata(MDs);
2209 if (F.hasPersonalityFn()) {
2212 Assert(Per->getParent() == F.getParent(),
2213 "Referencing personality function in another module!",
2214 &
F, F.getParent(), Per, Per->getParent());
2217 if (F.isMaterializable()) {
2219 Assert(MDs.empty(),
"unmaterialized function cannot have metadata", &
F,
2220 MDs.empty() ? nullptr : MDs.front().second);
2221 }
else if (F.isDeclaration()) {
2222 for (
const auto &
I : MDs) {
2224 "function declaration may not have a !dbg attachment", &F);
2226 "function declaration may not have a !prof attachment", &F);
2229 visitMDNode(*
I.second);
2231 Assert(!F.hasPersonalityFn(),
2232 "Function declaration shouldn't have a personality routine", &
F);
2236 Assert(!isLLVMdotName,
"llvm intrinsics cannot be defined!", &F);
2239 const BasicBlock *Entry = &F.getEntryBlock();
2241 "Entry block to function must not have predecessors!", Entry);
2246 "blockaddress may not be used with the entry block!", Entry);
2249 unsigned NumDebugAttachments = 0, NumProfAttachments = 0;
2251 for (
const auto &
I : MDs) {
2257 ++NumDebugAttachments;
2259 "function must have a single !dbg attachment", &F,
I.second);
2261 "function !dbg attachment must be a subprogram", &F,
I.second);
2262 auto *
SP = cast<DISubprogram>(
I.second);
2263 const Function *&AttachedTo = DISubprogramAttachments[
SP];
2264 AssertDI(!AttachedTo || AttachedTo == &F,
2265 "DISubprogram attached to more than one function",
SP, &F);
2270 ++NumProfAttachments;
2271 Assert(NumProfAttachments == 1,
2272 "function must have a single !prof attachment", &F,
I.second);
2277 visitMDNode(*
I.second);
2285 if (F.getIntrinsicID() && F.getParent()->isMaterialized()) {
2287 if (F.hasAddressTaken(&U))
2288 Assert(
false,
"Invalid user of intrinsic instruction!", U);
2291 auto *N = F.getSubprogram();
2292 HasDebugInfo = (N !=
nullptr);
2303 for (
auto &
I : BB) {
2307 dyn_cast_or_null<DILocation>(
I.getDebugLoc().getAsMDNode());
2310 if (!Seen.
insert(DL).second)
2314 AssertDI(Parent && isa<DILocalScope>(Parent),
2315 "DILocation's scope must be a DILocalScope", N, &F, &
I, DL,
2318 if (Scope && !Seen.
insert(Scope).second)
2325 if (SP && ((Scope != SP) && !Seen.
insert(SP).second))
2330 "!dbg attachment points at wrong subprogram for function",
N, &
F,
2337 void Verifier::visitBasicBlock(
BasicBlock &BB) {
2338 InstsInThisBlock.clear();
2345 if (isa<PHINode>(BB.
front())) {
2351 Assert(PN.getNumIncomingValues() != 0,
2352 "PHI nodes must have at least one entry. If the block is dead, " 2353 "the PHI should be removed!",
2355 Assert(PN.getNumIncomingValues() == Preds.
size(),
2356 "PHINode should have one entry for each predecessor of its " 2357 "parent basic block!",
2362 Values.
reserve(PN.getNumIncomingValues());
2363 for (
unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i)
2365 std::make_pair(PN.getIncomingBlock(i), PN.getIncomingValue(i)));
2368 for (
unsigned i = 0, e = Values.
size(); i != e; ++i) {
2375 "PHI node has multiple entries for the same basic block with " 2376 "different incoming values!",
2377 &PN, Values[i].
first, Values[i].
second, Values[i - 1].second);
2381 Assert(Values[i].first == Preds[i],
2382 "PHI node entries do not match predecessors!", &PN,
2383 Values[i].first, Preds[i]);
2391 Assert(
I.getParent() == &BB,
"Instruction has bogus parent pointer!");
2398 "Terminator found in the middle of a basic block!", I.
getParent());
2399 visitInstruction(I);
2402 void Verifier::visitBranchInst(
BranchInst &BI) {
2405 "Branch condition is not 'i1' type!", &BI, BI.
getCondition());
2407 visitTerminator(BI);
2410 void Verifier::visitReturnInst(
ReturnInst &RI) {
2415 "Found return instr that returns non-void in Function of void " 2420 "Function return type does not match operand " 2421 "type of return inst!",
2426 visitTerminator(RI);
2434 for (
auto &Case : SI.
cases()) {
2435 Assert(Case.getCaseValue()->getType() == SwitchTy,
2436 "Switch constants must all be same type as switch value!", &
SI);
2438 "Duplicate integer as switch case", &SI, Case.getCaseValue());
2441 visitTerminator(SI);
2446 "Indirectbr operand must have pointer type!", &BI);
2449 "Indirectbr destinations must all have pointer type!", &BI);
2451 visitTerminator(BI);
2454 void Verifier::visitSelectInst(
SelectInst &SI) {
2457 "Invalid operands for select instruction!", &SI);
2460 "Select values must have same type as select instruction!", &
SI);
2461 visitInstruction(SI);
2468 Assert(
false,
"User-defined operators should not live outside of a pass!", &I);
2471 void Verifier::visitTruncInst(
TruncInst &I) {
2483 "trunc source and destination must both be a vector or neither", &
I);
2484 Assert(SrcBitSize > DestBitSize,
"DestTy too big for Trunc", &I);
2486 visitInstruction(I);
2489 void Verifier::visitZExtInst(
ZExtInst &I) {
2498 "zext source and destination must both be a vector or neither", &
I);
2502 Assert(SrcBitSize < DestBitSize,
"Type too small for ZExt", &I);
2504 visitInstruction(I);
2507 void Verifier::visitSExtInst(
SExtInst &I) {
2519 "sext source and destination must both be a vector or neither", &
I);
2520 Assert(SrcBitSize < DestBitSize,
"Type too small for SExt", &I);
2522 visitInstruction(I);
2536 "fptrunc source and destination must both be a vector or neither", &
I);
2537 Assert(SrcBitSize > DestBitSize,
"DestTy too big for FPTrunc", &I);
2539 visitInstruction(I);
2542 void Verifier::visitFPExtInst(
FPExtInst &I) {
2554 "fpext source and destination must both be a vector or neither", &
I);
2555 Assert(SrcBitSize < DestBitSize,
"DestTy too small for FPExt", &I);
2557 visitInstruction(I);
2560 void Verifier::visitUIToFPInst(
UIToFPInst &I) {
2569 "UIToFP source and dest must both be vector or scalar", &I);
2571 "UIToFP source must be integer or integer vector", &
I);
2575 if (SrcVec && DstVec)
2576 Assert(cast<VectorType>(SrcTy)->getNumElements() ==
2577 cast<VectorType>(DestTy)->getNumElements(),
2578 "UIToFP source and dest vector length mismatch", &I);
2580 visitInstruction(I);
2583 void Verifier::visitSIToFPInst(
SIToFPInst &I) {
2592 "SIToFP source and dest must both be vector or scalar", &I);
2594 "SIToFP source must be integer or integer vector", &
I);
2598 if (SrcVec && DstVec)
2599 Assert(cast<VectorType>(SrcTy)->getNumElements() ==
2600 cast<VectorType>(DestTy)->getNumElements(),
2601 "SIToFP source and dest vector length mismatch", &I);
2603 visitInstruction(I);
2606 void Verifier::visitFPToUIInst(
FPToUIInst &I) {
2615 "FPToUI source and dest must both be vector or scalar", &I);
2619 "FPToUI result must be integer or integer vector", &
I);
2621 if (SrcVec && DstVec)
2622 Assert(cast<VectorType>(SrcTy)->getNumElements() ==
2623 cast<VectorType>(DestTy)->getNumElements(),
2624 "FPToUI source and dest vector length mismatch", &I);
2626 visitInstruction(I);
2629 void Verifier::visitFPToSIInst(
FPToSIInst &I) {
2638 "FPToSI source and dest must both be vector or scalar", &I);
2642 "FPToSI result must be integer or integer vector", &
I);
2644 if (SrcVec && DstVec)
2645 Assert(cast<VectorType>(SrcTy)->getNumElements() ==
2646 cast<VectorType>(DestTy)->getNumElements(),
2647 "FPToSI source and dest vector length mismatch", &I);
2649 visitInstruction(I);
2659 if (
auto *PTy = dyn_cast<PointerType>(SrcTy->
getScalarType()))
2661 "ptrtoint not supported for non-integral pointers");
2671 "PtrToInt Vector width mismatch", &
I);
2674 visitInstruction(I);
2683 "IntToPtr source must be an integral", &
I);
2686 if (
auto *PTy = dyn_cast<PointerType>(DestTy->
getScalarType()))
2688 "inttoptr not supported for non-integral pointers");
2696 "IntToPtr Vector width mismatch", &
I);
2698 visitInstruction(I);
2704 "Invalid bitcast", &I);
2705 visitInstruction(I);
2717 "AddrSpaceCast must be between different address spaces", &
I);
2720 "AddrSpaceCast vector pointer number of elements mismatch", &
I);
2721 visitInstruction(I);
2726 void Verifier::visitPHINode(
PHINode &PN) {
2733 "PHI nodes not grouped at top of basic block!", &PN, PN.
getParent());
2742 "PHI node operands are not the same type as the result!", &PN);
2747 visitInstruction(PN);
2750 void Verifier::visitCallBase(
CallBase &Call) {
2752 "Called function must be a pointer!",
Call);
2755 Assert(FPTy->getElementType()->isFunctionTy(),
2756 "Called function is not pointer to function type!",
Call);
2759 "Called function is not the same type as the call!",
Call);
2764 if (FTy->isVarArg())
2766 "Called function requires more parameters than were provided!",
2770 "Incorrect number of arguments passed to called function!",
Call);
2773 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
2775 "Call parameter type does not match function signature!",
2781 "Attribute after last parameter!", Call);
2789 "speculatable attribute may not apply to call sites",
Call);
2793 verifyFunctionAttrs(FTy, Attrs, &Call);
2801 Assert(AI->isUsedWithInAlloca(),
2802 "inalloca argument for call has mismatched alloca", AI,
Call);
2808 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
2812 Assert(AI->isSwiftError(),
2813 "swifterror argument for call has mismatched alloca", AI,
Call);
2818 "swifterror argument should come from an alloca or parameter",
2819 SwiftErrorArg, Call);
2820 Assert(ArgI->hasSwiftErrorAttr(),
2821 "swifterror argument for call has mismatched parameter", ArgI,
2825 if (FTy->isVarArg()) {
2827 bool SawNest =
false;
2828 bool SawReturned =
false;
2830 for (
unsigned Idx = 0; Idx < FTy->getNumParams(); ++Idx) {
2838 for (
unsigned Idx = FTy->getNumParams(); Idx < Call.
arg_size(); ++Idx) {
2841 verifyParameterAttrs(ArgAttrs, Ty, &Call);
2844 Assert(!SawNest,
"More than one parameter has attribute nest!", Call);
2849 Assert(!SawReturned,
"More than one parameter has attribute returned!",
2852 "Incompatible argument and return types for 'returned' " 2864 "Attribute 'sret' cannot be used for vararg call arguments!",
2869 "inalloca isn't on the last argument!",
Call);
2876 for (
Type *ParamTy : FTy->params()) {
2877 Assert(!ParamTy->isMetadataTy(),
2878 "Function has metadata parameter but isn't an intrinsic",
Call);
2879 Assert(!ParamTy->isTokenTy(),
2880 "Function has token parameter but isn't an intrinsic",
Call);
2886 Assert(!FTy->getReturnType()->isTokenTy(),
2887 "Return type cannot be token for indirect call!");
2891 visitIntrinsicCall(
ID, Call);
2895 bool FoundDeoptBundle =
false, FoundFuncletBundle =
false,
2896 FoundGCTransitionBundle =
false;
2901 Assert(!FoundDeoptBundle,
"Multiple deopt operand bundles", Call);
2902 FoundDeoptBundle =
true;
2904 Assert(!FoundGCTransitionBundle,
"Multiple gc-transition operand bundles",
2906 FoundGCTransitionBundle =
true;
2908 Assert(!FoundFuncletBundle,
"Multiple funclet operand bundles", Call);
2909 FoundFuncletBundle =
true;
2911 "Expected exactly one funclet bundle operand",
Call);
2913 "Funclet bundle operands should correspond to a FuncletPadInst",
2924 "inlinable function call in a function with " 2925 "debug info must have a !dbg location",
2928 visitInstruction(Call);
2949 for (
auto AK : ABIAttrs) {
2958 void Verifier::verifyMustTailCall(
CallInst &CI) {
2969 "cannot guarantee tail call due to mismatched parameter counts",
2974 "cannot guarantee tail call due to mismatched parameter types", &CI);
2978 "cannot guarantee tail call due to mismatched varargs", &CI);
2980 "cannot guarantee tail call due to mismatched return types", &CI);
2984 "cannot guarantee tail call due to mismatched calling conv", &CI);
2993 Assert(CallerABIAttrs == CalleeABIAttrs,
2994 "cannot guarantee tail call due to mismatched ABI impacting " 2995 "function attributes",
3003 Value *RetVal = &CI;
3007 if (
BitCastInst *BI = dyn_cast_or_null<BitCastInst>(Next)) {
3009 "bitcast following musttail call must use the call", BI);
3016 Assert(Ret,
"musttail call must precede a ret with an optional bitcast",
3019 "musttail call result must be returned",
Ret);
3022 void Verifier::visitCallInst(
CallInst &CI) {
3026 verifyMustTailCall(CI);
3029 void Verifier::visitInvokeInst(
InvokeInst &II) {
3036 "The unwind destination does not have an exception handling instruction!",
3039 visitTerminator(II);
3046 "Unary operators must have same type for" 3047 "operands and result!",
3053 case Instruction::FNeg:
3055 "FNeg operator only works with float types!", &U);
3061 visitInstruction(U);
3069 "Both operands to a binary operator are not of the same type!", &
B);
3075 case Instruction::Sub:
3076 case Instruction::Mul:
3077 case Instruction::SDiv:
3078 case Instruction::UDiv:
3079 case Instruction::SRem:
3080 case Instruction::URem:
3082 "Integer arithmetic operators only work with integral types!", &
B);
3084 "Integer arithmetic operators must have same type " 3085 "for operands and result!",
3090 case Instruction::FAdd:
3091 case Instruction::FSub:
3092 case Instruction::FMul:
3093 case Instruction::FDiv:
3094 case Instruction::FRem:
3096 "Floating-point arithmetic operators only work with " 3097 "floating-point types!",
3100 "Floating-point arithmetic operators must have same type " 3101 "for operands and result!",
3105 case Instruction::And:
3106 case Instruction::Or:
3107 case Instruction::Xor:
3109 "Logical operators only work with integral types!", &
B);
3111 "Logical operators must have same type for operands and result!",
3114 case Instruction::Shl:
3115 case Instruction::LShr:
3116 case Instruction::AShr:
3118 "Shifts only work with integral types!", &
B);
3120 "Shift return type must be same as operands!", &
B);
3126 visitInstruction(B);
3129 void Verifier::visitICmpInst(
ICmpInst &IC) {
3134 "Both operands to ICmp instruction are not of the same type!", &IC);
3137 "Invalid operand types for ICmp instruction", &IC);
3140 "Invalid predicate in ICmp instruction!", &IC);
3142 visitInstruction(IC);
3150 "Both operands to FCmp instruction are not of the same type!", &FC);
3153 "Invalid operand types for FCmp instruction", &
FC);
3156 "Invalid predicate in FCmp instruction!", &
FC);
3158 visitInstruction(FC);
3164 "Invalid extractelement operands!", &EI);
3165 visitInstruction(EI);
3171 "Invalid insertelement operands!", &IE);
3172 visitInstruction(IE);
3178 "Invalid shufflevector operands!", &SV);
3179 visitInstruction(SV);
3185 Assert(isa<PointerType>(TargetTy),
3186 "GEP base pointer is not a vector or a vector of pointers", &GEP);
3192 "GEP indexes must be integers", &GEP);
3195 Assert(ElTy,
"Invalid indices for GEP pointer type!", &GEP);
3199 "GEP is not of right type for indices!", &
GEP, ElTy);
3201 if (GEP.getType()->isVectorTy()) {
3203 unsigned GEPWidth = GEP.getType()->getVectorNumElements();
3204 if (GEP.getPointerOperandType()->isVectorTy())
3205 Assert(GEPWidth == GEP.getPointerOperandType()->getVectorNumElements(),
3206 "Vector GEP result width doesn't match operand's", &
GEP);
3207 for (
Value *Idx : Idxs) {
3208 Type *IndexTy = Idx->getType();
3211 Assert(IndexWidth == GEPWidth,
"Invalid GEP index vector width", &GEP);
3214 "All GEP indices should be of integer type");
3218 if (
auto *PTy = dyn_cast<PointerType>(GEP.getType())) {
3219 Assert(GEP.getAddressSpace() == PTy->getAddressSpace(),
3220 "GEP address space doesn't match type", &
GEP);
3223 visitInstruction(GEP);
3232 "precondition violation");
3235 Assert(NumOperands % 2 == 0,
"Unfinished range!", Range);
3236 unsigned NumRanges = NumOperands / 2;
3237 Assert(NumRanges >= 1,
"It should have at least one range!", Range);
3240 for (
unsigned i = 0; i < NumRanges; ++i) {
3242 mdconst::dyn_extract<ConstantInt>(Range->
getOperand(2 * i));
3243 Assert(Low,
"The lower limit must be an integer!", Low);
3245 mdconst::dyn_extract<ConstantInt>(Range->
getOperand(2 * i + 1));
3246 Assert(High,
"The upper limit must be an integer!", High);
3248 "Range types must match instruction type!", &
I);
3254 "Range must not be empty!", Range);
3257 "Intervals are overlapping", Range);
3265 if (NumRanges > 2) {
3267 mdconst::dyn_extract<ConstantInt>(Range->
getOperand(0))->getValue();
3269 mdconst::dyn_extract<ConstantInt>(Range->
getOperand(1))->getValue();
3272 "Intervals are overlapping", Range);
3278 void Verifier::checkAtomicMemAccessSize(
Type *Ty,
const Instruction *I) {
3280 Assert(Size >= 8,
"atomic memory access' size must be byte-sized", Ty, I);
3281 Assert(!(Size & (Size - 1)),
3282 "atomic memory access' operand must have a power-of-two size", Ty, I);
3285 void Verifier::visitLoadInst(
LoadInst &LI) {
3287 Assert(PTy,
"Load operand must be a pointer.", &LI);
3290 "huge alignment values are unsupported", &LI);
3291 Assert(ElTy->
isSized(),
"loading unsized types is not allowed", &LI);
3295 "Load cannot have Release ordering", &LI);
3297 "Atomic load must specify explicit alignment", &LI);
3299 "atomic load operand must have integer, pointer, or floating point " 3302 checkAtomicMemAccessSize(ElTy, &LI);
3305 "Non-atomic load cannot have SynchronizationScope specified", &LI);
3308 visitInstruction(LI);
3311 void Verifier::visitStoreInst(
StoreInst &SI) {
3313 Assert(PTy,
"Store operand must be a pointer.", &SI);
3316 "Stored value type does not match pointer operand type!", &
SI, ElTy);
3318 "huge alignment values are unsupported", &
SI);
3323 "Store cannot have Acquire ordering", &
SI);
3325 "Atomic store must specify explicit alignment", &
SI);
3327 "atomic store operand must have integer, pointer, or floating point " 3330 checkAtomicMemAccessSize(ElTy, &SI);
3333 "Non-atomic store cannot have SynchronizationScope specified", &
SI);
3335 visitInstruction(SI);
3339 void Verifier::verifySwiftErrorCall(
CallBase &Call,
3340 const Value *SwiftErrorVal) {
3343 if (*I == SwiftErrorVal) {
3345 "swifterror value when used in a callsite should be marked " 3346 "with swifterror attribute",
3347 SwiftErrorVal,
Call);
3352 void Verifier::verifySwiftErrorValue(
const Value *SwiftErrorVal) {
3355 for (
const User *U : SwiftErrorVal->
users()) {
3356 Assert(isa<LoadInst>(U) || isa<StoreInst>(U) || isa<CallInst>(U) ||
3358 "swifterror value can only be loaded and stored from, or " 3359 "as a swifterror argument!",
3362 if (
auto StoreI = dyn_cast<StoreInst>(U))
3363 Assert(StoreI->getOperand(1) == SwiftErrorVal,
3364 "swifterror value should be the second operand when used " 3365 "by stores", SwiftErrorVal, U);
3366 if (
auto *Call = dyn_cast<CallBase>(U))
3367 verifySwiftErrorCall(*const_cast<CallBase *>(Call), SwiftErrorVal);
3371 void Verifier::visitAllocaInst(
AllocaInst &AI) {
3376 "Allocation instruction pointer not in the stack address space!",
3379 "Cannot allocate unsized type", &AI);
3381 "Alloca array size must have integer type", &AI);
3383 "huge alignment values are unsupported", &AI);
3386 verifySwiftErrorValue(&AI);
3389 visitInstruction(AI);
3396 "cmpxchg instructions must be atomic.", &CXI);
3398 "cmpxchg instructions must be atomic.", &CXI);
3400 "cmpxchg instructions cannot be unordered.", &CXI);
3402 "cmpxchg instructions cannot be unordered.", &CXI);
3404 "cmpxchg instructions failure argument shall be no stronger than the " 3409 "cmpxchg failure ordering cannot include release semantics", &CXI);
3412 Assert(PTy,
"First cmpxchg operand must be a pointer.", &CXI);
3413 Type *ElTy = PTy->getElementType();
3415 "cmpxchg operand must have integer or pointer type", ElTy, &CXI);
3416 checkAtomicMemAccessSize(ElTy, &CXI);
3418 "Expected value type does not match pointer operand type!", &CXI,
3421 "Stored value type does not match pointer operand type!", &CXI, ElTy);
3422 visitInstruction(CXI);
3427 "atomicrmw instructions must be atomic.", &RMWI);
3429 "atomicrmw instructions cannot be unordered.", &RMWI);
3432 Assert(PTy,
"First atomicrmw operand must be a pointer.", &RMWI);
3436 " operand must have integer type!",
3438 checkAtomicMemAccessSize(ElTy, &RMWI);
3440 "Argument value type does not match pointer operand type!", &RMWI,
3443 "Invalid binary operation!", &RMWI);
3444 visitInstruction(RMWI);
3447 void Verifier::visitFenceInst(
FenceInst &FI) {
3453 "fence instructions may only have acquire, release, acq_rel, or " 3454 "seq_cst ordering.",
3456 visitInstruction(FI);
3462 "Invalid ExtractValueInst operands!", &EVI);
3464 visitInstruction(EVI);
3471 "Invalid InsertValueInst operands!", &IVI);
3473 visitInstruction(IVI);
3477 if (
auto *FPI = dyn_cast<FuncletPadInst>(EHPad))
3478 return FPI->getParentPad();
3483 void Verifier::visitEHPadPredecessors(
Instruction &I) {
3491 if (
auto *LPI = dyn_cast<LandingPadInst>(&I)) {
3498 "Block containing LandingPadInst must be jumped to " 3499 "only by the unwind edge of an invoke.",
3504 if (
auto *CPI = dyn_cast<CatchPadInst>(&I)) {
3506 Assert(BB->getUniquePredecessor() == CPI->getCatchSwitch()->getParent(),
3507 "Block containg CatchPadInst must be jumped to " 3508 "only by its catchswitch.",
3510 Assert(BB != CPI->getCatchSwitch()->getUnwindDest(),
3511 "Catchswitch cannot unwind to one of its catchpads",
3512 CPI->getCatchSwitch(), CPI);
3523 if (
auto *II = dyn_cast<InvokeInst>(TI)) {
3525 "EH pad must be jumped to via an unwind edge", ToPad, II);
3527 FromPad = Bundle->Inputs[0];
3530 }
else if (
auto *CRI = dyn_cast<CleanupReturnInst>(TI)) {
3531 FromPad = CRI->getOperand(0);
3532 Assert(FromPad != ToPadParent,
"A cleanupret must exit its cleanup", CRI);
3533 }
else if (
auto *CSI = dyn_cast<CatchSwitchInst>(TI)) {
3536 Assert(
false,
"EH pad must be jumped to via an unwind edge", ToPad, TI);
3543 "EH pad cannot handle exceptions raised within it", FromPad, TI);
3544 if (FromPad == ToPadParent) {
3548 Assert(!isa<ConstantTokenNone>(FromPad),
3549 "A single unwind edge may only enter one EH pad", TI);
3551 "EH pad jumps through a cycle of pads", FromPad);
3560 "LandingPadInst needs at least one clause or to be a cleanup.", &LPI);
3562 visitEHPadPredecessors(LPI);
3564 if (!LandingPadResultTy)
3565 LandingPadResultTy = LPI.
getType();
3568 "The landingpad instruction should have a consistent result type " 3569 "inside a function.",
3573 Assert(F->hasPersonalityFn(),
3574 "LandingPadInst needs to be in a function with a personality.", &LPI);
3579 "LandingPadInst not the first non-PHI instruction in the block.",
3586 "Catch operand does not have pointer type!", &LPI);
3588 Assert(LPI.
isFilter(i),
"Clause is neither catch nor filter!", &LPI);
3589 Assert(isa<ConstantArray>(Clause) || isa<ConstantAggregateZero>(Clause),
3590 "Filter operand is not an array of constants!", &LPI);
3594 visitInstruction(LPI);
3597 void Verifier::visitResumeInst(
ResumeInst &RI) {
3599 "ResumeInst needs to be in a function with a personality.", &RI);
3601 if (!LandingPadResultTy)
3605 "The resume instruction should have a consistent result type " 3606 "inside a function.",
3609 visitTerminator(RI);
3617 "CatchPadInst needs to be in a function with a personality.", &CPI);
3620 "CatchPadInst needs to be directly nested in a CatchSwitchInst.",
3626 "CatchPadInst not the first non-PHI instruction in the block.", &CPI);
3628 visitEHPadPredecessors(CPI);
3629 visitFuncletPadInst(CPI);
3634 "CatchReturnInst needs to be provided a CatchPad", &CatchReturn,
3637 visitTerminator(CatchReturn);
3645 "CleanupPadInst needs to be in a function with a personality.", &CPI);
3650 "CleanupPadInst not the first non-PHI instruction in the block.",
3654 Assert(isa<ConstantTokenNone>(ParentPad) || isa<FuncletPadInst>(ParentPad),
3655 "CleanupPadInst has an invalid parent.", &CPI);
3657 visitEHPadPredecessors(CPI);
3658 visitFuncletPadInst(CPI);
3662 User *FirstUser =
nullptr;
3663 Value *FirstUnwindPad =
nullptr;
3667 while (!Worklist.empty()) {
3670 "FuncletPadInst must not be nested within itself", CurrentPad);
3671 Value *UnresolvedAncestorPad =
nullptr;
3672 for (User *U : CurrentPad->
users()) {
3674 if (
auto *CRI = dyn_cast<CleanupReturnInst>(U)) {
3675 UnwindDest = CRI->getUnwindDest();
3676 }
else if (
auto *CSI = dyn_cast<CatchSwitchInst>(U)) {
3681 if (CSI->unwindsToCaller())
3683 UnwindDest = CSI->getUnwindDest();
3684 }
else if (
auto *II = dyn_cast<InvokeInst>(U)) {
3686 }
else if (isa<CallInst>(U)) {
3691 }
else if (
auto *CPI = dyn_cast<CleanupPadInst>(U)) {
3695 Worklist.push_back(CPI);
3698 Assert(isa<CatchReturnInst>(U),
"Bogus funclet pad use", U);
3706 if (!cast<Instruction>(UnwindPad)->isEHPad())
3710 if (UnwindParent == CurrentPad)
3716 Value *ExitedPad = CurrentPad;
3719 if (ExitedPad == &FPI) {
3724 UnresolvedAncestorPad = &FPI;
3728 if (ExitedParent == UnwindParent) {
3732 UnresolvedAncestorPad = ExitedParent;
3735 ExitedPad = ExitedParent;
3736 }
while (!isa<ConstantTokenNone>(ExitedPad));
3741 UnresolvedAncestorPad = &FPI;
3748 Assert(UnwindPad == FirstUnwindPad,
"Unwind edges out of a funclet " 3749 "pad must have the same unwind " 3751 &FPI, U, FirstUser);
3754 FirstUnwindPad = UnwindPad;
3756 if (isa<CleanupPadInst>(&FPI) && !isa<ConstantTokenNone>(UnwindPad) &&
3758 SiblingFuncletInfo[&FPI] = cast<Instruction>(U);
3763 if (CurrentPad != &FPI)
3766 if (UnresolvedAncestorPad) {
3767 if (CurrentPad == UnresolvedAncestorPad) {
3771 assert(CurrentPad == &FPI);
3779 Value *ResolvedPad = CurrentPad;
3780 while (!Worklist.empty()) {
3781 Value *UnclePad = Worklist.back();
3785 while (ResolvedPad != AncestorPad) {
3787 if (ResolvedParent == UnresolvedAncestorPad) {
3790 ResolvedPad = ResolvedParent;
3794 if (ResolvedPad != AncestorPad)
3797 Worklist.pop_back();
3802 if (FirstUnwindPad) {
3803 if (
auto *CatchSwitch = dyn_cast<CatchSwitchInst>(FPI.
getParentPad())) {
3804 BasicBlock *SwitchUnwindDest = CatchSwitch->getUnwindDest();
3805 Value *SwitchUnwindPad;
3806 if (SwitchUnwindDest)
3810 Assert(SwitchUnwindPad == FirstUnwindPad,
3811 "Unwind edges out of a catch must have the same unwind dest as " 3812 "the parent catchswitch",
3813 &FPI, FirstUser, CatchSwitch);
3817 visitInstruction(FPI);
3825 "CatchSwitchInst needs to be in a function with a personality.",
3831 "CatchSwitchInst not the first non-PHI instruction in the block.",
3835 Assert(isa<ConstantTokenNone>(ParentPad) || isa<FuncletPadInst>(ParentPad),
3836 "CatchSwitchInst has an invalid parent.", ParentPad);
3841 "CatchSwitchInst must unwind to an EH block which is not a " 3847 SiblingFuncletInfo[&CatchSwitch] = &CatchSwitch;
3851 "CatchSwitchInst cannot have empty handler list", &CatchSwitch);
3854 Assert(isa<CatchPadInst>(Handler->getFirstNonPHI()),
3855 "CatchSwitchInst handlers must be catchpads", &CatchSwitch, Handler);
3858 visitEHPadPredecessors(CatchSwitch);
3859 visitTerminator(CatchSwitch);
3864 "CleanupReturnInst needs to be provided a CleanupPad", &CRI,
3870 "CleanupReturnInst must unwind to an EH block which is not a " 3875 visitTerminator(CRI);
3878 void Verifier::verifyDominatesUse(
Instruction &I,
unsigned i) {
3883 if (
InvokeInst *II = dyn_cast<InvokeInst>(Op)) {
3895 if (!isa<PHINode>(I) && InstsInThisBlock.count(Op))
3899 Assert(DT.dominates(Op, U),
3900 "Instruction does not dominate all uses!",
Op, &
I);
3905 "apply only to pointer types", &
I);
3907 "dereferenceable, dereferenceable_or_null apply only to load" 3908 " instructions, use attributes for calls or invokes", &I);
3910 "take one operand!", &
I);
3912 Assert(CI && CI->getType()->isIntegerTy(64),
"dereferenceable, " 3913 "dereferenceable_or_null metadata value must be an i64!", &
I);
3920 Assert(BB,
"Instruction not embedded in basic block!", &I);
3922 if (!isa<PHINode>(I)) {
3923 for (User *U : I.
users()) {
3924 Assert(U != (User *)&I || !DT.isReachableFromEntry(BB),
3925 "Only PHI nodes may reference their own value!", &
I);
3931 "Instruction has a name, but provides a void value!", &
I);
3936 "Instruction returns a non-scalar type!", &
I);
3941 "Invalid use of metadata!", &
I);
3947 if (
Instruction *Used = dyn_cast<Instruction>(U.getUser()))
3948 Assert(Used->getParent() !=
nullptr,
3949 "Instruction referencing" 3950 " instruction not embedded in a basic block!",
3953 CheckFailed(
"Use of instruction is not an instruction!", U);
3968 Assert(
false,
"Instruction operands must be first-class values!", &I);
3976 "Cannot take the address of an intrinsic!", &I);
3985 "Cannot invoke an intrinsic other than donothing, patchpoint, " 3986 "statepoint, coro_resume or coro_destroy",
3989 &
I, &
M,
F, F->getParent());
3992 "Referring to a basic block in another function!", &
I);
3995 "Referring to an argument in another function!", &
I);
3999 }
else if (isa<Instruction>(I.
getOperand(i))) {
4000 verifyDominatesUse(I, i);
4001 }
else if (isa<InlineAsm>(I.
getOperand(i))) {
4003 "Cannot take the address of an inline asm!", &
I);
4011 visitConstantExprsRecursively(CE);
4018 "fpmath requires a floating point result!", &
I);
4021 mdconst::dyn_extract_or_null<ConstantFP>(MD->
getOperand(0))) {
4022 const APFloat &Accuracy = CFP0->getValueAPF();
4024 "fpmath accuracy must have float type", &
I);
4026 "fpmath accuracy not a positive number!", &
I);
4028 Assert(
false,
"invalid fpmath accuracy!", &I);
4033 Assert(isa<LoadInst>(I) || isa<CallInst>(I) || isa<InvokeInst>(I),
4034 "Ranges are only for loads, calls and invokes!", &I);
4035 visitRangeMetadata(I, Range, I.
getType());
4042 "nonnull applies only to load instructions, use attributes" 4043 " for calls or invokes",
4048 visitDereferenceableMetadata(I, MD);
4051 visitDereferenceableMetadata(I, MD);
4054 TBAAVerifyHelper.visitTBAAMetadata(I, TBAA);
4059 Assert(isa<LoadInst>(I),
"align applies only to load instructions, " 4060 "use attributes for calls or invokes", &I);
4061 Assert(AlignMD->getNumOperands() == 1,
"align takes one operand!", &
I);
4062 ConstantInt *CI = mdconst::dyn_extract<ConstantInt>(AlignMD->getOperand(0));
4063 Assert(CI && CI->getType()->isIntegerTy(64),
4064 "align metadata value must be an i64!", &
I);
4065 uint64_t
Align = CI->getZExtValue();
4067 "align metadata value must be a power of 2!", &I);
4069 "alignment is larger that implementation defined limit", &I);
4073 AssertDI(isa<DILocation>(N),
"invalid !dbg metadata attachment", &I, N);
4077 if (
auto *DII = dyn_cast<DbgVariableIntrinsic>(&I))
4078 verifyFragmentExpression(*DII);
4080 InstsInThisBlock.insert(&I);
4101 "Intrinsic has incorrect return type!", IF);
4102 for (
unsigned i = 0, e = IFTy->getNumParams(); i != e; ++i)
4105 "Intrinsic has incorrect argument type!", IF);
4110 "Intrinsic was not defined with variable arguments!", IF);
4113 "Callsite was not defined with variable arguments!", IF);
4116 Assert(TableRef.
empty(),
"Intrinsic has too few arguments!",
IF);
4124 "Intrinsic name not mangled correctly for type arguments! " 4132 if (
auto *MD = dyn_cast<MetadataAsValue>(V))
4133 visitMetadataAsValue(*MD, Call.
getCaller());
4140 if (isa<ConstantPointerNull>(InfoArg))
4144 "info argument of llvm.coro.begin must refer to an initialized " 4147 Assert(isa<ConstantStruct>(Init) || isa<ConstantArray>(Init),
4148 "info argument of llvm.coro.begin must refer to either a struct or " 4155 "is_zero_undef argument of bit counting intrinsics must be a " 4183 visitConstrainedFPIntrinsic(cast<ConstrainedFPIntrinsic>(Call));
4187 "invalid llvm.dbg.declare intrinsic call 1", Call);
4188 visitDbgIntrinsic(
"declare", cast<DbgVariableIntrinsic>(Call));
4191 visitDbgIntrinsic(
"addr", cast<DbgVariableIntrinsic>(Call));
4194 visitDbgIntrinsic(
"value", cast<DbgVariableIntrinsic>(Call));
4197 visitDbgLabelIntrinsic(
"label", cast<DbgLabelInst>(Call));
4202 const auto *
MI = cast<MemIntrinsic>(&
Call);
4203 auto IsValidAlignment = [&](
unsigned Alignment) ->
bool {
4206 Assert(IsValidAlignment(
MI->getDestAlignment()),
4207 "alignment of arg 0 of memory intrinsic must be 0 or a power of 2",
4209 if (
const auto *MTI = dyn_cast<MemTransferInst>(
MI)) {
4210 Assert(IsValidAlignment(MTI->getSourceAlignment()),
4211 "alignment of arg 1 of memory intrinsic must be 0 or a power of 2",
4215 "isvolatile argument of memory intrinsics must be a constant int",
4222 const auto *AMI = cast<AtomicMemIntrinsic>(&
Call);
4227 "element size of the element-wise unordered atomic memory " 4228 "intrinsic must be a constant int",
4230 const APInt &ElementSizeVal = ElementSizeCI->getValue();
4232 "element size of the element-wise atomic memory intrinsic " 4233 "must be a power of 2",
4236 if (
auto *LengthCI = dyn_cast<ConstantInt>(AMI->getLength())) {
4237 uint64_t Length = LengthCI->getZExtValue();
4238 uint64_t ElementSize = AMI->getElementSizeInBytes();
4239 Assert((Length % ElementSize) == 0,
4240 "constant length must be a multiple of the element size in the " 4241 "element-wise atomic memory intrinsic",
4245 auto IsValidAlignment = [&](uint64_t Alignment) {
4248 uint64_t DstAlignment = AMI->getDestAlignment();
4249 Assert(IsValidAlignment(DstAlignment),
4250 "incorrect alignment of the destination argument", Call);
4251 if (
const auto *AMT = dyn_cast<AtomicMemTransferInst>(AMI)) {
4252 uint64_t SrcAlignment = AMT->getSourceAlignment();
4253 Assert(IsValidAlignment(SrcAlignment),
4254 "incorrect alignment of the source argument", Call);
4264 Assert(AI,
"llvm.gcroot parameter #1 must be an alloca.", Call);
4266 "llvm.gcroot parameter #2 must be a constant.", Call);
4269 "llvm.gcroot parameter #1 must either be a pointer alloca, " 4270 "or argument #2 must be a non-null constant.",
4276 "Enclosing function does not use GC.",
Call);
4280 "llvm.init_trampoline parameter #2 must resolve to a function.",
4286 cast<ConstantInt>(Call.
getArgOperand(1))->getZExtValue() < 2 &&
4287 cast<ConstantInt>(Call.
getArgOperand(2))->getZExtValue() < 4,
4288 "invalid arguments to llvm.prefetch",
Call);
4292 "llvm.stackprotector parameter #2 must resolve to an alloca.", Call);
4298 "size argument of memory use markers must be a constant integer",
4303 "llvm.invariant.end parameter #2 must be a constant integer", Call);
4309 "llvm.localescape used outside of entry block",
Call);
4311 "multiple calls to llvm.localescape in one function", Call);
4313 if (isa<ConstantPointerNull>(
Arg))
4317 "llvm.localescape only accepts static allocas",
Call);
4320 SawFrameEscape =
true;
4327 "llvm.localrecover first " 4328 "argument must be function defined in this module",
4331 Assert(IdxArg,
"idx argument of llvm.localrecover must be a constant int",
4333 auto &Entry = FrameEscapeInfo[Fn];
4335 std::max(uint64_t(Entry.second), IdxArg->getLimitedValue(~0U) + 1));
4340 if (
auto *CI = dyn_cast<CallInst>(&Call))
4342 "gc.statepoint support for inline assembly unimplemented", CI);
4344 "Enclosing function does not use GC.",
Call);
4346 verifyStatepoint(Call);
4350 "Enclosing function does not use GC.",
Call);
4354 StatepointCall ? StatepointCall->getCalledFunction() :
nullptr;
4355 Assert(StatepointFn && StatepointFn->isDeclaration() &&
4356 StatepointFn->getIntrinsicID() ==
4358 "gc.result operand #1 must be from a statepoint",
Call,
4359 Call.getArgOperand(0));
4362 const Value *
Target = StatepointCall->getArgOperand(2);
4363 auto *PT = cast<PointerType>(Target->getType());
4364 auto *TargetFuncType = cast<FunctionType>(PT->getElementType());
4365 Assert(Call.getType() == TargetFuncType->getReturnType(),
4366 "gc.result result type does not match wrapped callee",
Call);
4373 "gc.relocate must return a pointer or a vector of pointers", Call);
4382 LandingPad->
getParent()->getUniquePredecessor();
4386 Assert(InvokeBB,
"safepoints should have unique landingpads",
4391 "gc relocate should be linked to a statepoint", InvokeBB);
4398 "gc relocate is incorrectly tied to the statepoint", Call, Token);
4403 *cast<CallBase>(cast<GCRelocateInst>(
Call).getStatepoint());
4407 Assert(isa<ConstantInt>(Base),
4408 "gc.relocate operand #2 must be integer offset", Call);
4411 Assert(isa<ConstantInt>(Derived),
4412 "gc.relocate operand #3 must be integer offset", Call);
4414 const int BaseIndex = cast<ConstantInt>(Base)->getZExtValue();
4415 const int DerivedIndex = cast<ConstantInt>(Derived)->getZExtValue();
4417 Assert(0 <= BaseIndex && BaseIndex < (
int)StatepointCall.
arg_size(),
4418 "gc.relocate: statepoint base index out of bounds",
Call);
4419 Assert(0 <= DerivedIndex && DerivedIndex < (
int)StatepointCall.
arg_size(),
4420 "gc.relocate: statepoint derived index out of bounds",
Call);
4425 "gc.statepoint: insufficient arguments");
4427 "gc.statement: number of call arguments must be constant integer");
4428 const unsigned NumCallArgs =
4429 cast<ConstantInt>(StatepointCall.
getArgOperand(3))->getZExtValue();
4431 "gc.statepoint: mismatch in number of call arguments");
4433 "gc.statepoint: number of transition arguments must be " 4434 "a constant integer");
4435 const int NumTransitionArgs =
4436 cast<ConstantInt>(StatepointCall.
getArgOperand(NumCallArgs + 5))
4438 const int DeoptArgsStart = 4 + NumCallArgs + 1 + NumTransitionArgs + 1;
4440 "gc.statepoint: number of deoptimization arguments must be " 4441 "a constant integer");
4442 const int NumDeoptArgs =
4443 cast<ConstantInt>(StatepointCall.
getArgOperand(DeoptArgsStart))
4445 const int GCParamArgsStart = DeoptArgsStart + 1 + NumDeoptArgs;
4446 const int GCParamArgsEnd = StatepointCall.
arg_size();
4447 Assert(GCParamArgsStart <= BaseIndex && BaseIndex < GCParamArgsEnd,
4448 "gc.relocate: statepoint base index doesn't fall within the " 4449 "'gc parameters' section of the statepoint call",
4451 Assert(GCParamArgsStart <= DerivedIndex && DerivedIndex < GCParamArgsEnd,
4452 "gc.relocate: statepoint derived index doesn't fall within the " 4453 "'gc parameters' section of the statepoint call",
4462 "gc.relocate: relocated value must be a gc pointer",
Call);
4464 auto ResultType = Call.
getType();
4466 Assert(ResultType->isVectorTy() == DerivedType->isVectorTy(),
4467 "gc.relocate: vector relocates to vector and pointer to pointer",
4470 ResultType->getPointerAddressSpace() ==
4471 DerivedType->getPointerAddressSpace(),
4472 "gc.relocate: relocating a pointer shouldn't change its address space",
4479 "eh.exceptionpointer argument must be a catchpad", Call);
4494 Type *DataTy = cast<PointerType>(Ptr->getType())->getElementType();
4496 "masked_load: return must match pointer type",
Call);
4498 "masked_load: pass through and data type must match",
Call);
4500 DataTy->getVectorNumElements(),
4501 "masked_load: vector mask must be same length as data",
Call);
4513 Type *DataTy = cast<PointerType>(Ptr->
getType())->getElementType();
4515 "masked_store: storee must match pointer type",
Call);
4517 DataTy->getVectorNumElements(),
4518 "masked_store: vector mask must be same length as data",
Call);
4523 Assert(isa<CallInst>(Call),
"experimental_guard cannot be invoked", Call);
4525 "experimental_guard must have exactly one " 4526 "\"deopt\" operand bundle");
4531 Assert(isa<CallInst>(Call),
"experimental_deoptimize cannot be invoked",
4534 "experimental_deoptimize must have exactly one " 4535 "\"deopt\" operand bundle");
4537 "experimental_deoptimize return type must match caller return type");
4539 if (isa<CallInst>(Call)) {
4542 "calls to experimental_deoptimize must be followed by a return");
4546 "calls to experimental_deoptimize must be followed by a return " 4547 "of the value computed by experimental_deoptimize");
4559 "first operand of [us][add|sub]_sat must be an int type or vector " 4562 "second operand of [us][add|sub]_sat must be an int type or vector " 4570 "first operand of smul_fix must be an int type or vector " 4573 "second operand of smul_fix must be an int type or vector " 4577 Assert(Op3,
"third argument of smul_fix must be a constant integer");
4578 Assert(Op3->getType()->getBitWidth() <= 32,
4579 "third argument of smul_fix must fit within 32 bits");
4581 "the scale of smul_fix must be less than the width of the operands");
4595 if (
auto *
SP = dyn_cast<DISubprogram>(LocalScope))
4598 if (
auto *LB = dyn_cast<DILexicalBlockBase>(LocalScope))
4602 assert(!isa<DILocalScope>(LocalScope) &&
"Unknown type of local scope");
4609 (NumOperands == 3 && FPI.
isUnaryOp()) || (NumOperands == 4)),
4610 "invalid arguments for constrained FP intrinsic", &FPI);
4612 "invalid exception behavior argument", &FPI);
4614 "invalid rounding mode argument", &FPI);
4616 "invalid rounding mode argument", &FPI);
4618 "invalid exception behavior argument", &FPI);
4622 auto *MD = cast<MetadataAsValue>(DII.
getArgOperand(0))->getMetadata();
4623 AssertDI(isa<ValueAsMetadata>(MD) ||
4624 (isa<MDNode>(MD) && !cast<MDNode>(MD)->getNumOperands()),
4625 "invalid llvm.dbg." + Kind +
" intrinsic address/value", &DII, MD);
4627 "invalid llvm.dbg." + Kind +
" intrinsic variable", &DII,
4630 "invalid llvm.dbg." + Kind +
" intrinsic expression", &DII,
4635 if (!isa<DILocation>(N))
4644 AssertDI(Loc,
"llvm.dbg." + Kind +
" intrinsic requires a !dbg attachment",
4649 if (!VarSP || !LocSP)
4652 AssertDI(VarSP == LocSP,
"mismatched subprogram between llvm.dbg." + Kind +
4653 " variable and !dbg attachment",
4655 Loc->getScope()->getSubprogram());
4661 if (
Type->isBlockByrefStruct())
4663 "BlockByRef variable without complex expression", Var, &DII);
4670 "invalid llvm.dbg." + Kind +
" intrinsic variable", &DLI,
4675 if (!isa<DILocation>(N))
4684 Assert(Loc,
"llvm.dbg." + Kind +
" intrinsic requires a !dbg attachment",
4689 if (!LabelSP || !LocSP)
4692 AssertDI(LabelSP == LocSP,
"mismatched subprogram between llvm.dbg." + Kind +
4693 " label and !dbg attachment",
4695 Loc->getScope()->getSubprogram());
4703 if (!V || !E || !E->isValid())
4707 auto Fragment = E->getFragmentInfo();
4720 verifyFragmentExpression(*V, *Fragment, &I);
4723 template <
typename ValueOrMetadata>
4724 void Verifier::verifyFragmentExpression(
const DIVariable &V,
4726 ValueOrMetadata *Desc) {
4735 AssertDI(FragSize + FragOffset <= *VarSize,
4736 "fragment is larger than or outside of variable", Desc, &V);
4737 AssertDI(FragSize != *VarSize,
"fragment covers entire variable", Desc, &V);
4752 AssertDI(Var,
"dbg intrinsic without variable");
4754 unsigned ArgNo = Var->
getArg();
4760 if (DebugFnArgs.size() < ArgNo)
4761 DebugFnArgs.resize(ArgNo,
nullptr);
4763 auto *Prev = DebugFnArgs[ArgNo - 1];
4764 DebugFnArgs[ArgNo - 1] = Var;
4765 AssertDI(!Prev || (Prev == Var),
"conflicting debug info for argument", &I,
4769 void Verifier::verifyCompileUnits() {
4778 Listed.
insert(CUs->op_begin(), CUs->op_end());
4779 for (
auto *
CU : CUVisited)
4784 void Verifier::verifyDeoptimizeCallingConvs() {
4785 if (DeoptimizeDeclarations.empty())
4788 const Function *First = DeoptimizeDeclarations[0];
4789 for (
auto *F :
makeArrayRef(DeoptimizeDeclarations).slice(1)) {
4791 "All llvm.experimental.deoptimize declarations must have the same " 4792 "calling convention",
4798 bool HasSource = F.
getSource().hasValue();
4799 if (!HasSourceDebugInfo.count(&U))
4800 HasSourceDebugInfo[&U] = HasSource;
4801 AssertDI(HasSource == HasSourceDebugInfo[&U],
4802 "inconsistent use of embedded source");
4817 return !V.verify(F);
4823 Verifier V(OS, !BrokenDebugInfo, M);
4827 Broken |= !V.verify(F);
4829 Broken |= !V.verify();
4830 if (BrokenDebugInfo)
4831 *BrokenDebugInfo = V.hasBrokenDebugInfo();
4842 std::unique_ptr<Verifier> V;
4843 bool FatalErrors =
true;
4848 explicit VerifierLegacyPass(
bool FatalErrors)
4850 FatalErrors(FatalErrors) {
4854 bool doInitialization(
Module &M)
override {
4855 V = llvm::make_unique<Verifier>(
4861 if (!V->verify(F) && FatalErrors) {
4868 bool doFinalization(
Module &M)
override {
4869 bool HasErrors =
false;
4872 HasErrors |= !V->verify(F);
4874 HasErrors |= !V->verify();
4875 if (FatalErrors && (HasErrors || V->hasBrokenDebugInfo()))
4888 template <
typename... Tys>
void TBAAVerifier::CheckFailed(Tys &&...
Args) {
4890 return Diagnostic->CheckFailed(
Args...);
4893 #define AssertTBAA(C, ...) \ 4896 CheckFailed(__VA_ARGS__); \ 4904 TBAAVerifier::TBAABaseNodeSummary
4908 CheckFailed(
"Base nodes must have at least two operands", &I, BaseNode);
4912 auto Itr = TBAABaseNodes.find(BaseNode);
4913 if (Itr != TBAABaseNodes.end())
4916 auto Result = verifyTBAABaseNodeImpl(I, BaseNode, IsNewFormat);
4917 auto InsertResult = TBAABaseNodes.insert({BaseNode, Result});
4919 assert(InsertResult.second &&
"We just checked!");
4923 TBAAVerifier::TBAABaseNodeSummary
4926 const TBAAVerifier::TBAABaseNodeSummary InvalidNode = {
true, ~0u};
4930 return isValidScalarTBAANode(BaseNode)
4931 ? TBAAVerifier::TBAABaseNodeSummary({
false, 0})
4937 CheckFailed(
"Access tag nodes must have the number of operands that is a " 4938 "multiple of 3!", BaseNode);
4943 CheckFailed(
"Struct tag nodes must have an odd number of operands!",
4951 auto *TypeSizeNode = mdconst::dyn_extract_or_null<ConstantInt>(
4953 if (!TypeSizeNode) {
4954 CheckFailed(
"Type size nodes must be constants!", &I, BaseNode);
4960 if (!IsNewFormat && !isa<MDString>(BaseNode->
getOperand(0))) {
4961 CheckFailed(
"Struct tag nodes have a string as their first operand",
4969 unsigned BitWidth = ~0u;
4973 unsigned FirstFieldOpNo = IsNewFormat ? 3 : 1;
4974 unsigned NumOpsPerField = IsNewFormat ? 3 : 2;
4975 for (
unsigned Idx = FirstFieldOpNo; Idx < BaseNode->
getNumOperands();
4976 Idx += NumOpsPerField) {
4979 if (!isa<MDNode>(FieldTy)) {
4980 CheckFailed(
"Incorrect field entry in struct type node!", &I, BaseNode);
4985 auto *OffsetEntryCI =
4986 mdconst::dyn_extract_or_null<ConstantInt>(FieldOffset);
4987 if (!OffsetEntryCI) {
4988 CheckFailed(
"Offset entries must be constants!", &I, BaseNode);
4993 if (BitWidth == ~0u)
4994 BitWidth = OffsetEntryCI->getBitWidth();
4996 if (OffsetEntryCI->getBitWidth() != BitWidth) {
4998 "Bitwidth between the offsets and struct type entries must match", &I,
5010 !PrevOffset || PrevOffset->
ule(OffsetEntryCI->getValue());
5013 CheckFailed(
"Offsets must be increasing!", &I, BaseNode);
5017 PrevOffset = OffsetEntryCI->getValue();
5020 auto *MemberSizeNode = mdconst::dyn_extract_or_null<ConstantInt>(
5022 if (!MemberSizeNode) {
5023 CheckFailed(
"Member size entries must be constants!", &I, BaseNode);
5030 return Failed ? InvalidNode
5031 : TBAAVerifier::TBAABaseNodeSummary(
false, BitWidth);
5052 auto *Parent = dyn_cast_or_null<MDNode>(MD->
getOperand(1));
5053 return Parent && Visited.
insert(Parent).second &&
5057 bool TBAAVerifier::isValidScalarTBAANode(
const MDNode *MD) {
5058 auto ResultIt = TBAAScalarNodes.find(MD);
5059 if (ResultIt != TBAAScalarNodes.end())
5060 return ResultIt->second;
5064 auto InsertResult = TBAAScalarNodes.insert({MD, Result});
5066 assert(InsertResult.second &&
"Just checked!");
5085 return cast<MDNode>(BaseNode->
getOperand(1));
5087 unsigned FirstFieldOpNo = IsNewFormat ? 3 : 1;
5088 unsigned NumOpsPerField = IsNewFormat ? 3 : 2;
5089 for (
unsigned Idx = FirstFieldOpNo; Idx < BaseNode->
getNumOperands();
5090 Idx += NumOpsPerField) {
5091 auto *OffsetEntryCI =
5092 mdconst::extract<ConstantInt>(BaseNode->
getOperand(Idx + 1));
5093 if (OffsetEntryCI->getValue().ugt(Offset)) {
5094 if (Idx == FirstFieldOpNo) {
5095 CheckFailed(
"Could not find TBAA parent in struct type node", &I,
5100 unsigned PrevIdx = Idx - NumOpsPerField;
5101 auto *PrevOffsetEntryCI =
5102 mdconst::extract<ConstantInt>(BaseNode->
getOperand(PrevIdx + 1));
5103 Offset -= PrevOffsetEntryCI->getValue();
5104 return cast<MDNode>(BaseNode->
getOperand(PrevIdx));
5109 auto *LastOffsetEntryCI = mdconst::extract<ConstantInt>(
5111 Offset -= LastOffsetEntryCI->getValue();
5112 return cast<MDNode>(BaseNode->
getOperand(LastIdx));
5129 AssertTBAA(isa<LoadInst>(I) || isa<StoreInst>(I) || isa<CallInst>(I) ||
5130 isa<VAArgInst>(I) || isa<AtomicRMWInst>(I) ||
5131 isa<AtomicCmpXchgInst>(I),
5132 "This instruction shall not have a TBAA access tag!", &I);
5134 bool IsStructPathTBAA =
5139 "Old-style TBAA is no longer allowed, use struct-path TBAA instead", &I);
5148 "Access tag metadata must have either 4 or 5 operands", &
I, MD);
5151 "Struct tag metadata must have either 3 or 4 operands", &
I, MD);
5156 auto *AccessSizeNode = mdconst::dyn_extract_or_null<ConstantInt>(
5158 AssertTBAA(AccessSizeNode,
"Access size field must be a constant", &I, MD);
5162 unsigned ImmutabilityFlagOpNo = IsNewFormat ? 4 : 3;
5164 auto *IsImmutableCI = mdconst::dyn_extract_or_null<ConstantInt>(
5167 "Immutability tag on struct tag metadata must be a constant",
5170 IsImmutableCI->isZero() || IsImmutableCI->isOne(),
5171 "Immutability part of the struct tag metadata must be either 0 or 1",
5176 "Malformed struct tag metadata: base and access-type " 5177 "should be non-null and point to Metadata nodes",
5178 &I, MD, BaseNode, AccessType);
5181 AssertTBAA(isValidScalarTBAANode(AccessType),
5182 "Access type node must be a valid scalar type", &I, MD,
5186 auto *OffsetCI = mdconst::dyn_extract_or_null<ConstantInt>(MD->
getOperand(2));
5187 AssertTBAA(OffsetCI,
"Offset must be constant integer", &I, MD);
5189 APInt Offset = OffsetCI->getValue();
5190 bool SeenAccessTypeInPath =
false;
5195 BaseNode = getFieldNodeFromTBAABaseNode(I, BaseNode, Offset,
5197 if (!StructPath.
insert(BaseNode).second) {
5198 CheckFailed(
"Cycle detected in struct path", &I, MD);
5203 unsigned BaseNodeBitWidth;
5204 std::tie(Invalid, BaseNodeBitWidth) = verifyTBAABaseNode(I, BaseNode,
5212 SeenAccessTypeInPath |= BaseNode == AccessType;
5214 if (isValidScalarTBAANode(BaseNode) || BaseNode == AccessType)
5215 AssertTBAA(Offset == 0,
"Offset not zero at the point of scalar access",
5219 (BaseNodeBitWidth == 0 && Offset == 0) ||
5220 (IsNewFormat && BaseNodeBitWidth == ~0u),
5221 "Access bit-width not the same as description bit-width", &
I, MD,
5224 if (IsNewFormat && SeenAccessTypeInPath)
5228 AssertTBAA(SeenAccessTypeInPath,
"Did not see access type in access path!",
5234 INITIALIZE_PASS(VerifierLegacyPass,
"verify",
"Module Verifier",
false,
false)
5237 return new VerifierLegacyPass(FatalErrors);
5255 if (FatalErrors && (Res.IRBroken || Res.DebugInfoBroken))
5263 if (res.IRBroken && FatalErrors)
bool isDeclarationForLinker() const
Metadata * getRawRetainedTypes() const
Return a value (possibly void), from a function.
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
static bool isScope(const Metadata *MD)
IntegerType * getType() const
getType - Specialize the getType() method to always return an IntegerType, which reduces the amount o...
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
Tracking metadata reference owned by Metadata.
static Value * getParentPad(Value *EHPad)
bool hasDefinitiveInitializer() const
hasDefinitiveInitializer - Whether the global variable has an initializer, and any other instances of...
iterator_range< use_iterator > uses()
raw_ostream & errs()
This returns a reference to a raw_ostream for standard error.
bool hasLocalLinkage() const
C - The default llvm calling convention, compatible with C.
unsigned getOpcode() const
Return the opcode at the root of this constant expression.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
iterator_range< CaseIt > cases()
Iteration adapter for range-for loops.
This class represents an incoming formal argument to a Function.
bool doesNotAccessMemory(unsigned OpNo) const
Base class for instruction visitors.
Value * getAggregateOperand()
bool isSpeculatable() const
Determine if the call has sideeffects.
const Value * stripInBoundsOffsets() const
Strip off pointer casts and inbounds GEPs.
This represents the llvm.dbg.label instruction.
Atomic ordering constants.
Takes the max of the two values, which are required to be integers.
StringRef getName() const
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
bool hasPrivateLinkage() const
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
bool isMetadataTy() const
Return true if this is 'metadata'.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
BinaryOps getOpcode() const
const APInt & getUpper() const
Return the upper value for this range.
bool isAtomic() const
Return true if this instruction has an AtomicOrdering of unordered or higher.
Type * getParamType(unsigned i) const
Parameter type accessors.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
static bool isValidOperands(const Value *Vec, const Value *NewElt, const Value *Idx)
Return true if an insertelement instruction can be formed with the specified operands.
Metadata * getRawGlobalVariables() const
Metadata * getRawVTableHolder() const
A Module instance is used to store all the information related to an LLVM module. ...
bool isSized(SmallPtrSetImpl< Type *> *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
Result run(Module &M, ModuleAnalysisManager &)
An instruction for ordering other memory operations.
an instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
Function * getCaller()
Helper to get the caller (the parent function).
This class represents zero extension of integer types.
unsigned getNumElements() const
Random access to the elements.
void push_back(const T &Elt)
Metadata * getRawFile() const
Return the raw underlying file.
This class represents a function call, abstracting a target machine's calling convention.
bool hasAvailableExternallyLinkage() const
Metadata * getRawInlinedAt() const
Value * getCondition() const
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this store instruction.
FunctionPass * createVerifierPass(bool FatalErrors=true)
const Value * getTrueValue() const
An efficient, type-erasing, non-owning reference to a callable.
bool isSwiftError() const
Return true if this alloca is used as a swifterror argument to a call.
This file contains the declaration of the Comdat class, which represents a single COMDAT in LLVM...
AtomicOrdering getOrdering() const
Returns the ordering constraint of this load instruction.
This instruction constructs a fixed permutation of two input vectors.
LLVMContext & getContext() const
All values hold a context through their type.
DICompositeTypeArray getEnumTypes() const
bool sgt(const APInt &RHS) const
Signed greather than comparison.
const Use & getOperandUse(unsigned i) const
This class implements a map that also provides access to all stored values in a deterministic order...
bool hasDLLImportStorageClass() const
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
static Instruction * getSuccPad(Instruction *Terminator)
Metadata * getRawScope() const
User::op_iterator arg_end()
Return the iterator pointing to the end of the argument list.
const fltSemantics & getSemantics() const
const MDOperand & getOperand(unsigned I) const
This class represents a sign extension of integer types.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
An instruction for reading from memory.
Manage lifetime of a slot tracker for printing IR.
bool hasExternalWeakLinkage() const
void CheckFailed(const Twine &Message)
A check failed, so printout out the condition and the message.
Typed, array-like tuple of metadata.
AttrBuilder & addAttribute(Attribute::AttrKind Val)
Add an attribute to the builder.
an instruction that atomically reads a memory location, combines it with another value, and then stores the result back.
Value * getCondition() const
BasicBlock * getUnwindDest() const
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
bool isVectorTy() const
True if this is an instance of VectorType.
This is the common base class for constrained floating point intrinsics.
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
OperandBundleUse getOperandBundleAt(unsigned Index) const
Return the operand bundle at a specific index.
This defines the Use class.
void reserve(size_type N)
bool isMustTailCall() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
unsigned getNumDestinations() const
return the number of possible destinations in this indirectbr instruction.
unsigned getBitWidth() const
Return the number of bits in the APInt.
DINodeArray getElements() const
Check a module for errors, and report separate error states for IR and debug info errors...
iterator_range< user_iterator > materialized_users()
AtomicOrdering getFailureOrdering() const
Returns the failure ordering constraint of this cmpxchg instruction.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Adds a requirement that another module flag be present and have a specified value after linking is pe...
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Value * getArgOperand(unsigned i) const
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Appends the two values, which are required to be metadata nodes.
Calling convention used for Mesa/AMDPAL geometry shaders.
unsigned getAllocaAddrSpace() const
Metadata * getRawTypeArray() const
This class represents a conversion between pointers from one address space to another.
static bool castIsValid(Instruction::CastOps op, Value *S, Type *DstTy)
This method can be used to determine if a cast from S to DstTy using Opcode op is valid or not...
amdgpu Simplify well known AMD library false Value Value const Twine & Name
unsigned countOperandBundlesOfType(StringRef Name) const
Return the number of operand bundles with the tag Name attached to this instruction.
StringRef getName() const
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
This class represents the LLVM 'select' instruction.
Calling convention used for Mesa/AMDPAL compute shaders.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
unsigned getAlignment() const
Return the alignment of the memory that is being allocated by the instruction.
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
PointerType * getType() const
Overload to return most specific pointer type.
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
bool isStrongerThan(AtomicOrdering ao, AtomicOrdering other)
Returns true if ao is stronger than other as defined by the AtomicOrdering lattice, which is based on C++'s definition.
bool isResolved() const
Check if node is fully resolved.
DIGlobalVariable * getVariable() const
Class to represent struct types.
SPIR_KERNEL - Calling convention for SPIR kernel functions.
LLVMContext & getContext() const
Get the global data context.
A Use represents the edge between a Value definition and its users.
DILabel * getLabel() const
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
BinOp getOperation() const
Value * getDerivedPtr() const
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
uint32_t getTagID() const
Return the tag of this operand bundle as an integer.
bool isArtificial() const
bool isIntegerTy() const
True if this is an instance of IntegerType.
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
This file contains the simple types necessary to represent the attributes associated with functions a...
AttributeSet getRetAttributes() const
The attributes for the ret value are returned.
unsigned getNumHandlers() const
return the number of 'handlers' in this catchswitch instruction, except the default handler ...
static bool isNewFormatTBAATypeNode(llvm::MDNode *Type)
bool hasAttributes(unsigned Index) const
Return true if attribute exists at the given index.
Metadata * getRawType() const
uint64_t getNumElements() const
static const unsigned MaximumAlignment
Type * getSourceElementType() const
StringRef getFilename() const
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Determine whether the argument or parameter has the given attribute.
BasicBlock * getDestination(unsigned i)
Return the specified destination.
This file implements a class to represent arbitrary precision integral constant values and operations...
bool hasCommonLinkage() const
This class represents a cast from a pointer to an integer.
AtomicOrdering
Atomic ordering for LLVM's memory model.
static bool IsRootTBAANode(const MDNode *MD)
static bool isValidOperands(const Value *V1, const Value *V2, const Value *Mask)
Return true if a shufflevector instruction can be formed with the specified operands.
bool hasValidDeclarationLinkage() const
static StringRef getOperationName(BinOp Op)
void visit(Iterator Start, Iterator End)
bool hasExternalLinkage() const
Metadata * getRawImportedEntities() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
Fast - This calling convention attempts to make calls as fast as possible (e.g.
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
A constant value that is initialized with an expression using other constant values.
Class to represent function types.
Type * getType() const
All values are typed, get the type of this value.
static bool isTypeCongruent(Type *L, Type *R)
Two types are "congruent" if they are identical, or if they are both pointer types with different poi...
bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value. ...
Holds the characteristics of one fragment of a larger variable.
op_range operands() const
AtomicOrdering getSuccessOrdering() const
Returns the success ordering constraint of this cmpxchg instruction.
#define Assert(C,...)
We know that cond should be true, if not print an error message.
Class to represent array types.
This is the common base class for debug info intrinsics for variables.
AttributeSet getParamAttributes(unsigned ArgNo) const
The attributes for the argument or parameter at the given index are returned.
This instruction compares its operands according to the predicate given to the constructor.
RoundingMode getRoundingMode() const
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
DIMacroNodeArray getElements() const
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
bool isIntOrPtrTy() const
Return true if this is an integer type or a pointer type.
This class represents a no-op cast from one type to another.
GlobalValue * getNamedValue(StringRef Name) const
Return the global value in the module with the specified name, of arbitrary type. ...
ConstantRange intersectWith(const ConstantRange &CR) const
Return the range that results from the intersection of this range with another range.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
const APInt & getValue() const
Return the constant as an APInt value reference.
An instruction for storing to memory.
bool hasPersonalityFn() const
Check whether this function has a personality function.
Metadata * getRawEntity() const
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
LinkageTypes getLinkage() const
This class represents a cast from floating point to signed integer.
unsigned getAlignment() const
Value * getParentPad() const
unsigned getNumOperandBundles() const
Return the number of operand bundles associated with this User.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
handler_range handlers()
iteration adapter for range-for loops.
iterator_range< op_iterator > operands()
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree...
amdgpu Simplify well known AMD library false Value * Callee
This class represents a truncation of integer types.
Calling convention used for Mesa vertex shaders, or AMDPAL last shader stage before rasterization (ve...
Value * getOperand(unsigned i) const
Class to represent pointers.
Metadata * getRawFile() const
Optional< OperandBundleUse > getOperandBundle(StringRef Name) const
Return an operand bundle by name, if present.
bool hasAttribute(Attribute::AttrKind Kind) const
Return true if the attribute exists in this set.
Flag
These should be considered private to the implementation of the MCInstrDesc class.
bool hasAppendingLinkage() const
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
AttributeSet getAttributes(unsigned Index) const
The attributes for the specified index are returned.
StringRef getString() const
DIMacroNodeArray getMacros() const
bool isVoidTy() const
Return true if this is 'void'.
const BasicBlock & getEntryBlock() const
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
ExceptionBehavior getExceptionBehavior() const
static bool runOnFunction(Function &F, bool PostInlining)
Type * getReturnType() const
Returns the type of the ret val.
void getModuleFlagsMetadata(SmallVectorImpl< ModuleFlagEntry > &Flags) const
Returns the module flags in the provided vector.
This instruction inserts a single (scalar) element into a VectorType value.
StringRef getName() const
unsigned getColumn() const
static bool isIntPredicate(Predicate P)
bool isLabelTy() const
Return true if this is 'label'.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
const Instruction * getFirstNonPHI() const
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
Emits an error if two values disagree, otherwise the resulting value is that of the operands...
Metadata * getRawExpression() const
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
A set of analyses that are preserved following a run of a transformation pass.
Metadata * getRawDiscriminator() const
static AttributeSet get(LLVMContext &C, const AttrBuilder &B)
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
unsigned arg_size() const
Value * getCalledValue() const
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
DISubprogram * getSubprogram() const
Get the attached subprogram.
Conditional or Unconditional Branch instruction.
bool isHexDigit(char C)
Checks if character C is a hexadecimal numeric character.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
Resume the propagation of an exception.
CountType getCount() const
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool isPointerTy() const
True if this is an instance of PointerType.
bool hasInAllocaArgument() const
Determine if there are is an inalloca argument.
const Instruction & front() const
Indirect Branch Instruction.
PTX_Kernel - Call to a PTX kernel.
void print(raw_ostream &ROS, bool IsForDebug=false) const
FunctionType * getFunctionType() const
Base class for template parameters.
ModFlagBehavior
This enumeration defines the supported behaviors of module flags.
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
ConstantFP - Floating Point Values [float, double].
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Interval::pred_iterator pred_begin(Interval *I)
pred_begin/pred_end - define methods so that Intervals may be used just like BasicBlocks can with the...
DIExpression * getExpression() const
DIExpression * getExpression() const
bool isODRUniquingDebugTypes() const
Whether there is a string map for uniquing debug info identifiers across the context.
Metadata * getRawLabel() const
static bool isValidLinkage(LinkageTypes L)
A pair of DIGlobalVariable and DIExpression.
Represent the analysis usage information of a pass.
constexpr bool isPowerOf2_64(uint64_t Value)
Return true if the argument is a power of two > 0 (64 bit edition.)
This file declares a class to represent arbitrary precision floating point values and provide a varie...
static Type * getVoidTy(LLVMContext &C)
static bool isFuncOnlyAttr(Attribute::AttrKind Kind)
Return true if this attribute kind only applies to functions.
bool visitTBAAMetadata(Instruction &I, const MDNode *MD)
Visit an instruction and return true if it is valid, return false if an invalid TBAA is attached...
DIImportedEntityArray getImportedEntities() const
This instruction compares its operands according to the predicate given to the constructor.
void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
FunctionPass class - This class is used to implement most global optimizations.
static FunctionType * get(Type *Result, ArrayRef< Type *> Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
Interval::pred_iterator pred_end(Interval *I)
unsigned getAddressSpace() const
Return the address space of the Pointer type.
Base class for variables.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
bool isFullSet() const
Return true if this set contains all of the elements possible for this data-type. ...
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
bool pred_empty(const BasicBlock *BB)
const Function * getFunction() const
Return the function this instruction belongs to.
This class represents a cast from an integer to a pointer.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
static DISubprogram * getSubprogram(Metadata *LocalScope)
Carefully grab the subprogram from a local scope.
Calling convention used for Mesa/AMDPAL pixel shaders.
const Value * stripPointerCasts() const
Strip off pointer casts, all-zero GEPs, and aliases.
This class represents the va_arg llvm instruction, which returns an argument of the specified type gi...
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
const Value * getArraySize() const
Get the number of elements allocated.
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
AtomicOrdering getOrdering() const
Returns the ordering constraint of this rmw instruction.
Metadata * getRawType() const
iterator_range< User::op_iterator > args()
Iteration adapter for range-for loops.
void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
Print the name of this Value out to the specified raw_ostream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool verify(const TargetRegisterInfo &TRI) const
Check that information hold by this instance make sense for the given TRI.
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
bool isFilter(unsigned Idx) const
Return 'true' if the clause and index Idx is a filter clause.
An imported module (C++ using directive or similar).
Base class for scope-like contexts.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Value * getParentPad() const
Convenience accessors.
void sort(IteratorTy Start, IteratorTy End)
Metadata * getRawElements() const
bool isEmptySet() const
Return true if this set contains no members.
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches, switches, etc.
bool isLittleEndian() const
BasicBlock * getNormalDest() const
Metadata * getRawScope() const
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
static const fltSemantics & IEEEsingle() LLVM_READNONE
#define AssertDI(C,...)
We know that a debug info condition should be true, if not print an error message.
unsigned getNumOperands() const
std::string getAsString(bool InAttrGrp=false) const
bool hasParamAttribute(unsigned ArgNo, Attribute::AttrKind Kind) const
Equivalent to hasAttribute(ArgNo + FirstArgIndex, Kind).
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
bool matchIntrinsicVarArg(bool isVarArg, ArrayRef< IITDescriptor > &Infos)
Verify if the intrinsic has variable arguments.
This is the shared class of boolean and integer constants.
constexpr bool isInt< 32 >(int64_t x)
VerifierSupport(raw_ostream *OS, const Module &M)
Metadata * getRawTemplateParams() const
static Optional< DebugEmissionKind > getEmissionKind(StringRef Str)
testing::Matcher< const detail::ErrorHolder & > Failed()
Optional< uint64_t > getSizeInBits() const
Determines the size of the variable's type.
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl< IITDescriptor > &T)
Return the IIT table descriptor for the specified intrinsic into an array of IITDescriptors.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Module.h This file contains the declarations for the Module class.
Metadata * getRawVariable() const
bool isFiniteNonZero() const
static bool isDINode(const Metadata *MD)
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs(unsigned Index) const
Get the allocsize argument numbers (or pair(0, 0) if unknown).
static bool isFuncOrArgAttr(Attribute::AttrKind Kind)
Return true if this is a function attribute that can also appear on arguments.
static bool isValidModFlagBehavior(Metadata *MD, ModFlagBehavior &MFB)
Checks if Metadata represents a valid ModFlagBehavior, and stores the converted result in MFB...
This class represents a range of values.
BasicBlock * getUnwindDest() const
Type * getReturnType() const
MDNode * getAsMDNode() const
Return this as a bar MDNode.
This class represents a cast from floating point to unsigned integer.
LLVM_NODISCARD T pop_back_val()
unsigned getProgramAddressSpace() const
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
bool isConditional() const
pred_range predecessors(BasicBlock *BB)
bool hasGlobalUnnamedAddr() const
Metadata * getRawElements() const
Metadata * getRawFile() const
static AttrBuilder getParameterABIAttributes(int I, AttributeList Attrs)
AttributeList getAttributes() const
Return the parameter attributes for this call.
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
Uses the specified value, regardless of the behavior or value of the other module.
static BlockAddress * lookup(const BasicBlock *BB)
Lookup an existing BlockAddress constant for the given BasicBlock.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
DISubprogram * getSubprogram() const
Get the subprogram for this scope.
unsigned getVectorNumElements() const
FunctionType * getFunctionType() const
Returns the FunctionType for me.
Class to represent vector types.
This file contains constants used for implementing Dwarf debug support.
Target - Wrapper for Target specific information.
ConstantArray - Constant Array Declarations.
Class for arbitrary precision integers.
unsigned getNumAttrSets() const
Metadata * getRawFile() const
bool ule(const APInt &RHS) const
Unsigned less or equal comparison.
A (clang) module that has been imported by the compile unit.
StringRef getName() const
static bool isFPPredicate(Predicate P)
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
Emits a warning if two values disagree.
void setPreservesAll()
Set by analyses that do not transform their input at all.
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
A lightweight accessor for an operand bundle meant to be passed around by value.
iterator_range< user_iterator > users()
InstListType::iterator iterator
Instruction iterators...
DIGlobalVariableExpressionArray getGlobalVariables() const
Generic tagged DWARF-like metadata node.
iterator insert(iterator I, T &&Elt)
unsigned getNumElements() const
Metadata * getRawFile() const
bool isNonIntegralPointerType(PointerType *PT) const
bool verifyModule(const Module &M, raw_ostream *OS=nullptr, bool *BrokenDebugInfo=nullptr)
Check a module for errors.
amdgpu Simplify well known AMD library false Value Value * Arg
Metadata * getRawBaseType() const
uint64_t getTypeSizeInBits(Type *Ty) const
Size examples:
User::op_iterator arg_begin()
Return the iterator pointing to the beginning of the argument list.
Type array for a subprogram.
Intel_OCL_BI - Calling conventions for Intel OpenCL built-ins.
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
PTX_Device - Call to a PTX device function.
unsigned getParamAlignment(unsigned ArgNo) const
Return the alignment for the specified function parameter.
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
unsigned getNumArgOperands() const
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Metadata * getRawEnumTypes() const
bool isInlineAsm() const
Check if this call is an inline asm statement.
Appends the two values, which are required to be metadata nodes.
unsigned getAlignment() const
Return the alignment of the access that is being performed.
static Type * getIndexedType(Type *Ty, ArrayRef< Value *> IdxList)
Returns the type of the element that would be loaded with a load instruction with the specified param...
LLVM_NODISCARD bool empty() const
bool BrokenDebugInfo
Broken debug info can be "recovered" from by stripping the debug info.
UnaryOps getOpcode() const
AtomicOrdering getOrdering() const
Returns the ordering constraint of this store instruction.
Metadata * getRawScope() const
bool isTokenTy() const
Return true if this is 'token'.
CallingConv::ID getCallingConv() const
verify safepoint Safepoint IR Verifier
Calling convention used for Mesa/AMDPAL hull shaders (= tessellation control shaders).
bool canLosslesslyBitCastTo(Type *Ty) const
Return true if this type could be converted with a lossless BitCast to type 'Ty'. ...
StringRef getName() const
Return a constant reference to the value's name.
Function * getCalledFunction() const
Returns the function called, or null if this is an indirect function invocation.
const Function * getParent() const
Return the enclosing method, or null if none.
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID of this load instruction.
bool matchIntrinsicType(Type *Ty, ArrayRef< IITDescriptor > &Infos, SmallVectorImpl< Type *> &ArgTys)
Match the specified type (which comes from an intrinsic argument or return value) with the type const...
void CheckFailed(const Twine &Message, const T1 &V1, const Ts &... Vs)
A check failed (with values to print).
void DebugInfoCheckFailed(const Twine &Message, const T1 &V1, const Ts &... Vs)
A debug info check failed (with values to print).
bool onlyReadsMemory(unsigned OpNo) const
const APInt & getLower() const
Return the lower value for this range.
Value * getValue() const
Convenience accessor.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
bool isCatch(unsigned Idx) const
Return 'true' if the clause and index Idx is a catch clause.
void initializeVerifierLegacyPassPass(PassRegistry &)
This class represents a cast unsigned integer to floating point.
Type * getResultElementType() const
bool verifyFunction(const Function &F, raw_ostream *OS=nullptr)
Check a function for errors, useful for use when debugging a pass.
Optional< StringRef > getSource() const
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Type * getValueType() const
iterator_range< const_phi_iterator > phis() const
Returns a range that iterates over the phis in the basic block.
static ConstantTokenNone * get(LLVMContext &Context)
Return the ConstantTokenNone.
unsigned getMacinfoType() const
DILocalVariable * getVariable() const
Value * getReturnValue() const
Convenience accessor. Returns null if there is no return value.
ArrayRef< unsigned > getNonIntegralAddressSpaces() const
Return the address spaces containing non-integral pointers.
StringRef getValue() const
unsigned getAlignment() const
Return the alignment of the access that is being performed.
void DebugInfoCheckFailed(const Twine &Message)
A debug info check failed.
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Metadata * getRawStaticDataMemberDeclaration() const
DIScopeArray getRetainedTypes() const
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
bool isStatepoint(ImmutableCallSite CS)
static bool IsScalarTBAANodeImpl(const MDNode *MD, SmallPtrSetImpl< const MDNode *> &Visited)
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
DITypeRef getType() const
This class represents a cast from signed integer to floating point.
DILocalScope * getScope() const
Get the local scope for this label.
bool hasFnAttribute(Attribute::AttrKind Kind) const
Equivalent to hasAttribute(AttributeList::FunctionIndex, Kind) but may be faster. ...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static void forEachUser(const Value *User, SmallPtrSet< const Value *, 32 > &Visited, llvm::function_ref< bool(const Value *)> Callback)
const BasicBlock & front() const
bool hasAttributes() const
Return true if attributes exists in this set.
bool isEHPad() const
Return true if this basic block is an exception handling block.
This class represents a truncation of floating point types.
BasicBlock * getUnwindDest() const
Represents calls to the gc.relocate intrinsic.
ArrayRef< unsigned > getIndices() const
Module * getParent()
Get the module that this global value is contained inside of...
Verify that the TBAA Metadatas are valid.
LLVM Value Representation.
bool hasInitializer() const
Definitions have initializers, declarations don't.
Metadata * getRawMacros() const
Metadata * getRawScope() const
static bool hasConflictingReferenceFlags(unsigned Flags)
Detect mutually exclusive flags.
Synchronized with respect to all concurrently executing threads.
bool TreatBrokenDebugInfoAsError
Whether to treat broken debug info as an error.
AttrBuilder typeIncompatible(Type *Ty)
Which attributes cannot be applied to a type.
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
AttributeSet getFnAttributes() const
The function attributes are returned.
DITypeRefArray getTypeArray() const
This class implements an extremely fast bulk output stream that can only output to a stream...
bool hasDefaultVisibility() const
Metadata * getRawScope() const
bool Broken
Track the brokenness of the module while recursively visiting.
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
static bool isContiguous(const ConstantRange &A, const ConstantRange &B)
StringRef - Represent a constant reference to a string, i.e.
AttrBuilder & addAlignmentAttr(unsigned Align)
This turns an int alignment (which must be a power of 2) into the form used internally in Attribute...
A container for analyses that lazily runs them and caches their results.
const LandingPadInst * getLandingPadInst() const
Return the landingpad instruction associated with the landing pad.
AtomicOrdering getOrdering() const
Returns the ordering constraint of this fence instruction.
bool isStaticAlloca() const
Return true if this alloca is in the entry block of the function and is a constant size...
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
Metadata * getRawType() const
Metadata * getRawScope() const
const Use & getCalledOperandUse() const
This header defines various interfaces for pass management in LLVM.
DILocalScope * getScope() const
Get the local scope for this variable.
unsigned getNumOperands() const
Return number of MDNode operands.
op_range incoming_values()
This class represents an extension of floating point types.
bool isEmpty() const
Return true if there are no attributes.
A bitmask that includes all valid flags.
#define AssertTBAA(C,...)
A special type used by analysis passes to provide an address that identifies that particular analysis...
Calling convention for AMDGPU code object kernels.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
Type * getElementType() const
PointerType * getType() const
Global values are always pointers.
Metadata * getRawScope() const
bool empty() const
empty - Check if the array is empty.
bool isArrayTy() const
True if this is an instance of ArrayType.
StringRef getName() const
Type * getTypeAtIndex(const Value *V) const
Given an index value into the type, return the type of the element.
const BasicBlock * getParent() const
an instruction to allocate memory on the stack
This instruction inserts a struct field of array element value into an aggregate value.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...
static bool isType(const Metadata *MD)
Basic type, like 'int' or 'float'.
static 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...
const Constant * getAliasee() const