r210398 - Driver: add -m{,no-}long-calls support

Saleem Abdulrasool compnerd at compnerd.org
Sat Jun 7 12:32:38 PDT 2014


Author: compnerd
Date: Sat Jun  7 14:32:38 2014
New Revision: 210398

URL: http://llvm.org/viewvc/llvm-project?rev=210398&view=rev
Log:
Driver: add -m{,no-}long-calls support

This mirrors the GCC option for the ARM backend.  This option enables the
backend option "-enable-arm-long-calls".  The default behaviour is that this is
disabled due to the slight overhead of the generated calls.

If the target of jumps are greater than 64M range of offset-based jumps, then
the target address must be loaded into a register to make an indirect jump.  The
backend support for this has been present, but was not previously controllable
by the proper flag.

Added:
    cfe/trunk/test/Driver/arm-long-calls.c
Modified:
    cfe/trunk/include/clang/Driver/Options.td
    cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=210398&r1=210397&r2=210398&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Sat Jun  7 14:32:38 2014
@@ -1106,6 +1106,10 @@ def mcrc : Flag<["-"], "mcrc">, Group<m_
   HelpText<"Allow use of CRC instructions (ARM only)">;
 def mnocrc : Flag<["-"], "mnocrc">, Group<m_arm_Features_Group>,
   HelpText<"Disallow use of CRC instructions (ARM only)">;
+def mlong_calls : Flag<["-"], "mlong-calls">, Group<m_arm_Features_Group>,
+  HelpText<"Generate an indirect jump to enable jumps further than 64M">;
+def mno_long_calls : Flag<["-"], "mno-long-calls">, Group<m_arm_Features_Group>,
+  HelpText<"Restore the default behaviour of not generating long calls">;
 
 def mgeneral_regs_only : Flag<["-"], "mgeneral-regs-only">, Group<m_aarch64_Features_Group>,
   HelpText<"Generate code which only uses the general purpose registers (AArch64 only)">;

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=210398&r1=210397&r2=210398&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Sat Jun  7 14:32:38 2014
@@ -3469,6 +3469,17 @@ 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("-enable-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/Driver/arm-long-calls.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-long-calls.c?rev=210398&view=auto
==============================================================================
--- cfe/trunk/test/Driver/arm-long-calls.c (added)
+++ cfe/trunk/test/Driver/arm-long-calls.c Sat Jun  7 14:32:38 2014
@@ -0,0 +1,15 @@
+// RUN: %clang -target armv7-eabi -### %s 2>&1 \
+// RUN:    | FileCheck %s -check-prefix CHECK-DEFAULT
+
+// RUN: %clang -target armv7-eabi -### -mlong-calls %s 2>&1 \
+// RUN:    | FileCheck %s -check-prefix CHECK-LONG-CALLS
+
+// 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" "-enable-arm-long-calls"
+
+// CHECK-LONG-CALLS: "-backend-option" "-enable-arm-long-calls"
+
+// CHECK-NO-LONG-CALLS-NOT: "-backend-option" "-enable-arm-long-calls"
+





More information about the cfe-commits mailing list