diff options
author | Mehdi Amini <mehdi.amini@apple.com> | 2016-04-13 17:20:07 +0000 |
---|---|---|
committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-04-13 17:20:07 +0000 |
commit | b5b289339b51e4f180ffca55e31d62429275ee67 (patch) | |
tree | d4bb39a9534ada0a25bd594d6e9a5a74d40a2f5c /llvm/lib/Bitcode | |
parent | ce744a95fd99e7b9ae368e2f98de60b09c70fed0 (diff) | |
download | bcm5719-llvm-b5b289339b51e4f180ffca55e31d62429275ee67.tar.gz bcm5719-llvm-b5b289339b51e4f180ffca55e31d62429275ee67.zip |
Revert "Make aliases explicit in the summary"
Inadvertently commited...
This reverts commit e618ec93786d99df2ddf280ad2d5e02f5516cecf.
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266215
Diffstat (limited to 'llvm/lib/Bitcode')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 51 | ||||
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 70 |
2 files changed, 3 insertions, 118 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index e5fb51b1bed..321c775531e 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -5848,35 +5848,6 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() { Info->setSummary(std::move(FS)); break; } - // FS_ALIAS: [valueid, linkage, valueid] - // Aliases must be emitted (and parsed) after all FS_PERMODULE entries, as - // they expect all aliasee summaries to be available. - case bitc::FS_ALIAS: { - unsigned ValueID = Record[0]; - uint64_t RawLinkage = Record[1]; - unsigned AliaseeID = Record[2]; - std::unique_ptr<AliasSummary> AS = - llvm::make_unique<AliasSummary>(getDecodedLinkage(RawLinkage)); - // The module path string ref set in the summary must be owned by the - // index's module string table. Since we don't have a module path - // string table section in the per-module index, we create a single - // module path string table entry with an empty (0) ID to take - // ownership. - AS->setModulePath( - TheIndex->addModulePath(Buffer->getBufferIdentifier(), 0)->first()); - - GlobalValue::GUID AliaseeGUID = getGUIDFromValueId(AliaseeID); - auto *AliaseeInfo = TheIndex->getGlobalValueInfo(AliaseeGUID); - if (!AliaseeInfo->summary()) - return error("Alias expects aliasee summary to be parsed"); - AS->setAliasee(AliaseeInfo->summary()); - - GlobalValue::GUID GUID = getGUIDFromValueId(ValueID); - auto *Info = TheIndex->getGlobalValueInfo(GUID); - assert(!Info->summary() && "Expected a single summary per VST entry"); - Info->setSummary(std::move(AS)); - break; - } // FS_PERMODULE_GLOBALVAR_INIT_REFS: [valueid, linkage, n x valueid] case bitc::FS_PERMODULE_GLOBALVAR_INIT_REFS: { unsigned ValueID = Record[0]; @@ -5935,28 +5906,6 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseEntireSummary() { Combined = true; break; } - // FS_COMBINED_ALIAS: [modid, linkage, offset] - // Aliases must be emitted (and parsed) after all FS_PERMODULE entries, as - // they expect all aliasee summaries to be available. - case bitc::FS_COMBINED_ALIAS: { - uint64_t ModuleId = Record[0]; - uint64_t RawLinkage = Record[1]; - uint64_t AliaseeSummaryOffset = Record[2]; - std::unique_ptr<AliasSummary> AS = - llvm::make_unique<AliasSummary>(getDecodedLinkage(RawLinkage)); - AS->setModulePath(ModuleIdMap[ModuleId]); - - auto *AliaseeInfo = getInfoFromSummaryOffset(AliaseeSummaryOffset); - if (!AliaseeInfo->summary()) - return error("Alias expects aliasee summary to be parsed"); - AS->setAliasee(AliaseeInfo->summary()); - - auto *Info = getInfoFromSummaryOffset(CurRecordBit); - assert(!Info->summary() && "Expected a single summary per VST entry"); - Info->setSummary(std::move(AS)); - Combined = true; - break; - } // FS_COMBINED_GLOBALVAR_INIT_REFS: [modid, linkage, n x valueid] case bitc::FS_COMBINED_GLOBALVAR_INIT_REFS: { uint64_t ModuleId = Record[0]; diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index a55f4954b45..1b90c885a9b 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -2924,24 +2924,16 @@ static void WritePerModuleGlobalValueSummary(const Module *M, Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); unsigned FSModRefsAbbrev = Stream.EmitAbbrev(Abbv); - // Abbrev for FS_ALIAS. - Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(bitc::FS_ALIAS)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid - unsigned FSAliasAbbrev = Stream.EmitAbbrev(Abbv); - SmallVector<uint64_t, 64> NameVals; // Iterate over the list of functions instead of the Index to // ensure the ordering is stable. for (const Function &F : *M) { if (F.isDeclaration()) continue; - // We shouldn't have any anonymous functions as they are not supported in - // ThinLTO and should be renamed. + // Skip anonymous functions. We will emit a function summary for + // any aliases below. if (!F.hasName()) - report_fatal_error("Unexpected anonymous function when writing summary"); + continue; auto *Info = Index.getGlobalValueInfo(F); WritePerModuleFunctionSummaryRecord( @@ -2955,20 +2947,6 @@ static void WritePerModuleGlobalValueSummary(const Module *M, for (const GlobalVariable &G : M->globals()) WriteModuleLevelReferences(G, Index, VE, NameVals, FSModRefsAbbrev, Stream); - for (const GlobalAlias &A : M->aliases()) { - auto *Aliasee = A.getBaseObject(); - if (!Aliasee->hasName()) - // Nameless function don't have an entry in the summary, skip it. - continue; - auto AliasId = VE.getValueID(&A); - auto AliaseeId = VE.getValueID(Aliasee); - NameVals.push_back(AliasId); - NameVals.push_back(getEncodedLinkage(A.getLinkage())); - NameVals.push_back(AliaseeId); - Stream.EmitRecord(bitc::FS_ALIAS, NameVals, FSAliasAbbrev); - NameVals.clear(); - } - Stream.ExitBlock(); } @@ -3012,31 +2990,11 @@ static void WriteCombinedGlobalValueSummary( Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); unsigned FSModRefsAbbrev = Stream.EmitAbbrev(Abbv); - // Abbrev for FS_COMBINED_ALIAS. - Abbv = new BitCodeAbbrev(); - Abbv->Add(BitCodeAbbrevOp(bitc::FS_COMBINED_ALIAS)); - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // modid - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // offset - unsigned FSAliasAbbrev = Stream.EmitAbbrev(Abbv); - - // The aliases are emitted as a post-pass, and will point to the summary - // offset id of the aliasee. For this purpose we need to be able to get back - // from the summary to the offset - SmallVector<GlobalValueInfo *, 64> Aliases; - DenseMap<const GlobalValueSummary *, uint64_t> SummaryToOffsetMap; - SmallVector<uint64_t, 64> NameVals; for (const auto &FII : Index) { for (auto &FI : FII.second) { GlobalValueSummary *S = FI->summary(); assert(S); - if (isa<AliasSummary>(S)) { - // Will process aliases as a post-pass because the reader wants all - // global to be loaded first. - Aliases.push_back(FI.get()); - continue; - } if (auto *VS = dyn_cast<GlobalVarSummary>(S)) { NameVals.push_back(Index.getModuleId(VS->modulePath())); @@ -3059,8 +3017,6 @@ static void WriteCombinedGlobalValueSummary( // reader will invoke readRecord after the abbrev id read. FI->setBitcodeIndex(Stream.GetCurrentBitNo() + Stream.GetAbbrevIDWidth()); - // Store temporarily the offset in the map for a possible alias. - SummaryToOffsetMap[S] = FI->bitcodeIndex(); // Emit the finished record. Stream.EmitRecord(bitc::FS_COMBINED_GLOBALVAR_INIT_REFS, NameVals, @@ -3112,8 +3068,6 @@ static void WriteCombinedGlobalValueSummary( // in the VST entry. Add the current code size since the // reader will invoke readRecord after the abbrev id read. FI->setBitcodeIndex(Stream.GetCurrentBitNo() + Stream.GetAbbrevIDWidth()); - // Store temporarily the offset in the map for a possible alias. - SummaryToOffsetMap[S] = FI->bitcodeIndex(); unsigned FSAbbrev = (HasProfileData ? FSCallsProfileAbbrev : FSCallsAbbrev); @@ -3126,24 +3080,6 @@ static void WriteCombinedGlobalValueSummary( } } - for (auto GVI : Aliases) { - AliasSummary *AS = cast<AliasSummary>(GVI->summary()); - NameVals.push_back(Index.getModuleId(AS->modulePath())); - NameVals.push_back(getEncodedLinkage(AS->linkage())); - auto AliaseeOffset = SummaryToOffsetMap[&AS->getAliasee()]; - assert(AliaseeOffset); - NameVals.push_back(AliaseeOffset); - - // Record the starting offset of this summary entry for use - // in the VST entry. Add the current code size since the - // reader will invoke readRecord after the abbrev id read. - GVI->setBitcodeIndex(Stream.GetCurrentBitNo() + Stream.GetAbbrevIDWidth()); - - // Emit the finished record. - Stream.EmitRecord(bitc::FS_COMBINED_ALIAS, NameVals, FSAliasAbbrev); - NameVals.clear(); - } - Stream.ExitBlock(); } |