116 using namespace llvm;
137 : OS(OS), M(M),
MST(&M),
DL(M.getDataLayout()),
Context(M.getContext()) {}
144 void Write(
const Value *V) {
147 if (isa<Instruction>(V)) {
178 void Write(
Type *
T) {
190 void Write(
const APInt *AI) {
196 void Write(
const unsigned i) { *
OS << i <<
'\n'; }
199 for (
const T &V : Vs)
203 template <
typename T1,
typename... Ts>
204 void WriteTs(
const T1 &V1,
const Ts &... Vs) {
209 template <
typename... Ts>
void WriteTs() {}
218 *
OS << Message <<
'\n';
226 template <
typename T1,
typename... Ts>
236 *
OS << Message <<
'\n';
242 template <
typename T1,
typename... Ts>
274 Type *LandingPadResultTy;
305 explicit Verifier(
raw_ostream *OS,
bool ShouldTreatBrokenDebugInfoAsError,
308 SawFrameEscape(
false), TBAAVerifyHelper(this) {
309 TreatBrokenDebugInfoAsError = ShouldTreatBrokenDebugInfoAsError;
312 bool hasBrokenDebugInfo()
const {
return BrokenDebugInfo; }
316 "An instance of this class only works with a specific module!");
325 DT.recalculate(const_cast<Function &>(F));
328 if (!BB.empty() && BB.back().isTerminator())
332 *OS <<
"Basic Block in function '" << F.getName()
333 <<
"' does not have terminator!\n";
334 BB.printAsOperand(*OS,
true, MST);
342 visit(const_cast<Function &>(F));
343 verifySiblingFuncletUnwinds();
344 InstsInThisBlock.clear();
345 LandingPadResultTy =
nullptr;
346 SawFrameEscape =
false;
347 SiblingFuncletInfo.clear();
358 if (F.getIntrinsicID() == Intrinsic::experimental_deoptimize)
359 DeoptimizeDeclarations.push_back(&F);
363 verifyFrameRecoverIndices();
365 visitGlobalVariable(GV);
368 visitGlobalAlias(GA);
371 visitNamedMDNode(NMD);
374 visitComdat(SMEC.getValue());
377 visitModuleIdents(M);
379 verifyCompileUnits();
381 verifyDeoptimizeCallingConvs();
395 void visitMDNode(
const MDNode &MD);
398 void visitComdat(
const Comdat &C);
399 void visitModuleIdents(
const Module &M);
400 void visitModuleFlags(
const Module &M);
401 void visitModuleFlag(
const MDNode *
Op,
404 void visitFunction(
const Function &F);
410 #define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS) void visit##CLASS(const CLASS &N);
411 #include "llvm/IR/Metadata.def"
412 void visitDIScope(
const DIScope &
N);
436 void visitPHINode(
PHINode &PN);
443 void visitVAArgInst(
VAArgInst &VAA) { visitInstruction(VAA); }
460 template <
class DbgIntrinsicTy>
479 void verifySwiftErrorCallSite(
CallSite CS,
const Value *SwiftErrorVal);
480 void verifySwiftErrorValue(
const Value *SwiftErrorVal);
481 void verifyMustTailCall(
CallInst &CI);
483 unsigned ArgNo, std::string &Suffix);
484 bool verifyAttributeCount(
AttributeSet Attrs,
unsigned Params);
485 void verifyAttributeTypes(
AttributeSet Attrs,
unsigned Idx,
bool isFunction,
488 bool isReturnValue,
const Value *V);
491 void verifyFunctionMetadata(
ArrayRef<std::pair<unsigned, MDNode *>> MDs);
493 void visitConstantExprsRecursively(
const Constant *EntryC);
496 void verifyFrameRecoverIndices();
497 void verifySiblingFuncletUnwinds();
502 void verifyCompileUnits();
506 void verifyDeoptimizeCallingConvs();
512 #define Assert(C, ...) \
513 do { if (!(C)) { CheckFailed(__VA_ARGS__); return; } } while (false)
517 #define AssertDI(C, ...) \
518 do { if (!(C)) { DebugInfoCheckFailed(__VA_ARGS__); return; } } while (false)
532 if (!Visited.
insert(User).second)
535 if (Callback(TheNextUser))
539 void Verifier::visitGlobalValue(
const GlobalValue &GV) {
541 "Global is external, but doesn't have external or weak linkage!", &GV);
544 "huge alignment values are unsupported", &GV);
546 "Only global variables can have appending linkage!", &GV);
551 "Only global arrays can have appending linkage!", GVar);
559 if (!
I->getParent() || !
I->getParent()->getParent())
560 CheckFailed(
"Global is referenced by parentless instruction!", &GV, &M,
562 else if (
I->getParent()->getParent()->getParent() != &M)
563 CheckFailed(
"Global is referenced in a different module!", &GV, &M,
I,
564 I->getParent()->getParent(),
565 I->getParent()->getParent()->getParent());
567 }
else if (
const Function *F = dyn_cast<Function>(V)) {
568 if (F->getParent() != &M)
569 CheckFailed(
"Global is used by function in a different module", &GV, &M,
580 "Global variable initializer type does not match global "
587 "'common' global must have a zero initializer!", &GV);
590 Assert(!GV.
hasComdat(),
"'common' global may not be in a Comdat!", &GV);
595 GV.
getName() ==
"llvm.global_dtors")) {
597 "invalid linkage for intrinsic global variable", &GV);
609 "wrong type for intrinsic global variable", &GV);
613 cast<PointerType>(ETy)->getElementType()->isIntegerTy(8),
614 "wrong type for intrinsic global variable", &GV);
620 GV.
getName() ==
"llvm.compiler.used")) {
622 "invalid linkage for intrinsic global variable", &GV);
624 if (
ArrayType *ATy = dyn_cast<ArrayType>(GVType)) {
626 Assert(PTy,
"wrong type for intrinsic global variable", &GV);
630 Assert(InitArray,
"wrong initalizer for intrinsic global variable",
633 Value *V =
Op->stripPointerCastsNoFollowAliases();
634 Assert(isa<GlobalVariable>(V) || isa<Function>(V) ||
636 "invalid llvm.used member", V);
637 Assert(V->
hasName(),
"members of llvm.used must be named", V);
646 "Global is marked as dllimport, but not external", &GV);
651 for (
auto *MD : MDs) {
652 if (
auto *GVE = dyn_cast<DIGlobalVariableExpression>(MD))
653 visitDIGlobalVariableExpression(*GVE);
655 AssertDI(
false,
"!dbg attachment of global variable must be a DIGlobalVariableExpression");
659 visitGlobalValue(GV);
666 visitGlobalValue(GV);
672 visitAliaseeSubExpr(Visited, GA, C);
677 if (
const auto *GV = dyn_cast<GlobalValue>(&C)) {
681 if (
const auto *GA2 = dyn_cast<GlobalAlias>(GV)) {
682 Assert(Visited.
insert(GA2).second,
"Aliases cannot form a cycle", &GA);
684 Assert(!GA2->isInterposable(),
"Alias cannot point to an interposable alias",
693 if (
const auto *CE = dyn_cast<ConstantExpr>(&C))
694 visitConstantExprsRecursively(CE);
698 if (
const auto *GA2 = dyn_cast<GlobalAlias>(V))
699 visitAliaseeSubExpr(Visited, GA, *GA2->
getAliasee());
700 else if (
const auto *C2 = dyn_cast<Constant>(V))
701 visitAliaseeSubExpr(Visited, GA, *C2);
705 void Verifier::visitGlobalAlias(
const GlobalAlias &GA) {
707 "Alias should have private, internal, linkonce, weak, linkonce_odr, "
708 "weak_odr, or external linkage!",
711 Assert(Aliasee,
"Aliasee cannot be NULL!", &GA);
713 "Alias and aliasee types should match!", &GA);
715 Assert(isa<GlobalValue>(Aliasee) || isa<ConstantExpr>(Aliasee),
716 "Aliasee should be either GlobalValue or ConstantExpr", &GA);
718 visitAliaseeSubExpr(GA, *Aliasee);
720 visitGlobalValue(GA);
723 void Verifier::visitNamedMDNode(
const NamedMDNode &NMD) {
728 "unrecognized named metadata node in the llvm.dbg namespace",
731 if (NMD.
getName() ==
"llvm.dbg.cu")
732 AssertDI(MD && isa<DICompileUnit>(MD),
"invalid compile unit", &NMD, MD);
741 void Verifier::visitMDNode(
const MDNode &MD) {
744 if (!MDNodes.insert(&MD).second)
750 case Metadata::MDTupleKind:
752 #define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS) \
753 case Metadata::CLASS##Kind: \
754 visit##CLASS(cast<CLASS>(MD)); \
756 #include "llvm/IR/Metadata.def"
762 Assert(!isa<LocalAsMetadata>(
Op),
"Invalid operand for global metadata!",
764 if (
auto *
N = dyn_cast<MDNode>(
Op)) {
768 if (
auto *V = dyn_cast<ValueAsMetadata>(
Op)) {
769 visitValueAsMetadata(*V,
nullptr);
782 "Unexpected metadata round-trip through values", &MD, MD.
getValue());
788 Assert(F,
"function-local metadata used outside a function", L);
793 if (
Instruction *
I = dyn_cast<Instruction>(L->getValue())) {
794 Assert(
I->getParent(),
"function-local metadata not in basic block",
L,
I);
795 ActualF =
I->getParent()->getParent();
796 }
else if (
BasicBlock *BB = dyn_cast<BasicBlock>(L->getValue()))
797 ActualF = BB->getParent();
798 else if (
Argument *
A = dyn_cast<Argument>(L->getValue()))
799 ActualF =
A->getParent();
800 assert(ActualF &&
"Unimplemented function local metadata case!");
802 Assert(ActualF == F,
"function-local metadata used in wrong function", L);
807 if (
auto *
N = dyn_cast<MDNode>(MD)) {
814 if (!MDNodes.insert(MD).second)
817 if (
auto *V = dyn_cast<ValueAsMetadata>(MD))
818 visitValueAsMetadata(*V, F);
840 return isValidMetadataArrayImpl<Ty>(
N,
false);
844 return isValidMetadataArrayImpl<Ty>(
N,
true);
847 void Verifier::visitDILocation(
const DILocation &
N) {
849 "location requires a valid scope", &N, N.
getRawScope());
851 AssertDI(isa<DILocation>(IA),
"inlined-at should be a location", &
N, IA);
858 void Verifier::visitDIScope(
const DIScope &N) {
860 AssertDI(isa<DIFile>(F),
"invalid file", &
N,
F);
863 void Verifier::visitDISubrange(
const DISubrange &N) {
864 AssertDI(N.
getTag() == dwarf::DW_TAG_subrange_type,
"invalid tag", &
N);
868 void Verifier::visitDIEnumerator(
const DIEnumerator &N) {
872 void Verifier::visitDIBasicType(
const DIBasicType &N) {
874 N.
getTag() == dwarf::DW_TAG_unspecified_type,
883 N.
getTag() == dwarf::DW_TAG_pointer_type ||
884 N.
getTag() == dwarf::DW_TAG_ptr_to_member_type ||
885 N.
getTag() == dwarf::DW_TAG_reference_type ||
886 N.
getTag() == dwarf::DW_TAG_rvalue_reference_type ||
887 N.
getTag() == dwarf::DW_TAG_const_type ||
888 N.
getTag() == dwarf::DW_TAG_volatile_type ||
889 N.
getTag() == dwarf::DW_TAG_restrict_type ||
890 N.
getTag() == dwarf::DW_TAG_atomic_type ||
891 N.
getTag() == dwarf::DW_TAG_member ||
892 N.
getTag() == dwarf::DW_TAG_inheritance ||
893 N.
getTag() == dwarf::DW_TAG_friend,
895 if (N.
getTag() == dwarf::DW_TAG_ptr_to_member_type) {
896 AssertDI(
isType(N.getRawExtraData()),
"invalid pointer to member type", &N,
897 N.getRawExtraData());
906 return (Flags & DINode::FlagLValueReference) &&
907 (Flags & DINode::FlagRValueReference);
910 void Verifier::visitTemplateParams(
const MDNode &N,
const Metadata &RawParams) {
912 AssertDI(Params,
"invalid template params", &N, &RawParams);
914 AssertDI(
Op && isa<DITemplateParameter>(
Op),
"invalid template parameter",
924 N.
getTag() == dwarf::DW_TAG_structure_type ||
925 N.
getTag() == dwarf::DW_TAG_union_type ||
926 N.
getTag() == dwarf::DW_TAG_enumeration_type ||
927 N.
getTag() == dwarf::DW_TAG_class_type,
939 "invalid reference flags", &N);
941 visitTemplateParams(N, *Params);
943 if (N.
getTag() == dwarf::DW_TAG_class_type ||
944 N.
getTag() == dwarf::DW_TAG_union_type) {
946 "class/union requires a filename", &
N, N.
getFile());
951 AssertDI(N.
getTag() == dwarf::DW_TAG_subroutine_type,
"invalid tag", &
N);
953 AssertDI(isa<MDTuple>(Types),
"invalid composite elements", &N, Types);
955 AssertDI(
isType(Ty),
"invalid subroutine type ref", &N, Types, Ty);
959 "invalid reference flags", &N);
962 void Verifier::visitDIFile(
const DIFile &N) {
965 N.getChecksum().empty()),
"invalid checksum kind", &N);
980 "invalid emission kind", &N);
983 AssertDI(isa<MDTuple>(Array),
"invalid enum list", &N, Array);
985 auto *
Enum = dyn_cast_or_null<DICompositeType>(
Op);
986 AssertDI(Enum &&
Enum->getTag() == dwarf::DW_TAG_enumeration_type,
987 "invalid enum type", &
N, N.getEnumTypes(),
Op);
991 AssertDI(isa<MDTuple>(Array),
"invalid retained type list", &N, Array);
994 (isa<DISubprogram>(
Op) &&
995 !cast<DISubprogram>(
Op)->isDefinition())),
996 "invalid retained type", &N,
Op);
1000 AssertDI(isa<MDTuple>(Array),
"invalid global variable list", &N, Array);
1003 "invalid global variable ref", &N,
Op);
1007 AssertDI(isa<MDTuple>(Array),
"invalid imported entity list", &N, Array);
1009 AssertDI(
Op && isa<DIImportedEntity>(
Op),
"invalid imported entity ref",
1014 AssertDI(isa<MDTuple>(Array),
"invalid macro list", &N, Array);
1016 AssertDI(
Op && isa<DIMacroNode>(
Op),
"invalid macro ref", &N,
Op);
1019 CUVisited.insert(&N);
1022 void Verifier::visitDISubprogram(
const DISubprogram &N) {
1024 AssertDI(
isScope(N.getRawScope()),
"invalid scope", &N, N.getRawScope());
1026 AssertDI(isa<DIFile>(F),
"invalid file", &
N,
F);
1027 if (
auto *T = N.getRawType())
1028 AssertDI(isa<DISubroutineType>(T),
"invalid subroutine type", &
N,
T);
1029 AssertDI(
isType(N.getRawContainingType()),
"invalid containing type", &N,
1030 N.getRawContainingType());
1031 if (
auto *Params = N.getRawTemplateParams())
1032 visitTemplateParams(N, *Params);
1033 if (
auto *S = N.getRawDeclaration())
1034 AssertDI(isa<DISubprogram>(S) && !cast<DISubprogram>(S)->isDefinition(),
1035 "invalid subprogram declaration", &
N, S);
1036 if (
auto *RawVars = N.getRawVariables()) {
1038 AssertDI(Vars,
"invalid variable list", &N, RawVars);
1040 AssertDI(
Op && isa<DILocalVariable>(
Op),
"invalid local variable", &N,
1045 "invalid reference flags", &N);
1047 auto *
Unit = N.getRawUnit();
1048 if (N.isDefinition()) {
1051 AssertDI(
Unit,
"subprogram definitions must have a compile unit", &N);
1055 AssertDI(!
Unit,
"subprogram declarations must not have a compile unit", &N);
1060 AssertDI(N.
getTag() == dwarf::DW_TAG_lexical_block,
"invalid tag", &
N);
1066 visitDILexicalBlockBase(N);
1069 "cannot have column info without line info", &
N);
1073 visitDILexicalBlockBase(N);
1076 void Verifier::visitDINamespace(
const DINamespace &N) {
1079 AssertDI(isa<DIScope>(S),
"invalid scope ref", &
N, S);
1082 void Verifier::visitDIMacro(
const DIMacro &N) {
1085 "invalid macinfo type", &
N);
1092 void Verifier::visitDIMacroFile(
const DIMacroFile &N) {
1094 "invalid macinfo type", &
N);
1096 AssertDI(isa<DIFile>(F),
"invalid file", &
N,
F);
1099 AssertDI(isa<MDTuple>(Array),
"invalid macro list", &N, Array);
1101 AssertDI(
Op && isa<DIMacroNode>(
Op),
"invalid macro ref", &N,
Op);
1106 void Verifier::visitDIModule(
const DIModule &N) {
1116 visitDITemplateParameter(N);
1118 AssertDI(N.
getTag() == dwarf::DW_TAG_template_type_parameter,
"invalid tag",
1122 void Verifier::visitDITemplateValueParameter(
1124 visitDITemplateParameter(N);
1127 N.
getTag() == dwarf::DW_TAG_GNU_template_template_param ||
1128 N.
getTag() == dwarf::DW_TAG_GNU_template_parameter_pack,
1132 void Verifier::visitDIVariable(
const DIVariable &N) {
1134 AssertDI(isa<DIScope>(S),
"invalid scope", &
N, S);
1137 AssertDI(isa<DIFile>(F),
"invalid file", &
N,
F);
1147 AssertDI(isa<DIDerivedType>(Member),
1148 "invalid static data member declaration", &N, Member);
1158 "local variable requires a valid scope", &N, N.
getRawScope());
1161 void Verifier::visitDIExpression(
const DIExpression &N) {
1165 void Verifier::visitDIGlobalVariableExpression(
1169 visitDIGlobalVariable(*Var);
1171 visitDIExpression(*Expr);
1175 AssertDI(N.
getTag() == dwarf::DW_TAG_APPLE_property,
"invalid tag", &
N);
1179 AssertDI(isa<DIFile>(F),
"invalid file", &
N,
F);
1184 N.
getTag() == dwarf::DW_TAG_imported_declaration,
1187 AssertDI(isa<DIScope>(S),
"invalid scope for imported entity", &
N, S);
1192 void Verifier::visitComdat(
const Comdat &C) {
1200 void Verifier::visitModuleIdents(
const Module &M) {
1209 "incorrect number of operands in llvm.ident metadata",
N);
1211 (
"invalid value for llvm.ident metadata entry operand"
1212 "(the operand should be a string)"),
1217 void Verifier::visitModuleFlags(
const Module &M) {
1225 visitModuleFlag(MDN, SeenIDs, Requirements);
1228 for (
const MDNode *Requirement : Requirements) {
1229 const MDString *
Flag = cast<MDString>(Requirement->getOperand(0));
1230 const Metadata *ReqValue = Requirement->getOperand(1);
1234 CheckFailed(
"invalid requirement on flag, flag is not present in module",
1240 CheckFailed((
"invalid requirement on flag, "
1241 "flag does not have the required value"),
1249 Verifier::visitModuleFlag(
const MDNode *Op,
1255 "incorrect number of operands in module flag",
Op);
1259 mdconst::dyn_extract_or_null<ConstantInt>(Op->
getOperand(0)),
1260 "invalid behavior operand in module flag (expected constant integer)",
1263 "invalid behavior operand in module flag (unexpected constant)",
1267 Assert(ID,
"invalid ID operand in module flag (expected metadata string)",
1283 "invalid value for 'require' module flag (expected metadata pair)",
1286 (
"invalid value for 'require' module flag "
1287 "(first value operand should be a string)"),
1300 "invalid value for 'append'-type module flag "
1301 "(expected a metadata node)",
1309 bool Inserted = SeenIDs.
insert(std::make_pair(ID, Op)).second;
1311 "module flag identifiers must be unique (or of 'require' type)", ID);
1315 void Verifier::verifyAttributeTypes(
AttributeSet Attrs,
unsigned Idx,
1316 bool isFunction,
const Value *V) {
1317 unsigned Slot = ~0U;
1324 assert(Slot != ~0U &&
"Attribute set inconsistency!");
1328 if (
I->isStringAttribute())
1331 if (
I->getKindAsEnum() == Attribute::NoReturn ||
1332 I->getKindAsEnum() == Attribute::NoUnwind ||
1333 I->getKindAsEnum() == Attribute::NoInline ||
1334 I->getKindAsEnum() == Attribute::AlwaysInline ||
1335 I->getKindAsEnum() == Attribute::OptimizeForSize ||
1336 I->getKindAsEnum() == Attribute::StackProtect ||
1337 I->getKindAsEnum() == Attribute::StackProtectReq ||
1338 I->getKindAsEnum() == Attribute::StackProtectStrong ||
1339 I->getKindAsEnum() == Attribute::SafeStack ||
1340 I->getKindAsEnum() == Attribute::NoRedZone ||
1341 I->getKindAsEnum() == Attribute::NoImplicitFloat ||
1342 I->getKindAsEnum() == Attribute::Naked ||
1343 I->getKindAsEnum() == Attribute::InlineHint ||
1344 I->getKindAsEnum() == Attribute::StackAlignment ||
1345 I->getKindAsEnum() == Attribute::UWTable ||
1346 I->getKindAsEnum() == Attribute::NonLazyBind ||
1347 I->getKindAsEnum() == Attribute::ReturnsTwice ||
1348 I->getKindAsEnum() == Attribute::SanitizeAddress ||
1349 I->getKindAsEnum() == Attribute::SanitizeThread ||
1350 I->getKindAsEnum() == Attribute::SanitizeMemory ||
1351 I->getKindAsEnum() == Attribute::MinSize ||
1352 I->getKindAsEnum() == Attribute::NoDuplicate ||
1353 I->getKindAsEnum() == Attribute::Builtin ||
1354 I->getKindAsEnum() == Attribute::NoBuiltin ||
1356 I->getKindAsEnum() == Attribute::OptimizeNone ||
1359 I->getKindAsEnum() == Attribute::ArgMemOnly ||
1360 I->getKindAsEnum() == Attribute::NoRecurse ||
1361 I->getKindAsEnum() == Attribute::InaccessibleMemOnly ||
1362 I->getKindAsEnum() == Attribute::InaccessibleMemOrArgMemOnly ||
1363 I->getKindAsEnum() == Attribute::AllocSize) {
1365 CheckFailed(
"Attribute '" +
I->getAsString() +
1366 "' only applies to functions!", V);
1371 I->getKindAsEnum() == Attribute::ReadNone) {
1373 CheckFailed(
"Attribute '" +
I->getAsString() +
1374 "' does not apply to function returns");
1377 }
else if (isFunction) {
1378 CheckFailed(
"Attribute '" +
I->getAsString() +
1379 "' does not apply to functions!", V);
1387 void Verifier::verifyParameterAttrs(
AttributeSet Attrs,
unsigned Idx,
Type *Ty,
1388 bool isReturnValue,
const Value *V) {
1392 verifyAttributeTypes(Attrs, Idx,
false, V);
1403 "Attributes 'byval', 'inalloca', 'nest', 'sret', 'nocapture', "
1404 "'returned', 'swiftself', and 'swifterror' do not apply to return "
1410 unsigned AttrCount = 0;
1411 AttrCount += Attrs.
hasAttribute(Idx, Attribute::ByVal);
1412 AttrCount += Attrs.
hasAttribute(Idx, Attribute::InAlloca);
1413 AttrCount += Attrs.
hasAttribute(Idx, Attribute::StructRet) ||
1416 Assert(AttrCount <= 1,
"Attributes 'byval', 'inalloca', 'inreg', 'nest', "
1417 "and 'sret' are incompatible!",
1423 "'inalloca and readonly' are incompatible!",
1429 "'sret and returned' are incompatible!",
1435 "'zeroext and signext' are incompatible!",
1441 "'readnone and readonly' are incompatible!",
1447 "'readnone and writeonly' are incompatible!",
1453 "'readonly and writeonly' are incompatible!",
1459 "'noinline and alwaysinline' are incompatible!",
1464 "Wrong types for attribute: " +
1469 if (
PointerType *PTy = dyn_cast<PointerType>(Ty)) {
1474 "Attributes 'byval' and 'inalloca' do not support unsized types!",
1479 "Attribute 'swifterror' only applies to parameters "
1480 "with pointer to pointer type!",
1484 "Attribute 'byval' only applies to parameters with pointer type!",
1487 "Attribute 'swifterror' only applies to parameters "
1488 "with pointer type!",
1500 bool SawNest =
false;
1501 bool SawReturned =
false;
1502 bool SawSRet =
false;
1503 bool SawSwiftSelf =
false;
1504 bool SawSwiftError =
false;
1517 verifyParameterAttrs(Attrs, Idx, Ty, Idx == 0, V);
1523 Assert(!SawNest,
"More than one parameter has attribute nest!", V);
1528 Assert(!SawReturned,
"More than one parameter has attribute returned!",
1532 "argument and return types for 'returned' attribute",
1538 Assert(!SawSRet,
"Cannot have multiple 'sret' parameters!", V);
1539 Assert(Idx == 1 || Idx == 2,
1540 "Attribute 'sret' is not on first or second parameter!", V);
1545 Assert(!SawSwiftSelf,
"Cannot have multiple 'swiftself' parameters!", V);
1546 SawSwiftSelf =
true;
1550 Assert(!SawSwiftError,
"Cannot have multiple 'swifterror' parameters!",
1552 SawSwiftError =
true;
1569 "Attributes 'readnone and readonly' are incompatible!", V);
1574 "Attributes 'readnone and writeonly' are incompatible!", V);
1579 "Attributes 'readonly and writeonly' are incompatible!", V);
1584 Attribute::InaccessibleMemOrArgMemOnly)),
1585 "Attributes 'readnone and inaccessiblemem_or_argmemonly' are incompatible!", V);
1590 Attribute::InaccessibleMemOnly)),
1591 "Attributes 'readnone and inaccessiblememonly' are incompatible!", V);
1596 Attribute::AlwaysInline)),
1597 "Attributes 'noinline and alwaysinline' are incompatible!", V);
1600 Attribute::OptimizeNone)) {
1602 "Attribute 'optnone' requires 'noinline'!", V);
1605 Attribute::OptimizeForSize),
1606 "Attributes 'optsize and optnone' are incompatible!", V);
1609 "Attributes 'minsize and optnone' are incompatible!", V);
1616 "Attribute 'jumptable' requires 'unnamed_addr'", V);
1620 std::pair<unsigned, Optional<unsigned>>
Args =
1625 CheckFailed(
"'allocsize' " + Name +
" argument is out of bounds", V);
1630 CheckFailed(
"'allocsize' " + Name +
1631 " argument must refer to an integer parameter",
1639 if (!CheckParam(
"element size", Args.first))
1642 if (Args.second && !CheckParam(
"number of elements", *Args.second))
1647 void Verifier::verifyFunctionMetadata(
1648 ArrayRef<std::pair<unsigned, MDNode *>> MDs) {
1649 for (
const auto &Pair : MDs) {
1651 MDNode *MD = Pair.second;
1653 "!prof annotations should have exactly 2 operands", MD);
1659 "expected string with name of the !prof annotation", MD);
1662 Assert(ProfName.equals(
"function_entry_count"),
1663 "first operand should be 'function_entry_count'", MD);
1669 "expected integer argument to function_entry_count", MD);
1674 void Verifier::visitConstantExprsRecursively(
const Constant *EntryC) {
1675 if (!ConstantExprVisited.insert(EntryC).second)
1681 while (!Stack.
empty()) {
1685 if (
const auto *CE = dyn_cast<ConstantExpr>(C))
1686 visitConstantExpr(CE);
1688 if (
const auto *GV = dyn_cast<GlobalValue>(C)) {
1691 Assert(GV->
getParent() == &M,
"Referencing global in another module!",
1701 if (!ConstantExprVisited.insert(OpC).second)
1708 void Verifier::visitConstantExpr(
const ConstantExpr *CE) {
1709 if (CE->
getOpcode() == Instruction::BitCast)
1712 "Invalid bitcast", CE);
1714 if (CE->
getOpcode() == Instruction::IntToPtr ||
1715 CE->
getOpcode() == Instruction::PtrToInt) {
1716 auto *PtrTy = CE->
getOpcode() == Instruction::IntToPtr
1720 ?
"inttoptr not supported for non-integral pointers"
1721 :
"ptrtoint not supported for non-integral pointers";
1723 !
DL.isNonIntegralPointerType(cast<PointerType>(PtrTy->getScalarType())),
1728 bool Verifier::verifyAttributeCount(
AttributeSet Attrs,
unsigned Params) {
1734 if (LastIndex <= Params
1736 && (LastSlot == 0 || Attrs.
getSlotIndex(LastSlot - 1) <= Params)))
1746 Intrinsic::experimental_gc_statepoint);
1752 "gc.statepoint must read and write all memory to preserve "
1753 "reordering restrictions required by safepoint semantics",
1757 Assert(isa<ConstantInt>(IDV),
"gc.statepoint ID must be a constant integer",
1761 Assert(isa<ConstantInt>(NumPatchBytesV),
1762 "gc.statepoint number of patchable bytes must be a constant integer",
1764 const int64_t NumPatchBytes =
1765 cast<ConstantInt>(NumPatchBytesV)->getSExtValue();
1767 Assert(NumPatchBytes >= 0,
"gc.statepoint number of patchable bytes must be "
1773 Assert(PT && PT->getElementType()->isFunctionTy(),
1774 "gc.statepoint callee must be of function pointer type", &CI,
Target);
1775 FunctionType *TargetFuncType = cast<FunctionType>(PT->getElementType());
1778 Assert(isa<ConstantInt>(NumCallArgsV),
1779 "gc.statepoint number of arguments to underlying call "
1780 "must be constant integer",
1782 const int NumCallArgs = cast<ConstantInt>(NumCallArgsV)->getZExtValue();
1784 "gc.statepoint number of arguments to underlying call "
1787 const int NumParams = (int)TargetFuncType->getNumParams();
1788 if (TargetFuncType->isVarArg()) {
1789 Assert(NumCallArgs >= NumParams,
1790 "gc.statepoint mismatch in number of vararg call args", &CI);
1793 Assert(TargetFuncType->getReturnType()->isVoidTy(),
1794 "gc.statepoint doesn't support wrapping non-void "
1795 "vararg functions yet",
1798 Assert(NumCallArgs == NumParams,
1799 "gc.statepoint mismatch in number of call args", &CI);
1802 Assert(isa<ConstantInt>(FlagsV),
1803 "gc.statepoint flags must be constant integer", &CI);
1804 const uint64_t Flags = cast<ConstantInt>(FlagsV)->getZExtValue();
1806 "unknown flag used in gc.statepoint flags argument", &CI);
1810 for (
int i = 0;
i < NumParams;
i++) {
1811 Type *ParamType = TargetFuncType->getParamType(
i);
1813 Assert(ArgType == ParamType,
1814 "gc.statepoint call argument does not match wrapped "
1819 const int EndCallArgsInx = 4 + NumCallArgs;
1821 const Value *NumTransitionArgsV = CS.
getArgument(EndCallArgsInx+1);
1822 Assert(isa<ConstantInt>(NumTransitionArgsV),
1823 "gc.statepoint number of transition arguments "
1824 "must be constant integer",
1826 const int NumTransitionArgs =
1827 cast<ConstantInt>(NumTransitionArgsV)->getZExtValue();
1828 Assert(NumTransitionArgs >= 0,
1829 "gc.statepoint number of transition arguments must be positive", &CI);
1830 const int EndTransitionArgsInx = EndCallArgsInx + 1 + NumTransitionArgs;
1832 const Value *NumDeoptArgsV = CS.
getArgument(EndTransitionArgsInx+1);
1833 Assert(isa<ConstantInt>(NumDeoptArgsV),
1834 "gc.statepoint number of deoptimization arguments "
1835 "must be constant integer",
1837 const int NumDeoptArgs = cast<ConstantInt>(NumDeoptArgsV)->getZExtValue();
1838 Assert(NumDeoptArgs >= 0,
"gc.statepoint number of deoptimization arguments "
1842 const int ExpectedNumArgs =
1843 7 + NumCallArgs + NumTransitionArgs + NumDeoptArgs;
1845 "gc.statepoint too few arguments according to length fields", &CI);
1850 for (
const User *U : CI.
users()) {
1852 Assert(Call,
"illegal use of statepoint token", &CI, U);
1853 if (!Call)
continue;
1854 Assert(isa<GCRelocateInst>(Call) || isa<GCResultInst>(Call),
1855 "gc.result or gc.relocate are the only value uses "
1856 "of a gc.statepoint",
1858 if (isa<GCResultInst>(Call)) {
1860 "gc.result connected to wrong gc.statepoint", &CI,
Call);
1861 }
else if (isa<GCRelocateInst>(Call)) {
1863 "gc.relocate connected to wrong gc.statepoint", &CI,
Call);
1877 void Verifier::verifyFrameRecoverIndices() {
1878 for (
auto &Counts : FrameEscapeInfo) {
1880 unsigned EscapedObjectCount = Counts.second.first;
1881 unsigned MaxRecoveredIndex = Counts.second.second;
1882 Assert(MaxRecoveredIndex <= EscapedObjectCount,
1883 "all indices passed to llvm.localrecover must be less than the "
1884 "number of arguments passed ot llvm.localescape in the parent "
1892 if (
auto *II = dyn_cast<InvokeInst>(Terminator))
1893 UnwindDest = II->getUnwindDest();
1894 else if (
auto *CSI = dyn_cast<CatchSwitchInst>(Terminator))
1895 UnwindDest = CSI->getUnwindDest();
1897 UnwindDest = cast<CleanupReturnInst>(
Terminator)->getUnwindDest();
1901 void Verifier::verifySiblingFuncletUnwinds() {
1904 for (
const auto &Pair : SiblingFuncletInfo) {
1906 if (Visited.
count(PredPad))
1912 if (Active.
count(SuccPad)) {
1919 if (CycleTerminator != CyclePad)
1922 }
while (CyclePad != SuccPad);
1923 Assert(
false,
"EH pads can't handle each other's exceptions",
1927 if (!Visited.
insert(SuccPad).second)
1931 auto TermI = SiblingFuncletInfo.find(PredPad);
1932 if (TermI == SiblingFuncletInfo.end())
1934 Terminator = TermI->second;
1945 void Verifier::visitFunction(
const Function &F) {
1946 visitGlobalValue(F);
1953 "Function context does not match Module context!", &
F);
1957 "# formal arguments must match # of arguments for function type!", &
F,
1959 Assert(F.getReturnType()->isFirstClassType() ||
1960 F.getReturnType()->isVoidTy() || F.getReturnType()->isStructTy(),
1961 "Functions cannot return aggregate values!", &
F);
1963 Assert(!F.hasStructRetAttr() || F.getReturnType()->isVoidTy(),
1964 "Invalid struct return type!", &
F);
1969 "Attribute after last parameter!", &F);
1972 verifyFunctionAttrs(FT, Attrs, &F);
1978 "Attribute 'builtin' can only be applied to a callsite.", &
F);
1983 switch (F.getCallingConv()) {
1992 Assert(!F.isVarArg(),
"Calling convention does not support varargs or "
1993 "perfect forwarding!",
1998 bool isLLVMdotName = F.getName().size() >= 5 &&
1999 F.getName().substr(0, 5) ==
"llvm.";
2003 for (
const Argument &Arg : F.args()) {
2005 "Argument value does not match function argument type!", &Arg,
2007 Assert(Arg.getType()->isFirstClassType(),
2008 "Function arguments must have first-class types!", &Arg);
2009 if (!isLLVMdotName) {
2010 Assert(!Arg.getType()->isMetadataTy(),
2011 "Function takes metadata but isn't an intrinsic", &Arg, &
F);
2012 Assert(!Arg.getType()->isTokenTy(),
2013 "Function takes token but isn't an intrinsic", &Arg, &
F);
2017 if (Attrs.hasAttribute(i+1, Attribute::SwiftError)) {
2018 verifySwiftErrorValue(&Arg);
2024 Assert(!F.getReturnType()->isTokenTy(),
2025 "Functions returns a token but isn't an intrinsic", &
F);
2029 F.getAllMetadata(MDs);
2030 assert(F.hasMetadata() != MDs.empty() &&
"Bit out-of-sync");
2031 verifyFunctionMetadata(MDs);
2034 if (F.hasPersonalityFn()) {
2037 Assert(Per->getParent() == F.getParent(),
2038 "Referencing personality function in another module!",
2039 &
F, F.getParent(), Per, Per->getParent());
2042 if (F.isMaterializable()) {
2044 Assert(MDs.empty(),
"unmaterialized function cannot have metadata", &
F,
2045 MDs.empty() ?
nullptr : MDs.front().second);
2046 }
else if (F.isDeclaration()) {
2047 for (
const auto &
I : MDs) {
2049 "function declaration may not have a !dbg attachment", &F);
2051 "function declaration may not have a !prof attachment", &F);
2054 visitMDNode(*
I.second);
2056 Assert(!F.hasPersonalityFn(),
2057 "Function declaration shouldn't have a personality routine", &
F);
2061 Assert(!isLLVMdotName,
"llvm intrinsics cannot be defined!", &F);
2064 const BasicBlock *Entry = &F.getEntryBlock();
2066 "Entry block to function must not have predecessors!", Entry);
2071 "blockaddress may not be used with the entry block!", Entry);
2074 unsigned NumDebugAttachments = 0, NumProfAttachments = 0;
2076 for (
const auto &
I : MDs) {
2082 ++NumDebugAttachments;
2084 "function must have a single !dbg attachment", &F,
I.second);
2086 "function !dbg attachment must be a subprogram", &F,
I.second);
2089 ++NumProfAttachments;
2090 Assert(NumProfAttachments == 1,
2091 "function must have a single !prof attachment", &F,
I.second);
2096 visitMDNode(*
I.second);
2104 if (F.getIntrinsicID() && F.getParent()->isMaterialized()) {
2106 if (F.hasAddressTaken(&U))
2107 Assert(
false,
"Invalid user of intrinsic instruction!", U);
2110 Assert(!F.hasDLLImportStorageClass() ||
2111 (F.isDeclaration() && F.hasExternalLinkage()) ||
2112 F.hasAvailableExternallyLinkage(),
2113 "Function is marked as dllimport, but not external.", &
F);
2115 auto *N = F.getSubprogram();
2119 visitDISubprogram(*N);
2128 for (
auto &
I : BB) {
2132 dyn_cast_or_null<DILocation>(
I.getDebugLoc().getAsMDNode());
2135 if (!Seen.
insert(DL).second)
2139 if (Scope && !Seen.
insert(Scope).second)
2146 if (SP && ((Scope != SP) && !Seen.
insert(SP).second))
2151 "!dbg attachment points at wrong subprogram for function",
N, &
F,
2158 void Verifier::visitBasicBlock(
BasicBlock &BB) {
2159 InstsInThisBlock.clear();
2166 if (isa<PHINode>(BB.
front())) {
2169 std::sort(Preds.begin(), Preds.end());
2173 Assert(PN->getNumIncomingValues() != 0,
2174 "PHI nodes must have at least one entry. If the block is dead, "
2175 "the PHI should be removed!",
2177 Assert(PN->getNumIncomingValues() == Preds.size(),
2178 "PHINode should have one entry for each predecessor of its "
2179 "parent basic block!",
2184 Values.
reserve(PN->getNumIncomingValues());
2185 for (
unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++
i)
2186 Values.
push_back(std::make_pair(PN->getIncomingBlock(i),
2187 PN->getIncomingValue(i)));
2188 std::sort(Values.
begin(), Values.
end());
2190 for (
unsigned i = 0, e = Values.
size(); i != e; ++
i) {
2195 Assert(i == 0 || Values[i].first != Values[i - 1].first ||
2196 Values[i].second == Values[i - 1].second,
2197 "PHI node has multiple entries for the same basic block with "
2198 "different incoming values!",
2199 PN, Values[i].first, Values[i].second, Values[i - 1].second);
2203 Assert(Values[i].first == Preds[i],
2204 "PHI node entries do not match predecessors!", PN,
2205 Values[i].first, Preds[i]);
2213 Assert(
I.getParent() == &BB,
"Instruction has bogus parent pointer!");
2220 "Terminator found in the middle of a basic block!", I.
getParent());
2221 visitInstruction(I);
2224 void Verifier::visitBranchInst(
BranchInst &BI) {
2227 "Branch condition is not 'i1' type!", &BI, BI.
getCondition());
2229 visitTerminatorInst(BI);
2232 void Verifier::visitReturnInst(
ReturnInst &RI) {
2237 "Found return instr that returns non-void in Function of void "
2242 "Function return type does not match operand "
2243 "type of return inst!",
2248 visitTerminatorInst(RI);
2256 for (
auto &Case : SI.
cases()) {
2257 Assert(Case.getCaseValue()->getType() == SwitchTy,
2258 "Switch constants must all be same type as switch value!", &
SI);
2260 "Duplicate integer as switch case", &SI, Case.getCaseValue());
2263 visitTerminatorInst(SI);
2268 "Indirectbr operand must have pointer type!", &BI);
2271 "Indirectbr destinations must all have pointer type!", &BI);
2273 visitTerminatorInst(BI);
2276 void Verifier::visitSelectInst(
SelectInst &SI) {
2279 "Invalid operands for select instruction!", &SI);
2282 "Select values must have same type as select instruction!", &
SI);
2283 visitInstruction(SI);
2290 Assert(
false,
"User-defined operators should not live outside of a pass!", &I);
2293 void Verifier::visitTruncInst(
TruncInst &I) {
2305 "trunc source and destination must both be a vector or neither", &
I);
2306 Assert(SrcBitSize > DestBitSize,
"DestTy too big for Trunc", &I);
2308 visitInstruction(I);
2311 void Verifier::visitZExtInst(
ZExtInst &I) {
2320 "zext source and destination must both be a vector or neither", &
I);
2324 Assert(SrcBitSize < DestBitSize,
"Type too small for ZExt", &I);
2326 visitInstruction(I);
2329 void Verifier::visitSExtInst(
SExtInst &I) {
2341 "sext source and destination must both be a vector or neither", &
I);
2342 Assert(SrcBitSize < DestBitSize,
"Type too small for SExt", &I);
2344 visitInstruction(I);
2358 "fptrunc source and destination must both be a vector or neither", &
I);
2359 Assert(SrcBitSize > DestBitSize,
"DestTy too big for FPTrunc", &I);
2361 visitInstruction(I);
2364 void Verifier::visitFPExtInst(
FPExtInst &I) {
2376 "fpext source and destination must both be a vector or neither", &
I);
2377 Assert(SrcBitSize < DestBitSize,
"DestTy too small for FPExt", &I);
2379 visitInstruction(I);
2382 void Verifier::visitUIToFPInst(
UIToFPInst &I) {
2391 "UIToFP source and dest must both be vector or scalar", &I);
2393 "UIToFP source must be integer or integer vector", &
I);
2397 if (SrcVec && DstVec)
2398 Assert(cast<VectorType>(SrcTy)->getNumElements() ==
2399 cast<VectorType>(DestTy)->getNumElements(),
2400 "UIToFP source and dest vector length mismatch", &I);
2402 visitInstruction(I);
2405 void Verifier::visitSIToFPInst(
SIToFPInst &I) {
2414 "SIToFP source and dest must both be vector or scalar", &I);
2416 "SIToFP source must be integer or integer vector", &
I);
2420 if (SrcVec && DstVec)
2421 Assert(cast<VectorType>(SrcTy)->getNumElements() ==
2422 cast<VectorType>(DestTy)->getNumElements(),
2423 "SIToFP source and dest vector length mismatch", &I);
2425 visitInstruction(I);
2428 void Verifier::visitFPToUIInst(
FPToUIInst &I) {
2437 "FPToUI source and dest must both be vector or scalar", &I);
2441 "FPToUI result must be integer or integer vector", &
I);
2443 if (SrcVec && DstVec)
2444 Assert(cast<VectorType>(SrcTy)->getNumElements() ==
2445 cast<VectorType>(DestTy)->getNumElements(),
2446 "FPToUI source and dest vector length mismatch", &I);
2448 visitInstruction(I);
2451 void Verifier::visitFPToSIInst(
FPToSIInst &I) {
2460 "FPToSI source and dest must both be vector or scalar", &I);
2464 "FPToSI result must be integer or integer vector", &
I);
2466 if (SrcVec && DstVec)
2467 Assert(cast<VectorType>(SrcTy)->getNumElements() ==
2468 cast<VectorType>(DestTy)->getNumElements(),
2469 "FPToSI source and dest vector length mismatch", &I);
2471 visitInstruction(I);
2480 "PtrToInt source must be pointer", &
I);
2482 if (
auto *PTy = dyn_cast<PointerType>(SrcTy->
getScalarType()))
2483 Assert(!DL.isNonIntegralPointerType(PTy),
2484 "ptrtoint not supported for non-integral pointers");
2487 "PtrToInt result must be integral", &
I);
2495 "PtrToInt Vector width mismatch", &
I);
2498 visitInstruction(I);
2507 "IntToPtr source must be an integral", &
I);
2509 "IntToPtr result must be a pointer", &
I);
2511 if (
auto *PTy = dyn_cast<PointerType>(DestTy->
getScalarType()))
2512 Assert(!DL.isNonIntegralPointerType(PTy),
2513 "inttoptr not supported for non-integral pointers");
2521 "IntToPtr Vector width mismatch", &
I);
2523 visitInstruction(I);
2529 "Invalid bitcast", &I);
2530 visitInstruction(I);
2542 "AddrSpaceCast must be between different address spaces", &
I);
2545 "AddrSpaceCast vector pointer number of elements mismatch", &
I);
2546 visitInstruction(I);
2551 void Verifier::visitPHINode(
PHINode &PN) {
2558 "PHI nodes not grouped at top of basic block!", &PN, PN.
getParent());
2567 "PHI node operands are not the same type as the result!", &PN);
2572 visitInstruction(PN);
2575 void Verifier::verifyCallSite(
CallSite CS) {
2579 "Called function must be a pointer!",
I);
2582 Assert(FPTy->getElementType()->isFunctionTy(),
2583 "Called function is not pointer to function type!",
I);
2586 "Called function is not the same type as the call!",
I);
2591 if (FTy->isVarArg())
2593 "Called function requires more parameters than were provided!",
I);
2596 "Incorrect number of arguments passed to called function!",
I);
2599 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++
i)
2601 "Call parameter type does not match function signature!",
2607 "Attribute after last parameter!", I);
2610 verifyFunctionAttrs(FTy, Attrs, I);
2616 Value *InAllocaArg = CS.
getArgument(FTy->getNumParams() - 1);
2618 Assert(AI->isUsedWithInAlloca(),
2619 "inalloca argument for call has mismatched alloca", AI,
I);
2625 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++
i)
2629 Assert(AI->isSwiftError(),
2630 "swifterror argument for call has mismatched alloca", AI,
I);
2634 Assert(ArgI,
"swifterror argument should come from an alloca or parameter", SwiftErrorArg, I);
2635 Assert(ArgI->hasSwiftErrorAttr(),
2636 "swifterror argument for call has mismatched parameter", ArgI,
I);
2639 if (FTy->isVarArg()) {
2641 bool SawNest =
false;
2642 bool SawReturned =
false;
2644 for (
unsigned Idx = 1; Idx < 1 + FTy->getNumParams(); ++Idx) {
2652 for (
unsigned Idx = 1 + FTy->getNumParams(); Idx <= CS.
arg_size(); ++Idx) {
2654 verifyParameterAttrs(Attrs, Idx, Ty,
false, I);
2657 Assert(!SawNest,
"More than one parameter has attribute nest!", I);
2662 Assert(!SawReturned,
"More than one parameter has attribute returned!",
2665 "Incompatible argument and return types for 'returned' "
2672 "Attribute 'sret' cannot be used for vararg call arguments!",
I);
2675 Assert(Idx == CS.
arg_size(),
"inalloca isn't on the last argument!",
I);
2682 for (
Type *ParamTy : FTy->params()) {
2683 Assert(!ParamTy->isMetadataTy(),
2684 "Function has metadata parameter but isn't an intrinsic",
I);
2685 Assert(!ParamTy->isTokenTy(),
2686 "Function has token parameter but isn't an intrinsic",
I);
2692 Assert(!FTy->getReturnType()->isTokenTy(),
2693 "Return type cannot be token for indirect call!");
2697 visitIntrinsicCallSite(ID, CS);
2701 bool FoundDeoptBundle =
false, FoundFuncletBundle =
false,
2702 FoundGCTransitionBundle =
false;
2707 Assert(!FoundDeoptBundle,
"Multiple deopt operand bundles", I);
2708 FoundDeoptBundle =
true;
2710 Assert(!FoundGCTransitionBundle,
"Multiple gc-transition operand bundles",
2712 FoundGCTransitionBundle =
true;
2714 Assert(!FoundFuncletBundle,
"Multiple funclet operand bundles", I);
2715 FoundFuncletBundle =
true;
2717 "Expected exactly one funclet bundle operand",
I);
2719 "Funclet bundle operands should correspond to a FuncletPadInst",
2730 "info must have a !dbg location",
2733 visitInstruction(*I);
2750 Attribute::StructRet, Attribute::ByVal, Attribute::InAlloca,
2751 Attribute::InReg, Attribute::Returned, Attribute::SwiftSelf,
2752 Attribute::SwiftError};
2754 for (
auto AK : ABIAttrs) {
2763 void Verifier::verifyMustTailCall(
CallInst &CI) {
2773 "cannot guarantee tail call due to mismatched parameter counts", &CI);
2775 "cannot guarantee tail call due to mismatched varargs", &CI);
2777 "cannot guarantee tail call due to mismatched return types", &CI);
2781 "cannot guarantee tail call due to mismatched parameter types", &CI);
2786 "cannot guarantee tail call due to mismatched calling conv", &CI);
2795 Assert(CallerABIAttrs == CalleeABIAttrs,
2796 "cannot guarantee tail call due to mismatched ABI impacting "
2797 "function attributes",
2805 Value *RetVal = &CI;
2809 if (
BitCastInst *BI = dyn_cast_or_null<BitCastInst>(Next)) {
2811 "bitcast following musttail call must use the call", BI);
2818 Assert(Ret,
"musttail call must be precede a ret with an optional bitcast",
2821 "musttail call result must be returned",
Ret);
2824 void Verifier::visitCallInst(
CallInst &CI) {
2825 verifyCallSite(&CI);
2828 verifyMustTailCall(CI);
2831 void Verifier::visitInvokeInst(
InvokeInst &II) {
2832 verifyCallSite(&II);
2838 "The unwind destination does not have an exception handling instruction!",
2841 visitTerminatorInst(II);
2849 "Both operands to a binary operator are not of the same type!", &
B);
2855 case Instruction::Sub:
2856 case Instruction::Mul:
2857 case Instruction::SDiv:
2858 case Instruction::UDiv:
2859 case Instruction::SRem:
2860 case Instruction::URem:
2862 "Integer arithmetic operators only work with integral types!", &
B);
2864 "Integer arithmetic operators must have same type "
2865 "for operands and result!",
2870 case Instruction::FAdd:
2871 case Instruction::FSub:
2872 case Instruction::FMul:
2873 case Instruction::FDiv:
2874 case Instruction::FRem:
2876 "Floating-point arithmetic operators only work with "
2877 "floating-point types!",
2880 "Floating-point arithmetic operators must have same type "
2881 "for operands and result!",
2889 "Logical operators only work with integral types!", &
B);
2891 "Logical operators must have same type for operands and result!",
2894 case Instruction::Shl:
2895 case Instruction::LShr:
2896 case Instruction::AShr:
2898 "Shifts only work with integral types!", &
B);
2900 "Shift return type must be same as operands!", &
B);
2906 visitInstruction(B);
2909 void Verifier::visitICmpInst(
ICmpInst &IC) {
2914 "Both operands to ICmp instruction are not of the same type!", &IC);
2917 "Invalid operand types for ICmp instruction", &IC);
2921 "Invalid predicate in ICmp instruction!", &IC);
2923 visitInstruction(IC);
2931 "Both operands to FCmp instruction are not of the same type!", &FC);
2934 "Invalid operand types for FCmp instruction", &
FC);
2938 "Invalid predicate in FCmp instruction!", &
FC);
2940 visitInstruction(FC);
2946 "Invalid extractelement operands!", &EI);
2947 visitInstruction(EI);
2953 "Invalid insertelement operands!", &IE);
2954 visitInstruction(IE);
2960 "Invalid shufflevector operands!", &SV);
2961 visitInstruction(SV);
2967 Assert(isa<PointerType>(TargetTy),
2968 "GEP base pointer is not a vector or a vector of pointers", &GEP);
2973 Assert(ElTy,
"Invalid indices for GEP pointer type!", &GEP);
2977 "GEP is not of right type for indices!", &
GEP, ElTy);
2979 if (GEP.getType()->isVectorTy()) {
2981 unsigned GEPWidth = GEP.getType()->getVectorNumElements();
2982 if (GEP.getPointerOperandType()->isVectorTy())
2983 Assert(GEPWidth == GEP.getPointerOperandType()->getVectorNumElements(),
2984 "Vector GEP result width doesn't match operand's", &
GEP);
2985 for (Value *Idx : Idxs) {
2986 Type *IndexTy = Idx->getType();
2989 Assert(IndexWidth == GEPWidth,
"Invalid GEP index vector width", &GEP);
2992 "All GEP indices should be of integer type");
2995 visitInstruction(GEP);
3004 "precondition violation");
3007 Assert(NumOperands % 2 == 0,
"Unfinished range!", Range);
3008 unsigned NumRanges = NumOperands / 2;
3009 Assert(NumRanges >= 1,
"It should have at least one range!", Range);
3012 for (
unsigned i = 0; i < NumRanges; ++
i) {
3014 mdconst::dyn_extract<ConstantInt>(Range->
getOperand(2 * i));
3015 Assert(Low,
"The lower limit must be an integer!", Low);
3017 mdconst::dyn_extract<ConstantInt>(Range->
getOperand(2 * i + 1));
3018 Assert(High,
"The upper limit must be an integer!", High);
3020 "Range types must match instruction type!", &
I);
3025 Assert(!CurRange.isEmptySet() && !CurRange.isFullSet(),
3026 "Range must not be empty!", Range);
3028 Assert(CurRange.intersectWith(LastRange).isEmptySet(),
3029 "Intervals are overlapping", Range);
3030 Assert(LowV.
sgt(LastRange.getLower()),
"Intervals are not in order",
3037 if (NumRanges > 2) {
3039 mdconst::dyn_extract<ConstantInt>(Range->
getOperand(0))->getValue();
3041 mdconst::dyn_extract<ConstantInt>(Range->
getOperand(1))->getValue();
3043 Assert(FirstRange.intersectWith(LastRange).isEmptySet(),
3044 "Intervals are overlapping", Range);
3050 void Verifier::checkAtomicMemAccessSize(
Type *Ty,
const Instruction *I) {
3051 unsigned Size = DL.getTypeSizeInBits(Ty);
3052 Assert(Size >= 8,
"atomic memory access' size must be byte-sized", Ty, I);
3053 Assert(!(Size & (Size - 1)),
3054 "atomic memory access' operand must have a power-of-two size", Ty, I);
3057 void Verifier::visitLoadInst(
LoadInst &LI) {
3059 Assert(PTy,
"Load operand must be a pointer.", &LI);
3062 "huge alignment values are unsupported", &LI);
3063 Assert(ElTy->
isSized(),
"loading unsized types is not allowed", &LI);
3067 "Load cannot have Release ordering", &LI);
3069 "Atomic load must specify explicit alignment", &LI);
3072 "atomic load operand must have integer, pointer, or floating point "
3075 checkAtomicMemAccessSize(ElTy, &LI);
3078 "Non-atomic load cannot have SynchronizationScope specified", &LI);
3081 visitInstruction(LI);
3084 void Verifier::visitStoreInst(
StoreInst &SI) {
3086 Assert(PTy,
"Store operand must be a pointer.", &SI);
3089 "Stored value type does not match pointer operand type!", &
SI, ElTy);
3091 "huge alignment values are unsupported", &
SI);
3096 "Store cannot have Acquire ordering", &
SI);
3098 "Atomic store must specify explicit alignment", &
SI);
3101 "atomic store operand must have integer, pointer, or floating point "
3104 checkAtomicMemAccessSize(ElTy, &SI);
3107 "Non-atomic store cannot have SynchronizationScope specified", &
SI);
3109 visitInstruction(SI);
3113 void Verifier::verifySwiftErrorCallSite(
CallSite CS,
3114 const Value *SwiftErrorVal) {
3117 I !=
E; ++
I, ++Idx) {
3118 if (*I == SwiftErrorVal) {
3120 "swifterror value when used in a callsite should be marked "
3121 "with swifterror attribute",
3127 void Verifier::verifySwiftErrorValue(
const Value *SwiftErrorVal) {
3130 for (
const User *U : SwiftErrorVal->
users()) {
3131 Assert(isa<LoadInst>(U) || isa<StoreInst>(U) || isa<CallInst>(U) ||
3133 "swifterror value can only be loaded and stored from, or "
3134 "as a swifterror argument!",
3137 if (
auto StoreI = dyn_cast<StoreInst>(U))
3138 Assert(StoreI->getOperand(1) == SwiftErrorVal,
3139 "swifterror value should be the second operand when used "
3140 "by stores", SwiftErrorVal, U);
3141 if (
auto CallI = dyn_cast<CallInst>(U))
3142 verifySwiftErrorCallSite(const_cast<CallInst*>(CallI), SwiftErrorVal);
3143 if (
auto II = dyn_cast<InvokeInst>(U))
3144 verifySwiftErrorCallSite(const_cast<InvokeInst*>(II), SwiftErrorVal);
3148 void Verifier::visitAllocaInst(
AllocaInst &AI) {
3152 "Allocation instruction pointer not in the generic address space!",
3155 "Cannot allocate unsized type", &AI);
3157 "Alloca array size must have integer type", &AI);
3159 "huge alignment values are unsupported", &AI);
3162 verifySwiftErrorValue(&AI);
3165 visitInstruction(AI);
3172 "cmpxchg instructions must be atomic.", &CXI);
3174 "cmpxchg instructions must be atomic.", &CXI);
3176 "cmpxchg instructions cannot be unordered.", &CXI);
3178 "cmpxchg instructions cannot be unordered.", &CXI);
3180 "cmpxchg instructions failure argument shall be no stronger than the "
3185 "cmpxchg failure ordering cannot include release semantics", &CXI);
3188 Assert(PTy,
"First cmpxchg operand must be a pointer.", &CXI);
3189 Type *ElTy = PTy->getElementType();
3191 "cmpxchg operand must have integer or pointer type",
3193 checkAtomicMemAccessSize(ElTy, &CXI);
3195 "Expected value type does not match pointer operand type!", &CXI,
3198 "Stored value type does not match pointer operand type!", &CXI, ElTy);
3199 visitInstruction(CXI);
3204 "atomicrmw instructions must be atomic.", &RMWI);
3206 "atomicrmw instructions cannot be unordered.", &RMWI);
3208 Assert(PTy,
"First atomicrmw operand must be a pointer.", &RMWI);
3209 Type *ElTy = PTy->getElementType();
3212 checkAtomicMemAccessSize(ElTy, &RMWI);
3214 "Argument value type does not match pointer operand type!", &RMWI,
3218 "Invalid binary operation!", &RMWI);
3219 visitInstruction(RMWI);
3222 void Verifier::visitFenceInst(
FenceInst &FI) {
3228 "fence instructions may only have acquire, release, acq_rel, or "
3229 "seq_cst ordering.",
3231 visitInstruction(FI);
3237 "Invalid ExtractValueInst operands!", &EVI);
3239 visitInstruction(EVI);
3246 "Invalid InsertValueInst operands!", &IVI);
3248 visitInstruction(IVI);
3252 if (
auto *FPI = dyn_cast<FuncletPadInst>(EHPad))
3253 return FPI->getParentPad();
3258 void Verifier::visitEHPadPredecessors(
Instruction &I) {
3266 if (
auto *LPI = dyn_cast<LandingPadInst>(&I)) {
3273 "Block containing LandingPadInst must be jumped to "
3274 "only by the unwind edge of an invoke.",
3279 if (
auto *CPI = dyn_cast<CatchPadInst>(&I)) {
3281 Assert(BB->getUniquePredecessor() == CPI->getCatchSwitch()->getParent(),
3282 "Block containg CatchPadInst must be jumped to "
3283 "only by its catchswitch.",
3285 Assert(BB != CPI->getCatchSwitch()->getUnwindDest(),
3286 "Catchswitch cannot unwind to one of its catchpads",
3287 CPI->getCatchSwitch(), CPI);
3298 if (
auto *II = dyn_cast<InvokeInst>(TI)) {
3300 "EH pad must be jumped to via an unwind edge", ToPad, II);
3302 FromPad = Bundle->Inputs[0];
3305 }
else if (
auto *CRI = dyn_cast<CleanupReturnInst>(TI)) {
3306 FromPad = CRI->getOperand(0);
3307 Assert(FromPad != ToPadParent,
"A cleanupret must exit its cleanup", CRI);
3308 }
else if (
auto *CSI = dyn_cast<CatchSwitchInst>(TI)) {
3311 Assert(
false,
"EH pad must be jumped to via an unwind edge", ToPad, TI);
3318 "EH pad cannot handle exceptions raised within it", FromPad, TI);
3319 if (FromPad == ToPadParent) {
3323 Assert(!isa<ConstantTokenNone>(FromPad),
3324 "A single unwind edge may only enter one EH pad", TI);
3326 "EH pad jumps through a cycle of pads", FromPad);
3335 "LandingPadInst needs at least one clause or to be a cleanup.", &LPI);
3337 visitEHPadPredecessors(LPI);
3339 if (!LandingPadResultTy)
3340 LandingPadResultTy = LPI.
getType();
3343 "The landingpad instruction should have a consistent result type "
3344 "inside a function.",
3348 Assert(F->hasPersonalityFn(),
3349 "LandingPadInst needs to be in a function with a personality.", &LPI);
3354 "LandingPadInst not the first non-PHI instruction in the block.",
3361 "Catch operand does not have pointer type!", &LPI);
3363 Assert(LPI.
isFilter(i),
"Clause is neither catch nor filter!", &LPI);
3364 Assert(isa<ConstantArray>(Clause) || isa<ConstantAggregateZero>(Clause),
3365 "Filter operand is not an array of constants!", &LPI);
3369 visitInstruction(LPI);
3372 void Verifier::visitResumeInst(
ResumeInst &RI) {
3374 "ResumeInst needs to be in a function with a personality.", &RI);
3376 if (!LandingPadResultTy)
3380 "The resume instruction should have a consistent result type "
3381 "inside a function.",
3384 visitTerminatorInst(RI);
3392 "CatchPadInst needs to be in a function with a personality.", &CPI);
3395 "CatchPadInst needs to be directly nested in a CatchSwitchInst.",
3401 "CatchPadInst not the first non-PHI instruction in the block.", &CPI);
3403 visitEHPadPredecessors(CPI);
3404 visitFuncletPadInst(CPI);
3409 "CatchReturnInst needs to be provided a CatchPad", &CatchReturn,
3412 visitTerminatorInst(CatchReturn);
3420 "CleanupPadInst needs to be in a function with a personality.", &CPI);
3425 "CleanupPadInst not the first non-PHI instruction in the block.",
3429 Assert(isa<ConstantTokenNone>(ParentPad) || isa<FuncletPadInst>(ParentPad),
3430 "CleanupPadInst has an invalid parent.", &CPI);
3432 visitEHPadPredecessors(CPI);
3433 visitFuncletPadInst(CPI);
3437 User *FirstUser =
nullptr;
3438 Value *FirstUnwindPad =
nullptr;
3442 while (!Worklist.empty()) {
3445 "FuncletPadInst must not be nested within itself", CurrentPad);
3446 Value *UnresolvedAncestorPad =
nullptr;
3447 for (User *U : CurrentPad->
users()) {
3449 if (
auto *CRI = dyn_cast<CleanupReturnInst>(U)) {
3450 UnwindDest = CRI->getUnwindDest();
3451 }
else if (
auto *CSI = dyn_cast<CatchSwitchInst>(U)) {
3456 if (CSI->unwindsToCaller())
3458 UnwindDest = CSI->getUnwindDest();
3459 }
else if (
auto *II = dyn_cast<InvokeInst>(U)) {
3461 }
else if (isa<CallInst>(U)) {
3466 }
else if (
auto *CPI = dyn_cast<CleanupPadInst>(U)) {
3470 Worklist.push_back(CPI);
3473 Assert(isa<CatchReturnInst>(U),
"Bogus funclet pad use", U);
3481 if (!cast<Instruction>(UnwindPad)->isEHPad())
3485 if (UnwindParent == CurrentPad)
3491 Value *ExitedPad = CurrentPad;
3494 if (ExitedPad == &FPI) {
3499 UnresolvedAncestorPad = &FPI;
3503 if (ExitedParent == UnwindParent) {
3507 UnresolvedAncestorPad = ExitedParent;
3510 ExitedPad = ExitedParent;
3511 }
while (!isa<ConstantTokenNone>(ExitedPad));
3516 UnresolvedAncestorPad = &FPI;
3523 Assert(UnwindPad == FirstUnwindPad,
"Unwind edges out of a funclet "
3524 "pad must have the same unwind "
3526 &FPI, U, FirstUser);
3529 FirstUnwindPad = UnwindPad;
3531 if (isa<CleanupPadInst>(&FPI) && !isa<ConstantTokenNone>(UnwindPad) &&
3533 SiblingFuncletInfo[&FPI] = cast<TerminatorInst>(U);
3538 if (CurrentPad != &FPI)
3541 if (UnresolvedAncestorPad) {
3542 if (CurrentPad == UnresolvedAncestorPad) {
3546 assert(CurrentPad == &FPI);
3554 Value *ResolvedPad = CurrentPad;
3555 while (!Worklist.empty()) {
3556 Value *UnclePad = Worklist.back();
3560 while (ResolvedPad != AncestorPad) {
3562 if (ResolvedParent == UnresolvedAncestorPad) {
3565 ResolvedPad = ResolvedParent;
3569 if (ResolvedPad != AncestorPad)
3572 Worklist.pop_back();
3577 if (FirstUnwindPad) {
3578 if (
auto *CatchSwitch = dyn_cast<CatchSwitchInst>(FPI.
getParentPad())) {
3579 BasicBlock *SwitchUnwindDest = CatchSwitch->getUnwindDest();
3580 Value *SwitchUnwindPad;
3581 if (SwitchUnwindDest)
3585 Assert(SwitchUnwindPad == FirstUnwindPad,
3586 "Unwind edges out of a catch must have the same unwind dest as "
3587 "the parent catchswitch",
3588 &FPI, FirstUser, CatchSwitch);
3592 visitInstruction(FPI);
3600 "CatchSwitchInst needs to be in a function with a personality.",
3606 "CatchSwitchInst not the first non-PHI instruction in the block.",
3610 Assert(isa<ConstantTokenNone>(ParentPad) || isa<FuncletPadInst>(ParentPad),
3611 "CatchSwitchInst has an invalid parent.", ParentPad);
3616 "CatchSwitchInst must unwind to an EH block which is not a "
3622 SiblingFuncletInfo[&CatchSwitch] = &CatchSwitch;
3626 "CatchSwitchInst cannot have empty handler list", &CatchSwitch);
3629 Assert(isa<CatchPadInst>(Handler->getFirstNonPHI()),
3630 "CatchSwitchInst handlers must be catchpads", &CatchSwitch, Handler);
3633 visitEHPadPredecessors(CatchSwitch);
3634 visitTerminatorInst(CatchSwitch);
3639 "CleanupReturnInst needs to be provided a CleanupPad", &CRI,
3645 "CleanupReturnInst must unwind to an EH block which is not a "
3650 visitTerminatorInst(CRI);
3653 void Verifier::verifyDominatesUse(
Instruction &I,
unsigned i) {
3658 if (
InvokeInst *II = dyn_cast<InvokeInst>(Op)) {
3670 if (!isa<PHINode>(I) && InstsInThisBlock.count(Op))
3674 Assert(DT.dominates(Op, U),
3675 "Instruction does not dominate all uses!",
Op, &
I);
3680 "apply only to pointer types", &
I);
3682 "dereferenceable, dereferenceable_or_null apply only to load"
3683 " instructions, use attributes for calls or invokes", &I);
3685 "take one operand!", &
I);
3687 Assert(CI && CI->getType()->isIntegerTy(64),
"dereferenceable, "
3688 "dereferenceable_or_null metadata value must be an i64!", &
I);
3695 Assert(BB,
"Instruction not embedded in basic block!", &I);
3697 if (!isa<PHINode>(I)) {
3698 for (User *U : I.
users()) {
3699 Assert(U != (User *)&I || !DT.isReachableFromEntry(BB),
3700 "Only PHI nodes may reference their own value!", &
I);
3706 "Instruction has a name, but provides a void value!", &
I);
3711 "Instruction returns a non-scalar type!", &
I);
3716 "Invalid use of metadata!", &
I);
3723 Assert(Used->getParent() !=
nullptr,
3724 "Instruction referencing"
3725 " instruction not embedded in a basic block!",
3728 CheckFailed(
"Use of instruction is not an instruction!", U);
3739 Assert(
false,
"Instruction operands must be first-class values!", &I);
3747 i == (isa<CallInst>(
I) ? e - 1 : isa<InvokeInst>(I) ? e - 3 : 0),
3748 "Cannot take the address of an intrinsic!", &I);
3754 F->
getIntrinsicID() == Intrinsic::experimental_patchpoint_void ||
3757 "Cannot invoke an intrinsic other than donothing, patchpoint, "
3758 "statepoint, coro_resume or coro_destroy",
3760 Assert(F->
getParent() == &M,
"Referencing function in another module!",
3761 &
I, &M,
F, F->getParent());
3762 }
else if (
BasicBlock *OpBB = dyn_cast<BasicBlock>(I.getOperand(i))) {
3764 "Referring to a basic block in another function!", &
I);
3765 }
else if (
Argument *OpArg = dyn_cast<Argument>(I.getOperand(i))) {
3767 "Referring to an argument in another function!", &
I);
3768 }
else if (
GlobalValue *GV = dyn_cast<GlobalValue>(I.getOperand(i))) {
3769 Assert(GV->getParent() == &M,
"Referencing global in another module!", &
I,
3770 &M, GV, GV->getParent());
3771 }
else if (isa<Instruction>(I.getOperand(i))) {
3772 verifyDominatesUse(I, i);
3773 }
else if (isa<InlineAsm>(I.getOperand(i))) {
3774 Assert((i + 1 == e && isa<CallInst>(I)) ||
3775 (i + 3 == e && isa<InvokeInst>(I)),
3776 "Cannot take the address of an inline asm!", &I);
3777 }
else if (
ConstantExpr *CE = dyn_cast<ConstantExpr>(I.getOperand(i))) {
3779 !DL.getNonIntegralAddressSpaces().empty()) {
3784 visitConstantExprsRecursively(CE);
3790 Assert(I.getType()->isFPOrFPVectorTy(),
3791 "fpmath requires a floating point result!", &
I);
3794 mdconst::dyn_extract_or_null<ConstantFP>(MD->
getOperand(0))) {
3795 const APFloat &Accuracy = CFP0->getValueAPF();
3797 "fpmath accuracy must have float type", &
I);
3799 "fpmath accuracy not a positive number!", &
I);
3801 Assert(
false,
"invalid fpmath accuracy!", &I);
3806 Assert(isa<LoadInst>(I) || isa<CallInst>(I) || isa<InvokeInst>(I),
3807 "Ranges are only for loads, calls and invokes!", &I);
3808 visitRangeMetadata(I, Range, I.getType());
3812 Assert(I.getType()->isPointerTy(),
"nonnull applies only to pointer types",
3815 "nonnull applies only to load instructions, use attributes"
3816 " for calls or invokes",
3821 visitDereferenceableMetadata(I, MD);
3824 visitDereferenceableMetadata(I, MD);
3827 TBAAVerifyHelper.visitTBAAMetadata(I, TBAA);
3830 Assert(I.getType()->isPointerTy(),
"align applies only to pointer types",
3832 Assert(isa<LoadInst>(I),
"align applies only to load instructions, "
3833 "use attributes for calls or invokes", &I);
3834 Assert(AlignMD->getNumOperands() == 1,
"align takes one operand!", &
I);
3835 ConstantInt *CI = mdconst::dyn_extract<ConstantInt>(AlignMD->getOperand(0));
3836 Assert(CI && CI->getType()->isIntegerTy(64),
3837 "align metadata value must be an i64!", &
I);
3838 uint64_t Align = CI->getZExtValue();
3840 "align metadata value must be a power of 2!", &I);
3842 "alignment is larger that implementation defined limit", &I);
3845 if (
MDNode *N = I.getDebugLoc().getAsMDNode()) {
3846 AssertDI(isa<DILocation>(N),
"invalid !dbg metadata attachment", &I, N);
3850 if (
auto *DII = dyn_cast<DbgInfoIntrinsic>(&I))
3851 verifyFragmentExpression(*DII);
3853 InstsInThisBlock.insert(&I);
3874 "Intrinsic has incorrect return type!", IF);
3875 for (
unsigned i = 0, e = IFTy->getNumParams(); i != e; ++
i)
3878 "Intrinsic has incorrect argument type!", IF);
3883 "Intrinsic was not defined with variable arguments!", IF);
3886 "Callsite was not defined with variable arguments!", IF);
3889 Assert(TableRef.
empty(),
"Intrinsic has too few arguments!", IF);
3897 "Intrinsic name not mangled correctly for type arguments! "
3904 for (Value *V : CS.
args())
3905 if (
auto *MD = dyn_cast<MetadataAsValue>(V))
3906 visitMetadataAsValue(*MD, CS.
getCaller());
3911 case Intrinsic::coro_id: {
3913 if (isa<ConstantPointerNull>(InfoArg))
3916 Assert(GV && GV->isConstant() && GV->hasDefinitiveInitializer(),
3917 "info argument of llvm.coro.begin must refer to an initialized "
3919 Constant *Init = GV->getInitializer();
3920 Assert(isa<ConstantStruct>(Init) || isa<ConstantArray>(Init),
3921 "info argument of llvm.coro.begin must refer to either a struct or "
3925 case Intrinsic::ctlz:
3926 case Intrinsic::cttz:
3928 "is_zero_undef argument of bit counting intrinsics must be a "
3932 case Intrinsic::dbg_declare:
3934 "invalid llvm.dbg.declare intrinsic call 1", CS);
3935 visitDbgIntrinsic(
"declare", cast<DbgDeclareInst>(*CS.
getInstruction()));
3937 case Intrinsic::dbg_value:
3938 visitDbgIntrinsic(
"value", cast<DbgValueInst>(*CS.
getInstruction()));
3940 case Intrinsic::memcpy:
3941 case Intrinsic::memmove:
3942 case Intrinsic::memset: {
3945 "alignment argument of memory intrinsics must be a constant int",
3949 "alignment argument of memory intrinsics must be a power of 2", CS);
3951 "isvolatile argument of memory intrinsics must be a constant int",
3955 case Intrinsic::memcpy_element_atomic: {
3957 Assert(ElementSizeCI,
"element size of the element-wise atomic memory "
3958 "intrinsic must be a constant int",
3962 "element size of the element-wise atomic memory intrinsic "
3963 "must be a power of 2",
3966 auto IsValidAlignment = [&](uint64_t Alignment) {
3973 Assert(IsValidAlignment(DstAlignment),
3974 "incorrect alignment of the destination argument",
3976 Assert(IsValidAlignment(SrcAlignment),
3977 "incorrect alignment of the source argument",
3981 case Intrinsic::gcroot:
3982 case Intrinsic::gcwrite:
3983 case Intrinsic::gcread:
3984 if (ID == Intrinsic::gcroot) {
3987 Assert(AI,
"llvm.gcroot parameter #1 must be an alloca.", CS);
3989 "llvm.gcroot parameter #2 must be a constant.", CS);
3992 "llvm.gcroot parameter #1 must either be a pointer alloca, "
3993 "or argument #2 must be a non-null constant.",
3999 "Enclosing function does not use GC.", CS);
4001 case Intrinsic::init_trampoline:
4003 "llvm.init_trampoline parameter #2 must resolve to a function.",
4009 cast<ConstantInt>(CS.
getArgOperand(1))->getZExtValue() < 2 &&
4011 "invalid arguments to llvm.prefetch", CS);
4013 case Intrinsic::stackprotector:
4015 "llvm.stackprotector parameter #2 must resolve to an alloca.", CS);
4017 case Intrinsic::lifetime_start:
4018 case Intrinsic::lifetime_end:
4019 case Intrinsic::invariant_start:
4021 "size argument of memory use markers must be a constant integer",
4024 case Intrinsic::invariant_end:
4026 "llvm.invariant.end parameter #2 must be a constant integer", CS);
4029 case Intrinsic::localescape: {
4032 "llvm.localescape used outside of entry block", CS);
4034 "multiple calls to llvm.localescape in one function", CS);
4035 for (Value *Arg : CS.
args()) {
4036 if (isa<ConstantPointerNull>(Arg))
4040 "llvm.localescape only accepts static allocas", CS);
4043 SawFrameEscape =
true;
4046 case Intrinsic::localrecover: {
4050 "llvm.localrecover first "
4051 "argument must be function defined in this module",
4054 Assert(IdxArg,
"idx argument of llvm.localrecover must be a constant int",
4056 auto &Entry = FrameEscapeInfo[Fn];
4058 std::max(uint64_t(Entry.second), IdxArg->getLimitedValue(~0U) + 1));
4062 case Intrinsic::experimental_gc_statepoint:
4064 "gc.statepoint support for inline assembly unimplemented", CS);
4066 "Enclosing function does not use GC.", CS);
4068 verifyStatepoint(CS);
4070 case Intrinsic::experimental_gc_result: {
4072 "Enclosing function does not use GC.", CS);
4076 StatepointCS.getInstruction() ? StatepointCS.getCalledFunction() :
nullptr;
4077 Assert(StatepointFn && StatepointFn->isDeclaration() &&
4078 StatepointFn->getIntrinsicID() ==
4079 Intrinsic::experimental_gc_statepoint,
4080 "gc.result operand #1 must be from a statepoint", CS,
4084 const Value *Target = StatepointCS.getArgument(2);
4085 auto *PT = cast<PointerType>(Target->getType());
4086 auto *TargetFuncType = cast<FunctionType>(PT->getElementType());
4087 Assert(CS.getType() == TargetFuncType->getReturnType(),
4088 "gc.result result type does not match wrapped callee", CS);
4091 case Intrinsic::experimental_gc_relocate: {
4092 Assert(CS.getNumArgOperands() == 3,
"wrong number of arguments", CS);
4094 Assert(isa<PointerType>(CS.getType()->getScalarType()),
4095 "gc.relocate must return a pointer or a vector of pointers", CS);
4101 dyn_cast<LandingPadInst>(CS.getArgOperand(0))) {
4104 LandingPad->
getParent()->getUniquePredecessor();
4108 Assert(InvokeBB,
"safepoints should have unique landingpads",
4113 "gc relocate should be linked to a statepoint", InvokeBB);
4119 auto Token = CS.getArgOperand(0);
4121 "gc relocate is incorrectly tied to the statepoint", CS,
Token);
4127 cast<GCRelocateInst>(*CS.getInstruction()).getStatepoint());
4130 Value* Base = CS.getArgOperand(1);
4131 Assert(isa<ConstantInt>(Base),
4132 "gc.relocate operand #2 must be integer offset", CS);
4134 Value* Derived = CS.getArgOperand(2);
4135 Assert(isa<ConstantInt>(Derived),
4136 "gc.relocate operand #3 must be integer offset", CS);
4138 const int BaseIndex = cast<ConstantInt>(Base)->getZExtValue();
4139 const int DerivedIndex = cast<ConstantInt>(Derived)->getZExtValue();
4141 Assert(0 <= BaseIndex && BaseIndex < (
int)StatepointCS.arg_size(),
4142 "gc.relocate: statepoint base index out of bounds", CS);
4143 Assert(0 <= DerivedIndex && DerivedIndex < (
int)StatepointCS.arg_size(),
4144 "gc.relocate: statepoint derived index out of bounds", CS);
4148 Assert(StatepointCS.arg_size() > 0,
4149 "gc.statepoint: insufficient arguments");
4150 Assert(isa<ConstantInt>(StatepointCS.getArgument(3)),
4151 "gc.statement: number of call arguments must be constant integer");
4152 const unsigned NumCallArgs =
4153 cast<ConstantInt>(StatepointCS.getArgument(3))->getZExtValue();
4154 Assert(StatepointCS.arg_size() > NumCallArgs + 5,
4155 "gc.statepoint: mismatch in number of call arguments");
4156 Assert(isa<ConstantInt>(StatepointCS.getArgument(NumCallArgs + 5)),
4157 "gc.statepoint: number of transition arguments must be "
4158 "a constant integer");
4159 const int NumTransitionArgs =
4160 cast<ConstantInt>(StatepointCS.getArgument(NumCallArgs + 5))
4162 const int DeoptArgsStart = 4 + NumCallArgs + 1 + NumTransitionArgs + 1;
4163 Assert(isa<ConstantInt>(StatepointCS.getArgument(DeoptArgsStart)),
4164 "gc.statepoint: number of deoptimization arguments must be "
4165 "a constant integer");
4166 const int NumDeoptArgs =
4167 cast<ConstantInt>(StatepointCS.getArgument(DeoptArgsStart))
4169 const int GCParamArgsStart = DeoptArgsStart + 1 + NumDeoptArgs;
4170 const int GCParamArgsEnd = StatepointCS.arg_size();
4171 Assert(GCParamArgsStart <= BaseIndex && BaseIndex < GCParamArgsEnd,
4172 "gc.relocate: statepoint base index doesn't fall within the "
4173 "'gc parameters' section of the statepoint call",
4175 Assert(GCParamArgsStart <= DerivedIndex && DerivedIndex < GCParamArgsEnd,
4176 "gc.relocate: statepoint derived index doesn't fall within the "
4177 "'gc parameters' section of the statepoint call",
4184 GCRelocateInst &Relocate = cast<GCRelocateInst>(*CS.getInstruction());
4186 "gc.relocate: relocated value must be a gc pointer", CS);
4188 auto ResultType = CS.getType();
4190 Assert(ResultType->isVectorTy() == DerivedType->isVectorTy(),
4191 "gc.relocate: vector relocates to vector and pointer to pointer",
4194 ResultType->getPointerAddressSpace() ==
4195 DerivedType->getPointerAddressSpace(),
4196 "gc.relocate: relocating a pointer shouldn't change its address space",
4200 case Intrinsic::eh_exceptioncode:
4201 case Intrinsic::eh_exceptionpointer: {
4202 Assert(isa<CatchPadInst>(CS.getArgOperand(0)),
4203 "eh.exceptionpointer argument must be a catchpad", CS);
4206 case Intrinsic::masked_load: {
4207 Assert(CS.getType()->isVectorTy(),
"masked_load: must return a vector", CS);
4209 Value *
Ptr = CS.getArgOperand(0);
4211 Value *
Mask = CS.getArgOperand(2);
4212 Value *PassThru = CS.getArgOperand(3);
4214 "masked_load: mask must be vector", CS);
4217 Type *DataTy = cast<PointerType>(Ptr->getType())->getElementType();
4218 Assert(DataTy == CS.getType(),
4219 "masked_load: return must match pointer type", CS);
4221 "masked_load: pass through and data type must match", CS);
4223 DataTy->getVectorNumElements(),
4224 "masked_load: vector mask must be same length as data", CS);
4227 case Intrinsic::masked_store: {
4228 Value *Val = CS.getArgOperand(0);
4229 Value *Ptr = CS.getArgOperand(1);
4231 Value *Mask = CS.getArgOperand(3);
4233 "masked_store: mask must be vector", CS);
4236 Type *DataTy = cast<PointerType>(Ptr->
getType())->getElementType();
4238 "masked_store: storee must match pointer type", CS);
4240 DataTy->getVectorNumElements(),
4241 "masked_store: vector mask must be same length as data", CS);
4245 case Intrinsic::experimental_guard: {
4246 Assert(CS.isCall(),
"experimental_guard cannot be invoked", CS);
4248 "experimental_guard must have exactly one "
4249 "\"deopt\" operand bundle");
4253 case Intrinsic::experimental_deoptimize: {
4254 Assert(CS.isCall(),
"experimental_deoptimize cannot be invoked", CS);
4256 "experimental_deoptimize must have exactly one "
4257 "\"deopt\" operand bundle");
4258 Assert(CS.getType() == CS.getInstruction()->getFunction()->getReturnType(),
4259 "experimental_deoptimize return type must match caller return type");
4262 auto *DeoptCI = CS.getInstruction();
4265 "calls to experimental_deoptimize must be followed by a return");
4267 if (!CS.getType()->isVoidTy() && RI)
4268 Assert(RI->getReturnValue() == DeoptCI,
4269 "calls to experimental_deoptimize must be followed by a return "
4270 "of the value computed by experimental_deoptimize");
4286 if (
auto *SP = dyn_cast<DISubprogram>(LocalScope))
4289 if (
auto *LB = dyn_cast<DILexicalBlockBase>(LocalScope))
4293 assert(!isa<DILocalScope>(LocalScope) &&
"Unknown type of local scope");
4297 template <
class DbgIntrinsicTy>
4298 void Verifier::visitDbgIntrinsic(
StringRef Kind, DbgIntrinsicTy &DII) {
4299 auto *MD = cast<MetadataAsValue>(DII.getArgOperand(0))->getMetadata();
4300 AssertDI(isa<ValueAsMetadata>(MD) ||
4301 (isa<MDNode>(MD) && !cast<MDNode>(MD)->getNumOperands()),
4302 "invalid llvm.dbg." + Kind +
" intrinsic address/value", &DII, MD);
4303 AssertDI(isa<DILocalVariable>(DII.getRawVariable()),
4304 "invalid llvm.dbg." + Kind +
" intrinsic variable", &DII,
4305 DII.getRawVariable());
4306 AssertDI(isa<DIExpression>(DII.getRawExpression()),
4307 "invalid llvm.dbg." + Kind +
" intrinsic expression", &DII,
4308 DII.getRawExpression());
4311 if (
MDNode *N = DII.getDebugLoc().getAsMDNode())
4312 if (!isa<DILocation>(N))
4321 Assert(Loc,
"llvm.dbg." + Kind +
" intrinsic requires a !dbg attachment",
4326 if (!VarSP || !LocSP)
4329 AssertDI(VarSP == LocSP,
"mismatched subprogram between llvm.dbg." + Kind +
4330 " variable and !dbg attachment",
4332 Loc->getScope()->getSubprogram());
4340 if (
auto *T = dyn_cast<DIType>(RawType))
4341 if (uint64_t Size = T->getSizeInBits())
4344 if (
auto *DT = dyn_cast<DIDerivedType>(RawType)) {
4346 RawType = DT->getRawBaseType();
4361 if (
auto *DVI = dyn_cast<DbgValueInst>(&I)) {
4362 V = dyn_cast_or_null<DILocalVariable>(DVI->getRawVariable());
4363 E = dyn_cast_or_null<DIExpression>(DVI->getRawExpression());
4365 auto *DDI = cast<DbgDeclareInst>(&
I);
4366 V = dyn_cast_or_null<DILocalVariable>(DDI->getRawVariable());
4367 E = dyn_cast_or_null<DIExpression>(DDI->getRawExpression());
4371 if (!V || !E || !E->isValid())
4375 auto Fragment = E->getFragmentInfo();
4385 if (V->isArtificial())
4394 unsigned FragSize = Fragment->SizeInBits;
4395 unsigned FragOffset = Fragment->OffsetInBits;
4396 AssertDI(FragSize + FragOffset <= VarSize,
4397 "fragment is larger than or outside of variable", &I, V, E);
4398 AssertDI(FragSize != VarSize,
"fragment covers entire variable", &I, V, E);
4401 void Verifier::verifyCompileUnits() {
4402 auto *CUs = M.getNamedMetadata(
"llvm.dbg.cu");
4405 Listed.
insert(CUs->op_begin(), CUs->op_end());
4408 [&Listed](
const Metadata *CU) {
return Listed.
count(CU); }),
4409 "All DICompileUnits must be listed in llvm.dbg.cu");
4413 void Verifier::verifyDeoptimizeCallingConvs() {
4414 if (DeoptimizeDeclarations.empty())
4417 const Function *First = DeoptimizeDeclarations[0];
4418 for (
auto *F :
makeArrayRef(DeoptimizeDeclarations).slice(1)) {
4420 "All llvm.experimental.deoptimize declarations must have the same "
4421 "calling convention",
4438 return !V.verify(F);
4442 bool *BrokenDebugInfo) {
4444 Verifier V(OS, !BrokenDebugInfo, M);
4446 bool Broken =
false;
4448 Broken |= !V.verify(F);
4450 Broken |= !V.verify();
4451 if (BrokenDebugInfo)
4452 *BrokenDebugInfo = V.hasBrokenDebugInfo();
4463 std::unique_ptr<Verifier> V;
4464 bool FatalErrors =
true;
4469 explicit VerifierLegacyPass(
bool FatalErrors)
4471 FatalErrors(FatalErrors) {
4475 bool doInitialization(
Module &M)
override {
4476 V = llvm::make_unique<Verifier>(
4481 bool runOnFunction(
Function &F)
override {
4482 if (!V->verify(F) && FatalErrors)
4488 bool doFinalization(
Module &M)
override {
4489 bool HasErrors =
false;
4492 HasErrors |= !V->verify(F);
4494 HasErrors |= !V->verify();
4498 assert(!V->hasBrokenDebugInfo() &&
"Module contains invalid debug info");
4502 if (V->hasBrokenDebugInfo()) {
4504 M.getContext().diagnose(DiagInvalid);
4519 template <
typename... Tys>
void TBAAVerifier::CheckFailed(Tys &&... Args) {
4524 #define AssertTBAA(C, ...) \
4527 CheckFailed(__VA_ARGS__); \
4535 TBAAVerifier::TBAABaseNodeSummary
4538 CheckFailed(
"Base nodes must have at least two operands", &I, BaseNode);
4542 auto Itr = TBAABaseNodes.find(BaseNode);
4543 if (Itr != TBAABaseNodes.end())
4546 auto Result = verifyTBAABaseNodeImpl(I, BaseNode);
4547 auto InsertResult = TBAABaseNodes.insert({BaseNode, Result});
4549 assert(InsertResult.second &&
"We just checked!");
4553 TBAAVerifier::TBAABaseNodeSummary
4555 const TBAAVerifier::TBAABaseNodeSummary InvalidNode = {
true, ~0u};
4559 return isValidScalarTBAANode(BaseNode)
4560 ? TBAAVerifier::TBAABaseNodeSummary({
false, 0})
4565 CheckFailed(
"Struct tag nodes must have an odd number of operands!",
4570 if (!isa<MDString>(BaseNode->
getOperand(0))) {
4571 CheckFailed(
"Struct tag nodes have a string as their first operand",
4576 bool Failed =
false;
4579 unsigned BitWidth = ~0u;
4583 for (
unsigned Idx = 1; Idx < BaseNode->
getNumOperands(); Idx += 2) {
4586 if (!isa<MDNode>(FieldTy)) {
4587 CheckFailed(
"Incorrect field entry in struct type node!", &I, BaseNode);
4592 auto *OffsetEntryCI =
4593 mdconst::dyn_extract_or_null<ConstantInt>(FieldOffset);
4594 if (!OffsetEntryCI) {
4595 CheckFailed(
"Offset entries must be constants!", &I, BaseNode);
4600 if (BitWidth == ~0u)
4601 BitWidth = OffsetEntryCI->getBitWidth();
4603 if (OffsetEntryCI->getBitWidth() != BitWidth) {
4605 "Bitwidth between the offsets and struct type entries must match", &I,
4617 !PrevOffset || PrevOffset->
ule(OffsetEntryCI->getValue());
4620 CheckFailed(
"Offsets must be increasing!", &I, BaseNode);
4624 PrevOffset = OffsetEntryCI->getValue();
4627 return Failed ? InvalidNode
4628 : TBAAVerifier::TBAABaseNodeSummary(
false, BitWidth);
4649 auto *Parent = dyn_cast_or_null<MDNode>(MD->
getOperand(1));
4650 return Parent && Visited.
insert(Parent).second &&
4654 bool TBAAVerifier::isValidScalarTBAANode(
const MDNode *MD) {
4655 auto ResultIt = TBAAScalarNodes.find(MD);
4656 if (ResultIt != TBAAScalarNodes.end())
4657 return ResultIt->second;
4661 auto InsertResult = TBAAScalarNodes.insert({MD, Result});
4663 assert(InsertResult.second &&
"Just checked!");
4681 return cast<MDNode>(BaseNode->
getOperand(1));
4683 for (
unsigned Idx = 1; Idx < BaseNode->
getNumOperands(); Idx += 2) {
4684 auto *OffsetEntryCI =
4685 mdconst::extract<ConstantInt>(BaseNode->
getOperand(Idx + 1));
4686 if (OffsetEntryCI->getValue().ugt(Offset)) {
4688 CheckFailed(
"Could not find TBAA parent in struct type node", &I,
4693 auto *PrevOffsetEntryCI =
4694 mdconst::extract<ConstantInt>(BaseNode->
getOperand(Idx - 1));
4695 Offset -= PrevOffsetEntryCI->getValue();
4696 return cast<MDNode>(BaseNode->
getOperand(Idx - 2));
4700 auto *LastOffsetEntryCI = mdconst::extract<ConstantInt>(
4703 Offset -= LastOffsetEntryCI->getValue();
4708 AssertTBAA(isa<LoadInst>(I) || isa<StoreInst>(I) || isa<CallInst>(I) ||
4709 isa<VAArgInst>(I) || isa<AtomicRMWInst>(I) ||
4710 isa<AtomicCmpXchgInst>(I),
4711 "TBAA is only for loads, stores and calls!", &I);
4713 bool IsStructPathTBAA =
4718 "Old-style TBAA is no longer allowed, use struct-path TBAA instead", &I);
4721 "Struct tag metadata must have either 3 or 4 operands", &
I, MD);
4727 auto *IsImmutableCI =
4728 mdconst::dyn_extract_or_null<ConstantInt>(MD->
getOperand(3));
4730 "Immutability tag on struct tag metadata must be a constant", &I,
4733 IsImmutableCI->isZero() || IsImmutableCI->isOne(),
4734 "Immutability part of the struct tag metadata must be either 0 or 1",
4739 "Malformed struct tag metadata: base and access-type "
4740 "should be non-null and point to Metadata nodes",
4741 &I, MD, BaseNode, AccessType);
4743 AssertTBAA(isValidScalarTBAANode(AccessType),
4744 "Access type node must be a valid scalar type", &I, MD,
4747 auto *OffsetCI = mdconst::dyn_extract_or_null<ConstantInt>(MD->
getOperand(2));
4748 AssertTBAA(OffsetCI,
"Offset must be constant integer", &I, MD);
4750 APInt Offset = OffsetCI->getValue();
4751 bool SeenAccessTypeInPath =
false;
4756 BaseNode = getFieldNodeFromTBAABaseNode(I, BaseNode, Offset)) {
4757 if (!StructPath.
insert(BaseNode).second) {
4758 CheckFailed(
"Cycle detected in struct path", &I, MD);
4763 unsigned BaseNodeBitWidth;
4764 std::tie(Invalid, BaseNodeBitWidth) = verifyTBAABaseNode(I, BaseNode);
4771 SeenAccessTypeInPath |= BaseNode == AccessType;
4773 if (isValidScalarTBAANode(BaseNode) || BaseNode == AccessType)
4774 AssertTBAA(Offset == 0,
"Offset not zero at the point of scalar access",
4778 (BaseNodeBitWidth == 0 && Offset == 0),
4779 "Access bit-width not the same as description bit-width", &I, MD,
4783 AssertTBAA(SeenAccessTypeInPath,
"Did not see access type in access path!",
4789 INITIALIZE_PASS(VerifierLegacyPass,
"verify",
"Module Verifier",
false,
false)
4792 return new VerifierLegacyPass(FatalErrors);
4813 assert(!Res.DebugInfoBroken &&
"Module contains invalid debug info");
4817 if (Res.DebugInfoBroken) {
4828 if (res.IRBroken && FatalErrors)
AttributeSet getAttributes() const
Return the parameter attributes for this call.
Metadata * getRawScope() const
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...
const Use & getOperandUse(unsigned i) const
Return a value (possibly void), from a function.
static bool isScope(const Metadata *MD)
StringRef getName() const
void push_back(const T &Elt)
A parsed version of the target data layout string in and methods for querying it. ...
AtomicOrdering getFailureOrdering() const
Returns the ordering constraint on this cmpxchg.
LinkageTypes getLinkage() const
Tracking metadata reference owned by Metadata.
IntegerType * getType() const
getType - Specialize the getType() method to always return an IntegerType, which reduces the amount o...
unsigned getNumHandlers() const
return the number of 'handlers' in this catchswitch instruction, except the default handler ...
static Value * getParentPad(Value *EHPad)
FunTy * getCaller() const
getCaller - Return the caller function for this call site
iterator_range< use_iterator > uses()
Intel_OCL_BI - Calling conventions for Intel OpenCL built-ins.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Metadata * getRawTemplateParams() const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
iterator_range< CaseIt > cases()
Iteration adapter for range-for loops.
unsigned getNumOperandBundles() const
LLVM Argument representation.
Base class for instruction visitors.
Value * getAggregateOperand()
Atomic ordering constants.
NodeTy * getNextNode()
Get the next node, or nullptr for the list tail.
Type * getSourceElementType() const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
SynchronizationScope getSynchScope() const
ValueT lookup(const KeyT &Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
ArrayRef< unsigned > getIndices() const
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.
A Module instance is used to store all the information related to an LLVM module. ...
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
static bool isValidMetadataArrayImpl(const MDTuple &N, bool AllowNull)
Result run(Module &M, ModuleAnalysisManager &)
AtomicOrdering getSuccessOrdering() const
Returns the ordering constraint on this cmpxchg.
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.
static bool isValidMetadataNullArray(const MDTuple &N)
DILocalScope * getScope() const
Get the local scope for this variable.
This class represents zero extension of integer types.
unsigned getNumOperands() const
unsigned getNumOperands() const
Return number of MDNode operands.
Value * getValue() const
Convenience accessor.
BBTy * getParent() const
Get the basic block containing the call site.
Metadata * getRawFile() const
Return the raw underlying file.
DIMacroNodeArray getElements() const
Type * getValueType() const
This class represents a function call, abstracting a target machine's calling convention.
bool isIntrinsic() const
isIntrinsic - Returns true if the function's name starts with "llvm.".
bool hasInAllocaArgument() const
Determine if there are is an inalloca argument.
bool hasAppendingLinkage() const
Metadata * getRawType() const
size_type count(PtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
static uint64_t getVariableSize(const DILocalVariable &V)
FunctionPass * createVerifierPass(bool FatalErrors=true)
An efficient, type-erasing, non-owning reference to a callable.
This instruction constructs a fixed permutation of two input vectors.
bool hasAvailableExternallyLinkage() const
bool onlyReadsMemory() const
Determine if the call does not access or only reads memory.
iterator begin(unsigned Slot) const
bool isTokenTy() const
Return true if this is 'token'.
bool isPtrOrPtrVectorTy() const
Return true if this is a pointer type or a vector of pointer types.
Type * getReturnType() const
Returns the type of the ret val.
This class implements a map that also provides access to all stored values in a deterministic order...
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
bool isEHPad() const
Return true if this basic block is an exception handling block.
const Function * getParent() const
Return the enclosing method, or null if none.
unsigned getParamAlignment(unsigned Index) const
Return the alignment for the specified function parameter.
const Instruction & front() const
This class represents a sign extension of integer types.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
An instruction for reading from memory.
Manage lifetime of a slot tracker for printing IR.
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.
This defines the Use class.
Type * getElementType() const
void reserve(size_type N)
static 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.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
Metadata * getRawScope() const
const Constant * getAliasee() const
unsigned getOpcode() const
Return the opcode at the root of this constant expression.
bool isFiniteNonZero() const
unsigned getColumn() const
Check a module for errors, and report separate error states for IR and debug info errors...
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
unsigned arg_size() const
Metadata * getRawType() const
iterator_range< user_iterator > materialized_users()
StringRef getName() const
Return a constant reference to the value's name.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
iterator begin()
Instruction iterator methods.
Adds a requirement that another module flag be present and have a specified value after linking is pe...
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Appends the two values, which are required to be metadata nodes.
Value * getDerivedPtr() 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...
bool hasCommonLinkage() const
StringRef getName() const
bool hasGC() const
hasGC/getGC/setGC/clearGC - The name of the garbage collection algorithm to use during code generatio...
StringRef getName(ID id)
Return the LLVM name for an intrinsic, such as "llvm.ppc.altivec.lvx".
This class represents the LLVM 'select' instruction.
struct fuzzer::@269 Flags
Value * getReturnValue() const
Convenience accessor. Returns null if there is no return value.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
const APInt & getValue() const
Return the constant as an APInt value reference.
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
void CheckFailed(const Twine &Message, const T1 &V1, const Ts &...Vs)
A check failed (with values to print).
void print(raw_ostream &O, bool IsForDebug=false) const
Implement operator<< on Value.
Class to represent struct types.
A Use represents the edge between a Value definition and its users.
ValTy * getCalledValue() const
getCalledValue - Return the pointer to function that is being called.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
PTX_Kernel - Call to a PTX kernel.
Instruction * getFirstNonPHI()
Returns a pointer to the first instruction in this block that is not a PHINode instruction.
bool canLosslesslyBitCastTo(Type *Ty) const
Return true if this type could be converted with a lossless BitCast to type 'Ty'. ...
Metadata * getRawRetainedTypes() const
bool hasAddressTaken() const
Returns true if there are any uses of this basic block other than direct branches, switches, etc.
This file contains the simple types necessary to represent the attributes associated with functions a...
bool isMustTailCall() const
StringRef getFilename() const
unsigned getMacinfoType() const
StringRef getName() const
static const unsigned MaximumAlignment
const std::string & getModuleIdentifier() const
Get the module identifier which is, essentially, the name of the module.
Type * getPointerOperandType() const
Method to return the pointer operand as a PointerType.
StringRef getName() const
BasicBlock * getDestination(unsigned i)
Return the specified destination.
DITypeRefArray getTypeArray() const
This file implements a class to represent arbitrary precision integral constant values and operations...
bool hasPrivateLinkage() const
SynchronizationScope getSynchScope() const
This class represents a cast from a pointer to an integer.
LLVM_NODISCARD bool empty() const
bool hasValidDeclarationLinkage() const
AtomicOrdering
Atomic ordering for LLVM's memory model.
static bool IsRootTBAANode(const MDNode *MD)
Metadata * getRawFile() const
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.
void visit(Iterator Start, Iterator End)
Metadata * getRawStaticDataMemberDeclaration() const
A constant value that is initialized with an expression using other constant values.
Class to represent function types.
AtomicOrdering getOrdering() const
Returns the ordering constraint on this RMW.
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...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
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 Assert(C,...)
We know that cond should be true, if not print an error message.
Class to represent array types.
This instruction compares its operands according to the predicate given to the constructor.
Function Alias Analysis false
bool sgt(const APInt &RHS) const
Signed greather than comparison.
bool StripDebugInfo(Module &M)
Strip debug info in the module if it exists.
bool isFirstClassType() const
Return true if the type is "first class", meaning it is a valid type for a Value. ...
This class represents a no-op cast from one type to another.
static FunctionType * get(Type *Result, ArrayRef< Type * > Params, bool isVarArg)
This static method is the primary way of constructing a FunctionType.
std::pair< unsigned, Optional< unsigned > > getAllocSizeArgs(unsigned Index) const
Get the allocsize argument numbers (or pair(0, 0) if unknown).
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
static GCRegistry::Add< OcamlGC > B("ocaml","ocaml 3.10-compatible GC")
const Function * getFunction() const
Return the function this instruction belongs to.
An instruction for storing to memory.
This class represents a cast from floating point to signed integer.
bool isArrayTy() const
True if this is an instance of ArrayType.
Metadata * getRawEnumTypes() const
This file contains the declaration of the Comdat class, which represents a single COMDAT in LLVM...
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...
Type * getScalarType() const LLVM_READONLY
If this is a vector type, return the element type, otherwise return 'this'.
This class represents a truncation of integer types.
bool isAtomic() const
Return true if this instruction has an AtomicOrdering of unordered or higher.
BasicBlock * getNormalDest() const
Class to represent pointers.
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
static const fltSemantics & IEEEsingle()
Flag
These should be considered private to the implementation of the MCInstrDesc class.
Metadata * getRawScope() const
static bool isValidMetadataArray(const MDTuple &N)
bool isSized(SmallPtrSetImpl< Type * > *Visited=nullptr) const
Return true if it makes sense to take the size of this type.
static ChecksumKind getChecksumKind(StringRef CSKindStr)
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
bool isFilter(unsigned Idx) const
Return 'true' if the clause and index Idx is a filter clause.
bool verify(const TargetRegisterInfo &TRI) const
Check that information hold by this instance make sense for the given TRI.
bool isIntOrIntVectorTy() const
Return true if this is an integer type or a vector of integer types.
unsigned getNumSlots() const
Return the number of slots used in this attribute list.
Type * getParamType(unsigned i) const
Parameter type accessors.
initializer< Ty > init(const Ty &Val)
This instruction inserts a single (scalar) element into a VectorType value.
iterator_range< IterTy > args() const
The landingpad instruction holds all of the information necessary to generate correct exception handl...
Emits an error if two values disagree, otherwise the resulting value is that of the operands...
Metadata * getRawFile() const
unsigned getAlignment() const
Return the alignment of the access that is being performed.
FunctionType * getFunctionType() const
Subclasses of this class are all able to terminate a basic block.
A set of analyses that are preserved following a run of a transformation pass.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs...ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Metadata * getRawMacros() 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.
Conditional or Unconditional Branch instruction.
C - The default llvm calling convention, compatible with C.
bool isVectorTy() const
True if this is an instance of VectorType.
This is an important base class in LLVM.
void getModuleFlagsMetadata(SmallVectorImpl< ModuleFlagEntry > &Flags) const
Returns the module flags in the provided vector.
PointerType * getType() const
Overload to return most specific pointer type.
Metadata * getRawType() const
void DebugInfoCheckFailed(const Twine &Message, const T1 &V1, const Ts &...Vs)
A debug info check failed (with values to print).
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
Resume the propagation of an exception.
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...
Indirect Branch Instruction.
APInt Or(const APInt &LHS, const APInt &RHS)
Bitwise OR function for APInt.
Base class for template parameters.
ModFlagBehavior
This enumeration defines the supported behaviors of module flags.
unsigned getAlignment() const
Return the alignment of the memory that is being allocated by the instruction.
ConstantFP - Floating Point Values [float, double].
LandingPadInst * getLandingPadInst()
Return the landingpad instruction associated with the landing pad.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
APInt Xor(const APInt &LHS, const APInt &RHS)
Bitwise XOR function for APInt.
Value * stripInBoundsOffsets()
Strip off pointer casts and inbounds GEPs.
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...
bool hasPersonalityFn() const
Check whether this function has a personality function.
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
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)
isPowerOf2_64 - This function returns 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)
uint16_t getParamAlignment(uint16_t i) const
Extract the alignment for a call or parameter (0=unknown).
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...
Metadata * getRawElements() const
This instruction compares its operands according to the predicate given to the constructor.
unsigned getBitWidth() const
Return the number of bits in the APInt.
uint64_t getNumElements() const
DIMacroNodeArray getMacros() const
User * getUser() const
Returns the User that contains this Use.
FunctionPass class - This class is used to implement most global optimizations.
Value * getOperand(unsigned i) const
Interval::pred_iterator pred_end(Interval *I)
Base class for variables.
std::pair< NoneType, bool > insert(const T &V)
insert - Insert an element into the set if it isn't already there.
Predicate getPredicate() const
Return the predicate for this instruction.
bool pred_empty(const BasicBlock *BB)
uint32_t getTagID() const
Return the tag of this operand bundle as an integer.
bool empty() const
empty - Check if the array is empty.
This class represents a cast from an integer to a pointer.
static DISubprogram * getSubprogram(Metadata *LocalScope)
Carefully grab the subprogram from a local scope.
bool isPointerTy() const
True if this is an instance of PointerType.
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.
LLVMContext & getContext() const
All values hold a context through their type.
bool isFPOrFPVectorTy() const
Return true if this is a FP type or a vector of FP.
const Value * getTrueValue() const
bool isPowerOf2() const
Check if this APInt's value is a power of two greater than zero.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
User::op_iterator arg_iterator
arg_iterator - The type of iterator to use when looping over actual arguments at this call site...
OperandBundleUse getOperandBundleAt(unsigned Index) const
FunctionType * getFunctionType() const
An imported module (C++ using directive or similar).
Base class for scope-like contexts.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
DIScopeArray getRetainedTypes() const
bool doesNotAccessMemory() const
Determine if the call does not access memory.
BasicBlock * getUnwindDest() const
bool isConditional() const
DIExpression * getExpression() const
AttributeSet getAttributes() const
getAttributes/setAttributes - get or set the parameter attributes of the call.
BasicBlock * getUnwindDest() const
DIImportedEntityArray getImportedEntities() const
BinaryOps getOpcode() const
StringRef getString() const
bool hasExternalLinkage() const
bool hasDLLImportStorageClass() const
const MDOperand & getOperand(unsigned I) const
Metadata * getRawBaseType() const
#define AssertDI(C,...)
We know that a debug info condition should be true, if not print an error message.
bool onlyAccessesArgMemory() const
Determine if the call can access memmory only using pointers based on its arguments.
Iterator for intrusive lists based on ilist_node.
bool hasGlobalUnnamedAddr() const
BasicBlock * getUnwindDest() const
AtomicOrdering getOrdering() const
Returns the ordering effect of this store.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
bool isSwiftError() const
Return true if this alloca is used as a swifterror argument to a call.
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)
InstrTy * getInstruction() const
VerifierSupport(raw_ostream *OS, const Module &M)
Optional< OperandBundleUse > getOperandBundle(StringRef Name) const
Return an operand bundle by name, if present.
PTX_Device - Call to a PTX device function.
static Optional< DebugEmissionKind > getEmissionKind(StringRef Str)
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
void getIntrinsicInfoTableEntries(ID id, SmallVectorImpl< IITDescriptor > &T)
Return the IIT table descriptor for the specified intrinsic into an array of IITDescriptors.
ValTy * getArgument(unsigned ArgNo) const
Metadata * getRawInlinedAt() const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool isStaticAlloca() const
Return true if this alloca is in the entry block of the function and is a constant size...
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
static bool isDINode(const Metadata *MD)
static bool isValidModFlagBehavior(Metadata *MD, ModFlagBehavior &MFB)
Checks if Metadata represents a valid ModFlagBehavior, and stores the converted result in MFB...
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
iterator end(unsigned Slot) const
This class represents a range of values.
This is the common base class for debug info intrinsics.
static const char * Target
const APInt & getLower() const
Return the lower value for this range.
StringRef getName() const
This class represents a cast from floating point to unsigned integer.
LLVM_NODISCARD T pop_back_val()
Value * getParentPad() const
Convenience accessors.
Value * stripPointerCasts()
Strip off pointer casts, all-zero GEPs, and aliases.
AtomicOrdering getOrdering() const
Returns the ordering effect of this fence.
bool isZero() const
This is just a convenience method to make client code smaller for a common code.
pred_range predecessors(BasicBlock *BB)
const BasicBlock & getEntryBlock() const
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
Metadata * getRawEntity() const
BinOp getOperation() const
Intrinsic::ID getIntrinsicID() const LLVM_READONLY
getIntrinsicID - This method returns the ID number of the specified function, or Intrinsic::not_intri...
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
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.
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
unsigned getNumArgOperands() const
Class to represent vector types.
Target - Wrapper for Target specific information.
ConstantArray - Constant Array Declarations.
bool hasInitializer() const
Definitions have initializers, declarations don't.
Class for arbitrary precision integers.
DIGlobalVariableExpressionArray getGlobalVariables() const
A (clang) module that has been imported by the compile unit.
bool isConstant() const
If the value is a global constant, its value is immutable throughout the runtime execution of the pro...
DISubprogram * getSubprogram() const
Get the attached subprogram.
bool isIntegerTy() const
True if this is an instance of IntegerType.
Emits a warning if two values disagree.
static Instruction * getSuccPad(TerminatorInst *Terminator)
void setPreservesAll()
Set by analyses that do not transform their input at all.
A lightweight accessor for an operand bundle meant to be passed around by value.
iterator_range< user_iterator > users()
unsigned getVectorNumElements() const
Generic tagged DWARF-like metadata node.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Value * getCondition() const
iterator insert(iterator I, T &&Elt)
bool isInlineAsm() const
Check if this call is an inline asm statement.
MDNode * getMetadata(unsigned KindID) const
Get the current metadata attachments for the given kind, if any.
bool verifyModule(const Module &M, raw_ostream *OS=nullptr, bool *BrokenDebugInfo=nullptr)
Check a module for errors.
APInt And(const APInt &LHS, const APInt &RHS)
Bitwise AND function for APInt.
Value * getParentPad() const
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...
static AttrBuilder getParameterABIAttributes(int I, AttributeSet Attrs)
bool isEHPad() const
Return true if the instruction is a variety of EH-block.
Type array for a subprogram.
Metadata * getRawImportedEntities() const
Metadata * getRawScope() const
Metadata * getRawScope() const
PointerType * getType() const
Global values are always pointers.
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
Value * getCondition() const
Appends the two values, which are required to be metadata nodes.
AtomicOrdering getOrdering() const
Returns the ordering effect of this fence.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
unsigned getSlotIndex(unsigned Slot) const
Return the index for the given slot.
bool BrokenDebugInfo
Broken debug info can be "recovered" from by stripping the debug info.
bool hasAttributes(unsigned Index) const
Return true if attribute exists at the given index.
unsigned getAlignment() const
Return the alignment of the access that is being performed.
ImmutableCallSite - establish a view to a call site for examination.
bool isCatch(unsigned Idx) const
Return 'true' if the clause and index Idx is a catch clause.
TerminatorInst * getTerminator()
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
FunctionType * getFunctionType() const
Returns the FunctionType for me.
bool paramHasAttr(unsigned i, Attribute::AttrKind Kind) const
Return true if the call or the callee has the given attribute.
DIGlobalVariable * getVariable() const
void initializeVerifierLegacyPassPass(PassRegistry &)
This class represents a cast unsigned integer to floating point.
bool verifyFunction(const Function &F, raw_ostream *OS=nullptr)
Check a function for errors, useful for use when debugging a pass.
Metadata * getRawElements() 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)
static ConstantTokenNone * get(LLVMContext &Context)
Return the ConstantTokenNone.
op_range operands() const
void diagnose(const DiagnosticInfo &DI)
Report a message to the currently installed diagnostic handler.
void DebugInfoCheckFailed(const Twine &Message)
A debug info check failed.
Metadata * getRawFile() const
Metadata * getRawScope() const
bool isStatepoint(ImmutableCallSite CS)
std::vector< uint8_t > Unit
This class represents a cast from signed integer to floating point.
const APInt & getUpper() const
Return the upper value for this range.
Type * getReturnType() const
unsigned getAlignment() const
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
This class represents a truncation of floating point types.
FunTy * getCalledFunction() const
getCalledFunction - Return the function being called if this is a direct call, otherwise return null ...
DICompositeTypeArray getEnumTypes() const
Represents calls to the gc.relocate intrinsic.
bool isLabelTy() const
Return true if this is 'label'.
Module * getParent()
Get the module that this global value is contained inside of...
Verify that the TBAA Metadatas are valid.
LLVM Value Representation.
static bool hasConflictingReferenceFlags(unsigned Flags)
bool TreatBrokenDebugInfoAsError
Whether to treat broken debug info as an error.
AttrBuilder typeIncompatible(Type *Ty)
Which attributes cannot be applied to a type.
const Value * getArraySize() const
Get the number of elements allocated.
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.
ValTy * getArgOperand(unsigned i) const
This class implements an extremely fast bulk output stream that can only output to a stream...
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).
void print(raw_ostream &ROS, bool IsForDebug=false) const
bool Broken
Track the brokenness of the module while recursively visiting.
static bool IsScalarTBAANodeImpl(const MDNode *MD, SmallPtrSetImpl< const MDNode * > &Visited)
static bool isContiguous(const ConstantRange &A, const ConstantRange &B)
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
PointerType * getPointerTo(unsigned AddrSpace=0) const
Return a pointer to the current type.
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.
CallingConv::ID getCallingConv() const
getCallingConv/setCallingConv - Get or set the calling convention of this function call...
This header defines various interfaces for pass management in LLVM.
unsigned getNumElements() const
Random access to the elements.
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
op_range incoming_values()
This class represents an extension of floating point types.
bool isResolved() const
Check if node is fully resolved.
DISubprogram * getSubprogram() const
Get the subprogram for this scope.
A bitmask that includes all valid flags.
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
#define AssertTBAA(C,...)
bool ule(const APInt &RHS) const
Unsigned less or equal comparison.
Fast - This calling convention attempts to make calls as fast as possible (e.g.
bool isDeclarationForLinker() const
unsigned getNumDestinations() const
return the number of possible destinations in this indirectbr instruction.
const fltSemantics & getSemantics() const
bool isEmpty() const
Return true if there are no attributes.
A special type used by analysis passes to provide an address that identifies that particular analysis...
const BasicBlock * getParent() const
InstListType::iterator iterator
Instruction iterators...
Type * getResultElementType() const
static cl::opt< bool > VerifyDebugInfo("verify-debug-info", cl::init(true))
Type * getTypeAtIndex(const Value *V) const
Given an index value into the type, return the type of the element.
LLVMContext & getContext() const
Get the global data context.
bool isVoidTy() const
Return true if this is 'void'.
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)
StringRef getValue() const
Metadata * getRawGlobalVariables() const
Basic type, like 'int' or 'float'.
bool isMetadataTy() const
Return true if this is 'metadata'.
Metadata * getRawTypeArray() const
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...
Metadata * getRawVTableHolder() const