[ARM] Pass subtarget feature "+long-calls" instead of passing backend option

"-arm-long-calls".

This change allows using -mlong-calls/-mno-long-calls for LTO and enabling or
disabling long call on a per-function basis.

rdar://problem/21529937

Differential Revision: http://reviews.llvm.org/D9414

llvm-svn: 241565
This commit is contained in:
Akira Hatanaka 2015-07-07 06:42:05 +00:00
parent 0a8890ff45
commit 3fb33a5d18
4 changed files with 21 additions and 20 deletions

View File

@ -638,6 +638,8 @@ static void getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args,
std::vector<const char *> &Features,
bool ForAS) {
bool KernelOrKext =
Args.hasArg(options::OPT_mkernel, options::OPT_fapple_kext);
StringRef FloatABI = tools::arm::getARMFloatABI(D, Args, Triple);
if (!ForAS) {
// FIXME: Note, this is a hack, the LLVM backend doesn't actually use these
@ -705,6 +707,14 @@ static void getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
if (Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v8_1a) {
Features.insert(Features.begin(), "+v8.1a");
}
if (Arg *A = Args.getLastArg(options::OPT_mlong_calls,
options::OPT_mno_long_calls)) {
if (A->getOption().matches(options::OPT_mlong_calls))
Features.push_back("+long-calls");
} else if (KernelOrKext && (!Triple.isiOS() || Triple.isOSVersionLT(6))) {
Features.push_back("+long-calls");
}
}
void Clang::AddARMTargetArgs(const ArgList &Args, ArgStringList &CmdArgs,
@ -778,11 +788,6 @@ void Clang::AddARMTargetArgs(const ArgList &Args, ArgStringList &CmdArgs,
// Kernel code has more strict alignment requirements.
if (KernelOrKext) {
if (!Triple.isiOS() || Triple.isOSVersionLT(6)) {
CmdArgs.push_back("-backend-option");
CmdArgs.push_back("-arm-long-calls");
}
CmdArgs.push_back("-backend-option");
CmdArgs.push_back("-arm-strict-align");
@ -4074,17 +4079,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
CmdArgs.push_back("-arm-restrict-it");
}
if (TT.getArch() == llvm::Triple::arm ||
TT.getArch() == llvm::Triple::thumb) {
if (Arg *A = Args.getLastArg(options::OPT_mlong_calls,
options::OPT_mno_long_calls)) {
if (A->getOption().matches(options::OPT_mlong_calls)) {
CmdArgs.push_back("-backend-option");
CmdArgs.push_back("-arm-long-calls");
}
}
}
// Forward -f options with positive and negative forms; we translate
// these by hand.
if (Arg *A = Args.getLastArg(options::OPT_fprofile_sample_use_EQ)) {

View File

@ -0,0 +1,7 @@
// RUN: %clang_cc1 -triple thumbv7-apple-ios5 -target-feature +long-calls -emit-llvm -o - %s | FileCheck -check-prefix=LONGCALL %s
// RUN: %clang_cc1 -triple thumbv7-apple-ios5 -emit-llvm -o - %s | FileCheck -check-prefix=NOLONGCALL %s
// LONGCALL: attributes #0 = { {{.*}} "target-features"="+long-calls"
// NOLONGCALL-NOT: attributes #0 = { {{.*}} "target-features"="+long-calls"
int foo1(int a) { return a; }

View File

@ -11,7 +11,7 @@
// RUN: -arch armv7 -mkernel -mstrict-align -### -fsyntax-only %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-ARM < %t %s
// CHECK-ARM: "-backend-option" "-arm-long-calls"
// CHECK-ARM: "-target-feature" "+long-calls"
// CHECK-ARM: "-backend-option" "-arm-strict-align"
// CHECK-ARM-NOT: "-backend-option" "-arm-strict-align"
// CHECK-ARM: "-fno-builtin"

View File

@ -7,9 +7,9 @@
// RUN: %clang -target armv7-eabi -### -mlong-calls -mno-long-calls %s 2>&1 \
// RUN: | FileCheck %s -check-prefix CHECK-NO-LONG-CALLS
// CHECK-DEFAULT-NOT: "-backend-option" "-arm-long-calls"
// CHECK-DEFAULT-NOT: "-target-feature" "+long-calls"
// CHECK-LONG-CALLS: "-backend-option" "-arm-long-calls"
// CHECK-LONG-CALLS: "-target-feature" "+long-calls"
// CHECK-NO-LONG-CALLS-NOT: "-backend-option" "-arm-long-calls"
// CHECK-NO-LONG-CALLS-NOT: "-target-feature" "+long-calls"