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

Ana Pazos via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 29 09:19:33 PDT 2017


apazos updated this revision to Diff 113104.
apazos edited the summary of this revision.
apazos added a comment.

Removed empty line.


https://reviews.llvm.org/D37246

Files:
  lib/IR/MDBuilder.cpp


Index: lib/IR/MDBuilder.cpp
===================================================================
--- lib/IR/MDBuilder.cpp
+++ lib/IR/MDBuilder.cpp
@@ -62,9 +62,15 @@
   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);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37246.113104.patch
Type: text/x-patch
Size: 759 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170829/3e446566/attachment.bin>


More information about the llvm-commits mailing list