Bitcode: Make the summary reader responsible for merging. NFCI.

This is to prepare for an upcoming change which uses pointers instead of
GUIDs to represent references.

Differential Revision: https://reviews.llvm.org/D32469

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301843 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Peter Collingbourne
2017-05-01 22:04:36 +00:00
parent 4d051558e4
commit 10dbf12dd6
7 changed files with 82 additions and 87 deletions
-36
View File
@@ -16,42 +16,6 @@
#include "llvm/ADT/StringMap.h"
using namespace llvm;
// Create the combined module index/summary from multiple
// per-module instances.
void ModuleSummaryIndex::mergeFrom(std::unique_ptr<ModuleSummaryIndex> Other,
uint64_t NextModuleId) {
if (Other->modulePaths().empty())
return;
assert(Other->modulePaths().size() == 1 &&
"Can only merge from an single-module index at that time");
StringRef OtherModPath = Other->modulePaths().begin()->first();
StringRef ModPath = addModulePath(OtherModPath, NextModuleId,
Other->getModuleHash(OtherModPath))
->first();
for (auto &OtherGlobalValSummaryLists : *Other) {
GlobalValue::GUID ValueGUID = OtherGlobalValSummaryLists.first;
GlobalValueSummaryList &List = OtherGlobalValSummaryLists.second;
// Assert that the value summary list only has one entry, since we shouldn't
// have duplicate names within a single per-module index.
assert(List.size() == 1);
std::unique_ptr<GlobalValueSummary> Summary = std::move(List.front());
// Note the module path string ref was copied above and is still owned by
// the original per-module index. Reset it to the new module path
// string reference owned by the combined index.
Summary->setModulePath(ModPath);
// Add new value summary to existing list. There may be duplicates when
// combining GlobalValueMap entries, due to COMDAT values. Any local
// values were given unique global IDs.
addGlobalValueSummary(ValueGUID, std::move(Summary));
}
}
// Collect for the given module the list of function it defines
// (GUID -> Summary).
void ModuleSummaryIndex::collectDefinedFunctionsForModule(