forked from OSchip/llvm-project
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@91177308-0d34-0410-b5e6-96231b3b80d8> llvm-svn: 269638
This commit is contained in:
parent
fe97408495
commit
367577aab9
|
@ -3177,8 +3177,15 @@ void ModuleBitcodeWriter::writePerModuleFunctionSummaryRecord(
|
||||||
|
|
||||||
NameVals.insert(NameVals.end(), Refs.begin(), Refs.end());
|
NameVals.insert(NameVals.end(), Refs.begin(), Refs.end());
|
||||||
|
|
||||||
|
std::vector<FunctionSummary::EdgeTy> Calls = FS->calls();
|
||||||
|
std::sort(Calls.begin(), Calls.end(),
|
||||||
|
[this](const FunctionSummary::EdgeTy &L,
|
||||||
|
const FunctionSummary::EdgeTy &R) {
|
||||||
|
return VE.getValueID(L.first.getValue()) <
|
||||||
|
VE.getValueID(R.first.getValue());
|
||||||
|
});
|
||||||
bool HasProfileData = F.getEntryCount().hasValue();
|
bool HasProfileData = F.getEntryCount().hasValue();
|
||||||
for (auto &ECI : FS->calls()) {
|
for (auto &ECI : Calls) {
|
||||||
NameVals.push_back(VE.getValueID(ECI.first.getValue()));
|
NameVals.push_back(VE.getValueID(ECI.first.getValue()));
|
||||||
assert(ECI.second.CallsiteCount > 0 && "Expected at least one callsite");
|
assert(ECI.second.CallsiteCount > 0 && "Expected at least one callsite");
|
||||||
NameVals.push_back(ECI.second.CallsiteCount);
|
NameVals.push_back(ECI.second.CallsiteCount);
|
||||||
|
|
Loading…
Reference in New Issue