[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:07 PDT 2026
https://github.com/oltolm created https://github.com/llvm/llvm-project/pull/222705
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.
>From bb9c8d9886409da8a4efb992466a6e213ded3271 Mon Sep 17 00:00:00 2001
From: Oleg Tolmatcev <oleg.tolmatcev at gmail.com>
Date: Thu, 10 Sep 2026 17:49:24 +0200
Subject: [PATCH] [compiler-rt][asan] Use native TLS for TSD on Windows
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.
Co-authored-by: Hannes Domani <ssbssa at yahoo.de>
---
compiler-rt/lib/asan/asan_win.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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
More information about the llvm-commits
mailing list