[llvm] [HWASAN] Follow up for #83503 implement selective instrumentation (PR #83942)

via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 6 12:46:05 PST 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff ccf0c8da1a0e6eea5e31fd5872ac864bf7005147 8acaf614f1bfd4885125a112b8796421395ac37a -- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index 5d1c9615a5..9b757682aa 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -52,6 +52,7 @@
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/RandomNumberGenerator.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/TargetParser/Triple.h"
 #include "llvm/Transforms/Instrumentation/AddressSanitizerCommon.h"
@@ -60,7 +61,6 @@
 #include "llvm/Transforms/Utils/MemoryTaggingSupport.h"
 #include "llvm/Transforms/Utils/ModuleUtils.h"
 #include "llvm/Transforms/Utils/PromoteMemToReg.h"
-#include "llvm/Support/RandomNumberGenerator.h"
 #include <optional>
 #include <random>
 
@@ -1536,21 +1536,24 @@ void HWAddressSanitizer::sanitizeFunction(Function &F,
   NumTotalFuncs++;
   if (CSelectiveInstrumentation) {
     if (RandomSkipRate.getNumOccurrences()) {
-      std::unique_ptr<RandomNumberGenerator> Rng = F.getParent()->createRNG(F.getName());
+      std::unique_ptr<RandomNumberGenerator> Rng =
+          F.getParent()->createRNG(F.getName());
       std::bernoulli_distribution D(RandomSkipRate);
-      if (D(*Rng)) return;
+      if (D(*Rng))
+        return;
     } else {
       if ((F.getGUID() % MaxRandomRate) < SkipInstRandomRate) {
-      return;
-    }
-    auto &MAMProxy = FAM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
+        return;
+      }
+      auto &MAMProxy = FAM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
       ProfileSummaryInfo *PSI =
           MAMProxy.getCachedResult<ProfileSummaryAnalysis>(*F.getParent());
       if (PSI && PSI->hasProfileSummary()) {
         auto &BFI = FAM.getResult<BlockFrequencyAnalysis>(F);
-        if ((HotPercentileCutoff.getNumOccurrences() && HotPercentileCutoff >= 0)
-                ? PSI->isFunctionHotInCallGraphNthPercentile(HotPercentileCutoff,
-                                                            &F, BFI)
+        if ((HotPercentileCutoff.getNumOccurrences() &&
+             HotPercentileCutoff >= 0)
+                ? PSI->isFunctionHotInCallGraphNthPercentile(
+                      HotPercentileCutoff, &F, BFI)
                 : PSI->isFunctionHotInCallGraph(&F, BFI))
           return;
       } else {

``````````

</details>


https://github.com/llvm/llvm-project/pull/83942


More information about the llvm-commits mailing list