diff options
author | Mandeep Singh Grang <mgrang@codeaurora.org> | 2018-03-20 00:44:59 +0000 |
---|---|---|
committer | Mandeep Singh Grang <mgrang@codeaurora.org> | 2018-03-20 00:44:59 +0000 |
commit | 789e1d7e04752d0c2df371b5acf13e9190ec1666 (patch) | |
tree | 9100e21057ce4e6115288a40ecc8b6f4c1af77ff | |
parent | 7dce3214a401e4e8b1a3ad04e79ae6c3dd0a8d1e (diff) |
[compiler-rt] Change std::sort to llvm::sort in response to r327219
Summary:
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.
Reviewers: kcc, rsmith, RKSimon, eugenis
Reviewed By: RKSimon
Subscribers: efriedma, kubamracek, dberris, #sanitizers, llvm-commits
Differential Revision: https://reviews.llvm.org/D44360
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@327929 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/asan/tests/asan_mem_test.cc | 2 | ||||
-rw-r--r-- | lib/fuzzer/FuzzerCorpus.h | 2 | ||||
-rw-r--r-- | lib/fuzzer/FuzzerMerge.cpp | 18 | ||||
-rw-r--r-- | lib/sanitizer_common/tests/sanitizer_common_test.cc | 2 | ||||
-rw-r--r-- | lib/sanitizer_common/tests/sanitizer_linux_test.cc | 4 |
5 files changed, 14 insertions, 14 deletions
diff --git a/lib/asan/tests/asan_mem_test.cc b/lib/asan/tests/asan_mem_test.cc index c32088684..c02c2e364 100644 --- a/lib/asan/tests/asan_mem_test.cc +++ b/lib/asan/tests/asan_mem_test.cc @@ -82,7 +82,7 @@ static bool AllocateTwoAdjacentArrays(char **x1, char **x2, size_t size) { for (size_t i = 0; i < 1000U && !res; i++) { v.push_back(reinterpret_cast<uintptr_t>(new char[size])); if (i == 0) continue; - sort(v.begin(), v.end()); + llvm::sort(v.begin(), v.end()); for (size_t j = 1; j < v.size(); j++) { assert(v[j] > v[j-1]); if ((size_t)(v[j] - v[j-1]) < size * 2) { diff --git a/lib/fuzzer/FuzzerCorpus.h b/lib/fuzzer/FuzzerCorpus.h index 2da929835..7dd6dd6a9 100644 --- a/lib/fuzzer/FuzzerCorpus.h +++ b/lib/fuzzer/FuzzerCorpus.h @@ -83,7 +83,7 @@ class InputCorpus { II.NumFeatures = NumFeatures; II.MayDeleteFile = MayDeleteFile; II.UniqFeatureSet = FeatureSet; - std::sort(II.UniqFeatureSet.begin(), II.UniqFeatureSet.end()); + llvm::sort(II.UniqFeatureSet.begin(), II.UniqFeatureSet.end()); ComputeSHA1(U.data(), U.size(), II.Sha1); Hashes.insert(Sha1ToString(II.Sha1)); UpdateCorpusDistribution(); diff --git a/lib/fuzzer/FuzzerMerge.cpp b/lib/fuzzer/FuzzerMerge.cpp index 5f3052a39..321f2654c 100644 --- a/lib/fuzzer/FuzzerMerge.cpp +++ b/lib/fuzzer/FuzzerMerge.cpp @@ -100,7 +100,7 @@ bool Merger::Parse(std::istream &IS, bool ParseCoverage) { TmpFeatures.clear(); // use a vector from outer scope to avoid resizes. while (ISS1 >> std::hex >> N) TmpFeatures.push_back(N); - std::sort(TmpFeatures.begin(), TmpFeatures.end()); + llvm::sort(TmpFeatures.begin(), TmpFeatures.end()); Files[CurrentFileIdx].Features = TmpFeatures; } } else { @@ -148,12 +148,12 @@ size_t Merger::Merge(const Set<uint32_t> &InitialFeatures, // Sort. Give preference to // * smaller files // * files with more features. - std::sort(Files.begin() + NumFilesInFirstCorpus, Files.end(), - [&](const MergeFileInfo &a, const MergeFileInfo &b) -> bool { - if (a.Size != b.Size) - return a.Size < b.Size; - return a.Features.size() > b.Features.size(); - }); + llvm::sort(Files.begin() + NumFilesInFirstCorpus, Files.end(), + [&](const MergeFileInfo &a, const MergeFileInfo &b) -> bool { + if (a.Size != b.Size) + return a.Size < b.Size; + return a.Features.size() > b.Features.size(); + }); // One greedy pass: add the file's features to AllFeatures. // If new features were added, add this file to NewFiles. @@ -321,10 +321,10 @@ void Fuzzer::CrashResistantMerge(const Vector<std::string> &Args, Vector<SizedFile> AllFiles; GetSizedFilesFromDir(Corpora[0], &AllFiles); size_t NumFilesInFirstCorpus = AllFiles.size(); - std::sort(AllFiles.begin(), AllFiles.end()); + llvm::sort(AllFiles.begin(), AllFiles.end()); for (size_t i = 1; i < Corpora.size(); i++) GetSizedFilesFromDir(Corpora[i], &AllFiles); - std::sort(AllFiles.begin() + NumFilesInFirstCorpus, AllFiles.end()); + llvm::sort(AllFiles.begin() + NumFilesInFirstCorpus, AllFiles.end()); Printf("MERGE-OUTER: %zd files, %zd in the initial corpus\n", AllFiles.size(), NumFilesInFirstCorpus); WriteNewControlFile(CFPath, AllFiles, NumFilesInFirstCorpus); diff --git a/lib/sanitizer_common/tests/sanitizer_common_test.cc b/lib/sanitizer_common/tests/sanitizer_common_test.cc index 576649cea..1f9eea59a 100644 --- a/lib/sanitizer_common/tests/sanitizer_common_test.cc +++ b/lib/sanitizer_common/tests/sanitizer_common_test.cc @@ -209,7 +209,7 @@ TEST(SanitizerCommon, InternalLowerBoundVsStdLowerBound) { data[j] = create_item(i, j); } - std::sort(data.begin(), data.end()); + llvm::sort(data.begin(), data.end()); for (size_t j = 0; j < i; ++j) { int val = create_item(i, j); diff --git a/lib/sanitizer_common/tests/sanitizer_linux_test.cc b/lib/sanitizer_common/tests/sanitizer_linux_test.cc index 8a6afab65..d53c1e763 100644 --- a/lib/sanitizer_common/tests/sanitizer_linux_test.cc +++ b/lib/sanitizer_common/tests/sanitizer_linux_test.cc @@ -131,8 +131,8 @@ static std::vector<pid_t> ReadTidsToVector(ThreadLister *thread_lister) { } static bool Includes(std::vector<pid_t> first, std::vector<pid_t> second) { - std::sort(first.begin(), first.end()); - std::sort(second.begin(), second.end()); + llvm::sort(first.begin(), first.end()); + llvm::sort(second.begin(), second.end()); return std::includes(first.begin(), first.end(), second.begin(), second.end()); } |