[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 10:14:36 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL312012: [PGO] Fixed non-determinism with DenseSet storing function importing info. (authored by apazos).

Changed prior to commit:
  https://reviews.llvm.org/D37246?vs=113104&id=113107#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37246

Files:
  llvm/trunk/lib/IR/MDBuilder.cpp


Index: llvm/trunk/lib/IR/MDBuilder.cpp
===================================================================
--- llvm/trunk/lib/IR/MDBuilder.cpp
+++ llvm/trunk/lib/IR/MDBuilder.cpp
@@ -62,9 +62,14 @@
   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.113107.patch
Type: text/x-patch
Size: 783 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170829/b391397a/attachment.bin>


More information about the llvm-commits mailing list