[compiler-rt] [compiler-rt][TSan] Fix TSan compile error on Android (PR #162369)

Fei Peng via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 7 13:42:10 PDT 2025


https://github.com/airpfei created https://github.com/llvm/llvm-project/pull/162369

None

>From 4452d26a6dd9220e0041d9cdff37481d8735abee Mon Sep 17 00:00:00 2001
From: Fei Peng <pengfei.02 at bytedance.com>
Date: Tue, 7 Oct 2025 13:35:57 -0700
Subject: [PATCH] [compiler-rt][TSan] Fix TSan compile error on Android

---
 compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
index 6b6538735beb0..61c9bbb03f7f2 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
@@ -680,7 +680,8 @@ ThreadState *cur_thread() {
   // significant bit of TLS_SLOT_SANITIZER to 1. Scudo allocator uses this bit
   // as a flag to disable memory initialization. This is a workaround to get the
   // correct ThreadState pointer.
-  reinterpret_cast<ThreadState*>(addr & ~1ULL);
+  uptr addr = reinterpret_cast<uptr>(thr);
+  return reinterpret_cast<ThreadState*>(addr & ~1ULL);
 }
 
 void set_cur_thread(ThreadState *thr) {



More information about the llvm-commits mailing list