Skip to content

Conversation

brad0
Copy link
Contributor

@brad0 brad0 commented Oct 3, 2025

Drop workarounds for Android API levels pre 9, 17, 21.

The minimum Android API currently supported by the LTS NDK is 21.

@llvmbot
Copy link
Member

llvmbot commented Oct 3, 2025

@llvm/pr-subscribers-llvm-analysis
@llvm/pr-subscribers-compiler-rt-sanitizer
@llvm/pr-subscribers-backend-x86
@llvm/pr-subscribers-llvm-transforms
@llvm/pr-subscribers-backend-arm

@llvm/pr-subscribers-llvm-ir

Author: Brad Smith (brad0)

Changes

Drop workarounds for Android API levels pre 9 and 17.


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

5 Files Affected:

  • (modified) llvm/include/llvm/IR/RuntimeLibcalls.h (+1-2)
  • (modified) llvm/lib/Target/X86/X86ISelLoweringCall.cpp (+1-1)
  • (modified) llvm/test/CodeGen/ARM/sincos.ll (+1-26)
  • (modified) llvm/test/CodeGen/X86/stack-protector-target.ll (+1-11)
  • (modified) llvm/test/Transforms/SafeStack/X86/abi_ssp.ll (+2-6)
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h
index 93183bc6b4aa92..5ef6f24c272e49 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.h
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.h
@@ -225,8 +225,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));
+    return TT.isGNUEnvironment() || TT.isOSFuchsia() || 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 3bc46af4d130b5..6dd43b277e6799 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/test/CodeGen/ARM/sincos.ll b/llvm/test/CodeGen/ARM/sincos.ll
index e1b683a8a66575..1a4313e651d727 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 f7c5680d0d8113..4ba0302cf6fc30 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/Transforms/SafeStack/X86/abi_ssp.ll b/llvm/test/Transforms/SafeStack/X86/abi_ssp.ll
index e66127533d38d6..3b6fb3aa0bfdbc 100644
--- a/llvm/test/Transforms/SafeStack/X86/abi_ssp.ll
+++ b/llvm/test/Transforms/SafeStack/X86/abi_ssp.ll
@@ -1,9 +1,7 @@
 ; RUN: opt -safe-stack -S -mtriple=i686-pc-linux-gnu < %s -o - | FileCheck --check-prefixes=COMMON,TLS32 %s
 ; RUN: opt -safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck --check-prefixes=COMMON,TLS64 %s
 
-; RUN: opt -safe-stack -S -mtriple=i686-linux-android < %s -o - | FileCheck --check-prefixes=COMMON,GLOBAL32 %s
-; RUN: opt -safe-stack -S -mtriple=i686-linux-android24 < %s -o - | FileCheck --check-prefixes=COMMON,TLS32 %s
-
+; RUN: opt -safe-stack -S -mtriple=i686-linux-android < %s -o - | FileCheck --check-prefixes=COMMON,TLS32 %s
 ; RUN: opt -safe-stack -S -mtriple=x86_64-linux-android < %s -o - | FileCheck --check-prefixes=COMMON,TLS64 %s
 
 ; RUN: opt -safe-stack -S -mtriple=x86_64-unknown-fuchsia < %s -o - | FileCheck --check-prefixes=COMMON,FUCHSIA64 %s
@@ -11,9 +9,7 @@
 ; RUN: opt -passes=safe-stack -S -mtriple=i686-pc-linux-gnu < %s -o - | FileCheck --check-prefixes=COMMON,TLS32 %s
 ; RUN: opt -passes=safe-stack -S -mtriple=x86_64-pc-linux-gnu < %s -o - | FileCheck --check-prefixes=COMMON,TLS64 %s
 
-; RUN: opt -passes=safe-stack -S -mtriple=i686-linux-android < %s -o - | FileCheck --check-prefixes=COMMON,GLOBAL32 %s
-; RUN: opt -passes=safe-stack -S -mtriple=i686-linux-android24 < %s -o - | FileCheck --check-prefixes=COMMON,TLS32 %s
-
+; RUN: opt -passes=safe-stack -S -mtriple=i686-linux-android < %s -o - | FileCheck --check-prefixes=COMMON,TLS32 %s
 ; RUN: opt -passes=safe-stack -S -mtriple=x86_64-linux-android < %s -o - | FileCheck --check-prefixes=COMMON,TLS64 %s
 
 ; RUN: opt -passes=safe-stack -S -mtriple=x86_64-unknown-fuchsia < %s -o - | FileCheck --check-prefixes=COMMON,FUCHSIA64 %s

