[llvm] [hwasan][NFCI] Rename ClRandomSkipRate to ClRandomKeepRate (PR #126990)
Thurston Dang via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 12 16:52:07 PST 2025
https://github.com/thurstond created https://github.com/llvm/llvm-project/pull/126990
The meaning of ClRandomSkipRate was inverted in
https://github.com/llvm/llvm-project/pull/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.
>From c31d325f2cc308b03303f5449665a2f68e6f280c Mon Sep 17 00:00:00 2001
From: Thurston Dang <thurston at google.com>
Date: Thu, 13 Feb 2025 00:49:30 +0000
Subject: [PATCH] [hwasan][NFCI] Rename ClRandomSkipRate to ClRandomKeepRate
The meaning of ClRandomSkipRate was inverted in
https://github.com/llvm/llvm-project/pull/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.
---
.../Instrumentation/HWAddressSanitizer.cpp | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index 645c102752692..5a184cc066aab 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -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");
@@ -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();
@@ -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);
};
More information about the llvm-commits
mailing list