[compiler-rt] c7a4ede - tsan: make IsMetaMem accept u32*
Dmitry Vyukov via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 5 04:36:35 PDT 2021
Author: Dmitry Vyukov
Date: 2021-08-05T13:36:23+02:00
New Revision: c7a4ede3511692a58627a9eedb8518dcef6c9a97
URL: https://github.com/llvm/llvm-project/commit/c7a4ede3511692a58627a9eedb8518dcef6c9a97
DIFF: https://github.com/llvm/llvm-project/commit/c7a4ede3511692a58627a9eedb8518dcef6c9a97.diff
LOG: tsan: make IsMetaMem accept u32*
MemToMeta returns u32*, so it's reasonable for IsMetaMem
to accept u32* as well.
Changing the argument type just removes few type casts.
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D107481
Added:
Modified:
compiler-rt/lib/tsan/rtl/tsan_debugging.cpp
compiler-rt/lib/tsan/rtl/tsan_platform.h
compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/tsan/rtl/tsan_debugging.cpp b/compiler-rt/lib/tsan/rtl/tsan_debugging.cpp
index d54814c6a0dcb..8abbb380293fd 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_debugging.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_debugging.cpp
@@ -195,7 +195,7 @@ const char *__tsan_locate_address(uptr addr, char *name, uptr name_size,
const char *region_kind = nullptr;
if (name && name_size > 0) name[0] = 0;
- if (IsMetaMem(addr)) {
+ if (IsMetaMem(reinterpret_cast<u32 *>(addr))) {
region_kind = "meta shadow";
} else if (IsShadowMem(addr)) {
region_kind = "shadow";
diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform.h b/compiler-rt/lib/tsan/rtl/tsan_platform.h
index 8bd218e25fd6f..8f784ac8cc753 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_platform.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_platform.h
@@ -892,7 +892,8 @@ bool IsMetaMemImpl(uptr mem) {
}
ALWAYS_INLINE
-bool IsMetaMem(uptr mem) {
+bool IsMetaMem(const u32 *p) {
+ uptr mem = reinterpret_cast<uptr>(p);
#if defined(__aarch64__) && !defined(__APPLE__) && !SANITIZER_GO
switch (vmaSize) {
case 39: return IsMetaMemImpl<Mapping39>(mem);
@@ -926,7 +927,6 @@ bool IsMetaMem(uptr mem) {
#endif
}
-
template<typename Mapping>
uptr MemToShadowImpl(uptr x) {
DCHECK(IsAppMem(x));
diff --git a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
index 46abdead5971b..9285f9283ebd6 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl.cpp
@@ -328,7 +328,7 @@ static void CheckShadowMapping() {
if (p < beg || p >= end)
continue;
const uptr s = MemToShadow(p);
- const uptr m = (uptr)MemToMeta(p);
+ u32 *const m = MemToMeta(p);
VPrintf(3, " checking pointer %p: shadow=%p meta=%p\n", p, s, m);
CHECK(IsAppMem(p));
CHECK(IsShadowMem(s));
@@ -338,10 +338,9 @@ static void CheckShadowMapping() {
// Ensure that shadow and meta mappings are linear within a single
// user range. Lots of code that processes memory ranges assumes it.
const uptr prev_s = MemToShadow(prev);
- const uptr prev_m = (uptr)MemToMeta(prev);
+ u32 *const prev_m = MemToMeta(prev);
CHECK_EQ(s - prev_s, (p - prev) * kShadowMultiplier);
- CHECK_EQ((m - prev_m) / kMetaShadowSize,
- (p - prev) / kMetaShadowCell);
+ CHECK_EQ(m - prev_m, (p - prev) / kMetaShadowCell);
}
prev = p;
}
More information about the llvm-commits
mailing list