Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,11 @@ static cl::opt<int> ClHotPercentileCutoff("hwasan-percentile-cutoff-hot",
cl::desc("Hot percentile cutoff."));

static cl::opt<float>
ClRandomSkipRate("hwasan-random-rate",
ClRandomKeepRate("hwasan-random-rate",
cl::desc("Probability value in the range [0.0, 1.0] "
"to keep instrumentation of a function."));
"to keep instrumentation of a function. "
"Note: instrumentation can be skipped randomly "
"OR because of the hot percentile cutoff."));

STATISTIC(NumTotalFuncs, "Number of total funcs");
STATISTIC(NumInstrumentedFuncs, "Number of instrumented funcs");
Expand Down Expand Up @@ -301,7 +303,7 @@ class HWAddressSanitizer {
: M(M), SSI(SSI) {
this->Recover = optOr(ClRecover, Recover);
this->CompileKernel = optOr(ClEnableKhwasan, CompileKernel);
this->Rng = ClRandomSkipRate.getNumOccurrences() ? M.createRNG(DEBUG_TYPE)
this->Rng = ClRandomKeepRate.getNumOccurrences() ? M.createRNG(DEBUG_TYPE)
: nullptr;

initializeModule();
Expand Down Expand Up @@ -1599,9 +1601,9 @@ bool HWAddressSanitizer::selectiveInstrumentationShouldSkip(
};

auto SkipRandom = [&]() {
if (!ClRandomSkipRate.getNumOccurrences())
if (!ClRandomKeepRate.getNumOccurrences())
return false;
std::bernoulli_distribution D(ClRandomSkipRate);
std::bernoulli_distribution D(ClRandomKeepRate);
return !D(*Rng);
};

Expand Down