[PATCH] D121870: Use a stable-sort when combining bases

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 16 23:11:36 PDT 2022


MaskRay added a comment.

In D121870#3388248 <https://reviews.llvm.org/D121870#3388248>, @efriedma wrote:

> LGTM
>
>> I suspect that the test is too stringent in its check--the resultant code looks functionally identical to me under both stable and unstable sorting,
>
> We don't want the code generated by LLVM to depend on the way std::sort is implemented.  Even if there isn't any functional difference, any sort of non-determinism makes it harder to understand bugs or performance issues.  (Output changing based on the host C++ library isn't as bad as cases where it depends on ASLR randomization or something like that, but still.)

Agree. libc++ now provides `-D_LIBCPP_DEBUG_RANDOMIZE_UNSPECIFIED_STABILITY` (D96946 <https://reviews.llvm.org/D96946>, or via `_LIBCPP_DEBUG=1`) to randomize std::sort.
Some build bots using libc++ may consider switching to this mode.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D121870/new/

https://reviews.llvm.org/D121870



More information about the llvm-commits mailing list