[PATCH] D45132: [Bitcode] Change std::sort to llvm::sort in response to r327219
Mandeep Singh Grang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 31 18:56:30 PDT 2018
mgrang created this revision.
mgrang added reviewers: pcc, mehdi_amini, dexonsmith.
r327219 added wrappers to std::sort which randomly shuffle the container before sorting.
This will help in uncovering non-determinism caused due to undefined sorting
order of objects having the same key.
To make use of that infrastructure we need to invoke llvm::sort instead of std::sort.
Note: This patch is one of a series of patches to replace *all* std::sort to llvm::sort.
Refer the comments section in https://reviews.llvm.org/D44363 for a list of all the required patches.
Repository:
rL LLVM
https://reviews.llvm.org/D45132
Files:
lib/Bitcode/Reader/ValueList.cpp
lib/Bitcode/Writer/BitcodeWriter.cpp
lib/Bitcode/Writer/ValueEnumerator.cpp
Index: lib/Bitcode/Writer/ValueEnumerator.cpp
===================================================================
--- lib/Bitcode/Writer/ValueEnumerator.cpp
+++ lib/Bitcode/Writer/ValueEnumerator.cpp
@@ -183,7 +183,7 @@
return;
bool IsGlobalValue = OM.isGlobalValue(ID);
- std::sort(List.begin(), List.end(), [&](const Entry &L, const Entry &R) {
+ llvm::sort(List.begin(), List.end(), [&](const Entry &L, const Entry &R) {
const Use *LU = L.first;
const Use *RU = R.first;
if (LU == RU)
@@ -744,7 +744,7 @@
// and then sort by the original/current ID. Since the IDs are guaranteed to
// be unique, the result of std::sort will be deterministic. There's no need
// for std::stable_sort.
- std::sort(Order.begin(), Order.end(), [this](MDIndex LHS, MDIndex RHS) {
+ llvm::sort(Order.begin(), Order.end(), [this](MDIndex LHS, MDIndex RHS) {
return std::make_tuple(LHS.F, getMetadataTypeOrder(LHS.get(MDs)), LHS.ID) <
std::make_tuple(RHS.F, getMetadataTypeOrder(RHS.get(MDs)), RHS.ID);
});
Index: lib/Bitcode/Writer/BitcodeWriter.cpp
===================================================================
--- lib/Bitcode/Writer/BitcodeWriter.cpp
+++ lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -3478,7 +3478,7 @@
NameVals.push_back(VE.getValueID(RI.getValue()));
// Sort the refs for determinism output, the vector returned by FS->refs() has
// been initialized from a DenseSet.
- std::sort(NameVals.begin() + SizeBeforeRefs, NameVals.end());
+ llvm::sort(NameVals.begin() + SizeBeforeRefs, NameVals.end());
Stream.EmitRecord(bitc::FS_PERMODULE_GLOBALVAR_INIT_REFS, NameVals,
FSModRefsAbbrev);
Index: lib/Bitcode/Reader/ValueList.cpp
===================================================================
--- lib/Bitcode/Reader/ValueList.cpp
+++ lib/Bitcode/Reader/ValueList.cpp
@@ -144,7 +144,7 @@
void BitcodeReaderValueList::resolveConstantForwardRefs() {
// Sort the values by-pointer so that they are efficient to look up with a
// binary search.
- std::sort(ResolveConstants.begin(), ResolveConstants.end());
+ llvm::sort(ResolveConstants.begin(), ResolveConstants.end());
SmallVector<Constant *, 64> NewOps;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45132.140560.patch
Type: text/x-patch
Size: 2216 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180401/0caf3420/attachment.bin>
More information about the llvm-commits
mailing list