Skip to content

Commit b71f2fc

Browse files
committed
[Android] Use ELF TLS for Android API level 29+
Use ELF TLS by default instead of emulated TLS for Android build targets when the API level is >= 29. Android Q features full TLS support. See release notes (https://developer.android.com/preview/features#elf-tls) and implementation details (https://android.googlesource.com/platform/bionic/+/master/docs/elf-tls.md#Workaround_Use-Variant-2-on-arm32_arm64). Reviewed By: rprichard, danalbert Differential Revision: https://reviews.llvm.org/D147849
1 parent 914d082 commit b71f2fc

File tree

6 files changed

+13
-2
lines changed

6 files changed

+13
-2
lines changed

llvm/include/llvm/TargetParser/Triple.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -979,9 +979,11 @@ class Triple {
979979
}
980980

981981
/// Tests whether the target uses emulated TLS as default.
982+
///
983+
/// Note: Android API level 29 (10) introduced ELF TLS.
982984
bool hasDefaultEmulatedTLS() const {
983-
return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment() ||
984-
isOHOSFamily();
985+
return (isAndroid() && isAndroidVersionLT(29)) || isOSOpenBSD() ||
986+
isWindowsCygwinEnvironment() || isOHOSFamily();
985987
}
986988

987989
/// Tests whether the target uses -data-sections as default.

llvm/test/CodeGen/AArch64/emutls_generic.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
; aarch64-windows-gnu needs explicit -emulated-tls
1919
; RUN: llc < %s -mtriple=aarch64-apple-darwin -O3 \
2020
; RUN: | FileCheck -check-prefix=NoEMU %s
21+
; RUN: llc < %s -mtriple=aarch64-linux-android29 -O3 \
22+
; RUN: | FileCheck -check-prefix=NoEMU %s
2123

2224
; NoEMU-NOT: __emutls
2325

llvm/test/CodeGen/X86/emutls-pic.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
; RUN: llc < %s -mtriple=i386-linux-gnu -relocation-model=pic | FileCheck -check-prefix=NoEMU %s
77
; RUN: llc < %s -mtriple=x86_64-linux-gnu -relocation-model=pic | FileCheck -check-prefix=NoEMU %s
8+
; RUN: llc < %s -mtriple=x86_64-linux-android29 -relocation-model=pic | FileCheck -check-prefix=NoEMU %s
89
; RUN: llc < %s -mtriple=i386-linux-android -relocation-model=pic | FileCheck -check-prefix=X86 %s
910
; RUN: llc < %s -mtriple=x86_64-linux-android -relocation-model=pic | FileCheck -check-prefix=X64 %s
1011
; RUN: llc < %s -mtriple=i386-linux-ohos -relocation-model=pic | FileCheck -check-prefix=X86 %s

llvm/test/CodeGen/X86/emutls-pie.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
; RUN: | FileCheck -check-prefix=NoEMU %s
1212
; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic \
1313
; RUN: | FileCheck -check-prefix=NoEMU %s
14+
; RUN: llc < %s -mcpu=generic -mtriple=i386-linux-android29 -relocation-model=pic \
15+
; RUN: | FileCheck -check-prefix=NoEMU %s
1416
; RUN: llc < %s -mcpu=generic -mtriple=i386-linux-android -relocation-model=pic \
1517
; RUN: | FileCheck -check-prefix=X86 %s
1618
; RUN: llc < %s -mcpu=generic -mtriple=x86_64-linux-android -relocation-model=pic \

llvm/test/CodeGen/X86/emutls_generic.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
; RUN: | FileCheck -check-prefix=X86_64 %s
1616
; RUN: llc < %s -mtriple=i386-linux-gnu -relocation-model=pic \
1717
; RUN: | FileCheck -check-prefix=NoEMU %s
18+
; RUN: llc < %s -mtriple=i686-linux-android29 -relocation-model=pic \
19+
; RUN: | FileCheck -check-prefix=NoEMU %s
1820

1921
; NoEMU-NOT: __emutls
2022

llvm/test/CodeGen/X86/fast-isel-emutls.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
; RUN: llc < %s -emulated-tls -relocation-model=pic -mtriple=i686-unknown-linux-gnu -fast-isel | FileCheck %s
22
; RUN: llc < %s -relocation-model=pic -mtriple=i686-unknown-linux-gnu -fast-isel \
33
; RUN: | FileCheck -check-prefix=NoEMU %s
4+
; RUN: llc < %s -relocation-model=pic -mtriple=i686-linux-android29 -fast-isel \
5+
; RUN: | FileCheck -check-prefix=NoEMU %s
46
; PR3654
57

68
; NoEMU-NOT: __emutls

0 commit comments

Comments
 (0)