Skip to content

Commit 9a0ae08

Browse files
authored
[NFC][HWASAN] Simplify selectiveInstrumentationShouldSkip (#87670)
1 parent 8a0bfe4 commit 9a0ae08

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ class HWAddressSanitizer {
317317
};
318318

319319
bool selectiveInstrumentationShouldSkip(Function &F,
320-
FunctionAnalysisManager &FAM);
320+
FunctionAnalysisManager &FAM) const;
321321
void initializeModule();
322322
void createHwasanCtorComdat();
323323

@@ -1500,28 +1500,24 @@ bool HWAddressSanitizer::instrumentStack(memtag::StackInfo &SInfo,
15001500
}
15011501

15021502
bool HWAddressSanitizer::selectiveInstrumentationShouldSkip(
1503-
Function &F, FunctionAnalysisManager &FAM) {
1503+
Function &F, FunctionAnalysisManager &FAM) const {
15041504
if (ClRandomSkipRate.getNumOccurrences()) {
15051505
std::bernoulli_distribution D(ClRandomSkipRate);
1506-
if (D(*Rng))
1507-
return true;
1508-
} else {
1509-
auto &MAMProxy = FAM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
1510-
ProfileSummaryInfo *PSI =
1511-
MAMProxy.getCachedResult<ProfileSummaryAnalysis>(*F.getParent());
1512-
if (PSI && PSI->hasProfileSummary()) {
1513-
auto &BFI = FAM.getResult<BlockFrequencyAnalysis>(F);
1514-
if ((ClHotPercentileCutoff.getNumOccurrences() &&
1515-
ClHotPercentileCutoff >= 0)
1516-
? PSI->isFunctionHotInCallGraphNthPercentile(
1517-
ClHotPercentileCutoff, &F, BFI)
1518-
: PSI->isFunctionHotInCallGraph(&F, BFI))
1519-
return true;
1520-
} else {
1521-
++NumNoProfileSummaryFuncs;
1522-
}
1506+
return (D(*Rng));
15231507
}
1524-
return false;
1508+
auto &MAMProxy = FAM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
1509+
ProfileSummaryInfo *PSI =
1510+
MAMProxy.getCachedResult<ProfileSummaryAnalysis>(*F.getParent());
1511+
if (!PSI || !PSI->hasProfileSummary()) {
1512+
++NumNoProfileSummaryFuncs;
1513+
return false;
1514+
}
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));
15251521
}
15261522

15271523
void HWAddressSanitizer::sanitizeFunction(Function &F,

0 commit comments

Comments
 (0)