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); }
129 void clear() { MetadataPtrs.
clear(); }
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());
539 if (!Visited.
insert(S).second)
542 ParentSubprogram[InitialScope] = llvm::dyn_cast_or_null<DISubprogram>(S);
544 return ParentSubprogram[InitialScope];
549 void upgradeCULocals() {
551 for (
MDNode *
N : CUNodes->operands()) {
552 auto *
CU = dyn_cast<DICompileUnit>(
N);
556 if (
CU->getRawImportedEntities()) {
559 for (
Metadata *
Op :
CU->getImportedEntities()->operands()) {
560 auto *IE = cast<DIImportedEntity>(
Op);
561 if (dyn_cast_or_null<DILocalScope>(IE->getScope())) {
562 EntitiesToRemove.
insert(IE);
566 if (!EntitiesToRemove.
empty()) {
569 for (
Metadata *
Op :
CU->getImportedEntities()->operands()) {
570 if (!EntitiesToRemove.
contains(cast<DIImportedEntity>(
Op))) {
576 std::map<DISubprogram *, SmallVector<Metadata *>> SPToEntities;
577 for (
auto *
I : EntitiesToRemove) {
578 auto *Entity = cast<DIImportedEntity>(
I);
579 if (
auto *SP = findEnclosingSubprogram(
580 cast<DILocalScope>(Entity->getScope()))) {
581 SPToEntities[SP].push_back(Entity);
586 for (
auto I = SPToEntities.begin();
I != SPToEntities.end(); ++
I) {
588 auto RetainedNodes = SP->getRetainedNodes();
590 RetainedNodes.end());
592 SP->replaceRetainedNodes(
MDNode::get(Context, MDs));
602 ParentSubprogram.
clear();
607 void upgradeDeclareExpressions(
Function &
F) {
608 if (!NeedDeclareExpressionUpgrade)
611 auto UpdateDeclareIfNeeded = [&](
auto *Declare) {
612 auto *DIExpr = Declare->getExpression();
613 if (!DIExpr || !DIExpr->startsWithDeref() ||
614 !isa_and_nonnull<Argument>(Declare->getAddress()))
617 Ops.
append(std::next(DIExpr->elements_begin()), DIExpr->elements_end());
624 if (DVR.isDbgDeclare())
625 UpdateDeclareIfNeeded(&DVR);
627 if (
auto *DDI = dyn_cast<DbgDeclareInst>(&
I))
628 UpdateDeclareIfNeeded(DDI);
636 auto N = Expr.
size();
637 switch (FromVersion) {
639 return error(
"Invalid record");
641 if (
N >= 3 && Expr[
N - 3] == dwarf::DW_OP_bit_piece)
646 if (
N && Expr[0] == dwarf::DW_OP_deref) {
648 if (Expr.
size() >= 3 &&
652 *std::prev(
End) = dwarf::DW_OP_deref;
654 NeedDeclareExpressionUpgrade =
true;
660 while (!SubExpr.empty()) {
665 switch (SubExpr.front()) {
669 case dwarf::DW_OP_constu:
670 case dwarf::DW_OP_minus:
671 case dwarf::DW_OP_plus:
681 HistoricSize = std::min(SubExpr.size(), HistoricSize);
684 switch (SubExpr.front()) {
685 case dwarf::DW_OP_plus:
686 Buffer.
push_back(dwarf::DW_OP_plus_uconst);
687 Buffer.
append(Args.begin(), Args.end());
689 case dwarf::DW_OP_minus:
691 Buffer.
append(Args.begin(), Args.end());
696 Buffer.
append(Args.begin(), Args.end());
701 SubExpr = SubExpr.slice(HistoricSize);
714 void upgradeDebugInfo(
bool ModuleLevel) {
715 upgradeCUSubprograms();
716 upgradeCUVariables();
727 : MetadataList(TheModule.getContext(), Stream.SizeInBytes()),
728 ValueList(ValueList), Stream(Stream), Context(TheModule.getContext()),
729 TheModule(TheModule), Callbacks(
std::
move(Callbacks)),
730 IsImporting(IsImporting) {}
734 bool hasFwdRefs()
const {
return MetadataList.hasFwdRefs(); }
737 if (
ID < MDStringRef.size())
738 return lazyLoadOneMDString(
ID);
739 if (
auto *MD = MetadataList.lookup(
ID))
743 if (
ID < (MDStringRef.size() + GlobalMetadataBitPosIndex.size())) {
744 PlaceholderQueue Placeholders;
745 lazyLoadOneMetadata(
ID, Placeholders);
746 resolveForwardRefsAndPlaceholders(Placeholders);
747 return MetadataList.lookup(
ID);
749 return MetadataList.getMetadataFwdRef(
ID);
753 return FunctionsWithSPs.
lookup(
F);
766 unsigned size()
const {
return MetadataList.size(); }
772MetadataLoader::MetadataLoaderImpl::lazyLoadModuleMetadataBlock() {
773 IndexCursor = Stream;
775 GlobalDeclAttachmentPos = 0;
786 switch (Entry.Kind) {
789 return error(
"Malformed block");
804 return std::move(Err);
811 return MaybeRecord.takeError();
812 unsigned NumStrings =
Record[0];
813 MDStringRef.reserve(NumStrings);
814 auto IndexNextMDString = [&](
StringRef Str) {
815 MDStringRef.push_back(Str);
817 if (
auto Err = parseMetadataStrings(
Record, Blob, IndexNextMDString))
818 return std::move(Err);
825 return std::move(Err);
831 return MaybeRecord.takeError();
833 return error(
"Invalid record");
837 return std::move(Err);
845 "Corrupted bitcode: Expected `Record` when trying to find the "
851 "Corrupted bitcode: Expected `METADATA_INDEX` when trying to "
852 "find the Metadata index");
854 return MaybeCode.takeError();
856 auto CurrentValue = BeginPos;
857 GlobalMetadataBitPosIndex.reserve(
Record.size());
858 for (
auto &Elt :
Record) {
860 GlobalMetadataBitPosIndex.push_back(CurrentValue);
867 return error(
"Corrupted Metadata block");
871 return std::move(Err);
877 Code = MaybeCode.get();
880 return MaybeCode.takeError();
885 Code = MaybeCode.get();
887 return MaybeCode.takeError();
896 return MaybeNextBitCode.takeError();
901 for (
unsigned i = 0; i !=
Size; ++i) {
906 MDNode *MD = MetadataList.getMDNodeFwdRefOrNull(
Record[i]);
907 assert(MD &&
"Invalid metadata: expect fwd ref to MDNode");
913 if (!GlobalDeclAttachmentPos)
914 GlobalDeclAttachmentPos = SavedPos;
916 NumGlobalDeclAttachSkipped++;
960 GlobalMetadataBitPosIndex.clear();
974Expected<bool> MetadataLoader::MetadataLoaderImpl::loadGlobalDeclAttachments() {
976 if (!GlobalDeclAttachmentPos)
985 return std::move(Err);
994 switch (
Entry.Kind) {
997 return error(
"Malformed block");
1000 assert(NumGlobalDeclAttachSkipped == NumGlobalDeclAttachParsed);
1012 assert(NumGlobalDeclAttachSkipped == NumGlobalDeclAttachParsed);
1016 NumGlobalDeclAttachParsed++;
1021 return std::move(Err);
1027 return MaybeRecord.takeError();
1028 if (
Record.size() % 2 == 0)
1029 return error(
"Invalid record");
1030 unsigned ValueID =
Record[0];
1031 if (ValueID >= ValueList.size())
1032 return error(
"Invalid record");
1033 if (
auto *GO = dyn_cast<GlobalObject>(ValueList[ValueID])) {
1038 if (
Error Err = parseGlobalObjectAttachment(
1040 return std::move(Err);
1042 return std::move(Err);
1047void MetadataLoader::MetadataLoaderImpl::callMDTypeCallback(
Metadata **Val,
1049 if (Callbacks.MDType) {
1050 (*Callbacks.MDType)(Val,
TypeID, Callbacks.GetTypeByID,
1051 Callbacks.GetContainedTypeID);
1058 if (!ModuleLevel && MetadataList.hasFwdRefs())
1059 return error(
"Invalid metadata: fwd refs into function blocks");
1063 auto EntryPos = Stream.GetCurrentBitNo();
1069 PlaceholderQueue Placeholders;
1073 if (ModuleLevel && IsImporting && MetadataList.empty() &&
1075 auto SuccessOrErr = lazyLoadModuleMetadataBlock();
1077 return SuccessOrErr.takeError();
1078 if (SuccessOrErr.get()) {
1081 MetadataList.resize(MDStringRef.size() +
1082 GlobalMetadataBitPosIndex.size());
1087 SuccessOrErr = loadGlobalDeclAttachments();
1089 return SuccessOrErr.takeError();
1090 assert(SuccessOrErr.get());
1094 resolveForwardRefsAndPlaceholders(Placeholders);
1095 upgradeDebugInfo(ModuleLevel);
1098 Stream.ReadBlockEnd();
1099 if (
Error Err = IndexCursor.JumpToBit(EntryPos))
1101 if (
Error Err = Stream.SkipBlock()) {
1112 unsigned NextMetadataNo = MetadataList.size();
1117 if (
Error E = Stream.advanceSkippingSubblocks().moveInto(Entry))
1120 switch (Entry.Kind) {
1123 return error(
"Malformed block");
1125 resolveForwardRefsAndPlaceholders(Placeholders);
1126 upgradeDebugInfo(ModuleLevel);
1136 ++NumMDRecordLoaded;
1138 Stream.readRecord(Entry.ID,
Record, &Blob)) {
1139 if (
Error Err = parseOneMetadata(
Record, MaybeCode.
get(), Placeholders,
1140 Blob, NextMetadataNo))
1147MDString *MetadataLoader::MetadataLoaderImpl::lazyLoadOneMDString(
unsigned ID) {
1148 ++NumMDStringLoaded;
1150 return cast<MDString>(MD);
1152 MetadataList.assignValue(MDS,
ID);
1156void MetadataLoader::MetadataLoaderImpl::lazyLoadOneMetadata(
1157 unsigned ID, PlaceholderQueue &Placeholders) {
1158 assert(
ID < (MDStringRef.size()) + GlobalMetadataBitPosIndex.size());
1159 assert(
ID >= MDStringRef.size() &&
"Unexpected lazy-loading of MDString");
1161 if (
auto *MD = MetadataList.lookup(
ID)) {
1162 auto *
N = cast<MDNode>(MD);
1163 if (!
N->isTemporary())
1168 if (
Error Err = IndexCursor.JumpToBit(
1169 GlobalMetadataBitPosIndex[
ID - MDStringRef.size()]))
1173 if (
Error E = IndexCursor.advanceSkippingSubblocks().moveInto(Entry))
1177 ++NumMDRecordLoaded;
1179 IndexCursor.readRecord(Entry.ID,
Record, &Blob)) {
1181 parseOneMetadata(
Record, MaybeCode.
get(), Placeholders, Blob,
ID))
1191void MetadataLoader::MetadataLoaderImpl::resolveForwardRefsAndPlaceholders(
1192 PlaceholderQueue &Placeholders) {
1196 Placeholders.getTemporaries(MetadataList, Temporaries);
1199 if (Temporaries.
empty() && !MetadataList.hasFwdRefs())
1204 for (
auto ID : Temporaries)
1205 lazyLoadOneMetadata(
ID, Placeholders);
1206 Temporaries.clear();
1210 while (MetadataList.hasFwdRefs())
1211 lazyLoadOneMetadata(MetadataList.getNextFwdRef(), Placeholders);
1216 MetadataList.tryToResolveCycles();
1220 Placeholders.flush(MetadataList);
1224 Type *Ty,
unsigned TyID) {
1236 if (
Idx < ValueList.
size() && ValueList[
Idx] &&
1237 ValueList[
Idx]->getType() == Ty)
1243Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
1245 PlaceholderQueue &Placeholders,
StringRef Blob,
unsigned &NextMetadataNo) {
1247 bool IsDistinct =
false;
1248 auto getMD = [&](
unsigned ID) ->
Metadata * {
1249 if (
ID < MDStringRef.size())
1250 return lazyLoadOneMDString(
ID);
1252 if (
auto *MD = MetadataList.lookup(
ID))
1256 if (
ID < (MDStringRef.size() + GlobalMetadataBitPosIndex.size())) {
1260 MetadataList.getMetadataFwdRef(NextMetadataNo);
1261 lazyLoadOneMetadata(
ID, Placeholders);
1262 return MetadataList.lookup(
ID);
1265 return MetadataList.getMetadataFwdRef(
ID);
1267 if (
auto *MD = MetadataList.getMetadataIfResolved(
ID))
1269 return &Placeholders.getPlaceholderOp(
ID);
1271 auto getMDOrNull = [&](
unsigned ID) ->
Metadata * {
1273 return getMD(
ID - 1);
1276 auto getMDOrNullWithoutPlaceholders = [&](
unsigned ID) ->
Metadata * {
1278 return MetadataList.getMetadataFwdRef(
ID - 1);
1281 auto getMDString = [&](
unsigned ID) ->
MDString * {
1284 auto MDS = getMDOrNull(
ID);
1285 return cast_or_null<MDString>(MDS);
1289 auto getDITypeRefOrNull = [&](
unsigned ID) {
1290 return MetadataList.upgradeTypeRef(getMDOrNull(
ID));
1293#define GET_OR_DISTINCT(CLASS, ARGS) \
1294 (IsDistinct ? CLASS::getDistinct ARGS : CLASS::get ARGS)
1303 if (
Error E = Stream.ReadCode().moveInto(Code))
1306 ++NumMDRecordLoaded;
1309 return error(
"METADATA_NAME not followed by METADATA_NAMED_NODE");
1311 return MaybeNextBitCode.takeError();
1316 for (
unsigned i = 0; i !=
Size; ++i) {
1317 MDNode *MD = MetadataList.getMDNodeFwdRefOrNull(
Record[i]);
1319 return error(
"Invalid named metadata: expect fwd ref to MDNode");
1328 if (
Record.size() % 2 == 1)
1329 return error(
"Invalid record");
1333 auto dropRecord = [&] {
1334 MetadataList.assignValue(
MDNode::get(Context, {}), NextMetadataNo);
1337 if (
Record.size() != 2) {
1342 unsigned TyID =
Record[0];
1343 Type *Ty = Callbacks.GetTypeByID(TyID);
1349 Value *
V = ValueList.getValueFwdRef(
Record[1], Ty, TyID,
1352 return error(
"Invalid value reference from old fn metadata");
1360 if (
Record.size() % 2 == 1)
1361 return error(
"Invalid record");
1365 for (
unsigned i = 0; i !=
Size; i += 2) {
1366 unsigned TyID =
Record[i];
1367 Type *Ty = Callbacks.GetTypeByID(TyID);
1369 return error(
"Invalid record");
1375 return error(
"Invalid value reference from old metadata");
1377 assert(isa<ConstantAsMetadata>(MD) &&
1378 "Expected non-function-local metadata");
1379 callMDTypeCallback(&MD, TyID);
1384 MetadataList.assignValue(
MDNode::get(Context, Elts), NextMetadataNo);
1390 return error(
"Invalid record");
1392 unsigned TyID =
Record[0];
1393 Type *Ty = Callbacks.GetTypeByID(TyID);
1395 return error(
"Invalid record");
1399 return error(
"Invalid value reference from metadata");
1402 callMDTypeCallback(&MD, TyID);
1403 MetadataList.assignValue(MD, NextMetadataNo);
1423 return error(
"Invalid record");
1427 unsigned Column =
Record[2];
1431 MetadataList.assignValue(
1440 return error(
"Invalid record");
1447 return error(
"Invalid record");
1449 auto *Header = getMDString(
Record[3]);
1451 for (
unsigned I = 4, E =
Record.size();
I != E; ++
I)
1453 MetadataList.assignValue(
1469 switch (
Record[0] >> 1) {
1476 unrotateSign(
Record[2])));
1484 return error(
"Invalid record: Unsupported version of DISubrange");
1487 MetadataList.assignValue(Val, NextMetadataNo);
1488 IsDistinct =
Record[0] & 1;
1495 (Context, getMDOrNull(
Record[1]),
1497 getMDOrNull(
Record[4])));
1499 MetadataList.assignValue(Val, NextMetadataNo);
1500 IsDistinct =
Record[0] & 1;
1506 return error(
"Invalid record");
1508 IsDistinct =
Record[0] & 1;
1509 bool IsUnsigned =
Record[0] & 2;
1510 bool IsBigInt =
Record[0] & 4;
1515 const size_t NumWords =
Record.size() - 3;
1520 MetadataList.assignValue(
1522 (Context,
Value, IsUnsigned, getMDString(
Record[2]))),
1529 return error(
"Invalid record");
1537 MetadataList.assignValue(
1547 return error(
"Invalid record");
1550 bool SizeIs8 =
Record.size() == 8;
1553 Metadata *StringLocationExp = SizeIs8 ? nullptr : getMDOrNull(
Record[5]);
1554 unsigned Offset = SizeIs8 ? 5 : 6;
1555 MetadataList.assignValue(
1567 return error(
"Invalid record");
1571 std::optional<unsigned> DWARFAddressSpace;
1573 DWARFAddressSpace =
Record[12] - 1;
1576 std::optional<DIDerivedType::PtrAuthData> PtrAuthData;
1581 if (
Record.size() > 14) {
1585 PtrAuthData.emplace(
Record[14]);
1590 MetadataList.assignValue(
1594 getDITypeRefOrNull(
Record[5]),
1596 Record[9], DWARFAddressSpace, PtrAuthData, Flags,
1604 return error(
"Invalid record");
1608 IsDistinct =
Record[0] & 0x1;
1609 bool IsNotUsedInTypeRef =
Record[0] >= 2;
1618 return error(
"Alignment value is too large");
1624 unsigned RuntimeLang =
Record[12];
1626 Metadata *TemplateParams =
nullptr;
1650 (
Tag == dwarf::DW_TAG_enumeration_type ||
1651 Tag == dwarf::DW_TAG_class_type ||
1652 Tag == dwarf::DW_TAG_structure_type ||
1653 Tag == dwarf::DW_TAG_union_type)) {
1661 TemplateParams = getMDOrNull(
Record[14]);
1664 OffsetInBits =
Record[9];
1666 VTableHolder = getDITypeRefOrNull(
Record[13]);
1667 TemplateParams = getMDOrNull(
Record[14]);
1671 DataLocation = getMDOrNull(
Record[17]);
1672 if (
Record.size() > 19) {
1673 Associated = getMDOrNull(
Record[18]);
1674 Allocated = getMDOrNull(
Record[19]);
1676 if (
Record.size() > 20) {
1677 Rank = getMDOrNull(
Record[20]);
1679 if (
Record.size() > 21) {
1682 if (
Record.size() > 23) {
1683 Specification = getMDOrNull(
Record[23]);
1690 SizeInBits, AlignInBits, OffsetInBits, Specification,
1691 NumExtraInhabitants, Flags, Elements, RuntimeLang, VTableHolder,
1692 TemplateParams, Discriminator, DataLocation, Associated, Allocated,
1699 SizeInBits, AlignInBits, OffsetInBits, Flags,
1700 Elements, RuntimeLang, VTableHolder, TemplateParams,
1701 Identifier, Discriminator, DataLocation, Associated,
1703 NumExtraInhabitants));
1704 if (!IsNotUsedInTypeRef && Identifier)
1705 MetadataList.addTypeRef(*Identifier, *cast<DICompositeType>(CT));
1707 MetadataList.assignValue(CT, NextMetadataNo);
1713 return error(
"Invalid record");
1714 bool IsOldTypeRefArray =
Record[0] < 2;
1717 IsDistinct =
Record[0] & 0x1;
1721 Types = MetadataList.upgradeTypeRefArray(Types);
1723 MetadataList.assignValue(
1732 return error(
"Invalid record");
1736 MetadataList.assignValue(
1739 (Context,
Record.size() >= 8 ? getMDOrNull(
Record[1]) :
nullptr,
1752 return error(
"Invalid record");
1755 std::optional<DIFile::ChecksumInfo<MDString *>> Checksum;
1764 MetadataList.assignValue(
1766 (Context, getMDString(
Record[1]),
1767 getMDString(
Record[2]), Checksum,
1768 Record.size() > 5 ? getMDString(
Record[5]) :
nullptr)),
1775 return error(
"Invalid record");
1785 Record.size() <= 15 ?
nullptr : getMDOrNull(
Record[15]),
1791 Record.size() <= 20 ?
nullptr : getMDString(
Record[20]),
1792 Record.size() <= 21 ?
nullptr : getMDString(
Record[21]));
1794 MetadataList.assignValue(
CU, NextMetadataNo);
1799 CUSubprograms.push_back({
CU, SPs});
1804 return error(
"Invalid record");
1806 bool HasSPFlags =
Record[0] & 4;
1819 const unsigned DIFlagMainSubprogram = 1 << 21;
1820 bool HasOldMainSubprogramFlag =
Flags & DIFlagMainSubprogram;
1821 if (HasOldMainSubprogramFlag)
1825 Flags &= ~static_cast<DINode::DIFlags>(DIFlagMainSubprogram);
1827 if (HasOldMainSubprogramFlag && HasSPFlags)
1828 SPFlags |= DISubprogram::SPFlagMainSubprogram;
1829 else if (!HasSPFlags)
1833 HasOldMainSubprogramFlag);
1836 IsDistinct = (
Record[0] & 1) || (SPFlags & DISubprogram::SPFlagDefinition);
1842 bool HasUnit =
Record[0] & 2;
1843 if (!HasSPFlags && HasUnit &&
Record.size() < 19)
1844 return error(
"Invalid record");
1845 if (HasSPFlags && !HasUnit)
1846 return error(
"Invalid record");
1849 bool HasThisAdj =
true;
1850 bool HasThrownTypes =
true;
1851 bool HasAnnotations =
false;
1852 bool HasTargetFuncName =
false;
1853 unsigned OffsetA = 0;
1854 unsigned OffsetB = 0;
1858 if (
Record.size() >= 19) {
1862 HasThisAdj =
Record.size() >= 20;
1863 HasThrownTypes =
Record.size() >= 21;
1865 HasAnnotations =
Record.size() >= 19;
1866 HasTargetFuncName =
Record.size() >= 20;
1872 getDITypeRefOrNull(
Record[1]),
1879 getDITypeRefOrNull(
Record[8 + OffsetA]),
1881 HasThisAdj ?
Record[16 + OffsetB] : 0,
1884 HasUnit ? CUorFn :
nullptr,
1885 getMDOrNull(
Record[13 + OffsetB]),
1886 getMDOrNull(
Record[14 + OffsetB]),
1887 getMDOrNull(
Record[15 + OffsetB]),
1888 HasThrownTypes ? getMDOrNull(
Record[17 + OffsetB])
1890 HasAnnotations ? getMDOrNull(
Record[18 + OffsetB])
1892 HasTargetFuncName ? getMDString(
Record[19 + OffsetB])
1895 MetadataList.assignValue(SP, NextMetadataNo);
1900 if (
auto *CMD = dyn_cast_or_null<ConstantAsMetadata>(CUorFn))
1901 if (
auto *
F = dyn_cast<Function>(CMD->getValue())) {
1902 if (
F->isMaterializable())
1905 FunctionsWithSPs[
F] = SP;
1906 else if (!
F->empty())
1907 F->setSubprogram(SP);
1914 return error(
"Invalid record");
1917 MetadataList.assignValue(
1919 (Context, getMDOrNull(
Record[1]),
1927 return error(
"Invalid record");
1930 MetadataList.assignValue(
1932 (Context, getMDOrNull(
Record[1]),
1939 IsDistinct =
Record[0] & 1;
1940 MetadataList.assignValue(
1942 (Context, getMDOrNull(
Record[1]),
1954 else if (
Record.size() == 5)
1957 return error(
"Invalid record");
1959 IsDistinct =
Record[0] & 1;
1960 bool ExportSymbols =
Record[0] & 2;
1961 MetadataList.assignValue(
1963 (Context, getMDOrNull(
Record[1]),
Name, ExportSymbols)),
1970 return error(
"Invalid record");
1973 MetadataList.assignValue(
1976 getMDString(
Record[4]))),
1983 return error(
"Invalid record");
1986 MetadataList.assignValue(
1989 getMDOrNull(
Record[4]))),
1996 return error(
"Invalid record");
1999 MetadataList.assignValue(
2001 (Context, getMDString(
Record[1]),
2002 getDITypeRefOrNull(
Record[2]),
2004 : getMDOrNull(
false))),
2011 return error(
"Invalid record");
2015 MetadataList.assignValue(
2019 getDITypeRefOrNull(
Record[3]),
2020 (
Record.size() == 6) ? getMDOrNull(
Record[4]) : getMDOrNull(
false),
2022 : getMDOrNull(
Record[4]))),
2029 return error(
"Invalid record");
2031 IsDistinct =
Record[0] & 1;
2039 MetadataList.assignValue(
2041 (Context, getMDOrNull(
Record[1]),
2053 MetadataList.assignValue(
2056 (Context, getMDOrNull(
Record[1]), getMDString(
Record[2]),
2059 getMDOrNull(
Record[10]),
nullptr,
Record[11],
nullptr)),
2066 NeedUpgradeToDIGlobalVariableExpression =
true;
2069 if (
Record.size() > 11) {
2071 return error(
"Alignment value is too large");
2072 AlignInBits =
Record[11];
2075 if (
auto *CMD = dyn_cast_or_null<ConstantAsMetadata>(Expr)) {
2076 if (
auto *GV = dyn_cast<GlobalVariable>(CMD->getValue())) {
2079 }
else if (
auto *CI = dyn_cast<ConstantInt>(CMD->getValue())) {
2081 {dwarf::DW_OP_constu, CI->getZExtValue(),
2082 dwarf::DW_OP_stack_value});
2089 (Context, getMDOrNull(
Record[1]), getMDString(
Record[2]),
2092 getMDOrNull(
Record[10]),
nullptr, AlignInBits,
nullptr));
2102 MetadataList.assignValue(
MDNode, NextMetadataNo);
2105 return error(
"Invalid record");
2111 return error(
"Invalid DIAssignID record.");
2113 IsDistinct =
Record[0] & 1;
2115 return error(
"Invalid DIAssignID record. Must be distinct");
2124 return error(
"Invalid record");
2126 IsDistinct =
Record[0] & 1;
2127 bool HasAlignment =
Record[0] & 2;
2131 bool HasTag = !HasAlignment &&
Record.size() > 8;
2137 return error(
"Alignment value is too large");
2143 MetadataList.assignValue(
2145 (Context, getMDOrNull(
Record[1 + HasTag]),
2146 getMDString(
Record[2 + HasTag]),
2148 getDITypeRefOrNull(
Record[5 + HasTag]),
2156 return error(
"Invalid record");
2158 IsDistinct =
Record[0] & 1;
2159 MetadataList.assignValue(
2169 return error(
"Invalid record");
2171 IsDistinct =
Record[0] & 1;
2176 if (
Error Err = upgradeDIExpression(
Version, Elts, Buffer))
2186 return error(
"Invalid record");
2192 MetadataList.assignValue(
2194 (Context, getMDOrNull(
Record[1]), Expr)),
2201 return error(
"Invalid record");
2204 MetadataList.assignValue(
2206 (Context, getMDString(
Record[1]),
2216 return error(
"Invalid DIImportedEntity record");
2219 bool HasFile = (
Record.size() >= 7);
2220 bool HasElements = (
Record.size() >= 8);
2221 MetadataList.assignValue(
2224 getDITypeRefOrNull(
Record[3]),
2225 HasFile ? getMDOrNull(
Record[6]) :
nullptr,
2227 HasElements ? getMDOrNull(
Record[7]) :
nullptr)),
2237 ++NumMDStringLoaded;
2239 MetadataList.assignValue(MD, NextMetadataNo);
2244 auto CreateNextMDString = [&](
StringRef Str) {
2245 ++NumMDStringLoaded;
2246 MetadataList.assignValue(
MDString::get(Context, Str), NextMetadataNo);
2249 if (
Error Err = parseMetadataStrings(
Record, Blob, CreateNextMDString))
2254 if (
Record.size() % 2 == 0)
2255 return error(
"Invalid record");
2256 unsigned ValueID =
Record[0];
2257 if (ValueID >= ValueList.size())
2258 return error(
"Invalid record");
2259 if (
auto *GO = dyn_cast<GlobalObject>(ValueList[ValueID]))
2260 if (
Error Err = parseGlobalObjectAttachment(
2277 if (isa<MDNode>(MD) && cast<MDNode>(MD)->isTemporary())
2279 "Invalid record: DIArgList should not contain forward refs");
2280 if (!isa<ValueAsMetadata>(MD))
2281 return error(
"Invalid record");
2282 Elts.
push_back(cast<ValueAsMetadata>(MD));
2285 MetadataList.assignValue(
DIArgList::get(Context, Elts), NextMetadataNo);
2291#undef GET_OR_DISTINCT
2294Error MetadataLoader::MetadataLoaderImpl::parseMetadataStrings(
2301 return error(
"Invalid record: metadata strings layout");
2303 unsigned NumStrings =
Record[0];
2304 unsigned StringsOffset =
Record[1];
2306 return error(
"Invalid record: metadata strings with no strings");
2307 if (StringsOffset > Blob.
size())
2308 return error(
"Invalid record: metadata strings corrupt offset");
2315 if (
R.AtEndOfStream())
2316 return error(
"Invalid record: metadata strings bad length");
2321 if (Strings.size() <
Size)
2322 return error(
"Invalid record: metadata strings truncated chars");
2324 CallBack(Strings.slice(0,
Size));
2325 Strings = Strings.drop_front(
Size);
2326 }
while (--NumStrings);
2331Error MetadataLoader::MetadataLoaderImpl::parseGlobalObjectAttachment(
2334 for (
unsigned I = 0, E =
Record.size();
I != E;
I += 2) {
2335 auto K = MDKindMap.find(
Record[
I]);
2336 if (K == MDKindMap.end())
2337 return error(
"Invalid ID");
2341 return error(
"Invalid metadata attachment: expect fwd ref to MDNode");
2354 PlaceholderQueue Placeholders;
2358 if (
Error E = Stream.advanceSkippingSubblocks().moveInto(Entry))
2361 switch (Entry.Kind) {
2364 return error(
"Malformed block");
2366 resolveForwardRefsAndPlaceholders(Placeholders);
2375 ++NumMDRecordLoaded;
2379 switch (MaybeRecord.
get()) {
2383 unsigned RecordLength =
Record.size();
2385 return error(
"Invalid record");
2386 if (RecordLength % 2 == 0) {
2388 if (
Error Err = parseGlobalObjectAttachment(
F,
Record))
2395 for (
unsigned i = 1; i != RecordLength; i = i + 2) {
2396 unsigned Kind =
Record[i];
2398 if (
I == MDKindMap.end())
2399 return error(
"Invalid ID");
2400 if (
I->second == LLVMContext::MD_tbaa && StripTBAA)
2404 if (
Idx < (MDStringRef.size() + GlobalMetadataBitPosIndex.size()) &&
2405 !MetadataList.lookup(
Idx)) {
2408 lazyLoadOneMetadata(
Idx, Placeholders);
2409 resolveForwardRefsAndPlaceholders(Placeholders);
2412 Metadata *Node = MetadataList.getMetadataFwdRef(
Idx);
2413 if (isa<LocalAsMetadata>(Node))
2417 MDNode *MD = dyn_cast_or_null<MDNode>(Node);
2419 return error(
"Invalid metadata attachment");
2421 if (HasSeenOldLoopTags &&
I->second == LLVMContext::MD_loop)
2424 if (
I->second == LLVMContext::MD_tbaa) {
2437Error MetadataLoader::MetadataLoaderImpl::parseMetadataKindRecord(
2440 return error(
"Invalid record");
2442 unsigned Kind =
Record[0];
2445 unsigned NewKind = TheModule.getMDKindID(
Name.str());
2446 if (!MDKindMap.insert(std::make_pair(Kind, NewKind)).second)
2447 return error(
"Conflicting METADATA_KIND records");
2461 if (
Error E = Stream.advanceSkippingSubblocks().moveInto(Entry))
2464 switch (Entry.Kind) {
2467 return error(
"Malformed block");
2477 ++NumMDRecordLoaded;
2481 switch (MaybeCode.
get()) {
2494 Pimpl = std::move(
RHS.Pimpl);
2506 Stream, TheModule, ValueList,
std::
move(Callbacks), IsImporting)) {}
2508Error MetadataLoader::parseMetadata(
bool ModuleLevel) {
2509 return Pimpl->parseMetadata(ModuleLevel);
2517 return Pimpl->getMetadataFwdRefOrLoad(
Idx);
2521 return Pimpl->lookupSubprogramForFunction(
F);
2526 return Pimpl->parseMetadataAttachment(
F, InstructionList);
2530 return Pimpl->parseMetadataKinds();
2534 return Pimpl->setStripTBAA(StripTBAA);
2543 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...
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.
Module.h This file contains the declarations for the Module class.
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)
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, Metadata *Specification, uint32_t NumExtraInhabitants, 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)
An efficient, type-erasing, non-owning reference to a callable.
@ C
The default llvm calling convention, compatible with C.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
@ 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)
@ 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)
const char * toString(DWARFSectionKind Kind)
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...