[llvm] [HWASAN] Follow up for #83503 implement selective instrumentation (PR #83942)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 6 12:48:48 PST 2024
================
@@ -1526,19 +1534,28 @@ void HWAddressSanitizer::sanitizeFunction(Function &F,
return;
NumTotalFuncs++;
- if (CSkipHotCode) {
- auto &MAMProxy = FAM.getResult<ModuleAnalysisManagerFunctionProxy>(F);
- ProfileSummaryInfo *PSI =
- MAMProxy.getCachedResult<ProfileSummaryAnalysis>(*F.getParent());
- if (PSI && PSI->hasProfileSummary()) {
- auto &BFI = FAM.getResult<BlockFrequencyAnalysis>(F);
- if ((HotPercentileCutoff.getNumOccurrences() && HotPercentileCutoff >= 0)
- ? PSI->isFunctionHotInCallGraphNthPercentile(HotPercentileCutoff,
- &F, BFI)
- : PSI->isFunctionHotInCallGraph(&F, BFI))
- return;
+ if (CSelectiveInstrumentation) {
+ if (RandomSkipRate.getNumOccurrences()) {
+ std::unique_ptr<RandomNumberGenerator> Rng = F.getParent()->createRNG(F.getName());
----------------
vitalybuka wrote:
'remove-traps-random-rate" is function pass, so I need to recreate random every function
HWAddressSanitizer is module pass, so you can make it the class member.
```
HWAddressSanitizer(Module &M, bool CompileKernel, bool Recover,
const StackSafetyGlobalInfo *SSI) : Rng(M->createRNG("hwasan"))
```
Note module name is already appended in createRNG
https://github.com/llvm/llvm-project/pull/83942
More information about the llvm-commits
mailing list