Skip to content

Commit 876fa60

Browse files
authored
[TySan] Skip instrumentation for function declarations (#122488)
Skip function declarations for instrumentation. Fixes #122467
1 parent 77ef5a6 commit 876fa60

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

llvm/lib/Transforms/Instrumentation/TypeSanitizer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,8 @@ void collectMemAccessInfo(
512512

513513
bool TypeSanitizer::sanitizeFunction(Function &F,
514514
const TargetLibraryInfo &TLI) {
515+
if (F.isDeclaration())
516+
return false;
515517
// This is required to prevent instrumenting call to __tysan_init from within
516518
// the module constructor.
517519
if (&F == TysanCtorFunction.getCallee() || &F == TysanGlobalsSetTypeFunction)

llvm/test/Instrumentation/TypeSanitizer/basic.ll

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

66
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
77

8+
declare i32 @declaration_only(i32 %a) sanitize_type
9+
810
;.
911
; CHECK: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ i32, ptr, ptr } { i32 0, ptr @tysan.module_ctor, ptr null }]
1012
; 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

0 commit comments

Comments
 (0)