Looks like this breaks our buildbot (attaching logs from running "make -f Makefile.old presubmit" locally):<div><div><br></div><div><div>clang++ unit_tests/tsan_clock_test.o unit_tests/tsan_flags_test.o unit_tests/tsan_mman_test.o unit_tests/tsan_mutex_test.o unit_tests/tsan_platform_test.o unit_tests/tsan_printf_test.o unit_tests/tsan_shadow_test.o unit_tests/tsan_suppressions_test.o unit_tests/tsan_sync_test.o unit_tests/tsan_vector_test.o rtl_tests/tsan_bench.o rtl_tests/tsan_mop.o rtl_tests/tsan_mutex.o rtl_tests/tsan_posix.o rtl_tests/tsan_string.o rtl_tests/tsan_test.o rtl_tests/tsan_test_util_linux.o rtl_tests/tsan_thread.o ../sanitizer_common/tests/sanitizer_allocator64_test.o ../sanitizer_common/tests/sanitizer_allocator_test.o rtl/libtsan.a third_party/googletest/build/gtest-all.o -o tsan_test -ldl -lpthread -pie</div>
<div>rtl_tests/tsan_test_util_linux.o: In function `ScopedThread::Impl::HandleEvent(Event*)':</div><div>/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/rtl_tests/tsan_test_util_linux.cc:304: undefined reference to `__interceptor_memcpy'</div>
<div>/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/rtl_tests/tsan_test_util_linux.cc:307: undefined reference to `__interceptor_memset'</div><div>rtl/libtsan.a(tsan_interceptors.o): In function `__tsan::intercept_memset(unsigned long, void*, int, unsigned long)':</div>
<div>/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:384: undefined reference to `__interception::real_memset'</div><div>/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:385: undefined reference to `__interception::real_memset'</div>
<div>rtl/libtsan.a(tsan_interceptors.o): In function `__tsan::intercept_memcpy(unsigned long, void*, void const*, unsigned long)':</div><div>/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:390: undefined reference to `__interception::real_memcpy'</div>
<div>/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:392: undefined reference to `__interception::real_memcpy'</div><div>rtl/libtsan.a(tsan_interceptors.o): In function `__tsan::intercept_memcmp(unsigned long, void const*, void const*, unsigned long)':</div>
<div>/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:397: undefined reference to `__interception::real_memcmp'</div><div>rtl/libtsan.a(tsan_interceptors.o): In function `__interceptor_signal':</div>
<div>/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:1345: undefined reference to `__interception::real_memset'</div><div>rtl/libtsan.a(tsan_interceptors.o): In function `__tsan::InitializeInterceptors()':</div>
<div>/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:1457: undefined reference to `__interception::real_memcpy'</div><div>/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:1457: undefined reference to `__interception::real_memset'</div>
<div>/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:1488: undefined reference to `__interception::real_memset'</div><div>/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:1488: undefined reference to `__interceptor_memset'</div>
<div>/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:1489: undefined reference to `__interception::real_memcpy'</div><div>/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:1489: undefined reference to `__interceptor_memcpy'</div>
<div>/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:1494: undefined reference to `__interception::real_memcmp'</div><div>/home/samsonov/llvm-project/llvm2/projects/compiler-rt/lib/tsan/tsan_interceptors.cc:1494: undefined reference to `__interceptor_memcmp'</div>
<br><div class="gmail_quote">On Thu, Jun 28, 2012 at 1:00 AM, Dmitry Vyukov <span dir="ltr"><<a href="mailto:dvyukov@google.com" target="_blank">dvyukov@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Author: dvyukov<br>Date: Wed Jun 27 16:00:23 2012<br>New Revision: 159294<br><br>URL: <a href="http://llvm.org/viewvc/llvm-project?rev=159294&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=159294&view=rev</a><br>
Log:<br>tsan: prevent insertion of unwanted memset/memcpy/memcmp into runtime<br><br>Modified:<br>   compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h<br>   compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h<br>   compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc<br>
   compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc<br>   compiler-rt/trunk/lib/tsan/rtl/tsan_md5.cc<br>   compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc<br>   compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc<br>   compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc<br>
   compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc<br>   compiler-rt/trunk/lib/tsan/rtl/tsan_vector.h<br>   compiler-rt/trunk/lib/tsan/rtl_tests/tsan_test_util_linux.cc<br>   compiler-rt/trunk/lib/tsan/unit_tests/tsan_platform_test.cc<br>
