[llvm] d23c24f - [llvm][nsan] Skip function declarations (#105598)

via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 21 18:08:34 PDT 2024


Author: Alexander Shaposhnikov
Date: 2024-08-21T18:08:31-07:00
New Revision: d23c24f336674727d281258157fc5b15ce9040a4

URL: https://github.com/llvm/llvm-project/commit/d23c24f336674727d281258157fc5b15ce9040a4
DIFF: https://github.com/llvm/llvm-project/commit/d23c24f336674727d281258157fc5b15ce9040a4.diff

LOG: [llvm][nsan] Skip function declarations (#105598)

Skip function declarations in the instrumentation pass.

Added: 
    

Modified: 
    llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp
    llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll

Removed: 
    


################################################################################
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


        


More information about the llvm-commits mailing list