[llvm-commits] [compiler-rt] r159430 - in /compiler-rt/trunk/lib/tsan/rtl: tsan_defs.h tsan_interceptors.cc tsan_interceptors2.cc
Dmitry Vyukov
dvyukov at google.com
Fri Jun 29 08:19:14 PDT 2012
Author: dvyukov
Date: Fri Jun 29 10:19:14 2012
New Revision: 159430
URL: http://llvm.org/viewvc/llvm-project?rev=159430&view=rev
Log:
tsan: remove own memset/memcpy/memcmp (too messy)
Removed:
compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors2.cc
Modified:
compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h
compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h?rev=159430&r1=159429&r2=159430&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h Fri Jun 29 10:19:14 2012
@@ -154,29 +154,4 @@
} // namespace __tsan
-extern "C" inline void *ALWAYS_INLINE
-memset(void *ptr, int v, uptr size) NOTHROW {
- for (uptr i = 0; i < size; i++)
- ((char*)ptr)[i] = (char)v;
- return ptr;
-}
-
-extern "C" inline void *ALWAYS_INLINE
-memcpy(void *dst, const void *src, uptr size) NOTHROW {
- for (uptr i = 0; i < size; i++)
- ((char*)dst)[i] = ((char*)src)[i];
- return dst;
-}
-
-extern "C" inline int ALWAYS_INLINE
-memcmp(const void *p1, const void *p2, uptr size) NOTHROW {
- for (uptr i = 0; i < size; i++) {
- if (((unsigned char*)p1)[i] < ((unsigned char*)p2)[i])
- return -1;
- if (((unsigned char*)p1)[i] > ((unsigned char*)p2)[i])
- return 1;
- }
- return 0;
-}
-
#endif // TSAN_DEFS_H
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?rev=159430&r1=159429&r2=159430&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Fri Jun 29 10:19:14 2012
@@ -373,29 +373,21 @@
return len;
}
-DECLARE_REAL(void*, memset, void *dst, int v, uptr size);
-DECLARE_REAL(void*, memcpy, void *dst, const void *src, uptr size);
-DECLARE_REAL(int, memcmp, const void *s1, const void *s2, uptr n);
-extern "C" void *__interceptor_memset(void *dst, int v, uptr size);
-extern "C" void *__interceptor_memcpy(void *dst, const void *src, uptr size);
-extern "C" int __interceptor_memcmp(const void *s1, const void *s2, uptr n);
-
-namespace __tsan {
-void *intercept_memset(uptr callpc, void *dst, int v, uptr size) {
- SCOPED_INTERCEPTOR_LIBC(memset, dst, v, size);
+TSAN_INTERCEPTOR(void*, memset, void *dst, int v, uptr size) {
+ SCOPED_TSAN_INTERCEPTOR(memset, dst, v, size);
MemoryAccessRange(thr, pc, (uptr)dst, size, true);
- return REAL(memset)(dst, v, size);
+ return internal_memset(dst, v, size);
}
-void *intercept_memcpy(uptr callpc, void *dst, const void *src, uptr size) {
- SCOPED_INTERCEPTOR_LIBC(memcpy, dst, src, size);
+TSAN_INTERCEPTOR(void*, memcpy, void *dst, const void *src, uptr size) {
+ SCOPED_TSAN_INTERCEPTOR(memcpy, dst, src, size);
MemoryAccessRange(thr, pc, (uptr)dst, size, true);
MemoryAccessRange(thr, pc, (uptr)src, size, false);
- return REAL(memcpy)(dst, src, size);
+ return internal_memcpy(dst, src, size);
}
-int intercept_memcmp(uptr callpc, const void *s1, const void *s2, uptr n) {
- SCOPED_INTERCEPTOR_LIBC(memcmp, s1, s2, n);
+TSAN_INTERCEPTOR(int, memcmp, const void *s1, const void *s2, uptr n) {
+ SCOPED_TSAN_INTERCEPTOR(memcmp, s1, s2, n);
int res = 0;
uptr len = 0;
for (; len < n; len++) {
@@ -406,7 +398,6 @@
MemoryAccessRange(thr, pc, (uptr)s2, len < n ? len + 1 : n, false);
return res;
}
-}
TSAN_INTERCEPTOR(int, strcmp, const char *s1, const char *s2) {
SCOPED_TSAN_INTERCEPTOR(strcmp, s1, s2);
@@ -1449,25 +1440,13 @@
namespace __tsan {
-// Used until we obtain real efficient functions.
-static void* poormans_memset(void *dst, int v, uptr size) {
- for (uptr i = 0; i < size; i++)
- ((char*)dst)[i] = (char)v;
- return dst;
-}
-
-static void* poormans_memcpy(void *dst, const void *src, uptr size) {
- for (uptr i = 0; i < size; i++)
- ((char*)dst)[i] = ((char*)src)[i];
- return dst;
-}
-
void InitializeInterceptors() {
CHECK_GT(cur_thread()->in_rtl, 0);
// We need to setup it early, because functions like dlsym() can call it.
- REAL(memset) = poormans_memset;
- REAL(memcpy) = poormans_memcpy;
+ REAL(memset) = internal_memset;
+ REAL(memcpy) = internal_memcpy;
+ REAL(memcmp) = internal_memcmp;
TSAN_INTERCEPT(longjmp);
TSAN_INTERCEPT(siglongjmp);
Removed: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors2.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors2.cc?rev=159429&view=auto
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors2.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors2.cc (removed)
@@ -1,35 +0,0 @@
-//===-- tsan_interceptors2.cc ---------------------------------------------===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file is a part of ThreadSanitizer (TSan), a race detector.
-//
-//===----------------------------------------------------------------------===//
-
-#include "interception/interception.h"
-#include "sanitizer_common/sanitizer_common.h"
-
-namespace __tsan {
- void *intercept_memset(uptr, void*, int, uptr);
- void *intercept_memcpy(uptr, void*, const void*, uptr);
- int intercept_memcmp(uptr, const void*, const void*, uptr);
-}
-
-using namespace __tsan; // NOLINT
-
-INTERCEPTOR(void*, memset, void *dst, int v, uptr size) {
- return intercept_memset((uptr)__builtin_return_address(0), dst, v, size);
-}
-
-INTERCEPTOR(void*, memcpy, void *dst, const void *src, uptr size) {
- return intercept_memcpy((uptr)__builtin_return_address(0), dst, src, size);
-}
-
-INTERCEPTOR(int, memcmp, const void *s1, const void *s2, uptr n) {
- return intercept_memcmp((uptr)__builtin_return_address(0), s1, s2, n);
-}
More information about the llvm-commits
mailing list