@brad0 brad0 force-pushed the android_api_remove_9_17 branch from 587ca42 to 66c9c77 Compare October 3, 2025 21:56
@brad0 brad0 changed the title [Android] Drop workarounds for older Android API levels pre 9 and 17 [Android] Drop workarounds for older Android API levels pre 9, 17 and 21 Oct 3, 2025
@brad0 brad0 force-pushed the android_api_remove_9_17 branch 2 times, most recently from 7fd3538 to 0b66b56 Compare October 3, 2025 22:11
@pirama-arumuga-nainar
Copy link
Collaborator

@smeenai FYI.

@smeenai
Copy link
Collaborator

smeenai commented Oct 3, 2025

Thanks for flagging this! We recently moved to API 21+ for all our major apps (and I'm delighted to not have to support anything older anymore), so this should be okay on our end now :)

@brad0 brad0 force-pushed the android_api_remove_9_17 branch from 0b66b56 to c41e1cd Compare October 4, 2025 01:32
@llvmbot llvmbot added the llvm:analysis Includes value tracking, cost tables and constant folding label Oct 4, 2025
@brad0 brad0 force-pushed the android_api_remove_9_17 branch from c41e1cd to 24a9ea1 Compare October 4, 2025 02:48
@llvmbot llvmbot added the llvm:instcombine Covers the InstCombine, InstSimplify and AggressiveInstCombine passes label Oct 4, 2025
Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your PR description should not just be saying what you are doing, by why you are doing it. What policy are you following in these removals?

This one looks OK to me in that these are older than the minimum API level of the current LTS NDK, but given that you also submitted #161893 where this is decidedly not the case, it's unclear to me what the underlying process driving these changes is.

@enh-google
Copy link
Contributor

Your PR description should not just be saying what you are doing, by why you are doing it. What policy are you following in these removals?

This one looks OK to me in that these are older than the minimum API level of the current LTS NDK, but given that you also submitted #161893 where this is decidedly not the case, it's unclear to me what the underlying process driving these changes is.

that's why this got broken in two --- these changes represent the current shipping state of the NDK, whereas the other changes are where the NDK will be in a few more months.

is there a good place we can document this "track the NDK" policy? (i was surprised to see in some of the diff context here that there's still support for ubuntu's "jaunty" release from 2009, for example, but maybe there's a documented llvm ubuntu release support policy somewhere?)

@enh-google
Copy link
Contributor

and, no, sadly we don't have Android documentation [that i know of --- @DanAlbert ?] that tells you either (a) what our policy is or (b) what that policy means in practice at any given time.

there's extensive documentation of (a) internally, and you can infer (b) from the lowest __INTRODUCED_IN() in the headers in the ndk ... but there's no public doc i can think of. to be fair, it's quite complicated; it's not time-based, and it's not just usage-based because obviously some things are much more painful to support than others.

@brad0
Copy link
Contributor Author

brad0 commented Oct 8, 2025

Your PR description should not just be saying what you are doing, by why you are doing it. What policy are you following in these removals?

The Android NDK eventually drops support for Android versions. I have been garbage collecting bits for Operating Systems that are no longer supported whether it be FreeBSD/NetBSD/Android, etc.

This one looks OK to me in that these are older than the minimum API level of the current LTS NDK, but given that you also submitted #161893 where this is decidedly not the case, it's unclear to me what the underlying process driving these changes is.

The other patch was based on me being tagged in this other issue, android/ndk#2188 , originally I had everything as one patch and was going to wait but then split out the older bits that can be commited now. It'll be waiting until the NDK issue is completed in a number of months, so NDK r31.

@enh-google
Copy link
Contributor

(github n00b asks: i see you updated the first comment on the conversation tab in a way that addresses @nikic's question, but do you need to do the commit message on the patch too? i think the answer is no, because github replaces that commit message at "squash and merge" time? otherwise lgtm.)

@brad0 brad0 force-pushed the android_api_remove_9_17 branch from 24a9ea1 to 6598b58 Compare October 8, 2025 16:00
@brad0
Copy link
Contributor Author

brad0 commented Oct 8, 2025

(github n00b asks: i see you updated the first comment on the conversation tab in a way that addresses @nikic's question, but do you need to do the commit message on the patch too? i think the answer is no, because github replaces that commit message at "squash and merge" time? otherwise lgtm.)

I am not 100% sure. I updated it either way.

@brad0 brad0 requested a review from nikic October 8, 2025 16:55
Drop workarounds for Android API levels pre 9, 17 and 21.

The minimum Android API currently supported by the LTS NDK is 21.
@brad0 brad0 force-pushed the android_api_remove_9_17 branch from 6598b58 to 15102ac Compare October 8, 2025 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:ARM backend:X86 compiler-rt:sanitizer llvm:analysis Includes value tracking, cost tables and constant folding llvm:instcombine Covers the InstCombine, InstSimplify and AggressiveInstCombine passes llvm:ir llvm:transforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants