Skip to content

Commit d23c24f

Browse files
[llvm][nsan] Skip function declarations (#105598)
Skip function declarations in the instrumentation pass.
1 parent 359c704 commit d23c24f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

llvm/lib/Transforms/Instrumentation/NumericalStabilitySanitizer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2038,7 +2038,8 @@ static void moveFastMathFlags(Function &F,
20382038

20392039
bool NumericalStabilitySanitizer::sanitizeFunction(
20402040
Function &F, const TargetLibraryInfo &TLI) {
2041-
if (!F.hasFnAttribute(Attribute::SanitizeNumericalStability))
2041+
if (!F.hasFnAttribute(Attribute::SanitizeNumericalStability) ||
2042+
F.isDeclaration())
20422043
return false;
20432044

20442045
// This is required to prevent instrumenting call to __nsan_init from within

llvm/test/Instrumentation/NumericalStabilitySanitizer/basic.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
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"
66

7+
declare float @declaration_only(float %a) sanitize_numerical_stability
8+
79
; Tests with simple control flow.
810

911
@float_const = private unnamed_addr constant float 0.5

0 commit comments

Comments
 (0)