1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

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
This commit is contained in:
Mehdi Amini 2016-05-16 04:50:47 +00:00
parent 2f4a231157
commit 1241c40298

View File

@ -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()) {