[llvm] 876fa60 - [TySan] Skip instrumentation for function declarations (#122488)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 11 04:15:25 PST 2025
Author: Mingjie Xu
Date: 2025-01-11T20:15:21+08:00
New Revision: 876fa60f081ed66ad9645f955790198c3a96882c
URL: https://github.com/llvm/llvm-project/commit/876fa60f081ed66ad9645f955790198c3a96882c
DIFF: https://github.com/llvm/llvm-project/commit/876fa60f081ed66ad9645f955790198c3a96882c.diff
LOG: [TySan] Skip instrumentation for function declarations (#122488)
Skip function declarations for instrumentation.
Fixes https://github.com/llvm/llvm-project/issues/122467
Added:
Modified:
llvm/lib/Transforms/Instrumentation/TypeSanitizer.cpp
llvm/test/Instrumentation/TypeSanitizer/basic.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Instrumentation/TypeSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/TypeSanitizer.cpp
index 9cd81f3e6edb30..2ae8106218667b 100644
--- a/llvm/lib/Transforms/Instrumentation/TypeSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/TypeSanitizer.cpp
@@ -512,6 +512,8 @@ void collectMemAccessInfo(
bool TypeSanitizer::sanitizeFunction(Function &F,
const TargetLibraryInfo &TLI) {
+ if (F.isDeclaration())
+ return false;
// This is required to prevent instrumenting call to __tysan_init from within
// the module constructor.
if (&F == TysanCtorFunction.getCallee() || &F == TysanGlobalsSetTypeFunction)
diff --git a/llvm/test/Instrumentation/TypeSanitizer/basic.ll b/llvm/test/Instrumentation/TypeSanitizer/basic.ll
index 704c18800f19e0..b40b64664502a0 100644
--- a/llvm/test/Instrumentation/TypeSanitizer/basic.ll
+++ b/llvm/test/Instrumentation/TypeSanitizer/basic.ll
@@ -5,6 +5,8 @@
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+declare i32 @declaration_only(i32 %a) sanitize_type
+
;.
; CHECK: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 0, ptr @tysan.module_ctor, ptr null }]
; CHECK: @__tysan_v1_Simple_20C_2b_2b_20TBAA = linkonce_odr constant { i64, i64, [16 x i8] } { i64 2, i64 0, [16 x i8] c"Simple C++ TBAA\00" }, comdat
More information about the llvm-commits
mailing list