<br>Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h<br>URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h?rev=159294&r1=159293&r2=159294&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h?rev=159294&r1=159293&r2=159294&view=diff</a><br>
==============================================================================<br>--- compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h (original)<br>+++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_internal_defs.h Wed Jun 27 16:00:23 2012<br>
@@ -26,6 +26,7 @@<br> // Platform-specific defs.<br> #if defined(_WIN32)<br> typedef unsigned long    DWORD;  // NOLINT<br>+# define ALWAYS_INLINE __declspec(forceinline)<br> // FIXME(timurrrr): do we need this on Windows?<br>
 # define ALIAS(x)<br> # define ALIGNED(x) __declspec(align(x))<br>@@ -33,18 +34,24 @@<br> # define NOINLINE __declspec(noinline)<br> # define NORETURN __declspec(noreturn)<br> # define THREADLOCAL   __declspec(thread)<br>
+# define NOTHROW<br> #else  // _WIN32<br>+# define ALWAYS_INLINE __attribute__((always_inline))<br> # define ALIAS(x) __attribute__((alias(x)))<br> # define ALIGNED(x) __attribute__((aligned(x)))<br> # define FORMAT(f, a)  __attribute__((format(printf, f, a)))<br>
 # define NOINLINE __attribute__((noinline))<br> # define NORETURN  __attribute__((noreturn))<br> # define THREADLOCAL   __thread<br>+# ifdef __cplusplus<br>+#   define NOTHROW throw()<br>+# else<br>+#   define NOTHROW __attribute__((__nothrow__))<br>
+#endif<br> #endif  // _WIN32<br><br> // We have no equivalent of these on Windows.<br> #ifndef _WIN32<br>-# define ALWAYS_INLINE __attribute__((always_inline))<br> # define LIKELY(x)     __builtin_expect(!!(x), 1)<br> # define UNLIKELY(x)   __builtin_expect(!!(x), 0)<br>
 # define UNUSED __attribute__((unused))<br><br>Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h<br>URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h?rev=159294&r1=159293&r2=159294&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h?rev=159294&r1=159293&r2=159294&view=diff</a><br>
==============================================================================<br>--- compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h (original)<br>+++ compiler-rt/trunk/lib/tsan/rtl/tsan_defs.h Wed Jun 27 16:00:23 2012<br>@@ -14,7 +14,6 @@<br>
 #ifndef TSAN_DEFS_H<br> #define TSAN_DEFS_H<br><br>-#include "interception/interception.h"<br> #include "sanitizer_common/sanitizer_internal_defs.h"<br> #include "sanitizer_common/sanitizer_libc.h"<br>
 #include "tsan_stat.h"<br>@@ -155,9 +154,29 @@<br><br> }  // namespace __tsan<br><br>-DECLARE_REAL(void*, memset, void *ptr, int v, uptr size);<br>-DECLARE_REAL(void*, memcpy, void *dst, const void *src, uptr size);<br>
