ahatanak added reviewers: echristo, dexonsmith.
ahatanak added a subscriber: cfe-commits.
Herald added subscribers: rengolin, aemerson.

Currently, clang uses backend-option "-arm-use-movt=0" to disallow emitting 
movt/movw pairs to materialize 32-bit immediate values. This patch makes 
changes to pass subtarget feature "+dont-use-movt" instead to enable 
disallowing movt/movw pairs when doing LTO.

http://reviews.llvm.org/D11025

Files:
  lib/Driver/Tools.cpp
  test/CodeGen/arm-dont-use-movt.c
  test/Driver/arm-dont-use-movt.c

Index: test/Driver/arm-dont-use-movt.c
===================================================================
--- /dev/null
+++ test/Driver/arm-dont-use-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" "+dont-use-movt"
+
+// CHECK-KERNEL: "-target-feature" "+dont-use-movt"
Index: test/CodeGen/arm-dont-use-movt.c
===================================================================
--- /dev/null
+++ test/CodeGen/arm-dont-use-movt.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple thumbv7-apple-ios5  -target-feature +dont-use-movt 
-emit-llvm -o - %s | FileCheck -check-prefix=DONT-USE-MOVT %s
+// RUN: %clang_cc1 -triple thumbv7-apple-ios5 -emit-llvm -o - %s | FileCheck 
-check-prefix=USE-MOVT %s
+
+// DONT-USE-MOVT: attributes #0 = { {{.*}} "target-features"="+dont-use-movt"
+// USE-MOVT-NOT: attributes #0 = { {{.*}} "target-features"="+dont-use-movt"
+
+int foo1(int a) { return a; }
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -718,6 +718,10 @@
   } 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("+dont-use-movt");
 }
 
 void Clang::AddARMTargetArgs(const ArgList &Args, ArgStringList &CmdArgs,
@@ -793,10 +797,6 @@
   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.


Index: test/Driver/arm-dont-use-movt.c
===================================================================
--- /dev/null
+++ test/Driver/arm-dont-use-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" "+dont-use-movt"
+
+// CHECK-KERNEL: "-target-feature" "+dont-use-movt"
Index: test/CodeGen/arm-dont-use-movt.c
===================================================================
--- /dev/null
+++ test/CodeGen/arm-dont-use-movt.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple thumbv7-apple-ios5  -target-feature +dont-use-movt -emit-llvm -o - %s | FileCheck -check-prefix=DONT-USE-MOVT %s
+// RUN: %clang_cc1 -triple thumbv7-apple-ios5 -emit-llvm -o - %s | FileCheck -check-prefix=USE-MOVT %s
+
+// DONT-USE-MOVT: attributes #0 = { {{.*}} "target-features"="+dont-use-movt"
+// USE-MOVT-NOT: attributes #0 = { {{.*}} "target-features"="+dont-use-movt"
+
+int foo1(int a) { return a; }
Index: lib/Driver/Tools.cpp
===================================================================
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -718,6 +718,10 @@
   } 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("+dont-use-movt");
 }
 
 void Clang::AddARMTargetArgs(const ArgList &Args, ArgStringList &CmdArgs,
@@ -793,10 +797,6 @@
   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.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to