diff options
author | Ana Pazos <apazos@codeaurora.org> | 2017-08-29 17:13:24 +0000 |
---|---|---|
committer | Ana Pazos <apazos@codeaurora.org> | 2017-08-29 17:13:24 +0000 |
commit | 90b17420e87282082cffd8c9e61f83e1f155a16d (patch) | |
tree | 5fc82065640c155713d9a5d3c4e058e4f34964aa /llvm/lib/IR/MDBuilder.cpp | |
parent | 29c5d02f4f7c1a77e435efaca2ec8370accd7fb1 (diff) | |
download | bcm5719-llvm-90b17420e87282082cffd8c9e61f83e1f155a16d.tar.gz bcm5719-llvm-90b17420e87282082cffd8c9e61f83e1f155a16d.zip |
[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
Diffstat (limited to 'llvm/lib/IR/MDBuilder.cpp')
-rw-r--r-- | llvm/lib/IR/MDBuilder.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/llvm/lib/IR/MDBuilder.cpp b/llvm/lib/IR/MDBuilder.cpp index b9c4f482adf..84bad318591 100644 --- a/llvm/lib/IR/MDBuilder.cpp +++ b/llvm/lib/IR/MDBuilder.cpp @@ -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); } |