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

2021-12-08 Thread Kirill A. Korinsky via Phabricator via cfe-commits
catap updated this revision to Diff 392865.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

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/OpenMP/for_lastprivate_codegen.cpp
  clang/test/OpenMP/master_taskloop_in_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_in_reduction_codegen.cpp
  clang/test/OpenMP/parallel_master_taskloop_simd_codegen.cpp
  clang/test/OpenMP/sections_lastprivate_codegen.cpp
  clang/test/OpenMP/task_in_reduction_codegen.cpp
  clang/test/OpenMP/taskgroup_task_reduction_codegen.cpp
  clang/test/OpenMP/taskloop_in_reduction_codegen.cpp
  clang/test/OpenMP/taskloop_simd_in_reduction_codegen.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
@@ -819,7 +819,9 @@
 
   /// Tests whether the target uses emulated TLS as default.
   bool hasDefaultEmulatedTLS() const {
-return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment();
+return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment() ||
+   (isMacOSX() && !isMacOSXVersionLT(10, 4) &&
+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
+++ clang/test/SemaCXX/cxx11-thread-unsupported.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -triple=x86_64-apple-macosx10.6 -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple=x86_64-apple-macosx10.3 -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,9 +5,9 @@
 // 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
-// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fsyntax-only %s
+// Darwin supports TLS since macOS 10.4.
+// RUN: not %clang_cc1 -triple x86_64-apple-darwin7 -fsyntax-only %s
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.4.0 -fsyntax-only %s
 
 // RUN: %clang_cc1 -triple x86_64-pc-win32 -fsyntax-only %s
 // RUN: %clang_cc1 -triple i386-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,5 @@
-// RUN: not %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.6 %s 2>&1 | FileCheck %s --check-prefix NO-TLS
+// RUN: not %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.3 %s 2>&1 | FileCheck %s --check-prefix NO-TLS
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.4 %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/test/OpenMP/taskloop_simd_in_reduction_codegen.cpp
===
--- clang/test/OpenMP/taskloop_simd_in_reduction_codegen.cpp
+++ clang/test/OpenMP/taskloop_simd_in_reduction_codegen.cpp
@@ -1,11 +1,11 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" "pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _
-// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK1
-// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin7 -fopenmp -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK1
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin7 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-apple-darwin7 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK2
 
-// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK3

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

2021-12-08 Thread Kirill A. Korinsky via Phabricator via cfe-commits
catap updated this revision to Diff 392828.

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
@@ -819,7 +819,8 @@
 
   /// Tests whether the target uses emulated TLS as default.
   bool hasDefaultEmulatedTLS() const {
-return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment();
+return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment() ||
+   (isMacOSX() && !isMacOSXVersionLT(10, 4) && 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
+++ clang/test/SemaCXX/cxx11-thread-unsupported.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++11 -triple=x86_64-apple-macosx10.6 -verify %s
+// RUN: %clang_cc1 -std=c++11 -triple=x86_64-apple-macosx10.3 -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,9 +5,9 @@
 // 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
-// RUN: %clang_cc1 -triple x86_64-apple-macos10.7.0 -fsyntax-only %s
+// Darwin supports TLS since macOS 10.4.
+// RUN: not %clang_cc1 -triple x86_64-apple-darwin7 -fsyntax-only %s
+// RUN: %clang_cc1 -triple x86_64-apple-macos10.4.0 -fsyntax-only %s
 
 // RUN: %clang_cc1 -triple x86_64-pc-win32 -fsyntax-only %s
 // RUN: %clang_cc1 -triple i386-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,5 @@
-// RUN: not %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.6 %s 2>&1 | 
FileCheck %s --check-prefix NO-TLS
+// RUN: not %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.3 %s 2>&1 | 
FileCheck %s --check-prefix NO-TLS
+// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-macosx10.4 %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  = 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.


Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -819,7 +819,8 @@
 
   /// Tests whether the target uses emulated TLS as default.
   bool hasDefaultEmulatedTLS() const {
-return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment();
+return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment() ||
+   (isMacOSX() && !isMacOSXVersionLT(10, 4) && 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
+++ 

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

2021-12-08 Thread Kirill A. Korinsky via Phabricator via cfe-commits
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  = 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.


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: 

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

2021-12-08 Thread Kirill A. Korinsky via Phabricator via cfe-commits
catap updated this revision to Diff 392731.

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
+++ clang/test/SemaCXX/cxx11-thread-unsupported.cpp
@@ -1,5 +1,5 @@
 // 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}}
+  thread_local int x;
 }
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 NO-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  = 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.


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
+++ clang/test/SemaCXX/cxx11-thread-unsupported.cpp
@@ -1,5 +1,5 @@
 // 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}}
+  thread_local int x;
 }
Index: clang/test/Sema/tls.c
===
--- 

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

2021-12-08 Thread Kirill A. Korinsky via Phabricator via cfe-commits
catap updated this revision to Diff 392715.

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
  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() ||
+   (isOSDarwin() && isMacOSXVersionLT(10, 7));
   }
 
   /// Tests whether the target uses -data-sections as default.
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  = CGF.getTarget().getTriple();
-Name = T.isOSDarwin() ?  "_tlv_atexit" : "__cxa_thread_atexit";
+Name = (T.isOSDarwin() && !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.


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() ||
+   (isOSDarwin() && isMacOSXVersionLT(10, 7));
   }
 
   /// Tests whether the target uses -data-sections as default.
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  = CGF.getTarget().getTriple();
-Name = T.isOSDarwin() ?  "_tlv_atexit" : "__cxa_thread_atexit";
+Name = (T.isOSDarwin() && !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.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-12-07 Thread Kirill A. Korinsky via Phabricator via cfe-commits
catap updated this revision to Diff 392539.

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
  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() ||
+   isMacOSXVersionLT(10, 7);
   }
 
   /// Tests whether the target uses -data-sections as default.
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  = CGF.getTarget().getTriple();
-Name = T.isOSDarwin() ?  "_tlv_atexit" : "__cxa_thread_atexit";
+Name = (T.isOSDarwin() && !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.


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() ||
+   isMacOSXVersionLT(10, 7);
   }
 
   /// Tests whether the target uses -data-sections as default.
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  = CGF.getTarget().getTriple();
-Name = T.isOSDarwin() ?  "_tlv_atexit" : "__cxa_thread_atexit";
+Name = (T.isOSDarwin() && !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.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-12-07 Thread Kirill A. Korinsky via Phabricator via cfe-commits
catap updated this revision to Diff 392531.

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
  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() ||
+   isMacOSXVersionLT(10, 7);
   }
 
   /// Tests whether the target uses -data-sections as default.
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  = CGF.getTarget().getTriple();
-Name = T.isOSDarwin() ?  "_tlv_atexit" : "__cxa_thread_atexit";
+Name = (T.isOSDarwin() && !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.


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() ||
+   isMacOSXVersionLT(10, 7);
   }
 
   /// Tests whether the target uses -data-sections as default.
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  = CGF.getTarget().getTriple();
-Name = T.isOSDarwin() ?  "_tlv_atexit" : "__cxa_thread_atexit";
+Name = (T.isOSDarwin() && !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.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-12-07 Thread Kirill A. Korinsky via Phabricator via cfe-commits
catap updated this revision to Diff 392496.

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
  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() ||
+   isMacOSXVersionLT(10, 7);
   }
 
   /// Tests whether the target uses -data-sections as default.
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  = CGF.getTarget().getTriple();
-Name = T.isOSDarwin() ?  "_tlv_atexit" : "__cxa_thread_atexit";
+Name = (T.isOSDarwin() && !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.


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() ||
+   isMacOSXVersionLT(10, 7);
   }
 
   /// Tests whether the target uses -data-sections as default.
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  = CGF.getTarget().getTriple();
-Name = T.isOSDarwin() ?  "_tlv_atexit" : "__cxa_thread_atexit";
+Name = (T.isOSDarwin() && !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.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-12-07 Thread Kirill A. Korinsky via Phabricator via cfe-commits
catap updated this revision to Diff 392450.

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
  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() ||
+   isMacOSXVersionLT(10, 7);
   }
 
   /// Tests whether the target uses -data-sections as default.
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2580,7 +2580,8 @@
   const char *Name = "__cxa_atexit";
   if (TLS) {
 const llvm::Triple  = CGF.getTarget().getTriple();
-Name = T.isOSDarwin() ?  "_tlv_atexit" : "__cxa_thread_atexit";
+Name = (T.isOSDarwin() && !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.


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() ||
+   isMacOSXVersionLT(10, 7);
   }
 
   /// Tests whether the target uses -data-sections as default.
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2580,7 +2580,8 @@
   const char *Name = "__cxa_atexit";
   if (TLS) {
 const llvm::Triple  = CGF.getTarget().getTriple();
-Name = T.isOSDarwin() ?  "_tlv_atexit" : "__cxa_thread_atexit";
+Name = (T.isOSDarwin() && !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.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-12-07 Thread Kirill A. Korinsky via Phabricator via cfe-commits
catap created this revision.
catap added a reviewer: chandlerc.
catap added projects: clang, LLVM.
Herald added subscribers: dexonsmith, JDevlieghere.
catap requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits.

The first version of macOS which had TLV inside DYLD was macOS 10.7 and 
llvm/clang can't compile code:

  __thread int x;
  
  void use_x() {
  x = 7;
  }

on macOS before 10.7 as:

.section__TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 6
.globl  _use_x  ## -- Begin function use_x
.p2align4, 0x90
  _use_x: ## @use_x
.cfi_startproc
pushq   %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq%rsp, %rbp
.cfi_def_cfa_register %rbp
leaq___emutls_v.x(%rip), %rdi
callq   ___emutls_get_address
movl$7, (%rax)
popq%rbp
retq
.cfi_endproc
  ## -- End function
.section__DATA,__data
.globl  ___emutls_v.x   ## @__emutls_v.x
.p2align3
  ___emutls_v.x:
.quad   4   ## 0x4
.quad   4   ## 0x4
.quad   0
.quad   0
  
  .subsections_via_symbols

Which allows me to build rust for macOS 10.6 for example.

This changes effectively reverts an assumption that was introduced at least at 
25 Jun 2010 in commit 
https://github.com/llvm/llvm-project/commit/17c7b89054639ad3cd86f917ad11a50377c8de17

I guess it isn't the only place, but it shown how deep ago it was.

This patch was tested on all MacPorts users for quite a while since it was 
firstly introduced on 13 Dec 2018 at commit 
https://github.com/macports/macports-ports/commit/5949e6264728ac7f74625c9eaf5b41d2852d07e6

Co-authored-by: Ken Cunningham 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115250

Files:
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/CodeGen/ItaniumCXXABI.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,7 @@
 
   /// Tests whether the target uses emulated TLS as default.
   bool hasDefaultEmulatedTLS() const {
-return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment();
+return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment() || 
isMacOSXVersionLT(10, 7);
   }
 
   /// Tests whether the target uses -data-sections as default.
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2580,7 +2580,7 @@
   const char *Name = "__cxa_atexit";
   if (TLS) {
 const llvm::Triple  = CGF.getTarget().getTriple();
-Name = T.isOSDarwin() ?  "_tlv_atexit" : "__cxa_thread_atexit";
+Name = (T.isOSDarwin() && !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.


Index: llvm/include/llvm/ADT/Triple.h
===
--- llvm/include/llvm/ADT/Triple.h
+++ llvm/include/llvm/ADT/Triple.h
@@ -839,7 +839,7 @@
 
   /// Tests whether the target uses emulated TLS as default.
   bool hasDefaultEmulatedTLS() const {
-return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment();
+return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment() || isMacOSXVersionLT(10, 7);
   }
 
   /// Tests whether the target uses -data-sections as default.
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2580,7 +2580,7 @@
   const char *Name = "__cxa_atexit";
   if (TLS) {
 const llvm::Triple  = CGF.getTarget().getTriple();
-Name = T.isOSDarwin() ?  "_tlv_atexit" : "__cxa_thread_atexit";
+Name = (T.isOSDarwin() && !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