[PATCH] D133268: [tsan] Replace mem intrinsics with calls to interceptor

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 3 22:25:25 PDT 2022


vitalybuka created this revision.
Herald added subscribers: Enna1, hiraditya.
Herald added a project: All.
vitalybuka requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

It's not a problem as-is, but slight changes in
pipeline can return llvm intrinsics back.
In partucular InstCombine is able to return them back.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133268

Files:
  llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
  llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll


Index: llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll
===================================================================
--- llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll
+++ llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll
@@ -35,7 +35,7 @@
     tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %x, i8* align 4 %y, i64 16, i1 false)
     ret void
 ; CHECK: define void @MemCpyTest
-; CHECK: call i8* @memcpy
+; CHECK: call i8* @__interceptor_memcpy
 ; CHECK: ret void
 }
 
@@ -44,7 +44,7 @@
     tail call void @llvm.memcpy.inline.p0i8.p0i8.i64(i8* align 4 %x, i8* align 4 %y, i64 16, i1 false)
     ret void
 ; CHECK: define void @MemCpyInlineTest
-; CHECK: call i8* @memcpy
+; CHECK: call i8* @__interceptor_memcpy
 ; CHECK: ret void
 }
 
@@ -53,7 +53,7 @@
     tail call void @llvm.memmove.p0i8.p0i8.i64(i8* align 4 %x, i8* align 4 %y, i64 16, i1 false)
     ret void
 ; CHECK: define void @MemMoveTest
-; CHECK: call i8* @memmove
+; CHECK: call i8* @__interceptor_memmove
 ; CHECK: ret void
 }
 
@@ -62,7 +62,7 @@
     tail call void @llvm.memset.p0i8.i64(i8* align 4 %x, i8 77, i64 16, i1 false)
     ret void
 ; CHECK: define void @MemSetTest
-; CHECK: call i8* @memset
+; CHECK: call i8* @__interceptor_memset
 ; CHECK: ret void
 }
 
@@ -71,7 +71,7 @@
     tail call void @llvm.memset.inline.p0i8.i64(i8* align 4 %x, i8 77, i64 16, i1 false)
     ret void
 ; CHECK: define void @MemSetInlineTest
-; CHECK: call i8* @memset
+; CHECK: call i8* @__interceptor_memset
 ; CHECK: ret void
 }
 
Index: llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
@@ -341,13 +341,13 @@
   }
 
   MemmoveFn =
-      M.getOrInsertFunction("memmove", Attr, IRB.getInt8PtrTy(),
+      M.getOrInsertFunction("__interceptor_memmove", Attr, IRB.getInt8PtrTy(),
                             IRB.getInt8PtrTy(), IRB.getInt8PtrTy(), IntptrTy);
   MemcpyFn =
-      M.getOrInsertFunction("memcpy", Attr, IRB.getInt8PtrTy(),
+      M.getOrInsertFunction("__interceptor_memcpy", Attr, IRB.getInt8PtrTy(),
                             IRB.getInt8PtrTy(), IRB.getInt8PtrTy(), IntptrTy);
   MemsetFn =
-      M.getOrInsertFunction("memset", Attr, IRB.getInt8PtrTy(),
+      M.getOrInsertFunction("__interceptor_memset", Attr, IRB.getInt8PtrTy(),
                             IRB.getInt8PtrTy(), IRB.getInt32Ty(), IntptrTy);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133268.457835.patch
Type: text/x-patch
Size: 2528 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220904/3d2a56e3/attachment.bin>


More information about the llvm-commits mailing list