-DECLARE_REAL(int, strncmp, const char *s1, const char *s2, uptr n);<br>-DECLARE_REAL(const char*, strstr, const char *s1, const char *s2);<br>+extern "C" inline void *ALWAYS_INLINE<br>+memset(void *ptr, int v, uptr size) NOTHROW {<br>
+  for (uptr i = 0; i < size; i++)<br>+    ((char*)ptr)[i] = (char)v;<br>+  return ptr;<br>+}<br>+<br>+extern "C" inline void *ALWAYS_INLINE<br>+memcpy(void *dst, const void *src, uptr size) NOTHROW {<br>+  for (uptr i = 0; i < size; i++)<br>
+    ((char*)dst)[i] = ((char*)src)[i];<br>+  return dst;<br>+}<br>+<br>+extern "C" inline int ALWAYS_INLINE<br>+memcmp(const void *p1, const void *p2, uptr size) NOTHROW {<br>+  for (uptr i = 0; i < size; i++) {<br>
+    if (((unsigned char*)p1)[i] < ((unsigned char*)p2)[i])<br>+      return -1;<br>+    if (((unsigned char*)p1)[i] > ((unsigned char*)p2)[i])<br>+      return 1;<br>+  }<br>+  return 0;<br>+}<br><br> #endif  // TSAN_DEFS_H<br>
<br>Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc<br>URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc?rev=159294&r1=159293&r2=159294&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc?rev=159294&r1=159293&r2=159294&view=diff</a><br>
==============================================================================<br>--- compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc (original)<br>+++ compiler-rt/trunk/lib/tsan/rtl/tsan_flags.cc Wed Jun 27 16:00:23 2012<br>
@@ -32,7 +32,7 @@<br> }<br><br> void InitializeFlags(Flags *f, const char *env) {<br>-  REAL(memset)(f, 0, sizeof(*f));<br>+  internal_memset(f, 0, sizeof(*f));<br><br>  // Default values.<br>  f->enable_annotations = true;<br>
@@ -78,7 +78,7 @@<br>                                const char **end) {<br>  if (env == 0)<br>    return *end = 0;<br>-  const char *pos = REAL(strstr)(env, name);<br>+  const char *pos = internal_strstr(env, name);<br>  if (pos == 0)<br>
    return *end = 0;<br>  pos += internal_strlen(name);<br>@@ -139,7 +139,7 @@<br>    return;<br>  int len = end - val;<br>  char *f = (char*)internal_alloc(MBlockFlag, len + 1);<br>-  REAL(memcpy)(f, val, len);<br>+  internal_memcpy(f, val, len);<br>
  f[len] = 0;<br>  *flag = f;<br> }<br><br>Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc<br>URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?rev=159294&r1=159293&r2=159294&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc?rev=159294&r1=159293&r2=159294&view=diff</a><br>
