[PATCH] D36963: Use sorting instead of a lot of stable_partitions for `ICF::segregate` function

Alex Telishev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 22 14:09:51 PDT 2017


alex.telishev added inline comments.


================
Comment at: lld/COFF/ICF.cpp:214
+
+    return B1 < B2;
   };
----------------
ruiu wrote:
> I think this comparison breaks determinism because it compares pointer values that change on every process invocation. You may be able to just return `false`?
Unfortunately, no - that would break strict ordering (`A < B == false` and `B < A == false`, like NaN) and  `stable_sort` will break in this case. It's possible to `return true` and make them all be equal to each other for the purposes of sorting. But in this case loop after `stable_sort` in `segregate` function needs to use different comparison. It's possible to use `equalsConstant` from before this patch (as we only need equality there), but it'll be a lot of copy-paste. 


https://reviews.llvm.org/D36963





More information about the llvm-commits mailing list