summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-05-16 04:50:47 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-05-16 04:50:47 +0000
commit7c9ceb5cc8753210daa2548fa4e3b32ebd4c07b3 (patch)
tree012134b7db35bb7243b58c3c055dcd124f7f60e7 /llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
parent0eadc53f6d8c7b9bf2760186eaf17a87cf8dfcf6 (diff)
downloadbcm5719-llvm-7c9ceb5cc8753210daa2548fa4e3b32ebd4c07b3.tar.gz
bcm5719-llvm-7c9ceb5cc8753210daa2548fa4e3b32ebd4c07b3.zip
ThinLTO: fix non-determinism in bitcode writing
Refs are initialized from a DenseSet. We can sort them using the value id to recover some determinism during serialization. From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 269629
Diffstat (limited to 'llvm/lib/Bitcode/Writer/BitcodeWriter.cpp')
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriter.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
index 050294da166..1bd2e6f9b99 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -3168,8 +3168,14 @@ void ModuleBitcodeWriter::writePerModuleFunctionSummaryRecord(
NameVals.push_back(FS->instCount());
NameVals.push_back(FS->refs().size());
+ // Compute refs in a separate vector to be able to sort them for determinism.
+ std::vector<uint64_t> Refs;
+ Refs.reserve(FS->refs().size());
for (auto &RI : FS->refs())
- NameVals.push_back(VE.getValueID(RI.getValue()));
+ Refs.push_back(VE.getValueID(RI.getValue()));
+ std::sort(Refs.begin(), Refs.end());
+
+ NameVals.insert(NameVals.end(), Refs.begin(), Refs.end());
bool HasProfileData = F.getEntryCount().hasValue();
for (auto &ECI : FS->calls()) {
OpenPOWER on IntegriCloud