Skip to content

Commit df07121

Browse files
authored
[hwasan][NFCI] Rename ClRandomSkipRate to ClRandomKeepRate (llvm#126990)
The meaning of ClRandomSkipRate was inverted in llvm#88070 but the variable name was not changed. This patch fixes it to avoid confusion. Additionally, it elaborates the flag description to mention the interaction between the random keep rate and hotness cutoff.
1 parent 8ed3637 commit df07121

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,12 @@ static cl::opt<int> ClHotPercentileCutoff("hwasan-percentile-cutoff-hot",
195195
cl::desc("Hot percentile cutoff."));
196196

197197
static cl::opt<float>
198-
ClRandomSkipRate("hwasan-random-rate",
198+
ClRandomKeepRate("hwasan-random-rate",
199199
cl::desc("Probability value in the range [0.0, 1.0] "
200-
"to keep instrumentation of a function."));
200+
"to keep instrumentation of a function. "
201+
"Note: instrumentation can be skipped randomly "
202+
"OR because of the hot percentile cutoff, if "
203+
"both are supplied."));
201204

202205
STATISTIC(NumTotalFuncs, "Number of total funcs");
203206
STATISTIC(NumInstrumentedFuncs, "Number of instrumented funcs");
@@ -301,7 +304,7 @@ class HWAddressSanitizer {
301304
: M(M), SSI(SSI) {
302305
this->Recover = optOr(ClRecover, Recover);
303306
this->CompileKernel = optOr(ClEnableKhwasan, CompileKernel);
304-
this->Rng = ClRandomSkipRate.getNumOccurrences() ? M.createRNG(DEBUG_TYPE)
307+
this->Rng = ClRandomKeepRate.getNumOccurrences() ? M.createRNG(DEBUG_TYPE)
305308
: nullptr;
306309

307310
initializeModule();
@@ -1599,9 +1602,9 @@ bool HWAddressSanitizer::selectiveInstrumentationShouldSkip(
15991602
};
16001603

16011604
auto SkipRandom = [&]() {
1602-
if (!ClRandomSkipRate.getNumOccurrences())
1605+
if (!ClRandomKeepRate.getNumOccurrences())
16031606
return false;
1604-
std::bernoulli_distribution D(ClRandomSkipRate);
1607+
std::bernoulli_distribution D(ClRandomKeepRate);
16051608
return !D(*Rng);
16061609
};
16071610

0 commit comments

Comments
 (0)