Skip to content

Commit 03f5472

Browse files
authored
[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`.
1 parent 864d253 commit 03f5472

File tree

4 files changed

+9
-22
lines changed

4 files changed

+9
-22
lines changed

llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,8 @@ static cl::opt<bool>
187187
cl::desc("Use selective instrumentation"),
188188
cl::Hidden, cl::init(false));
189189

190-
static cl::opt<int> ClHotPercentileCutoff(
191-
"hwasan-percentile-cutoff-hot", cl::init(0),
192-
cl::desc("Alternative hot percentile cuttoff."
193-
"By default `-profile-summary-cutoff-hot` is used."));
190+
static cl::opt<int> ClHotPercentileCutoff("hwasan-percentile-cutoff-hot",
191+
cl::desc("Hot percentile cuttoff."));
194192

195193
static cl::opt<float>
196194
ClRandomSkipRate("hwasan-random-skip-rate", cl::init(0),
@@ -1512,12 +1510,8 @@ bool HWAddressSanitizer::selectiveInstrumentationShouldSkip(
15121510
++NumNoProfileSummaryFuncs;
15131511
return false;
15141512
}
1515-
auto &BFI = FAM.getResult<BlockFrequencyAnalysis>(F);
1516-
return (
1517-
(ClHotPercentileCutoff.getNumOccurrences() && ClHotPercentileCutoff >= 0)
1518-
? PSI->isFunctionHotInCallGraphNthPercentile(ClHotPercentileCutoff,
1519-
&F, BFI)
1520-
: PSI->isFunctionHotInCallGraph(&F, BFI));
1513+
return PSI->isFunctionHotInCallGraphNthPercentile(
1514+
ClHotPercentileCutoff, &F, FAM.getResult<BlockFrequencyAnalysis>(F));
15211515
}
15221516

15231517
void HWAddressSanitizer::sanitizeFunction(Function &F,

llvm/lib/Transforms/Instrumentation/RemoveTrapsPass.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ using namespace llvm;
2222

2323
#define DEBUG_TYPE "remove-traps"
2424

25-
static cl::opt<int> HotPercentileCutoff(
26-
"remove-traps-percentile-cutoff-hot", cl::init(0),
27-
cl::desc("Alternative hot percentile cuttoff. By default "
28-
"`-profile-summary-cutoff-hot` is used."));
25+
static cl::opt<int> HotPercentileCutoff("remove-traps-percentile-cutoff-hot",
26+
cl::desc("Hot percentile cuttoff."));
2927

3028
static cl::opt<float>
3129
RandomRate("remove-traps-random-rate", cl::init(0.0),
@@ -64,12 +62,7 @@ static bool removeUbsanTraps(Function &F, const BlockFrequencyInfo &BFI,
6462
uint64_t Count = 0;
6563
for (const auto *PR : predecessors(&BB))
6664
Count += BFI.getBlockProfileCount(PR).value_or(0);
67-
68-
IsHot =
69-
HotPercentileCutoff.getNumOccurrences()
70-
? (HotPercentileCutoff > 0 &&
71-
PSI->isHotCountNthPercentile(HotPercentileCutoff, Count))
72-
: PSI->isHotCount(Count);
65+
IsHot = PSI->isHotCountNthPercentile(HotPercentileCutoff, Count);
7366
}
7467

7568
if (ShouldRemove(IsHot)) {

llvm/test/Instrumentation/HWAddressSanitizer/pgo-opt-out.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; RUN: opt < %s -passes='require<profile-summary>,hwasan' -S -hwasan-selective-instrumentation=1 \
22
; RUN: -hwasan-percentile-cutoff-hot=700000 | FileCheck %s --check-prefix=HOT70
33
; RUN: opt < %s -passes='require<profile-summary>,hwasan' -S -hwasan-selective-instrumentation=1 \
4-
; RUN: | FileCheck %s --check-prefix=HOT99
4+
; RUN: -hwasan-percentile-cutoff-hot=990000 | FileCheck %s --check-prefix=HOT99
55
; RUN: opt < %s -passes='require<profile-summary>,hwasan' -S -hwasan-selective-instrumentation=1 \
66
; RUN: -hwasan-random-skip-rate=0.0 | FileCheck %s --check-prefix=RANDOM0
77
; RUN: opt < %s -passes='require<profile-summary>,hwasan' -S -hwasan-selective-instrumentation=1 \

llvm/test/Transforms/RemoveTraps/remove-traps.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
22
; RUN: opt < %s -passes='function(remove-traps)' -S | FileCheck %s --check-prefixes=NOPROFILE
33
; RUN: opt < %s -passes='function(remove-traps)' -remove-traps-random-rate=1 -S | FileCheck %s --check-prefixes=ALL
4-
; RUN: opt < %s -passes='require<profile-summary>,function(remove-traps)' -S | FileCheck %s --check-prefixes=HOT99
4+
; RUN: opt < %s -passes='require<profile-summary>,function(remove-traps)' -remove-traps-percentile-cutoff-hot=990000 -S | FileCheck %s --check-prefixes=HOT99
55
; RUN: opt < %s -passes='require<profile-summary>,function(remove-traps)' -remove-traps-percentile-cutoff-hot=700000 -S | FileCheck %s --check-prefixes=HOT70
66

77
target triple = "x86_64-pc-linux-gnu"

0 commit comments

Comments
 (0)