[clang] [ARM] Forbid use of TLS with execute-only (PR #124806)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 28 09:57:11 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-arm

Author: Oliver Stannard (ostannard)

<details>
<summary>Changes</summary>

Thread-local code generation requires constant pools because most of the relocations needed for it operate on data, so it cannot be used with -mexecute-only (or -mpure-code, which is aliased in the driver).

Without this we hit an assertion in the backend when trying to generate a constant pool.

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


2 Files Affected:

- (modified) clang/lib/Basic/Targets/ARM.cpp (+2) 
- (added) clang/test/Sema/arm-execute-only-tls.c (+10) 


``````````diff
diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index 0fd5433a76402e..5aa2baeb81b731 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -608,6 +608,8 @@ bool ARMTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
       HasBTI = 1;
     } else if (Feature == "+fullbf16") {
       HasFullBFloat16 = true;
+    } else if (Feature == "+execute-only") {
+      TLSSupported = false;
     }
   }
 
diff --git a/clang/test/Sema/arm-execute-only-tls.c b/clang/test/Sema/arm-execute-only-tls.c
new file mode 100644
index 00000000000000..b17ff450cb74d1
--- /dev/null
+++ b/clang/test/Sema/arm-execute-only-tls.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple arm-none-eabi                               -fsyntax-only -verify=default      %s
+// RUN: %clang_cc1 -triple arm-none-eabi -target-feature +execute-only -fsyntax-only -verify=execute-only %s
+
+// default-no-diagnostics
+
+/// Thread-local code generation requires constant pools because most of the
+/// relocations needed for it operate on data, so it cannot be used with
+/// -mexecute-only (or -mpure-code, which is aliased in the driver).
+
+_Thread_local int t; // execute-only-error {{thread-local storage is not supported for the current target}}

``````````

</details>


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


More information about the cfe-commits mailing list