diff options
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r-- | contrib/llvm-project/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 230 |
1 files changed, 134 insertions, 96 deletions
diff --git a/contrib/llvm-project/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/contrib/llvm-project/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 9416c7f5a03e..8fca569a391b 100644 --- a/contrib/llvm-project/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/contrib/llvm-project/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -123,6 +123,7 @@ enum { FUNCTION_INST_BINOP_ABBREV, FUNCTION_INST_BINOP_FLAGS_ABBREV, FUNCTION_INST_CAST_ABBREV, + FUNCTION_INST_CAST_FLAGS_ABBREV, FUNCTION_INST_RET_VOID_ABBREV, FUNCTION_INST_RET_VAL_ABBREV, FUNCTION_INST_UNREACHABLE_ABBREV, @@ -335,8 +336,7 @@ private: unsigned Abbrev); void writeDIMacroFile(const DIMacroFile *N, SmallVectorImpl<uint64_t> &Record, unsigned Abbrev); - void writeDIArgList(const DIArgList *N, SmallVectorImpl<uint64_t> &Record, - unsigned Abbrev); + void writeDIArgList(const DIArgList *N, SmallVectorImpl<uint64_t> &Record); void writeDIModule(const DIModule *N, SmallVectorImpl<uint64_t> &Record, unsigned Abbrev); void writeDIAssignID(const DIAssignID *N, SmallVectorImpl<uint64_t> &Record, @@ -431,6 +431,10 @@ class IndexBitcodeWriter : public BitcodeWriterBase { /// Tracks the last value id recorded in the GUIDToValueMap. unsigned GlobalValueId = 0; + /// Tracks the assignment of module paths in the module path string table to + /// an id assigned for use in summary references to the module path. + DenseMap<StringRef, uint64_t> ModuleIdMap; + public: /// Constructs a IndexBitcodeWriter object for the given combined index, /// writing to the provided \p Buffer. When writing a subset of the index @@ -512,8 +516,16 @@ public: Callback(*MPI); } } else { - for (const auto &MPSE : Index.modulePaths()) - Callback(MPSE); + // Since StringMap iteration order isn't guaranteed, order by path string + // first. + // FIXME: Make this a vector of StringMapEntry instead to avoid the later + // map lookup. + std::vector<StringRef> ModulePaths; + for (auto &[ModPath, _] : Index.modulePaths()) + ModulePaths.push_back(ModPath); + llvm::sort(ModulePaths.begin(), ModulePaths.end()); + for (auto &ModPath : ModulePaths) + Callback(*Index.modulePaths().find(ModPath)); } } @@ -735,6 +747,8 @@ static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind) { return bitc::ATTR_KIND_NO_SANITIZE_COVERAGE; case Attribute::NullPointerIsValid: return bitc::ATTR_KIND_NULL_POINTER_IS_VALID; + case Attribute::OptimizeForDebugging: + return bitc::ATTR_KIND_OPTIMIZE_FOR_DEBUGGING; case Attribute::OptForFuzzing: return bitc::ATTR_KIND_OPT_FOR_FUZZING; case Attribute::OptimizeForSize: @@ -809,6 +823,12 @@ static uint64_t getAttrKindEncoding(Attribute::AttrKind Kind) { return bitc::ATTR_KIND_MUSTPROGRESS; case Attribute::PresplitCoroutine: return bitc::ATTR_KIND_PRESPLIT_COROUTINE; + case Attribute::Writable: + return bitc::ATTR_KIND_WRITABLE; + case Attribute::CoroDestroyOnlyWhenComplete: + return bitc::ATTR_KIND_CORO_ONLY_DESTROY_WHEN_COMPLETE; + case Attribute::DeadOnUnwind: + return bitc::ATTR_KIND_DEAD_ON_UNWIND; case Attribute::EndAttrKinds: llvm_unreachable("Can not encode end-attribute kinds marker."); case Attribute::None: @@ -1139,6 +1159,24 @@ static uint64_t getEncodedGVarFlags(GlobalVarSummary::GVarFlags Flags) { return RawFlags; } +static uint64_t getEncodedHotnessCallEdgeInfo(const CalleeInfo &CI) { + uint64_t RawFlags = 0; + + RawFlags |= CI.Hotness; // 3 bits + RawFlags |= (CI.HasTailCall << 3); // 1 bit + + return RawFlags; +} + +static uint64_t getEncodedRelBFCallEdgeInfo(const CalleeInfo &CI) { + uint64_t RawFlags = 0; + + RawFlags |= CI.RelBlockFreq; // CalleeInfo::RelBlockFreqBits bits + RawFlags |= (CI.HasTailCall << CalleeInfo::RelBlockFreqBits); // 1 bit + + return RawFlags; +} + static unsigned getEncodedVisibility(const GlobalValue &GV) { switch (GV.getVisibility()) { case GlobalValue::DefaultVisibility: return 0; @@ -1385,7 +1423,7 @@ void ModuleBitcodeWriter::writeModuleInfo() { // GLOBALVAR: [strtab offset, strtab size, type, isconst, initid, // linkage, alignment, section, visibility, threadlocal, // unnamed_addr, externally_initialized, dllstorageclass, - // comdat, attributes, DSO_Local, GlobalSanitizer] + // comdat, attributes, DSO_Local, GlobalSanitizer, code_model] Vals.push_back(addToStrtab(GV.getName())); Vals.push_back(GV.getName().size()); Vals.push_back(VE.getTypeID(GV.getValueType())); @@ -1402,7 +1440,7 @@ void ModuleBitcodeWriter::writeModuleInfo() { GV.isExternallyInitialized() || GV.getDLLStorageClass() != GlobalValue::DefaultStorageClass || GV.hasComdat() || GV.hasAttributes() || GV.isDSOLocal() || - GV.hasPartition() || GV.hasSanitizerMetadata()) { + GV.hasPartition() || GV.hasSanitizerMetadata() || GV.getCodeModel()) { Vals.push_back(getEncodedVisibility(GV)); Vals.push_back(getEncodedThreadLocalMode(GV)); Vals.push_back(getEncodedUnnamedAddr(GV)); @@ -1420,6 +1458,7 @@ void ModuleBitcodeWriter::writeModuleInfo() { Vals.push_back((GV.hasSanitizerMetadata() ? serializeSanitizerMetadata( GV.getSanitizerMetadata()) : 0)); + Vals.push_back(GV.getCodeModelRaw()); } else { AbbrevToUse = SimpleGVarAbbrev; } @@ -1522,6 +1561,9 @@ static uint64_t getOptimizationFlags(const Value *V) { } else if (const auto *PEO = dyn_cast<PossiblyExactOperator>(V)) { if (PEO->isExact()) Flags |= 1 << bitc::PEO_EXACT; + } else if (const auto *PDI = dyn_cast<PossiblyDisjointInst>(V)) { + if (PDI->isDisjoint()) + Flags |= 1 << bitc::PDI_DISJOINT; } else if (const auto *FPMO = dyn_cast<FPMathOperator>(V)) { if (FPMO->hasAllowReassoc()) Flags |= bitc::AllowReassoc; @@ -1537,6 +1579,9 @@ static uint64_t getOptimizationFlags(const Value *V) { Flags |= bitc::AllowContract; if (FPMO->hasApproxFunc()) Flags |= bitc::ApproxFunc; + } else if (const auto *NNI = dyn_cast<PossiblyNonNegInst>(V)) { + if (NNI->hasNonNeg()) + Flags |= 1 << bitc::PNNI_NON_NEG; } return Flags; @@ -1953,13 +1998,12 @@ void ModuleBitcodeWriter::writeDIMacroFile(const DIMacroFile *N, } void ModuleBitcodeWriter::writeDIArgList(const DIArgList *N, - SmallVectorImpl<uint64_t> &Record, - unsigned Abbrev) { + SmallVectorImpl<uint64_t> &Record) { Record.reserve(N->getArgs().size()); for (ValueAsMetadata *MD : N->getArgs()) Record.push_back(VE.getMetadataID(MD)); - Stream.EmitRecord(bitc::METADATA_ARG_LIST, Record, Abbrev); + Stream.EmitRecord(bitc::METADATA_ARG_LIST, Record); Record.clear(); } @@ -2242,6 +2286,10 @@ void ModuleBitcodeWriter::writeMetadataRecords( #include "llvm/IR/Metadata.def" } } + if (auto *AL = dyn_cast<DIArgList>(MD)) { + writeDIArgList(AL, Record); + continue; + } writeValueAsMetadata(cast<ValueAsMetadata>(MD), Record); } } @@ -2813,6 +2861,12 @@ void ModuleBitcodeWriter::writeInstruction(const Instruction &I, AbbrevToUse = FUNCTION_INST_CAST_ABBREV; Vals.push_back(VE.getTypeID(I.getType())); Vals.push_back(getEncodedCastOpcode(I.getOpcode())); + uint64_t Flags = getOptimizationFlags(&I); + if (Flags != 0) { + if (AbbrevToUse == FUNCTION_INST_CAST_ABBREV) + AbbrevToUse = FUNCTION_INST_CAST_FLAGS_ABBREV; + Vals.push_back(Flags); + } } else { assert(isa<BinaryOperator>(I) && "Unknown instruction!"); Code = bitc::FUNC_CODE_INST_BINOP; @@ -3634,6 +3688,18 @@ void ModuleBitcodeWriter::writeBlockInfo() { FUNCTION_INST_CAST_ABBREV) llvm_unreachable("Unexpected abbrev ordering!"); } + { // INST_CAST_FLAGS abbrev for FUNCTION_BLOCK. + auto Abbv = std::make_shared<BitCodeAbbrev>(); + Abbv->Add(BitCodeAbbrevOp(bitc::FUNC_CODE_INST_CAST)); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // OpVal + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, // dest ty + VE.computeBitsRequiredForTypeIndicies())); + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // opc + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8)); // flags + if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID, Abbv) != + FUNCTION_INST_CAST_FLAGS_ABBREV) + llvm_unreachable("Unexpected abbrev ordering!"); + } { // INST_RET abbrev for FUNCTION_BLOCK. auto Abbv = std::make_shared<BitCodeAbbrev>(); @@ -3715,33 +3781,33 @@ void IndexBitcodeWriter::writeModStrings() { unsigned AbbrevHash = Stream.EmitAbbrev(std::move(Abbv)); SmallVector<unsigned, 64> Vals; - forEachModule( - [&](const StringMapEntry<std::pair<uint64_t, ModuleHash>> &MPSE) { - StringRef Key = MPSE.getKey(); - const auto &Value = MPSE.getValue(); - StringEncoding Bits = getStringEncoding(Key); - unsigned AbbrevToUse = Abbrev8Bit; - if (Bits == SE_Char6) - AbbrevToUse = Abbrev6Bit; - else if (Bits == SE_Fixed7) - AbbrevToUse = Abbrev7Bit; - - Vals.push_back(Value.first); - Vals.append(Key.begin(), Key.end()); - - // Emit the finished record. - Stream.EmitRecord(bitc::MST_CODE_ENTRY, Vals, AbbrevToUse); - - // Emit an optional hash for the module now - const auto &Hash = Value.second; - if (llvm::any_of(Hash, [](uint32_t H) { return H; })) { - Vals.assign(Hash.begin(), Hash.end()); - // Emit the hash record. - Stream.EmitRecord(bitc::MST_CODE_HASH, Vals, AbbrevHash); - } + forEachModule([&](const StringMapEntry<ModuleHash> &MPSE) { + StringRef Key = MPSE.getKey(); + const auto &Hash = MPSE.getValue(); + StringEncoding Bits = getStringEncoding(Key); + unsigned AbbrevToUse = Abbrev8Bit; + if (Bits == SE_Char6) + AbbrevToUse = Abbrev6Bit; + else if (Bits == SE_Fixed7) + AbbrevToUse = Abbrev7Bit; - Vals.clear(); - }); + auto ModuleId = ModuleIdMap.size(); + ModuleIdMap[Key] = ModuleId; + Vals.push_back(ModuleId); + Vals.append(Key.begin(), Key.end()); + + // Emit the finished record. + Stream.EmitRecord(bitc::MST_CODE_ENTRY, Vals, AbbrevToUse); + + // Emit an optional hash for the module now + if (llvm::any_of(Hash, [](uint32_t H) { return H; })) { + Vals.assign(Hash.begin(), Hash.end()); + // Emit the hash record. + Stream.EmitRecord(bitc::MST_CODE_HASH, Vals, AbbrevHash); + } + + Vals.clear(); + }); Stream.ExitBlock(); } @@ -3963,8 +4029,9 @@ static void writeFunctionHeapProfileRecords( // Helper to emit a single function summary record. void ModuleBitcodeWriterBase::writePerModuleFunctionSummaryRecord( SmallVector<uint64_t, 64> &NameVals, GlobalValueSummary *Summary, - unsigned ValueID, unsigned FSCallsAbbrev, unsigned FSCallsProfileAbbrev, - unsigned CallsiteAbbrev, unsigned AllocAbbrev, const Function &F) { + unsigned ValueID, unsigned FSCallsRelBFAbbrev, + unsigned FSCallsProfileAbbrev, unsigned CallsiteAbbrev, + unsigned AllocAbbrev, const Function &F) { NameVals.push_back(ValueID); FunctionSummary *FS = cast<FunctionSummary>(Summary); @@ -3991,21 +4058,21 @@ void ModuleBitcodeWriterBase::writePerModuleFunctionSummaryRecord( for (auto &RI : FS->refs()) NameVals.push_back(VE.getValueID(RI.getValue())); - bool HasProfileData = - F.hasProfileData() || ForceSummaryEdgesCold != FunctionSummary::FSHT_None; + const bool UseRelBFRecord = + WriteRelBFToSummary && !F.hasProfileData() && + ForceSummaryEdgesCold == FunctionSummary::FSHT_None; for (auto &ECI : FS->calls()) { NameVals.push_back(getValueId(ECI.first)); - if (HasProfileData) - NameVals.push_back(static_cast<uint8_t>(ECI.second.Hotness)); - else if (WriteRelBFToSummary) - NameVals.push_back(ECI.second.RelBlockFreq); + if (UseRelBFRecord) + NameVals.push_back(getEncodedRelBFCallEdgeInfo(ECI.second)); + else + NameVals.push_back(getEncodedHotnessCallEdgeInfo(ECI.second)); } - unsigned FSAbbrev = (HasProfileData ? FSCallsProfileAbbrev : FSCallsAbbrev); + unsigned FSAbbrev = + (UseRelBFRecord ? FSCallsRelBFAbbrev : FSCallsProfileAbbrev); unsigned Code = - (HasProfileData ? bitc::FS_PERMODULE_PROFILE - : (WriteRelBFToSummary ? bitc::FS_PERMODULE_RELBF - : bitc::FS_PERMODULE)); + (UseRelBFRecord ? bitc::FS_PERMODULE_RELBF : bitc::FS_PERMODULE_PROFILE); // Emit the finished record. Stream.EmitRecord(Code, NameVals, FSAbbrev); @@ -4114,17 +4181,14 @@ void ModuleBitcodeWriterBase::writePerModuleGlobalValueSummary() { Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // numrefs Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // rorefcnt Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // worefcnt - // numrefs x valueid, n x (valueid, hotness) + // numrefs x valueid, n x (valueid, hotness+tailcall flags) Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); unsigned FSCallsProfileAbbrev = Stream.EmitAbbrev(std::move(Abbv)); - // Abbrev for FS_PERMODULE or FS_PERMODULE_RELBF. + // Abbrev for FS_PERMODULE_RELBF. Abbv = std::make_shared<BitCodeAbbrev>(); - if (WriteRelBFToSummary) - Abbv->Add(BitCodeAbbrevOp(bitc::FS_PERMODULE_RELBF)); - else - Abbv->Add(BitCodeAbbrevOp(bitc::FS_PERMODULE)); + Abbv->Add(BitCodeAbbrevOp(bitc::FS_PERMODULE_RELBF)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // flags Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // instcount @@ -4132,10 +4196,10 @@ void ModuleBitcodeWriterBase::writePerModuleGlobalValueSummary() { Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // numrefs Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // rorefcnt Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // worefcnt - // numrefs x valueid, n x (valueid [, rel_block_freq]) + // numrefs x valueid, n x (valueid, rel_block_freq+tailcall]) Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); - unsigned FSCallsAbbrev = Stream.EmitAbbrev(std::move(Abbv)); + unsigned FSCallsRelBFAbbrev = Stream.EmitAbbrev(std::move(Abbv)); // Abbrev for FS_PERMODULE_GLOBALVAR_INIT_REFS. Abbv = std::make_shared<BitCodeAbbrev>(); @@ -4207,9 +4271,9 @@ void ModuleBitcodeWriterBase::writePerModuleGlobalValueSummary() { continue; } auto *Summary = VI.getSummaryList()[0].get(); - writePerModuleFunctionSummaryRecord(NameVals, Summary, VE.getValueID(&F), - FSCallsAbbrev, FSCallsProfileAbbrev, - CallsiteAbbrev, AllocAbbrev, F); + writePerModuleFunctionSummaryRecord( + NameVals, Summary, VE.getValueID(&F), FSCallsRelBFAbbrev, + FSCallsProfileAbbrev, CallsiteAbbrev, AllocAbbrev, F); } // Capture references from GlobalVariable initializers, which are outside @@ -4280,25 +4344,8 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() { Stream.EmitRecord(bitc::FS_STACK_IDS, StackIds, StackIdAbbvId); } - // Abbrev for FS_COMBINED. - auto Abbv = std::make_shared<BitCodeAbbrev>(); - Abbv->Add(BitCodeAbbrevOp(bitc::FS_COMBINED)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // modid - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // flags - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // instcount - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // fflags - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // entrycount - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // numrefs - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // rorefcnt - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // worefcnt - // numrefs x valueid, n x (valueid) - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); - unsigned FSCallsAbbrev = Stream.EmitAbbrev(std::move(Abbv)); - // Abbrev for FS_COMBINED_PROFILE. - Abbv = std::make_shared<BitCodeAbbrev>(); + auto Abbv = std::make_shared<BitCodeAbbrev>(); Abbv->Add(BitCodeAbbrevOp(bitc::FS_COMBINED_PROFILE)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // modid @@ -4309,7 +4356,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() { Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // numrefs Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // rorefcnt Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // worefcnt - // numrefs x valueid, n x (valueid, hotness) + // numrefs x valueid, n x (valueid, hotness+tailcall flags) Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); unsigned FSCallsProfileAbbrev = Stream.EmitAbbrev(std::move(Abbv)); @@ -4410,7 +4457,8 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() { if (auto *VS = dyn_cast<GlobalVarSummary>(S)) { NameVals.push_back(*ValueId); - NameVals.push_back(Index.getModuleId(VS->modulePath())); + assert(ModuleIdMap.count(VS->modulePath())); + NameVals.push_back(ModuleIdMap[VS->modulePath()]); NameVals.push_back(getEncodedGVSummaryFlags(VS->flags())); NameVals.push_back(getEncodedGVarFlags(VS->varflags())); for (auto &RI : VS->refs()) { @@ -4460,7 +4508,8 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() { }); NameVals.push_back(*ValueId); - NameVals.push_back(Index.getModuleId(FS->modulePath())); + assert(ModuleIdMap.count(FS->modulePath())); + NameVals.push_back(ModuleIdMap[FS->modulePath()]); NameVals.push_back(getEncodedGVSummaryFlags(FS->flags())); NameVals.push_back(FS->instCount()); NameVals.push_back(getEncodedFFlags(FS->fflags())); @@ -4487,14 +4536,6 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() { NameVals[7] = RORefCnt; NameVals[8] = WORefCnt; - bool HasProfileData = false; - for (auto &EI : FS->calls()) { - HasProfileData |= - EI.second.getHotness() != CalleeInfo::HotnessType::Unknown; - if (HasProfileData) - break; - } - for (auto &EI : FS->calls()) { // If this GUID doesn't have a value id, it doesn't have a function // summary and we don't need to record any calls to it. @@ -4502,16 +4543,12 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() { if (!CallValueId) continue; NameVals.push_back(*CallValueId); - if (HasProfileData) - NameVals.push_back(static_cast<uint8_t>(EI.second.Hotness)); + NameVals.push_back(getEncodedHotnessCallEdgeInfo(EI.second)); } - unsigned FSAbbrev = (HasProfileData ? FSCallsProfileAbbrev : FSCallsAbbrev); - unsigned Code = - (HasProfileData ? bitc::FS_COMBINED_PROFILE : bitc::FS_COMBINED); - // Emit the finished record. - Stream.EmitRecord(Code, NameVals, FSAbbrev); + Stream.EmitRecord(bitc::FS_COMBINED_PROFILE, NameVals, + FSCallsProfileAbbrev); NameVals.clear(); MaybeEmitOriginalName(*S); }); @@ -4520,7 +4557,8 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() { auto AliasValueId = SummaryToValueIdMap[AS]; assert(AliasValueId); NameVals.push_back(AliasValueId); - NameVals.push_back(Index.getModuleId(AS->modulePath())); + assert(ModuleIdMap.count(AS->modulePath())); + NameVals.push_back(ModuleIdMap[AS->modulePath()]); NameVals.push_back(getEncodedGVSummaryFlags(AS->flags())); auto AliaseeValueId = SummaryToValueIdMap[&AS->getAliasee()]; assert(AliaseeValueId); @@ -5137,7 +5175,7 @@ void llvm::embedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf, // Save llvm.compiler.used and remove it. SmallVector<Constant *, 2> UsedArray; SmallVector<GlobalValue *, 4> UsedGlobals; - Type *UsedElementType = Type::getInt8Ty(M.getContext())->getPointerTo(0); + Type *UsedElementType = PointerType::getUnqual(M.getContext()); GlobalVariable *Used = collectUsedGlobalVariables(M, UsedGlobals, true); for (auto *GV : UsedGlobals) { if (GV->getName() != "llvm.embedded.module" && |