[llvm] r269634 - ThinLTO: fix non-determinism in bitcode writing
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Mon May 16 01:50:24 PDT 2016
Author: mehdi_amini
Date: Mon May 16 03:50:23 2016
New Revision: 269634
URL: http://llvm.org/viewvc/llvm-project?rev=269634&view=rev
Log:
ThinLTO: fix non-determinism in bitcode writing
Calls are initialized from a DenseMap. We can sort them using the
value id to recover some determinism during serialization.
From: Mehdi Amini <mehdi.amini at apple.com>
Modified:
llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=269634&r1=269633&r2=269634&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Mon May 16 03:50:23 2016
@@ -3177,8 +3177,14 @@ void ModuleBitcodeWriter::writePerModule
NameVals.insert(NameVals.end(), Refs.begin(), Refs.end());
+ std::vector<FunctionSummary::EdgeTy> Calls = FS->calls();
+ std::sort(Calls.begin(), Calls.end(),
+ [this](FunctionSummary::EdgeTy &L, FunctionSummary::EdgeTy &R) {
+ return VE.getValueID(L.first.getValue()) <
+ VE.getValueID(R.first.getValue());
+ });
bool HasProfileData = F.getEntryCount().hasValue();
- for (auto &ECI : FS->calls()) {
+ for (auto &ECI : Calls) {
NameVals.push_back(VE.getValueID(ECI.first.getValue()));
assert(ECI.second.CallsiteCount > 0 && "Expected at least one callsite");
NameVals.push_back(ECI.second.CallsiteCount);
More information about the llvm-commits
mailing list