69#define DEBUG_TYPE "bitcode-reader"
71STATISTIC(NumMDStringLoaded,
"Number of MDStrings loaded");
72STATISTIC(NumMDNodeTemporary,
"Number of MDNode::Temporary created");
73STATISTIC(NumMDRecordLoaded,
"Number of Metadata records loaded");
79 cl::desc(
"Import full type definitions for ThinLTO."));
83 cl::desc(
"Force disable the lazy-loading on-demand of metadata when "
84 "loading bitcode for importing."));
88static int64_t unrotateSign(
uint64_t U) {
return (U & 1) ? ~(U >> 1) : U >> 1; }
90class BitcodeReaderMetadataList {
117 unsigned RefsUpperBound;
120 BitcodeReaderMetadataList(
LLVMContext &
C,
size_t RefsUpperBound)
126 unsigned size()
const {
return MetadataPtrs.
size(); }
127 void resize(
unsigned N) { MetadataPtrs.
resize(
N); }
131 void pop_back() { MetadataPtrs.
pop_back(); }
132 bool empty()
const {
return MetadataPtrs.
empty(); }
134 Metadata *operator[](
unsigned i)
const {
136 return MetadataPtrs[i];
140 if (
I < MetadataPtrs.
size())
141 return MetadataPtrs[
I];
145 void shrinkTo(
unsigned N) {
146 assert(
N <=
size() &&
"Invalid shrinkTo request!");
148 assert(UnresolvedNodes.
empty() &&
"Unexpected unresolved node");
162 MDNode *getMDNodeFwdRefOrNull(
unsigned Idx);
164 void tryToResolveCycles();
166 int getNextFwdRef() {
184void BitcodeReaderMetadataList::assignValue(
Metadata *MD,
unsigned Idx) {
185 if (
auto *MDN = dyn_cast<MDNode>(MD))
186 if (!MDN->isResolved())
204 TempMDTuple PrevMD(cast<MDTuple>(OldMD.
get()));
205 PrevMD->replaceAllUsesWith(MD);
209Metadata *BitcodeReaderMetadataList::getMetadataFwdRef(
unsigned Idx) {
211 if (
Idx >= RefsUpperBound)
224 ++NumMDNodeTemporary;
226 MetadataPtrs[
Idx].reset(MD);
230Metadata *BitcodeReaderMetadataList::getMetadataIfResolved(
unsigned Idx) {
232 if (
auto *
N = dyn_cast_or_null<MDNode>(MD))
233 if (!
N->isResolved())
238MDNode *BitcodeReaderMetadataList::getMDNodeFwdRefOrNull(
unsigned Idx) {
239 return dyn_cast_or_null<MDNode>(getMetadataFwdRef(
Idx));
242void BitcodeReaderMetadataList::tryToResolveCycles() {
248 for (
const auto &
Ref : OldTypeRefs.FwdDecls)
249 OldTypeRefs.Final.insert(
Ref);
250 OldTypeRefs.FwdDecls.clear();
254 for (
const auto &Array : OldTypeRefs.Arrays)
255 Array.second->replaceAllUsesWith(resolveTypeRefArray(
Array.first.get()));
256 OldTypeRefs.Arrays.clear();
261 for (
const auto &
Ref : OldTypeRefs.Unknown) {
263 Ref.second->replaceAllUsesWith(CT);
265 Ref.second->replaceAllUsesWith(
Ref.first);
267 OldTypeRefs.Unknown.clear();
269 if (UnresolvedNodes.
empty())
274 for (
unsigned I : UnresolvedNodes) {
275 auto &MD = MetadataPtrs[
I];
276 auto *
N = dyn_cast_or_null<MDNode>(MD);
280 assert(!
N->isTemporary() &&
"Unexpected forward reference");
285 UnresolvedNodes.clear();
288void BitcodeReaderMetadataList::addTypeRef(
MDString &
UUID,
292 OldTypeRefs.FwdDecls.insert(std::make_pair(&
UUID, &CT));
294 OldTypeRefs.Final.insert(std::make_pair(&
UUID, &CT));
298 auto *
UUID = dyn_cast_or_null<MDString>(MaybeUUID);
302 if (
auto *CT = OldTypeRefs.Final.lookup(
UUID))
305 auto &
Ref = OldTypeRefs.Unknown[
UUID];
311Metadata *BitcodeReaderMetadataList::upgradeTypeRefArray(
Metadata *MaybeTuple) {
312 auto *Tuple = dyn_cast_or_null<MDTuple>(MaybeTuple);
313 if (!Tuple || Tuple->isDistinct())
317 if (!Tuple->isTemporary())
318 return resolveTypeRefArray(Tuple);
322 OldTypeRefs.Arrays.emplace_back(
323 std::piecewise_construct, std::forward_as_tuple(Tuple),
325 return OldTypeRefs.Arrays.back().second.get();
328Metadata *BitcodeReaderMetadataList::resolveTypeRefArray(
Metadata *MaybeTuple) {
329 auto *Tuple = dyn_cast_or_null<MDTuple>(MaybeTuple);
330 if (!Tuple || Tuple->isDistinct())
335 Ops.
reserve(Tuple->getNumOperands());
336 for (
Metadata *MD : Tuple->operands())
344class PlaceholderQueue {
347 std::deque<DistinctMDOperandPlaceholder> PHs;
350 ~PlaceholderQueue() {
352 "PlaceholderQueue hasn't been flushed before being destroyed");
354 bool empty()
const {
return PHs.empty(); }
356 void flush(BitcodeReaderMetadataList &MetadataList);
360 void getTemporaries(BitcodeReaderMetadataList &MetadataList,
362 for (
auto &PH : PHs) {
363 auto ID = PH.getID();
364 auto *MD = MetadataList.lookup(
ID);
369 auto *
N = dyn_cast_or_null<MDNode>(MD);
370 if (
N &&
N->isTemporary())
379 PHs.emplace_back(
ID);
383void PlaceholderQueue::flush(BitcodeReaderMetadataList &MetadataList) {
384 while (!PHs.empty()) {
385 auto *MD = MetadataList.lookup(PHs.front().getID());
386 assert(MD &&
"Flushing placeholder on unassigned MD");
388 if (
auto *MDN = dyn_cast<MDNode>(MD))
389 assert(MDN->isResolved() &&
390 "Flushing Placeholder while cycles aren't resolved");
392 PHs.front().replaceUseWith(MD);
400 return make_error<StringError>(
405 BitcodeReaderMetadataList MetadataList;
418 std::vector<StringRef> MDStringRef;
425 std::vector<uint64_t> GlobalMetadataBitPosIndex;
430 uint64_t GlobalDeclAttachmentPos = 0;
435 unsigned NumGlobalDeclAttachSkipped = 0;
436 unsigned NumGlobalDeclAttachParsed = 0;
449 void lazyLoadOneMetadata(
unsigned Idx, PlaceholderQueue &Placeholders);
453 std::vector<std::pair<DICompileUnit *, Metadata *>> CUSubprograms;
462 bool StripTBAA =
false;
463 bool HasSeenOldLoopTags =
false;
464 bool NeedUpgradeToDIGlobalVariableExpression =
false;
465 bool NeedDeclareExpressionUpgrade =
false;
471 bool IsImporting =
false;
474 PlaceholderQueue &Placeholders,
StringRef Blob,
475 unsigned &NextMetadataNo);
482 void resolveForwardRefsAndPlaceholders(PlaceholderQueue &Placeholders);
485 void upgradeCUSubprograms() {
486 for (
auto CU_SP : CUSubprograms)
487 if (
auto *SPs = dyn_cast_or_null<MDTuple>(CU_SP.second))
488 for (
auto &
Op : SPs->operands())
489 if (
auto *SP = dyn_cast_or_null<DISubprogram>(
Op))
490 SP->replaceUnit(CU_SP.first);
491 CUSubprograms.clear();
495 void upgradeCUVariables() {
496 if (!NeedUpgradeToDIGlobalVariableExpression)
501 for (
unsigned I = 0, E = CUNodes->getNumOperands();
I != E; ++
I) {
502 auto *
CU = cast<DICompileUnit>(CUNodes->getOperand(
I));
503 if (
auto *GVs = dyn_cast_or_null<MDTuple>(
CU->getRawGlobalVariables()))
504 for (
unsigned I = 0;
I < GVs->getNumOperands();
I++)
506 dyn_cast_or_null<DIGlobalVariable>(GVs->getOperand(
I))) {
509 GVs->replaceOperandWith(
I, DGVE);
514 for (
auto &GV : TheModule.
globals()) {
516 GV.getMetadata(LLVMContext::MD_dbg, MDs);
517 GV.eraseMetadata(LLVMContext::MD_dbg);
519 if (
auto *DGV = dyn_cast<DIGlobalVariable>(MD)) {
522 GV.addMetadata(LLVMContext::MD_dbg, *DGVE);
524 GV.addMetadata(LLVMContext::MD_dbg, *MD);
531 if (
auto *SP = ParentSubprogram[S]) {
537 while (S && !isa<DISubprogram>(S)) {
538 S = dyn_cast_or_null<DILocalScope>(S->
getScope());
543 ParentSubprogram[InitialScope] = llvm::dyn_cast_or_null<DISubprogram>(S);
545 return ParentSubprogram[InitialScope];
550 void upgradeCULocals() {
552 for (
MDNode *
N : CUNodes->operands()) {
553 auto *
CU = dyn_cast<DICompileUnit>(
N);
557 if (
CU->getRawImportedEntities()) {
560 for (
Metadata *
Op :
CU->getImportedEntities()->operands()) {
561 auto *IE = cast<DIImportedEntity>(
Op);
562 if (dyn_cast_or_null<DILocalScope>(IE->getScope())) {
563 EntitiesToRemove.
insert(IE);
567 if (!EntitiesToRemove.
empty()) {
570 for (
Metadata *
Op :
CU->getImportedEntities()->operands()) {
571 if (!EntitiesToRemove.
contains(cast<DIImportedEntity>(
Op))) {
577 std::map<DISubprogram *, SmallVector<Metadata *>> SPToEntities;
578 for (
auto *
I : EntitiesToRemove) {
579 auto *Entity = cast<DIImportedEntity>(
I);
580 if (
auto *SP = findEnclosingSubprogram(
581 cast<DILocalScope>(Entity->getScope()))) {
582 SPToEntities[SP].push_back(Entity);
587 for (
auto I = SPToEntities.begin();
I != SPToEntities.end(); ++
I) {
589 auto RetainedNodes = SP->getRetainedNodes();
591 RetainedNodes.end());
593 SP->replaceRetainedNodes(
MDNode::get(Context, MDs));
603 ParentSubprogram.
clear();
608 void upgradeDeclareExpressions(
Function &
F) {
609 if (!NeedDeclareExpressionUpgrade)
612 auto UpdateDeclareIfNeeded = [&](
auto *Declare) {
613 auto *DIExpr = Declare->getExpression();
614 if (!DIExpr || !DIExpr->startsWithDeref() ||
615 !isa_and_nonnull<Argument>(Declare->getAddress()))
618 Ops.
append(std::next(DIExpr->elements_begin()), DIExpr->elements_end());
625 if (DVR.isDbgDeclare())
626 UpdateDeclareIfNeeded(&DVR);
628 if (
auto *DDI = dyn_cast<DbgDeclareInst>(&
I))
629 UpdateDeclareIfNeeded(DDI);
637 auto N = Expr.
size();
638 switch (FromVersion) {
640 return error(
"Invalid record");
642 if (
N >= 3 && Expr[
N - 3] == dwarf::DW_OP_bit_piece)
647 if (
N && Expr[0] == dwarf::DW_OP_deref) {
649 if (Expr.
size() >= 3 &&
653 *std::prev(
End) = dwarf::DW_OP_deref;
655 NeedDeclareExpressionUpgrade =
true;
661 while (!SubExpr.empty()) {
666 switch (SubExpr.front()) {
670 case dwarf::DW_OP_constu:
671 case dwarf::DW_OP_minus:
672 case dwarf::DW_OP_plus:
682 HistoricSize = std::min(SubExpr.size(), HistoricSize);
685 switch (SubExpr.front()) {
686 case dwarf::DW_OP_plus:
687 Buffer.
push_back(dwarf::DW_OP_plus_uconst);
688 Buffer.
append(Args.begin(), Args.end());
690 case dwarf::DW_OP_minus:
692 Buffer.
append(Args.begin(), Args.end());
697 Buffer.
append(Args.begin(), Args.end());
702 SubExpr = SubExpr.slice(HistoricSize);
715 void upgradeDebugInfo(
bool ModuleLevel) {
716 upgradeCUSubprograms();
717 upgradeCUVariables();
728 : MetadataList(TheModule.getContext(), Stream.SizeInBytes()),
729 ValueList(ValueList), Stream(Stream), Context(TheModule.getContext()),
730 TheModule(TheModule), Callbacks(
std::
move(Callbacks)),
731 IsImporting(IsImporting) {}
735 bool hasFwdRefs()
const {
return MetadataList.hasFwdRefs(); }
738 if (
ID < MDStringRef.size())
739 return lazyLoadOneMDString(
ID);
740 if (
auto *MD = MetadataList.lookup(
ID))
744 if (
ID < (MDStringRef.size() + GlobalMetadataBitPosIndex.size())) {
745 PlaceholderQueue Placeholders;
746 lazyLoadOneMetadata(
ID, Placeholders);
747 resolveForwardRefsAndPlaceholders(Placeholders);
748 return MetadataList.lookup(
ID);
750 return MetadataList.getMetadataFwdRef(
ID);
754 return FunctionsWithSPs.
lookup(
F);
767 unsigned size()
const {
return MetadataList.size(); }
773MetadataLoader::MetadataLoaderImpl::lazyLoadModuleMetadataBlock() {
774 IndexCursor = Stream;
776 GlobalDeclAttachmentPos = 0;
787 switch (Entry.Kind) {
790 return error(
"Malformed block");
805 return std::move(Err);
812 return MaybeRecord.takeError();
813 unsigned NumStrings =
Record[0];
814 MDStringRef.reserve(NumStrings);
815 auto IndexNextMDString = [&](
StringRef Str) {
816 MDStringRef.push_back(Str);
818 if (
auto Err = parseMetadataStrings(
Record, Blob, IndexNextMDString))
819 return std::move(Err);
826 return std::move(Err);
832 return MaybeRecord.takeError();
834 return error(
"Invalid record");
838 return std::move(Err);
846 "Corrupted bitcode: Expected `Record` when trying to find the "
852 "Corrupted bitcode: Expected `METADATA_INDEX` when trying to "
853 "find the Metadata index");
855 return MaybeCode.takeError();
857 auto CurrentValue = BeginPos;
858 GlobalMetadataBitPosIndex.reserve(
Record.size());
859 for (
auto &Elt :
Record) {
861 GlobalMetadataBitPosIndex.push_back(CurrentValue);
868 return error(
"Corrupted Metadata block");
872 return std::move(Err);
878 Code = MaybeCode.get();
881 return MaybeCode.takeError();
886 Code = MaybeCode.get();
888 return MaybeCode.takeError();
897 return MaybeNextBitCode.takeError();
902 for (
unsigned i = 0; i !=
Size; ++i) {
907 MDNode *MD = MetadataList.getMDNodeFwdRefOrNull(
Record[i]);
908 assert(MD &&
"Invalid metadata: expect fwd ref to MDNode");
914 if (!GlobalDeclAttachmentPos)
915 GlobalDeclAttachmentPos = SavedPos;
917 NumGlobalDeclAttachSkipped++;
961 GlobalMetadataBitPosIndex.clear();
975Expected<bool> MetadataLoader::MetadataLoaderImpl::loadGlobalDeclAttachments() {
977 if (!GlobalDeclAttachmentPos)
986 return std::move(Err);
995 switch (
Entry.Kind) {
998 return error(
"Malformed block");
1001 assert(NumGlobalDeclAttachSkipped == NumGlobalDeclAttachParsed);
1013 assert(NumGlobalDeclAttachSkipped == NumGlobalDeclAttachParsed);
1017 NumGlobalDeclAttachParsed++;
1022 return std::move(Err);
1028 return MaybeRecord.takeError();
1029 if (
Record.size() % 2 == 0)
1030 return error(
"Invalid record");
1031 unsigned ValueID =
Record[0];
1032 if (ValueID >= ValueList.size())
1033 return error(
"Invalid record");
1034 if (
auto *GO = dyn_cast<GlobalObject>(ValueList[ValueID])) {
1039 if (
Error Err = parseGlobalObjectAttachment(
1041 return std::move(Err);
1043 return std::move(Err);
1048void MetadataLoader::MetadataLoaderImpl::callMDTypeCallback(
Metadata **Val,
1050 if (Callbacks.MDType) {
1051 (*Callbacks.MDType)(Val,
TypeID, Callbacks.GetTypeByID,
1052 Callbacks.GetContainedTypeID);
1059 if (!ModuleLevel && MetadataList.hasFwdRefs())
1060 return error(
"Invalid metadata: fwd refs into function blocks");
1064 auto EntryPos = Stream.GetCurrentBitNo();
1070 PlaceholderQueue Placeholders;
1074 if (ModuleLevel && IsImporting && MetadataList.empty() &&
1076 auto SuccessOrErr = lazyLoadModuleMetadataBlock();
1078 return SuccessOrErr.takeError();
1079 if (SuccessOrErr.get()) {
1082 MetadataList.resize(MDStringRef.size() +
1083 GlobalMetadataBitPosIndex.size());
1088 SuccessOrErr = loadGlobalDeclAttachments();
1090 return SuccessOrErr.takeError();
1091 assert(SuccessOrErr.get());
1095 resolveForwardRefsAndPlaceholders(Placeholders);
1096 upgradeDebugInfo(ModuleLevel);
1099 Stream.ReadBlockEnd();
1100 if (
Error Err = IndexCursor.JumpToBit(EntryPos))
1102 if (
Error Err = Stream.SkipBlock()) {
1113 unsigned NextMetadataNo = MetadataList.size();
1118 if (
Error E = Stream.advanceSkippingSubblocks().moveInto(Entry))
1121 switch (Entry.Kind) {
1124 return error(
"Malformed block");
1126 resolveForwardRefsAndPlaceholders(Placeholders);
1127 upgradeDebugInfo(ModuleLevel);
1137 ++NumMDRecordLoaded;
1139 Stream.readRecord(Entry.ID,
Record, &Blob)) {
1140 if (
Error Err = parseOneMetadata(
Record, MaybeCode.
get(), Placeholders,
1141 Blob, NextMetadataNo))
1148MDString *MetadataLoader::MetadataLoaderImpl::lazyLoadOneMDString(
unsigned ID) {
1149 ++NumMDStringLoaded;
1151 return cast<MDString>(MD);
1153 MetadataList.assignValue(MDS,
ID);
1157void MetadataLoader::MetadataLoaderImpl::lazyLoadOneMetadata(
1158 unsigned ID, PlaceholderQueue &Placeholders) {
1159 assert(
ID < (MDStringRef.size()) + GlobalMetadataBitPosIndex.size());
1160 assert(
ID >= MDStringRef.size() &&
"Unexpected lazy-loading of MDString");
1162 if (
auto *MD = MetadataList.lookup(
ID)) {
1163 auto *
N = cast<MDNode>(MD);
1164 if (!
N->isTemporary())
1169 if (
Error Err = IndexCursor.JumpToBit(
1170 GlobalMetadataBitPosIndex[
ID - MDStringRef.size()]))
1174 if (
Error E = IndexCursor.advanceSkippingSubblocks().moveInto(Entry))
1178 ++NumMDRecordLoaded;
1180 IndexCursor.readRecord(Entry.ID,
Record, &Blob)) {
1182 parseOneMetadata(
Record, MaybeCode.
get(), Placeholders, Blob,
ID))
1192void MetadataLoader::MetadataLoaderImpl::resolveForwardRefsAndPlaceholders(
1193 PlaceholderQueue &Placeholders) {
1197 Placeholders.getTemporaries(MetadataList, Temporaries);
1200 if (Temporaries.
empty() && !MetadataList.hasFwdRefs())
1205 for (
auto ID : Temporaries)
1206 lazyLoadOneMetadata(
ID, Placeholders);
1207 Temporaries.clear();
1211 while (MetadataList.hasFwdRefs())
1212 lazyLoadOneMetadata(MetadataList.getNextFwdRef(), Placeholders);
1217 MetadataList.tryToResolveCycles();
1221 Placeholders.flush(MetadataList);
1225 Type *Ty,
unsigned TyID) {
1237 if (
Idx < ValueList.
size() && ValueList[
Idx] &&
1238 ValueList[
Idx]->getType() == Ty)
1244Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
1246 PlaceholderQueue &Placeholders,
StringRef Blob,
unsigned &NextMetadataNo) {
1248 bool IsDistinct =
false;
1249 auto getMD = [&](
unsigned ID) ->
Metadata * {
1250 if (
ID < MDStringRef.size())
1251 return lazyLoadOneMDString(
ID);
1253 if (
auto *MD = MetadataList.lookup(
ID))
1257 if (
ID < (MDStringRef.size() + GlobalMetadataBitPosIndex.size())) {
1261 MetadataList.getMetadataFwdRef(NextMetadataNo);
1262 lazyLoadOneMetadata(
ID, Placeholders);
1263 return MetadataList.lookup(
ID);
1266 return MetadataList.getMetadataFwdRef(
ID);
1268 if (
auto *MD = MetadataList.getMetadataIfResolved(
ID))
1270 return &Placeholders.getPlaceholderOp(
ID);
1272 auto getMDOrNull = [&](
unsigned ID) ->
Metadata * {
1274 return getMD(
ID - 1);
1277 auto getMDOrNullWithoutPlaceholders = [&](
unsigned ID) ->
Metadata * {
1279 return MetadataList.getMetadataFwdRef(
ID - 1);
1282 auto getMDString = [&](
unsigned ID) ->
MDString * {
1285 auto MDS = getMDOrNull(
ID);
1286 return cast_or_null<MDString>(MDS);
1290 auto getDITypeRefOrNull = [&](
unsigned ID) {
1291 return MetadataList.upgradeTypeRef(getMDOrNull(
ID));
1294#define GET_OR_DISTINCT(CLASS, ARGS) \
1295 (IsDistinct ? CLASS::getDistinct ARGS : CLASS::get ARGS)
1304 if (
Error E = Stream.ReadCode().moveInto(Code))
1307 ++NumMDRecordLoaded;
1310 return error(
"METADATA_NAME not followed by METADATA_NAMED_NODE");
1312 return MaybeNextBitCode.takeError();
1317 for (
unsigned i = 0; i !=
Size; ++i) {
1318 MDNode *MD = MetadataList.getMDNodeFwdRefOrNull(
Record[i]);
1320 return error(
"Invalid named metadata: expect fwd ref to MDNode");
1329 if (
Record.size() % 2 == 1)
1330 return error(
"Invalid record");
1334 auto dropRecord = [&] {
1335 MetadataList.assignValue(
MDNode::get(Context, std::nullopt),
1339 if (
Record.size() != 2) {
1344 unsigned TyID =
Record[0];
1345 Type *Ty = Callbacks.GetTypeByID(TyID);
1351 Value *
V = ValueList.getValueFwdRef(
Record[1], Ty, TyID,
1354 return error(
"Invalid value reference from old fn metadata");
1362 if (
Record.size() % 2 == 1)
1363 return error(
"Invalid record");
1367 for (
unsigned i = 0; i !=
Size; i += 2) {
1368 unsigned TyID =
Record[i];
1369 Type *Ty = Callbacks.GetTypeByID(TyID);
1371 return error(
"Invalid record");
1377 return error(
"Invalid value reference from old metadata");
1379 assert(isa<ConstantAsMetadata>(MD) &&
1380 "Expected non-function-local metadata");
1381 callMDTypeCallback(&MD, TyID);
1386 MetadataList.assignValue(
MDNode::get(Context, Elts), NextMetadataNo);
1392 return error(
"Invalid record");
1394 unsigned TyID =
Record[0];
1395 Type *Ty = Callbacks.GetTypeByID(TyID);
1397 return error(
"Invalid record");
1401 return error(
"Invalid value reference from metadata");
1404 callMDTypeCallback(&MD, TyID);
1405 MetadataList.assignValue(MD, NextMetadataNo);
1425 return error(
"Invalid record");
1429 unsigned Column =
Record[2];
1433 MetadataList.assignValue(
1442 return error(
"Invalid record");
1449 return error(
"Invalid record");
1451 auto *Header = getMDString(
Record[3]);
1453 for (
unsigned I = 4, E =
Record.size();
I != E; ++
I)
1455 MetadataList.assignValue(
1471 switch (
Record[0] >> 1) {
1478 unrotateSign(
Record[2])));
1486 return error(
"Invalid record: Unsupported version of DISubrange");
1489 MetadataList.assignValue(Val, NextMetadataNo);
1490 IsDistinct =
Record[0] & 1;
1497 (Context, getMDOrNull(
Record[1]),
1499 getMDOrNull(
Record[4])));
1501 MetadataList.assignValue(Val, NextMetadataNo);
1502 IsDistinct =
Record[0] & 1;
1508 return error(
"Invalid record");
1510 IsDistinct =
Record[0] & 1;
1511 bool IsUnsigned =
Record[0] & 2;
1512 bool IsBigInt =
Record[0] & 4;
1517 const size_t NumWords =
Record.size() - 3;
1522 MetadataList.assignValue(
1524 (Context,
Value, IsUnsigned, getMDString(
Record[2]))),
1531 return error(
"Invalid record");
1538 MetadataList.assignValue(
1548 return error(
"Invalid record");
1551 bool SizeIs8 =
Record.size() == 8;
1554 Metadata *StringLocationExp = SizeIs8 ? nullptr : getMDOrNull(
Record[5]);
1555 unsigned Offset = SizeIs8 ? 5 : 6;
1556 MetadataList.assignValue(
1568 return error(
"Invalid record");
1572 std::optional<unsigned> DWARFAddressSpace;
1574 DWARFAddressSpace =
Record[12] - 1;
1577 std::optional<DIDerivedType::PtrAuthData> PtrAuthData;
1582 if (
Record.size() > 14) {
1586 PtrAuthData.emplace(
Record[14]);
1591 MetadataList.assignValue(
1595 getDITypeRefOrNull(
Record[5]),
1597 Record[9], DWARFAddressSpace, PtrAuthData, Flags,
1605 return error(
"Invalid record");
1609 IsDistinct =
Record[0] & 0x1;
1610 bool IsNotUsedInTypeRef =
Record[0] >= 2;
1619 return error(
"Alignment value is too large");
1624 unsigned RuntimeLang =
Record[12];
1626 Metadata *TemplateParams =
nullptr;
1649 (
Tag == dwarf::DW_TAG_enumeration_type ||
1650 Tag == dwarf::DW_TAG_class_type ||
1651 Tag == dwarf::DW_TAG_structure_type ||
1652 Tag == dwarf::DW_TAG_union_type)) {
1660 TemplateParams = getMDOrNull(
Record[14]);
1663 OffsetInBits =
Record[9];
1665 VTableHolder = getDITypeRefOrNull(
Record[13]);
1666 TemplateParams = getMDOrNull(
Record[14]);
1670 DataLocation = getMDOrNull(
Record[17]);
1671 if (
Record.size() > 19) {
1672 Associated = getMDOrNull(
Record[18]);
1673 Allocated = getMDOrNull(
Record[19]);
1675 if (
Record.size() > 20) {
1676 Rank = getMDOrNull(
Record[20]);
1678 if (
Record.size() > 21) {
1686 SizeInBits, AlignInBits, OffsetInBits, Flags, Elements, RuntimeLang,
1687 VTableHolder, TemplateParams, Discriminator, DataLocation, Associated,
1694 SizeInBits, AlignInBits, OffsetInBits, Flags,
1695 Elements, RuntimeLang, VTableHolder, TemplateParams,
1696 Identifier, Discriminator, DataLocation, Associated,
1698 if (!IsNotUsedInTypeRef && Identifier)
1699 MetadataList.addTypeRef(*Identifier, *cast<DICompositeType>(CT));
1701 MetadataList.assignValue(CT, NextMetadataNo);
1707 return error(
"Invalid record");
1708 bool IsOldTypeRefArray =
Record[0] < 2;
1711 IsDistinct =
Record[0] & 0x1;
1715 Types = MetadataList.upgradeTypeRefArray(Types);
1717 MetadataList.assignValue(
1726 return error(
"Invalid record");
1730 MetadataList.assignValue(
1733 (Context,
Record.size() >= 8 ? getMDOrNull(
Record[1]) :
nullptr,
1746 return error(
"Invalid record");
1749 std::optional<DIFile::ChecksumInfo<MDString *>> Checksum;
1758 MetadataList.assignValue(
1760 (Context, getMDString(
Record[1]),
1761 getMDString(
Record[2]), Checksum,
1762 Record.size() > 5 ? getMDString(
Record[5]) :
nullptr)),
1769 return error(
"Invalid record");
1779 Record.size() <= 15 ?
nullptr : getMDOrNull(
Record[15]),
1785 Record.size() <= 20 ?
nullptr : getMDString(
Record[20]),
1786 Record.size() <= 21 ?
nullptr : getMDString(
Record[21]));
1788 MetadataList.assignValue(
CU, NextMetadataNo);
1793 CUSubprograms.push_back({
CU, SPs});
1798 return error(
"Invalid record");
1800 bool HasSPFlags =
Record[0] & 4;
1813 const unsigned DIFlagMainSubprogram = 1 << 21;
1814 bool HasOldMainSubprogramFlag =
Flags & DIFlagMainSubprogram;
1815 if (HasOldMainSubprogramFlag)
1819 Flags &= ~static_cast<DINode::DIFlags>(DIFlagMainSubprogram);
1821 if (HasOldMainSubprogramFlag && HasSPFlags)
1822 SPFlags |= DISubprogram::SPFlagMainSubprogram;
1823 else if (!HasSPFlags)
1827 HasOldMainSubprogramFlag);
1830 IsDistinct = (
Record[0] & 1) || (SPFlags & DISubprogram::SPFlagDefinition);
1836 bool HasUnit =
Record[0] & 2;
1837 if (!HasSPFlags && HasUnit &&
Record.size() < 19)
1838 return error(
"Invalid record");
1839 if (HasSPFlags && !HasUnit)
1840 return error(
"Invalid record");
1843 bool HasThisAdj =
true;
1844 bool HasThrownTypes =
true;
1845 bool HasAnnotations =
false;
1846 bool HasTargetFuncName =
false;
1847 unsigned OffsetA = 0;
1848 unsigned OffsetB = 0;
1852 if (
Record.size() >= 19) {
1856 HasThisAdj =
Record.size() >= 20;
1857 HasThrownTypes =
Record.size() >= 21;
1859 HasAnnotations =
Record.size() >= 19;
1860 HasTargetFuncName =
Record.size() >= 20;
1866 getDITypeRefOrNull(
Record[1]),
1873 getDITypeRefOrNull(
Record[8 + OffsetA]),
1875 HasThisAdj ?
Record[16 + OffsetB] : 0,
1878 HasUnit ? CUorFn :
nullptr,
1879 getMDOrNull(
Record[13 + OffsetB]),
1880 getMDOrNull(
Record[14 + OffsetB]),
1881 getMDOrNull(
Record[15 + OffsetB]),
1882 HasThrownTypes ? getMDOrNull(
Record[17 + OffsetB])
1884 HasAnnotations ? getMDOrNull(
Record[18 + OffsetB])
1886 HasTargetFuncName ? getMDString(
Record[19 + OffsetB])
1889 MetadataList.assignValue(SP, NextMetadataNo);
1894 if (
auto *CMD = dyn_cast_or_null<ConstantAsMetadata>(CUorFn))
1895 if (
auto *
F = dyn_cast<Function>(CMD->getValue())) {
1896 if (
F->isMaterializable())
1899 FunctionsWithSPs[
F] = SP;
1900 else if (!
F->empty())
1901 F->setSubprogram(SP);
1908 return error(
"Invalid record");
1911 MetadataList.assignValue(
1913 (Context, getMDOrNull(
Record[1]),
1921 return error(
"Invalid record");
1924 MetadataList.assignValue(
1926 (Context, getMDOrNull(
Record[1]),
1933 IsDistinct =
Record[0] & 1;
1934 MetadataList.assignValue(
1936 (Context, getMDOrNull(
Record[1]),
1948 else if (
Record.size() == 5)
1951 return error(
"Invalid record");
1953 IsDistinct =
Record[0] & 1;
1954 bool ExportSymbols =
Record[0] & 2;
1955 MetadataList.assignValue(
1957 (Context, getMDOrNull(
Record[1]),
Name, ExportSymbols)),
1964 return error(
"Invalid record");
1967 MetadataList.assignValue(
1970 getMDString(
Record[4]))),
1977 return error(
"Invalid record");
1980 MetadataList.assignValue(
1983 getMDOrNull(
Record[4]))),
1990 return error(
"Invalid record");
1993 MetadataList.assignValue(
1995 (Context, getMDString(
Record[1]),
1996 getDITypeRefOrNull(
Record[2]),
1998 : getMDOrNull(
false))),
2005 return error(
"Invalid record");
2009 MetadataList.assignValue(
2013 getDITypeRefOrNull(
Record[3]),
2014 (
Record.size() == 6) ? getMDOrNull(
Record[4]) : getMDOrNull(
false),
2016 : getMDOrNull(
Record[4]))),
2023 return error(
"Invalid record");
2025 IsDistinct =
Record[0] & 1;
2033 MetadataList.assignValue(
2035 (Context, getMDOrNull(
Record[1]),
2047 MetadataList.assignValue(
2050 (Context, getMDOrNull(
Record[1]), getMDString(
Record[2]),
2053 getMDOrNull(
Record[10]),
nullptr,
Record[11],
nullptr)),
2060 NeedUpgradeToDIGlobalVariableExpression =
true;
2063 if (
Record.size() > 11) {
2065 return error(
"Alignment value is too large");
2066 AlignInBits =
Record[11];
2069 if (
auto *CMD = dyn_cast_or_null<ConstantAsMetadata>(Expr)) {
2070 if (
auto *GV = dyn_cast<GlobalVariable>(CMD->getValue())) {
2073 }
else if (
auto *CI = dyn_cast<ConstantInt>(CMD->getValue())) {
2075 {dwarf::DW_OP_constu, CI->getZExtValue(),
2076 dwarf::DW_OP_stack_value});
2083 (Context, getMDOrNull(
Record[1]), getMDString(
Record[2]),
2086 getMDOrNull(
Record[10]),
nullptr, AlignInBits,
nullptr));
2096 MetadataList.assignValue(
MDNode, NextMetadataNo);
2099 return error(
"Invalid record");
2105 return error(
"Invalid DIAssignID record.");
2107 IsDistinct =
Record[0] & 1;
2109 return error(
"Invalid DIAssignID record. Must be distinct");
2118 return error(
"Invalid record");
2120 IsDistinct =
Record[0] & 1;
2121 bool HasAlignment =
Record[0] & 2;
2125 bool HasTag = !HasAlignment &&
Record.size() > 8;
2131 return error(
"Alignment value is too large");
2137 MetadataList.assignValue(
2139 (Context, getMDOrNull(
Record[1 + HasTag]),
2140 getMDString(
Record[2 + HasTag]),
2142 getDITypeRefOrNull(
Record[5 + HasTag]),
2150 return error(
"Invalid record");
2152 IsDistinct =
Record[0] & 1;
2153 MetadataList.assignValue(
2163 return error(
"Invalid record");
2165 IsDistinct =
Record[0] & 1;
2170 if (
Error Err = upgradeDIExpression(
Version, Elts, Buffer))
2180 return error(
"Invalid record");
2186 MetadataList.assignValue(
2188 (Context, getMDOrNull(
Record[1]), Expr)),
2195 return error(
"Invalid record");
2198 MetadataList.assignValue(
2200 (Context, getMDString(
Record[1]),
2210 return error(
"Invalid DIImportedEntity record");
2213 bool HasFile = (
Record.size() >= 7);
2214 bool HasElements = (
Record.size() >= 8);
2215 MetadataList.assignValue(
2218 getDITypeRefOrNull(
Record[3]),
2219 HasFile ? getMDOrNull(
Record[6]) :
nullptr,
2221 HasElements ? getMDOrNull(
Record[7]) :
nullptr)),
2231 ++NumMDStringLoaded;
2233 MetadataList.assignValue(MD, NextMetadataNo);
2238 auto CreateNextMDString = [&](
StringRef Str) {
2239 ++NumMDStringLoaded;
2240 MetadataList.assignValue(
MDString::get(Context, Str), NextMetadataNo);
2243 if (
Error Err = parseMetadataStrings(
Record, Blob, CreateNextMDString))
2248 if (
Record.size() % 2 == 0)
2249 return error(
"Invalid record");
2250 unsigned ValueID =
Record[0];
2251 if (ValueID >= ValueList.size())
2252 return error(
"Invalid record");
2253 if (
auto *GO = dyn_cast<GlobalObject>(ValueList[ValueID]))
2254 if (
Error Err = parseGlobalObjectAttachment(
2271 if (isa<MDNode>(MD) && cast<MDNode>(MD)->isTemporary())
2273 "Invalid record: DIArgList should not contain forward refs");
2274 if (!isa<ValueAsMetadata>(MD))
2275 return error(
"Invalid record");
2276 Elts.
push_back(cast<ValueAsMetadata>(MD));
2279 MetadataList.assignValue(
DIArgList::get(Context, Elts), NextMetadataNo);
2285#undef GET_OR_DISTINCT
2288Error MetadataLoader::MetadataLoaderImpl::parseMetadataStrings(
2295 return error(
"Invalid record: metadata strings layout");
2297 unsigned NumStrings =
Record[0];
2298 unsigned StringsOffset =
Record[1];
2300 return error(
"Invalid record: metadata strings with no strings");
2301 if (StringsOffset > Blob.
size())
2302 return error(
"Invalid record: metadata strings corrupt offset");
2309 if (
R.AtEndOfStream())
2310 return error(
"Invalid record: metadata strings bad length");
2315 if (Strings.size() <
Size)
2316 return error(
"Invalid record: metadata strings truncated chars");
2318 CallBack(Strings.slice(0,
Size));
2319 Strings = Strings.drop_front(
Size);
2320 }
while (--NumStrings);
2325Error MetadataLoader::MetadataLoaderImpl::parseGlobalObjectAttachment(
2328 for (
unsigned I = 0, E =
Record.size();
I != E;
I += 2) {
2329 auto K = MDKindMap.find(
Record[
I]);
2330 if (K == MDKindMap.end())
2331 return error(
"Invalid ID");
2335 return error(
"Invalid metadata attachment: expect fwd ref to MDNode");
2348 PlaceholderQueue Placeholders;
2352 if (
Error E = Stream.advanceSkippingSubblocks().moveInto(Entry))
2355 switch (Entry.Kind) {
2358 return error(
"Malformed block");
2360 resolveForwardRefsAndPlaceholders(Placeholders);
2369 ++NumMDRecordLoaded;
2373 switch (MaybeRecord.
get()) {
2377 unsigned RecordLength =
Record.size();
2379 return error(
"Invalid record");
2380 if (RecordLength % 2 == 0) {
2382 if (
Error Err = parseGlobalObjectAttachment(
F,
Record))
2389 for (
unsigned i = 1; i != RecordLength; i = i + 2) {
2390 unsigned Kind =
Record[i];
2392 if (
I == MDKindMap.end())
2393 return error(
"Invalid ID");
2394 if (
I->second == LLVMContext::MD_tbaa && StripTBAA)
2398 if (
Idx < (MDStringRef.size() + GlobalMetadataBitPosIndex.size()) &&
2399 !MetadataList.lookup(
Idx)) {
2402 lazyLoadOneMetadata(
Idx, Placeholders);
2403 resolveForwardRefsAndPlaceholders(Placeholders);
2406 Metadata *Node = MetadataList.getMetadataFwdRef(
Idx);
2407 if (isa<LocalAsMetadata>(Node))
2411 MDNode *MD = dyn_cast_or_null<MDNode>(Node);
2413 return error(
"Invalid metadata attachment");
2415 if (HasSeenOldLoopTags &&
I->second == LLVMContext::MD_loop)
2418 if (
I->second == LLVMContext::MD_tbaa) {
2431Error MetadataLoader::MetadataLoaderImpl::parseMetadataKindRecord(
2434 return error(
"Invalid record");
2436 unsigned Kind =
Record[0];
2439 unsigned NewKind = TheModule.getMDKindID(
Name.str());
2440 if (!MDKindMap.insert(std::make_pair(Kind, NewKind)).second)
2441 return error(
"Conflicting METADATA_KIND records");
2455 if (
Error E = Stream.advanceSkippingSubblocks().moveInto(Entry))
2458 switch (Entry.Kind) {
2461 return error(
"Malformed block");
2471 ++NumMDRecordLoaded;
2475 switch (MaybeCode.
get()) {
2488 Pimpl = std::move(
RHS.Pimpl);
2500 Stream, TheModule, ValueList,
std::
move(Callbacks), IsImporting)) {}
2502Error MetadataLoader::parseMetadata(
bool ModuleLevel) {
2503 return Pimpl->parseMetadata(ModuleLevel);
2511 return Pimpl->getMetadataFwdRefOrLoad(
Idx);
2515 return Pimpl->lookupSubprogramForFunction(
F);
2520 return Pimpl->parseMetadataAttachment(
F, InstructionList);
2524 return Pimpl->parseMetadataKinds();
2528 return Pimpl->setStripTBAA(StripTBAA);
2537 return Pimpl->upgradeDebugIntrinsics(
F);
This file implements a class to represent arbitrary precision integral constant values and operations...
#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.
Value * getValueFwdRef(unsigned Idx, Type *Ty, unsigned TyID, BasicBlock *ConstExprInsertBB)
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)
@ AF_DontPopBlockAtEnd
If this flag is used, the advance() method does not automatically pop the block scope when the end of...
Expected< unsigned > skipRecord(unsigned AbbrevID)
Read the current record and discard it, returning the code for the record.
Expected< unsigned > ReadCode()
static DIArgList * get(LLVMContext &Context, ArrayRef< ValueAsMetadata * > Args)
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.
Record of a variable value-assignment, aka a non instruction representation of the dbg....
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(StringRef 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.
bool starts_with(StringRef Prefix) const
Check if this string starts with the given Prefix.
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.
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'.
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
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.
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 ...
static auto filterDbgVars(iterator_range< simple_ilist< DbgRecord >::iterator > R)
Filter the DbgRecord range to DbgVariableRecord types only and downcast.
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...