[PATCH] D115250: switched to emulated TLV on macOS before 10.7

Kirill A. Korinsky via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 8 07:20:55 PST 2021


catap updated this revision to Diff 392755.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115250/new/

https://reviews.llvm.org/D115250

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/Sema/darwin-tls.c
  clang/test/Sema/tls.c
  clang/test/SemaCXX/cxx11-thread-unsupported.cpp
  llvm/include/llvm/ADT/Triple.h


Index: llvm/include/llvm/ADT/Triple.h
===================================================================
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -839,7 +839,8 @@
 
   /// Tests whether the target uses emulated TLS as default.
   bool hasDefaultEmulatedTLS() const {
-    return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment();
+    return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment() ||
+           (isMacOSX() && isMacOSXVersionLT(10, 7));
   }
 
   /// Tests whether the target uses -data-sections as default.
Index: clang/test/SemaCXX/cxx11-thread-unsupported.cpp
===================================================================
--- clang/test/SemaCXX/cxx11-thread-unsupported.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-// RUN: %clang_cc1 -std=c++11 -triple=x86_64-apple-macosx10.6 -verify %s
-
-void f() {
-  thread_local int x; // expected-error {{thread-local storage is not supported for the current target}}
-}
Index: clang/test/Sema/tls.c
===================================================================
--- clang/test/Sema/tls.c
+++ clang/test/Sema/tls.c
@@ -5,8 +5,8 @@
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only %s
 // RUN: %clang_cc1 -triple i386-pc-linux-gnu -fsyntax-only %s
 
-// Darwin supports TLS since 10.7.
-// RUN: not %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only %s
+// Darwin supports TLS.
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only %s
 // RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fsyntax-only %s
 
 // RUN: %clang_cc1 -triple x86_64-pc-win32 -fsyntax-only %s
Index: clang/test/Sema/darwin-tls.c
===================================================================
--- clang/test/Sema/darwin-tls.c
+++ clang/test/Sema/darwin-tls.c
@@ -1,4 +1,4 @@
-// RUN: not %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.6 %s 2>&1 | FileCheck %s --check-prefix NO-TLS
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.6 %s 2>&1 | FileCheck %s --check-prefix TLS
 // RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.7 %s 2>&1 | FileCheck %s --check-prefix TLS
 
 // RUN: not %clang_cc1 -fsyntax-only -triple arm64-apple-ios7.1 %s 2>&1 | FileCheck %s --check-prefix NO-TLS
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===================================================================
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2580,7 +2580,9 @@
   const char *Name = "__cxa_atexit";
   if (TLS) {
     const llvm::Triple &T = CGF.getTarget().getTriple();
-    Name = T.isOSDarwin() ?  "_tlv_atexit" : "__cxa_thread_atexit";
+    Name = (T.isOSDarwin() && !(T.isMacOSX() && T.isMacOSXVersionLT(10, 7)))
+               ? "_tlv_atexit"
+               : "__cxa_thread_atexit";
   }
 
   // We're assuming that the destructor function is something we can
Index: clang/lib/Basic/Targets/OSTargets.h
===================================================================
--- clang/lib/Basic/Targets/OSTargets.h
+++ clang/lib/Basic/Targets/OSTargets.h
@@ -91,7 +91,7 @@
     this->TLSSupported = false;
 
     if (Triple.isMacOSX())
-      this->TLSSupported = !Triple.isMacOSXVersionLT(10, 7);
+      this->TLSSupported = !Triple.isMacOSXVersionLT(10, 4);
     else if (Triple.isiOS()) {
       // 64-bit iOS supported it from 8 onwards, 32-bit device from 9 onwards,
       // 32-bit simulator from 10 onwards.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115250.392755.patch
Type: text/x-patch
Size: 3405 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211208/7bb80593/attachment.bin>


More information about the cfe-commits mailing list