[compiler-rt] r339976 - Revert "[libFuzzer] Use std::discrete_distribution for input selection."
Matt Morehouse via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 16 18:30:27 PDT 2018
Author: morehouse
Date: Thu Aug 16 18:30:27 2018
New Revision: 339976
URL: http://llvm.org/viewvc/llvm-project?rev=339976&view=rev
Log:
Revert "[libFuzzer] Use std::discrete_distribution for input selection."
This reverts r339973 due to msan.test failing on
sanitizer-x86_64-linux-fuzzer bot.
Modified:
compiler-rt/trunk/lib/fuzzer/FuzzerCorpus.h
Modified: compiler-rt/trunk/lib/fuzzer/FuzzerCorpus.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/FuzzerCorpus.h?rev=339976&r1=339975&r2=339976&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/FuzzerCorpus.h (original)
+++ compiler-rt/trunk/lib/fuzzer/FuzzerCorpus.h Thu Aug 16 18:30:27 2018
@@ -174,7 +174,7 @@ class InputCorpus {
// Returns an index of random unit from the corpus to mutate.
size_t ChooseUnitIdxToMutate(Random &Rand) {
- size_t Idx = CorpusDistribution(Rand);
+ size_t Idx = static_cast<size_t>(CorpusDistribution(Rand));
assert(Idx < Inputs.size());
return Idx;
}
@@ -276,7 +276,9 @@ private:
void UpdateCorpusDistribution() {
size_t N = Inputs.size();
assert(N);
+ Intervals.resize(N + 1);
Weights.resize(N);
+ std::iota(Intervals.begin(), Intervals.end(), 0);
for (size_t i = 0; i < N; i++)
Weights[i] = Inputs[i]->NumFeatures
? (i + 1) * (Inputs[i]->HasFocusFunction ? 1000 : 1)
@@ -289,11 +291,12 @@ private:
Printf("%f ", Weights[i]);
Printf("Weights\n");
}
- CorpusDistribution =
- std::discrete_distribution<size_t>(Weights.begin(), Weights.end());
+ CorpusDistribution = std::piecewise_constant_distribution<double>(
+ Intervals.begin(), Intervals.end(), Weights.begin());
}
- std::discrete_distribution<size_t> CorpusDistribution;
+ std::piecewise_constant_distribution<double> CorpusDistribution;
+ Vector<double> Intervals;
Vector<double> Weights;
std::unordered_set<std::string> Hashes;
More information about the llvm-commits
mailing list