diff options
author | Teresa Johnson <tejohnson@google.com> | 2016-02-06 16:07:35 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2016-02-06 16:07:35 +0000 |
commit | 5e22e4461d23130484dfdc83d2646f1a92d8e74d (patch) | |
tree | c325e41e05c24cfba8d985fef7e09f3d143ce6bb /llvm/lib/Bitcode | |
parent | 63b1ecab7ddc4d766263415c70f0794cedc2c11f (diff) | |
download | bcm5719-llvm-5e22e4461d23130484dfdc83d2646f1a92d8e74d.tar.gz bcm5719-llvm-5e22e4461d23130484dfdc83d2646f1a92d8e74d.zip |
[ThinLTO] Include linkage type in function summary
Summary:
Adds the linkage type to both the per-module and combined function
summaries, which subsumes the current islocal bit. This will eventually
be used to optimized linkage types based on global summary-based
analysis.
Reviewers: joker.eph
Subscribers: joker.eph, davidxl, llvm-commits
Differential Revision: http://reviews.llvm.org/D16943
llvm-svn: 259993
Diffstat (limited to 'llvm/lib/Bitcode')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 12 | ||||
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 16 |
2 files changed, 18 insertions, 10 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 36650dbe05a..176d836bf13 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -5592,14 +5592,14 @@ std::error_code FunctionIndexBitcodeReader::parseEntireSummary() { switch (Stream.readRecord(Entry.ID, Record)) { default: // Default behavior: ignore. break; - // FS_PERMODULE_ENTRY: [valueid, islocal, instcount] + // FS_PERMODULE_ENTRY: [valueid, linkage, instcount] case bitc::FS_CODE_PERMODULE_ENTRY: { unsigned ValueID = Record[0]; - bool IsLocal = Record[1]; + uint64_t RawLinkage = Record[1]; unsigned InstCount = Record[2]; std::unique_ptr<FunctionSummary> FS = llvm::make_unique<FunctionSummary>(InstCount); - FS->setLocalFunction(IsLocal); + FS->setFunctionLinkage(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 @@ -5609,12 +5609,14 @@ std::error_code FunctionIndexBitcodeReader::parseEntireSummary() { TheIndex->addModulePath(Buffer->getBufferIdentifier(), 0)); SummaryMap[ValueID] = std::move(FS); } - // FS_COMBINED_ENTRY: [modid, instcount] + // FS_COMBINED_ENTRY: [modid, linkage, instcount] case bitc::FS_CODE_COMBINED_ENTRY: { uint64_t ModuleId = Record[0]; - unsigned InstCount = Record[1]; + uint64_t RawLinkage = Record[1]; + unsigned InstCount = Record[2]; std::unique_ptr<FunctionSummary> FS = llvm::make_unique<FunctionSummary>(InstCount); + FS->setFunctionLinkage(getDecodedLinkage(RawLinkage)); FS->setModulePath(ModuleIdMap[ModuleId]); SummaryMap[CurRecordBit] = std::move(FS); } diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 5f85882cd40..bccd0430a09 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -496,8 +496,8 @@ static void WriteTypeTable(const ValueEnumerator &VE, BitstreamWriter &Stream) { Stream.ExitBlock(); } -static unsigned getEncodedLinkage(const GlobalValue &GV) { - switch (GV.getLinkage()) { +static unsigned getEncodedLinkage(const GlobalValue::LinkageTypes Linkage) { + switch (Linkage) { case GlobalValue::ExternalLinkage: return 0; case GlobalValue::WeakAnyLinkage: @@ -524,6 +524,10 @@ static unsigned getEncodedLinkage(const GlobalValue &GV) { llvm_unreachable("Invalid linkage"); } +static unsigned getEncodedLinkage(const GlobalValue &GV) { + return getEncodedLinkage(GV.getLinkage()); +} + static unsigned getEncodedVisibility(const GlobalValue &GV) { switch (GV.getVisibility()) { case GlobalValue::DefaultVisibility: return 0; @@ -2449,7 +2453,7 @@ static void SaveFunctionInfo( std::unique_ptr<FunctionSummary> FuncSummary; if (EmitFunctionSummary) { FuncSummary = llvm::make_unique<FunctionSummary>(NumInsts); - FuncSummary->setLocalFunction(F.hasLocalLinkage()); + FuncSummary->setFunctionLinkage(F.getLinkage()); } FunctionIndex[&F] = llvm::make_unique<FunctionInfo>(BitcodeIndex, std::move(FuncSummary)); @@ -2776,7 +2780,7 @@ static void WritePerModuleFunctionSummaryRecord( unsigned FSAbbrev, BitstreamWriter &Stream) { assert(FS); NameVals.push_back(ValueID); - NameVals.push_back(FS->isLocalFunction()); + NameVals.push_back(getEncodedLinkage(FS->getFunctionLinkage())); NameVals.push_back(FS->instCount()); // Emit the finished record. @@ -2795,7 +2799,7 @@ static void WritePerModuleFunctionSummary( BitCodeAbbrev *Abbv = new BitCodeAbbrev(); Abbv->Add(BitCodeAbbrevOp(bitc::FS_CODE_PERMODULE_ENTRY)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // valueid - Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // islocal + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // instcount unsigned FSAbbrev = Stream.EmitAbbrev(Abbv); @@ -2845,6 +2849,7 @@ static void WriteCombinedFunctionSummary(const FunctionInfoIndex &I, BitCodeAbbrev *Abbv = new BitCodeAbbrev(); Abbv->Add(BitCodeAbbrevOp(bitc::FS_CODE_COMBINED_ENTRY)); Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // modid + Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 5)); // linkage Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // instcount unsigned FSAbbrev = Stream.EmitAbbrev(Abbv); @@ -2855,6 +2860,7 @@ static void WriteCombinedFunctionSummary(const FunctionInfoIndex &I, assert(FS); NameVals.push_back(I.getModuleId(FS->modulePath())); + NameVals.push_back(getEncodedLinkage(FS->getFunctionLinkage())); NameVals.push_back(FS->instCount()); // Record the starting offset of this summary entry for use |