From cd0f3da09c8b80e354b6bcb86529d560b4fbb955 Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Thu, 16 Jul 2015 00:43:00 +0000 Subject: [PATCH] [ARM] Pass subtarget feature "+no-movt" instead of passing backend option "-arm-use-movt=0". This change is needed since backend options do not make it to the backend when doing LTO and are not capable of changing the behavior of code-gen passes on a per-function basis. rdar://problem/21529937 Differential Revision: http://reviews.llvm.org/D11025 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@242368 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/Tools.cpp | 8 ++++---- test/CodeGen/arm-no-movt.c | 7 +++++++ test/Driver/arm-no-movt.c | 9 +++++++++ 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 test/CodeGen/arm-no-movt.c create mode 100644 test/Driver/arm-no-movt.c diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 8c11992f1f..89e3987170 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -718,6 +718,10 @@ static void getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple, } else if (KernelOrKext && (!Triple.isiOS() || Triple.isOSVersionLT(6))) { Features.push_back("+long-calls"); } + + // The kext linker doesn't know how to deal with movw/movt. + if (KernelOrKext) + Features.push_back("+no-movt"); } void Clang::AddARMTargetArgs(const ArgList &Args, ArgStringList &CmdArgs, @@ -793,10 +797,6 @@ void Clang::AddARMTargetArgs(const ArgList &Args, ArgStringList &CmdArgs, if (KernelOrKext) { CmdArgs.push_back("-backend-option"); CmdArgs.push_back("-arm-strict-align"); - - // The kext linker doesn't know how to deal with movw/movt. - CmdArgs.push_back("-backend-option"); - CmdArgs.push_back("-arm-use-movt=0"); } // -mkernel implies -mstrict-align; don't add the redundant option. diff --git a/test/CodeGen/arm-no-movt.c b/test/CodeGen/arm-no-movt.c new file mode 100644 index 0000000000..0773941fb3 --- /dev/null +++ b/test/CodeGen/arm-no-movt.c @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -triple thumbv7-apple-ios5 -target-feature +no-movt -emit-llvm -o - %s | FileCheck -check-prefix=NO-MOVT %s +// RUN: %clang_cc1 -triple thumbv7-apple-ios5 -emit-llvm -o - %s | FileCheck -check-prefix=MOVT %s + +// NO-MOVT: attributes #0 = { {{.*}} "target-features"="+no-movt" +// MOVT-NOT: attributes #0 = { {{.*}} "target-features"="+no-movt" + +int foo1(int a) { return a; } diff --git a/test/Driver/arm-no-movt.c b/test/Driver/arm-no-movt.c new file mode 100644 index 0000000000..9684d0e16c --- /dev/null +++ b/test/Driver/arm-no-movt.c @@ -0,0 +1,9 @@ +// RUN: %clang -target armv7-apple-darwin -### %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix CHECK-DEFAULT + +// RUN: %clang -target armv7-apple-darwin -mkernel -### %s 2>&1 \ +// RUN: | FileCheck %s -check-prefix CHECK-KERNEL + +// CHECK-DEFAULT-NOT: "-target-feature" "+no-movt" + +// CHECK-KERNEL: "-target-feature" "+no-movt" -- 2.50.1