[llvm] [TySan] Skip instrumentation for function declarations (PR #122488)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 10 08:24:42 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-compiler-rt-sanitizer
Author: Mingjie Xu (Enna1)
<details>
<summary>Changes</summary>
Skip function declarations for instrumentation.
---
Full diff: https://github.com/llvm/llvm-project/pull/122488.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/Instrumentation/TypeSanitizer.cpp (+2)
- (modified) llvm/test/Instrumentation/TypeSanitizer/basic.ll (+2)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/122488
More information about the llvm-commits
mailing list