70#define DEBUG_TYPE "bitcode-reader"
72STATISTIC(NumMDStringLoaded,
"Number of MDStrings loaded");
73STATISTIC(NumMDNodeTemporary,
"Number of MDNode::Temporary created");
74STATISTIC(NumMDRecordLoaded,
"Number of Metadata records loaded");
80 cl::desc(
"Import full type definitions for ThinLTO."));
84 cl::desc(
"Force disable the lazy-loading on-demand of metadata when "
85 "loading bitcode for importing."));
89static int64_t unrotateSign(
uint64_t U) {
return (U & 1) ? ~(U >> 1) : U >> 1; }
91class BitcodeReaderMetadataList {
118 unsigned RefsUpperBound;
121 BitcodeReaderMetadataList(
LLVMContext &
C,
size_t RefsUpperBound)
127 unsigned size()
const {
return MetadataPtrs.
size(); }
128 void resize(
unsigned N) { MetadataPtrs.
resize(
N); }
132 void pop_back() { MetadataPtrs.
pop_back(); }
133 bool empty()
const {
return MetadataPtrs.
empty(); }
135 Metadata *operator[](
unsigned i)
const {
137 return MetadataPtrs[i];
141 if (
I < MetadataPtrs.
size())
142 return MetadataPtrs[
I];
146 void shrinkTo(
unsigned N) {
147 assert(
N <=
size() &&
"Invalid shrinkTo request!");
149 assert(UnresolvedNodes.
empty() &&
"Unexpected unresolved node");
163 MDNode *getMDNodeFwdRefOrNull(
unsigned Idx);
165 void tryToResolveCycles();
167 int getNextFwdRef() {
185void BitcodeReaderMetadataList::assignValue(
Metadata *MD,
unsigned Idx) {
186 if (
auto *MDN = dyn_cast<MDNode>(MD))
187 if (!MDN->isResolved())
205 TempMDTuple PrevMD(cast<MDTuple>(OldMD.
get()));
206 PrevMD->replaceAllUsesWith(MD);
210Metadata *BitcodeReaderMetadataList::getMetadataFwdRef(
unsigned Idx) {
212 if (
Idx >= RefsUpperBound)
225 ++NumMDNodeTemporary;
227 MetadataPtrs[
Idx].reset(MD);
231Metadata *BitcodeReaderMetadataList::getMetadataIfResolved(
unsigned Idx) {
233 if (
auto *
N = dyn_cast_or_null<MDNode>(MD))
234 if (!
N->isResolved())
239MDNode *BitcodeReaderMetadataList::getMDNodeFwdRefOrNull(
unsigned Idx) {
240 return dyn_cast_or_null<MDNode>(getMetadataFwdRef(
Idx));
243void BitcodeReaderMetadataList::tryToResolveCycles() {
249 for (
const auto &
Ref : OldTypeRefs.FwdDecls)
250 OldTypeRefs.Final.insert(
Ref);
251 OldTypeRefs.FwdDecls.clear();
255 for (
const auto &Array : OldTypeRefs.Arrays)
256 Array.second->replaceAllUsesWith(resolveTypeRefArray(
Array.first.get()));
257 OldTypeRefs.Arrays.clear();
262 for (
const auto &
Ref : OldTypeRefs.Unknown) {
264 Ref.second->replaceAllUsesWith(CT);
266 Ref.second->replaceAllUsesWith(
Ref.first);
268 OldTypeRefs.Unknown.clear();
270 if (UnresolvedNodes.
empty())
275 for (
unsigned I : UnresolvedNodes) {
276 auto &MD = MetadataPtrs[
I];
277 auto *
N = dyn_cast_or_null<MDNode>(MD);
281 assert(!
N->isTemporary() &&
"Unexpected forward reference");
286 UnresolvedNodes.clear();
289void BitcodeReaderMetadataList::addTypeRef(
MDString &
UUID,
293 OldTypeRefs.FwdDecls.insert(std::make_pair(&
UUID, &CT));
295 OldTypeRefs.Final.insert(std::make_pair(&
UUID, &CT));
299 auto *
UUID = dyn_cast_or_null<MDString>(MaybeUUID);
303 if (
auto *CT = OldTypeRefs.Final.lookup(
UUID))
306 auto &
Ref = OldTypeRefs.Unknown[
UUID];
312Metadata *BitcodeReaderMetadataList::upgradeTypeRefArray(
Metadata *MaybeTuple) {
313 auto *Tuple = dyn_cast_or_null<MDTuple>(MaybeTuple);
314 if (!Tuple || Tuple->isDistinct())
318 if (!Tuple->isTemporary())
319 return resolveTypeRefArray(Tuple);
323 OldTypeRefs.Arrays.emplace_back(
324 std::piecewise_construct, std::forward_as_tuple(Tuple),
326 return OldTypeRefs.Arrays.back().second.get();
329Metadata *BitcodeReaderMetadataList::resolveTypeRefArray(
Metadata *MaybeTuple) {
330 auto *Tuple = dyn_cast_or_null<MDTuple>(MaybeTuple);
331 if (!Tuple || Tuple->isDistinct())
336 Ops.
reserve(Tuple->getNumOperands());
337 for (
Metadata *MD : Tuple->operands())
345class PlaceholderQueue {
348 std::deque<DistinctMDOperandPlaceholder> PHs;
351 ~PlaceholderQueue() {
353 "PlaceholderQueue hasn't been flushed before being destroyed");
355 bool empty()
const {
return PHs.empty(); }
357 void flush(BitcodeReaderMetadataList &MetadataList);
361 void getTemporaries(BitcodeReaderMetadataList &MetadataList,
363 for (
auto &PH : PHs) {
364 auto ID = PH.getID();
365 auto *MD = MetadataList.lookup(
ID);
370 auto *
N = dyn_cast_or_null<MDNode>(MD);
371 if (
N &&
N->isTemporary())
380 PHs.emplace_back(
ID);
384void PlaceholderQueue::flush(BitcodeReaderMetadataList &MetadataList) {
385 while (!PHs.empty()) {
386 auto *MD = MetadataList.lookup(PHs.front().getID());
387 assert(MD &&
"Flushing placeholder on unassigned MD");
389 if (
auto *MDN = dyn_cast<MDNode>(MD))
390 assert(MDN->isResolved() &&
391 "Flushing Placeholder while cycles aren't resolved");
393 PHs.front().replaceUseWith(MD);
401 return make_error<StringError>(
406 BitcodeReaderMetadataList MetadataList;
419 std::vector<StringRef> MDStringRef;
426 std::vector<uint64_t> GlobalMetadataBitPosIndex;
431 uint64_t GlobalDeclAttachmentPos = 0;
436 unsigned NumGlobalDeclAttachSkipped = 0;
437 unsigned NumGlobalDeclAttachParsed = 0;
450 void lazyLoadOneMetadata(
unsigned Idx, PlaceholderQueue &Placeholders);
454 std::vector<std::pair<DICompileUnit *, Metadata *>> CUSubprograms;
463 bool StripTBAA =
false;
464 bool HasSeenOldLoopTags =
false;
465 bool NeedUpgradeToDIGlobalVariableExpression =
false;
466 bool NeedDeclareExpressionUpgrade =
false;
472 bool IsImporting =
false;
475 PlaceholderQueue &Placeholders,
StringRef Blob,
476 unsigned &NextMetadataNo);
483 void resolveForwardRefsAndPlaceholders(PlaceholderQueue &Placeholders);
486 void upgradeCUSubprograms() {
487 for (
auto CU_SP : CUSubprograms)
488 if (
auto *SPs = dyn_cast_or_null<MDTuple>(CU_SP.second))
489 for (
auto &
Op : SPs->operands())
490 if (
auto *SP = dyn_cast_or_null<DISubprogram>(
Op))
491 SP->replaceUnit(CU_SP.first);
492 CUSubprograms.clear();
496 void upgradeCUVariables() {
497 if (!NeedUpgradeToDIGlobalVariableExpression)
502 for (
unsigned I = 0,
E = CUNodes->getNumOperands();
I !=
E; ++
I) {
503 auto *
CU = cast<DICompileUnit>(CUNodes->getOperand(
I));
504 if (
auto *GVs = dyn_cast_or_null<MDTuple>(
CU->getRawGlobalVariables()))
505 for (
unsigned I = 0;
I < GVs->getNumOperands();
I++)
507 dyn_cast_or_null<DIGlobalVariable>(GVs->getOperand(
I))) {
510 GVs->replaceOperandWith(
I, DGVE);
515 for (
auto &GV : TheModule.
globals()) {
517 GV.getMetadata(LLVMContext::MD_dbg, MDs);
518 GV.eraseMetadata(LLVMContext::MD_dbg);
520 if (
auto *DGV = dyn_cast<DIGlobalVariable>(MD)) {
523 GV.addMetadata(LLVMContext::MD_dbg, *DGVE);
525 GV.addMetadata(LLVMContext::MD_dbg, *MD);
532 if (
auto *SP = ParentSubprogram[S]) {
538 while (S && !isa<DISubprogram>(S)) {
539 S = dyn_cast_or_null<DILocalScope>(S->
getScope());
544 ParentSubprogram[InitialScope] = llvm::dyn_cast_or_null<DISubprogram>(S);
546 return ParentSubprogram[InitialScope];
551 void upgradeCULocals() {
553 for (
unsigned I = 0,
E = CUNodes->getNumOperands();
I !=
E; ++
I) {
554 auto *
CU = dyn_cast<DICompileUnit>(CUNodes->getOperand(
I));
558 if (
CU->getRawImportedEntities()) {
561 for (
Metadata *
Op :
CU->getImportedEntities()->operands()) {
562 auto *IE = cast<DIImportedEntity>(
Op);
563 if (dyn_cast_or_null<DILocalScope>(IE->getScope())) {
564 EntitiesToRemove.
insert(IE);
568 if (!EntitiesToRemove.
empty()) {
571 for (
Metadata *
Op :
CU->getImportedEntities()->operands()) {
572 if (!EntitiesToRemove.
contains(cast<DIImportedEntity>(
Op))) {
578 std::map<DISubprogram *, SmallVector<Metadata *>> SPToEntities;
579 for (
auto *
I : EntitiesToRemove) {
580 auto *Entity = cast<DIImportedEntity>(
I);
581 if (
auto *SP = findEnclosingSubprogram(
582 cast<DILocalScope>(Entity->getScope()))) {
583 SPToEntities[SP].push_back(Entity);
588 for (
auto I = SPToEntities.begin();
I != SPToEntities.end(); ++
I) {
590 auto RetainedNodes = SP->getRetainedNodes();
592 RetainedNodes.end());
604 ParentSubprogram.
clear();
609 void upgradeDeclareExpressions(
Function &
F) {
610 if (!NeedDeclareExpressionUpgrade)
615 if (
auto *DDI = dyn_cast<DbgDeclareInst>(&
I))
616 if (
auto *DIExpr = DDI->getExpression())
617 if (DIExpr->startsWithDeref() &&
618 isa_and_nonnull<Argument>(DDI->getAddress())) {
620 Ops.
append(std::next(DIExpr->elements_begin()),
621 DIExpr->elements_end());
630 auto N = Expr.
size();
631 switch (FromVersion) {
633 return error(
"Invalid record");
635 if (
N >= 3 && Expr[
N - 3] == dwarf::DW_OP_bit_piece)
640 if (
N && Expr[0] == dwarf::DW_OP_deref) {
642 if (Expr.
size() >= 3 &&
646 *std::prev(
End) = dwarf::DW_OP_deref;
648 NeedDeclareExpressionUpgrade =
true;
654 while (!SubExpr.empty()) {
659 switch (SubExpr.front()) {
663 case dwarf::DW_OP_constu:
664 case dwarf::DW_OP_minus:
665 case dwarf::DW_OP_plus:
675 HistoricSize = std::min(SubExpr.size(), HistoricSize);
678 switch (SubExpr.front()) {
679 case dwarf::DW_OP_plus:
680 Buffer.
push_back(dwarf::DW_OP_plus_uconst);
681 Buffer.
append(Args.begin(), Args.end());
683 case dwarf::DW_OP_minus:
685 Buffer.
append(Args.begin(), Args.end());
690 Buffer.
append(Args.begin(), Args.end());
695 SubExpr = SubExpr.slice(HistoricSize);
708 void upgradeDebugInfo() {
709 upgradeCUSubprograms();
710 upgradeCUVariables();
720 : MetadataList(TheModule.getContext(), Stream.SizeInBytes()),
721 ValueList(ValueList), Stream(Stream),
Context(TheModule.getContext()),
722 TheModule(TheModule), Callbacks(
std::
move(Callbacks)),
723 IsImporting(IsImporting) {}
727 bool hasFwdRefs()
const {
return MetadataList.hasFwdRefs(); }
730 if (
ID < MDStringRef.size())
731 return lazyLoadOneMDString(
ID);
732 if (
auto *MD = MetadataList.lookup(
ID))
736 if (
ID < (MDStringRef.size() + GlobalMetadataBitPosIndex.size())) {
737 PlaceholderQueue Placeholders;
738 lazyLoadOneMetadata(
ID, Placeholders);
739 resolveForwardRefsAndPlaceholders(Placeholders);
740 return MetadataList.lookup(
ID);
742 return MetadataList.getMetadataFwdRef(
ID);
746 return FunctionsWithSPs.
lookup(
F);
759 unsigned size()
const {
return MetadataList.size(); }
765MetadataLoader::MetadataLoaderImpl::lazyLoadModuleMetadataBlock() {
766 IndexCursor = Stream;
768 GlobalDeclAttachmentPos = 0;
779 switch (Entry.Kind) {
782 return error(
"Malformed block");
797 return std::move(Err);
804 return MaybeRecord.takeError();
805 unsigned NumStrings =
Record[0];
806 MDStringRef.reserve(NumStrings);
807 auto IndexNextMDString = [&](
StringRef Str) {
808 MDStringRef.push_back(Str);
810 if (
auto Err = parseMetadataStrings(
Record, Blob, IndexNextMDString))
811 return std::move(Err);
818 return std::move(Err);
824 return MaybeRecord.takeError();
826 return error(
"Invalid record");
830 return std::move(Err);
836 Entry = MaybeEntry.
get();
838 "Corrupted bitcode: Expected `Record` when trying to find the "
844 "Corrupted bitcode: Expected `METADATA_INDEX` when trying to "
845 "find the Metadata index");
847 return MaybeCode.takeError();
849 auto CurrentValue = BeginPos;
850 GlobalMetadataBitPosIndex.reserve(
Record.size());
851 for (
auto &Elt :
Record) {
853 GlobalMetadataBitPosIndex.push_back(CurrentValue);
860 return error(
"Corrupted Metadata block");
864 return std::move(Err);
870 Code = MaybeCode.get();
873 return MaybeCode.takeError();
878 Code = MaybeCode.get();
880 return MaybeCode.takeError();
889 return MaybeNextBitCode.takeError();
894 for (
unsigned i = 0; i !=
Size; ++i) {
899 MDNode *MD = MetadataList.getMDNodeFwdRefOrNull(
Record[i]);
900 assert(MD &&
"Invalid metadata: expect fwd ref to MDNode");
906 if (!GlobalDeclAttachmentPos)
907 GlobalDeclAttachmentPos = SavedPos;
909 NumGlobalDeclAttachSkipped++;
953 GlobalMetadataBitPosIndex.clear();
967Expected<bool> MetadataLoader::MetadataLoaderImpl::loadGlobalDeclAttachments() {
969 if (!GlobalDeclAttachmentPos)
978 return std::move(Err);
987 switch (Entry.Kind) {
990 return error(
"Malformed block");
993 assert(NumGlobalDeclAttachSkipped == NumGlobalDeclAttachParsed);
1005 assert(NumGlobalDeclAttachSkipped == NumGlobalDeclAttachParsed);
1009 NumGlobalDeclAttachParsed++;
1014 return std::move(Err);
1020 return MaybeRecord.takeError();
1021 if (
Record.size() % 2 == 0)
1022 return error(
"Invalid record");
1023 unsigned ValueID =
Record[0];
1024 if (ValueID >= ValueList.size())
1025 return error(
"Invalid record");
1026 if (
auto *GO = dyn_cast<GlobalObject>(ValueList[ValueID])) {
1031 if (
Error Err = parseGlobalObjectAttachment(
1033 return std::move(Err);
1035 return std::move(Err);
1040void MetadataLoader::MetadataLoaderImpl::callMDTypeCallback(
Metadata **Val,
1042 if (Callbacks.MDType) {
1043 (*Callbacks.MDType)(Val,
TypeID, Callbacks.GetTypeByID,
1044 Callbacks.GetContainedTypeID);
1051 if (!ModuleLevel && MetadataList.hasFwdRefs())
1052 return error(
"Invalid metadata: fwd refs into function blocks");
1056 auto EntryPos = Stream.GetCurrentBitNo();
1062 PlaceholderQueue Placeholders;
1066 if (ModuleLevel && IsImporting && MetadataList.empty() &&
1068 auto SuccessOrErr = lazyLoadModuleMetadataBlock();
1070 return SuccessOrErr.takeError();
1071 if (SuccessOrErr.get()) {
1074 MetadataList.resize(MDStringRef.size() +
1075 GlobalMetadataBitPosIndex.size());
1080 SuccessOrErr = loadGlobalDeclAttachments();
1082 return SuccessOrErr.takeError();
1083 assert(SuccessOrErr.get());
1087 resolveForwardRefsAndPlaceholders(Placeholders);
1091 Stream.ReadBlockEnd();
1092 if (
Error Err = IndexCursor.JumpToBit(EntryPos))
1094 if (
Error Err = Stream.SkipBlock()) {
1105 unsigned NextMetadataNo = MetadataList.size();
1110 if (
Error E = Stream.advanceSkippingSubblocks().moveInto(Entry))
1113 switch (Entry.Kind) {
1116 return error(
"Malformed block");
1118 resolveForwardRefsAndPlaceholders(Placeholders);
1129 ++NumMDRecordLoaded;
1131 Stream.readRecord(Entry.ID,
Record, &Blob)) {
1132 if (
Error Err = parseOneMetadata(
Record, MaybeCode.
get(), Placeholders,
1133 Blob, NextMetadataNo))
1140MDString *MetadataLoader::MetadataLoaderImpl::lazyLoadOneMDString(
unsigned ID) {
1141 ++NumMDStringLoaded;
1143 return cast<MDString>(MD);
1145 MetadataList.assignValue(MDS,
ID);
1149void MetadataLoader::MetadataLoaderImpl::lazyLoadOneMetadata(
1150 unsigned ID, PlaceholderQueue &Placeholders) {
1151 assert(
ID < (MDStringRef.size()) + GlobalMetadataBitPosIndex.size());
1152 assert(
ID >= MDStringRef.size() &&
"Unexpected lazy-loading of MDString");
1154 if (
auto *MD = MetadataList.lookup(
ID)) {
1155 auto *
N = cast<MDNode>(MD);
1156 if (!
N->isTemporary())
1161 if (
Error Err = IndexCursor.JumpToBit(
1162 GlobalMetadataBitPosIndex[
ID - MDStringRef.size()]))
1166 if (
Error E = IndexCursor.advanceSkippingSubblocks().moveInto(Entry))
1170 ++NumMDRecordLoaded;
1172 IndexCursor.readRecord(Entry.ID,
Record, &Blob)) {
1174 parseOneMetadata(
Record, MaybeCode.
get(), Placeholders, Blob,
ID))
1184void MetadataLoader::MetadataLoaderImpl::resolveForwardRefsAndPlaceholders(
1185 PlaceholderQueue &Placeholders) {
1189 Placeholders.getTemporaries(MetadataList, Temporaries);
1192 if (Temporaries.
empty() && !MetadataList.hasFwdRefs())
1197 for (
auto ID : Temporaries)
1198 lazyLoadOneMetadata(
ID, Placeholders);
1199 Temporaries.clear();
1203 while (MetadataList.hasFwdRefs())
1204 lazyLoadOneMetadata(MetadataList.getNextFwdRef(), Placeholders);
1209 MetadataList.tryToResolveCycles();
1213 Placeholders.flush(MetadataList);
1216Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
1218 PlaceholderQueue &Placeholders,
StringRef Blob,
unsigned &NextMetadataNo) {
1220 bool IsDistinct =
false;
1221 auto getMD = [&](
unsigned ID) ->
Metadata * {
1222 if (
ID < MDStringRef.size())
1223 return lazyLoadOneMDString(
ID);
1225 if (
auto *MD = MetadataList.lookup(
ID))
1229 if (
ID < (MDStringRef.size() + GlobalMetadataBitPosIndex.size())) {
1233 MetadataList.getMetadataFwdRef(NextMetadataNo);
1234 lazyLoadOneMetadata(
ID, Placeholders);
1235 return MetadataList.lookup(
ID);
1238 return MetadataList.getMetadataFwdRef(
ID);
1240 if (
auto *MD = MetadataList.getMetadataIfResolved(
ID))
1242 return &Placeholders.getPlaceholderOp(
ID);
1244 auto getMDOrNull = [&](
unsigned ID) ->
Metadata * {
1246 return getMD(
ID - 1);
1249 auto getMDOrNullWithoutPlaceholders = [&](
unsigned ID) ->
Metadata * {
1251 return MetadataList.getMetadataFwdRef(
ID - 1);
1254 auto getMDString = [&](
unsigned ID) ->
MDString * {
1257 auto MDS = getMDOrNull(
ID);
1258 return cast_or_null<MDString>(MDS);
1262 auto getDITypeRefOrNull = [&](
unsigned ID) {
1263 return MetadataList.upgradeTypeRef(getMDOrNull(
ID));
1266#define GET_OR_DISTINCT(CLASS, ARGS) \
1267 (IsDistinct ? CLASS::getDistinct ARGS : CLASS::get ARGS)
1276 if (
Error E = Stream.ReadCode().moveInto(Code))
1279 ++NumMDRecordLoaded;
1282 return error(
"METADATA_NAME not followed by METADATA_NAMED_NODE");
1284 return MaybeNextBitCode.takeError();
1289 for (
unsigned i = 0; i !=
Size; ++i) {
1290 MDNode *MD = MetadataList.getMDNodeFwdRefOrNull(
Record[i]);
1292 return error(
"Invalid named metadata: expect fwd ref to MDNode");
1301 if (
Record.size() % 2 == 1)
1302 return error(
"Invalid record");
1306 auto dropRecord = [&] {
1307 MetadataList.assignValue(
MDNode::get(Context, std::nullopt),
1311 if (
Record.size() != 2) {
1316 unsigned TyID =
Record[0];
1317 Type *Ty = Callbacks.GetTypeByID(TyID);
1323 Value *
V = ValueList.getValueFwdRef(
Record[1], Ty, TyID,
1326 return error(
"Invalid value reference from old fn metadata");
1334 if (
Record.size() % 2 == 1)
1335 return error(
"Invalid record");
1339 for (
unsigned i = 0; i !=
Size; i += 2) {
1340 unsigned TyID =
Record[i];
1341 Type *Ty = Callbacks.GetTypeByID(TyID);
1343 return error(
"Invalid record");
1347 Value *
V = ValueList.getValueFwdRef(
Record[i + 1], Ty, TyID,
1350 return error(
"Invalid value reference from old metadata");
1352 assert(isa<ConstantAsMetadata>(MD) &&
1353 "Expected non-function-local metadata");
1354 callMDTypeCallback(&MD, TyID);
1359 MetadataList.assignValue(
MDNode::get(Context, Elts), NextMetadataNo);
1365 return error(
"Invalid record");
1367 unsigned TyID =
Record[0];
1368 Type *Ty = Callbacks.GetTypeByID(TyID);
1370 return error(
"Invalid record");
1372 Value *
V = ValueList.getValueFwdRef(
Record[1], Ty, TyID,
1375 return error(
"Invalid value reference from metadata");
1378 callMDTypeCallback(&MD, TyID);
1379 MetadataList.assignValue(MD, NextMetadataNo);
1399 return error(
"Invalid record");
1403 unsigned Column =
Record[2];
1407 MetadataList.assignValue(
1416 return error(
"Invalid record");
1422 if (
Tag >= 1u << 16 || Version != 0)
1423 return error(
"Invalid record");
1425 auto *Header = getMDString(
Record[3]);
1427 for (
unsigned I = 4,
E =
Record.size();
I !=
E; ++
I)
1429 MetadataList.assignValue(
1445 switch (
Record[0] >> 1) {
1452 unrotateSign(
Record[2])));
1460 return error(
"Invalid record: Unsupported version of DISubrange");
1463 MetadataList.assignValue(Val, NextMetadataNo);
1464 IsDistinct =
Record[0] & 1;
1471 (Context, getMDOrNull(
Record[1]),
1473 getMDOrNull(
Record[4])));
1475 MetadataList.assignValue(Val, NextMetadataNo);
1476 IsDistinct =
Record[0] & 1;
1482 return error(
"Invalid record");
1484 IsDistinct =
Record[0] & 1;
1485 bool IsUnsigned =
Record[0] & 2;
1486 bool IsBigInt =
Record[0] & 4;
1491 const size_t NumWords =
Record.size() - 3;
1496 MetadataList.assignValue(
1498 (Context,
Value, IsUnsigned, getMDString(
Record[2]))),
1505 return error(
"Invalid record");
1512 MetadataList.assignValue(
1522 return error(
"Invalid record");
1525 bool SizeIs8 =
Record.size() == 8;
1528 Metadata *StringLocationExp = SizeIs8 ? nullptr : getMDOrNull(
Record[5]);
1529 unsigned Offset = SizeIs8 ? 5 : 6;
1530 MetadataList.assignValue(
1542 return error(
"Invalid record");
1546 std::optional<unsigned> DWARFAddressSpace;
1548 DWARFAddressSpace =
Record[12] - 1;
1556 MetadataList.assignValue(
1560 getDITypeRefOrNull(
Record[5]),
1562 Record[9], DWARFAddressSpace, Flags,
1570 return error(
"Invalid record");
1574 IsDistinct =
Record[0] & 0x1;
1575 bool IsNotUsedInTypeRef =
Record[0] >= 2;
1584 return error(
"Alignment value is too large");
1589 unsigned RuntimeLang =
Record[12];
1591 Metadata *TemplateParams =
nullptr;
1607 (
Tag == dwarf::DW_TAG_enumeration_type ||
1608 Tag == dwarf::DW_TAG_class_type ||
1609 Tag == dwarf::DW_TAG_structure_type ||
1610 Tag == dwarf::DW_TAG_union_type)) {
1619 TemplateParams = getMDOrNull(
Record[14]);
1623 OffsetInBits =
Record[9];
1625 VTableHolder = getDITypeRefOrNull(
Record[13]);
1626 TemplateParams = getMDOrNull(
Record[14]);
1630 DataLocation = getMDOrNull(
Record[17]);
1631 if (
Record.size() > 19) {
1632 Associated = getMDOrNull(
Record[18]);
1633 Allocated = getMDOrNull(
Record[19]);
1635 if (
Record.size() > 20) {
1636 Rank = getMDOrNull(
Record[20]);
1638 if (
Record.size() > 21) {
1646 SizeInBits, AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
1647 VTableHolder, TemplateParams, Discriminator, DataLocation, Associated,
1654 SizeInBits, AlignInBits, OffsetInBits, Flags,
1655 Elements, RuntimeLang, VTableHolder, TemplateParams,
1656 Identifier, Discriminator, DataLocation, Associated,
1658 if (!IsNotUsedInTypeRef && Identifier)
1659 MetadataList.addTypeRef(*Identifier, *cast<DICompositeType>(CT));
1661 MetadataList.assignValue(CT, NextMetadataNo);
1667 return error(
"Invalid record");
1668 bool IsOldTypeRefArray =
Record[0] < 2;
1671 IsDistinct =
Record[0] & 0x1;
1675 Types = MetadataList.upgradeTypeRefArray(Types);
1677 MetadataList.assignValue(
1686 return error(
"Invalid record");
1690 MetadataList.assignValue(
1693 (Context,
Record.size() >= 8 ? getMDOrNull(
Record[1]) :
nullptr,
1706 return error(
"Invalid record");
1709 std::optional<DIFile::ChecksumInfo<MDString *>> Checksum;
1718 MetadataList.assignValue(
1720 (Context, getMDString(
Record[1]),
1721 getMDString(
Record[2]), Checksum,
1722 Record.size() > 5 ? getMDString(
Record[5]) :
nullptr)),
1729 return error(
"Invalid record");
1739 Record.size() <= 15 ?
nullptr : getMDOrNull(
Record[15]),
1745 Record.size() <= 20 ?
nullptr : getMDString(
Record[20]),
1746 Record.size() <= 21 ?
nullptr : getMDString(
Record[21]));
1748 MetadataList.assignValue(
CU, NextMetadataNo);
1753 CUSubprograms.push_back({
CU, SPs});
1758 return error(
"Invalid record");
1760 bool HasSPFlags =
Record[0] & 4;
1773 const unsigned DIFlagMainSubprogram = 1 << 21;
1774 bool HasOldMainSubprogramFlag =
Flags & DIFlagMainSubprogram;
1775 if (HasOldMainSubprogramFlag)
1779 Flags &= ~static_cast<DINode::DIFlags>(DIFlagMainSubprogram);
1781 if (HasOldMainSubprogramFlag && HasSPFlags)
1782 SPFlags |= DISubprogram::SPFlagMainSubprogram;
1783 else if (!HasSPFlags)
1787 HasOldMainSubprogramFlag);
1790 IsDistinct = (
Record[0] & 1) || (SPFlags & DISubprogram::SPFlagDefinition);
1796 bool HasUnit =
Record[0] & 2;
1797 if (!HasSPFlags && HasUnit &&
Record.size() < 19)
1798 return error(
"Invalid record");
1799 if (HasSPFlags && !HasUnit)
1800 return error(
"Invalid record");
1803 bool HasThisAdj =
true;
1804 bool HasThrownTypes =
true;
1805 bool HasAnnotations =
false;
1806 bool HasTargetFuncName =
false;
1807 unsigned OffsetA = 0;
1808 unsigned OffsetB = 0;
1812 if (
Record.size() >= 19) {
1816 HasThisAdj =
Record.size() >= 20;
1817 HasThrownTypes =
Record.size() >= 21;
1819 HasAnnotations =
Record.size() >= 19;
1820 HasTargetFuncName =
Record.size() >= 20;
1826 getDITypeRefOrNull(
Record[1]),
1833 getDITypeRefOrNull(
Record[8 + OffsetA]),
1835 HasThisAdj ?
Record[16 + OffsetB] : 0,
1838 HasUnit ? CUorFn :
nullptr,
1839 getMDOrNull(
Record[13 + OffsetB]),
1840 getMDOrNull(
Record[14 + OffsetB]),
1841 getMDOrNull(
Record[15 + OffsetB]),
1842 HasThrownTypes ? getMDOrNull(
Record[17 + OffsetB])
1844 HasAnnotations ? getMDOrNull(
Record[18 + OffsetB])
1846 HasTargetFuncName ? getMDString(
Record[19 + OffsetB])
1849 MetadataList.assignValue(SP, NextMetadataNo);
1854 if (
auto *CMD = dyn_cast_or_null<ConstantAsMetadata>(CUorFn))
1855 if (
auto *
F = dyn_cast<Function>(CMD->getValue())) {
1856 if (
F->isMaterializable())
1859 FunctionsWithSPs[
F] = SP;
1860 else if (!
F->empty())
1861 F->setSubprogram(SP);
1868 return error(
"Invalid record");
1871 MetadataList.assignValue(
1873 (Context, getMDOrNull(
Record[1]),
1881 return error(
"Invalid record");
1884 MetadataList.assignValue(
1886 (Context, getMDOrNull(
Record[1]),
1893 IsDistinct =
Record[0] & 1;
1894 MetadataList.assignValue(
1896 (Context, getMDOrNull(
Record[1]),
1908 else if (
Record.size() == 5)
1911 return error(
"Invalid record");
1913 IsDistinct =
Record[0] & 1;
1914 bool ExportSymbols =
Record[0] & 2;
1915 MetadataList.assignValue(
1917 (Context, getMDOrNull(
Record[1]),
Name, ExportSymbols)),
1924 return error(
"Invalid record");
1927 MetadataList.assignValue(
1930 getMDString(
Record[4]))),
1937 return error(
"Invalid record");
1940 MetadataList.assignValue(
1943 getMDOrNull(
Record[4]))),
1950 return error(
"Invalid record");
1953 MetadataList.assignValue(
1955 (Context, getMDString(
Record[1]),
1956 getDITypeRefOrNull(
Record[2]),
1958 : getMDOrNull(
false))),
1965 return error(
"Invalid record");
1969 MetadataList.assignValue(
1973 getDITypeRefOrNull(
Record[3]),
1974 (
Record.size() == 6) ? getMDOrNull(
Record[4]) : getMDOrNull(
false),
1976 : getMDOrNull(
Record[4]))),
1983 return error(
"Invalid record");
1985 IsDistinct =
Record[0] & 1;
1993 MetadataList.assignValue(
1995 (Context, getMDOrNull(
Record[1]),
2004 }
else if (Version == 1) {
2007 MetadataList.assignValue(
2010 (Context, getMDOrNull(
Record[1]), getMDString(
Record[2]),
2013 getMDOrNull(
Record[10]),
nullptr,
Record[11],
nullptr)),
2017 }
else if (Version == 0) {
2020 NeedUpgradeToDIGlobalVariableExpression =
true;
2023 if (
Record.size() > 11) {
2025 return error(
"Alignment value is too large");
2026 AlignInBits =
Record[11];
2029 if (
auto *CMD = dyn_cast_or_null<ConstantAsMetadata>(Expr)) {
2030 if (
auto *GV = dyn_cast<GlobalVariable>(CMD->getValue())) {
2033 }
else if (
auto *CI = dyn_cast<ConstantInt>(CMD->getValue())) {
2035 {dwarf::DW_OP_constu, CI->getZExtValue(),
2036 dwarf::DW_OP_stack_value});
2043 (Context, getMDOrNull(
Record[1]), getMDString(
Record[2]),
2046 getMDOrNull(
Record[10]),
nullptr, AlignInBits,
nullptr));
2056 MetadataList.assignValue(
MDNode, NextMetadataNo);
2059 return error(
"Invalid record");
2065 return error(
"Invalid DIAssignID record.");
2067 IsDistinct =
Record[0] & 1;
2069 return error(
"Invalid DIAssignID record. Must be distinct");
2078 return error(
"Invalid record");
2080 IsDistinct =
Record[0] & 1;
2081 bool HasAlignment =
Record[0] & 2;
2085 bool HasTag = !HasAlignment &&
Record.size() > 8;
2091 return error(
"Alignment value is too large");
2097 MetadataList.assignValue(
2099 (Context, getMDOrNull(
Record[1 + HasTag]),
2100 getMDString(
Record[2 + HasTag]),
2102 getDITypeRefOrNull(
Record[5 + HasTag]),
2110 return error(
"Invalid record");
2112 IsDistinct =
Record[0] & 1;
2113 MetadataList.assignValue(
2123 return error(
"Invalid record");
2125 IsDistinct =
Record[0] & 1;
2130 if (
Error Err = upgradeDIExpression(Version, Elts, Buffer))
2140 return error(
"Invalid record");
2146 MetadataList.assignValue(
2148 (Context, getMDOrNull(
Record[1]), Expr)),
2155 return error(
"Invalid record");
2158 MetadataList.assignValue(
2160 (Context, getMDString(
Record[1]),
2170 return error(
"Invalid DIImportedEntity record");
2173 bool HasFile = (
Record.size() >= 7);
2174 bool HasElements = (
Record.size() >= 8);
2175 MetadataList.assignValue(
2178 getDITypeRefOrNull(
Record[3]),
2179 HasFile ? getMDOrNull(
Record[6]) :
nullptr,
2181 HasElements ? getMDOrNull(
Record[7]) :
nullptr)),
2191 ++NumMDStringLoaded;
2193 MetadataList.assignValue(MD, NextMetadataNo);
2198 auto CreateNextMDString = [&](
StringRef Str) {
2199 ++NumMDStringLoaded;
2200 MetadataList.assignValue(
MDString::get(Context, Str), NextMetadataNo);
2203 if (
Error Err = parseMetadataStrings(
Record, Blob, CreateNextMDString))
2208 if (
Record.size() % 2 == 0)
2209 return error(
"Invalid record");
2210 unsigned ValueID =
Record[0];
2211 if (ValueID >= ValueList.size())
2212 return error(
"Invalid record");
2213 if (
auto *GO = dyn_cast<GlobalObject>(ValueList[ValueID]))
2214 if (
Error Err = parseGlobalObjectAttachment(
2231 if (isa<MDNode>(MD) && cast<MDNode>(MD)->isTemporary())
2233 "Invalid record: DIArgList should not contain forward refs");
2234 if (!isa<ValueAsMetadata>(MD))
2235 return error(
"Invalid record");
2236 Elts.
push_back(cast<ValueAsMetadata>(MD));
2239 MetadataList.assignValue(
DIArgList::get(Context, Elts), NextMetadataNo);
2245#undef GET_OR_DISTINCT
2248Error MetadataLoader::MetadataLoaderImpl::parseMetadataStrings(
2255 return error(
"Invalid record: metadata strings layout");
2257 unsigned NumStrings =
Record[0];
2258 unsigned StringsOffset =
Record[1];
2260 return error(
"Invalid record: metadata strings with no strings");
2261 if (StringsOffset > Blob.
size())
2262 return error(
"Invalid record: metadata strings corrupt offset");
2269 if (
R.AtEndOfStream())
2270 return error(
"Invalid record: metadata strings bad length");
2275 if (Strings.size() <
Size)
2276 return error(
"Invalid record: metadata strings truncated chars");
2278 CallBack(Strings.slice(0,
Size));
2279 Strings = Strings.drop_front(
Size);
2280 }
while (--NumStrings);
2285Error MetadataLoader::MetadataLoaderImpl::parseGlobalObjectAttachment(
2288 for (
unsigned I = 0,
E =
Record.size();
I !=
E;
I += 2) {
2289 auto K = MDKindMap.find(
Record[
I]);
2290 if (K == MDKindMap.end())
2291 return error(
"Invalid ID");
2295 return error(
"Invalid metadata attachment: expect fwd ref to MDNode");
2308 PlaceholderQueue Placeholders;
2312 if (
Error E = Stream.advanceSkippingSubblocks().moveInto(Entry))
2315 switch (Entry.Kind) {
2318 return error(
"Malformed block");
2320 resolveForwardRefsAndPlaceholders(Placeholders);
2329 ++NumMDRecordLoaded;
2333 switch (MaybeRecord.
get()) {
2337 unsigned RecordLength =
Record.size();
2339 return error(
"Invalid record");
2340 if (RecordLength % 2 == 0) {
2342 if (
Error Err = parseGlobalObjectAttachment(
F,
Record))
2349 for (
unsigned i = 1; i != RecordLength; i = i + 2) {
2350 unsigned Kind =
Record[i];
2352 if (
I == MDKindMap.end())
2353 return error(
"Invalid ID");
2354 if (
I->second == LLVMContext::MD_tbaa && StripTBAA)
2358 if (
Idx < (MDStringRef.size() + GlobalMetadataBitPosIndex.size()) &&
2359 !MetadataList.lookup(
Idx)) {
2362 lazyLoadOneMetadata(
Idx, Placeholders);
2363 resolveForwardRefsAndPlaceholders(Placeholders);
2366 Metadata *Node = MetadataList.getMetadataFwdRef(
Idx);
2367 if (isa<LocalAsMetadata>(Node))
2371 MDNode *MD = dyn_cast_or_null<MDNode>(Node);
2373 return error(
"Invalid metadata attachment");
2375 if (HasSeenOldLoopTags &&
I->second == LLVMContext::MD_loop)
2378 if (
I->second == LLVMContext::MD_tbaa) {
2391Error MetadataLoader::MetadataLoaderImpl::parseMetadataKindRecord(
2394 return error(
"Invalid record");
2396 unsigned Kind =
Record[0];
2399 unsigned NewKind = TheModule.getMDKindID(
Name.str());
2400 if (!MDKindMap.insert(std::make_pair(Kind, NewKind)).second)
2401 return error(
"Conflicting METADATA_KIND records");
2415 if (
Error E = Stream.advanceSkippingSubblocks().moveInto(Entry))
2418 switch (Entry.Kind) {
2421 return error(
"Malformed block");
2431 ++NumMDRecordLoaded;
2435 switch (MaybeCode.
get()) {
2448 Pimpl = std::move(
RHS.Pimpl);
2460 Stream, TheModule, ValueList,
std::
move(Callbacks), IsImporting)) {}
2462Error MetadataLoader::parseMetadata(
bool ModuleLevel) {
2463 return Pimpl->parseMetadata(ModuleLevel);
2471 return Pimpl->getMetadataFwdRefOrLoad(
Idx);
2475 return Pimpl->lookupSubprogramForFunction(
F);
2480 return Pimpl->parseMetadataAttachment(
F, InstructionList);
2484 return Pimpl->parseMetadataKinds();
2488 return Pimpl->setStripTBAA(StripTBAA);
2497 return Pimpl->upgradeDebugIntrinsics(
F);
This file implements a class to represent arbitrary precision integral constant values and operations...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_UNLIKELY(EXPR)
#define LLVM_LIKELY(EXPR)
This file contains the declarations for the subclasses of Constant, which represent the different fla...
static void clear(coro::Shape &Shape)
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
This file contains constants used for implementing Dwarf debug support.
static bool lookup(const GsymReader &GR, DataExtractor &Data, uint64_t &Offset, uint64_t BaseAddr, uint64_t Addr, SourceLocations &SrcLocs, llvm::Error &Err)
A Lookup helper functions.
#define GET_OR_DISTINCT(CLASS, ARGS)
Module.h This file contains the declarations for the Module class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallString class.
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
std::pair< llvm::MachO::Target, std::string > UUID
Class for arbitrary precision integers.
Annotations lets you mark points and ranges inside source code, for tests:
This class represents an incoming formal argument to a Function.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
This represents a position within a bitcode file, implemented on top of a SimpleBitstreamCursor.
Error JumpToBit(uint64_t BitNo)
Reset the stream to the specified bit number.
uint64_t GetCurrentBitNo() const
Return the bit # of the bit we are reading.
Expected< BitstreamEntry > advanceSkippingSubblocks(unsigned Flags=0)
This is a convenience function for clients that don't expect any subblocks.
Expected< unsigned > readRecord(unsigned AbbrevID, SmallVectorImpl< uint64_t > &Vals, StringRef *Blob=nullptr)
Expected< unsigned > skipRecord(unsigned AbbrevID)
Read the current record and discard it, returning the code for the record.
Expected< unsigned > ReadCode()
@ AF_DontPopBlockAtEnd
If this flag is used, the advance() method does not automatically pop the block scope when the end of...
static DIAssignID * getDistinct(LLVMContext &Context)
Basic type, like 'int' or 'float'.
static DICompositeType * buildODRType(LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name, Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags, Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder, Metadata *TemplateParams, Metadata *Discriminator, Metadata *DataLocation, Metadata *Associated, Metadata *Allocated, Metadata *Rank, Metadata *Annotations)
Build a DICompositeType with the given ODR identifier.
MDString * getRawIdentifier() const
ChecksumKind
Which algorithm (e.g.
A pair of DIGlobalVariable and DIExpression.
An imported module (C++ using directive or similar).
Represents a module in the programming language, for example, a Clang module, or a Fortran module.
DIScope * getScope() const
String type, Fortran CHARACTER(n)
static DISPFlags toSPFlags(bool IsLocalToUnit, bool IsDefinition, bool IsOptimized, unsigned Virtuality=SPFlagNonvirtual, bool IsMainSubprogram=false)
DISPFlags
Debug info subprogram flags.
Type array for a subprogram.
bool isForwardDecl() const
This class represents an Operation in the Expression.
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
Implements a dense probed hash-table based set.
Placeholder metadata for operands of distinct MDNodes.
Lightweight error class with error context and mandatory checking.
static ErrorSuccess success()
Create a success value.
Tagged union holding either a T or a Error.
Error takeError()
Take ownership of the stored error.
reference get()
Returns a reference to the stored T value.
Generic tagged DWARF-like metadata node.
void addMetadata(unsigned KindID, MDNode &MD)
Add a metadata attachment.
void addDebugInfo(DIGlobalVariableExpression *GV)
Attach a DIGlobalVariableExpression.
void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
This is an important class for using LLVM in a threaded context.
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static MDString * get(LLVMContext &Context, StringRef Str)
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
static TempMDTuple getTemporary(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Return a temporary node.
A Module instance is used to store all the information related to an LLVM module.
NamedMDNode * getNamedMetadata(const Twine &Name) const
Return the first NamedMDNode in the module with the specified name.
iterator_range< global_iterator > globals()
NamedMDNode * getOrInsertNamedMetadata(StringRef Name)
Return the named MDNode in the module with the specified name.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
MutableArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
void addOperand(MDNode *M)
A vector that has set insertion semantics.
bool empty() const
Determine if the SetVector is empty or not.
bool insert(const value_type &X)
Insert a new element into the SetVector.
bool contains(const key_type &key) const
Check if the SetVector contains the given key.
This represents a position within a bitstream.
Implements a dense probed hash-table based set with some number of buckets stored inline.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void reserve(size_type N)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
StringRef drop_front(size_t N=1) const
Return a StringRef equal to 'this' but with the first N elements dropped.
StringRef slice(size_t Start, size_t End) const
Return a reference to the substring from [Start, End).
constexpr size_t size() const
size - Get the string size.
bool contains(StringRef Other) const
Return true if the given string is a substring of *this, and false otherwise.
bool startswith(StringRef Prefix) const
Tracking metadata reference.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
TypeID
Definitions of all of the base types for the Type system.
bool isVoidTy() const
Return true if this is 'void'.
bool isMetadataTy() const
Return true if this is 'metadata'.
LLVM Value Representation.
std::pair< iterator, bool > insert(const ValueT &V)
bool contains(const_arg_type_t< ValueT > V) const
Check if the set contains the given element.
An efficient, type-erasing, non-owning reference to a callable.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ C
The default llvm calling convention, compatible with C.
@ METADATA_TEMPLATE_VALUE
@ METADATA_LEXICAL_BLOCK_FILE
@ METADATA_SUBROUTINE_TYPE
@ METADATA_GLOBAL_DECL_ATTACHMENT
@ METADATA_IMPORTED_ENTITY
@ METADATA_GENERIC_SUBRANGE
@ METADATA_COMPOSITE_TYPE
@ METADATA_GLOBAL_VAR_EXPR
initializer< Ty > init(const Ty &Val)
std::optional< const char * > toString(const std::optional< DWARFFormValue > &V)
Take an optional DWARFFormValue and try to extract a string value from it.
@ DW_OP_LLVM_fragment
Only used in LLVM metadata.
Scope
Defines the scope in which this symbol should be visible: Default – Visible in the public interface o...
NodeAddr< CodeNode * > Code
This is an optimization pass for GlobalISel generic memory operations.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
std::error_code make_error_code(BitcodeError E)
MDNode * upgradeInstructionLoopAttachment(MDNode &N)
Upgrade the loop attachment metadata node.
bool mayBeOldLoopAttachmentTag(StringRef Name)
Check whether a string looks like an old loop attachment tag.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
@ Ref
The access may reference the value stored in memory.
constexpr unsigned BitWidth
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
APInt readWideAPInt(ArrayRef< uint64_t > Vals, unsigned TypeBits)
MDNode * UpgradeTBAANode(MDNode &TBAANode)
If the given TBAA tag uses the scalar TBAA format, create a new node corresponding to the upgrade to ...
void consumeError(Error Err)
Consume a Error without doing anything.
Implement std::hash so that hash_code can be used in STL containers.
When advancing through a bitstream cursor, each advance can discover a few different kinds of entries...