From 403e21978044800473999f36fd014428db4ed027 Mon Sep 17 00:00:00 2001 From: hhj Date: Tue, 9 Aug 2022 11:48:06 +0800 Subject: [PATCH] Use emulated-tls for ohos build For ie/le compatibility reasons, use the emulated-tls as the default TLS implementation for ohos target. If want to change diable emulated tls, pls use -fno-emulated-tls options. TEST: llvm CodeGen test case Signed-off-by: hhj --- llvm/include/llvm/ADT/Triple.h | 2 +- llvm/test/CodeGen/AArch64/emutls.ll | 4 ++++ llvm/test/CodeGen/AArch64/emutls_generic.ll | 12 ++++++++++++ llvm/test/CodeGen/ARM/emutls.ll | 4 ++++ llvm/test/CodeGen/ARM/emutls_generic.ll | 4 ++++ llvm/test/CodeGen/X86/emutls-pic.ll | 4 ++++ llvm/test/CodeGen/X86/emutls-pie.ll | 8 ++++++++ llvm/test/CodeGen/X86/emutls.ll | 4 ++++ llvm/test/CodeGen/X86/emutls_generic.ll | 12 ++++++++++++ 9 files changed, 53 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h index 183ac3787fdc..cfda6ad94281 100644 --- a/llvm/include/llvm/ADT/Triple.h +++ b/llvm/include/llvm/ADT/Triple.h @@ -821,7 +821,7 @@ public: /// Tests whether the target uses emulated TLS as default. bool hasDefaultEmulatedTLS() const { - return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment(); + return isOpenHOS() || isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment(); } /// Tests whether the target uses -data-sections as default. diff --git a/llvm/test/CodeGen/AArch64/emutls.ll b/llvm/test/CodeGen/AArch64/emutls.ll index 25be391bbfaa..918eb75bc7bd 100644 --- a/llvm/test/CodeGen/AArch64/emutls.ll +++ b/llvm/test/CodeGen/AArch64/emutls.ll @@ -2,6 +2,10 @@ ; RUN: -relocation-model=pic -frame-pointer=all < %s | FileCheck -check-prefix=ARM64 %s ; RUN: llc -mtriple=aarch64-linux-android \ ; RUN: -relocation-model=pic -frame-pointer=all < %s | FileCheck -check-prefix=ARM64 %s +; RUN: llc -emulated-tls -mtriple=aarch64-linux-ohos \ +; RUN: -relocation-model=pic -frame-pointer=all < %s | FileCheck -check-prefix=ARM64 %s +; RUN: llc -mtriple=aarch64-linux-ohos \ +; RUN: -relocation-model=pic -frame-pointer=all < %s | FileCheck -check-prefix=ARM64 %s ; Copied from X86/emutls.ll diff --git a/llvm/test/CodeGen/AArch64/emutls_generic.ll b/llvm/test/CodeGen/AArch64/emutls_generic.ll index 840833972881..6b5819a7fc4e 100644 --- a/llvm/test/CodeGen/AArch64/emutls_generic.ll +++ b/llvm/test/CodeGen/AArch64/emutls_generic.ll @@ -8,6 +8,12 @@ ; RUN: | FileCheck -check-prefix=ARM_64 %s ; RUN: llc < %s -emulated-tls -mtriple=aarch64-apple-darwin -O3 \ ; RUN: | FileCheck -check-prefix=DARWIN %s +; RUN: llc < %s -emulated-tls -mtriple=aarch64-linux-ohos -relocation-model=pic \ +; RUN: | FileCheck -check-prefix=ARM_64 %s +; RUN: llc < %s -emulated-tls -mtriple=aarch64-linux-ohos -relocation-model=pic -O3 \ +; RUN: | FileCheck -check-prefix=ARM_64 %s +; RUN: llc < %s -emulated-tls -mtriple=aarch64-linux-ohos -O3 \ +; RUN: | FileCheck -check-prefix=ARM_64 %s ; RUN: llc < %s -mtriple=aarch64-linux-android -relocation-model=pic \ ; RUN: | FileCheck -check-prefix=ARM_64 %s @@ -18,6 +24,12 @@ ; aarch64-windows-gnu needs explicit -emulated-tls ; RUN: llc < %s -mtriple=aarch64-apple-darwin -O3 \ ; RUN: | FileCheck -check-prefix=NoEMU %s +; RUN: llc < %s -mtriple=aarch64-linux-ohos -relocation-model=pic \ +; RUN: | FileCheck -check-prefix=ARM_64 %s +; RUN: llc < %s -mtriple=aarch64-linux-ohos -relocation-model=pic -O3 \ +; RUN: | FileCheck -check-prefix=ARM_64 %s +; RUN: llc < %s -mtriple=aarch64-linux-ohos -O3 \ +; RUN: | FileCheck -check-prefix=ARM_64 %s ; NoEMU-NOT: __emutls diff --git a/llvm/test/CodeGen/ARM/emutls.ll b/llvm/test/CodeGen/ARM/emutls.ll index 92b656d9ba09..29894a9efa7b 100644 --- a/llvm/test/CodeGen/ARM/emutls.ll +++ b/llvm/test/CodeGen/ARM/emutls.ll @@ -2,6 +2,10 @@ ; RUN: -relocation-model=pic < %s | FileCheck -check-prefix=ARM32 %s ; RUN: llc -mtriple=arm-linux-android \ ; RUN: -relocation-model=pic < %s | FileCheck -check-prefix=ARM32 %s +; RUN: llc -emulated-tls -mtriple=arm-linux-ohos \ +; RUN: -relocation-model=pic < %s | FileCheck -check-prefix=ARM32 %s +; RUN: llc -mtriple=arm-linux-ohos \ +; RUN: -relocation-model=pic < %s | FileCheck -check-prefix=ARM32 %s ; Copied from X86/emutls.ll diff --git a/llvm/test/CodeGen/ARM/emutls_generic.ll b/llvm/test/CodeGen/ARM/emutls_generic.ll index 8bf0ab301244..803462740f79 100644 --- a/llvm/test/CodeGen/ARM/emutls_generic.ll +++ b/llvm/test/CodeGen/ARM/emutls_generic.ll @@ -10,6 +10,8 @@ ; RUN: | FileCheck -check-prefix=DARWIN %s ; RUN: llc < %s -emulated-tls -mtriple=thumbv7-windows-gnu -O3 \ ; RUN: | FileCheck -check-prefix=WIN %s +; RUN: llc < %s -emulated-tls -mtriple=arm-linux-ohos -relocation-model=pic \ +; RUN: | FileCheck -check-prefix=ARM_32 %s ; RUN: llc < %s -mtriple=arm-linux-android -relocation-model=pic \ ; RUN: | FileCheck -check-prefix=ARM_32 %s @@ -21,6 +23,8 @@ ; RUN: | FileCheck -check-prefix=ARM_32 %s ; arm-apple-darwin must use -emulated-tls ; windows must use -emulated-tls +; RUN: llc < %s -mtriple=arm-linux-ohos -relocation-model=pic \ +; RUN: | FileCheck -check-prefix=ARM_32 %s ; Make sure that TLS symbols are emitted in expected order. diff --git a/llvm/test/CodeGen/X86/emutls-pic.ll b/llvm/test/CodeGen/X86/emutls-pic.ll index 66f226a8bd5a..b265bb6517c3 100644 --- a/llvm/test/CodeGen/X86/emutls-pic.ll +++ b/llvm/test/CodeGen/X86/emutls-pic.ll @@ -2,11 +2,15 @@ ; RUN: llc < %s -emulated-tls -mtriple=x86_64-linux-gnu -relocation-model=pic | FileCheck -check-prefix=X64 %s ; RUN: llc < %s -emulated-tls -mtriple=i386-linux-android -relocation-model=pic | FileCheck -check-prefix=X86 %s ; RUN: llc < %s -emulated-tls -mtriple=x86_64-linux-android -relocation-model=pic | FileCheck -check-prefix=X64 %s +; RUN: llc < %s -emulated-tls -mtriple=i386-linux-ohos -relocation-model=pic | FileCheck -check-prefix=X86 %s +; RUN: llc < %s -emulated-tls -mtriple=x86_64-linux-ohos -relocation-model=pic | FileCheck -check-prefix=X64 %s ; RUN: llc < %s -mtriple=i386-linux-gnu -relocation-model=pic | FileCheck -check-prefix=NoEMU %s ; RUN: llc < %s -mtriple=x86_64-linux-gnu -relocation-model=pic | FileCheck -check-prefix=NoEMU %s ; RUN: llc < %s -mtriple=i386-linux-android -relocation-model=pic | FileCheck -check-prefix=X86 %s ; RUN: llc < %s -mtriple=x86_64-linux-android -relocation-model=pic | FileCheck -check-prefix=X64 %s +; RUN: llc < %s -mtriple=i386-linux-ohos -relocation-model=pic | FileCheck -check-prefix=X86 %s +; RUN: llc < %s -mtriple=x86_64-linux-ohos -relocation-model=pic | FileCheck -check-prefix=X64 %s ; NoEMU-NOT: __emutls diff --git a/llvm/test/CodeGen/X86/emutls-pie.ll b/llvm/test/CodeGen/X86/emutls-pie.ll index 38f0c245bee6..40945a37ab57 100644 --- a/llvm/test/CodeGen/X86/emutls-pie.ll +++ b/llvm/test/CodeGen/X86/emutls-pie.ll @@ -6,6 +6,10 @@ ; RUN: | FileCheck -check-prefix=X86 %s ; RUN: llc < %s -emulated-tls -mcpu=generic -mtriple=x86_64-linux-android -relocation-model=pic \ ; RUN: | FileCheck -check-prefix=X64 %s +; RUN: llc < %s -emulated-tls -mcpu=generic -mtriple=i386-linux-ohos -relocation-model=pic \ +; RUN: | FileCheck -check-prefix=X86 %s +; RUN: llc < %s -emulated-tls -mcpu=generic -mtriple=x86_64-linux-ohos -relocation-model=pic \ +; RUN: | FileCheck -check-prefix=X64 %s ; RUN: llc < %s -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic \ ; RUN: | FileCheck -check-prefix=NoEMU %s @@ -15,6 +19,10 @@ ; RUN: | FileCheck -check-prefix=X86 %s ; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-android -relocation-model=pic \ ; RUN: | FileCheck -check-prefix=X64 %s +; RUN: llc < %s -mcpu=generic -mtriple=i386-linux-ohos -relocation-model=pic \ +; RUN: | FileCheck -check-prefix=X86 %s +; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-ohos -relocation-model=pic \ +; RUN: | FileCheck -check-prefix=X64 %s ; NoEMU-NOT: __emutls diff --git a/llvm/test/CodeGen/X86/emutls.ll b/llvm/test/CodeGen/X86/emutls.ll index 7e567d287c61..7105f595221e 100644 --- a/llvm/test/CodeGen/X86/emutls.ll +++ b/llvm/test/CodeGen/X86/emutls.ll @@ -2,11 +2,15 @@ ; RUN: llc < %s -emulated-tls -mtriple=x86_64-linux-gnu | FileCheck -check-prefix=X64 %s ; RUN: llc < %s -emulated-tls -mtriple=i386-linux-android | FileCheck -check-prefix=X86 %s ; RUN: llc < %s -emulated-tls -mtriple=x86_64-linux-android | FileCheck -check-prefix=X64 %s +; RUN: llc < %s -emulated-tls -mtriple=i386-linux-ohos | FileCheck -check-prefix=X86 %s +; RUN: llc < %s -emulated-tls -mtriple=x86_64-linux-ohos | FileCheck -check-prefix=X64 %s ; RUN: llc < %s -mtriple=i386-linux-gnu | FileCheck -check-prefix=NoEMU %s ; RUN: llc < %s -mtriple=x86_64-linux-gnu | FileCheck -check-prefix=NoEMU %s ; RUN: llc < %s -mtriple=i386-linux-android | FileCheck -check-prefix=X86 %s ; RUN: llc < %s -mtriple=x86_64-linux-android | FileCheck -check-prefix=X64 %s +; RUN: llc < %s -mtriple=i386-linux-ohos | FileCheck -check-prefix=X86 %s +; RUN: llc < %s -mtriple=x86_64-linux-ohos | FileCheck -check-prefix=X64 %s ; Copied from tls.ll; emulated TLS model is not implemented ; for *-pc-win32 and *-pc-windows targets yet. diff --git a/llvm/test/CodeGen/X86/emutls_generic.ll b/llvm/test/CodeGen/X86/emutls_generic.ll index 7fc6089b9077..9e61bc5924cf 100644 --- a/llvm/test/CodeGen/X86/emutls_generic.ll +++ b/llvm/test/CodeGen/X86/emutls_generic.ll @@ -6,6 +6,12 @@ ; RUN: | FileCheck -check-prefix=X86_64 %s ; RUN: llc < %s -emulated-tls -mtriple=i386-linux-gnu -relocation-model=pic \ ; RUN: | FileCheck %s +; RUN: llc < %s -emulated-tls -mtriple=i686-linux-ohos -relocation-model=pic \ +; RUN: | FileCheck -check-prefix=X86_32 %s +; RUN: llc < %s -emulated-tls -mtriple=i686-linux-ohos -relocation-model=pic \ +; RUN: | FileCheck -check-prefix=X86_32 %s +; RUN: llc < %s -emulated-tls -mtriple=x86_64-linux-ohos -relocation-model=pic \ +; RUN: | FileCheck -check-prefix=X86_64 %s ; RUN: llc < %s -mtriple=i686-linux-android -relocation-model=pic \ ; RUN: | FileCheck -check-prefix=X86_32 %s @@ -15,6 +21,12 @@ ; RUN: | FileCheck -check-prefix=X86_64 %s ; RUN: llc < %s -mtriple=i386-linux-gnu -relocation-model=pic \ ; RUN: | FileCheck -check-prefix=NoEMU %s +; RUN: llc < %s -mtriple=i686-linux-ohos -relocation-model=pic \ +; RUN: | FileCheck -check-prefix=X86_32 %s +; RUN: llc < %s -mtriple=i686-linux-ohos -relocation-model=pic \ +; RUN: | FileCheck -check-prefix=X86_32 %s +; RUN: llc < %s -mtriple=x86_64-linux-ohos -relocation-model=pic \ +; RUN: | FileCheck -check-prefix=X86_64 %s ; NoEMU-NOT: __emutls -- Gitee