[llvm] [llvm][nsan] Skip function declarations (PR #105598)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 21 17:08:49 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
@llvm/pr-subscribers-llvm-transforms
Author: Alexander Shaposhnikov (alexander-shaposhnikov)
<details>
<summary>Changes</summary>
Skip function declarations in the instrumentation pass.
---
Full diff: https://github.com/llvm/llvm-project/pull/105598.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp (+2-1)
- (modified) llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll (+2)
``````````diff
diff --git a/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp b/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
index 5872396669435a..ffd9faff1d3a53 100644
--- a/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
@@ -2038,7 +2038,8 @@ static void moveFastMathFlags(Function &F,
bool NumericalStabilitySanitizer::sanitizeFunction(
Function &F, const TargetLibraryInfo &TLI) {
- if (!F.hasFnAttribute(Attribute::SanitizeNumericalStability))
+ if (!F.hasFnAttribute(Attribute::SanitizeNumericalStability) ||
+ F.isDeclaration())
return false;
// This is required to prevent instrumenting call to __nsan_init from within
diff --git a/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll b/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll
index 5da68320d91f90..2131162bf4bf3f 100644
--- a/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll
+++ b/llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll
@@ -4,6 +4,8 @@
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
+declare float @declaration_only(float %a) sanitize_numerical_stability
+
; Tests with simple control flow.
@float_const = private unnamed_addr constant float 0.5
``````````
</details>
https://github.com/llvm/llvm-project/pull/105598
More information about the llvm-commits
mailing list