14 #ifndef LLVM_FUZZMUTATE_RANDOM_H 15 #define LLVM_FUZZMUTATE_RANDOM_H 22 template <
typename T,
typename GenT>
T uniform(GenT &Gen,
T Min,
T Max) {
23 return std::uniform_int_distribution<T>(Min, Max)(Gen);
27 template <
typename T,
typename GenT>
T uniform(GenT &Gen) {
28 return uniform<T>(Gen, std::numeric_limits<T>::min(),
36 typename std::remove_const<T>::type Selection = {};
37 uint64_t TotalWeight = 0;
43 bool isEmpty()
const {
return TotalWeight == 0; }
65 TotalWeight += Weight;
67 if (uniform<uint64_t>(RandGen, 1, TotalWeight) <= Weight)
73 template <
typename GenT,
typename RangeT,
74 typename ElT =
typename std::remove_reference<
75 decltype(*
std::begin(std::declval<RangeT>()))>::type>
82 template <
typename GenT,
typename T>
90 template <
typename T,
typename GenT>
97 #endif // LLVM_FUZZMUTATE_RANDOM_H GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
ReservoirSampler & sample(const T &Item, uint64_t Weight)
Sample a single item with the given weight.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
This class represents lattice values for constants.
uint64_t totalWeight() const
T uniform(GenT &Gen, T Min, T Max)
Return a uniformly distributed random value between Min and Max.
ReservoirSampler & sample(RangeT &&Items)
Sample each item in Items with unit weight.
ReservoirSampler< ElT, GenT > makeSampler(GenT &RandGen, RangeT &&Items)
const T & operator*() const
Randomly selects an item by sampling into a set with an unknown number of elements, which may each be weighted to be more likely choices.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
ReservoirSampler(GenT &RandGen)
const T & getSelection() const