llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Ian Anderson (ian-twilightcoder)

<details>
<summary>Changes</summary>

Thread local storage isn't universally supported on all architectures. Only 
enable it for the ones that are known to support it.

rdar://183822457

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


2 Files Affected:

- (modified) clang/lib/Basic/Targets/OSTargets.h (+21-2) 
- (modified) clang/test/Sema/darwin-tls.c (+3) 


``````````diff
diff --git a/clang/lib/Basic/Targets/OSTargets.h 
b/clang/lib/Basic/Targets/OSTargets.h
index e3343ca3e1902..fb5c17cefc004 100644
--- a/clang/lib/Basic/Targets/OSTargets.h
+++ b/clang/lib/Basic/Targets/OSTargets.h
@@ -110,8 +110,27 @@ class LLVM_LIBRARY_VISIBILITY DarwinTargetInfo
       // No TLS on DriverKit.
     } else if (Triple.isXROS())
       this->TLSSupported = true;
-    else if (Triple.isAppleFirmware())
-      this->TLSSupported = true;
+    else if (Triple.isAppleFirmware()) {
+      if (Triple.isAArch64() || Triple.isARM())
+        this->TLSSupported = true;
+      else if (Triple.isThumb()) {
+        switch (Triple.getSubArch()) {
+        case llvm::Triple::NoSubArch:
+        case llvm::Triple::ARMSubArch_v4t:
+        case llvm::Triple::ARMSubArch_v5:
+        case llvm::Triple::ARMSubArch_v5te:
+        case llvm::Triple::ARMSubArch_v6:
+        case llvm::Triple::ARMSubArch_v6k:
+        case llvm::Triple::ARMSubArch_v6m:
+          // Thumb-1 doesn't support TLS.
+          break;
+
+        default:
+          this->TLSSupported = true;
+          break;
+        }
+      }
+    }
 
     this->MCountName = "\01mcount";
   }
diff --git a/clang/test/Sema/darwin-tls.c b/clang/test/Sema/darwin-tls.c
index 2a3d6871cd88c..ddae9011d9c42 100644
--- a/clang/test/Sema/darwin-tls.c
+++ b/clang/test/Sema/darwin-tls.c
@@ -15,6 +15,9 @@
 // RUN: %clang_cc1 -fsyntax-only -Wno-error=implicit-int -triple 
i386-apple-watchos3.0-simulator %s 2>&1 | FileCheck %s --check-prefix TLS
 // RUN: %clang_cc1 -fsyntax-only -Wno-error=implicit-int -triple 
arm64-apple-xros %s 2>&1 | FileCheck %s --check-prefix TLS
 // RUN: %clang_cc1 -fsyntax-only -Wno-error=implicit-int -triple 
arm64-apple-xros-simulator %s 2>&1 | FileCheck %s --check-prefix TLS
+
+// RUN: not %clang_cc1 -fsyntax-only -triple thumbv6m-apple-firmware %s 2>&1 | 
FileCheck %s --check-prefix NO-TLS
+// RUN: %clang_cc1 -fsyntax-only -Wno-error=implicit-int -triple 
thumbv7em-apple-firmware %s 2>&1 | FileCheck %s --check-prefix TLS
 // RUN: %clang_cc1 -fsyntax-only -Wno-error=implicit-int -triple 
arm64-apple-firmware %s 2>&1 | FileCheck %s --check-prefix TLS
 
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/213595
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to