diff options
author | Vitaly Buka <vitalybuka@google.com> | 2024-04-04 14:25:53 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-04 14:25:53 -0700 |
commit | 03f54725c3f2b26bfef052b9f4b5deee749e5369 (patch) | |
tree | 8b4c2ed7f6a450206aedfaadc1185954d7f38c95 | |
parent | 864d2531df8078a5bb49d24383d7219595d23690 (diff) | |
download | llvm-03f54725c3f2b26bfef052b9f4b5deee749e5369.zip llvm-03f54725c3f2b26bfef052b9f4b5deee749e5369.tar.gz llvm-03f54725c3f2b26bfef052b9f4b5deee749e5369.tar.bz2 |
[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`.
4 files changed, 9 insertions, 22 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp index 88e84ed..8562e2e 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 d87f748..6bcbccd 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 e568f5b..da9bff8 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 e3cca83..4853149 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" |