Skip to content

Commit 402eca2

Browse files
authored
Enable frame pointer for non-leaf functions on Android (llvm#97614)
On Android, we always want frame pointers to make debugging in the field easier. Since frame pointers are already enabled for AArch64, ARM and RISCV64, effectively this change further enables frame pointers for X86 and X86_64.
1 parent 04fc471 commit 402eca2

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,8 @@ static bool useFramePointerForTargetByDefault(const llvm::opt::ArgList &Args,
7878
!Args.hasArg(clang::driver::options::OPT_mfentry))
7979
return true;
8080

81-
if (Triple.isAndroid()) {
82-
switch (Triple.getArch()) {
83-
case llvm::Triple::aarch64:
84-
case llvm::Triple::arm:
85-
case llvm::Triple::armeb:
86-
case llvm::Triple::thumb:
87-
case llvm::Triple::thumbeb:
88-
case llvm::Triple::riscv64:
89-
return true;
90-
default:
91-
break;
92-
}
93-
}
81+
if (Triple.isAndroid())
82+
return true;
9483

9584
switch (Triple.getArch()) {
9685
case llvm::Triple::xcore:
@@ -166,7 +155,7 @@ static bool useFramePointerForTargetByDefault(const llvm::opt::ArgList &Args,
166155

167156
static bool useLeafFramePointerForTargetByDefault(const llvm::Triple &Triple) {
168157
if (Triple.isAArch64() || Triple.isPS() || Triple.isVE() ||
169-
(Triple.isAndroid() && Triple.isRISCV64()))
158+
(Triple.isAndroid() && !Triple.isARM()))
170159
return false;
171160

172161
return true;

clang/test/Driver/frame-pointer.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
// RUN: %clang --target=i386-pc-linux -### -S -O3 %s 2>&1 | FileCheck -check-prefix=CHECK3-32 %s
55
// RUN: %clang --target=i386-pc-linux -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECKs-32 %s
66

7+
// RUN: %clang --target=i386-linux-android -### -S -O0 %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID %s
8+
// RUN: %clang --target=i386-linux-android -### -S -O1 %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID %s
9+
// RUN: %clang --target=i386-linux-android -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID %s
710

811
// RUN: %clang --target=x86_64-pc-linux -### -S -O0 %s 2>&1 | FileCheck -check-prefix=CHECK0-64 %s
912
// RUN: %clang --target=x86_64-pc-linux -### -S -O1 %s 2>&1 | FileCheck -check-prefix=CHECK1-64 %s
@@ -12,6 +15,10 @@
1215
// RUN: %clang --target=x86_64-pc-linux -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECKs-64 %s
1316
// RUN: %clang --target=x86_64-pc-win32-macho -### -S -O3 %s 2>&1 | FileCheck -check-prefix=CHECK-MACHO-64 %s
1417

18+
// RUN: %clang --target=x86_64-linux-android -### -S -O0 %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID %s
19+
// RUN: %clang --target=x86_64-linux-android -### -S -O1 %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID %s
20+
// RUN: %clang --target=x86_64-linux-android -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID %s
21+
1522
// Trust the above to get the optimizations right, and just test other targets
1623
// that want this by default.
1724
// RUN: %clang --target=s390x-pc-linux -### -S -O0 %s 2>&1 | FileCheck -check-prefix=CHECK0-64 %s
@@ -57,9 +64,9 @@
5764
// RUN: %clang --target=riscv64-unknown-linux-gnu -### -S -O3 %s 2>&1 | FileCheck -check-prefix=CHECK3-64 %s
5865
// RUN: %clang --target=riscv64-unknown-linux-gnu -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECKs-64 %s
5966

60-
// RUN: %clang --target=riscv64-linux-android -### -S -O0 %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID-64 %s
61-
// RUN: %clang --target=riscv64-linux-android -### -S -O1 %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID-64 %s
62-
// RUN: %clang --target=riscv64-linux-android -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID-64 %s
67+
// RUN: %clang --target=riscv64-linux-android -### -S -O0 %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID %s
68+
// RUN: %clang --target=riscv64-linux-android -### -S -O1 %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID %s
69+
// RUN: %clang --target=riscv64-linux-android -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID %s
6370

6471
// RUN: %clang --target=loongarch32 -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s
6572
// RUN: %clang --target=loongarch32 -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s
@@ -86,4 +93,4 @@
8693
// CHECKs-64-NOT: -mframe-pointer=all
8794
// CHECK-MACHO-64: -mframe-pointer=all
8895

89-
// CHECK-ANDROID-64: -mframe-pointer=non-leaf
96+
// CHECK-ANDROID: -mframe-pointer=non-leaf

0 commit comments

Comments
 (0)