==============================================================================<br>--- compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc (original)<br>+++ compiler-rt/trunk/lib/tsan/rtl/tsan_interceptors.cc Wed Jun 27 16:00:23 2012<br>
@@ -172,6 +172,17 @@<br>      return REAL(func)(__VA_ARGS__); \<br> /**/<br><br>+#define SCOPED_INTERCEPTOR_LIBC(func, ...) \<br>+    ThreadState *thr = cur_thread(); \<br>+    StatInc(thr, StatInterceptor); \<br>+    StatInc(thr, StatInt_##func); \<br>
+    ScopedInterceptor si(thr, #func, callpc); \<br>+    const uptr pc = (uptr)&func; \<br>+    (void)pc; \<br>+    if (thr->in_rtl > 1) \<br>+      return REAL(func)(__VA_ARGS__); \<br>+/**/<br>+<br> #define TSAN_INTERCEPTOR(ret, func, ...) INTERCEPTOR(ret, func, __VA_ARGS__)<br>
 #define TSAN_INTERCEPT(func) INTERCEPT_FUNCTION(func)<br><br>@@ -321,7 +332,7 @@<br>  {<br>    SCOPED_INTERCEPTOR_RAW(calloc, size, n);<br>    p = user_alloc(thr, pc, n * size);<br>-    REAL(memset)(p, 0, n * size);<br>+    internal_memset(p, 0, n * size);<br>
  }<br>  invoke_malloc_hook(p, n * size);<br>  return p;<br>@@ -354,26 +365,48 @@<br>  user_free(thr, pc, p);<br> }<br><br>-TSAN_INTERCEPTOR(uptr, strlen, const void *s) {<br>+TSAN_INTERCEPTOR(uptr, strlen, const char *s) {<br>
  SCOPED_TSAN_INTERCEPTOR(strlen, s);<br>-  uptr len = REAL(strlen)(s);<br>+  uptr len = internal_strlen(s);<br>  MemoryAccessRange(thr, pc, (uptr)s, len + 1, false);<br>  return len;<br> }<br><br>-TSAN_INTERCEPTOR(void*, memset, void *dst, int v, uptr size) {<br>
-  SCOPED_TSAN_INTERCEPTOR(memset, dst, v, size);<br>+DECLARE_REAL(void*, memset, void *dst, int v, uptr size);<br>+DECLARE_REAL(void*, memcpy, void *dst, const void *src, uptr size);<br>+DECLARE_REAL(int, memcmp, const void *s1, const void *s2, uptr n);<br>
+extern "C" void *__interceptor_memset(void *dst, int v, uptr size);<br>+extern "C" void *__interceptor_memcpy(void *dst, const void *src, uptr size);<br>+extern "C" int __interceptor_memcmp(const void *s1, const void *s2, uptr n);<br>
+<br>+namespace __tsan {<br>+void *intercept_memset(uptr callpc, void *dst, int v, uptr size) {<br>+  SCOPED_INTERCEPTOR_LIBC(memset, dst, v, size);<br>  MemoryAccessRange(thr, pc, (uptr)dst, size, true);<br>  return REAL(memset)(dst, v, size);<br>
 }<br><br>-TSAN_INTERCEPTOR(void*, memcpy, void *dst, const void *src, uptr size) {<br>-  SCOPED_TSAN_INTERCEPTOR(memcpy, dst, src, size);<br>+void *intercept_memcpy(uptr callpc, void *dst, const void *src, uptr size) {<br>
+  SCOPED_INTERCEPTOR_LIBC(memcpy, dst, src, size);<br>  MemoryAccessRange(thr, pc, (uptr)dst, size, true);<br>  MemoryAccessRange(thr, pc, (uptr)src, size, false);<br>  return REAL(memcpy)(dst, src, size);<br> }<br><br>+int intercept_memcmp(uptr callpc, const void *s1, const void *s2, uptr n) {<br>
+  SCOPED_INTERCEPTOR_LIBC(memcmp, s1, s2, n);<br>+  int res = 0;<br>+  uptr len = 0;<br>+  for (; len < n; len++) {<br>+    if ((res = ((unsigned char*)s1)[len] - ((unsigned char*)s2)[len]))<br>+      break;<br>+  }<br>
+  MemoryAccessRange(thr, pc, (uptr)s1, len < n ? len + 1 : n, false);<br>+  MemoryAccessRange(thr, pc, (uptr)s2, len < n ? len + 1 : n, false);<br>+  return res;<br>+}<br>+}<br>+<br> TSAN_INTERCEPTOR(int, strcmp, const char *s1, const char *s2) {<br>
  SCOPED_TSAN_INTERCEPTOR(strcmp, s1, s2);<br>  uptr len = 0;<br>@@ -419,52 +452,39 @@<br>  return REAL(memmove)(dst, src, n);<br> }<br><br>-TSAN_INTERCEPTOR(int, memcmp, const void *s1, const void *s2, uptr n) {<br>-  SCOPED_TSAN_INTERCEPTOR(memcmp, s1, s2, n);<br>
-  int res = 0;<br>-  uptr len = 0;<br>-  for (; len < n; len++) {<br>-    if ((res = ((unsigned char*)s1)[len] - ((unsigned char*)s2)[len]))<br>-      break;<br>-  }<br>-  MemoryAccessRange(thr, pc, (uptr)s1, len < n ? len + 1 : n, false);<br>
-  MemoryAccessRange(thr, pc, (uptr)s2, len < n ? len + 1 : n, false);<br>-  return res;<br>-}<br>-<br>-TSAN_INTERCEPTOR(void*, strchr, void *s, int c) {<br>+TSAN_INTERCEPTOR(char*, strchr, char *s, int c) {<br>  SCOPED_TSAN_INTERCEPTOR(strchr, s, c);<br>
-  void *res = REAL(strchr)(s, c);<br>-  uptr len = res ? (char*)res - (char*)s + 1 : REAL(strlen)(s) + 1;<br>+  char *res = REAL(strchr)(s, c);<br>+  uptr len = res ? (char*)res - (char*)s + 1 : internal_strlen(s) + 1;<br>
  MemoryAccessRange(thr, pc, (uptr)s, len, false);<br>  return res;<br> }<br><br>-TSAN_INTERCEPTOR(void*, strchrnul, void *s, int c) {<br>+TSAN_INTERCEPTOR(char*, strchrnul, char *s, int c) {<br>  SCOPED_TSAN_INTERCEPTOR(strchrnul, s, c);<br>
-  void *res = REAL(strchrnul)(s, c);<br>+  char *res = REAL(strchrnul)(s, c);<br>  uptr len = (char*)res - (char*)s + 1;<br>  MemoryAccessRange(thr, pc, (uptr)s, len, false);<br>  return res;<br> }<br><br>-TSAN_INTERCEPTOR(void*, strrchr, void *s, int c) {<br>
+TSAN_INTERCEPTOR(char*, strrchr, char *s, int c) {<br>  SCOPED_TSAN_INTERCEPTOR(strrchr, s, c);<br>-  MemoryAccessRange(thr, pc, (uptr)s, REAL(strlen)(s) + 1, false);<br>+  MemoryAccessRange(thr, pc, (uptr)s, internal_strlen(s) + 1, false);<br>
  return REAL(strrchr)(s, c);<br> }<br><br>-TSAN_INTERCEPTOR(void*, strcpy, void *dst, const void *src) {  // NOLINT<br>+TSAN_INTERCEPTOR(char*, strcpy, char *dst, const char *src) {  // NOLINT<br>  SCOPED_TSAN_INTERCEPTOR(strcpy, dst, src);  // NOLINT<br>
-  uptr srclen = REAL(strlen)(src);<br>+  uptr srclen = internal_strlen(src);<br>  MemoryAccessRange(thr, pc, (uptr)dst, srclen + 1, true);<br>  MemoryAccessRange(thr, pc, (uptr)src, srclen + 1, false);<br>  return REAL(strcpy)(dst, src);  // NOLINT<br>
 }<br><br>-TSAN_INTERCEPTOR(void*, strncpy, void *dst, void *src, uptr n) {<br>+TSAN_INTERCEPTOR(char*, strncpy, char *dst, char *src, uptr n) {<br>  SCOPED_TSAN_INTERCEPTOR(strncpy, dst, src, n);<br>-  uptr srclen = REAL(strlen)(src);<br>
+  uptr srclen = internal_strlen(src);<br>  MemoryAccessRange(thr, pc, (uptr)dst, n, true);<br>  MemoryAccessRange(thr, pc, (uptr)src, min(srclen + 1, n), false);<br>  return REAL(strncpy)(dst, src, n);<br>@@ -473,8 +493,8 @@<br>
 TSAN_INTERCEPTOR(const char*, strstr, const char *s1, const char *s2) {<br>  SCOPED_TSAN_INTERCEPTOR(strstr, s1, s2);<br>  const char *res = REAL(strstr)(s1, s2);<br>-  uptr len1 = REAL(strlen)(s1);<br>-  uptr len2 = REAL(strlen)(s2);<br>
+  uptr len1 = internal_strlen(s1);<br>+  uptr len2 = internal_strlen(s2);<br>  MemoryAccessRange(thr, pc, (uptr)s1, len1 + 1, false);<br>  MemoryAccessRange(thr, pc, (uptr)s2, len2 + 1, false);<br>  return res;<br>@@ -1224,7 +1244,7 @@<br>
<br> TSAN_INTERCEPTOR(int, puts, const char *s) {<br>  SCOPED_TSAN_INTERCEPTOR(puts, s);<br>-  MemoryAccessRange(thr, pc, (uptr)s, REAL(strlen)(s), false);<br>+  MemoryAccessRange(thr, pc, (uptr)s, internal_strlen(s), false);<br>
  return REAL(puts)(s);<br> }<br><br><br>Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_md5.cc<br>URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_md5.cc?rev=159294&r1=159293&r2=159294&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_md5.cc?rev=159294&r1=159293&r2=159294&view=diff</a><br>
==============================================================================<br>--- compiler-rt/trunk/lib/tsan/rtl/tsan_md5.cc (original)<br>+++ compiler-rt/trunk/lib/tsan/rtl/tsan_md5.cc Wed Jun 27 16:00:23 2012<br>@@ -166,11 +166,11 @@<br>
    free = 64 - used;<br><br>    if (size < free) {<br>-      REAL(memcpy)(&ctx->buffer[used], data, size);<br>+      internal_memcpy(&ctx->buffer[used], data, size);<br>      return;<br>    }<br><br>-    REAL(memcpy)(&ctx->buffer[used], data, free);<br>
+    internal_memcpy(&ctx->buffer[used], data, free);<br>    data = (unsigned char *)data + free;<br>    size -= free;<br>    body(ctx, ctx->buffer, 64);<br>@@ -181,7 +181,7 @@<br>    size &= 0x3f;<br>  }<br>
<br>-  REAL(memcpy)(ctx->buffer, data, size);<br>+  internal_memcpy(ctx->buffer, data, size);<br> }<br><br> void MD5_Final(unsigned char *result, MD5_CTX *ctx) {<br>@@ -194,13 +194,13 @@<br>  free = 64 - used;<br><br>
  if (free < 8) {<br>-    REAL(memset)(&ctx->buffer[used], 0, free);<br>+    internal_memset(&ctx->buffer[used], 0, free);<br>    body(ctx, ctx->buffer, 64);<br>    used = 0;<br>    free = 64;<br>  }<br>
<br>-  REAL(memset)(&ctx->buffer[used], 0, free - 8);<br>+  internal_memset(&ctx->buffer[used], 0, free - 8);<br><br>  ctx->lo <<= 3;<br>  ctx->buffer[56] = ctx->lo;<br>@@ -231,7 +231,7 @@<br>
  result[14] = ctx->d >> 16;<br>  result[15] = ctx->d >> 24;<br><br>-  REAL(memset)(ctx, 0, sizeof(*ctx));<br>+  internal_memset(ctx, 0, sizeof(*ctx));<br> }<br><br> MD5Hash md5_hash(const void *data, uptr size) {<br>
<br>Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc<br>URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc?rev=159294&r1=159293&r2=159294&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc?rev=159294&r1=159293&r2=159294&view=diff</a><br>
==============================================================================<br>--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc (original)<br>+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_report.cc Wed Jun 27 16:00:23 2012<br>
@@ -50,9 +50,9 @@<br>  const char *path_prefix = flags()->strip_path_prefix;<br>  uptr path_prefix_len = internal_strlen(path_prefix);<br>  for (ReportStack *ent = stack; ent; ent = ent->next) {<br>-    if (ent->func && 0 == REAL(strncmp)(ent->func, prefix, prefix_len))<br>
+    if (ent->func && 0 == internal_strncmp(ent->func, prefix, prefix_len))<br>      ent->func += prefix_len;<br>-    if (ent->file && 0 == REAL(strncmp)(ent->file, path_prefix,<br>+    if (ent->file && 0 == internal_strncmp(ent->file, path_prefix,<br>
                                           path_prefix_len))<br>      ent->file += path_prefix_len;<br>    if (ent->file && ent->file[0] == '.' && ent->file[1] == '/')<br><br>Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc?rev=159294&r1=159293&r2=159294&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc?rev=159294&r1=159293&r2=159294&view=diff</a><br>
==============================================================================<br>--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc (original)<br>+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl_thread.cc Wed Jun 27 16:00:23 2012<br>
@@ -212,7 +212,7 @@<br>  // Save from info about the thread.<br>  tctx->dead_info = new(internal_alloc(MBlockDeadInfo, sizeof(ThreadDeadInfo)))<br>      ThreadDeadInfo();<br>-  REAL(memcpy)(&tctx->dead_info->trace.events[0],<br>
+  internal_memcpy(&tctx->dead_info->trace.events[0],<br>      &thr->trace.events[0], sizeof(thr->trace.events));<br>  for (int i = 0; i < kTraceParts; i++) {<br>    tctx->dead_info->trace.headers[i].stack0.CopyFrom(<br>
<br>Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc<br>URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc?rev=159294&r1=159293&r2=159294&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc?rev=159294&r1=159293&r2=159294&view=diff</a><br>
==============================================================================<br>--- compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc (original)<br>+++ compiler-rt/trunk/lib/tsan/rtl/tsan_suppressions.cc Wed Jun 27 16:00:23 2012<br>
@@ -69,7 +69,7 @@<br>    tpos = (char*)internal_strchr(templ, '*');<br>    if (tpos != 0)<br>      tpos[0] = 0;<br>-    spos = REAL(strstr)(str, templ);<br>+    spos = internal_strstr(str, templ);<br>    str = spos + internal_strlen(templ);<br>
    templ = tpos;<br>    if (tpos)<br>@@ -94,18 +94,18 @@<br>      while (line != end2 && (end2[-1] == ' ' || end2[-1] == '\t'))<br>        end2--;<br>      SuppressionType stype;<br>-      if (0 == REAL(strncmp)(line, "race:", sizeof("race:") - 1)) {<br>
+      if (0 == internal_strncmp(line, "race:", sizeof("race:") - 1)) {<br>        stype = SuppressionRace;<br>        line += sizeof("race:") - 1;<br>-      } else if (0 == REAL(strncmp)(line, "thread:",<br>
+      } else if (0 == internal_strncmp(line, "thread:",<br>          sizeof("thread:") - 1)) {<br>        stype = SuppressionThread;<br>        line += sizeof("thread:") - 1;<br>-      } else if (0 == REAL(strncmp)(line, "mutex:",<br>
+      } else if (0 == internal_strncmp(line, "mutex:",<br>          sizeof("mutex:") - 1)) {<br>        stype = SuppressionMutex;<br>        line += sizeof("mutex:") - 1;<br>-      } else if (0 == REAL(strncmp)(line, "signal:",<br>
+      } else if (0 == internal_strncmp(line, "signal:",<br>          sizeof("signal:") - 1)) {<br>        stype = SuppressionSignal;<br>        line += sizeof("signal:") - 1;<br>@@ -119,7 +119,7 @@<br>
      head = s;<br>      s->type = stype;<br>      s->templ = (char*)internal_alloc(MBlockSuppression, end2 - line + 1);<br>-      REAL(memcpy)(s->templ, line, end2 - line);<br>+      internal_memcpy(s->templ, line, end2 - line);<br>
      s->templ[end2 - line] = 0;<br>    }<br>    if (end[0] == 0)<br><br>Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc<br>URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc?rev=159294&r1=159293&r2=159294&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc?rev=159294&r1=159293&r2=159294&view=diff</a><br>
==============================================================================<br>--- compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc (original)<br>+++ compiler-rt/trunk/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc Wed Jun 27 16:00:23 2012<br>
@@ -149,7 +149,7 @@<br> static ReportStack *NewFrame(uptr addr) {<br>  ReportStack *ent = (ReportStack*)internal_alloc(MBlockReportStack,<br>                                                  sizeof(ReportStack));<br>-  REAL(memset)(ent, 0, sizeof(*ent));<br>
+  internal_memset(ent, 0, sizeof(*ent));<br>  ent->pc = addr;<br>  return ent;<br> }<br>@@ -181,12 +181,12 @@<br>  char *pos = (char*)internal_strchr(func, '\n');<br>  if (pos && func[0] != '?') {<br>
    res->func = (char*)internal_alloc(MBlockReportStack, pos - func + 1);<br>-    REAL(memcpy)(res->func, func, pos - func);<br>+    internal_memcpy(res->func, func, pos - func);<br>    res->func[pos - func] = 0;<br>
    char *pos2 = (char*)internal_strchr(pos, ':');<br>    if (pos2) {<br>      res->file = (char*)internal_alloc(MBlockReportStack, pos2 - pos - 1 + 1);<br>-      REAL(memcpy)(res->file, pos + 1, pos2 - pos - 1);<br>
+      internal_memcpy(res->file, pos + 1, pos2 - pos - 1);<br>      res->file[pos2 - pos - 1] = 0;<br>      res->line = atoi(pos2 + 1);<br>     }<br>@@ -196,43 +196,6 @@<br><br> ReportStack *SymbolizeData(uptr addr) {<br>
  return 0;<br>-  /*<br>-  if (base == 0)<br>-    base = GetImageBase();<br>-  int res = 0;<br>-  InternalScopedBuf<char> cmd(1024);<br>-  internal_snprintf(cmd, cmd.Size(),<br>-  "nm -alC %s|grep \"%zx\"|awk '{printf(\"%%s\\n%%s\", $3, $4)}' > tsan.tmp2",<br>
-    exe, (addr - base));<br>-  if (system(cmd))<br>-    return 0;<br>-  FILE* f3 = fopen("tsan.tmp2", "rb");<br>-  if (f3) {<br>-    InternalScopedBuf<char> tmp(1024);<br>-    if (fread(tmp, 1, tmp.Size(), f3) <= 0)<br>
-      return 0;<br>-    char *pos = strchr(tmp, '\n');<br>-    if (pos && tmp[0] != '?') {<br>-      res = 1;<br>-      symb[0].module = 0;<br>-      symb[0].offset = addr;<br>-      symb[0].name = alloc->Alloc<char>(pos - tmp + 1);<br>
-      REAL(memcpy)(symb[0].name, tmp, pos - tmp);<br>-      symb[0].name[pos - tmp] = 0;<br>-      symb[0].file = 0;<br>-      symb[0].line = 0;<br>-      char *pos2 = strchr(pos, ':');<br>-      if (pos2) {<br>-        symb[0].file = alloc->Alloc<char>(pos2 - pos - 1 + 1);<br>
-        REAL(memcpy)(symb[0].file, pos + 1, pos2 - pos - 1);<br>-        symb[0].file[pos2 - pos - 1] = 0;<br>-        symb[0].line = atoi(pos2 + 1);<br>-      }<br>-    }<br>-    fclose(f3);<br>-  }<br>-  return res;<br>
-  */<br> }<br><br> }  // namespace __tsan<br><br>Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_vector.h<br>URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_vector.h?rev=159294&r1=159293&r2=159294&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_vector.h?rev=159294&r1=159293&r2=159294&view=diff</a><br>
==============================================================================<br>--- compiler-rt/trunk/lib/tsan/rtl/tsan_vector.h (original)<br>+++ compiler-rt/trunk/lib/tsan/rtl/tsan_vector.h Wed Jun 27 16:00:23 2012<br>
@@ -94,7 +94,7 @@<br>      cap = size;<br>    T *p = (T*)internal_alloc(typ_, cap * sizeof(T));<br>    if (cap0) {<br>-      REAL(memcpy)(p, begin_, cap0 * sizeof(T));<br>+      internal_memcpy(p, begin_, cap0 * sizeof(T));<br>
      internal_free(begin_);<br>    }<br>    begin_ = p;<br><br>Modified: compiler-rt/trunk/lib/tsan/rtl_tests/tsan_test_util_linux.cc<br>URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl_tests/tsan_test_util_linux.cc?rev=159294&r1=159293&r2=159294&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl_tests/tsan_test_util_linux.cc?rev=159294&r1=159293&r2=159294&view=diff</a><br>
==============================================================================<br>--- compiler-rt/trunk/lib/tsan/rtl_tests/tsan_test_util_linux.cc (original)<br>+++ compiler-rt/trunk/lib/tsan/rtl_tests/tsan_test_util_linux.cc Wed Jun 27 16:00:23 2012<br>
@@ -33,6 +33,9 @@<br> static __thread bool expect_report_reported;<br> static __thread ReportType expect_report_type;<br><br>+extern "C" void *__interceptor_memcpy(void*, const void*, uptr);<br>+extern "C" void *__interceptor_memset(void*, int, uptr);<br>
+<br> static void *BeforeInitThread(void *param) {<br>  (void)param;<br>  return 0;<br>@@ -298,10 +301,10 @@<br>    static_cast<Mutex*>(ev->ptr)->ReadUnlock();<br>    break;<br>  case Event::MEMCPY:<br>-    memcpy(ev->ptr, (void*)ev->arg, ev->arg2);<br>
+    __interceptor_memcpy(ev->ptr, (void*)ev->arg, ev->arg2);<br>    break;<br>  case Event::MEMSET:<br>-    memset(ev->ptr, ev->arg, ev->arg2);<br>+    __interceptor_memset(ev->ptr, ev->arg, ev->arg2);<br>
    break;<br>  default: CHECK(0);<br>  }<br><br>Modified: compiler-rt/trunk/lib/tsan/unit_tests/tsan_platform_test.cc<br>URL: <a href="http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/unit_tests/tsan_platform_test.cc?rev=159294&r1=159293&r2=159294&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/unit_tests/tsan_platform_test.cc?rev=159294&r1=159293&r2=159294&view=diff</a><br>
==============================================================================<br>--- compiler-rt/trunk/lib/tsan/unit_tests/tsan_platform_test.cc (original)<br>+++ compiler-rt/trunk/lib/tsan/unit_tests/tsan_platform_test.cc Wed Jun 27 16:00:23 2012<br>
@@ -79,7 +79,7 @@<br>  EXPECT_EQ(len1, internal_read(fd, buf, len1));<br>  EXPECT_EQ(0, internal_memcmp(buf, str1, len1));<br>  EXPECT_EQ((char)0, buf[len1 + 1]);<br>-  REAL(memset)(buf, 0, len1);<br>+  internal_memset(buf, 0, len1);<br>
  EXPECT_EQ(len2, internal_read(fd, buf, len2));<br>  EXPECT_EQ(0, internal_memcmp(buf, str2, len2));<br>  internal_close(fd);<br><br><br>_______________________________________________<br>llvm-commits mailing list<br><a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Alexey Samsonov, MSK</div>
</div></div><div><br></div>