[TSan] use efficient real_memcpy inside runtime
llvm-svn: 158260
diff --git a/compiler-rt/lib/tsan/rtl/tsan_defs.h b/compiler-rt/lib/tsan/rtl/tsan_defs.h
index d2a5ce7..76895d6 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_defs.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_defs.h
@@ -135,6 +135,7 @@
}
void real_memset(void *ptr, int c, uptr size);
+void real_memcpy(void *dst, const void *src, uptr size);
int internal_memcmp(const void *s1, const void *s2, uptr size);
int internal_strncmp(const char *s1, const char *s2, uptr size);
void internal_strcpy(char *s1, const char *s2);
diff --git a/compiler-rt/lib/tsan/rtl/tsan_flags.cc b/compiler-rt/lib/tsan/rtl/tsan_flags.cc
index afad9bb..2268d6a 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_flags.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_flags.cc
@@ -139,7 +139,7 @@
return;
int len = end - val;
char *f = (char*)internal_alloc(MBlockFlag, len + 1);
- internal_memcpy(f, val, len);
+ real_memcpy(f, val, len);
f[len] = 0;
*flag = f;
}
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
index 9114e76..35ab0be 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors.cc
@@ -1525,6 +1525,10 @@
REAL(memset)(ptr, c, size);
}
+void real_memcpy(void *dst, const void *src, uptr size) {
+ REAL(memcpy)(dst, src, size);
+}
+
int internal_memcmp(const void *s1, const void *s2, uptr size) {
return REAL(memcmp)(s1, s2, size);
}
diff --git a/compiler-rt/lib/tsan/rtl/tsan_md5.cc b/compiler-rt/lib/tsan/rtl/tsan_md5.cc
index aeae302..c2074c0 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_md5.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_md5.cc
@@ -166,11 +166,11 @@
free = 64 - used;
if (size < free) {
- internal_memcpy(&ctx->buffer[used], data, size);
+ real_memcpy(&ctx->buffer[used], data, size);
return;
}
- internal_memcpy(&ctx->buffer[used], data, free);
+ real_memcpy(&ctx->buffer[used], data, free);
data = (unsigned char *)data + free;
size -= free;
body(ctx, ctx->buffer, 64);
@@ -181,7 +181,7 @@
size &= 0x3f;
}
- internal_memcpy(ctx->buffer, data, size);
+ real_memcpy(ctx->buffer, data, size);
}
void MD5_Final(unsigned char *result, MD5_CTX *ctx) {
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc
index 147e383..7f6d69b 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_thread.cc
@@ -212,7 +212,7 @@
// Save from info about the thread.
tctx->dead_info = new(internal_alloc(MBlockDeadInfo, sizeof(ThreadDeadInfo)))
ThreadDeadInfo();
- internal_memcpy(&tctx->dead_info->trace.events[0],
+ real_memcpy(&tctx->dead_info->trace.events[0],
&thr->trace.events[0], sizeof(thr->trace.events));
for (int i = 0; i < kTraceParts; i++) {
tctx->dead_info->trace.headers[i].stack0.CopyFrom(
diff --git a/compiler-rt/lib/tsan/rtl/tsan_suppressions.cc b/compiler-rt/lib/tsan/rtl/tsan_suppressions.cc
index d4c37e1..ced6591 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_suppressions.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_suppressions.cc
@@ -118,7 +118,7 @@
head = s;
s->type = stype;
s->templ = (char*)internal_alloc(MBlockSuppression, end2 - line + 1);
- internal_memcpy(s->templ, line, end2 - line);
+ real_memcpy(s->templ, line, end2 - line);
s->templ[end2 - line] = 0;
}
if (end[0] == 0)
diff --git a/compiler-rt/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc b/compiler-rt/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc
index 71ba7cd..6a445c2 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_symbolize_addr2line_linux.cc
@@ -179,12 +179,12 @@
char *pos = (char*)internal_strchr(func, '\n');
if (pos && func[0] != '?') {
res->func = (char*)internal_alloc(MBlockReportStack, pos - func + 1);
- internal_memcpy(res->func, func, pos - func);
+ real_memcpy(res->func, func, pos - func);
res->func[pos - func] = 0;
char *pos2 = (char*)internal_strchr(pos, ':');
if (pos2) {
res->file = (char*)internal_alloc(MBlockReportStack, pos2 - pos - 1 + 1);
- internal_memcpy(res->file, pos + 1, pos2 - pos - 1);
+ real_memcpy(res->file, pos + 1, pos2 - pos - 1);
res->file[pos2 - pos - 1] = 0;
res->line = atoi(pos2 + 1);
}
@@ -215,14 +215,14 @@
symb[0].module = 0;
symb[0].offset = addr;
symb[0].name = alloc->Alloc<char>(pos - tmp + 1);
- internal_memcpy(symb[0].name, tmp, pos - tmp);
+ real_memcpy(symb[0].name, tmp, pos - tmp);
symb[0].name[pos - tmp] = 0;
symb[0].file = 0;
symb[0].line = 0;
char *pos2 = strchr(pos, ':');
if (pos2) {
symb[0].file = alloc->Alloc<char>(pos2 - pos - 1 + 1);
- internal_memcpy(symb[0].file, pos + 1, pos2 - pos - 1);
+ real_memcpy(symb[0].file, pos + 1, pos2 - pos - 1);
symb[0].file[pos2 - pos - 1] = 0;
symb[0].line = atoi(pos2 + 1);
}
diff --git a/compiler-rt/lib/tsan/rtl/tsan_sync.cc b/compiler-rt/lib/tsan/rtl/tsan_sync.cc
index e917c5b..36b316a 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_sync.cc
+++ b/compiler-rt/lib/tsan/rtl/tsan_sync.cc
@@ -155,7 +155,7 @@
return;
n_ = cnt;
s_ = (uptr*)internal_alloc(MBlockStackTrace, cnt * sizeof(s_[0]));
- internal_memcpy(s_, pcs, cnt * sizeof(s_[0]));
+ real_memcpy(s_, pcs, cnt * sizeof(s_[0]));
}
void StackTrace::ObtainCurrent(ThreadState *thr, uptr toppc) {
diff --git a/compiler-rt/lib/tsan/rtl/tsan_vector.h b/compiler-rt/lib/tsan/rtl/tsan_vector.h
index d41063d..5b6998f 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_vector.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_vector.h
@@ -94,7 +94,7 @@
cap = size;
T *p = (T*)internal_alloc(typ_, cap * sizeof(T));
if (cap0) {
- internal_memcpy(p, begin_, cap0 * sizeof(T));
+ real_memcpy(p, begin_, cap0 * sizeof(T));
internal_free(begin_);
}
begin_ = p;