diff options
author | Mehdi Amini <mehdi.amini@apple.com> | 2016-04-23 23:38:17 +0000 |
---|---|---|
committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-04-23 23:38:17 +0000 |
commit | ae64eafd31781d6eee0b23a6d4d5f50d84d143ec (patch) | |
tree | bc8c443446d72c38213f5be27e2837d7ecc29009 /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | |
parent | cb87494f4cbd4769c6769a752c2c9fb5c4e1bb00 (diff) | |
download | bcm5719-llvm-ae64eafd31781d6eee0b23a6d4d5f50d84d143ec.tar.gz bcm5719-llvm-ae64eafd31781d6eee0b23a6d4d5f50d84d143ec.zip |
Store and emit original name in combined index
Summary:
As discussed in D18298, some local globals can't
be renamed/promoted (because they have a section, or because
they are referenced from inline assembly).
To be able to detect naming collision, we need to keep around
the "GUID" using their original name without taking the linkage
into account.
Reviewers: tejohnson
Subscribers: joker.eph, llvm-commits
Differential Revision: http://reviews.llvm.org/D19454
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 267304
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 3be4fe03d51..302629b9176 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -3211,6 +3211,17 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() { DenseMap<const GlobalValueSummary *, uint64_t> SummaryToOffsetMap; SmallVector<uint64_t, 64> NameVals; + + // For local linkage, we also emit the original name separately + // immediately after the record. + auto MaybeEmitOriginalName = [&](GlobalValueSummary &S) { + if (!GlobalValue::isLocalLinkage(S.linkage())) + return; + NameVals.push_back(S.getOriginalName()); + Stream.EmitRecord(bitc::FS_COMBINED_ORIGINAL_NAME, NameVals); + NameVals.clear(); + }; + for (const auto &FII : Index) { for (auto &FI : FII.second) { GlobalValueSummary *S = FI->summary(); @@ -3241,6 +3252,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() { Stream.EmitRecord(bitc::FS_COMBINED_GLOBALVAR_INIT_REFS, NameVals, FSModRefsAbbrev); NameVals.clear(); + MaybeEmitOriginalName(*S); continue; } @@ -3288,6 +3300,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() { // Emit the finished record. Stream.EmitRecord(Code, NameVals, FSAbbrev); NameVals.clear(); + MaybeEmitOriginalName(*S); } } @@ -3307,6 +3320,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() { // Emit the finished record. Stream.EmitRecord(bitc::FS_COMBINED_ALIAS, NameVals, FSAliasAbbrev); NameVals.clear(); + MaybeEmitOriginalName(*AS); } Stream.ExitBlock(); |