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

[PGO] Fixed non-determinism with DenseSet storing function importing info.

Summary:
r296498 introduced a DenseSet to store function importing info.

Using this container causes a test failure in
test/Transform/SampleProfile/import.ll when in Reverse Iteration mode.

This patch orders IDs before iterating through this container.

Reviewers: danielcdh, mgrang

Reviewed By: danielcdh

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D37246

llvm-svn: 312012
This commit is contained in:
Ana Pazos 2017-08-29 17:13:24 +00:00
parent 0970f16449
commit 68168b137b

View File

@ -62,9 +62,14 @@ MDNode *MDBuilder::createFunctionEntryCount(
SmallVector<Metadata *, 8> Ops;
Ops.push_back(createString("function_entry_count"));
Ops.push_back(createConstant(ConstantInt::get(Int64Ty, Count)));
if (Imports)
for (auto ID : *Imports)
if (Imports) {
SmallVector<GlobalValue::GUID, 2> OrderID(Imports->begin(), Imports->end());
std::stable_sort(OrderID.begin(), OrderID.end(),
[] (GlobalValue::GUID A, GlobalValue::GUID B) {
return A < B;});
for (auto ID : OrderID)
Ops.push_back(createConstant(ConstantInt::get(Int64Ty, ID)));
}
return MDNode::get(Context, Ops);
}