[llvm] 7a4fab4 - [LoongArch] Emit error messages when using emulated TLS

via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 12 02:41:31 PDT 2024


Author: wanglei
Date: 2024-06-12T17:41:26+08:00
New Revision: 7a4fab410124144f0196bdee6645b649799dec15

URL: https://github.com/llvm/llvm-project/commit/7a4fab410124144f0196bdee6645b649799dec15
DIFF: https://github.com/llvm/llvm-project/commit/7a4fab410124144f0196bdee6645b649799dec15.diff

LOG: [LoongArch] Emit error messages when using emulated TLS

Reviewed By: SixWeining

Pull Request: https://github.com/llvm/llvm-project/pull/92483

Added: 
    llvm/test/CodeGen/LoongArch/emutls.ll

Modified: 
    llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
index 9d7e4636abac1..1721287dab4dd 100644
--- a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
@@ -945,6 +945,10 @@ LoongArchTargetLowering::lowerGlobalTLSAddress(SDValue Op,
   GlobalAddressSDNode *N = cast<GlobalAddressSDNode>(Op);
   assert(N->getOffset() == 0 && "unexpected offset in global node");
 
+  if (DAG.getTarget().useEmulatedTLS())
+    report_fatal_error("the emulated TLS is prohibited",
+                       /*GenCrashDiag=*/false);
+
   bool IsDesc = DAG.getTarget().useTLSDESC();
 
   switch (getTargetMachine().getTLSModel(N->getGlobal())) {

diff  --git a/llvm/test/CodeGen/LoongArch/emutls.ll b/llvm/test/CodeGen/LoongArch/emutls.ll
new file mode 100644
index 0000000000000..7824ce33d946f
--- /dev/null
+++ b/llvm/test/CodeGen/LoongArch/emutls.ll
@@ -0,0 +1,11 @@
+; RUN: not llc --mtriple=loongarch64 -emulated-tls -mattr=+d \
+; RUN:     -relocation-model=pic < %s 2>&1 | FileCheck %s
+
+; CHECK: LLVM ERROR: the emulated TLS is prohibited
+
+ at x = thread_local global i8 7, align 2
+
+define ptr @get_x() nounwind {
+entry:
+  ret ptr @x
+}


        


More information about the llvm-commits mailing list