31#include "llvm/Config/llvm-config.h"
91 cl::desc(
"Number of metadatas above which we emit an index "
92 "to enable lazy-loading"));
95 cl::desc(
"The threshold (unit M) for flushing LLVM bitcode."));
99 cl::desc(
"Write relative block frequency to function summary "));
117 VST_BBENTRY_6_ABBREV,
121 CONSTANTS_INTEGER_ABBREV,
122 CONSTANTS_CE_CAST_Abbrev,
123 CONSTANTS_NULL_Abbrev,
127 FUNCTION_INST_UNOP_ABBREV,
128 FUNCTION_INST_UNOP_FLAGS_ABBREV,
129 FUNCTION_INST_BINOP_ABBREV,
130 FUNCTION_INST_BINOP_FLAGS_ABBREV,
131 FUNCTION_INST_CAST_ABBREV,
132 FUNCTION_INST_CAST_FLAGS_ABBREV,
133 FUNCTION_INST_RET_VOID_ABBREV,
134 FUNCTION_INST_RET_VAL_ABBREV,
135 FUNCTION_INST_UNREACHABLE_ABBREV,
136 FUNCTION_INST_GEP_ABBREV,
137 FUNCTION_DEBUG_RECORD_VALUE_ABBREV,
142class BitcodeWriterBase {
153 : Stream(Stream), StrtabBuilder(StrtabBuilder) {}
156 void writeModuleVersion();
159void BitcodeWriterBase::writeModuleVersion() {
166class ModuleBitcodeWriterBase :
public BitcodeWriterBase {
180 std::map<GlobalValue::GUID, unsigned> GUIDToValueIdMap;
183 unsigned GlobalValueId;
194 bool ShouldPreserveUseListOrder,
196 : BitcodeWriterBase(Stream, StrtabBuilder),
M(
M),
206 for (
const auto &GUIDSummaryLists : *Index)
208 for (
auto &Summary : GUIDSummaryLists.second.SummaryList)
209 if (
auto FS = dyn_cast<FunctionSummary>(
Summary.get())) {
214 for (
auto &CallEdge :
FS->calls())
215 if (!CallEdge.first.haveGVs() || !CallEdge.first.getValue())
216 assignValueId(CallEdge.first.getGUID());
222 for (
auto &RefEdge :
FS->refs())
223 if (!RefEdge.haveGVs() || !RefEdge.getValue())
224 assignValueId(RefEdge.getGUID());
229 void writePerModuleGlobalValueSummary();
232 void writePerModuleFunctionSummaryRecord(
234 unsigned ValueID,
unsigned FSCallsAbbrev,
unsigned FSCallsProfileAbbrev,
235 unsigned CallsiteAbbrev,
unsigned AllocAbbrev,
unsigned ContextIdAbbvId,
240 unsigned FSModRefsAbbrev,
241 unsigned FSModVTableRefsAbbrev);
244 GUIDToValueIdMap[ValGUID] = ++GlobalValueId;
248 const auto &VMI = GUIDToValueIdMap.find(ValGUID);
251 assert(VMI != GUIDToValueIdMap.end() &&
252 "GUID does not have assigned value Id");
258 if (!
VI.haveGVs() || !
VI.getValue())
259 return getValueId(
VI.getGUID());
263 std::map<GlobalValue::GUID, unsigned> &valueIds() {
return GUIDToValueIdMap; }
267class ModuleBitcodeWriter :
public ModuleBitcodeWriterBase {
287 : ModuleBitcodeWriterBase(
M, StrtabBuilder, Stream,
288 ShouldPreserveUseListOrder,
Index),
289 GenerateHash(GenerateHash), ModHash(ModHash),
290 BitcodeStartBit(Stream.GetCurrentBitNo()) {}
296 uint64_t bitcodeStartBit() {
return BitcodeStartBit; }
300 void writeAttributeGroupTable();
301 void writeAttributeTable();
302 void writeTypeTable();
304 void writeValueSymbolTableForwardDecl();
305 void writeModuleInfo();
310 unsigned createDILocationAbbrev();
313 unsigned createGenericDINodeAbbrev();
381 unsigned createNamedMetadataAbbrev();
383 unsigned createMetadataStringsAbbrev();
388 std::vector<unsigned> *MDAbbrevs =
nullptr,
389 std::vector<uint64_t> *IndexPos =
nullptr);
390 void writeModuleMetadata();
391 void writeFunctionMetadata(
const Function &
F);
392 void writeFunctionMetadataAttachment(
const Function &
F);
395 void writeModuleMetadataKinds();
396 void writeOperandBundleTags();
397 void writeSyncScopeNames();
398 void writeConstants(
unsigned FirstVal,
unsigned LastVal,
bool isGlobal);
399 void writeModuleConstants();
400 bool pushValueAndType(
const Value *V,
unsigned InstID,
402 bool pushValueOrMetadata(
const Value *V,
unsigned InstID,
404 void writeOperandBundles(
const CallBase &CB,
unsigned InstID);
405 void pushValue(
const Value *V,
unsigned InstID,
407 void pushValueSigned(
const Value *V,
unsigned InstID,
409 void writeInstruction(
const Instruction &
I,
unsigned InstID,
412 void writeGlobalValueSymbolTable(
415 void writeUseListBlock(
const Function *
F);
419 void writeBlockInfo();
426 unsigned getEncodedAlign(
MaybeAlign Alignment) {
return encode(Alignment); }
430class IndexBitcodeWriter :
public BitcodeWriterBase {
445 std::map<GlobalValue::GUID, unsigned> GUIDToValueIdMap;
449 std::vector<uint64_t> StackIds;
457 unsigned GlobalValueId = 0;
475 : BitcodeWriterBase(Stream, StrtabBuilder),
Index(
Index),
476 DecSummaries(DecSummaries),
477 ModuleToSummariesForIndex(ModuleToSummariesForIndex) {
481 auto RecordStackIdReference = [&](
unsigned StackIdIndex) {
486 StackIdIndicesToIndex.
insert({StackIdIndex, StackIds.size()});
488 StackIds.push_back(
Index.getStackIdAtIndex(StackIdIndex));
495 forEachSummary([&](GVInfo
I,
bool IsAliasee) {
496 GUIDToValueIdMap[
I.first] = ++GlobalValueId;
499 auto *
FS = dyn_cast<FunctionSummary>(
I.second);
505 for (
auto &CI :
FS->callsites()) {
516 if (CI.StackIdIndices.empty()) {
517 GUIDToValueIdMap[CI.Callee.getGUID()] = ++GlobalValueId;
520 for (
auto Idx : CI.StackIdIndices)
521 RecordStackIdReference(
Idx);
523 for (
auto &AI :
FS->allocs())
524 for (
auto &MIB : AI.MIBs)
525 for (
auto Idx : MIB.StackIdIndices)
526 RecordStackIdReference(
Idx);
531 using GVInfo = std::pair<GlobalValue::GUID, GlobalValueSummary *>;
536 template<
typename Functor>
537 void forEachSummary(Functor Callback) {
538 if (ModuleToSummariesForIndex) {
539 for (
auto &M : *ModuleToSummariesForIndex)
540 for (
auto &Summary :
M.second) {
541 Callback(Summary,
false);
545 if (
auto *AS = dyn_cast<AliasSummary>(
Summary.getSecond()))
546 Callback({AS->getAliaseeGUID(), &AS->getAliasee()},
true);
549 for (
auto &Summaries : Index)
550 for (
auto &Summary : Summaries.second.SummaryList)
551 Callback({Summaries.first,
Summary.get()},
false);
559 template <
typename Functor>
void forEachModule(Functor Callback) {
560 if (ModuleToSummariesForIndex) {
561 for (
const auto &M : *ModuleToSummariesForIndex) {
562 const auto &MPI =
Index.modulePaths().find(
M.first);
563 if (MPI ==
Index.modulePaths().end()) {
567 assert(ModuleToSummariesForIndex->size() == 1);
577 std::vector<StringRef> ModulePaths;
578 for (
auto &[ModPath,
_] :
Index.modulePaths())
579 ModulePaths.push_back(ModPath);
580 llvm::sort(ModulePaths.begin(), ModulePaths.end());
581 for (
auto &ModPath : ModulePaths)
582 Callback(*
Index.modulePaths().find(ModPath));
590 void writeModStrings();
591 void writeCombinedGlobalValueSummary();
594 auto VMI = GUIDToValueIdMap.find(ValGUID);
595 if (VMI == GUIDToValueIdMap.end())
600 std::map<GlobalValue::GUID, unsigned> &valueIds() {
return GUIDToValueIdMap; }
634 case Instruction::Add:
636 case Instruction::Sub:
638 case Instruction::Mul:
641 case Instruction::FDiv:
644 case Instruction::FRem:
714 case Attribute::Alignment:
716 case Attribute::AllocAlign:
718 case Attribute::AllocSize:
720 case Attribute::AlwaysInline:
722 case Attribute::Builtin:
724 case Attribute::ByVal:
726 case Attribute::Convergent:
728 case Attribute::InAlloca:
730 case Attribute::Cold:
732 case Attribute::DisableSanitizerInstrumentation:
734 case Attribute::FnRetThunkExtern:
738 case Attribute::ElementType:
740 case Attribute::HybridPatchable:
742 case Attribute::InlineHint:
744 case Attribute::InReg:
746 case Attribute::JumpTable:
748 case Attribute::MinSize:
750 case Attribute::AllocatedPointer:
752 case Attribute::AllocKind:
754 case Attribute::Memory:
756 case Attribute::NoFPClass:
758 case Attribute::Naked:
760 case Attribute::Nest:
762 case Attribute::NoAlias:
764 case Attribute::NoBuiltin:
766 case Attribute::NoCallback:
768 case Attribute::NoCapture:
770 case Attribute::NoDivergenceSource:
772 case Attribute::NoDuplicate:
774 case Attribute::NoFree:
776 case Attribute::NoImplicitFloat:
778 case Attribute::NoInline:
780 case Attribute::NoRecurse:
782 case Attribute::NoMerge:
784 case Attribute::NonLazyBind:
786 case Attribute::NonNull:
788 case Attribute::Dereferenceable:
790 case Attribute::DereferenceableOrNull:
792 case Attribute::NoRedZone:
794 case Attribute::NoReturn:
796 case Attribute::NoSync:
798 case Attribute::NoCfCheck:
800 case Attribute::NoProfile:
802 case Attribute::SkipProfile:
804 case Attribute::NoUnwind:
806 case Attribute::NoSanitizeBounds:
808 case Attribute::NoSanitizeCoverage:
810 case Attribute::NullPointerIsValid:
812 case Attribute::OptimizeForDebugging:
814 case Attribute::OptForFuzzing:
816 case Attribute::OptimizeForSize:
818 case Attribute::OptimizeNone:
820 case Attribute::ReadNone:
822 case Attribute::ReadOnly:
824 case Attribute::Returned:
826 case Attribute::ReturnsTwice:
828 case Attribute::SExt:
830 case Attribute::Speculatable:
832 case Attribute::StackAlignment:
834 case Attribute::StackProtect:
836 case Attribute::StackProtectReq:
838 case Attribute::StackProtectStrong:
840 case Attribute::SafeStack:
842 case Attribute::ShadowCallStack:
844 case Attribute::StrictFP:
846 case Attribute::StructRet:
848 case Attribute::SanitizeAddress:
850 case Attribute::SanitizeHWAddress:
852 case Attribute::SanitizeThread:
854 case Attribute::SanitizeType:
856 case Attribute::SanitizeMemory:
858 case Attribute::SanitizeNumericalStability:
860 case Attribute::SanitizeRealtime:
862 case Attribute::SanitizeRealtimeBlocking:
864 case Attribute::SpeculativeLoadHardening:
866 case Attribute::SwiftError:
868 case Attribute::SwiftSelf:
870 case Attribute::SwiftAsync:
872 case Attribute::UWTable:
874 case Attribute::VScaleRange:
876 case Attribute::WillReturn:
878 case Attribute::WriteOnly:
880 case Attribute::ZExt:
882 case Attribute::ImmArg:
884 case Attribute::SanitizeMemTag:
886 case Attribute::Preallocated:
888 case Attribute::NoUndef:
890 case Attribute::ByRef:
892 case Attribute::MustProgress:
894 case Attribute::PresplitCoroutine:
896 case Attribute::Writable:
898 case Attribute::CoroDestroyOnlyWhenComplete:
900 case Attribute::CoroElideSafe:
902 case Attribute::DeadOnUnwind:
904 case Attribute::Range:
906 case Attribute::Initializes:
908 case Attribute::NoExt:
934 unsigned NumWords =
A.getActiveWords();
935 const uint64_t *RawData =
A.getRawData();
936 for (
unsigned i = 0; i < NumWords; i++)
956void ModuleBitcodeWriter::writeAttributeGroupTable() {
957 const std::vector<ValueEnumerator::IndexAndAttrSet> &AttrGrps =
959 if (AttrGrps.empty())
return;
965 unsigned AttrListIndex = Pair.first;
968 Record.push_back(AttrListIndex);
971 if (Attr.isEnumAttribute()) {
974 }
else if (Attr.isIntAttribute()) {
977 Record.push_back(Attr.getValueAsInt());
978 }
else if (Attr.isStringAttribute()) {
989 }
else if (Attr.isTypeAttribute()) {
990 Type *Ty = Attr.getValueAsType();
991 Record.push_back(Ty ? 6 : 5);
995 }
else if (Attr.isConstantRangeAttribute()) {
1001 assert(Attr.isConstantRangeListAttribute());
1007 for (
auto &CR : Val)
1019void ModuleBitcodeWriter::writeAttributeTable() {
1021 if (
Attrs.empty())
return;
1027 for (
unsigned i :
AL.indexes()) {
1041void ModuleBitcodeWriter::writeTypeTable() {
1050 auto Abbv = std::make_shared<BitCodeAbbrev>();
1053 unsigned OpaquePtrAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
1056 Abbv = std::make_shared<BitCodeAbbrev>();
1061 unsigned FunctionAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
1064 Abbv = std::make_shared<BitCodeAbbrev>();
1069 unsigned StructAnonAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
1072 Abbv = std::make_shared<BitCodeAbbrev>();
1076 unsigned StructNameAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
1079 Abbv = std::make_shared<BitCodeAbbrev>();
1084 unsigned StructNamedAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
1087 Abbv = std::make_shared<BitCodeAbbrev>();
1091 unsigned ArrayAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
1099 for (
Type *
T : TypeList) {
1100 int AbbrevToUse = 0;
1103 switch (
T->getTypeID()) {
1130 AbbrevToUse = OpaquePtrAbbrev;
1139 for (
unsigned i = 0, e = FT->getNumParams(); i != e; ++i)
1141 AbbrevToUse = FunctionAbbrev;
1149 for (
Type *ET :
ST->elements())
1152 if (
ST->isLiteral()) {
1154 AbbrevToUse = StructAnonAbbrev;
1156 if (
ST->isOpaque()) {
1160 AbbrevToUse = StructNamedAbbrev;
1164 if (!
ST->getName().empty())
1174 TypeVals.
push_back(AT->getNumElements());
1176 AbbrevToUse = ArrayAbbrev;
1185 TypeVals.
push_back(VT->getElementCount().getKnownMinValue());
1187 if (isa<ScalableVectorType>(VT))
1197 for (
Type *InnerTy :
TET->type_params())
1199 for (
unsigned IntParam :
TET->int_params())
1208 Stream.
EmitRecord(Code, TypeVals, AbbrevToUse);
1249 RawFlags |= Flags.ReadNone;
1250 RawFlags |= (Flags.ReadOnly << 1);
1251 RawFlags |= (Flags.NoRecurse << 2);
1252 RawFlags |= (Flags.ReturnDoesNotAlias << 3);
1253 RawFlags |= (Flags.NoInline << 4);
1254 RawFlags |= (Flags.AlwaysInline << 5);
1255 RawFlags |= (Flags.NoUnwind << 6);
1256 RawFlags |= (Flags.MayThrow << 7);
1257 RawFlags |= (Flags.HasUnknownCall << 8);
1258 RawFlags |= (Flags.MustBeUnreachable << 9);
1265 bool ImportAsDecl =
false) {
1268 RawFlags |= Flags.NotEligibleToImport;
1269 RawFlags |= (Flags.Live << 1);
1270 RawFlags |= (Flags.DSOLocal << 2);
1271 RawFlags |= (Flags.CanAutoHide << 3);
1276 RawFlags = (RawFlags << 4) | Flags.Linkage;
1278 RawFlags |= (Flags.Visibility << 8);
1280 unsigned ImportType = Flags.ImportType | ImportAsDecl;
1281 RawFlags |= (ImportType << 10);
1287 uint64_t RawFlags = Flags.MaybeReadOnly | (Flags.MaybeWriteOnly << 1) |
1288 (Flags.Constant << 2) | Flags.VCallVisibility << 3;
1330 case GlobalVariable::NotThreadLocal:
return 0;
1331 case GlobalVariable::GeneralDynamicTLSModel:
return 1;
1332 case GlobalVariable::LocalDynamicTLSModel:
return 2;
1333 case GlobalVariable::InitialExecTLSModel:
return 3;
1334 case GlobalVariable::LocalExecTLSModel:
return 4;
1340 switch (
C.getSelectionKind()) {
1357 case GlobalValue::UnnamedAddr::None:
return 0;
1358 case GlobalValue::UnnamedAddr::Local:
return 2;
1359 case GlobalValue::UnnamedAddr::Global:
return 1;
1364size_t ModuleBitcodeWriter::addToStrtab(
StringRef Str) {
1367 return StrtabBuilder.
add(Str);
1370void ModuleBitcodeWriter::writeComdats() {
1385void ModuleBitcodeWriter::writeValueSymbolTableForwardDecl() {
1390 auto Abbv = std::make_shared<BitCodeAbbrev>();
1396 unsigned VSTOffsetAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
1412 bool isChar6 =
true;
1413 for (
char C : Str) {
1416 if ((
unsigned char)
C & 128)
1426 "Sanitizer Metadata is too large for naive serialization.");
1429 return Meta.NoAddress | (
Meta.NoHWAddress << 1) |
1430 (
Meta.Memtag << 2) | (
Meta.IsDynInit << 3);
1436void ModuleBitcodeWriter::writeModuleInfo() {
1438 if (!
M.getTargetTriple().empty())
1441 const std::string &
DL =
M.getDataLayoutStr();
1444 if (!
M.getModuleInlineAsm().empty())
1450 std::map<std::string, unsigned> SectionMap;
1451 std::map<std::string, unsigned> GCMap;
1453 unsigned MaxGlobalType = 0;
1454 const auto UpdateMaxAlignment = [&MaxAlignment](
const MaybeAlign A) {
1456 MaxAlignment = !MaxAlignment ? *
A : std::max(*MaxAlignment, *
A);
1459 UpdateMaxAlignment(GV.getAlign());
1460 MaxGlobalType = std::max(MaxGlobalType, VE.
getTypeID(GV.getValueType()));
1461 if (GV.hasSection()) {
1463 unsigned &
Entry = SectionMap[std::string(GV.getSection())];
1467 Entry = SectionMap.size();
1472 UpdateMaxAlignment(
F.getAlign());
1473 if (
F.hasSection()) {
1475 unsigned &
Entry = SectionMap[std::string(
F.getSection())];
1479 Entry = SectionMap.size();
1484 unsigned &
Entry = GCMap[
F.getGC()];
1488 Entry = GCMap.size();
1494 unsigned SimpleGVarAbbrev = 0;
1495 if (!
M.global_empty()) {
1497 auto Abbv = std::make_shared<BitCodeAbbrev>();
1511 unsigned MaxEncAlignment = getEncodedAlign(MaxAlignment);
1515 if (SectionMap.empty())
1521 SimpleGVarAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
1535 auto Abbv = std::make_shared<BitCodeAbbrev>();
1538 Abbv->Add(AbbrevOpToUse);
1539 unsigned FilenameAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
1541 for (
const auto P :
M.getSourceFileName())
1551 unsigned AbbrevToUse = 0;
1557 Vals.
push_back(addToStrtab(GV.getName()));
1560 Vals.
push_back(GV.getType()->getAddressSpace() << 2 | 2 | GV.isConstant());
1564 Vals.
push_back(getEncodedAlign(GV.getAlign()));
1565 Vals.
push_back(GV.hasSection() ? SectionMap[std::string(GV.getSection())]
1567 if (GV.isThreadLocal() ||
1569 GV.getUnnamedAddr() != GlobalValue::UnnamedAddr::None ||
1570 GV.isExternallyInitialized() ||
1572 GV.hasComdat() || GV.hasAttributes() || GV.isDSOLocal() ||
1573 GV.hasPartition() || GV.hasSanitizerMetadata() || GV.getCodeModel()) {
1577 Vals.
push_back(GV.isExternallyInitialized());
1585 Vals.
push_back(addToStrtab(GV.getPartition()));
1586 Vals.
push_back(GV.getPartition().size());
1589 GV.getSanitizerMetadata())
1593 AbbrevToUse = SimpleGVarAbbrev;
1613 Vals.
push_back(getEncodedAlign(
F.getAlign()));
1614 Vals.
push_back(
F.hasSection() ? SectionMap[std::string(
F.getSection())]
1626 F.hasPersonalityFn() ? (VE.
getValueID(
F.getPersonalityFn()) + 1) : 0);
1630 Vals.
push_back(addToStrtab(
F.getPartition()));
1633 unsigned AbbrevToUse = 0;
1646 Vals.
push_back(
A.getType()->getAddressSpace());
1654 Vals.
push_back(addToStrtab(
A.getPartition()));
1657 unsigned AbbrevToUse = 0;
1669 Vals.
push_back(
I.getType()->getAddressSpace());
1674 Vals.
push_back(addToStrtab(
I.getPartition()));
1680 writeValueSymbolTableForwardDecl();
1686 if (
const auto *OBO = dyn_cast<OverflowingBinaryOperator>(V)) {
1687 if (OBO->hasNoSignedWrap())
1689 if (OBO->hasNoUnsignedWrap())
1691 }
else if (
const auto *PEO = dyn_cast<PossiblyExactOperator>(V)) {
1694 }
else if (
const auto *PDI = dyn_cast<PossiblyDisjointInst>(V)) {
1695 if (PDI->isDisjoint())
1697 }
else if (
const auto *FPMO = dyn_cast<FPMathOperator>(V)) {
1698 if (FPMO->hasAllowReassoc())
1700 if (FPMO->hasNoNaNs())
1702 if (FPMO->hasNoInfs())
1704 if (FPMO->hasNoSignedZeros())
1706 if (FPMO->hasAllowReciprocal())
1708 if (FPMO->hasAllowContract())
1710 if (FPMO->hasApproxFunc())
1712 }
else if (
const auto *NNI = dyn_cast<PossiblyNonNegInst>(V)) {
1713 if (NNI->hasNonNeg())
1715 }
else if (
const auto *TI = dyn_cast<TruncInst>(V)) {
1716 if (TI->hasNoSignedWrap())
1718 if (TI->hasNoUnsignedWrap())
1720 }
else if (
const auto *
GEP = dyn_cast<GEPOperator>(V)) {
1721 if (
GEP->isInBounds())
1723 if (
GEP->hasNoUnsignedSignedWrap())
1725 if (
GEP->hasNoUnsignedWrap())
1727 }
else if (
const auto *ICmp = dyn_cast<ICmpInst>(V)) {
1728 if (ICmp->hasSameSign())
1735void ModuleBitcodeWriter::writeValueAsMetadata(
1745void ModuleBitcodeWriter::writeMDTuple(
const MDTuple *
N,
1750 assert(!(MD && isa<LocalAsMetadata>(MD)) &&
1751 "Unexpected function-local metadata");
1760unsigned ModuleBitcodeWriter::createDILocationAbbrev() {
1763 auto Abbv = std::make_shared<BitCodeAbbrev>();
1774void ModuleBitcodeWriter::writeDILocation(
const DILocation *
N,
1778 Abbrev = createDILocationAbbrev();
1780 Record.push_back(
N->isDistinct());
1781 Record.push_back(
N->getLine());
1782 Record.push_back(
N->getColumn());
1785 Record.push_back(
N->isImplicitCode());
1791unsigned ModuleBitcodeWriter::createGenericDINodeAbbrev() {
1794 auto Abbv = std::make_shared<BitCodeAbbrev>();
1805void ModuleBitcodeWriter::writeGenericDINode(
const GenericDINode *
N,
1809 Abbrev = createGenericDINodeAbbrev();
1811 Record.push_back(
N->isDistinct());
1812 Record.push_back(
N->getTag());
1815 for (
auto &
I :
N->operands())
1822void ModuleBitcodeWriter::writeDISubrange(
const DISubrange *
N,
1836void ModuleBitcodeWriter::writeDIGenericSubrange(
1849void ModuleBitcodeWriter::writeDIEnumerator(
const DIEnumerator *
N,
1853 Record.push_back(IsBigInt | (
N->isUnsigned() << 1) |
N->isDistinct());
1854 Record.push_back(
N->getValue().getBitWidth());
1862void ModuleBitcodeWriter::writeDIBasicType(
const DIBasicType *
N,
1865 Record.push_back(
N->isDistinct());
1866 Record.push_back(
N->getTag());
1868 Record.push_back(
N->getSizeInBits());
1869 Record.push_back(
N->getAlignInBits());
1870 Record.push_back(
N->getEncoding());
1871 Record.push_back(
N->getFlags());
1872 Record.push_back(
N->getNumExtraInhabitants());
1878void ModuleBitcodeWriter::writeDIStringType(
const DIStringType *
N,
1881 Record.push_back(
N->isDistinct());
1882 Record.push_back(
N->getTag());
1887 Record.push_back(
N->getSizeInBits());
1888 Record.push_back(
N->getAlignInBits());
1889 Record.push_back(
N->getEncoding());
1895void ModuleBitcodeWriter::writeDIDerivedType(
const DIDerivedType *
N,
1898 Record.push_back(
N->isDistinct());
1899 Record.push_back(
N->getTag());
1902 Record.push_back(
N->getLine());
1905 Record.push_back(
N->getSizeInBits());
1906 Record.push_back(
N->getAlignInBits());
1907 Record.push_back(
N->getOffsetInBits());
1908 Record.push_back(
N->getFlags());
1913 if (
const auto &DWARFAddressSpace =
N->getDWARFAddressSpace())
1914 Record.push_back(*DWARFAddressSpace + 1);
1920 if (
auto PtrAuthData =
N->getPtrAuthData())
1921 Record.push_back(PtrAuthData->RawData);
1929void ModuleBitcodeWriter::writeDICompositeType(
1932 const unsigned IsNotUsedInOldTypeRef = 0x2;
1933 Record.push_back(IsNotUsedInOldTypeRef | (
unsigned)
N->isDistinct());
1934 Record.push_back(
N->getTag());
1937 Record.push_back(
N->getLine());
1940 Record.push_back(
N->getSizeInBits());
1941 Record.push_back(
N->getAlignInBits());
1942 Record.push_back(
N->getOffsetInBits());
1943 Record.push_back(
N->getFlags());
1945 Record.push_back(
N->getRuntimeLang());
1955 Record.push_back(
N->getNumExtraInhabitants());
1962void ModuleBitcodeWriter::writeDISubroutineType(
1965 const unsigned HasNoOldTypeRefs = 0x2;
1966 Record.push_back(HasNoOldTypeRefs | (
unsigned)
N->isDistinct());
1967 Record.push_back(
N->getFlags());
1975void ModuleBitcodeWriter::writeDIFile(
const DIFile *
N,
1978 Record.push_back(
N->isDistinct());
1981 if (
N->getRawChecksum()) {
1982 Record.push_back(
N->getRawChecksum()->Kind);
1990 auto Source =
N->getRawSource();
1998void ModuleBitcodeWriter::writeDICompileUnit(
const DICompileUnit *
N,
2001 assert(
N->isDistinct() &&
"Expected distinct compile units");
2003 Record.push_back(
N->getSourceLanguage());
2006 Record.push_back(
N->isOptimized());
2008 Record.push_back(
N->getRuntimeVersion());
2010 Record.push_back(
N->getEmissionKind());
2016 Record.push_back(
N->getDWOId());
2018 Record.push_back(
N->getSplitDebugInlining());
2019 Record.push_back(
N->getDebugInfoForProfiling());
2020 Record.push_back((
unsigned)
N->getNameTableKind());
2021 Record.push_back(
N->getRangesBaseAddress());
2029void ModuleBitcodeWriter::writeDISubprogram(
const DISubprogram *
N,
2032 const uint64_t HasUnitFlag = 1 << 1;
2033 const uint64_t HasSPFlagsFlag = 1 << 2;
2034 Record.push_back(
uint64_t(
N->isDistinct()) | HasUnitFlag | HasSPFlagsFlag);
2039 Record.push_back(
N->getLine());
2041 Record.push_back(
N->getScopeLine());
2043 Record.push_back(
N->getSPFlags());
2044 Record.push_back(
N->getVirtualIndex());
2045 Record.push_back(
N->getFlags());
2050 Record.push_back(
N->getThisAdjustment());
2062 Record.push_back(
N->isDistinct());
2065 Record.push_back(
N->getLine());
2066 Record.push_back(
N->getColumn());
2072void ModuleBitcodeWriter::writeDILexicalBlockFile(
2075 Record.push_back(
N->isDistinct());
2078 Record.push_back(
N->getDiscriminator());
2084void ModuleBitcodeWriter::writeDICommonBlock(
const DICommonBlock *
N,
2087 Record.push_back(
N->isDistinct());
2092 Record.push_back(
N->getLineNo());
2098void ModuleBitcodeWriter::writeDINamespace(
const DINamespace *
N,
2101 Record.push_back(
N->isDistinct() |
N->getExportSymbols() << 1);
2109void ModuleBitcodeWriter::writeDIMacro(
const DIMacro *
N,
2112 Record.push_back(
N->isDistinct());
2113 Record.push_back(
N->getMacinfoType());
2114 Record.push_back(
N->getLine());
2122void ModuleBitcodeWriter::writeDIMacroFile(
const DIMacroFile *
N,
2125 Record.push_back(
N->isDistinct());
2126 Record.push_back(
N->getMacinfoType());
2127 Record.push_back(
N->getLine());
2135void ModuleBitcodeWriter::writeDIArgList(
const DIArgList *
N,
2137 Record.reserve(
N->getArgs().size());
2145void ModuleBitcodeWriter::writeDIModule(
const DIModule *
N,
2148 Record.push_back(
N->isDistinct());
2149 for (
auto &
I :
N->operands())
2151 Record.push_back(
N->getLineNo());
2152 Record.push_back(
N->getIsDecl());
2158void ModuleBitcodeWriter::writeDIAssignID(
const DIAssignID *
N,
2162 Record.push_back(
N->isDistinct());
2167void ModuleBitcodeWriter::writeDITemplateTypeParameter(
2170 Record.push_back(
N->isDistinct());
2173 Record.push_back(
N->isDefault());
2179void ModuleBitcodeWriter::writeDITemplateValueParameter(
2182 Record.push_back(
N->isDistinct());
2183 Record.push_back(
N->getTag());
2186 Record.push_back(
N->isDefault());
2193void ModuleBitcodeWriter::writeDIGlobalVariable(
2202 Record.push_back(
N->getLine());
2204 Record.push_back(
N->isLocalToUnit());
2205 Record.push_back(
N->isDefinition());
2208 Record.push_back(
N->getAlignInBits());
2215void ModuleBitcodeWriter::writeDILocalVariable(
2231 const uint64_t HasAlignmentFlag = 1 << 1;
2236 Record.push_back(
N->getLine());
2238 Record.push_back(
N->getArg());
2239 Record.push_back(
N->getFlags());
2240 Record.push_back(
N->getAlignInBits());
2247void ModuleBitcodeWriter::writeDILabel(
2254 Record.push_back(
N->getLine());
2260void ModuleBitcodeWriter::writeDIExpression(
const DIExpression *
N,
2263 Record.reserve(
N->getElements().size() + 1);
2266 Record.append(
N->elements_begin(),
N->elements_end());
2272void ModuleBitcodeWriter::writeDIGlobalVariableExpression(
2275 Record.push_back(
N->isDistinct());
2286 Record.push_back(
N->isDistinct());
2289 Record.push_back(
N->getLine());
2292 Record.push_back(
N->getAttributes());
2299void ModuleBitcodeWriter::writeDIImportedEntity(
2302 Record.push_back(
N->isDistinct());
2303 Record.push_back(
N->getTag());
2306 Record.push_back(
N->getLine());
2315unsigned ModuleBitcodeWriter::createNamedMetadataAbbrev() {
2316 auto Abbv = std::make_shared<BitCodeAbbrev>();
2323void ModuleBitcodeWriter::writeNamedMetadata(
2325 if (
M.named_metadata_empty())
2328 unsigned Abbrev = createNamedMetadataAbbrev();
2332 Record.append(Str.bytes_begin(), Str.bytes_end());
2337 for (
const MDNode *
N : NMD.operands())
2344unsigned ModuleBitcodeWriter::createMetadataStringsAbbrev() {
2345 auto Abbv = std::make_shared<BitCodeAbbrev>();
2357void ModuleBitcodeWriter::writeMetadataStrings(
2359 if (Strings.empty())
2364 Record.push_back(Strings.size());
2371 W.EmitVBR(cast<MDString>(MD)->getLength(), 6);
2380 Blob.
append(cast<MDString>(MD)->getString());
2389#define HANDLE_MDNODE_LEAF(CLASS) CLASS##AbbrevID,
2390#include "llvm/IR/Metadata.def"
2394void ModuleBitcodeWriter::writeMetadataRecords(
2396 std::vector<unsigned> *MDAbbrevs, std::vector<uint64_t> *IndexPos) {
2401#define HANDLE_MDNODE_LEAF(CLASS) unsigned CLASS##Abbrev = 0;
2402#include "llvm/IR/Metadata.def"
2407 if (
const MDNode *
N = dyn_cast<MDNode>(MD)) {
2408 assert(
N->isResolved() &&
"Expected forward references to be resolved");
2410 switch (
N->getMetadataID()) {
2413#define HANDLE_MDNODE_LEAF(CLASS) \
2414 case Metadata::CLASS##Kind: \
2416 write##CLASS(cast<CLASS>(N), Record, \
2417 (*MDAbbrevs)[MetadataAbbrev::CLASS##AbbrevID]); \
2419 write##CLASS(cast<CLASS>(N), Record, CLASS##Abbrev); \
2421#include "llvm/IR/Metadata.def"
2424 if (
auto *
AL = dyn_cast<DIArgList>(MD)) {
2428 writeValueAsMetadata(cast<ValueAsMetadata>(MD),
Record);
2432void ModuleBitcodeWriter::writeModuleMetadata() {
2433 if (!VE.
hasMDs() &&
M.named_metadata_empty())
2441 std::vector<unsigned> MDAbbrevs;
2444 MDAbbrevs[MetadataAbbrev::DILocationAbbrevID] = createDILocationAbbrev();
2445 MDAbbrevs[MetadataAbbrev::GenericDINodeAbbrevID] =
2446 createGenericDINodeAbbrev();
2448 auto Abbv = std::make_shared<BitCodeAbbrev>();
2452 unsigned OffsetAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
2454 Abbv = std::make_shared<BitCodeAbbrev>();
2458 unsigned IndexAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
2480 std::vector<uint64_t> IndexPos;
2495 uint64_t PreviousValue = IndexOffsetRecordBitPos;
2496 for (
auto &Elt : IndexPos) {
2497 auto EltDelta = Elt - PreviousValue;
2498 PreviousValue = Elt;
2507 writeNamedMetadata(
Record);
2509 auto AddDeclAttachedMetadata = [&](
const GlobalObject &GO) {
2512 pushGlobalMetadataAttachment(
Record, GO);
2516 if (
F.isDeclaration() &&
F.hasMetadata())
2517 AddDeclAttachedMetadata(
F);
2521 if (GV.hasMetadata())
2522 AddDeclAttachedMetadata(GV);
2527void ModuleBitcodeWriter::writeFunctionMetadata(
const Function &
F) {
2538void ModuleBitcodeWriter::pushGlobalMetadataAttachment(
2543 for (
const auto &
I : MDs) {
2549void ModuleBitcodeWriter::writeFunctionMetadataAttachment(
const Function &
F) {
2554 if (
F.hasMetadata()) {
2555 pushGlobalMetadataAttachment(
Record,
F);
2566 I.getAllMetadataOtherThanDebugLoc(MDs);
2569 if (MDs.
empty())
continue;
2573 for (
unsigned i = 0, e = MDs.
size(); i != e; ++i) {
2574 Record.push_back(MDs[i].first);
2584void ModuleBitcodeWriter::writeModuleMetadataKinds() {
2590 M.getMDKindNames(Names);
2592 if (Names.
empty())
return;
2596 for (
unsigned MDKindID = 0, e = Names.
size(); MDKindID != e; ++MDKindID) {
2597 Record.push_back(MDKindID);
2608void ModuleBitcodeWriter::writeOperandBundleTags() {
2616 M.getOperandBundleTags(Tags);
2625 for (
auto Tag : Tags) {
2635void ModuleBitcodeWriter::writeSyncScopeNames() {
2637 M.getContext().getSyncScopeNames(SSNs);
2644 for (
auto SSN : SSNs) {
2645 Record.append(SSN.begin(), SSN.end());
2653void ModuleBitcodeWriter::writeConstants(
unsigned FirstVal,
unsigned LastVal,
2655 if (FirstVal == LastVal)
return;
2659 unsigned AggregateAbbrev = 0;
2660 unsigned String8Abbrev = 0;
2661 unsigned CString7Abbrev = 0;
2662 unsigned CString6Abbrev = 0;
2666 auto Abbv = std::make_shared<BitCodeAbbrev>();
2670 AggregateAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
2673 Abbv = std::make_shared<BitCodeAbbrev>();
2677 String8Abbrev = Stream.
EmitAbbrev(std::move(Abbv));
2679 Abbv = std::make_shared<BitCodeAbbrev>();
2683 CString7Abbrev = Stream.
EmitAbbrev(std::move(Abbv));
2685 Abbv = std::make_shared<BitCodeAbbrev>();
2689 CString6Abbrev = Stream.
EmitAbbrev(std::move(Abbv));
2695 Type *LastTy =
nullptr;
2696 for (
unsigned i = FirstVal; i != LastVal; ++i) {
2697 const Value *
V = Vals[i].first;
2699 if (
V->getType() != LastTy) {
2700 LastTy =
V->getType();
2703 CONSTANTS_SETTYPE_ABBREV);
2707 if (
const InlineAsm *IA = dyn_cast<InlineAsm>(V)) {
2710 unsigned(
IA->hasSideEffects()) |
unsigned(
IA->isAlignStack()) << 1 |
2711 unsigned(
IA->getDialect() & 1) << 2 |
unsigned(
IA->canThrow()) << 3);
2714 const std::string &AsmStr =
IA->getAsmString();
2715 Record.push_back(AsmStr.size());
2716 Record.append(AsmStr.begin(), AsmStr.end());
2719 const std::string &ConstraintStr =
IA->getConstraintString();
2720 Record.push_back(ConstraintStr.size());
2721 Record.append(ConstraintStr.begin(), ConstraintStr.end());
2727 unsigned Code = -1U;
2728 unsigned AbbrevToUse = 0;
2729 if (
C->isNullValue()) {
2731 }
else if (isa<PoisonValue>(
C)) {
2733 }
else if (isa<UndefValue>(
C)) {
2736 if (
IV->getBitWidth() <= 64) {
2740 AbbrevToUse = CONSTANTS_INTEGER_ABBREV;
2745 }
else if (
const ConstantFP *CFP = dyn_cast<ConstantFP>(
C)) {
2750 Record.push_back(CFP->getValueAPF().bitcastToAPInt().getZExtValue());
2754 APInt api = CFP->getValueAPF().bitcastToAPInt();
2756 Record.push_back((p[1] << 48) | (p[0] >> 16));
2757 Record.push_back(p[0] & 0xffffLL);
2759 APInt api = CFP->getValueAPF().bitcastToAPInt();
2764 assert(0 &&
"Unknown FP type!");
2766 }
else if (isa<ConstantDataSequential>(
C) &&
2767 cast<ConstantDataSequential>(
C)->isString()) {
2770 unsigned NumElts = Str->getNumElements();
2772 if (Str->isCString()) {
2777 AbbrevToUse = String8Abbrev;
2781 for (
unsigned i = 0; i != NumElts; ++i) {
2782 unsigned char V = Str->getElementAsInteger(i);
2784 isCStr7 &= (
V & 128) == 0;
2790 AbbrevToUse = CString6Abbrev;
2792 AbbrevToUse = CString7Abbrev;
2794 dyn_cast<ConstantDataSequential>(
C)) {
2796 Type *EltTy = CDS->getElementType();
2797 if (isa<IntegerType>(EltTy)) {
2798 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i)
2799 Record.push_back(CDS->getElementAsInteger(i));
2801 for (
unsigned i = 0, e = CDS->getNumElements(); i != e; ++i)
2803 CDS->getElementAsAPFloat(i).bitcastToAPInt().getLimitedValue());
2805 }
else if (isa<ConstantAggregate>(
C)) {
2807 for (
const Value *
Op :
C->operands())
2809 AbbrevToUse = AggregateAbbrev;
2810 }
else if (
const ConstantExpr *CE = dyn_cast<ConstantExpr>(
C)) {
2811 switch (
CE->getOpcode()) {
2818 AbbrevToUse = CONSTANTS_CE_CAST_Abbrev;
2820 assert(
CE->getNumOperands() == 2 &&
"Unknown constant expr!");
2830 case Instruction::FNeg: {
2831 assert(
CE->getNumOperands() == 1 &&
"Unknown constant expr!");
2840 case Instruction::GetElementPtr: {
2842 const auto *GO = cast<GEPOperator>(
C);
2845 if (std::optional<ConstantRange>
Range = GO->getInRange()) {
2849 for (
const Value *
Op :
CE->operands()) {
2855 case Instruction::ExtractElement:
2862 case Instruction::InsertElement:
2869 case Instruction::ShuffleVector:
2874 if (
C->getType() ==
C->getOperand(0)->getType()) {
2885 }
else if (
const BlockAddress *BA = dyn_cast<BlockAddress>(
C)) {
2890 }
else if (
const auto *Equiv = dyn_cast<DSOLocalEquivalent>(
C)) {
2894 }
else if (
const auto *
NC = dyn_cast<NoCFIValue>(
C)) {
2898 }
else if (
const auto *CPA = dyn_cast<ConstantPtrAuth>(
C)) {
2917void ModuleBitcodeWriter::writeModuleConstants() {
2922 for (
unsigned i = 0, e = Vals.size(); i != e; ++i) {
2923 if (!isa<GlobalValue>(Vals[i].first)) {
2924 writeConstants(i, Vals.size(),
true);
2938bool ModuleBitcodeWriter::pushValueAndType(
const Value *V,
unsigned InstID,
2943 if (
ValID >= InstID) {
2950bool ModuleBitcodeWriter::pushValueOrMetadata(
const Value *V,
unsigned InstID,
2952 bool IsMetadata =
V->getType()->isMetadataTy();
2955 Metadata *MD = cast<MetadataAsValue>(V)->getMetadata();
2960 return pushValueAndType(V, InstID, Vals);
2963void ModuleBitcodeWriter::writeOperandBundles(
const CallBase &CS,
2970 Record.push_back(
C.getOperandBundleTagID(Bundle.getTagName()));
2972 for (
auto &Input : Bundle.Inputs)
2973 pushValueOrMetadata(Input, InstID,
Record);
2982void ModuleBitcodeWriter::pushValue(
const Value *V,
unsigned InstID,
2988void ModuleBitcodeWriter::pushValueSigned(
const Value *V,
unsigned InstID,
2991 int64_t diff = ((int32_t)InstID - (int32_t)
ValID);
2996void ModuleBitcodeWriter::writeInstruction(
const Instruction &
I,
3000 unsigned AbbrevToUse = 0;
3002 switch (
I.getOpcode()) {
3006 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
3007 AbbrevToUse = FUNCTION_INST_CAST_ABBREV;
3012 if (AbbrevToUse == FUNCTION_INST_CAST_ABBREV)
3013 AbbrevToUse = FUNCTION_INST_CAST_FLAGS_ABBREV;
3017 assert(isa<BinaryOperator>(
I) &&
"Unknown instruction!");
3019 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
3020 AbbrevToUse = FUNCTION_INST_BINOP_ABBREV;
3021 pushValue(
I.getOperand(1), InstID, Vals);
3025 if (AbbrevToUse == FUNCTION_INST_BINOP_ABBREV)
3026 AbbrevToUse = FUNCTION_INST_BINOP_FLAGS_ABBREV;
3031 case Instruction::FNeg: {
3033 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
3034 AbbrevToUse = FUNCTION_INST_UNOP_ABBREV;
3038 if (AbbrevToUse == FUNCTION_INST_UNOP_ABBREV)
3039 AbbrevToUse = FUNCTION_INST_UNOP_FLAGS_ABBREV;
3044 case Instruction::GetElementPtr: {
3046 AbbrevToUse = FUNCTION_INST_GEP_ABBREV;
3047 auto &GEPInst = cast<GetElementPtrInst>(
I);
3050 for (
const Value *
Op :
I.operands())
3051 pushValueAndType(
Op, InstID, Vals);
3054 case Instruction::ExtractValue: {
3056 pushValueAndType(
I.getOperand(0), InstID, Vals);
3061 case Instruction::InsertValue: {
3063 pushValueAndType(
I.getOperand(0), InstID, Vals);
3064 pushValueAndType(
I.getOperand(1), InstID, Vals);
3069 case Instruction::Select: {
3071 pushValueAndType(
I.getOperand(1), InstID, Vals);
3072 pushValue(
I.getOperand(2), InstID, Vals);
3073 pushValueAndType(
I.getOperand(0), InstID, Vals);
3079 case Instruction::ExtractElement:
3081 pushValueAndType(
I.getOperand(0), InstID, Vals);
3082 pushValueAndType(
I.getOperand(1), InstID, Vals);
3084 case Instruction::InsertElement:
3086 pushValueAndType(
I.getOperand(0), InstID, Vals);
3087 pushValue(
I.getOperand(1), InstID, Vals);
3088 pushValueAndType(
I.getOperand(2), InstID, Vals);
3090 case Instruction::ShuffleVector:
3092 pushValueAndType(
I.getOperand(0), InstID, Vals);
3093 pushValue(
I.getOperand(1), InstID, Vals);
3094 pushValue(cast<ShuffleVectorInst>(
I).getShuffleMaskForBitcode(), InstID,
3097 case Instruction::ICmp:
3098 case Instruction::FCmp: {
3101 pushValueAndType(
I.getOperand(0), InstID, Vals);
3102 pushValue(
I.getOperand(1), InstID, Vals);
3110 case Instruction::Ret:
3113 unsigned NumOperands =
I.getNumOperands();
3114 if (NumOperands == 0)
3115 AbbrevToUse = FUNCTION_INST_RET_VOID_ABBREV;
3116 else if (NumOperands == 1) {
3117 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
3118 AbbrevToUse = FUNCTION_INST_RET_VAL_ABBREV;
3120 for (
const Value *
Op :
I.operands())
3121 pushValueAndType(
Op, InstID, Vals);
3125 case Instruction::Br:
3130 if (
II.isConditional()) {
3132 pushValue(
II.getCondition(), InstID, Vals);
3136 case Instruction::Switch:
3141 pushValue(
SI.getCondition(), InstID, Vals);
3143 for (
auto Case :
SI.cases()) {
3149 case Instruction::IndirectBr:
3153 pushValue(
I.getOperand(0), InstID, Vals);
3158 case Instruction::Invoke: {
3163 if (
II->hasOperandBundles())
3164 writeOperandBundles(*
II, InstID);
3173 pushValueAndType(Callee, InstID, Vals);
3176 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
3177 pushValue(
I.getOperand(i), InstID, Vals);
3180 if (FTy->isVarArg()) {
3181 for (
unsigned i = FTy->getNumParams(), e =
II->arg_size(); i != e; ++i)
3182 pushValueAndType(
I.getOperand(i), InstID, Vals);
3186 case Instruction::Resume:
3188 pushValueAndType(
I.getOperand(0), InstID, Vals);
3190 case Instruction::CleanupRet: {
3192 const auto &CRI = cast<CleanupReturnInst>(
I);
3193 pushValue(CRI.getCleanupPad(), InstID, Vals);
3194 if (CRI.hasUnwindDest())
3198 case Instruction::CatchRet: {
3200 const auto &CRI = cast<CatchReturnInst>(
I);
3201 pushValue(CRI.getCatchPad(), InstID, Vals);
3205 case Instruction::CleanupPad:
3206 case Instruction::CatchPad: {
3207 const auto &FuncletPad = cast<FuncletPadInst>(
I);
3210 pushValue(FuncletPad.getParentPad(), InstID, Vals);
3212 unsigned NumArgOperands = FuncletPad.arg_size();
3214 for (
unsigned Op = 0;
Op != NumArgOperands; ++
Op)
3215 pushValueAndType(FuncletPad.getArgOperand(
Op), InstID, Vals);
3218 case Instruction::CatchSwitch: {
3220 const auto &CatchSwitch = cast<CatchSwitchInst>(
I);
3222 pushValue(CatchSwitch.getParentPad(), InstID, Vals);
3224 unsigned NumHandlers = CatchSwitch.getNumHandlers();
3226 for (
const BasicBlock *CatchPadBB : CatchSwitch.handlers())
3229 if (CatchSwitch.hasUnwindDest())
3233 case Instruction::CallBr: {
3239 writeOperandBundles(*CBI, InstID);
3254 pushValueAndType(Callee, InstID, Vals);
3257 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i)
3258 pushValue(
I.getOperand(i), InstID, Vals);
3261 if (FTy->isVarArg()) {
3262 for (
unsigned i = FTy->getNumParams(), e = CBI->
arg_size(); i != e; ++i)
3263 pushValueAndType(
I.getOperand(i), InstID, Vals);
3267 case Instruction::Unreachable:
3269 AbbrevToUse = FUNCTION_INST_UNREACHABLE_ABBREV;
3272 case Instruction::PHI: {
3273 const PHINode &PN = cast<PHINode>(
I);
3290 Stream.
EmitRecord(Code, Vals64, AbbrevToUse);
3295 case Instruction::LandingPad: {
3306 pushValueAndType(LP.
getClause(
I), InstID, Vals);
3311 case Instruction::Alloca: {
3319 unsigned EncodedAlign = getEncodedAlign(AI.
getAlign());
3320 Bitfield::set<APV::AlignLower>(
3321 Record, EncodedAlign & ((1 << APV::AlignLower::Bits) - 1));
3322 Bitfield::set<APV::AlignUpper>(
Record,
3323 EncodedAlign >> APV::AlignLower::Bits);
3325 Bitfield::set<APV::ExplicitType>(
Record,
true);
3330 if (AS !=
M.getDataLayout().getAllocaAddrSpace())
3335 case Instruction::Load:
3336 if (cast<LoadInst>(
I).isAtomic()) {
3338 pushValueAndType(
I.getOperand(0), InstID, Vals);
3341 if (!pushValueAndType(
I.getOperand(0), InstID, Vals))
3342 AbbrevToUse = FUNCTION_INST_LOAD_ABBREV;
3346 Vals.
push_back(cast<LoadInst>(
I).isVolatile());
3347 if (cast<LoadInst>(
I).isAtomic()) {
3349 Vals.
push_back(getEncodedSyncScopeID(cast<LoadInst>(
I).getSyncScopeID()));
3352 case Instruction::Store:
3353 if (cast<StoreInst>(
I).isAtomic())
3357 pushValueAndType(
I.getOperand(1), InstID, Vals);
3358 pushValueAndType(
I.getOperand(0), InstID, Vals);
3360 Vals.
push_back(cast<StoreInst>(
I).isVolatile());
3361 if (cast<StoreInst>(
I).isAtomic()) {
3364 getEncodedSyncScopeID(cast<StoreInst>(
I).getSyncScopeID()));
3367 case Instruction::AtomicCmpXchg:
3369 pushValueAndType(
I.getOperand(0), InstID, Vals);
3370 pushValueAndType(
I.getOperand(1), InstID, Vals);
3371 pushValue(
I.getOperand(2), InstID, Vals);
3372 Vals.
push_back(cast<AtomicCmpXchgInst>(
I).isVolatile());
3376 getEncodedSyncScopeID(cast<AtomicCmpXchgInst>(
I).getSyncScopeID()));
3379 Vals.
push_back(cast<AtomicCmpXchgInst>(
I).isWeak());
3382 case Instruction::AtomicRMW:
3384 pushValueAndType(
I.getOperand(0), InstID, Vals);
3385 pushValueAndType(
I.getOperand(1), InstID, Vals);
3388 Vals.
push_back(cast<AtomicRMWInst>(
I).isVolatile());
3391 getEncodedSyncScopeID(cast<AtomicRMWInst>(
I).getSyncScopeID()));
3394 case Instruction::Fence:
3397 Vals.
push_back(getEncodedSyncScopeID(cast<FenceInst>(
I).getSyncScopeID()));
3399 case Instruction::Call: {
3404 writeOperandBundles(CI, InstID);
3424 for (
unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) {
3426 if (FTy->getParamType(i)->isLabelTy())
3433 if (FTy->isVarArg()) {
3434 for (
unsigned i = FTy->getNumParams(), e = CI.
arg_size(); i != e; ++i)
3439 case Instruction::VAArg:
3442 pushValue(
I.getOperand(0), InstID, Vals);
3445 case Instruction::Freeze:
3447 pushValueAndType(
I.getOperand(0), InstID, Vals);
3457void ModuleBitcodeWriter::writeGlobalValueSymbolTable(
3463 VSTOffset -= bitcodeStartBit();
3464 assert((VSTOffset & 31) == 0 &&
"VST block not 32-bit aligned");
3468 Stream.
BackpatchWord(VSTOffsetPlaceholder, VSTOffset / 32 + 1);
3472 auto Abbv = std::make_shared<BitCodeAbbrev>();
3476 unsigned FnEntryAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
3481 if (
F.isDeclaration())
3488 uint64_t BitcodeIndex = FunctionToBitcodeIndex[&
F] - bitcodeStartBit();
3489 assert((BitcodeIndex & 31) == 0 &&
"function block not 32-bit aligned");
3493 Record[1] = BitcodeIndex / 32 + 1;
3502void ModuleBitcodeWriter::writeFunctionLevelValueSymbolTable(
3517 unsigned AbbrevToUse = VST_ENTRY_8_ABBREV;
3523 if (isa<BasicBlock>(
Name.getValue())) {
3526 AbbrevToUse = VST_BBENTRY_6_ABBREV;
3530 AbbrevToUse = VST_ENTRY_6_ABBREV;
3532 AbbrevToUse = VST_ENTRY_7_ABBREV;
3535 for (
const auto P :
Name.getKey())
3539 Stream.
EmitRecord(Code, NameVals, AbbrevToUse);
3546void ModuleBitcodeWriter::writeUseList(
UseListOrder &&Order) {
3547 assert(Order.Shuffle.size() >= 2 &&
"Shuffle too small");
3549 if (isa<BasicBlock>(Order.V))
3559void ModuleBitcodeWriter::writeUseListBlock(
const Function *
F) {
3561 "Expected to be preserving use-list order");
3563 auto hasMore = [&]() {
3579void ModuleBitcodeWriter::writeFunction(
3598 unsigned CstStart, CstEnd;
3600 writeConstants(CstStart, CstEnd,
false);
3603 writeFunctionMetadata(
F);
3606 unsigned InstID = CstEnd;
3608 bool NeedsMetadataAttachment =
F.hasMetadata();
3616 writeInstruction(
I, InstID, Vals);
3618 if (!
I.getType()->isVoidTy())
3622 NeedsMetadataAttachment |=
I.hasMetadataOtherThanDebugLoc();
3649 auto PushValueOrMetadata = [&Vals, InstID,
3652 "RawLocation unexpectedly null in DbgVariableRecord");
3658 if (!pushValueAndType(VAM->getValue(), InstID, ValAndType)) {
3672 for (
DbgRecord &DR :
I.DebugMarker->getDbgRecordRange()) {
3698 FUNCTION_DEBUG_RECORD_VALUE_ABBREV);
3720 while (!Worklist.empty()) {
3721 Value *
V = Worklist.pop_back_val();
3722 for (
User *U :
V->users()) {
3723 if (
auto *
I = dyn_cast<Instruction>(U)) {
3727 }
else if (isa<Constant>(U) && !isa<GlobalValue>(U) &&
3728 Visited.insert(U).second)
3729 Worklist.push_back(U);
3735 if (!BlockAddressUsers.
empty()) {
3744 if (
auto *Symtab =
F.getValueSymbolTable())
3745 writeFunctionLevelValueSymbolTable(*Symtab);
3747 if (NeedsMetadataAttachment)
3748 writeFunctionMetadataAttachment(
F);
3750 writeUseListBlock(&
F);
3756void ModuleBitcodeWriter::writeBlockInfo() {
3763 auto Abbv = std::make_shared<BitCodeAbbrev>();
3774 auto Abbv = std::make_shared<BitCodeAbbrev>();
3784 auto Abbv = std::make_shared<BitCodeAbbrev>();
3794 auto Abbv = std::make_shared<BitCodeAbbrev>();
3800 VST_BBENTRY_6_ABBREV)
3805 auto Abbv = std::make_shared<BitCodeAbbrev>();
3810 CONSTANTS_SETTYPE_ABBREV)
3815 auto Abbv = std::make_shared<BitCodeAbbrev>();
3819 CONSTANTS_INTEGER_ABBREV)
3824 auto Abbv = std::make_shared<BitCodeAbbrev>();
3832 CONSTANTS_CE_CAST_Abbrev)
3836 auto Abbv = std::make_shared<BitCodeAbbrev>();
3839 CONSTANTS_NULL_Abbrev)
3846 auto Abbv = std::make_shared<BitCodeAbbrev>();
3854 FUNCTION_INST_LOAD_ABBREV)
3858 auto Abbv = std::make_shared<BitCodeAbbrev>();
3863 FUNCTION_INST_UNOP_ABBREV)
3867 auto Abbv = std::make_shared<BitCodeAbbrev>();
3873 FUNCTION_INST_UNOP_FLAGS_ABBREV)
3877 auto Abbv = std::make_shared<BitCodeAbbrev>();
3883 FUNCTION_INST_BINOP_ABBREV)
3887 auto Abbv = std::make_shared<BitCodeAbbrev>();
3894 FUNCTION_INST_BINOP_FLAGS_ABBREV)
3898 auto Abbv = std::make_shared<BitCodeAbbrev>();
3905 FUNCTION_INST_CAST_ABBREV)
3909 auto Abbv = std::make_shared<BitCodeAbbrev>();
3917 FUNCTION_INST_CAST_FLAGS_ABBREV)
3922 auto Abbv = std::make_shared<BitCodeAbbrev>();
3925 FUNCTION_INST_RET_VOID_ABBREV)
3929 auto Abbv = std::make_shared<BitCodeAbbrev>();
3933 FUNCTION_INST_RET_VAL_ABBREV)
3937 auto Abbv = std::make_shared<BitCodeAbbrev>();
3940 FUNCTION_INST_UNREACHABLE_ABBREV)
3944 auto Abbv = std::make_shared<BitCodeAbbrev>();
3952 FUNCTION_INST_GEP_ABBREV)
3956 auto Abbv = std::make_shared<BitCodeAbbrev>();
3963 FUNCTION_DEBUG_RECORD_VALUE_ABBREV)
3971void IndexBitcodeWriter::writeModStrings() {
3977 auto Abbv = std::make_shared<BitCodeAbbrev>();
3982 unsigned Abbrev8Bit = Stream.
EmitAbbrev(std::move(Abbv));
3985 Abbv = std::make_shared<BitCodeAbbrev>();
3990 unsigned Abbrev7Bit = Stream.
EmitAbbrev(std::move(Abbv));
3993 Abbv = std::make_shared<BitCodeAbbrev>();
3998 unsigned Abbrev6Bit = Stream.
EmitAbbrev(std::move(Abbv));
4001 Abbv = std::make_shared<BitCodeAbbrev>();
4008 unsigned AbbrevHash = Stream.
EmitAbbrev(std::move(Abbv));
4013 const auto &Hash = MPSE.
getValue();
4015 unsigned AbbrevToUse = Abbrev8Bit;
4017 AbbrevToUse = Abbrev6Bit;
4019 AbbrevToUse = Abbrev7Bit;
4021 auto ModuleId = ModuleIdMap.
size();
4022 ModuleIdMap[
Key] = ModuleId;
4031 Vals.
assign(Hash.begin(), Hash.end());
4043template <
typename Fn>
4047 if (!FS->type_tests().empty())
4052 auto WriteVFuncIdVec = [&](
uint64_t Ty,
4057 for (
auto &VF : VFs) {
4058 Record.push_back(VF.GUID);
4059 Record.push_back(VF.Offset);
4065 FS->type_test_assume_vcalls());
4067 FS->type_checked_load_vcalls());
4069 auto WriteConstVCallVec = [&](
uint64_t Ty,
4071 for (
auto &VC : VCs) {
4073 Record.push_back(VC.VFunc.GUID);
4074 Record.push_back(VC.VFunc.Offset);
4081 FS->type_test_assume_const_vcalls());
4083 FS->type_checked_load_const_vcalls());
4093 if (!FS->paramAccesses().empty()) {
4095 for (
auto &Arg : FS->paramAccesses()) {
4096 size_t UndoSize =
Record.size();
4097 Record.push_back(Arg.ParamNo);
4098 WriteRange(Arg.Use);
4099 Record.push_back(Arg.Calls.size());
4100 for (
auto &Call : Arg.Calls) {
4101 Record.push_back(Call.ParamNo);
4102 std::optional<unsigned> ValueID = GetValueID(Call.Callee);
4109 Record.push_back(*ValueID);
4110 WriteRange(Call.Offsets);
4121 std::set<GlobalValue::GUID> &ReferencedTypeIds) {
4122 if (!FS->type_tests().empty())
4123 for (
auto &TT : FS->type_tests())
4124 ReferencedTypeIds.insert(TT);
4126 auto GetReferencedTypesFromVFuncIdVec =
4128 for (
auto &VF : VFs)
4129 ReferencedTypeIds.insert(VF.GUID);
4132 GetReferencedTypesFromVFuncIdVec(FS->type_test_assume_vcalls());
4133 GetReferencedTypesFromVFuncIdVec(FS->type_checked_load_vcalls());
4135 auto GetReferencedTypesFromConstVCallVec =
4137 for (
auto &VC : VCs)
4138 ReferencedTypeIds.insert(VC.VFunc.GUID);
4141 GetReferencedTypesFromConstVCallVec(FS->type_test_assume_const_vcalls());
4142 GetReferencedTypesFromConstVCallVec(FS->type_checked_load_const_vcalls());
4178 NameVals.
push_back(Summary.TTRes.TheKind);
4179 NameVals.
push_back(Summary.TTRes.SizeM1BitWidth);
4180 NameVals.
push_back(Summary.TTRes.AlignLog2);
4181 NameVals.
push_back(Summary.TTRes.SizeM1);
4182 NameVals.
push_back(Summary.TTRes.BitMask);
4183 NameVals.
push_back(Summary.TTRes.InlineBits);
4185 for (
auto &W : Summary.WPDRes)
4197 for (
auto &
P : Summary) {
4213 static_assert(std::is_same_v<LinearFrameId, unsigned>);
4214 for (
auto &AI : FS->allocs()) {
4215 for (
auto &MIB : AI.MIBs) {
4217 StackIdIndices.
reserve(MIB.StackIdIndices.size());
4218 for (
auto Id : MIB.StackIdIndices)
4219 StackIdIndices.
push_back(GetStackIndex(Id));
4221 CallStacks.insert({CallStacks.size(), StackIdIndices});
4234 assert(!CallStacks.empty());
4240 Builder.
build(std::move(CallStacks),
nullptr,
4249 unsigned AllocAbbrev,
unsigned ContextIdAbbvId,
bool PerModule,
4250 std::function<
unsigned(
const ValueInfo &VI)> GetValueID,
4251 std::function<
unsigned(
unsigned)> GetStackIndex,
4252 bool WriteContextSizeInfoIndex,
4257 for (
auto &CI : FS->callsites()) {
4261 assert(!PerModule || (CI.Clones.size() == 1 && CI.Clones[0] == 0));
4262 Record.push_back(GetValueID(CI.Callee));
4264 Record.push_back(CI.StackIdIndices.size());
4265 Record.push_back(CI.Clones.size());
4267 for (
auto Id : CI.StackIdIndices)
4268 Record.push_back(GetStackIndex(Id));
4270 for (
auto V : CI.Clones)
4278 for (
auto &AI : FS->allocs()) {
4282 assert(!PerModule || (AI.Versions.size() == 1 && AI.Versions[0] == 0));
4283 Record.push_back(AI.MIBs.size());
4285 Record.push_back(AI.Versions.size());
4286 for (
auto &MIB : AI.MIBs) {
4289 assert(CallStackCount <= CallStackPos.
size());
4290 Record.push_back(CallStackPos[CallStackCount++]);
4293 for (
auto V : AI.Versions)
4296 assert(AI.ContextSizeInfos.empty() ||
4297 AI.ContextSizeInfos.size() == AI.MIBs.size());
4299 if (WriteContextSizeInfoIndex && !AI.ContextSizeInfos.empty()) {
4307 ContextIds.
reserve(AI.ContextSizeInfos.size() * 2);
4308 for (
auto &Infos : AI.ContextSizeInfos) {
4309 Record.push_back(Infos.size());
4310 for (
auto [FullStackId, TotalSize] : Infos) {
4317 Record.push_back(TotalSize);
4332void ModuleBitcodeWriterBase::writePerModuleFunctionSummaryRecord(
4334 unsigned ValueID,
unsigned FSCallsRelBFAbbrev,
4335 unsigned FSCallsProfileAbbrev,
unsigned CallsiteAbbrev,
4336 unsigned AllocAbbrev,
unsigned ContextIdAbbvId,
const Function &
F,
4344 Stream, FS, [&](
const ValueInfo &VI) -> std::optional<unsigned> {
4349 Stream, FS, CallsiteAbbrev, AllocAbbrev, ContextIdAbbvId,
4351 [&](
const ValueInfo &VI) {
return getValueId(VI); },
4352 [&](
unsigned I) {
return I; },
4353 true, CallStackPos, CallStackCount);
4355 auto SpecialRefCnts =
FS->specialRefCounts();
4360 NameVals.
push_back(SpecialRefCnts.first);
4361 NameVals.
push_back(SpecialRefCnts.second);
4363 for (
auto &RI :
FS->refs())
4366 const bool UseRelBFRecord =
4369 for (
auto &ECI :
FS->calls()) {
4370 NameVals.
push_back(getValueId(ECI.first));
4378 (UseRelBFRecord ? FSCallsRelBFAbbrev : FSCallsProfileAbbrev);
4389void ModuleBitcodeWriterBase::writeModuleLevelReferences(
4391 unsigned FSModRefsAbbrev,
unsigned FSModVTableRefsAbbrev) {
4392 auto VI =
Index->getValueInfo(
V.getGUID());
4393 if (!VI ||
VI.getSummaryList().empty()) {
4399 auto *
Summary =
VI.getSummaryList()[0].get();
4405 auto VTableFuncs =
VS->vTableFuncs();
4406 if (!VTableFuncs.empty())
4409 unsigned SizeBeforeRefs = NameVals.
size();
4410 for (
auto &RI :
VS->refs())
4416 if (VTableFuncs.empty())
4421 for (
auto &
P : VTableFuncs) {
4427 FSModVTableRefsAbbrev);
4434void ModuleBitcodeWriterBase::writePerModuleGlobalValueSummary() {
4437 bool IsThinLTO =
true;
4439 mdconst::extract_or_null<ConstantInt>(
M.getModuleFlag(
"ThinLTO")))
4440 IsThinLTO = MD->getZExtValue();
4452 if (
Index->enableSplitLTOUnit())
4454 if (
Index->hasUnifiedLTO())
4464 auto Abbv = std::make_shared<BitCodeAbbrev>();
4470 unsigned ValueGuidAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
4472 for (
const auto &GVI : valueIds()) {
4475 static_cast<uint32_t>(GVI.first >> 32),
4480 if (!
Index->stackIds().empty()) {
4481 auto StackIdAbbv = std::make_shared<BitCodeAbbrev>();
4488 unsigned StackIdAbbvId = Stream.
EmitAbbrev(std::move(StackIdAbbv));
4491 for (
auto Id :
Index->stackIds()) {
4499 auto ContextIdAbbv = std::make_shared<BitCodeAbbrev>();
4505 unsigned ContextIdAbbvId = Stream.
EmitAbbrev(std::move(ContextIdAbbv));
4508 Abbv = std::make_shared<BitCodeAbbrev>();
4520 unsigned FSCallsProfileAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
4523 Abbv = std::make_shared<BitCodeAbbrev>();
4535 unsigned FSCallsRelBFAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
4538 Abbv = std::make_shared<BitCodeAbbrev>();
4544 unsigned FSModRefsAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
4547 Abbv = std::make_shared<BitCodeAbbrev>();
4555 unsigned FSModVTableRefsAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
4558 Abbv = std::make_shared<BitCodeAbbrev>();
4563 unsigned FSAliasAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
4566 Abbv = std::make_shared<BitCodeAbbrev>();
4573 unsigned TypeIdCompatibleVtableAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
4575 Abbv = std::make_shared<BitCodeAbbrev>();
4581 unsigned CallsiteAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
4583 Abbv = std::make_shared<BitCodeAbbrev>();
4590 unsigned AllocAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
4592 Abbv = std::make_shared<BitCodeAbbrev>();
4597 unsigned RadixAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
4612 if (!VI ||
VI.getSummaryList().empty()) {
4618 auto *
Summary =
VI.getSummaryList()[0].get();
4621 FS, [](
unsigned I) {
return I; }, CallStacks);
4626 if (!CallStacks.
empty()) {
4644 if (!VI ||
VI.getSummaryList().empty()) {
4650 auto *
Summary =
VI.getSummaryList()[0].get();
4651 writePerModuleFunctionSummaryRecord(
4652 NameVals, Summary, VE.
getValueID(&
F), FSCallsRelBFAbbrev,
4653 FSCallsProfileAbbrev, CallsiteAbbrev, AllocAbbrev, ContextIdAbbvId,
F,
4654 CallStackPos, CallStackCount);
4660 writeModuleLevelReferences(
G, NameVals, FSModRefsAbbrev,
4661 FSModVTableRefsAbbrev);
4664 auto *Aliasee =
A.getAliaseeObject();
4667 if (!Aliasee->hasName() || isa<GlobalIFunc>(Aliasee))
4680 for (
auto &S :
Index->typeIdCompatibleVtableMap()) {
4684 TypeIdCompatibleVtableAbbrev);
4688 if (
Index->getBlockCount())
4696void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
4705 auto Abbv = std::make_shared<BitCodeAbbrev>();
4711 unsigned ValueGuidAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
4713 for (
const auto &GVI : valueIds()) {
4716 static_cast<uint32_t>(GVI.first >> 32),
4723 if (!StackIds.empty()) {
4724 auto StackIdAbbv = std::make_shared<BitCodeAbbrev>();
4731 unsigned StackIdAbbvId = Stream.
EmitAbbrev(std::move(StackIdAbbv));
4733 Vals.
reserve(StackIds.size() * 2);
4734 for (
auto Id : StackIds) {
4742 Abbv = std::make_shared<BitCodeAbbrev>();
4756 unsigned FSCallsProfileAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
4759 Abbv = std::make_shared<BitCodeAbbrev>();
4766 unsigned FSModRefsAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
4769 Abbv = std::make_shared<BitCodeAbbrev>();
4775 unsigned FSAliasAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
4777 Abbv = std::make_shared<BitCodeAbbrev>();
4785 unsigned CallsiteAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
4787 Abbv = std::make_shared<BitCodeAbbrev>();
4796 unsigned AllocAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
4798 Abbv = std::make_shared<BitCodeAbbrev>();
4803 unsigned RadixAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
4806 if (DecSummaries ==
nullptr)
4808 return DecSummaries->count(GVS);
4822 std::set<GlobalValue::GUID> ReferencedTypeIds;
4836 NameVals.
push_back(S.getOriginalName());
4847 forEachSummary([&](GVInfo
I,
bool IsAliasee) {
4850 auto *
FS = dyn_cast<FunctionSummary>(S);
4861 return StackIdIndicesToIndex[
I];
4868 if (!CallStacks.
empty()) {
4877 forEachSummary([&](GVInfo
I,
bool IsAliasee) {
4880 DefOrUseGUIDs.
insert(
I.first);
4882 DefOrUseGUIDs.
insert(
VI.getGUID());
4884 auto ValueId = getValueId(
I.first);
4886 SummaryToValueIdMap[S] = *ValueId;
4894 if (
auto *AS = dyn_cast<AliasSummary>(S)) {
4901 if (
auto *VS = dyn_cast<GlobalVarSummary>(S)) {
4904 NameVals.
push_back(ModuleIdMap[
VS->modulePath()]);
4908 for (
auto &RI :
VS->refs()) {
4909 auto RefValueId = getValueId(RI.getGUID());
4919 MaybeEmitOriginalName(*S);
4923 auto GetValueId = [&](
const ValueInfo &
VI) -> std::optional<unsigned> {
4925 return std::nullopt;
4926 return getValueId(
VI.getGUID());
4929 auto *
FS = cast<FunctionSummary>(S);
4934 Stream, FS, CallsiteAbbrev, AllocAbbrev, 0,
4938 std::optional<unsigned> ValueID = GetValueId(VI);
4953 return StackIdIndicesToIndex[
I];
4955 false, CallStackPos, CallStackCount);
4959 NameVals.
push_back(ModuleIdMap[
FS->modulePath()]);
4972 unsigned Count = 0, RORefCnt = 0, WORefCnt = 0;
4973 for (
auto &RI :
FS->refs()) {
4974 auto RefValueId = getValueId(RI.getGUID());
4978 if (RI.isReadOnly())
4980 else if (RI.isWriteOnly())
4984 NameVals[6] = Count;
4985 NameVals[7] = RORefCnt;
4986 NameVals[8] = WORefCnt;
4988 for (
auto &EI :
FS->calls()) {
4991 std::optional<unsigned> CallValueId = GetValueId(EI.first);
5000 FSCallsProfileAbbrev);
5002 MaybeEmitOriginalName(*S);
5005 for (
auto *AS : Aliases) {
5006 auto AliasValueId = SummaryToValueIdMap[AS];
5013 auto AliaseeValueId = SummaryToValueIdMap[&AS->
getAliasee()];
5020 MaybeEmitOriginalName(*AS);
5022 if (
auto *FS = dyn_cast<FunctionSummary>(&AS->
getAliasee()))
5026 if (!
Index.cfiFunctionDefs().empty()) {
5027 for (
auto &S :
Index.cfiFunctionDefs()) {
5034 if (!NameVals.
empty()) {
5040 if (!
Index.cfiFunctionDecls().empty()) {
5041 for (
auto &S :
Index.cfiFunctionDecls()) {
5048 if (!NameVals.
empty()) {
5056 for (
auto &
T : ReferencedTypeIds) {
5057 auto TidIter =
Index.typeIds().equal_range(
T);
5058 for (
const auto &[GUID, TypeIdPair] :
make_range(TidIter)) {
5066 if (
Index.getBlockCount())
5079 auto Abbv = std::make_shared<BitCodeAbbrev>();
5083 auto StringAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
5085 "LLVM" LLVM_VERSION_STRING, StringAbbrev);
5088 Abbv = std::make_shared<BitCodeAbbrev>();
5091 auto EpochAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
5097void ModuleBitcodeWriter::writeModuleHash(
StringRef View) {
5104 std::array<uint8_t, 20> Hash = Hasher.result();
5105 for (
int Pos = 0; Pos < 20; Pos += 4) {
5118void ModuleBitcodeWriter::write() {
5126 writeModuleVersion();
5135 writeAttributeGroupTable();
5138 writeAttributeTable();
5147 writeModuleConstants();
5150 writeModuleMetadataKinds();
5153 writeModuleMetadata();
5157 writeUseListBlock(
nullptr);
5159 writeOperandBundleTags();
5160 writeSyncScopeNames();
5165 if (!
F.isDeclaration())
5166 writeFunction(
F, FunctionToBitcodeIndex);
5171 writePerModuleGlobalValueSummary();
5173 writeGlobalValueSymbolTable(FunctionToBitcodeIndex);
5201 unsigned CPUType = ~0U;
5208 DARWIN_CPU_ARCH_ABI64 = 0x01000000,
5209 DARWIN_CPU_TYPE_X86 = 7,
5210 DARWIN_CPU_TYPE_ARM = 12,
5211 DARWIN_CPU_TYPE_POWERPC = 18
5216 CPUType = DARWIN_CPU_TYPE_X86 | DARWIN_CPU_ARCH_ABI64;
5218 CPUType = DARWIN_CPU_TYPE_X86;
5220 CPUType = DARWIN_CPU_TYPE_POWERPC;
5222 CPUType = DARWIN_CPU_TYPE_POWERPC | DARWIN_CPU_ARCH_ABI64;
5224 CPUType = DARWIN_CPU_TYPE_ARM;
5228 "Expected header size to be reserved");
5233 unsigned Position = 0;
5241 while (Buffer.
size() & 15)
5248 Stream.
Emit((
unsigned)
'B', 8);
5249 Stream.
Emit((
unsigned)
'C', 8);
5250 Stream.
Emit(0x0, 4);
5251 Stream.
Emit(0xC, 4);
5252 Stream.
Emit(0xE, 4);
5253 Stream.
Emit(0xD, 4);
5271 auto Abbv = std::make_shared<BitCodeAbbrev>();
5274 auto AbbrevNo = Stream->
EmitAbbrev(std::move(Abbv));
5282 assert(!WroteStrtab && !WroteSymtab);
5288 if (M->getModuleInlineAsm().empty())
5292 const Triple TT(M->getTargetTriple());
5294 if (!
T || !
T->hasMCAsmParser())
5316 std::vector<char> Strtab;
5318 Strtab.resize(StrtabBuilder.
getSize());
5322 {Strtab.data(), Strtab.size()});
5333 bool ShouldPreserveUseListOrder,
5342 assert(M.isMaterialized());
5343 Mods.push_back(
const_cast<Module *
>(&M));
5345 ModuleBitcodeWriter ModuleWriter(M, StrtabBuilder, *Stream,
5346 ShouldPreserveUseListOrder, Index,
5347 GenerateHash, ModHash);
5348 ModuleWriter.write();
5355 IndexBitcodeWriter IndexWriter(*Stream, StrtabBuilder, *Index, DecSummaries,
5356 ModuleToSummariesForIndex);
5357 IndexWriter.write();
5362 bool ShouldPreserveUseListOrder,
5366 Writer.writeModule(M, ShouldPreserveUseListOrder, Index, GenerateHash,
5368 Writer.writeSymtab();
5369 Writer.writeStrtab();
5371 Triple TT(M.getTargetTriple());
5372 if (TT.isOSDarwin() || TT.isOSBinFormatMachO()) {
5390void IndexBitcodeWriter::write() {
5393 writeModuleVersion();
5399 writeCombinedGlobalValueSummary();
5416 Writer.
writeIndex(&Index, ModuleToSummariesForIndex, DecSummaries);
5425class ThinLinkBitcodeWriter :
public ModuleBitcodeWriterBase {
5435 : ModuleBitcodeWriterBase(M, StrtabBuilder, Stream,
5437 ModHash(&ModHash) {}
5442 void writeSimplifiedModuleInfo();
5452void ThinLinkBitcodeWriter::writeSimplifiedModuleInfo() {
5464 auto Abbv = std::make_shared<BitCodeAbbrev>();
5467 Abbv->Add(AbbrevOpToUse);
5468 unsigned FilenameAbbrev = Stream.
EmitAbbrev(std::move(Abbv));
5470 for (
const auto P :
M.getSourceFileName())
5534void ThinLinkBitcodeWriter::write() {
5537 writeModuleVersion();
5539 writeSimplifiedModuleInfo();
5541 writePerModuleGlobalValueSummary();
5558 assert(M.isMaterialized());
5559 Mods.push_back(
const_cast<Module *
>(&M));
5561 ThinLinkBitcodeWriter ThinLinkWriter(M, StrtabBuilder, *Stream, Index,
5563 ThinLinkWriter.write();
5584 switch (
T.getObjectFormat()) {
5586 return "__LLVM,__bitcode";
5611 switch (
T.getObjectFormat()) {
5613 return "__LLVM,__cmdline";
5639 const std::vector<uint8_t> &CmdArgs) {
5644 Type *UsedElementType = Used ? Used->getValueType()->getArrayElementType()
5646 for (
auto *GV : UsedGlobals) {
5647 if (GV->getName() !=
"llvm.embedded.module" &&
5648 GV->getName() !=
"llvm.cmdline")
5653 Used->eraseFromParent();
5658 Triple T(M.getTargetTriple());
5687 M.getGlobalVariable(
"llvm.embedded.module",
true)) {
5688 assert(Old->hasZeroLiveUses() &&
5689 "llvm.embedded.module can only be used once in llvm.compiler.used");
5691 Old->eraseFromParent();
5693 GV->
setName(
"llvm.embedded.module");
5711 assert(Old->hasZeroLiveUses() &&
5712 "llvm.cmdline can only be used once in llvm.compiler.used");
5714 Old->eraseFromParent();
5720 if (UsedArray.
empty())
5728 NewUsed->setSection(
"llvm.metadata");
This file defines the StringMap class.
This file declares a class to represent arbitrary precision floating point values and provide a varie...
This file implements a class to represent arbitrary precision integral constant values and operations...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static void writeDIMacro(raw_ostream &Out, const DIMacro *N, AsmWriterContext &WriterCtx)
static void writeDIGlobalVariableExpression(raw_ostream &Out, const DIGlobalVariableExpression *N, AsmWriterContext &WriterCtx)
static void writeDICompositeType(raw_ostream &Out, const DICompositeType *N, AsmWriterContext &WriterCtx)
static void writeDIStringType(raw_ostream &Out, const DIStringType *N, AsmWriterContext &WriterCtx)
static void writeDIGlobalVariable(raw_ostream &Out, const DIGlobalVariable *N, AsmWriterContext &WriterCtx)
static void writeDIModule(raw_ostream &Out, const DIModule *N, AsmWriterContext &WriterCtx)
static void writeDIFile(raw_ostream &Out, const DIFile *N, AsmWriterContext &)
static void writeDISubroutineType(raw_ostream &Out, const DISubroutineType *N, AsmWriterContext &WriterCtx)
static void writeDILabel(raw_ostream &Out, const DILabel *N, AsmWriterContext &WriterCtx)
static void writeDIDerivedType(raw_ostream &Out, const DIDerivedType *N, AsmWriterContext &WriterCtx)
static void writeDIImportedEntity(raw_ostream &Out, const DIImportedEntity *N, AsmWriterContext &WriterCtx)
static void writeDIObjCProperty(raw_ostream &Out, const DIObjCProperty *N, AsmWriterContext &WriterCtx)
static void writeDISubprogram(raw_ostream &Out, const DISubprogram *N, AsmWriterContext &WriterCtx)
static void writeDILocation(raw_ostream &Out, const DILocation *DL, AsmWriterContext &WriterCtx)
static void writeDINamespace(raw_ostream &Out, const DINamespace *N, AsmWriterContext &WriterCtx)
static void writeDICommonBlock(raw_ostream &Out, const DICommonBlock *N, AsmWriterContext &WriterCtx)
static void writeDIBasicType(raw_ostream &Out, const DIBasicType *N, AsmWriterContext &)
static void writeGenericDINode(raw_ostream &Out, const GenericDINode *N, AsmWriterContext &WriterCtx)
static void writeDILocalVariable(raw_ostream &Out, const DILocalVariable *N, AsmWriterContext &WriterCtx)
static void writeDITemplateTypeParameter(raw_ostream &Out, const DITemplateTypeParameter *N, AsmWriterContext &WriterCtx)
static void writeDICompileUnit(raw_ostream &Out, const DICompileUnit *N, AsmWriterContext &WriterCtx)
static void writeDIGenericSubrange(raw_ostream &Out, const DIGenericSubrange *N, AsmWriterContext &WriterCtx)
static void writeDISubrange(raw_ostream &Out, const DISubrange *N, AsmWriterContext &WriterCtx)
static void writeDILexicalBlockFile(raw_ostream &Out, const DILexicalBlockFile *N, AsmWriterContext &WriterCtx)
static void writeDIEnumerator(raw_ostream &Out, const DIEnumerator *N, AsmWriterContext &)
static void writeMDTuple(raw_ostream &Out, const MDTuple *Node, AsmWriterContext &WriterCtx)
static void writeDIExpression(raw_ostream &Out, const DIExpression *N, AsmWriterContext &WriterCtx)
static void writeDIAssignID(raw_ostream &Out, const DIAssignID *DL, AsmWriterContext &WriterCtx)
static void writeDILexicalBlock(raw_ostream &Out, const DILexicalBlock *N, AsmWriterContext &WriterCtx)
static void writeDIArgList(raw_ostream &Out, const DIArgList *N, AsmWriterContext &WriterCtx, bool FromValue=false)
static void writeDITemplateValueParameter(raw_ostream &Out, const DITemplateValueParameter *N, AsmWriterContext &WriterCtx)
static void writeDIMacroFile(raw_ostream &Out, const DIMacroFile *N, AsmWriterContext &WriterCtx)
Atomic ordering constants.
This file contains the simple types necessary to represent the attributes associated with functions a...
static void writeFunctionHeapProfileRecords(BitstreamWriter &Stream, FunctionSummary *FS, unsigned CallsiteAbbrev, unsigned AllocAbbrev, unsigned ContextIdAbbvId, bool PerModule, std::function< unsigned(const ValueInfo &VI)> GetValueID, std::function< unsigned(unsigned)> GetStackIndex, bool WriteContextSizeInfoIndex, DenseMap< CallStackId, LinearCallStackId > &CallStackPos, CallStackId &CallStackCount)
static unsigned serializeSanitizerMetadata(const GlobalValue::SanitizerMetadata &Meta)
static void writeTypeIdCompatibleVtableSummaryRecord(SmallVector< uint64_t, 64 > &NameVals, StringTableBuilder &StrtabBuilder, StringRef Id, const TypeIdCompatibleVtableInfo &Summary, ValueEnumerator &VE)
static void getReferencedTypeIds(FunctionSummary *FS, std::set< GlobalValue::GUID > &ReferencedTypeIds)
Collect type IDs from type tests used by function.
static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind)
static void collectMemProfCallStacks(FunctionSummary *FS, std::function< LinearFrameId(unsigned)> GetStackIndex, MapVector< CallStackId, llvm::SmallVector< LinearFrameId > > &CallStacks)
static unsigned getEncodedUnaryOpcode(unsigned Opcode)
static void emitSignedInt64(SmallVectorImpl< uint64_t > &Vals, uint64_t V)
static unsigned getEncodedVisibility(const GlobalValue &GV)
static uint64_t getOptimizationFlags(const Value *V)
static unsigned getEncodedLinkage(const GlobalValue::LinkageTypes Linkage)
static unsigned getEncodedRMWOperation(AtomicRMWInst::BinOp Op)
static unsigned getEncodedThreadLocalMode(const GlobalValue &GV)
static DenseMap< CallStackId, LinearCallStackId > writeMemoryProfileRadixTree(MapVector< CallStackId, llvm::SmallVector< LinearFrameId > > &&CallStacks, BitstreamWriter &Stream, unsigned RadixAbbrev)
static void writeIdentificationBlock(BitstreamWriter &Stream)
Create the "IDENTIFICATION_BLOCK_ID" containing a single string with the current llvm version,...
static unsigned getEncodedCastOpcode(unsigned Opcode)
static cl::opt< bool > WriteRelBFToSummary("write-relbf-to-summary", cl::Hidden, cl::init(false), cl::desc("Write relative block frequency to function summary "))
static cl::opt< uint32_t > FlushThreshold("bitcode-flush-threshold", cl::Hidden, cl::init(512), cl::desc("The threshold (unit M) for flushing LLVM bitcode."))
static unsigned getEncodedOrdering(AtomicOrdering Ordering)
static unsigned getEncodedUnnamedAddr(const GlobalValue &GV)
bool WriteNewDbgInfoFormatToBitcode
static unsigned getEncodedComdatSelectionKind(const Comdat &C)
static uint64_t getEncodedGVSummaryFlags(GlobalValueSummary::GVFlags Flags, bool ImportAsDecl=false)
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 void writeBitcodeHeader(BitstreamWriter &Stream)
Helper to write the header common to all bitcode files.
llvm::cl::opt< bool > UseNewDbgInfoFormat
static uint64_t getEncodedRelBFCallEdgeInfo(const CalleeInfo &CI)
static void writeWholeProgramDevirtResolutionByArg(SmallVector< uint64_t, 64 > &NameVals, const std::vector< uint64_t > &args, const WholeProgramDevirtResolution::ByArg &ByArg)
static void emitConstantRange(SmallVectorImpl< uint64_t > &Record, const ConstantRange &CR, bool EmitBitWidth)
static StringEncoding getStringEncoding(StringRef Str)
Determine the encoding to use for the given string name and length.
static uint64_t getEncodedGVarFlags(GlobalVarSummary::GVarFlags Flags)
static const char * getSectionNameForCommandline(const Triple &T)
static cl::opt< unsigned > IndexThreshold("bitcode-mdindex-threshold", cl::Hidden, cl::init(25), cl::desc("Number of metadatas above which we emit an index " "to enable lazy-loading"))
static void writeTypeIdSummaryRecord(SmallVector< uint64_t, 64 > &NameVals, StringTableBuilder &StrtabBuilder, StringRef Id, const TypeIdSummary &Summary)
static void writeFunctionTypeMetadataRecords(BitstreamWriter &Stream, FunctionSummary *FS, Fn GetValueID)
Write the function type metadata related records that need to appear before a function summary entry ...
static uint64_t getEncodedHotnessCallEdgeInfo(const CalleeInfo &CI)
static void emitWideAPInt(SmallVectorImpl< uint64_t > &Vals, const APInt &A)
static void writeStringRecord(BitstreamWriter &Stream, unsigned Code, StringRef Str, unsigned AbbrevToUse)
static void writeWholeProgramDevirtResolution(SmallVector< uint64_t, 64 > &NameVals, StringTableBuilder &StrtabBuilder, uint64_t Id, const WholeProgramDevirtResolution &Wpd)
static unsigned getEncodedDLLStorageClass(const GlobalValue &GV)
static void writeInt32ToBuffer(uint32_t Value, SmallVectorImpl< char > &Buffer, uint32_t &Position)
static const char * getSectionNameForBitcode(const Triple &T)
static unsigned getEncodedBinaryOpcode(unsigned Opcode)
static uint64_t getEncodedFFlags(FunctionSummary::FFlags Flags)
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
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 contains the declaration of the GlobalIFunc class, which represents a single indirect funct...
static MaybeAlign getAlign(Value *Ptr)
Module.h This file contains the declarations for the Module class.
static cl::opt< LTOBitcodeEmbedding > EmbedBitcode("lto-embed-bitcode", cl::init(LTOBitcodeEmbedding::DoNotEmbed), cl::values(clEnumValN(LTOBitcodeEmbedding::DoNotEmbed, "none", "Do not embed"), clEnumValN(LTOBitcodeEmbedding::EmbedOptimized, "optimized", "Embed after all optimization passes"), clEnumValN(LTOBitcodeEmbedding::EmbedPostMergePreOptimized, "post-merge-pre-opt", "Embed post merge, but before optimizations")), cl::desc("Embed LLVM bitcode in object files produced by LTO"))
ModuleSummaryIndex.h This file contains the declarations the classes that hold the module index and s...
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
uint64_t IntrinsicInst * II
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file implements a set that has insertion order iteration characteristics.
This file defines the SmallPtrSet class.
This file defines the SmallString class.
This file defines the SmallVector class.
static unsigned getBitWidth(Type *Ty, const DataLayout &DL)
Returns the bitwidth of the given scalar or pointer type.
static const uint32_t IV[8]
Class for arbitrary precision integers.
unsigned getNumWords() const
Get the number of words.
unsigned getActiveWords() const
Compute the number of active words in the value of this APInt.
const uint64_t * getRawData() const
This function returns a pointer to the internal storage of the APInt.
int64_t getSExtValue() const
Get sign extended value.
Alias summary information.
const GlobalValueSummary & getAliasee() const
an instruction to allocate memory on the stack
bool isSwiftError() const
Return true if this alloca is used as a swifterror argument to a call.
Align getAlign() const
Return the alignment of the memory that is being allocated by the instruction.
Type * getAllocatedType() const
Return the type that is being allocated by the instruction.
bool isUsedWithInAlloca() const
Return true if this alloca is used as an inalloca argument to a call.
unsigned getAddressSpace() const
Return the address space for the allocation.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
bool empty() const
empty - Check if the array is empty.
Class to represent array types.
static ArrayType * get(Type *ElementType, uint64_t NumElements)
This static method is the primary way to construct an ArrayType.
BinOp
This enumeration lists the possible modifications atomicrmw can make.
@ USubCond
Subtract only if no unsigned overflow.
@ Min
*p = old <signed v ? old : v
@ USubSat
*p = usub.sat(old, v) usub.sat matches the behavior of llvm.usub.sat.
@ UIncWrap
Increment one up to a maximum value.
@ Max
*p = old >signed v ? old : v
@ UMin
*p = old <unsigned v ? old : v
@ FMin
*p = minnum(old, v) minnum matches the behavior of llvm.minnum.
@ UMax
*p = old >unsigned v ? old : v
@ FMax
*p = maxnum(old, v) maxnum matches the behavior of llvm.maxnum.
@ UDecWrap
Decrement one until a minimum value or zero.
bool hasAttributes() const
Return true if attributes exists in this set.
AttrKind
This enumeration lists the attributes that can be associated with parameters, function results,...
@ TombstoneKey
Use as Tombstone key for DenseMap of AttrKind.
@ None
No attributes have been set.
@ EmptyKey
Use as Empty key for DenseMap of AttrKind.
@ EndAttrKinds
Sentinel value useful for loops.
LLVM Basic Block Representation.
BitCodeAbbrevOp - This describes one or more operands in an abbreviation.
static bool isChar6(char C)
isChar6 - Return true if this character is legal in the Char6 encoding.
void writeThinLinkBitcode(const Module &M, const ModuleSummaryIndex &Index, const ModuleHash &ModHash)
Write the specified thin link bitcode file (i.e., the minimized bitcode file) to the buffer specified...
void writeIndex(const ModuleSummaryIndex *Index, const ModuleToSummariesForIndexTy *ModuleToSummariesForIndex, const GVSummaryPtrSet *DecSummaries)
void copyStrtab(StringRef Strtab)
Copy the string table for another module into this bitcode file.
void writeStrtab()
Write the bitcode file's string table.
void writeSymtab()
Attempt to write a symbol table to the bitcode file.
void writeModule(const Module &M, bool ShouldPreserveUseListOrder=false, const ModuleSummaryIndex *Index=nullptr, bool GenerateHash=false, ModuleHash *ModHash=nullptr)
Write the specified module to the buffer specified at construction time.
BitcodeWriter(SmallVectorImpl< char > &Buffer)
Create a BitcodeWriter that writes to Buffer.
unsigned EmitAbbrev(std::shared_ptr< BitCodeAbbrev > Abbv)
Emits the abbreviation Abbv to the stream.
void markAndBlockFlushing()
For scenarios where the user wants to access a section of the stream to (for example) compute some ch...
StringRef getMarkedBufferAndResumeFlushing()
resumes flushing, but does not flush, and returns the section in the internal buffer starting from th...
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 ...
void Emit(uint32_t Val, unsigned NumBits)
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...
unsigned EmitBlockInfoAbbrev(unsigned BlockID, std::shared_ptr< BitCodeAbbrev > Abbv)
EmitBlockInfoAbbrev - Emit a DEFINE_ABBREV record for the specified BlockID.
void EnterBlockInfoBlock()
EnterBlockInfoBlock - Start emitting the BLOCKINFO_BLOCK.
void BackpatchWord(uint64_t BitNo, unsigned Val)
void BackpatchWord64(uint64_t BitNo, uint64_t Val)
void EnterSubblock(unsigned BlockID, unsigned CodeLen)
uint64_t GetCurrentBitNo() const
Retrieve the current position in the stream, in bits.
void EmitRecordWithAbbrev(unsigned Abbrev, const Container &Vals)
EmitRecordWithAbbrev - Emit a record with the specified abbreviation.
The address of a basic block.
static BlockAddress * lookup(const BasicBlock *BB)
Lookup an existing BlockAddress constant for the given BasicBlock.
Conditional or Unconditional Branch instruction.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
OperandBundleUse getOperandBundleAt(unsigned Index) const
Return the operand bundle at a specific index.
unsigned getNumOperandBundles() const
Return the number of operand bundles associated with this User.
CallingConv::ID getCallingConv() const
Value * getCalledOperand() const
Value * getArgOperand(unsigned i) const
FunctionType * getFunctionType() const
unsigned arg_size() const
AttributeList getAttributes() const
Return the attributes for this call.
bool hasOperandBundles() const
Return true if this User has any operand bundles.
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
BasicBlock * getIndirectDest(unsigned i) const
BasicBlock * getDefaultDest() const
unsigned getNumIndirectDests() const
Return the number of callbr indirect dest labels.
This class represents a function call, abstracting a target machine's calling convention.
bool isNoTailCall() const
bool isMustTailCall() const
@ Largest
The linker will choose the largest COMDAT.
@ SameSize
The data referenced by the COMDAT must be the same size.
@ Any
The linker may choose any COMDAT.
@ NoDeduplicate
No deduplication is performed.
@ ExactMatch
The data referenced by the COMDAT must be the same.
static Constant * get(ArrayType *T, ArrayRef< Constant * > V)
static Constant * get(LLVMContext &Context, ArrayRef< ElementTy > Elts)
get() constructor - Return a constant with array type with an element count and element type matching...
ConstantDataSequential - A vector or array constant whose element type is a simple 1/2/4/8-byte integ...
A constant value that is initialized with an expression using other constant values.
static Constant * getPointerBitCastOrAddrSpaceCast(Constant *C, Type *Ty)
Create a BitCast or AddrSpaceCast for a pointer type depending on the address space.
ConstantFP - Floating Point Values [float, double].
This is the shared class of boolean and integer constants.
This class represents a range of values.
const APInt & getLower() const
Return the lower value for this range.
const APInt & getUpper() const
Return the upper value for this range.
uint32_t getBitWidth() const
Get the bit width of this ConstantRange.
ConstantRange sextOrTrunc(uint32_t BitWidth) const
Make this range have the bit width given by BitWidth.
This is an important base class in LLVM.
List of ValueAsMetadata, to be used as an argument to a dbg.value intrinsic.
Basic type, like 'int' or 'float'.
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.
String type, Fortran CHARACTER(n)
Type array for a subprogram.
This class represents an Operation in the Expression.
Records a position in IR for a source label (DILabel).
Base class for non-instruction debug metadata records that have positions within IR.
DebugLoc getDebugLoc() const
Record of a variable value-assignment, aka a non instruction representation of the dbg....
DIAssignID * getAssignID() const
DIExpression * getExpression() const
DILocalVariable * getVariable() const
Metadata * getRawLocation() const
Returns the metadata operand for the first location description.
bool isDbgDeclare() const
Metadata * getRawAddress() const
DIExpression * getAddressExpression() const
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
std::pair< iterator, bool > insert(const std::pair< KeyT, ValueT > &KV)
Implements a dense probed hash-table based set.
Lightweight error class with error context and mandatory checking.
Function summary information to aid decisions and implementation of importing.
ForceSummaryHotnessType
Types for -force-summary-edges-cold debugging option.
Generic tagged DWARF-like metadata node.
void getAllMetadata(SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
Appends all metadata attached to this value to MDs, sorting by KindID.
void setAlignment(Align Align)
Sets the alignment attribute of the GlobalObject.
void setSection(StringRef S)
Change the section for this global.
Function and variable summary information to aid decisions and implementation of importing.
GVFlags flags() const
Get the flags for this GlobalValue (see struct GVFlags).
StringRef modulePath() const
Get the path to the module containing this function.
ArrayRef< ValueInfo > refs() const
Return the list of values referenced by this global value definition.
VisibilityTypes getVisibility() const
static bool isLocalLinkage(LinkageTypes Linkage)
LinkageTypes getLinkage() const
static StringRef dropLLVMManglingEscape(StringRef Name)
If the given string begins with the GlobalValue name mangling escape character '\1',...
ThreadLocalMode getThreadLocalMode() const
@ DLLExportStorageClass
Function to be accessible from DLL.
@ DLLImportStorageClass
Function to be imported from DLL.
GUID getGUID() const
Return a 64-bit global unique ID constructed from global value name (i.e.
@ DefaultVisibility
The GV is visible.
@ HiddenVisibility
The GV is hidden.
@ ProtectedVisibility
The GV is protected.
UnnamedAddr getUnnamedAddr() const
LinkageTypes
An enumeration for the kinds of linkage for global values.
@ PrivateLinkage
Like Internal, but omit from symbol table.
@ CommonLinkage
Tentative definitions.
@ InternalLinkage
Rename collisions when linking (static functions).
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
@ WeakODRLinkage
Same, but only replaced by something equivalent.
@ ExternalLinkage
Externally visible function.
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
@ AppendingLinkage
Special purpose, only applies to global arrays.
@ AvailableExternallyLinkage
Available for inspection, not emission.
@ ExternalWeakLinkage
ExternalWeak linkage description.
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
DLLStorageClassTypes getDLLStorageClass() const
Global variable summary information to aid decisions and implementation of importing.
This instruction inserts a struct field of array element value into an aggregate value.
idx_iterator idx_end() const
idx_iterator idx_begin() const
This is an important class for using LLVM in a threaded context.
The landingpad instruction holds all of the information necessary to generate correct exception handl...
bool isCleanup() const
Return 'true' if this landingpad instruction is a cleanup.
unsigned getNumClauses() const
Get the number of clauses for this landing pad.
bool isCatch(unsigned Idx) const
Return 'true' if the clause and index Idx is a catch clause.
Constant * getClause(unsigned Idx) const
Get the value of the clause at index Idx.
Tracking metadata reference owned by Metadata.
This class implements a map that also provides access to all stored values in a deterministic order.
size_t getBufferSize() const
const char * getBufferStart() const
const char * getBufferEnd() const
Class to hold module path string table and global value map, and encapsulate methods for operating on...
static constexpr uint64_t BitcodeSummaryVersion
A Module instance is used to store all the information related to an LLVM module.
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
static PointerType * getUnqual(Type *ElementType)
This constructs a pointer to an object of the specified type in the default address space (address sp...
A class that wrap the SHA1 algorithm.
size_type size() const
Determine the number of elements in the SetVector.
bool empty() const
Determine if the SetVector is empty or not.
bool insert(const value_type &X)
Insert a new element into the SetVector.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
A SetVector that performs no allocations if smaller than a certain size.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
void append(StringRef RHS)
Append from a StringRef.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void assign(size_type NumElts, ValueParamT Elt)
void reserve(size_type N)
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
iterator insert(iterator I, T &&Elt)
void push_back(const T &Elt)
pointer data()
Return a pointer to the vector's buffer, even if empty().
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
const ValueTy & getValue() const
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
StringRef - Represent a constant reference to a string, i.e.
constexpr bool empty() const
empty - Check if the string is empty.
Utility for building string tables with deduplicated suffixes.
void finalizeInOrder()
Finalize the string table without reording it.
void write(raw_ostream &OS) const
size_t add(CachedHashStringRef S)
Add a string to the builder.
Class to represent struct types.
Class to represent target extensions types, which are generally unintrospectable from target-independ...
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isX86_FP80Ty() const
Return true if this is x86 long double.
bool isFloatTy() const
Return true if this is 'float', a 32-bit IEEE fp type.
bool isBFloatTy() const
Return true if this is 'bfloat', a 16-bit bfloat type.
@ X86_AMXTyID
AMX vectors (8192 bits, X86 specific)
@ TypedPointerTyID
Typed pointer used by some GPU targets.
@ HalfTyID
16-bit floating point type
@ TargetExtTyID
Target extension type.
@ VoidTyID
type with no size
@ ScalableVectorTyID
Scalable SIMD vector type.
@ FloatTyID
32-bit floating point type
@ IntegerTyID
Arbitrary bit width integers.
@ FixedVectorTyID
Fixed width SIMD vector type.
@ BFloatTyID
16-bit floating point type (7-bit significand)
@ DoubleTyID
64-bit floating point type
@ X86_FP80TyID
80-bit floating point type (X87)
@ PPC_FP128TyID
128-bit floating point type (two 64-bits, PowerPC)
@ FP128TyID
128-bit floating point type (112-bit significand)
bool isPPC_FP128Ty() const
Return true if this is powerpc long double.
bool isFP128Ty() const
Return true if this is 'fp128'.
bool isHalfTy() const
Return true if this is 'half', a 16-bit IEEE fp type.
bool isDoubleTy() const
Return true if this is 'double', a 64-bit IEEE fp type.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
unsigned getTypeID(Type *T) const
unsigned getMetadataID(const Metadata *MD) const
UseListOrderStack UseListOrders
std::vector< std::pair< const Value *, unsigned > > ValueList
ArrayRef< const Metadata * > getNonMDStrings() const
Get the non-MDString metadata for this block.
unsigned getInstructionID(const Instruction *I) const
unsigned getAttributeListID(AttributeList PAL) const
void incorporateFunction(const Function &F)
incorporateFunction/purgeFunction - If you'd like to deal with a function, use these two methods to g...
void getFunctionConstantRange(unsigned &Start, unsigned &End) const
getFunctionConstantRange - Return the range of values that corresponds to function-local constants.
unsigned getAttributeGroupID(IndexAndAttrSet Group) const
bool hasMDs() const
Check whether the current block has any metadata to emit.
unsigned getComdatID(const Comdat *C) const
uint64_t computeBitsRequiredForTypeIndices() const
unsigned getValueID(const Value *V) const
unsigned getMetadataOrNullID(const Metadata *MD) const
const std::vector< IndexAndAttrSet > & getAttributeGroups() const
const ValueList & getValues() const
unsigned getGlobalBasicBlockID(const BasicBlock *BB) const
getGlobalBasicBlockID - This returns the function-specific ID for the specified basic block.
void setInstructionID(const Instruction *I)
const std::vector< const BasicBlock * > & getBasicBlocks() const
const std::vector< AttributeList > & getAttributeLists() const
bool shouldPreserveUseListOrder() const
const ComdatSetType & getComdats() const
std::vector< Type * > TypeList
ArrayRef< const Metadata * > getMDStrings() const
Get the MDString metadata for this block.
std::pair< unsigned, AttributeSet > IndexAndAttrSet
Attribute groups as encoded in bitcode are almost AttributeSets, but they include the AttributeList i...
const TypeList & getTypes() const
This class provides a symbol table of name/value pairs.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
void setName(const Twine &Name)
Change the name of the value.
LLVMContext & getContext() const
All values hold a context through their type.
void takeName(Value *V)
Transfer the name from V to this value.
std::pair< iterator, bool > insert(const ValueT &V)
bool contains(const_arg_type_t< ValueT > V) const
Check if the set contains the given element.
void build(llvm::MapVector< CallStackId, llvm::SmallVector< FrameIdTy > > &&MemProfCallStackData, const llvm::DenseMap< FrameIdTy, LinearFrameId > *MemProfFrameIndexes, llvm::DenseMap< FrameIdTy, FrameStat > &FrameHistogram)
ArrayRef< LinearFrameId > getRadixArray() const
llvm::DenseMap< CallStackId, LinearCallStackId > takeCallStackPos()
This class implements an extremely fast bulk output stream that can only output to a stream.
raw_ostream & write(unsigned char C)
A raw_ostream that writes to an std::string.
This file contains the declaration of the Comdat class, which represents a single COMDAT in LLVM.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
@ C
The default llvm calling convention, compatible with C.
Predicate getPredicate(unsigned Condition, unsigned Hint)
Return predicate consisting of specified condition and hint bits.
@ CE
Windows NT (Windows on ARM)
@ TYPE_CODE_OPAQUE_POINTER
@ 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
@ FS_CONTEXT_RADIX_TREE_ARRAY
@ FS_COMBINED_GLOBALVAR_INIT_REFS
@ FS_TYPE_CHECKED_LOAD_VCALLS
@ FS_COMBINED_ORIGINAL_NAME
@ FS_PERMODULE_VTABLE_GLOBALVAR_INIT_REFS
@ FS_TYPE_TEST_ASSUME_CONST_VCALL
@ FS_PERMODULE_GLOBALVAR_INIT_REFS
@ FS_TYPE_TEST_ASSUME_VCALLS
@ FS_COMBINED_CALLSITE_INFO
@ FS_PERMODULE_CALLSITE_INFO
@ FS_PERMODULE_ALLOC_INFO
@ FS_TYPE_CHECKED_LOAD_CONST_VCALL
@ IDENTIFICATION_CODE_EPOCH
@ IDENTIFICATION_CODE_STRING
@ CST_CODE_DSO_LOCAL_EQUIVALENT
@ CST_CODE_CE_GEP_WITH_INRANGE
@ COMDAT_SELECTION_KIND_LARGEST
@ COMDAT_SELECTION_KIND_ANY
@ COMDAT_SELECTION_KIND_SAME_SIZE
@ COMDAT_SELECTION_KIND_EXACT_MATCH
@ COMDAT_SELECTION_KIND_NO_DUPLICATES
@ ATTR_KIND_STACK_PROTECT
@ ATTR_KIND_STACK_PROTECT_STRONG
@ ATTR_KIND_SANITIZE_MEMORY
@ ATTR_KIND_OPTIMIZE_FOR_SIZE
@ ATTR_KIND_FNRETTHUNK_EXTERN
@ ATTR_KIND_NO_DIVERGENCE_SOURCE
@ ATTR_KIND_SANITIZE_ADDRESS
@ ATTR_KIND_NO_IMPLICIT_FLOAT
@ ATTR_KIND_DEAD_ON_UNWIND
@ ATTR_KIND_STACK_ALIGNMENT
@ ATTR_KIND_STACK_PROTECT_REQ
@ ATTR_KIND_NULL_POINTER_IS_VALID
@ ATTR_KIND_SANITIZE_HWADDRESS
@ ATTR_KIND_RETURNS_TWICE
@ ATTR_KIND_SHADOWCALLSTACK
@ ATTR_KIND_OPT_FOR_FUZZING
@ ATTR_KIND_SANITIZE_NUMERICAL_STABILITY
@ ATTR_KIND_ALLOCATED_POINTER
@ ATTR_KIND_DISABLE_SANITIZER_INSTRUMENTATION
@ ATTR_KIND_CORO_ELIDE_SAFE
@ ATTR_KIND_NON_LAZY_BIND
@ ATTR_KIND_DEREFERENCEABLE
@ ATTR_KIND_OPTIMIZE_NONE
@ ATTR_KIND_HYBRID_PATCHABLE
@ ATTR_KIND_DEREFERENCEABLE_OR_NULL
@ ATTR_KIND_SANITIZE_REALTIME
@ ATTR_KIND_SPECULATIVE_LOAD_HARDENING
@ ATTR_KIND_ALWAYS_INLINE
@ ATTR_KIND_SANITIZE_TYPE
@ ATTR_KIND_PRESPLIT_COROUTINE
@ ATTR_KIND_NO_SANITIZE_COVERAGE
@ ATTR_KIND_SANITIZE_REALTIME_BLOCKING
@ ATTR_KIND_NO_SANITIZE_BOUNDS
@ ATTR_KIND_SANITIZE_MEMTAG
@ ATTR_KIND_CORO_ONLY_DESTROY_WHEN_COMPLETE
@ ATTR_KIND_SANITIZE_THREAD
@ ATTR_KIND_OPTIMIZE_FOR_DEBUGGING
@ SYNC_SCOPE_NAMES_BLOCK_ID
@ PARAMATTR_GROUP_BLOCK_ID
@ IDENTIFICATION_BLOCK_ID
@ GLOBALVAL_SUMMARY_BLOCK_ID
@ FULL_LTO_GLOBALVAL_SUMMARY_BLOCK_ID
@ OPERAND_BUNDLE_TAGS_BLOCK_ID
@ MODULE_CODE_SOURCE_FILENAME
@ MODULE_CODE_SECTIONNAME
@ FUNC_CODE_INST_CATCHRET
@ FUNC_CODE_INST_LANDINGPAD
@ FUNC_CODE_INST_EXTRACTVAL
@ FUNC_CODE_INST_CATCHPAD
@ FUNC_CODE_INST_CATCHSWITCH
@ FUNC_CODE_INST_CLEANUPRET
@ FUNC_CODE_DEBUG_RECORD_VALUE
@ FUNC_CODE_INST_LOADATOMIC
@ FUNC_CODE_DEBUG_RECORD_ASSIGN
@ FUNC_CODE_INST_STOREATOMIC
@ FUNC_CODE_INST_ATOMICRMW
@ FUNC_CODE_DEBUG_LOC_AGAIN
@ FUNC_CODE_INST_EXTRACTELT
@ FUNC_CODE_INST_INDIRECTBR
@ FUNC_CODE_DEBUG_RECORD_VALUE_SIMPLE
@ FUNC_CODE_INST_INSERTVAL
@ FUNC_CODE_DECLAREBLOCKS
@ FUNC_CODE_DEBUG_RECORD_LABEL
@ FUNC_CODE_INST_INSERTELT
@ FUNC_CODE_BLOCKADDR_USERS
@ FUNC_CODE_INST_CLEANUPPAD
@ FUNC_CODE_INST_SHUFFLEVEC
@ FUNC_CODE_INST_UNREACHABLE
@ FUNC_CODE_DEBUG_RECORD_DECLARE
@ FUNC_CODE_OPERAND_BUNDLE
@ FIRST_APPLICATION_ABBREV
@ PARAMATTR_GRP_CODE_ENTRY
initializer< Ty > init(const Ty &Val)
Error build(ArrayRef< Module * > Mods, SmallVector< char, 0 > &Symtab, StringTableBuilder &StrtabBuilder, BumpPtrAllocator &Alloc)
Fills in Symtab and StrtabBuilder with a valid symbol and string table for Mods.
template llvm::DenseMap< LinearFrameId, FrameStat > computeFrameHistogram< LinearFrameId >(llvm::MapVector< CallStackId, llvm::SmallVector< LinearFrameId > > &MemProfCallStackData)
NodeAddr< CodeNode * > Code
void write32le(void *P, uint32_t V)
uint32_t read32be(const void *P)
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
unsigned Log2_32_Ceil(uint32_t Value)
Return the ceil log base 2 of the specified value, 32 if the value is zero.
unsigned encode(MaybeAlign A)
Returns a representation of the alignment that encodes undefined as 0.
void WriteBitcodeToFile(const Module &M, raw_ostream &Out, bool ShouldPreserveUseListOrder=false, const ModuleSummaryIndex *Index=nullptr, bool GenerateHash=false, ModuleHash *ModHash=nullptr)
Write the specified module to the specified raw output stream.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
void writeThinLinkBitcodeToFile(const Module &M, raw_ostream &Out, const ModuleSummaryIndex &Index, const ModuleHash &ModHash)
Write the specified thin link bitcode file (i.e., the minimized bitcode file) to the given raw output...
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
FunctionSummary::ForceSummaryHotnessType ForceSummaryEdgesCold
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
void writeIndexToFile(const ModuleSummaryIndex &Index, raw_ostream &Out, const ModuleToSummariesForIndexTy *ModuleToSummariesForIndex=nullptr, const GVSummaryPtrSet *DecSummaries=nullptr)
Write the specified module summary index to the given raw output stream, where it will be written in ...
void embedBitcodeInModule(Module &M, MemoryBufferRef Buf, bool EmbedBitcode, bool EmbedCmdline, const std::vector< uint8_t > &CmdArgs)
If EmbedBitcode is set, save a copy of the llvm IR as data in the __LLVM,__bitcode section (....
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Error write(MCStreamer &Out, ArrayRef< std::string > Inputs, OnCuIndexOverflow OverflowOptValue)
void sort(IteratorTy Start, IteratorTy End)
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
AtomicOrdering
Atomic ordering for LLVM's memory model.
std::unordered_set< GlobalValueSummary * > GVSummaryPtrSet
A set of global value summary pointers.
DWARFExpression::Operation Op
std::map< std::string, GVSummaryMapTy, std::less<> > ModuleToSummariesForIndexTy
Map of a module name to the GUIDs and summaries we will import from that module.
OutputIt copy(R &&Range, OutputIt Out)
constexpr unsigned BitWidth
std::array< uint32_t, 5 > ModuleHash
160 bits SHA1
bool isBitcode(const unsigned char *BufPtr, const unsigned char *BufEnd)
isBitcode - Return true if the given bytes are the magic bytes for LLVM IR bitcode,...
std::vector< TypeIdOffsetVtableInfo > TypeIdCompatibleVtableInfo
List of vtable definitions decorated by a particular type identifier, and their corresponding offsets...
void consumeError(Error Err)
Consume a Error without doing anything.
GlobalVariable * collectUsedGlobalVariables(const Module &M, SmallVectorImpl< GlobalValue * > &Vec, bool CompilerUsed)
Given "llvm.used" or "llvm.compiler.used" as a global name, collect the initializer elements of that ...
This struct is a compact representation of a valid (non-zero power of two) alignment.
Class to accumulate and hold information about a callee.
static constexpr unsigned RelBlockFreqBits
The value stored in RelBlockFreq has to be interpreted as the digits of a scaled number with a scale ...
Flags specific to function summaries.
static constexpr uint32_t RangeWidth
Group flags (Linkage, NotEligibleToImport, etc.) as a bitfield.
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
static const Target * lookupTarget(StringRef Triple, std::string &Error)
lookupTarget - Lookup a target based on a target triple.
Structure to hold a use-list order.
ValID - Represents a reference of a definition of some sort with no type.
Struct that holds a reference to a particular GUID in a global value summary.
uint64_t Info
Additional information for the resolution:
enum llvm::WholeProgramDevirtResolution::ByArg::Kind TheKind
enum llvm::WholeProgramDevirtResolution::Kind TheKind
std::map< std::vector< uint64_t >, ByArg > ResByArg
Resolutions for calls with all constant integer arguments (excluding the first argument,...
std::string SingleImplName