summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-04-13 17:18:42 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-04-13 17:18:42 +0000
commitce744a95fd99e7b9ae368e2f98de60b09c70fed0 (patch)
treeef64981e3528a03565000d7b4a5fe58d6a5e8179 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp
parentf5a7ec7a5ced6720b84dbebe2b396bc95cadce09 (diff)
downloadbcm5719-llvm-ce744a95fd99e7b9ae368e2f98de60b09c70fed0.tar.gz
bcm5719-llvm-ce744a95fd99e7b9ae368e2f98de60b09c70fed0.zip
Make aliases explicit in the summary
Summary: To be able to work accurately on the reference graph when taking decision about internalizing, promoting, renaming, etc. We need to have the alias information explicit. Reviewers: tejohnson Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D18836 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 266214
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 321c775531e..e5fb51b1bed 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -5848,6 +5848,35 @@ 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];
@@ -5906,6 +5935,28 @@ 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];
OpenPOWER on IntegriCloud