44 cl::desc(
"Number of metadatas above which we emit an index "
45 "to enable lazy-loading"));
57 CONSTANTS_INTEGER_ABBREV,
58 CONSTANTS_CE_CAST_Abbrev,
59 CONSTANTS_NULL_Abbrev,
63 FUNCTION_INST_BINOP_ABBREV,
64 FUNCTION_INST_BINOP_FLAGS_ABBREV,
65 FUNCTION_INST_CAST_ABBREV,
66 FUNCTION_INST_RET_VOID_ABBREV,
67 FUNCTION_INST_RET_VAL_ABBREV,
68 FUNCTION_INST_UNREACHABLE_ABBREV,
69 FUNCTION_INST_GEP_ABBREV,
74 class BitcodeWriterBase {
81 uint64_t VSTOffsetPlaceholder = 0;
89 bool hasVSTOffsetPlaceholder() {
return VSTOffsetPlaceholder != 0; }
90 void writeValueSymbolTableForwardDecl();
95 class ModuleBitcodeWriter :
public BitcodeWriterBase {
112 uint64_t BitcodeStartBit;
117 std::map<GlobalValue::GUID, unsigned> GUIDToValueIdMap;
120 unsigned GlobalValueId;
128 : BitcodeWriterBase(Stream), Buffer(Buffer), M(*M),
129 VE(*M, ShouldPreserveUseListOrder), Index(Index),
130 GenerateHash(GenerateHash), BitcodeStartBit(Stream.GetCurrentBitNo()) {
136 GlobalValueId = VE.getValues().size();
139 for (
const auto &GUIDSummaryLists : *Index)
141 for (
auto &Summary : GUIDSummaryLists.second)
142 if (
auto FS = dyn_cast<FunctionSummary>(Summary.get()))
147 for (
auto &CallEdge :
FS->calls())
148 if (CallEdge.first.isGUID())
149 assignValueId(CallEdge.first.getGUID());
156 uint64_t bitcodeStartBit() {
return BitcodeStartBit; }
158 void writeAttributeGroupTable();
159 void writeAttributeTable();
160 void writeTypeTable();
162 void writeModuleInfo();
167 unsigned createDILocationAbbrev();
170 unsigned createGenericDINodeAbbrev();
226 unsigned createNamedMetadataAbbrev();
228 unsigned createMetadataStringsAbbrev();
233 std::vector<unsigned> *MDAbbrevs =
nullptr,
234 std::vector<uint64_t> *IndexPos =
nullptr);
235 void writeModuleMetadata();
236 void writeFunctionMetadata(
const Function &
F);
237 void writeFunctionMetadataAttachment(
const Function &
F);
238 void writeGlobalVariableMetadataAttachment(
const GlobalVariable &GV);
241 void writeModuleMetadataKinds();
242 void writeOperandBundleTags();
243 void writeConstants(
unsigned FirstVal,
unsigned LastVal,
bool isGlobal);
244 void writeModuleConstants();
245 bool pushValueAndType(
const Value *V,
unsigned InstID,
248 void pushValue(
const Value *V,
unsigned InstID,
250 void pushValueSigned(
const Value *V,
unsigned InstID,
252 void writeInstruction(
const Instruction &
I,
unsigned InstID,
254 void writeValueSymbolTable(
258 void writeUseListBlock(
const Function *
F);
262 void writeBlockInfo();
266 unsigned FSCallsAbbrev,
267 unsigned FSCallsProfileAbbrev,
271 unsigned FSModRefsAbbrev);
272 void writePerModuleGlobalValueSummary();
273 void writeModuleHash(
size_t BlockStartPos);
276 GUIDToValueIdMap[ValGUID] = ++GlobalValueId;
279 const auto &VMI = GUIDToValueIdMap.find(ValGUID);
282 assert(VMI != GUIDToValueIdMap.end() &&
283 "GUID does not have assigned value Id");
289 return getValueId(VI.
getGUID());
290 return VE.getValueID(VI.
getValue());
292 std::map<GlobalValue::GUID, unsigned> &valueIds() {
return GUIDToValueIdMap; }
296 class IndexBitcodeWriter :
public BitcodeWriterBase {
302 const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex;
306 std::map<GlobalValue::GUID, unsigned> GUIDToValueIdMap;
309 unsigned GlobalValueId = 0;
316 const std::map<std::string, GVSummaryMapTy>
317 *ModuleToSummariesForIndex =
nullptr)
318 : BitcodeWriterBase(Stream), Index(Index),
319 ModuleToSummariesForIndex(ModuleToSummariesForIndex) {
324 for (
const auto &
I : *
this)
325 GUIDToValueIdMap[
I.first] = ++GlobalValueId;
329 typedef std::pair<GlobalValue::GUID, GlobalValueSummary *> GVInfo;
338 const IndexBitcodeWriter &Writer;
344 std::map<std::string, GVSummaryMapTy>::const_iterator ModuleSummariesBack;
346 std::map<std::string, GVSummaryMapTy>::const_iterator ModuleSummariesIter;
348 GVSummaryMapTy::const_iterator ModuleGVSummariesIter;
357 GlobalValueSummaryList::const_iterator IndexGVSummariesIter;
362 iterator(
const IndexBitcodeWriter &Writer,
bool IsAtEnd) : Writer(Writer) {
367 if (Writer.ModuleToSummariesForIndex &&
368 !Writer.ModuleToSummariesForIndex->empty()) {
369 for (ModuleSummariesBack = Writer.ModuleToSummariesForIndex->begin();
370 std::next(ModuleSummariesBack) !=
371 Writer.ModuleToSummariesForIndex->end();
372 ModuleSummariesBack++)
374 ModuleSummariesIter = !IsAtEnd
375 ? Writer.ModuleToSummariesForIndex->begin()
376 : ModuleSummariesBack;
377 ModuleGVSummariesIter = !IsAtEnd ? ModuleSummariesIter->second.begin()
378 : ModuleSummariesBack->second.end();
379 }
else if (!Writer.ModuleToSummariesForIndex &&
380 Writer.Index.begin() != Writer.Index.end()) {
381 for (IndexSummariesBack = Writer.Index.begin();
382 std::next(IndexSummariesBack) != Writer.Index.end();
383 IndexSummariesBack++)
386 !IsAtEnd ? Writer.Index.begin() : IndexSummariesBack;
387 IndexGVSummariesIter = !IsAtEnd ? IndexSummariesIter->second.begin()
388 : IndexSummariesBack->second.end();
393 iterator &operator++() {
397 if (Writer.ModuleToSummariesForIndex) {
398 ++ModuleGVSummariesIter;
399 if (ModuleGVSummariesIter == ModuleSummariesIter->second.end() &&
400 ModuleSummariesIter != ModuleSummariesBack) {
401 ++ModuleSummariesIter;
402 ModuleGVSummariesIter = ModuleSummariesIter->second.begin();
405 ++IndexGVSummariesIter;
406 if (IndexGVSummariesIter == IndexSummariesIter->second.end() &&
407 IndexSummariesIter != IndexSummariesBack) {
408 ++IndexSummariesIter;
409 IndexGVSummariesIter = IndexSummariesIter->second.begin();
418 if (Writer.ModuleToSummariesForIndex)
419 return std::make_pair(ModuleGVSummariesIter->first,
420 ModuleGVSummariesIter->second);
421 return std::make_pair(IndexSummariesIter->first,
422 IndexGVSummariesIter->get());
428 if (Writer.ModuleToSummariesForIndex) {
430 if (Writer.ModuleToSummariesForIndex !=
431 RHS.Writer.ModuleToSummariesForIndex)
435 if (Writer.ModuleToSummariesForIndex->empty())
439 if (ModuleSummariesIter != RHS.ModuleSummariesIter)
441 return ModuleGVSummariesIter == RHS.ModuleGVSummariesIter;
445 if (RHS.Writer.ModuleToSummariesForIndex ||
446 &Writer.Index != &RHS.Writer.Index)
450 if (Writer.Index.begin() == Writer.Index.end())
454 if (IndexSummariesIter != RHS.IndexSummariesIter)
456 return IndexGVSummariesIter == RHS.IndexGVSummariesIter;
461 iterator
begin() {
return iterator(*
this,
false); }
463 iterator
end() {
return iterator(*
this,
true); }
470 void writeModStrings();
471 void writeCombinedValueSymbolTable();
472 void writeCombinedGlobalValueSummary();
477 bool doIncludeModule(
StringRef ModulePath) {
478 return !ModuleToSummariesForIndex ||
479 ModuleToSummariesForIndex->count(ModulePath);
483 const auto &VMI = GUIDToValueIdMap.find(ValGUID);
484 return VMI != GUIDToValueIdMap.end();
487 const auto &VMI = GUIDToValueIdMap.find(ValGUID);
489 if (VMI == GUIDToValueIdMap.end()) {
490 GUIDToValueIdMap[ValGUID] = ++GlobalValueId;
491 return GlobalValueId;
496 std::map<GlobalValue::GUID, unsigned> &valueIds() {
return GUIDToValueIdMap; }
524 case Instruction::Sub:
526 case Instruction::Mul:
529 case Instruction::FDiv:
532 case Instruction::FRem:
574 switch (SynchScope) {
586 for (
unsigned i = 0, e = Str.
size();
i != e; ++
i) {
598 case Attribute::Alignment:
600 case Attribute::AllocSize:
602 case Attribute::AlwaysInline:
604 case Attribute::ArgMemOnly:
606 case Attribute::Builtin:
608 case Attribute::ByVal:
612 case Attribute::InAlloca:
616 case Attribute::InaccessibleMemOnly:
618 case Attribute::InaccessibleMemOrArgMemOnly:
620 case Attribute::InlineHint:
622 case Attribute::InReg:
626 case Attribute::MinSize:
628 case Attribute::Naked:
630 case Attribute::Nest:
634 case Attribute::NoBuiltin:
636 case Attribute::NoCapture:
638 case Attribute::NoDuplicate:
640 case Attribute::NoImplicitFloat:
642 case Attribute::NoInline:
644 case Attribute::NoRecurse:
646 case Attribute::NonLazyBind:
648 case Attribute::NonNull:
650 case Attribute::Dereferenceable:
652 case Attribute::DereferenceableOrNull:
654 case Attribute::NoRedZone:
656 case Attribute::NoReturn:
658 case Attribute::NoUnwind:
660 case Attribute::OptimizeForSize:
662 case Attribute::OptimizeNone:
664 case Attribute::ReadNone:
668 case Attribute::Returned:
670 case Attribute::ReturnsTwice:
672 case Attribute::SExt:
674 case Attribute::StackAlignment:
676 case Attribute::StackProtect:
678 case Attribute::StackProtectReq:
680 case Attribute::StackProtectStrong:
682 case Attribute::SafeStack:
684 case Attribute::StructRet:
686 case Attribute::SanitizeAddress:
688 case Attribute::SanitizeThread:
690 case Attribute::SanitizeMemory:
692 case Attribute::SwiftError:
694 case Attribute::SwiftSelf:
696 case Attribute::UWTable:
700 case Attribute::ZExt:
711 void ModuleBitcodeWriter::writeAttributeGroupTable() {
712 const std::vector<AttributeSet> &AttrGrps = VE.getAttributeGroups();
713 if (AttrGrps.empty())
return;
718 for (
unsigned i = 0, e = AttrGrps.size();
i != e; ++
i) {
723 Record.
push_back(VE.getAttributeGroupID(A));
758 void ModuleBitcodeWriter::writeAttributeTable() {
759 const std::vector<AttributeSet> &Attrs = VE.getAttributes();
760 if (Attrs.empty())
return;
765 for (
unsigned i = 0, e = Attrs.size();
i != e; ++
i) {
778 void ModuleBitcodeWriter::writeTypeTable() {
784 uint64_t NumBits = VE.computeBitsRequiredForTypeIndicies();
787 auto Abbv = std::make_shared<BitCodeAbbrev>();
791 unsigned PtrAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
794 Abbv = std::make_shared<BitCodeAbbrev>();
800 unsigned FunctionAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
803 Abbv = std::make_shared<BitCodeAbbrev>();
809 unsigned StructAnonAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
812 Abbv = std::make_shared<BitCodeAbbrev>();
816 unsigned StructNameAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
819 Abbv = std::make_shared<BitCodeAbbrev>();
825 unsigned StructNamedAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
828 Abbv = std::make_shared<BitCodeAbbrev>();
833 unsigned ArrayAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
841 for (
unsigned i = 0, e = TypeList.size();
i != e; ++
i) {
870 if (AddressSpace == 0) AbbrevToUse = PtrAbbrev;
881 AbbrevToUse = FunctionAbbrev;
895 AbbrevToUse = StructAnonAbbrev;
901 AbbrevToUse = StructNamedAbbrev;
917 AbbrevToUse = ArrayAbbrev;
931 Stream.
EmitRecord(Code, TypeVals, AbbrevToUse);
972 uint64_t RawFlags = 0;
979 RawFlags = (RawFlags << 4) | Flags.
Linkage;
1038 void ModuleBitcodeWriter::writeComdats() {
1040 for (
const Comdat *
C : VE.getComdats()) {
1043 size_t Size =
C->getName().size();
1046 for (
char Chr :
C->getName())
1056 void BitcodeWriterBase::writeValueSymbolTableForwardDecl() {
1061 auto Abbv = std::make_shared<BitCodeAbbrev>();
1067 unsigned VSTOffsetAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
1083 bool isChar6 =
true;
1084 for (
const char *
C = Str, *
E =
C + StrLen;
C !=
E; ++
C) {
1087 if ((
unsigned char)*
C & 128)
1100 void ModuleBitcodeWriter::writeModuleInfo() {
1114 std::map<std::string, unsigned> SectionMap;
1115 std::map<std::string, unsigned> GCMap;
1116 unsigned MaxAlignment = 0;
1117 unsigned MaxGlobalType = 0;
1119 MaxAlignment = std::max(MaxAlignment, GV.getAlignment());
1120 MaxGlobalType = std::max(MaxGlobalType, VE.getTypeID(GV.getValueType()));
1121 if (GV.hasSection()) {
1123 unsigned &Entry = SectionMap[GV.getSection()];
1127 Entry = SectionMap.size();
1132 MaxAlignment = std::max(MaxAlignment,
F.getAlignment());
1133 if (
F.hasSection()) {
1135 unsigned &Entry = SectionMap[
F.getSection()];
1139 Entry = SectionMap.size();
1144 unsigned &Entry = GCMap[
F.getGC()];
1148 Entry = GCMap.size();
1154 unsigned SimpleGVarAbbrev = 0;
1155 if (!M.global_empty()) {
1157 auto Abbv = std::make_shared<BitCodeAbbrev>();
1166 if (MaxAlignment == 0)
1169 unsigned MaxEncAlignment =
Log2_32(MaxAlignment)+1;
1173 if (SectionMap.empty())
1179 SimpleGVarAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
1185 unsigned AbbrevToUse = 0;
1191 Vals.
push_back(VE.getTypeID(GV.getValueType()));
1192 Vals.
push_back(GV.getType()->getAddressSpace() << 2 | 2 | GV.isConstant());
1194 (VE.getValueID(GV.getInitializer()) + 1));
1197 Vals.
push_back(GV.hasSection() ? SectionMap[GV.getSection()] : 0);
1198 if (GV.isThreadLocal() ||
1201 GV.isExternallyInitialized() ||
1207 Vals.
push_back(GV.isExternallyInitialized());
1209 Vals.
push_back(GV.hasComdat() ? VE.getComdatID(GV.getComdat()) : 0);
1211 AbbrevToUse = SimpleGVarAbbrev;
1223 Vals.
push_back(VE.getTypeID(
F.getFunctionType()));
1227 Vals.
push_back(VE.getAttributeID(
F.getAttributes()));
1229 Vals.
push_back(
F.hasSection() ? SectionMap[
F.getSection()] : 0);
1233 Vals.
push_back(
F.hasPrologueData() ? (VE.getValueID(
F.getPrologueData()) + 1)
1236 Vals.
push_back(
F.hasComdat() ? VE.getComdatID(
F.getComdat()) : 0);
1237 Vals.
push_back(
F.hasPrefixData() ? (VE.getValueID(
F.getPrefixData()) + 1)
1240 F.hasPersonalityFn() ? (VE.getValueID(
F.getPersonalityFn()) + 1) : 0);
1242 unsigned AbbrevToUse = 0;
1251 Vals.
push_back(VE.getTypeID(A.getValueType()));
1252 Vals.
push_back(A.getType()->getAddressSpace());
1253 Vals.
push_back(VE.getValueID(A.getAliasee()));
1259 unsigned AbbrevToUse = 0;
1267 Vals.
push_back(VE.getTypeID(
I.getValueType()));
1268 Vals.
push_back(
I.getType()->getAddressSpace());
1269 Vals.
push_back(VE.getValueID(
I.getResolver()));
1279 M.getSourceFileName().size());
1287 auto Abbv = std::make_shared<BitCodeAbbrev>();
1290 Abbv->Add(AbbrevOpToUse);
1291 unsigned FilenameAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
1293 for (
const auto P : M.getSourceFileName())
1302 if (M.getValueSymbolTable().empty())
1304 writeValueSymbolTableForwardDecl();
1310 if (
const auto *OBO = dyn_cast<OverflowingBinaryOperator>(V)) {
1311 if (OBO->hasNoSignedWrap())
1313 if (OBO->hasNoUnsignedWrap())
1315 }
else if (
const auto *PEO = dyn_cast<PossiblyExactOperator>(V)) {
1318 }
else if (
const auto *FPMO = dyn_cast<FPMathOperator>(V)) {
1319 if (FPMO->hasUnsafeAlgebra())
1321 if (FPMO->hasNoNaNs())
1323 if (FPMO->hasNoInfs())
1325 if (FPMO->hasNoSignedZeros())
1327 if (FPMO->hasAllowReciprocal())
1334 void ModuleBitcodeWriter::writeValueAsMetadata(
1349 assert(!(MD && isa<LocalAsMetadata>(MD)) &&
1350 "Unexpected function-local metadata");
1351 Record.
push_back(VE.getMetadataOrNullID(MD));
1359 unsigned ModuleBitcodeWriter::createDILocationAbbrev() {
1362 auto Abbv = std::make_shared<BitCodeAbbrev>();
1376 Abbrev = createDILocationAbbrev();
1381 Record.
push_back(VE.getMetadataID(N->getScope()));
1382 Record.
push_back(VE.getMetadataOrNullID(N->getInlinedAt()));
1388 unsigned ModuleBitcodeWriter::createGenericDINodeAbbrev() {
1391 auto Abbv = std::make_shared<BitCodeAbbrev>();
1406 Abbrev = createGenericDINodeAbbrev();
1421 return I < 0 ? ~(U << 1) : U << 1;
1469 Record.
push_back(VE.getMetadataOrNullID(N->getBaseType()));
1474 Record.
push_back(VE.getMetadataOrNullID(N->getExtraData()));
1483 const unsigned IsNotUsedInOldTypeRef = 0x2;
1508 const unsigned HasNoOldTypeRefs = 0x2;
1560 uint64_t HasUnitFlag = 1 << 1;
1563 Record.
push_back(VE.getMetadataOrNullID(N->getRawName()));
1564 Record.
push_back(VE.getMetadataOrNullID(N->getRawLinkageName()));
1567 Record.
push_back(VE.getMetadataOrNullID(N->getType()));
1571 Record.
push_back(VE.getMetadataOrNullID(N->getContainingType()));
1576 Record.
push_back(VE.getMetadataOrNullID(N->getRawUnit()));
1577 Record.
push_back(VE.getMetadataOrNullID(N->getTemplateParams().
get()));
1578 Record.
push_back(VE.getMetadataOrNullID(N->getDeclaration()));
1579 Record.
push_back(VE.getMetadataOrNullID(N->getVariables().
get()));
1580 Record.
push_back(N->getThisAdjustment());
1688 const uint64_t
Version = 1 << 1;
1722 const uint64_t HasAlignmentFlag = 1 << 1;
1742 const uint64_t HasOpFragmentFlag = 1 << 1;
1791 unsigned ModuleBitcodeWriter::createNamedMetadataAbbrev() {
1792 auto Abbv = std::make_shared<BitCodeAbbrev>();
1799 void ModuleBitcodeWriter::writeNamedMetadata(
1801 if (M.named_metadata_empty())
1804 unsigned Abbrev = createNamedMetadataAbbrev();
1805 for (
const NamedMDNode &NMD : M.named_metadata()) {
1820 unsigned ModuleBitcodeWriter::createMetadataStringsAbbrev() {
1821 auto Abbv = std::make_shared<BitCodeAbbrev>();
1833 void ModuleBitcodeWriter::writeMetadataStrings(
1835 if (Strings.
empty())
1847 W.EmitVBR(cast<MDString>(MD)->getLength(), 6);
1856 Blob.
append(cast<MDString>(MD)->getString());
1865 #define HANDLE_MDNODE_LEAF(CLASS) CLASS##AbbrevID,
1866 #include "llvm/IR/Metadata.def"
1870 void ModuleBitcodeWriter::writeMetadataRecords(
1872 std::vector<unsigned> *MDAbbrevs, std::vector<uint64_t> *IndexPos) {
1877 #define HANDLE_MDNODE_LEAF(CLASS) unsigned CLASS##Abbrev = 0;
1878 #include "llvm/IR/Metadata.def"
1883 if (
const MDNode *N = dyn_cast<MDNode>(MD)) {
1889 #define HANDLE_MDNODE_LEAF(CLASS) \
1890 case Metadata::CLASS##Kind: \
1892 write##CLASS(cast<CLASS>(N), Record, \
1893 (*MDAbbrevs)[MetadataAbbrev::CLASS##AbbrevID]); \
1895 write##CLASS(cast<CLASS>(N), Record, CLASS##Abbrev); \
1897 #include "llvm/IR/Metadata.def"
1900 writeValueAsMetadata(cast<ValueAsMetadata>(MD), Record);
1904 void ModuleBitcodeWriter::writeModuleMetadata() {
1905 if (!VE.hasMDs() && M.named_metadata_empty())
1913 std::vector<unsigned> MDAbbrevs;
1916 MDAbbrevs[MetadataAbbrev::DILocationAbbrevID] = createDILocationAbbrev();
1917 MDAbbrevs[MetadataAbbrev::GenericDINodeAbbrevID] =
1918 createGenericDINodeAbbrev();
1920 auto Abbv = std::make_shared<BitCodeAbbrev>();
1924 unsigned OffsetAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
1926 Abbv = std::make_shared<BitCodeAbbrev>();
1930 unsigned IndexAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
1933 writeMetadataStrings(VE.getMDStrings(), Record);
1937 if (VE.getNonMDStrings().size() > IndexThreshold) {
1942 uint64_t Vals[] = {0, 0};
1952 std::vector<uint64_t> IndexPos;
1953 IndexPos.reserve(VE.getNonMDStrings().size());
1956 writeMetadataRecords(VE.getNonMDStrings(), Record, &MDAbbrevs, &IndexPos);
1958 if (VE.getNonMDStrings().size() > IndexThreshold) {
1967 uint64_t PreviousValue = IndexOffsetRecordBitPos;
1968 for (
auto &Elt : IndexPos) {
1969 auto EltDelta = Elt - PreviousValue;
1970 PreviousValue = Elt;
1979 writeNamedMetadata(Record);
1981 auto AddDeclAttachedMetadata = [&](
const GlobalObject &GO) {
1984 pushGlobalMetadataAttachment(Record, GO);
1988 if (
F.isDeclaration() &&
F.hasMetadata())
1989 AddDeclAttachedMetadata(
F);
1993 if (GV.hasMetadata())
1994 AddDeclAttachedMetadata(GV);
1999 void ModuleBitcodeWriter::writeFunctionMetadata(
const Function &
F) {
2005 writeMetadataStrings(VE.getMDStrings(), Record);
2006 writeMetadataRecords(VE.getNonMDStrings(), Record);
2010 void ModuleBitcodeWriter::pushGlobalMetadataAttachment(
2015 for (
const auto &
I : MDs) {
2017 Record.
push_back(VE.getMetadataID(
I.second));
2021 void ModuleBitcodeWriter::writeFunctionMetadataAttachment(
const Function &F) {
2027 pushGlobalMetadataAttachment(Record, F);
2038 I.getAllMetadataOtherThanDebugLoc(MDs);
2041 if (MDs.
empty())
continue;
2045 for (
unsigned i = 0, e = MDs.
size();
i != e; ++
i) {
2047 Record.
push_back(VE.getMetadataID(MDs[
i].second));
2056 void ModuleBitcodeWriter::writeModuleMetadataKinds() {
2062 M.getMDKindNames(Names);
2064 if (Names.
empty())
return;
2068 for (
unsigned MDKindID = 0, e = Names.
size(); MDKindID != e; ++MDKindID) {
2080 void ModuleBitcodeWriter::writeOperandBundleTags() {
2088 M.getOperandBundleTags(Tags);
2097 for (
auto Tag : Tags) {
2108 if ((int64_t)V >= 0)
2114 void ModuleBitcodeWriter::writeConstants(
unsigned FirstVal,
unsigned LastVal,
2116 if (FirstVal == LastVal)
return;
2120 unsigned AggregateAbbrev = 0;
2121 unsigned String8Abbrev = 0;
2122 unsigned CString7Abbrev = 0;
2123 unsigned CString6Abbrev = 0;
2127 auto Abbv = std::make_shared<BitCodeAbbrev>();
2131 AggregateAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
2134 Abbv = std::make_shared<BitCodeAbbrev>();
2138 String8Abbrev = Stream.
EmitAbbrev(std::move(Abbv));
2140 Abbv = std::make_shared<BitCodeAbbrev>();
2144 CString7Abbrev = Stream.
EmitAbbrev(std::move(Abbv));
2146 Abbv = std::make_shared<BitCodeAbbrev>();
2150 CString6Abbrev = Stream.
EmitAbbrev(std::move(Abbv));
2156 Type *LastTy =
nullptr;
2157 for (
unsigned i = FirstVal;
i != LastVal; ++
i) {
2158 const Value *V = Vals[
i].first;
2164 CONSTANTS_SETTYPE_ABBREV);
2168 if (
const InlineAsm *IA = dyn_cast<InlineAsm>(V)) {
2169 Record.
push_back(
unsigned(IA->hasSideEffects()) |
2170 unsigned(IA->isAlignStack()) << 1 |
2171 unsigned(IA->getDialect()&1) << 2);
2174 const std::string &AsmStr = IA->getAsmString();
2176 Record.
append(AsmStr.begin(), AsmStr.end());
2179 const std::string &ConstraintStr = IA->getConstraintString();
2181 Record.
append(ConstraintStr.begin(), ConstraintStr.end());
2187 unsigned Code = -1U;
2188 unsigned AbbrevToUse = 0;
2191 }
else if (isa<UndefValue>(C)) {
2193 }
else if (
const ConstantInt *IV = dyn_cast<ConstantInt>(C)) {
2194 if (IV->getBitWidth() <= 64) {
2195 uint64_t V = IV->getSExtValue();
2198 AbbrevToUse = CONSTANTS_INTEGER_ABBREV;
2204 unsigned NWords = IV->getValue().getActiveWords();
2205 const uint64_t *RawWords = IV->getValue().getRawData();
2206 for (
unsigned i = 0;
i != NWords; ++
i) {
2211 }
else if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(C)) {
2213 Type *Ty = CFP->getType();
2215 Record.
push_back(CFP->getValueAPF().bitcastToAPInt().getZExtValue());
2219 APInt api = CFP->getValueAPF().bitcastToAPInt();
2221 Record.
push_back((p[1] << 48) | (p[0] >> 16));
2224 APInt api = CFP->getValueAPF().bitcastToAPInt();
2229 assert (0 &&
"Unknown FP type!");
2231 }
else if (isa<ConstantDataSequential>(C) &&
2232 cast<ConstantDataSequential>(C)->isString()) {
2242 AbbrevToUse = String8Abbrev;
2246 for (
unsigned i = 0;
i != NumElts; ++
i) {
2249 isCStr7 &= (V & 128) == 0;
2255 AbbrevToUse = CString6Abbrev;
2257 AbbrevToUse = CString7Abbrev;
2259 dyn_cast<ConstantDataSequential>(C)) {
2261 Type *EltTy = CDS->getType()->getElementType();
2262 if (isa<IntegerType>(EltTy)) {
2263 for (
unsigned i = 0, e = CDS->getNumElements();
i != e; ++
i)
2264 Record.
push_back(CDS->getElementAsInteger(
i));
2266 for (
unsigned i = 0, e = CDS->getNumElements();
i != e; ++
i)
2268 CDS->getElementAsAPFloat(
i).bitcastToAPInt().getLimitedValue());
2270 }
else if (isa<ConstantAggregate>(C)) {
2274 AbbrevToUse = AggregateAbbrev;
2275 }
else if (
const ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
2276 switch (
CE->getOpcode()) {
2283 AbbrevToUse = CONSTANTS_CE_CAST_Abbrev;
2285 assert(
CE->getNumOperands() == 2 &&
"Unknown constant expr!");
2295 case Instruction::GetElementPtr: {
2297 const auto *GO = cast<GEPOperator>(
C);
2298 Record.
push_back(VE.getTypeID(GO->getSourceElementType()));
2301 Record.
push_back((*Idx << 1) | GO->isInBounds());
2302 }
else if (GO->isInBounds())
2304 for (
unsigned i = 0, e =
CE->getNumOperands();
i != e; ++
i) {
2316 case Instruction::ExtractElement:
2323 case Instruction::InsertElement:
2330 case Instruction::ShuffleVector:
2345 case Instruction::ICmp:
2346 case Instruction::FCmp:
2354 }
else if (
const BlockAddress *BA = dyn_cast<BlockAddress>(C)) {
2356 Record.
push_back(VE.getTypeID(BA->getFunction()->getType()));
2357 Record.
push_back(VE.getValueID(BA->getFunction()));
2358 Record.
push_back(VE.getGlobalBasicBlockID(BA->getBasicBlock()));
2365 Stream.
EmitRecord(Code, Record, AbbrevToUse);
2372 void ModuleBitcodeWriter::writeModuleConstants() {
2377 for (
unsigned i = 0, e = Vals.size();
i != e; ++
i) {
2378 if (!isa<GlobalValue>(Vals[
i].first)) {
2379 writeConstants(
i, Vals.size(),
true);
2393 bool ModuleBitcodeWriter::pushValueAndType(
const Value *V,
unsigned InstID,
2395 unsigned ValID = VE.getValueID(V);
2398 if (ValID >= InstID) {
2414 for (
auto &Input : Bundle.Inputs)
2415 pushValueAndType(Input, InstID, Record);
2424 void ModuleBitcodeWriter::pushValue(
const Value *V,
unsigned InstID,
2426 unsigned ValID = VE.getValueID(V);
2430 void ModuleBitcodeWriter::pushValueSigned(
const Value *V,
unsigned InstID,
2432 unsigned ValID = VE.getValueID(V);
2433 int64_t diff = ((int32_t)InstID - (int32_t)ValID);
2438 void ModuleBitcodeWriter::writeInstruction(
const Instruction &
I,
2442 unsigned AbbrevToUse = 0;
2443 VE.setInstructionID(&I);
2449 AbbrevToUse = FUNCTION_INST_CAST_ABBREV;
2453 assert(isa<BinaryOperator>(I) &&
"Unknown instruction!");
2456 AbbrevToUse = FUNCTION_INST_BINOP_ABBREV;
2461 if (AbbrevToUse == FUNCTION_INST_BINOP_ABBREV)
2462 AbbrevToUse = FUNCTION_INST_BINOP_FLAGS_ABBREV;
2468 case Instruction::GetElementPtr: {
2470 AbbrevToUse = FUNCTION_INST_GEP_ABBREV;
2471 auto &GEPInst = cast<GetElementPtrInst>(
I);
2473 Vals.
push_back(VE.getTypeID(GEPInst.getSourceElementType()));
2478 case Instruction::ExtractValue: {
2482 Vals.
append(EVI->idx_begin(), EVI->idx_end());
2485 case Instruction::InsertValue: {
2490 Vals.
append(IVI->idx_begin(), IVI->idx_end());
2499 case Instruction::ExtractElement:
2504 case Instruction::InsertElement:
2510 case Instruction::ShuffleVector:
2516 case Instruction::ICmp:
2517 case Instruction::FCmp: {
2522 Vals.
push_back(cast<CmpInst>(I).getPredicate());
2533 if (NumOperands == 0)
2534 AbbrevToUse = FUNCTION_INST_RET_VOID_ABBREV;
2535 else if (NumOperands == 1) {
2537 AbbrevToUse = FUNCTION_INST_RET_VAL_ABBREV;
2539 for (
unsigned i = 0, e = NumOperands;
i != e; ++
i)
2544 case Instruction::Br:
2563 Vals.
push_back(VE.getValueID(Case.getCaseValue()));
2564 Vals.
push_back(VE.getValueID(Case.getCaseSuccessor()));
2568 case Instruction::IndirectBr:
2577 case Instruction::Invoke: {
2583 writeOperandBundles(II, InstID);
2592 pushValueAndType(Callee, InstID, Vals);
2606 case Instruction::Resume:
2610 case Instruction::CleanupRet: {
2612 const auto &CRI = cast<CleanupReturnInst>(
I);
2613 pushValue(CRI.getCleanupPad(), InstID,
Vals);
2614 if (CRI.hasUnwindDest())
2615 Vals.
push_back(VE.getValueID(CRI.getUnwindDest()));
2618 case Instruction::CatchRet: {
2620 const auto &CRI = cast<CatchReturnInst>(
I);
2621 pushValue(CRI.getCatchPad(), InstID,
Vals);
2622 Vals.
push_back(VE.getValueID(CRI.getSuccessor()));
2625 case Instruction::CleanupPad:
2626 case Instruction::CatchPad: {
2627 const auto &FuncletPad = cast<FuncletPadInst>(
I);
2630 pushValue(FuncletPad.getParentPad(), InstID,
Vals);
2632 unsigned NumArgOperands = FuncletPad.getNumArgOperands();
2634 for (
unsigned Op = 0;
Op != NumArgOperands; ++
Op)
2635 pushValueAndType(FuncletPad.getArgOperand(
Op), InstID,
Vals);
2638 case Instruction::CatchSwitch: {
2640 const auto &CatchSwitch = cast<CatchSwitchInst>(
I);
2642 pushValue(CatchSwitch.getParentPad(), InstID,
Vals);
2644 unsigned NumHandlers = CatchSwitch.getNumHandlers();
2646 for (
const BasicBlock *CatchPadBB : CatchSwitch.handlers())
2647 Vals.
push_back(VE.getValueID(CatchPadBB));
2649 if (CatchSwitch.hasUnwindDest())
2650 Vals.
push_back(VE.getValueID(CatchSwitch.getUnwindDest()));
2653 case Instruction::Unreachable:
2655 AbbrevToUse = FUNCTION_INST_UNREACHABLE_ABBREV;
2658 case Instruction::PHI: {
2659 const PHINode &PN = cast<PHINode>(
I);
2671 Stream.
EmitRecord(Code, Vals64, AbbrevToUse);
2676 case Instruction::LandingPad: {
2692 case Instruction::Alloca: {
2700 "not enough bits for maximum alignment");
2701 assert(AlignRecord < 1 << 5 &&
"alignment greater than 1 << 64");
2703 AlignRecord |= 1 << 6;
2710 if (cast<LoadInst>(I).
isAtomic()) {
2716 AbbrevToUse = FUNCTION_INST_LOAD_ABBREV;
2721 if (cast<LoadInst>(I).
isAtomic()) {
2735 if (cast<StoreInst>(I).
isAtomic()) {
2740 case Instruction::AtomicCmpXchg:
2754 case Instruction::AtomicRMW:
2765 case Instruction::Fence:
2775 writeOperandBundles(&CI, InstID);
2795 for (
unsigned i = 0, e = FTy->getNumParams();
i != e; ++
i) {
2797 if (FTy->getParamType(
i)->isLabelTy())
2804 if (FTy->isVarArg()) {
2811 case Instruction::VAArg:
2826 void ModuleBitcodeWriter::writeValueSymbolTable(
2833 assert(!IsModuleLevel || !hasVSTOffsetPlaceholder());
2837 if (IsModuleLevel && hasVSTOffsetPlaceholder()) {
2842 VSTOffset -= bitcodeStartBit();
2843 assert((VSTOffset & 31) == 0 &&
"VST block not 32-bit aligned");
2847 Stream.
BackpatchWord(VSTOffsetPlaceholder, VSTOffset / 32 + 1);
2854 unsigned FnEntry8BitAbbrev;
2855 unsigned FnEntry7BitAbbrev;
2856 unsigned FnEntry6BitAbbrev;
2857 unsigned GUIDEntryAbbrev;
2858 if (IsModuleLevel && hasVSTOffsetPlaceholder()) {
2860 auto Abbv = std::make_shared<BitCodeAbbrev>();
2866 FnEntry8BitAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
2869 Abbv = std::make_shared<BitCodeAbbrev>();
2875 FnEntry7BitAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
2878 Abbv = std::make_shared<BitCodeAbbrev>();
2884 FnEntry6BitAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
2888 Abbv = std::make_shared<BitCodeAbbrev>();
2892 GUIDEntryAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
2904 unsigned AbbrevToUse = VST_ENTRY_8_ABBREV;
2912 if (GA && GA->getBaseObject())
2913 F = dyn_cast<Function>(GA->getBaseObject());
2920 if (isa<BasicBlock>(
Name.getValue())) {
2923 AbbrevToUse = VST_BBENTRY_6_ABBREV;
2928 assert(FunctionToBitcodeIndex);
2929 assert(hasVSTOffsetPlaceholder());
2933 uint64_t BitcodeIndex = (*FunctionToBitcodeIndex)[
F] - bitcodeStartBit();
2934 assert((BitcodeIndex & 31) == 0 &&
"function block not 32-bit aligned");
2938 NameVals.
push_back(BitcodeIndex / 32 + 1);
2941 AbbrevToUse = FnEntry8BitAbbrev;
2943 AbbrevToUse = FnEntry6BitAbbrev;
2945 AbbrevToUse = FnEntry7BitAbbrev;
2949 AbbrevToUse = VST_ENTRY_6_ABBREV;
2951 AbbrevToUse = VST_ENTRY_7_ABBREV;
2954 for (
const auto P :
Name.getKey())
2958 Stream.
EmitRecord(Code, NameVals, AbbrevToUse);
2963 if (IsModuleLevel && hasVSTOffsetPlaceholder())
2964 for (
const auto &GI : valueIds()) {
2976 void IndexBitcodeWriter::writeCombinedValueSymbolTable() {
2977 assert(hasVSTOffsetPlaceholder() &&
"Expected non-zero VSTOffsetPlaceholder");
2981 assert((VSTOffset & 31) == 0 &&
"VST block not 32-bit aligned");
2986 auto Abbv = std::make_shared<BitCodeAbbrev>();
2990 unsigned EntryAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
2993 for (
const auto &GVI : valueIds()) {
3005 void ModuleBitcodeWriter::writeUseList(
UseListOrder &&Order) {
3006 assert(Order.Shuffle.size() >= 2 &&
"Shuffle too small");
3008 if (isa<BasicBlock>(Order.V))
3014 Record.
push_back(VE.getValueID(Order.V));
3018 void ModuleBitcodeWriter::writeUseListBlock(
const Function *F) {
3019 assert(VE.shouldPreserveUseListOrder() &&
3020 "Expected to be preserving use-list order");
3022 auto hasMore = [&]() {
3023 return !VE.UseListOrders.empty() && VE.UseListOrders.back().F ==
F;
3031 writeUseList(std::move(VE.UseListOrders.back()));
3032 VE.UseListOrders.pop_back();
3038 void ModuleBitcodeWriter::writeFunction(
3046 VE.incorporateFunction(F);
3052 Vals.
push_back(VE.getBasicBlocks().size());
3057 unsigned CstStart, CstEnd;
3058 VE.getFunctionConstantRange(CstStart, CstEnd);
3059 writeConstants(CstStart, CstEnd,
false);
3062 writeFunctionMetadata(F);
3065 unsigned InstID = CstEnd;
3074 writeInstruction(*I, InstID, Vals);
3095 Vals.
push_back(VE.getMetadataOrNullID(DL->getScope()));
3096 Vals.
push_back(VE.getMetadataOrNullID(DL->getInlinedAt()));
3105 writeValueSymbolTable(*Symtab);
3107 if (NeedsMetadataAttachment)
3108 writeFunctionMetadataAttachment(F);
3109 if (VE.shouldPreserveUseListOrder())
3110 writeUseListBlock(&F);
3116 void ModuleBitcodeWriter::writeBlockInfo() {
3123 auto Abbv = std::make_shared<BitCodeAbbrev>();
3134 auto Abbv = std::make_shared<BitCodeAbbrev>();
3144 auto Abbv = std::make_shared<BitCodeAbbrev>();
3154 auto Abbv = std::make_shared<BitCodeAbbrev>();
3160 VST_BBENTRY_6_ABBREV)
3167 auto Abbv = std::make_shared<BitCodeAbbrev>();
3170 VE.computeBitsRequiredForTypeIndicies()));
3172 CONSTANTS_SETTYPE_ABBREV)
3177 auto Abbv = std::make_shared<BitCodeAbbrev>();
3181 CONSTANTS_INTEGER_ABBREV)
3186 auto Abbv = std::make_shared<BitCodeAbbrev>();
3190 VE.computeBitsRequiredForTypeIndicies()));
3194 CONSTANTS_CE_CAST_Abbrev)
3198 auto Abbv = std::make_shared<BitCodeAbbrev>();
3201 CONSTANTS_NULL_Abbrev)
3208 auto Abbv = std::make_shared<BitCodeAbbrev>();
3212 VE.computeBitsRequiredForTypeIndicies()));
3216 FUNCTION_INST_LOAD_ABBREV)
3220 auto Abbv = std::make_shared<BitCodeAbbrev>();
3226 FUNCTION_INST_BINOP_ABBREV)
3230 auto Abbv = std::make_shared<BitCodeAbbrev>();
3237 FUNCTION_INST_BINOP_FLAGS_ABBREV)
3241 auto Abbv = std::make_shared<BitCodeAbbrev>();
3245 VE.computeBitsRequiredForTypeIndicies()));
3248 FUNCTION_INST_CAST_ABBREV)
3253 auto Abbv = std::make_shared<BitCodeAbbrev>();
3256 FUNCTION_INST_RET_VOID_ABBREV)
3260 auto Abbv = std::make_shared<BitCodeAbbrev>();
3264 FUNCTION_INST_RET_VAL_ABBREV)
3268 auto Abbv = std::make_shared<BitCodeAbbrev>();
3271 FUNCTION_INST_UNREACHABLE_ABBREV)
3275 auto Abbv = std::make_shared<BitCodeAbbrev>();
3283 FUNCTION_INST_GEP_ABBREV)
3292 void IndexBitcodeWriter::writeModStrings() {
3298 auto Abbv = std::make_shared<BitCodeAbbrev>();
3303 unsigned Abbrev8Bit = Stream.
EmitAbbrev(std::move(Abbv));
3306 Abbv = std::make_shared<BitCodeAbbrev>();
3311 unsigned Abbrev7Bit = Stream.
EmitAbbrev(std::move(Abbv));
3314 Abbv = std::make_shared<BitCodeAbbrev>();
3319 unsigned Abbrev6Bit = Stream.
EmitAbbrev(std::move(Abbv));
3322 Abbv = std::make_shared<BitCodeAbbrev>();
3329 unsigned AbbrevHash = Stream.
EmitAbbrev(std::move(Abbv));
3333 if (!doIncludeModule(MPSE.getKey()))
3337 unsigned AbbrevToUse = Abbrev8Bit;
3339 AbbrevToUse = Abbrev6Bit;
3341 AbbrevToUse = Abbrev7Bit;
3345 for (
const auto P : MPSE.getKey())
3353 auto &
Hash = MPSE.getValue().second;
3354 bool AllZero =
true;
3355 for (
auto Val :
Hash) {
3371 void ModuleBitcodeWriter::writePerModuleFunctionSummaryRecord(
3373 unsigned ValueID,
unsigned FSCallsAbbrev,
unsigned FSCallsProfileAbbrev,
3385 for (
auto &RI : FS->
refs())
3386 NameVals.
push_back(VE.getValueID(RI.getValue()));
3389 for (
auto &ECI : FS->
calls()) {
3390 NameVals.
push_back(getValueId(ECI.first));
3392 NameVals.
push_back(static_cast<uint8_t>(ECI.second.Hotness));
3395 unsigned FSAbbrev = (HasProfileData ? FSCallsProfileAbbrev : FSCallsAbbrev);
3406 void ModuleBitcodeWriter::writeModuleLevelReferences(
3408 unsigned FSModRefsAbbrev) {
3411 if (Summaries == Index->
end()) {
3417 auto *Summary = Summaries->second.front().get();
3422 unsigned SizeBeforeRefs = NameVals.
size();
3423 for (
auto &RI : VS->
refs())
3424 NameVals.
push_back(VE.getValueID(RI.getValue()));
3427 std::sort(NameVals.
begin() + SizeBeforeRefs, NameVals.
end());
3441 void ModuleBitcodeWriter::writePerModuleGlobalValueSummary() {
3446 if (Index->
begin() == Index->
end()) {
3452 auto Abbv = std::make_shared<BitCodeAbbrev>();
3461 unsigned FSCallsAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
3464 Abbv = std::make_shared<BitCodeAbbrev>();
3473 unsigned FSCallsProfileAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
3476 Abbv = std::make_shared<BitCodeAbbrev>();
3482 unsigned FSModRefsAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
3485 Abbv = std::make_shared<BitCodeAbbrev>();
3490 unsigned FSAliasAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
3503 if (Summaries == Index->
end()) {
3509 auto *Summary = Summaries->second.front().get();
3510 writePerModuleFunctionSummaryRecord(NameVals, Summary, VE.getValueID(&F),
3511 FSCallsAbbrev, FSCallsProfileAbbrev,
F);
3517 writeModuleLevelReferences(
G, NameVals, FSModRefsAbbrev);
3520 auto *Aliasee = A.getBaseObject();
3521 if (!Aliasee->hasName())
3524 auto AliasId = VE.getValueID(&A);
3525 auto AliaseeId = VE.getValueID(Aliasee);
3539 void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
3544 auto Abbv = std::make_shared<BitCodeAbbrev>();
3554 unsigned FSCallsAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
3557 Abbv = std::make_shared<BitCodeAbbrev>();
3567 unsigned FSCallsProfileAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
3570 Abbv = std::make_shared<BitCodeAbbrev>();
3577 unsigned FSModRefsAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
3580 Abbv = std::make_shared<BitCodeAbbrev>();
3586 unsigned FSAliasAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
3602 NameVals.
push_back(S.getOriginalName());
3607 for (
const auto &I : *
this) {
3611 assert(hasValueId(I.first));
3612 unsigned ValueId = getValueId(I.first);
3613 SummaryToValueIdMap[S] = ValueId;
3615 if (
auto *AS = dyn_cast<AliasSummary>(S)) {
3622 if (
auto *VS = dyn_cast<GlobalVarSummary>(S)) {
3626 for (
auto &RI : VS->
refs()) {
3627 NameVals.
push_back(getValueId(RI.getGUID()));
3634 MaybeEmitOriginalName(*S);
3638 auto *FS = cast<FunctionSummary>(S);
3648 for (
auto &RI : FS->
refs()) {
3649 NameVals.
push_back(getValueId(RI.getGUID()));
3652 bool HasProfileData =
false;
3653 for (
auto &EI : FS->
calls()) {
3659 for (
auto &EI : FS->
calls()) {
3662 if (!hasValueId(EI.first.getGUID()))
3664 NameVals.
push_back(getValueId(EI.first.getGUID()));
3666 NameVals.
push_back(static_cast<uint8_t>(EI.second.Hotness));
3669 unsigned FSAbbrev = (HasProfileData ? FSCallsProfileAbbrev : FSCallsAbbrev);
3676 MaybeEmitOriginalName(*S);
3679 for (
auto *AS : Aliases) {
3680 auto AliasValueId = SummaryToValueIdMap[AS];
3685 auto AliaseeValueId = SummaryToValueIdMap[&AS->getAliasee()];
3692 MaybeEmitOriginalName(*AS);
3704 auto Abbv = std::make_shared<BitCodeAbbrev>();
3708 auto StringAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
3710 "LLVM" LLVM_VERSION_STRING, StringAbbrev);
3713 Abbv = std::make_shared<BitCodeAbbrev>();
3716 auto EpochAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
3722 void ModuleBitcodeWriter::writeModuleHash(
size_t BlockStartPos) {
3727 Buffer.
size() - BlockStartPos));
3730 for (
int Pos = 0; Pos < 20; Pos += 4) {
3742 size_t BlockStartPos = Buffer.
size();
3745 unsigned CurVersion = 1;
3753 writeAttributeGroupTable();
3756 writeAttributeTable();
3768 writeModuleConstants();
3771 writeModuleMetadataKinds();
3774 writeModuleMetadata();
3777 if (VE.shouldPreserveUseListOrder())
3778 writeUseListBlock(
nullptr);
3780 writeOperandBundleTags();
3786 writeFunction(*F, FunctionToBitcodeIndex);
3791 writePerModuleGlobalValueSummary();
3793 writeValueSymbolTable(M.getValueSymbolTable(),
3794 true, &FunctionToBitcodeIndex);
3797 writeModuleHash(BlockStartPos);
3831 DARWIN_CPU_ARCH_ABI64 = 0x01000000,
3832 DARWIN_CPU_TYPE_X86 = 7,
3833 DARWIN_CPU_TYPE_ARM = 12,
3834 DARWIN_CPU_TYPE_POWERPC = 18
3839 CPUType = DARWIN_CPU_TYPE_X86 | DARWIN_CPU_ARCH_ABI64;
3841 CPUType = DARWIN_CPU_TYPE_X86;
3843 CPUType = DARWIN_CPU_TYPE_POWERPC;
3845 CPUType = DARWIN_CPU_TYPE_POWERPC | DARWIN_CPU_ARCH_ABI64;
3847 CPUType = DARWIN_CPU_TYPE_ARM;
3851 "Expected header size to be reserved");
3856 unsigned Position = 0;
3864 while (Buffer.
size() & 15)
3871 Stream.
Emit((
unsigned)
'B', 8);
3872 Stream.
Emit((
unsigned)
'C', 8);
3873 Stream.
Emit(0x0, 4);
3874 Stream.
Emit(0xC, 4);
3875 Stream.
Emit(0xE, 4);
3876 Stream.
Emit(0xD, 4);
3887 bool ShouldPreserveUseListOrder,
3889 bool GenerateHash) {
3890 ModuleBitcodeWriter ModuleWriter(
3891 M, Buffer, *Stream, ShouldPreserveUseListOrder, Index, GenerateHash);
3892 ModuleWriter.write();
3898 bool ShouldPreserveUseListOrder,
3900 bool GenerateHash) {
3907 if (TT.isOSDarwin() || TT.isOSBinFormatMachO())
3911 Writer.
writeModule(M, ShouldPreserveUseListOrder, Index, GenerateHash);
3913 if (TT.isOSDarwin() || TT.isOSBinFormatMachO())
3924 unsigned CurVersion = 1;
3929 writeValueSymbolTableForwardDecl();
3935 writeCombinedGlobalValueSummary();
3939 writeCombinedValueSymbolTable();
3950 const std::map<std::string, GVSummaryMapTy> *ModuleToSummariesForIndex) {
3957 IndexBitcodeWriter IndexWriter(Stream, Index, ModuleToSummariesForIndex);
3958 IndexWriter.write();
MDString * getRawGetterName() const
AttributeSet getAttributes() const
Return the parameter attributes for this call.
void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * >> &MDs) const
Appends all attachments for the global to MDs, sorting by attachment ID.
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type (if unknown returns 0).
constexpr bool isUInt< 32 >(uint64_t x)
const Value * getCalledValue() const
Get a pointer to the function that is invoked by this instruction.
void push_back(const T &Elt)
unsigned Log2_32_Ceil(uint32_t Value)
Log2_32_Ceil - This function returns the ceil log base 2 of the specified value, 32 if the value is z...
const_iterator end(StringRef path)
Get end iterator over path.
LinkageTypes getLinkage() const
This class provides a symbol table of name/value pairs.
Special purpose, only applies to global arrays.
VisibilityTypes getVisibility() const
*p = old <signed v ? old : v
iterator_range< CaseIt > cases()
Iteration adapter for range-for loops.
DILocalScope * getScope() const
unsigned getNumOperandBundles() const
static void writeDIBasicType(raw_ostream &Out, const DIBasicType *N, TypePrinting *, SlotTracker *, const Module *)
static uint64_t getOptimizationFlags(const Value *V)
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
AttributeSet getAttributes() const
Return the parameter attributes for this invoke.
bool isOpaque() const
Return true if this is a type with an identity that has no body specified yet.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
unsigned Linkage
The linkage type of the associated global value.
DITypeRef getType() const
A Module instance is used to store all the information related to an LLVM module. ...
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
unsigned getNumParams() const
Return the number of fixed parameters this function type requires.
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
uint32_t getAlignInBits() const
2: 32-bit floating point type
Same, but only replaced by something equivalent.
Global variable summary information to aid decisions and implementation of importing.
static unsigned getEncodedThreadLocalMode(const GlobalValue &GV)
DILocalScope * getScope() const
Get the local scope for this variable.
unsigned getNumOperands() const
Available for inspection, not emission.
MDString * getRawName() const
unsigned getNumOperands() const
Return number of MDNode operands.
static void writeDISubrange(raw_ostream &Out, const DISubrange *N, TypePrinting *, SlotTracker *, const Module *)
UnnamedAddr getUnnamedAddr() const
DIMacroNodeArray getElements() const
This class represents a function call, abstracting a target machine's calling convention.
uint64_t getValueAsInt() const
Return the attribute's value as an integer.
*p = old <unsigned v ? old : v
Like Internal, but omit from symbol table.
*p = old >unsigned v ? old : v
Externally visible function.
const unsigned char * bytes_end() const
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
iterator begin(unsigned Slot) const
The data referenced by the COMDAT must be the same size.
const_iterator begin(StringRef path)
Get begin iterator over path.
static void writeDIMacroFile(raw_ostream &Out, const DIMacroFile *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
void write32le(void *P, uint32_t V)
bool getSplitDebugInlining() const
DITypeRef getBaseType() const
const GlobalValue * getValue() const
Accessor for GlobalValue* value.
The two locations do not alias at all.
4: 80-bit floating point type (X87)
A class that wrap the SHA1 algorithm.
unsigned getAddressSpace() const
Return the address space of the Pointer type.
1: 16-bit floating point type
DIScope * getScope() const
std::vector< std::pair< const Value *, unsigned > > ValueList
static void writeDILocation(raw_ostream &Out, const DILocation *DL, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
static void writeDITemplateTypeParameter(raw_ostream &Out, const DITemplateTypeParameter *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
Type * getElementType() const
void reserve(size_type N)
static void writeDILocalVariable(raw_ostream &Out, const DILocalVariable *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
*p = old >signed v ? old : v
static unsigned getEncodedRMWOperation(AtomicRMWInst::BinOp Op)
const std::string & getTargetTriple() const
Get the target triple which is a string describing the target host.
GlobalValueSummaryMapTy::const_iterator const_gvsummary_iterator
Type used for iterating through the global value summary map.
unsigned getColumn() const
static void emitDarwinBCHeaderAndTrailer(SmallVectorImpl< char > &Buffer, const Triple &TT)
If generating a bc file on darwin, we have to emit a header and trailer to make it compatible with th...
static bool isLocalLinkage(LinkageTypes Linkage)
uint64_t getDWOId() const
MDString * getRawName() const
uint64_t GetCurrentBitNo() const
Retrieve the current position in the stream, in bits.
static const uint64_t INDEX_VERSION
StringRef getName() const
Return a constant reference to the value's name.
MDString * getRawName() const
MDString * getRawDirectory() const
element_iterator element_end() const
The address of a basic block.
StringRef getKindAsString() const
Return the attribute's kind as a string.
unsigned NotEligibleToImport
Indicate if the global value cannot be imported (e.g.
DIScope * getScope() const
struct fuzzer::@269 Flags
Type::subtype_iterator element_iterator
uint32_t read32be(const void *P)
GVFlags flags()
Get the flags for this GlobalValue (see struct GVFlags).
Class to represent struct types.
MDString * getRawName() const
void BackpatchWord(uint64_t BitNo, unsigned NewWord)
Backpatch a 32-bit word in the output at the given bit offset with the specified value.
unsigned getNumArgOperands() const
Return the number of call arguments.
DINodeArray getElements() const
const Value * getCalledValue() const
Get a pointer to the function that is invoked by this instruction.
static unsigned getEncodedBinaryOpcode(unsigned Opcode)
bool isLiteral() const
Return true if this type is uniqued by structural equivalence, false if it is a struct definition...
No attributes have been set.
void Emit(uint32_t Val, unsigned NumBits)
void EnterBlockInfoBlock()
EnterBlockInfoBlock - Start emitting the BLOCKINFO_BLOCK.
The linker may choose any COMDAT.
MDString * getRawFlags() const
bool isMustTailCall() const
Windows NT (Windows on ARM)
element_iterator element_begin() const
static void writeGenericDINode(raw_ostream &Out, const GenericDINode *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
unsigned getMacinfoType() const
bool getExportSymbols() const
static const unsigned MaximumAlignment
StringRef result()
Return a reference to the current raw 160-bits SHA1 for the digested data since the last call to init...
DITypeRefArray getTypeArray() const
static void writeDIGlobalVariableExpression(raw_ostream &Out, const DIGlobalVariableExpression *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
LLVM_NODISCARD bool empty() const
AtomicOrdering
Atomic ordering for LLVM's memory model.
uint64_t getModuleId(const StringRef ModPath) const
Get the module ID recorded for the given module path.
static void writeDIFile(raw_ostream &Out, const DIFile *N, TypePrinting *, SlotTracker *, const Module *)
unsigned instCount() const
Get the instruction count recorded for this function.
A constant value that is initialized with an expression using other constant values.
Class to represent function types.
static unsigned getAlignment(GlobalVariable *GV)
void EmitRecordWithAbbrev(unsigned Abbrev, const Container &Vals)
EmitRecordWithAbbrev - Emit a record with the specified abbreviation.
ConstantDataSequential - A vector or array constant whose element type is a simple 1/2/4/8-byte integ...
BinOp
This enumeration lists the possible modifications atomicrmw can make.
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
Class to represent array types.
BasicBlock * getSuccessor(unsigned i) const
unsigned LiveRoot
Indicate that the global value must be considered a live root for index-based liveness analysis...
const StringMap< std::pair< uint64_t, ModuleHash > > & modulePaths() const
Table of modules, containing module hash and id.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
TypeID getTypeID() const
Return the type id for the type.
DIScopeRef getScope() const
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
Optional< uint64_t > getEntryCount() const
Get the entry count for this function.
void writeIdentificationBlock(BitstreamWriter &Stream)
Create the "IDENTIFICATION_BLOCK_ID" containing a single string with the current llvm version...
MDString * getRawName() const
bool isNoTailCall() const
void EmitRecord(unsigned Code, const Container &Vals, unsigned Abbrev=0)
EmitRecord - Emit the specified record to the stream, using an abbrev if we have one to compress the ...
static void writeDINamespace(raw_ostream &Out, const DINamespace *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
element_iterator elements_begin() const
Structure to hold a use-list order.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE size_t size() const
size - Get the string size.
Class to hold module path string table and global value map, and encapsulate methods for operating on...
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
static void writeDISubprogram(raw_ostream &Out, const DISubprogram *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
DIScopeRef getScope() const
void EnterSubblock(unsigned BlockID, unsigned CodeLen)
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
bool hasOperandBundles() const
Return true if this User has any operand bundles.
Type * getElementType() const
size_t size() const
size - Get the array size.
BasicBlock * getNormalDest() const
void update(ArrayRef< uint8_t > Data)
Digest more data.
StringRef modulePath() const
Get the path to the module containing this function.
Class to represent pointers.
DIScope * getScope() const
MDString * getRawChecksum() const
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
unsigned getNumIncomingValues() const
Return the number of incoming edges.
void append(in_iter S, in_iter E)
Append from an iterator pair.
11: Arbitrary bit width integers
MDString * getRawName() const
unsigned getRuntimeVersion() const
unsigned getRuntimeLang() const
void BackpatchWord64(uint64_t BitNo, uint64_t Val)
static ChecksumKind getChecksumKind(StringRef CSKindStr)
ExternalWeak linkage description.
Same, but only replaced by something equivalent.
unsigned getNumSlots() const
Return the number of slots used in this attribute list.
Type * getParamType(unsigned i) const
Parameter type accessors.
MDString * getRawSplitDebugFilename() const
ArrayRef< EdgeTy > calls() const
Return the list of <CalleeValueInfo, CalleeInfo> pairs.
initializer< Ty > init(const Ty &Val)
DITypeRef getType() const
element_iterator elements_end() const
No other Module may specify this COMDAT.
void writeModule(const Module *M, bool ShouldPreserveUseListOrder=false, const ModuleSummaryIndex *Index=nullptr, bool GenerateHash=false)
Write the specified module to the buffer specified at construction time.
MDString * getRawFilename() const
The landingpad instruction holds all of the information necessary to generate correct exception handl...
bool hasMetadata() const
Check if this has any metadata.
BitcodeWriter(SmallVectorImpl< char > &Buffer)
Create a BitcodeWriter that writes to Buffer.
MDString * getRawValue() const
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind)
This is an important class for using LLVM in a threaded context.
Conditional or Unconditional Branch instruction.
AttributeSet getSlotAttributes(unsigned Slot) const
Return the attributes at the given slot.
This is an important base class in LLVM.
const const_gvsummary_iterator findGlobalValueSummaryList(StringRef ValueName) const
Get the list of global value summary objects for a given value name.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
This file contains the declarations for the subclasses of Constant, which represent the different fla...
bool isLocalToUnit() const
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
APInt Or(const APInt &LHS, const APInt &RHS)
Bitwise OR function for APInt.
static unsigned getEncodedDLLStorageClass(const GlobalValue &GV)
BitCodeAbbrevOp - This describes one or more operands in an abbreviation.
unsigned getAlignment() const
Return the alignment of the memory that is being allocated by the instruction.
ConstantFP - Floating Point Values [float, double].
APInt Xor(const APInt &LHS, const APInt &RHS)
Bitwise XOR function for APInt.
static void writeDIModule(raw_ostream &Out, const DIModule *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
unsigned getSourceLanguage() const
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
A pair of DIGlobalVariable and DIExpression.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
bool isUsedWithInAlloca() const
Return true if this alloca is used as an inalloca argument to a call.
uint64_t getNumElements() const
DIMacroNodeArray getMacros() const
6: 128-bit floating point type (two 64-bits, PowerPC)
Value * getOperand(unsigned i) const
Metadata * getValue() const
uint32_t getAlignInBits() const
unsigned getEncoding() const
SelectionKind getSelectionKind() const
static StringEncoding getStringEncoding(const char *Str, unsigned StrLen)
Determine the encoding to use for the given string name and length.
uint64_t getOffsetInBits() const
The data referenced by the COMDAT must be the same.
unsigned getAttributes() const
bool isEnumAttribute() const
Return true if the attribute is an Attribute::AttrKind type.
bool empty() const
empty - Check if the array is empty.
static unsigned getEncodedCastOpcode(unsigned Opcode)
Sentinal value useful for loops.
Function and variable summary information to aid decisions and implementation of importing.
static unsigned getEncodedComdatSelectionKind(const Comdat &C)
uint64_t getElementAsInteger(unsigned i) const
If this is a sequential container of integers (of any size), return the specified element in the low ...
DINodeRef getEntity() const
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
static void writeDILexicalBlockFile(raw_ostream &Out, const DILexicalBlockFile *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
BlockMass operator*(BlockMass L, BranchProbability R)
bool isFP128Ty() const
Return true if this is 'fp128'.
FunctionType * getFunctionType() const
static void write(bool isBE, void *P, T V)
LLVMContext & getContext() const
All values hold a context through their type.
static bool isAtomic(Instruction *I)
static uint64_t rotateSign(int64_t I)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static void writeDIMacro(raw_ostream &Out, const DIMacro *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
static uint64_t getEncodedGVSummaryFlags(GlobalValueSummary::GVFlags Flags)
OperandBundleUse getOperandBundleAt(unsigned Index) const
bool isCString() const
This method returns true if the array "isString", ends with a null byte, and does not contains any ot...
Triple - Helper class for working with autoconf configuration names.
DITypeRef getType() const
FunctionType * getFunctionType() const
An imported module (C++ using directive or similar).
raw_ostream & write(unsigned char C)
CallingConv::ID getCallingConv() const
getCallingConv/setCallingConv - Get or set the calling convention of this function call...
void dump() const
Support for debugging, callable in GDB: V->dump()
DIScopeArray getRetainedTypes() const
const std::string & getModuleInlineAsm() const
Get any module-scope inline assembly blocks.
Struct to hold value either by GUID or GlobalValue*.
bool isConditional() const
unsigned EmitAbbrev(std::shared_ptr< BitCodeAbbrev > Abbv)
EmitAbbrev - This emits an abbreviation to the stream.
DIExpression * getExpression() const
ArrayRef< uint64_t > getElements() const
DIImportedEntityArray getImportedEntities() const
const MDOperand & getOperand(unsigned I) const
static void emitSignedInt64(SmallVectorImpl< uint64_t > &Vals, uint64_t V)
Iterator for intrusive lists based on ilist_node.
BasicBlock * getUnwindDest() const
bool isSwiftError() const
Return true if this alloca is used as a swifterror argument to a call.
This is the shared class of boolean and integer constants.
static void writeDIObjCProperty(raw_ostream &Out, const DIObjCProperty *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
InstrTy * getInstruction() const
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
16: SIMD 'packed' format, or other vector type
static Optional< DebugEmissionKind > getEmissionKind(StringRef Str)
static void writeStringRecord(BitstreamWriter &Stream, unsigned Code, StringRef Str, unsigned AbbrevToUse)
static void writeDITemplateValueParameter(raw_ostream &Out, const DITemplateValueParameter *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
static void writeDIGlobalVariable(raw_ostream &Out, const DIGlobalVariable *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
Keep one copy of function when linking (inline)
static void writeInt32ToBuffer(uint32_t Value, SmallVectorImpl< char > &Buffer, uint32_t &Position)
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
Attribute::AttrKind getKindAsEnum() const
Return the attribute's kind as an enum (Attribute::AttrKind).
CPUType
These values correspond to the CV_CPU_TYPE_e enumeration, and are documented here: https://msdn...
ArrayRef< GlobalValue::GUID > type_tests() const
Returns the list of type identifiers used by this function.
static void writeMDTuple(raw_ostream &Out, const MDTuple *Node, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
iterator end(unsigned Slot) const
MDString * getRawLinkageName() const
static void writeDIEnumerator(raw_ostream &Out, const DIEnumerator *N, TypePrinting *, SlotTracker *, const Module *)
static unsigned getEncodedLinkage(const GlobalValue::LinkageTypes Linkage)
bool isIntAttribute() const
Return true if the attribute is an integer attribute.
void EmitRecordWithBlob(unsigned Abbrev, const Container &Vals, StringRef Blob)
EmitRecordWithBlob - Emit the specified record to the stream, using an abbrev that includes a blob at...
Alias summary information.
static const unsigned BWH_HeaderSize
The linker will choose the largest COMDAT.
bool isNullValue() const
Return true if this is the value that would be returned by getNullValue.
static GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
ValueSymbolTable * getValueSymbolTable()
getSymbolTable() - Return the symbol table if any, otherwise nullptr.
unsigned Log2_32(uint32_t Value)
Log2_32 - This function returns the floor log base 2 of the specified value, -1 if the value is zero...
Value * getArgOperand(unsigned i) const
getArgOperand/setArgOperand - Return/set the i-th call argument.
Class to represent vector types.
Class for arbitrary precision integers.
unsigned getDiscriminator() const
DIGlobalVariableExpressionArray getGlobalVariables() const
static bool isWeak(const MCSymbolELF &Sym)
LinkageTypes
An enumeration for the kinds of linkage for global values.
void WriteIndexToFile(const ModuleSummaryIndex &Index, raw_ostream &Out, const std::map< std::string, GVSummaryMapTy > *ModuleToSummariesForIndex=nullptr)
Write the specified module summary index to the given raw output stream, where it will be written in ...
A (clang) module that has been imported by the compile unit.
static unsigned getEncodedOrdering(AtomicOrdering Ordering)
StringRef getName() const
Return the name for this struct type if it has an identity.
static unsigned getEncodedUnnamedAddr(const GlobalValue &GV)
Generic tagged DWARF-like metadata node.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
Value * getCondition() const
iterator insert(iterator I, T &&Elt)
APInt And(const APInt &LHS, const APInt &RHS)
Bitwise AND function for APInt.
ThreadLocalMode getThreadLocalMode() const
Type array for a subprogram.
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
Function to be accessible from DLL.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator end()
static void writeDISubroutineType(raw_ostream &Out, const DISubroutineType *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
Value * getCondition() const
bool isX86_FP80Ty() const
Return true if this is x86 long double.
ValID - Represents a reference of a definition of some sort with no type.
BasicBlock * getDefaultDest() const
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
DITemplateParameterArray getTemplateParams() const
void WriteBitcodeToFile(const Module *M, raw_ostream &Out, bool ShouldPreserveUseListOrder=false, const ModuleSummaryIndex *Index=nullptr, bool GenerateHash=false)
Write the specified module to the specified raw output stream.
bool isDeclaration() const
Return true if the primary definition of this global value is outside of the current translation unit...
unsigned getSlotIndex(unsigned Slot) const
Return the index for the given slot.
static void writeDIDerivedType(raw_ostream &Out, const DIDerivedType *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
static void writeDIExpression(raw_ostream &Out, const DIExpression *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
ImmutableCallSite - establish a view to a call site for examination.
static unsigned getEncodedSynchScope(SynchronizationScope SynchScope)
uint32_t getOperandBundleTagID(StringRef Tag) const
getOperandBundleTagID - Maps a bundle tag to an integer ID.
bool isCatch(unsigned Idx) const
Return 'true' if the clause and index Idx is a catch clause.
LLVM_ATTRIBUTE_ALWAYS_INLINE size_type size() const
bool empty() const
Determine if the symbol table is empty.
DIGlobalVariable * getVariable() const
unsigned getNumElements() const
Return the number of elements in the array or vector.
MDString * getRawIdentifier() const
uint64_t getSizeInBits() const
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
Keep one copy of named function when linking (weak)
Rename collisions when linking (static functions).
op_range operands() const
static bool isChar6(char C)
isChar6 - Return true if this character is legal in the Char6 encoding.
Function summary information to aid decisions and implementation of importing.
DITypeRef getVTableHolder() const
GlobalValue::GUID getGUID() const
Accessor for GUID value.
Function to be imported from DLL.
bool hasMetadataOtherThanDebugLoc() const
Return true if this instruction has metadata attached to it other than a debug location.
static void writeDICompileUnit(raw_ostream &Out, const DICompileUnit *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
3: 64-bit floating point type
StringRef getValueAsString() const
Return the attribute's value as a string.
Type * getReturnType() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
MDString * getRawName() const
const unsigned char * bytes_begin() const
static void writeDICompositeType(raw_ostream &Out, const DICompositeType *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
DICompositeTypeArray getEnumTypes() const
LLVM Value Representation.
DIDerivedType * getStaticDataMemberDeclaration() const
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
GlobalValueSummary * getGlobalValueSummary(const GlobalValue &GV, bool PerModuleIndex=true) const
Returns the first GlobalValueSummary for GV, asserting that there is only one if PerModuleIndex.
DLLStorageClassTypes getDLLStorageClass() const
bool isDefinition() const
Group flags (Linkage, NotEligibleToImport, etc.) as a bitfield.
This class implements an extremely fast bulk output stream that can only output to a stream...
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE const char * data() const
data - Get a pointer to the start of the string (which may not be null terminated).
std::vector< Type * > TypeList
ArrayRef< ValueInfo > refs() const
Return the list of values referenced by this global value definition.
std::string Hash(const Unit &U)
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
gvsummary_iterator begin()
iterator_range< global_iterator > globals()
StringRef - Represent a constant reference to a string, i.e.
MDString * getRawName() const
CallingConv::ID getCallingConv() const
getCallingConv/setCallingConv - Get or set the calling convention of this function call...
const std::string & getDataLayoutStr() const
Get the data layout string for the module's target platform.
int64_t getLowerBound() const
MDString * getRawSetterName() const
bool operator==(uint64_t V1, const APInt &V2)
static bool isVolatile(Instruction *Inst)
9: MMX vectors (64 bits, X86 specific)
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
bool isResolved() const
Check if node is fully resolved.
static GCRegistry::Add< ErlangGC > A("erlang","erlang-compatible garbage collector")
unsigned getNumArgOperands() const
Return the number of invoke arguments.
static void writeBitcodeHeader(BitstreamWriter &Stream)
Helper to write the header common to all bitcode files.
static void writeDIImportedEntity(raw_ostream &Out, const DIImportedEntity *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
MDString * getRawProducer() const
static void writeDILexicalBlock(raw_ostream &Out, const DILexicalBlock *N, TypePrinting *TypePrinter, SlotTracker *Machine, const Module *Context)
bool isVoidTy() const
Return true if this is 'void'.
an instruction to allocate memory on the stack
This instruction inserts a struct field of array element value into an aggregate value.
unsigned EmitBlockInfoAbbrev(unsigned BlockID, std::shared_ptr< BitCodeAbbrev > Abbv)
EmitBlockInfoAbbrev - Emit a DEFINE_ABBREV record for the specified BlockID.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results...
5: 128-bit floating point type (112-bit mantissa)
Basic type, like 'int' or 'float'.
static unsigned getEncodedVisibility(const GlobalValue &GV)