[clang] [llvm] [Android] Drop workarounds for older Android API levels (PR #161893)
Brad Smith via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 3 11:33:50 PDT 2025
https://github.com/brad0 created https://github.com/llvm/llvm-project/pull/161893
Drop workarounds for Android API levels pre 9, 17, 21 and 23.
>From dac18ff9306ce4be3ebd466b4330abfe5d425ad5 Mon Sep 17 00:00:00 2001
From: Brad Smith <brad at comstyle.com>
Date: Fri, 3 Oct 2025 13:42:48 -0400
Subject: [PATCH] [Android] Drop workarounds for older Android API levels
Drop workarounds for Android API levels pre 9, 17, 21 and 23.
---
clang/lib/Driver/ToolChains/Clang.cpp | 1 -
clang/lib/Driver/ToolChains/Linux.cpp | 4 +--
clang/test/Driver/aarch64-features.c | 6 +----
clang/test/Driver/aarch64-fmv.c | 12 ++-------
clang/test/Driver/linux-ld.c | 11 ++------
llvm/include/llvm/IR/RuntimeLibcalls.h | 2 +-
llvm/lib/Target/X86/X86ISelLoweringCall.cpp | 2 +-
.../Instrumentation/AddressSanitizer.cpp | 4 +--
llvm/test/CodeGen/ARM/sincos.ll | 27 +------------------
.../CodeGen/X86/stack-protector-target.ll | 12 +--------
.../AddressSanitizer/with-ifunc.ll | 7 +----
11 files changed, 12 insertions(+), 76 deletions(-)
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 412a176006bc0..9e2e7d7be4f75 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7870,7 +7870,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (Triple.isAArch64() &&
(Args.hasArg(options::OPT_mno_fmv) ||
- (Triple.isAndroid() && Triple.isAndroidVersionLT(23)) ||
getToolChain().GetRuntimeLibType(Args) != ToolChain::RLT_CompilerRT)) {
// Disable Function Multiversioning on AArch64 target.
CmdArgs.push_back("-target-feature");
diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp
index 16e35b08cfbd6..dde6f8203cacc 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -300,12 +300,10 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
// and the MIPS ABI require .dynsym to be sorted in different ways.
// .gnu.hash needs symbols to be grouped by hash code whereas the MIPS
// ABI requires a mapping between the GOT and the symbol table.
- // Android loader does not support .gnu.hash until API 23.
// Hexagon linker/loader does not support .gnu.hash
if (!IsMips && !IsHexagon) {
if (Distro.IsOpenSUSE() || Distro == Distro::UbuntuLucid ||
- Distro == Distro::UbuntuJaunty || Distro == Distro::UbuntuKarmic ||
- (IsAndroid && Triple.isAndroidVersionLT(23)))
+ Distro == Distro::UbuntuJaunty || Distro == Distro::UbuntuKarmic)
ExtraOpts.push_back("--hash-style=both");
else
ExtraOpts.push_back("--hash-style=gnu");
diff --git a/clang/test/Driver/aarch64-features.c b/clang/test/Driver/aarch64-features.c
index faef3878c0ab0..d2dc5a20119ee 100644
--- a/clang/test/Driver/aarch64-features.c
+++ b/clang/test/Driver/aarch64-features.c
@@ -8,14 +8,10 @@
// CHECK: fno-signed-char
// Check Function Multi Versioning option and rtlib dependency.
-// RUN: %clang --target=aarch64-linux-android23 -rtlib=compiler-rt \
-// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-FMV %s
// RUN: %clang --target=aarch64-linux-android -rtlib=compiler-rt \
-// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-FMV-OFF %s
+// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-FMV %s
// RUN: %clang --target=aarch64-linux-android -rtlib=compiler-rt -mno-fmv \
// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-FMV-OFF %s
-// RUN: %clang --target=aarch64-linux-android22 -rtlib=compiler-rt \
-// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-FMV-OFF %s
// RUN: %clang --target=aarch64-linux-gnu -rtlib=libgcc \
// RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-FMV-OFF %s
diff --git a/clang/test/Driver/aarch64-fmv.c b/clang/test/Driver/aarch64-fmv.c
index e7d01d1d5906a..84fb55c67a315 100644
--- a/clang/test/Driver/aarch64-fmv.c
+++ b/clang/test/Driver/aarch64-fmv.c
@@ -1,24 +1,16 @@
// Test which driver flags enable/disable Function Multiversioning on aarch64.
-// FMV is enabled for non-android aarch64 targets:
+// FMV is enabled with compiler-rt:
// RUN: %clang --target=aarch64 --rtlib=compiler-rt -### -c %s 2>&1 | FileCheck -check-prefix=FMV-ENABLED %s
// RUN: %clang --target=aarch64-linux-gnu --rtlib=compiler-rt -### -c %s 2>&1 | FileCheck -check-prefix=FMV-ENABLED %s
+// RUN: %clang --target=aarch64-linux-android --rtlib=compiler-rt -### -c %s 2>&1 | FileCheck -check-prefix=FMV-ENABLED %s
// RUN: %clang --target=arm64-apple-ios --rtlib=compiler-rt -### -c %s 2>&1 | FileCheck -check-prefix=FMV-ENABLED %s
// RUN: %clang --target=arm64-apple-macosx --rtlib=compiler-rt -### -c %s 2>&1 | FileCheck -check-prefix=FMV-ENABLED %s
-// android23 defaults to --rtlib=compiler-rt:
-// RUN: %clang --target=aarch64-linux-android23 -### -c %s 2>&1 | FileCheck -check-prefix=FMV-ENABLED %s
-// RUN: %clang --target=aarch64-linux-android23 --rtlib=compiler-rt -### -c %s 2>&1 | FileCheck -check-prefix=FMV-ENABLED %s
-
// FMV is disabled without compiler-rt:
// RUN: %clang --rtlib=libgcc --target=aarch64 -### -c %s 2>&1 | FileCheck -check-prefix=FMV-DISABLED %s
// RUN: %clang --rtlib=libgcc --target=aarch64-linux-gnu -### -c %s 2>&1 | FileCheck -check-prefix=FMV-DISABLED %s
-// Disabled for older android versions:
-// RUN: %clang --rtlib=compiler-rt --target=aarch64-linux-android -### -c %s 2>&1 | FileCheck -check-prefix=FMV-DISABLED %s
-// RUN: %clang --rtlib=compiler-rt --target=aarch64-linux-android22 -### -c %s 2>&1 | FileCheck -check-prefix=FMV-DISABLED %s
-// RUN: %clang --rtlib=compiler-rt --target=aarch64-linux-android22 -mno-fmv -### -c %s 2>&1 | FileCheck -check-prefix=FMV-DISABLED %s
-
// Disabled explicitly:
// RUN: %clang --rtlib=compiler-rt --target=aarch64 -mno-fmv -### -c %s 2>&1 | FileCheck -check-prefix=FMV-DISABLED %s
// RUN: %clang --rtlib=compiler-rt --target=aarch64-linux-android23 -mno-fmv -### -c %s 2>&1 | FileCheck -check-prefix=FMV-DISABLED %s
diff --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c
index be3293cdc253e..06566f9fab18f 100644
--- a/clang/test/Driver/linux-ld.c
+++ b/clang/test/Driver/linux-ld.c
@@ -926,16 +926,9 @@
// CHECK-MIPS64EL-REDHAT-NOT: "-dynamic-linker" "{{.*}}/lib{{(64)?}}/ld-musl-mipsel.so.1"
// CHECK-MIPS64EL-REDHAT-NOT: "--hash-style={{gnu|both}}"
-// Check that we pass --hash-style=both for pre-M Android versions and
-// --hash-style=gnu for newer Android versions.
+// Check that we pass for Android.
// RUN: %clang -### %s -no-pie 2>&1 \
-// RUN: --target=armv7-linux-android21 \
-// RUN: | FileCheck --check-prefix=CHECK-ANDROID-HASH-STYLE-L %s
-// CHECK-ANDROID-HASH-STYLE-L: "{{.*}}ld{{(.exe)?}}"
-// CHECK-ANDROID-HASH-STYLE-L: "--hash-style=both"
-//
-// RUN: %clang -### %s -no-pie 2>&1 \
-// RUN: --target=armv7-linux-android23 \
+// RUN: --target=armv7-linux-android \
// RUN: | FileCheck --check-prefix=CHECK-ANDROID-HASH-STYLE-M %s
// CHECK-ANDROID-HASH-STYLE-M: "{{.*}}ld{{(.exe)?}}"
// CHECK-ANDROID-HASH-STYLE-M: "--hash-style=gnu"
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h
index 93183bc6b4aa9..7563eb0b6dbdc 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.h
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.h
@@ -226,7 +226,7 @@ struct RuntimeLibcallsInfo {
/// Return true if the target has sincosf/sincos/sincosl functions
static bool hasSinCos(const Triple &TT) {
return TT.isGNUEnvironment() || TT.isOSFuchsia() ||
- (TT.isAndroid() && !TT.isAndroidVersionLT(9));
+ TT.isAndroid();
}
static bool hasSinCos_f32_f64(const Triple &TT) {
diff --git a/llvm/lib/Target/X86/X86ISelLoweringCall.cpp b/llvm/lib/Target/X86/X86ISelLoweringCall.cpp
index 3bc46af4d130b..6dd43b277e679 100644
--- a/llvm/lib/Target/X86/X86ISelLoweringCall.cpp
+++ b/llvm/lib/Target/X86/X86ISelLoweringCall.cpp
@@ -547,7 +547,7 @@ unsigned X86TargetLowering::getAddressSpace() const {
static bool hasStackGuardSlotTLS(const Triple &TargetTriple) {
return TargetTriple.isOSGlibc() || TargetTriple.isOSFuchsia() ||
- (TargetTriple.isAndroid() && !TargetTriple.isAndroidVersionLT(17));
+ TargetTriple.isAndroid();
}
static Constant* SegmentOffset(IRBuilderBase &IRB,
diff --git a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
index cdae9a7271915..2fc085c53c6d6 100644
--- a/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ b/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -600,9 +600,7 @@ static ShadowMapping getShadowMapping(const Triple &TargetTriple, int LongSize,
!IsRISCV64 && !IsLoongArch64 &&
!(Mapping.Offset & (Mapping.Offset - 1)) &&
Mapping.Offset != kDynamicShadowSentinel;
- bool IsAndroidWithIfuncSupport =
- IsAndroid && !TargetTriple.isAndroidVersionLT(21);
- Mapping.InGlobal = ClWithIfunc && IsAndroidWithIfuncSupport && IsArmOrThumb;
+ Mapping.InGlobal = ClWithIfunc && IsAndroid && IsArmOrThumb;
return Mapping;
}
diff --git a/llvm/test/CodeGen/ARM/sincos.ll b/llvm/test/CodeGen/ARM/sincos.ll
index e1b683a8a6657..1a4313e651d72 100644
--- a/llvm/test/CodeGen/ARM/sincos.ll
+++ b/llvm/test/CodeGen/ARM/sincos.ll
@@ -2,8 +2,7 @@
; RUN: llc < %s -mtriple=armv7-apple-ios7 -mcpu=cortex-a8 | FileCheck %s --check-prefix=SINCOS
; RUN: llc < %s -mtriple=armv7-linux-gnu -mcpu=cortex-a8 | FileCheck %s --check-prefix=SINCOS-GNU
; RUN: llc < %s -mtriple=armv7-linux-gnueabi -mcpu=cortex-a8 | FileCheck %s --check-prefix=SINCOS-GNU
-; RUN: llc < %s -mtriple=armv7-linux-android -mcpu=cortex-a8 | FileCheck %s --check-prefix=NOOPT-ANDROID
-; RUN: llc < %s -mtriple=armv7-linux-android9 -mcpu=cortex-a8 | FileCheck %s --check-prefix=SINCOS-GNU
+; RUN: llc < %s -mtriple=armv7-linux-android -mcpu=cortex-a8 | FileCheck %s --check-prefix=SINCOS-GNU
; Combine sin / cos into a single call unless they may write errno (as
; captured by readnone attrbiute, controlled by clang -fmath-errno
@@ -22,10 +21,6 @@ entry:
; NOOPT: bl _sinf
; NOOPT: bl _cosf
-; NOOPT-ANDROID-LABEL: test1:
-; NOOPT-ANDROID: bl sinf
-; NOOPT-ANDROID: bl cosf
-
%call = tail call float @sinf(float %x) readnone
%call1 = tail call float @cosf(float %x) readnone
%add = fadd float %call, %call1
@@ -44,10 +39,6 @@ entry:
; NOOPT: bl _sinf
; NOOPT: bl _cosf
-; NOOPT-ANDROID-LABEL: test1_fast:
-; NOOPT-ANDROID: bl sinf
-; NOOPT-ANDROID: bl cosf
-
%call = tail call fast float @sinf(float %x) readnone
%call1 = tail call fast float @cosf(float %x) readnone
%add = fadd float %call, %call1
@@ -68,10 +59,6 @@ entry:
; NOOPT: bl _sinf
; NOOPT: bl _cosf
-; NOOPT-ANDROID-LABEL: test1_errno:
-; NOOPT-ANDROID: bl sinf
-; NOOPT-ANDROID: bl cosf
-
%call = tail call float @sinf(float %x)
%call1 = tail call float @cosf(float %x)
%add = fadd float %call, %call1
@@ -90,10 +77,6 @@ entry:
; NOOPT: bl _sin
; NOOPT: bl _cos
-; NOOPT-ANDROID-LABEL: test2:
-; NOOPT-ANDROID: bl sin
-; NOOPT-ANDROID: bl cos
-
%call = tail call double @sin(double %x) readnone
%call1 = tail call double @cos(double %x) readnone
%add = fadd double %call, %call1
@@ -112,10 +95,6 @@ entry:
; NOOPT: bl _sin
; NOOPT: bl _cos
-; NOOPT-ANDROID-LABEL: test2_fast:
-; NOOPT-ANDROID: bl sin
-; NOOPT-ANDROID: bl cos
-
%call = tail call fast double @sin(double %x) readnone
%call1 = tail call fast double @cos(double %x) readnone
%add = fadd double %call, %call1
@@ -136,10 +115,6 @@ entry:
; NOOPT: bl _sin
; NOOPT: bl _cos
-; NOOPT-ANDROID-LABEL: test2_errno:
-; NOOPT-ANDROID: bl sin
-; NOOPT-ANDROID: bl cos
-
%call = tail call double @sin(double %x)
%call1 = tail call double @cos(double %x)
%add = fadd double %call, %call1
diff --git a/llvm/test/CodeGen/X86/stack-protector-target.ll b/llvm/test/CodeGen/X86/stack-protector-target.ll
index f7c5680d0d811..4ba0302cf6fc3 100644
--- a/llvm/test/CodeGen/X86/stack-protector-target.ll
+++ b/llvm/test/CodeGen/X86/stack-protector-target.ll
@@ -2,13 +2,8 @@
; RUN: llc -mtriple=i386-linux < %s -o - | FileCheck --check-prefix=I386-TLS %s
; RUN: llc -mtriple=x86_64-linux < %s -o - | FileCheck --check-prefix=X64-TLS %s
-; RUN: llc -mtriple=i386-linux-android < %s -o - | FileCheck --check-prefix=I386 %s
-; RUN: llc -mtriple=i386-linux-android16 < %s -o - | FileCheck --check-prefix=I386 %s
-; RUN: llc -mtriple=i386-linux-android17 < %s -o - | FileCheck --check-prefix=I386-TLS %s
-; RUN: llc -mtriple=i386-linux-android24 < %s -o - | FileCheck --check-prefix=I386-TLS %s
+; RUN: llc -mtriple=i386-linux-android < %s -o - | FileCheck --check-prefix=I386-TLS %s
; RUN: llc -mtriple=x86_64-linux-android < %s -o - | FileCheck --check-prefix=X64-TLS %s
-; RUN: llc -mtriple=x86_64-linux-android17 < %s -o - | FileCheck --check-prefix=X64-TLS %s
-; RUN: llc -mtriple=x86_64-linux-android24 < %s -o - | FileCheck --check-prefix=X64-TLS %s
; RUN: llc -mtriple=i386-kfreebsd < %s -o - | FileCheck --check-prefix=I386-TLS %s
; RUN: llc -mtriple=x86_64-kfreebsd < %s -o - | FileCheck --check-prefix=X64-TLS %s
@@ -27,11 +22,6 @@ declare void @_Z7CapturePi(ptr)
; X64-TLS: movq %fs:40, %[[C:.*]]
; X64-TLS: cmpq 16(%rsp), %[[C]]
-; I386: movl __stack_chk_guard, %[[B:.*]]
-; I386: movl %[[B]], 8(%esp)
-; I386: movl __stack_chk_guard, %[[C:.*]]
-; I386: cmpl 8(%esp), %[[C]]
-
; I386-TLS: movl %gs:20, %[[B:.*]]
; I386-TLS: movl %[[B]], 8(%esp)
; I386-TLS: movl %gs:20, %[[C:.*]]
diff --git a/llvm/test/Instrumentation/AddressSanitizer/with-ifunc.ll b/llvm/test/Instrumentation/AddressSanitizer/with-ifunc.ll
index f198fc01d2639..8a8f9b359eb90 100644
--- a/llvm/test/Instrumentation/AddressSanitizer/with-ifunc.ll
+++ b/llvm/test/Instrumentation/AddressSanitizer/with-ifunc.ll
@@ -4,13 +4,8 @@
; RUN: opt -passes=asan -S -asan-with-ifunc=1 -asan-with-ifunc-suppress-remat=0 < %s | FileCheck %s --check-prefixes=CHECK,CHECK-IFUNC
; RUN: opt -passes=asan -S -asan-with-ifunc=1 -asan-with-ifunc-suppress-remat=1 < %s | FileCheck %s --check-prefixes=CHECK,CHECK-IFUNC-NOREMAT
-; Pre-Lollipop Android does not support ifunc.
-; RUN: opt -passes=asan -S -asan-with-ifunc=1 -asan-with-ifunc-suppress-remat=0 -mtriple=armv7-linux-android20 < %s | FileCheck %s --check-prefixes=CHECK,CHECK-NOIFUNC
-; RUN: opt -passes=asan -S -asan-with-ifunc=1 -asan-with-ifunc-suppress-remat=0 -mtriple=armv7-linux-android < %s | FileCheck %s --check-prefixes=CHECK,CHECK-NOIFUNC
-; RUN: opt -passes=asan -S -asan-with-ifunc=1 -asan-with-ifunc-suppress-remat=0 -mtriple=armv7-linux-android21 < %s | FileCheck %s --check-prefixes=CHECK,CHECK-IFUNC
-
target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
-target triple = "armv7--linux-android22"
+target triple = "armv7--linux-android"
; CHECK-IFUNC: @__asan_shadow = external global [0 x i8]
; CHECK-NOIFUNC: @__asan_shadow_memory_dynamic_address = external global i32
More information about the llvm-commits
mailing list