[compiler-rt] 18c6ed2 - tsan: add AccessVptr
Dmitry Vyukov via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 3 02:03:41 PDT 2021
Author: Dmitry Vyukov
Date: 2021-08-03T11:03:36+02:00
New Revision: 18c6ed2f0f293582570ad3f6419e10ff808ba98e
URL: https://github.com/llvm/llvm-project/commit/18c6ed2f0f293582570ad3f6419e10ff808ba98e
DIFF: https://github.com/llvm/llvm-project/commit/18c6ed2f0f293582570ad3f6419e10ff808ba98e.diff
LOG: tsan: add AccessVptr
Add AccessVptr access type.
For now it's converted to the same thr->is_vptr_access,
but later it will be passed directly to ReportRace
and will enable efficient tail calling in MemoryAccess function
(currently __tsan_vptr_update/__tsan_vptr_read can't use
tail calls in MemoryAccess because of the trailing assignment
to thr->is_vptr_access).
Depends on D107276.
Reviewed By: vitalybuka, melver
Differential Revision: https://reviews.llvm.org/D107282
Added:
Modified:
compiler-rt/lib/tsan/rtl/tsan_interface_inl.h
compiler-rt/lib/tsan/rtl/tsan_rtl.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interface_inl.h b/compiler-rt/lib/tsan/rtl/tsan_interface_inl.h
index 1d36721c72bb..e4ea3366d847 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interface_inl.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_interface_inl.h
@@ -83,21 +83,15 @@ void __tsan_write8_pc(void *addr, void *pc) {
}
void __tsan_vptr_update(void **vptr_p, void *new_val) {
- CHECK_EQ(sizeof(vptr_p), 8);
- if (*vptr_p != new_val) {
- ThreadState *thr = cur_thread();
- thr->is_vptr_access = true;
- MemoryAccess(thr, CALLERPC, (uptr)vptr_p, 8, kAccessWrite);
- thr->is_vptr_access = false;
- }
+ if (*vptr_p == new_val)
+ return;
+ MemoryAccess(cur_thread(), CALLERPC, (uptr)vptr_p, sizeof(*vptr_p),
+ kAccessWrite | kAccessVptr);
}
void __tsan_vptr_read(void **vptr_p) {
- CHECK_EQ(sizeof(vptr_p), 8);
- ThreadState *thr = cur_thread();
- thr->is_vptr_access = true;
- MemoryAccess(thr, CALLERPC, (uptr)vptr_p, 8, kAccessRead);
- thr->is_vptr_access = false;
+ MemoryAccess(cur_thread(), CALLERPC, (uptr)vptr_p, sizeof(*vptr_p),
+ kAccessRead | kAccessVptr);
}
void __tsan_func_entry(void *pc) { FuncEntry(cur_thread(), STRIP_PAC_PC(pc)); }
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.h b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
index 7f13a4a0a1d5..483459b7646d 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.h
@@ -698,6 +698,7 @@ enum : AccessType {
kAccessWrite = 0,
kAccessRead = 1 << 0,
kAccessAtomic = 1 << 1,
+ kAccessVptr = 1 << 2,
};
void MemoryAccess(ThreadState *thr, uptr pc, uptr addr,
@@ -738,7 +739,11 @@ void MemoryAccess(ThreadState *thr, uptr pc, uptr addr, uptr size,
}
bool is_write = !(typ & kAccessRead);
bool is_atomic = typ & kAccessAtomic;
+ if (typ & kAccessVptr)
+ thr->is_vptr_access = true;
MemoryAccess(thr, pc, addr, size_log, is_write, is_atomic);
+ if (typ & kAccessVptr)
+ thr->is_vptr_access = false;
}
void MemoryResetRange(ThreadState *thr, uptr pc, uptr addr, uptr size);
More information about the llvm-commits
mailing list