diff options
author | Vitaly Buka <vitalybuka@google.com> | 2024-04-04 12:21:50 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-04 12:21:50 -0700 |
commit | 9a0ae081047d7088cdecfa86a8c90b721485e418 (patch) | |
tree | 4d172cf3d21b3d16f218600b76ead9d14175e74c | |
parent | 8a0bfe490592de3df28d82c5dd69956e43c20f1d (diff) | |
download | llvm-9a0ae081047d7088cdecfa86a8c90b721485e418.zip llvm-9a0ae081047d7088cdecfa86a8c90b721485e418.tar.gz llvm-9a0ae081047d7088cdecfa86a8c90b721485e418.tar.bz2 |
[NFC][HWASAN] Simplify `selectiveInstrumentationShouldSkip` (#87670)
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp index d0d349c..88e84ed 100644 --- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp +++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp @@ -317,7 +317,7 @@ private: }; bool selectiveInstrumentationShouldSkip(Function &F, - FunctionAnalysisManager &FAM); + FunctionAnalysisManager &FAM) const; void initializeModule(); void createHwasanCtorComdat(); @@ -1500,28 +1500,24 @@ bool HWAddressSanitizer::instrumentStack(memtag::StackInfo &SInfo, } bool HWAddressSanitizer::selectiveInstrumentationShouldSkip( - Function &F, FunctionAnalysisManager &FAM) { + Function &F, FunctionAnalysisManager &FAM) const { if (ClRandomSkipRate.getNumOccurrences()) { std::bernoulli_distribution D(ClRandomSkipRate); - if (D(*Rng)) - return true; - } else { - auto &MAMProxy = FAM.getResult<ModuleAnalysisManagerFunctionProxy>(F); - ProfileSummaryInfo *PSI = - MAMProxy.getCachedResult<ProfileSummaryAnalysis>(*F.getParent()); - if (PSI && PSI->hasProfileSummary()) { - auto &BFI = FAM.getResult<BlockFrequencyAnalysis>(F); - if ((ClHotPercentileCutoff.getNumOccurrences() && - ClHotPercentileCutoff >= 0) - ? PSI->isFunctionHotInCallGraphNthPercentile( - ClHotPercentileCutoff, &F, BFI) - : PSI->isFunctionHotInCallGraph(&F, BFI)) - return true; - } else { - ++NumNoProfileSummaryFuncs; - } + return (D(*Rng)); } - return false; + auto &MAMProxy = FAM.getResult<ModuleAnalysisManagerFunctionProxy>(F); + ProfileSummaryInfo *PSI = + MAMProxy.getCachedResult<ProfileSummaryAnalysis>(*F.getParent()); + if (!PSI || !PSI->hasProfileSummary()) { + ++NumNoProfileSummaryFuncs; + return false; + } + auto &BFI = FAM.getResult<BlockFrequencyAnalysis>(F); + return ( + (ClHotPercentileCutoff.getNumOccurrences() && ClHotPercentileCutoff >= 0) + ? PSI->isFunctionHotInCallGraphNthPercentile(ClHotPercentileCutoff, + &F, BFI) + : PSI->isFunctionHotInCallGraph(&F, BFI)); } void HWAddressSanitizer::sanitizeFunction(Function &F, |