Skip to content

Commit c31d325

Browse files
committed
[hwasan][NFCI] Rename ClRandomSkipRate to ClRandomKeepRate
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 51d8255 commit c31d325

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,11 @@ 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."));
201203

202204
STATISTIC(NumTotalFuncs, "Number of total funcs");
203205
STATISTIC(NumInstrumentedFuncs, "Number of instrumented funcs");
@@ -301,7 +303,7 @@ class HWAddressSanitizer {
301303
: M(M), SSI(SSI) {
302304
this->Recover = optOr(ClRecover, Recover);
303305
this->CompileKernel = optOr(ClEnableKhwasan, CompileKernel);
304-
this->Rng = ClRandomSkipRate.getNumOccurrences() ? M.createRNG(DEBUG_TYPE)
306+
this->Rng = ClRandomKeepRate.getNumOccurrences() ? M.createRNG(DEBUG_TYPE)
305307
: nullptr;
306308

307309
initializeModule();
@@ -1599,9 +1601,9 @@ bool HWAddressSanitizer::selectiveInstrumentationShouldSkip(
15991601
};
16001602

16011603
auto SkipRandom = [&]() {
1602-
if (!ClRandomSkipRate.getNumOccurrences())
1604+
if (!ClRandomKeepRate.getNumOccurrences())
16031605
return false;
1604-
std::bernoulli_distribution D(ClRandomSkipRate);
1606+
std::bernoulli_distribution D(ClRandomKeepRate);
16051607
return !D(*Rng);
16061608
};
16071609

0 commit comments

Comments
 (0)