[llvm-commits] [compiler-rt] r161957 - in /compiler-rt/trunk/lib/tsan/rtl: tsan_rtl.cc tsan_rtl.h
Dmitry Vyukov
dvyukov at google.com
Wed Aug 15 09:52:19 PDT 2012
Author: dvyukov
Date: Wed Aug 15 11:52:19 2012
New Revision: 161957
URL: http://llvm.org/viewvc/llvm-project?rev=161957&view=rev
Log:
tsan: provide function that imitates write to a region but does not detect races
Modified:
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc?rev=161957&r1=161956&r2=161957&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.cc Wed Aug 15 11:52:19 2012
@@ -427,13 +427,16 @@
const uptr kMaxResetSize = 1024*1024*1024;
if (size > kMaxResetSize)
size = kMaxResetSize;
- size = (size + 7) & ~7;
+ size = (size + (kShadowCell - 1)) & ~(kShadowCell - 1);
u64 *p = (u64*)MemToShadow(addr);
CHECK(IsShadowMem((uptr)p));
CHECK(IsShadowMem((uptr)(p + size * kShadowCnt / kShadowCell - 1)));
// FIXME: may overwrite a part outside the region
- for (uptr i = 0; i < size * kShadowCnt / kShadowCell; i++)
- p[i] = val;
+ for (uptr i = 0; i < size * kShadowCnt / kShadowCell;) {
+ p[i++] = val;
+ for (uptr j = 1; j < kShadowCnt; j++)
+ p[i++] = 0;
+ }
}
void MemoryResetRange(ThreadState *thr, uptr pc, uptr addr, uptr size) {
@@ -449,6 +452,13 @@
MemoryRangeSet(thr, pc, addr, size, s.raw());
}
+void MemoryRangeImitateWrite(ThreadState *thr, uptr pc, uptr addr, uptr size) {
+ Shadow s(thr->fast_state);
+ s.SetWrite(true);
+ s.SetAddr0AndSizeLog(0, 3);
+ MemoryRangeSet(thr, pc, addr, size, s.raw());
+}
+
void FuncEntry(ThreadState *thr, uptr pc) {
DCHECK_EQ(thr->in_rtl, 0);
StatInc(thr, StatFuncEnter);
Modified: compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h?rev=161957&r1=161956&r2=161957&view=diff
==============================================================================
--- compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h (original)
+++ compiler-rt/trunk/lib/tsan/rtl/tsan_rtl.h Wed Aug 15 11:52:19 2012
@@ -40,7 +40,9 @@
// Descriptor of user's memory block.
struct MBlock {
+ Mutex mtx;
uptr size;
+ SyncVar *head;
};
#ifndef TSAN_GO
@@ -451,6 +453,7 @@
uptr size, bool is_write);
void MemoryResetRange(ThreadState *thr, uptr pc, uptr addr, uptr size);
void MemoryRangeFreed(ThreadState *thr, uptr pc, uptr addr, uptr size);
+void MemoryRangeImitateWrite(ThreadState *thr, uptr pc, uptr addr, uptr size);
void IgnoreCtl(ThreadState *thr, bool write, bool begin);
void FuncEntry(ThreadState *thr, uptr pc);
More information about the llvm-commits
mailing list