r241565 - [ARM] Pass subtarget feature "+long-calls" instead of passing backend option
Akira Hatanaka
ahatanaka at apple.com
Mon Jul 6 23:42:05 PDT 2015
Author: ahatanak
Date: Tue Jul 7 01:42:05 2015
New Revision: 241565
URL: http://llvm.org/viewvc/llvm-project?rev=241565&view=rev
Log:
[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
Added:
cfe/trunk/test/CodeGen/arm-long-calls.c
Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/apple-kext-mkernel.c
cfe/trunk/test/Driver/arm-long-calls.c
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=241565&r1=241564&r2=241565&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Jul 7 01:42:05 2015
@@ -638,6 +638,8 @@ static void getARMTargetFeatures(const D
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 D
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 ArgLi
// 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,
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)) {
Added: cfe/trunk/test/CodeGen/arm-long-calls.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm-long-calls.c?rev=241565&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/arm-long-calls.c (added)
+++ cfe/trunk/test/CodeGen/arm-long-calls.c Tue Jul 7 01:42:05 2015
@@ -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; }
Modified: cfe/trunk/test/Driver/apple-kext-mkernel.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/apple-kext-mkernel.c?rev=241565&r1=241564&r2=241565&view=diff
==============================================================================
--- cfe/trunk/test/Driver/apple-kext-mkernel.c (original)
+++ cfe/trunk/test/Driver/apple-kext-mkernel.c Tue Jul 7 01:42:05 2015
@@ -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"
Modified: cfe/trunk/test/Driver/arm-long-calls.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-long-calls.c?rev=241565&r1=241564&r2=241565&view=diff
==============================================================================
--- cfe/trunk/test/Driver/arm-long-calls.c (original)
+++ cfe/trunk/test/Driver/arm-long-calls.c Tue Jul 7 01:42:05 2015
@@ -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"
More information about the cfe-commits
mailing list