[llvm-branch-commits] [HWASan] only remove attributes for called LibFuncs (PR #109489)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Sep 20 16:03:08 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Florian Mayer (fmayer)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/109489.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp (+9-4)
``````````diff
diff --git a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
index 50f8802924363a..6d4adc4f126f3b 100644
--- a/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -639,9 +639,6 @@ void HWAddressSanitizer::initializeModule() {
LLVM_DEBUG(dbgs() << "Init " << M.getName() << "\n");
TargetTriple = Triple(M.getTargetTriple());
- for (Function &F: M.functions())
- removeFnAttributes(&F);
-
// x86_64 currently has two modes:
// - Intel LAM (default)
// - pointer aliasing (heap only)
@@ -903,7 +900,13 @@ void HWAddressSanitizer::getInterestingMemoryOperands(
Type *Ty = CI->getParamByValType(ArgNo);
Interesting.emplace_back(I, ArgNo, false, Ty, Align(1));
}
- maybeMarkSanitizerLibraryCallNoBuiltin(CI, &TLI);
+ if (Function *F = CI->getCalledFunction()) {
+ LibFunc LF;
+ if (F->hasName() && TLI.getLibFunc(F->getName(), LF)) {
+ maybeMarkSanitizerLibraryCallNoBuiltin(CI, &TLI);
+ removeFnAttributes(F);
+ }
+ }
}
}
@@ -1625,6 +1628,8 @@ void HWAddressSanitizer::sanitizeFunction(Function &F,
if (selectiveInstrumentationShouldSkip(F, FAM))
return;
+ removeFnAttributes(&F);
+
NumInstrumentedFuncs++;
LLVM_DEBUG(dbgs() << "Function: " << F.getName() << "\n");
``````````
</details>
https://github.com/llvm/llvm-project/pull/109489
More information about the llvm-branch-commits
mailing list