Enable frame pointer for all non-leaf functions on riscv64 Android

Bringing parity with aarch64-android https://github.com/google/android-riscv64/issues/9#issuecomment-1535454205

Reviewers: enh, danalbert, pirama, srhines

Differential Revision: https://reviews.llvm.org/D150490
This commit is contained in:
AdityaK 2023-05-15 10:17:39 -07:00
parent 2239fd50bd
commit f98698714e
3 changed files with 32 additions and 5 deletions

View File

@ -420,6 +420,20 @@ static bool useFramePointerForTargetByDefault(const ArgList &Args,
if (Args.hasArg(options::OPT_pg) && !Args.hasArg(options::OPT_mfentry))
return true;
if (Triple.isAndroid()) {
switch (Triple.getArch()) {
case llvm::Triple::aarch64:
case llvm::Triple::arm:
case llvm::Triple::armeb:
case llvm::Triple::thumb:
case llvm::Triple::thumbeb:
case llvm::Triple::riscv64:
return true;
default:
break;
}
}
switch (Triple.getArch()) {
case llvm::Triple::xcore:
case llvm::Triple::wasm32:
@ -459,9 +473,6 @@ static bool useFramePointerForTargetByDefault(const ArgList &Args,
case llvm::Triple::armeb:
case llvm::Triple::thumb:
case llvm::Triple::thumbeb:
if (Triple.isAndroid())
return true;
[[fallthrough]];
case llvm::Triple::mips64:
case llvm::Triple::mips64el:
case llvm::Triple::mips:
@ -515,7 +526,8 @@ getFramePointerKind(const ArgList &Args, const llvm::Triple &Triple) {
bool OmitLeafFP =
Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
options::OPT_mno_omit_leaf_frame_pointer,
Triple.isAArch64() || Triple.isPS() || Triple.isVE());
Triple.isAArch64() || Triple.isPS() || Triple.isVE() ||
(Triple.isAndroid() && Triple.isRISCV64()));
if (NoOmitFP || mustUseNonLeafFramePointerForTarget(Triple) ||
(!OmitFP && useFramePointerForTargetByDefault(Args, Triple))) {
if (OmitLeafFP)

View File

@ -106,6 +106,12 @@
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
// RUN: %clang -### -target ve-unknown-linux-gnu -S %s 2>&1 | \
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
// RUN: %clang -### --target=aarch64-linux-android -S %s 2>&1 | \
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
// RUN: %clang -### --target=aarch64-linux-android -S -O2 %s 2>&1 | \
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
// RUN: %clang -### --target=aarch64-linux-android -S -Os %s 2>&1 | \
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
// RUN: %clang -### -target powerpc64 -S %s 2>&1 | \
// RUN: FileCheck --check-prefix=KEEP-ALL %s
@ -153,6 +159,9 @@
// RUN: FileCheck --check-prefix=KEEP-ALL %s
// RUN: %clang -### -target armv7a-linux-androideabi- -mthumb -mbig-endian -O1 -S %s 2>&1 | \
// RUN: FileCheck --check-prefix=KEEP-ALL %s
// RUN: %clang -### --target=riscv64-linux-android -O1 -S %s 2>&1 | \
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
// RUN: %clang -### --target=riscv64-linux-android -mbig-endian -O1 -S %s 2>&1 | \
// RUN: FileCheck --check-prefix=KEEP-NON-LEAF %s
void f0() {}
void f1() { f0(); }

View File

@ -57,6 +57,10 @@
// RUN: %clang --target=riscv64-unknown-linux-gnu -### -S -O3 %s 2>&1 | FileCheck -check-prefix=CHECK3-64 %s
// RUN: %clang --target=riscv64-unknown-linux-gnu -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECKs-64 %s
// RUN: %clang --target=riscv64-linux-android -### -S -O0 %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID-64 %s
// RUN: %clang --target=riscv64-linux-android -### -S -O1 %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID-64 %s
// RUN: %clang --target=riscv64-linux-android -### -S -Os %s 2>&1 | FileCheck -check-prefix=CHECK-ANDROID-64 %s
// RUN: %clang --target=loongarch32 -### -S -O0 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK0-32 %s
// RUN: %clang --target=loongarch32 -### -S -O1 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK1-32 %s
// RUN: %clang --target=loongarch32 -### -S -O2 %s -o %t.s 2>&1 | FileCheck -check-prefix=CHECK2-32 %s
@ -81,3 +85,5 @@
// CHECK3-64-NOT: -mframe-pointer=all
// CHECKs-64-NOT: -mframe-pointer=all
// CHECK-MACHO-64: -mframe-pointer=all
// CHECK-ANDROID-64: -mframe-pointer=non-leaf