[llvm] 03f5472 - [HWASAN][UBSAN] Don't use default `profile-summary-cutoff-hot` (#87691)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 4 14:25:57 PDT 2024
Author: Vitaly Buka
Date: 2024-04-04T14:25:53-07:00
New Revision: 03f54725c3f2b26bfef052b9f4b5deee749e5369
URL: https://github.com/llvm/llvm-project/commit/03f54725c3f2b26bfef052b9f4b5deee749e5369
DIFF: https://github.com/llvm/llvm-project/commit/03f54725c3f2b26bfef052b9f4b5deee749e5369.diff
LOG: [HWASAN][UBSAN] Don't use default `profile-summary-cutoff-hot` (#87691)
Default cutoff is not usefull here. Decision to
enable or not sanitizer causes more significant
performance impact, than a typical optimizations
which rely on `profile-summary-cutoff-hot`.
Added:
Modified:
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
llvm/lib/Transforms/Instrumentation/RemoveTrapsPass.cpp
llvm/test/Instrumentation/HWAddressSanitizer/pgo-opt-out.ll
llvm/test/Transforms/RemoveTraps/remove-traps.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index 88e84ed7be8e6a..8562e2efd33e10 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -187,10 +187,8 @@ static cl::opt<bool>
cl::desc("Use selective instrumentation"),
cl::Hidden, cl::init(false));
-static cl::opt<int> ClHotPercentileCutoff(
- "hwasan-percentile-cutoff-hot", cl::init(0),
- cl::desc("Alternative hot percentile cuttoff."
- "By default `-profile-summary-cutoff-hot` is used."));
+static cl::opt<int> ClHotPercentileCutoff("hwasan-percentile-cutoff-hot",
+ cl::desc("Hot percentile cuttoff."));
static cl::opt<float>
ClRandomSkipRate("hwasan-random-skip-rate", cl::init(0),
@@ -1512,12 +1510,8 @@ bool HWAddressSanitizer::selectiveInstrumentationShouldSkip(
++NumNoProfileSummaryFuncs;
return false;
}
- auto &BFI = FAM.getResult<BlockFrequencyAnalysis>(F);
- return (
- (ClHotPercentileCutoff.getNumOccurrences() && ClHotPercentileCutoff >= 0)
- ? PSI->isFunctionHotInCallGraphNthPercentile(ClHotPercentileCutoff,
- &F, BFI)
- : PSI->isFunctionHotInCallGraph(&F, BFI));
+ return PSI->isFunctionHotInCallGraphNthPercentile(
+ ClHotPercentileCutoff, &F, FAM.getResult<BlockFrequencyAnalysis>(F));
}
void HWAddressSanitizer::sanitizeFunction(Function &F,
diff --git a/llvm/lib/Transforms/Instrumentation/RemoveTrapsPass.cpp b/llvm/lib/Transforms/Instrumentation/RemoveTrapsPass.cpp
index d87f7482a21d25..6bcbccda031cec 100644
--- a/llvm/lib/Transforms/Instrumentation/RemoveTrapsPass.cpp
+++ b/llvm/lib/Transforms/Instrumentation/RemoveTrapsPass.cpp
@@ -22,10 +22,8 @@ using namespace llvm;
#define DEBUG_TYPE "remove-traps"
-static cl::opt<int> HotPercentileCutoff(
- "remove-traps-percentile-cutoff-hot", cl::init(0),
- cl::desc("Alternative hot percentile cuttoff. By default "
- "`-profile-summary-cutoff-hot` is used."));
+static cl::opt<int> HotPercentileCutoff("remove-traps-percentile-cutoff-hot",
+ cl::desc("Hot percentile cuttoff."));
static cl::opt<float>
RandomRate("remove-traps-random-rate", cl::init(0.0),
@@ -64,12 +62,7 @@ static bool removeUbsanTraps(Function &F, const BlockFrequencyInfo &BFI,
uint64_t Count = 0;
for (const auto *PR : predecessors(&BB))
Count += BFI.getBlockProfileCount(PR).value_or(0);
-
- IsHot =
- HotPercentileCutoff.getNumOccurrences()
- ? (HotPercentileCutoff > 0 &&
- PSI->isHotCountNthPercentile(HotPercentileCutoff, Count))
- : PSI->isHotCount(Count);
+ IsHot = PSI->isHotCountNthPercentile(HotPercentileCutoff, Count);
}
if (ShouldRemove(IsHot)) {
diff --git a/llvm/test/Instrumentation/HWAddressSanitizer/pgo-opt-out.ll b/llvm/test/Instrumentation/HWAddressSanitizer/pgo-opt-out.ll
index e568f5b88dc145..da9bff8c048cc6 100644
--- a/llvm/test/Instrumentation/HWAddressSanitizer/pgo-opt-out.ll
+++ b/llvm/test/Instrumentation/HWAddressSanitizer/pgo-opt-out.ll
@@ -1,7 +1,7 @@
; RUN: opt < %s -passes='require<profile-summary>,hwasan' -S -hwasan-selective-instrumentation=1 \
; RUN: -hwasan-percentile-cutoff-hot=700000 | FileCheck %s --check-prefix=HOT70
; RUN: opt < %s -passes='require<profile-summary>,hwasan' -S -hwasan-selective-instrumentation=1 \
-; RUN: | FileCheck %s --check-prefix=HOT99
+; RUN: -hwasan-percentile-cutoff-hot=990000 | FileCheck %s --check-prefix=HOT99
; RUN: opt < %s -passes='require<profile-summary>,hwasan' -S -hwasan-selective-instrumentation=1 \
; RUN: -hwasan-random-skip-rate=0.0 | FileCheck %s --check-prefix=RANDOM0
; RUN: opt < %s -passes='require<profile-summary>,hwasan' -S -hwasan-selective-instrumentation=1 \
diff --git a/llvm/test/Transforms/RemoveTraps/remove-traps.ll b/llvm/test/Transforms/RemoveTraps/remove-traps.ll
index e3cca83884a8e1..4853149f955b09 100644
--- a/llvm/test/Transforms/RemoveTraps/remove-traps.ll
+++ b/llvm/test/Transforms/RemoveTraps/remove-traps.ll
@@ -1,7 +1,7 @@
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
; RUN: opt < %s -passes='function(remove-traps)' -S | FileCheck %s --check-prefixes=NOPROFILE
; RUN: opt < %s -passes='function(remove-traps)' -remove-traps-random-rate=1 -S | FileCheck %s --check-prefixes=ALL
-; RUN: opt < %s -passes='require<profile-summary>,function(remove-traps)' -S | FileCheck %s --check-prefixes=HOT99
+; RUN: opt < %s -passes='require<profile-summary>,function(remove-traps)' -remove-traps-percentile-cutoff-hot=990000 -S | FileCheck %s --check-prefixes=HOT99
; RUN: opt < %s -passes='require<profile-summary>,function(remove-traps)' -remove-traps-percentile-cutoff-hot=700000 -S | FileCheck %s --check-prefixes=HOT70
target triple = "x86_64-pc-linux-gnu"
More information about the llvm-commits
mailing list