[compiler-rt] [compiler-rt][asan] Use native TLS for TSD on Windows (PR #222705)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 10 09:47:50 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: oltolm (oltolm)

<details>
<summary>Changes</summary>

GCC 16 supports native Windows TLS. Use compiler-rt's THREADLOCAL abstraction for fake_tsd on all compilers instead of spelling the MSVC-specific storage-class syntax directly. GCC configurations using emulated TLS remain unsupported.

---
Full diff: https://github.com/llvm/llvm-project/pull/222705.diff


1 Files Affected:

- (modified) compiler-rt/lib/asan/asan_win.cpp (+1-1) 


``````````diff
diff --git a/compiler-rt/lib/asan/asan_win.cpp b/compiler-rt/lib/asan/asan_win.cpp
index c671a2d6327eb..cbb107d6e5633 100644
--- a/compiler-rt/lib/asan/asan_win.cpp
+++ b/compiler-rt/lib/asan/asan_win.cpp
@@ -228,7 +228,7 @@ void FlushUnneededASanShadowMemory(uptr p, uptr size) {
 // ---------------------- TSD ---------------- {{{
 static bool tsd_key_inited = false;
 
-static __declspec(thread) void *fake_tsd = 0;
+static THREADLOCAL void* fake_tsd = 0;
 
 // https://docs.microsoft.com/en-us/windows/desktop/api/winternl/ns-winternl-_teb
 // "[This structure may be altered in future versions of Windows. Applications

``````````

</details>


https://github.com/llvm/llvm-project/pull/222705


More information about the llvm-commits mailing list