[PATCH] ARM: enable long calls for WoA

Saleem Abdulrasool abdulras at fb.com
Tue Apr 1 09:40:31 PDT 2014


Hi t.p.northover, grosbach,

Enable long calls on WoA.  While this may not be the most efficient approach,
the MSVC compiler also generates long calls for most scenarios.  Ideally, all
local symbols would be relaxed during CG to normal calls.  However, in the
scenario of external symbols, you do not know the required range for the jump,
and thus require long calls.

http://llvm-reviews.chandlerc.com/D3247

Files:
  lib/Target/ARM/ARMISelLowering.cpp
  test/CodeGen/ARM/Windows/calls.ll

Index: lib/Target/ARM/ARMISelLowering.cpp
===================================================================
--- lib/Target/ARM/ARMISelLowering.cpp
+++ lib/Target/ARM/ARMISelLowering.cpp
@@ -1645,8 +1645,9 @@
   bool isLocalARMFunc = false;
   ARMFunctionInfo *AFI = MF.getInfo<ARMFunctionInfo>();
 
-  if (EnableARMLongCalls) {
-    assert (getTargetMachine().getRelocationModel() == Reloc::Static
+  if (EnableARMLongCalls || Subtarget->isTargetWindows()) {
+    assert ((getTargetMachine().getRelocationModel() == Reloc::Static ||
+             Subtarget->isTargetWindows())
             && "long-calls with non-static relocation model!");
     // Handle a global address or an external symbol. If it's not one of
     // those, the target's already in a register, so we don't need to do
Index: test/CodeGen/ARM/Windows/calls.ll
===================================================================
--- /dev/null
+++ test/CodeGen/ARM/Windows/calls.ll
@@ -0,0 +1,36 @@
+; RUN: llc -mtriple=thumbv7-windows -mcpu=cortex-a9 -o - %s | FileCheck %s
+
+declare void @external()
+
+define void @internal() nounwind {
+entry:
+  ret void
+}
+
+define void @call_external() nounwind {
+entry:
+  tail call void @external()
+  ret void
+}
+
+define void @call_internal() nounwind {
+entry:
+  tail call void @internal()
+  ret void
+}
+
+; CHECK: call_external:
+; CHECK: 	ldr	r0, .L[[CPI:[^ ]*]]
+; CHECK: 	bx	r0
+; CHECK: .align 2
+; CHECK: .L[[CPI]]
+; CHECK: 	.long external
+
+; CHECK: call_internal
+; CHECK: 	ldr	r0, .L[[CPI:[^ ]*]]
+; FIXME: relax this to a bl function
+; CHECK: 	bx	r0
+; CHECK: .align 2
+; CHECK: .L[[CPI]]
+; CHECK: 	.long internal
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3247.1.patch
Type: text/x-patch
Size: 1654 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140401/5d0dfbd6/attachment.bin>


More information about the llvm-commits mailing list