Do not do tail calls to external symbols. If the
authorDale Johannesen <dalej@apple.com>
Wed, 23 Jun 2010 18:52:34 +0000 (18:52 +0000)
committerDale Johannesen <dalej@apple.com>
Wed, 23 Jun 2010 18:52:34 +0000 (18:52 +0000)
branch turns out to be ARM-to-Thumb or vice versa
the linker cannot resolve this.  8120438.

If this optimization is going to be useful we probably
need a compiler flag "assume callees are same architecture"
or something like that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@106662 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/ARM/ARMISelLowering.cpp

index 97a5f9da120e16b2ef40974b0e9387e13a5c472e..ceb6806f6d53101d20d3541a247dfa7e279f9f70 100644 (file)
@@ -1408,29 +1408,26 @@ ARMTargetLowering::IsEligibleForTailCallOptimization(SDValue Callee,
   if (isCalleeStructRet || isCallerStructRet)
     return false;
 
-  // FIXME: Completely disable sibcal for Thumb1 since Thumb1RegisterInfo::
+  // FIXME: Completely disable sibcall for Thumb1 since Thumb1RegisterInfo::
   // emitEpilogue is not ready for them.
   if (Subtarget->isThumb1Only())
     return false;
 
+  // For the moment, we can only do this to functions defined in this
+  // compilation, or to indirect calls.  A Thumb B to an ARM function,
+  // or vice versa, is not easily fixed up in the linker unlike BL.
+  // (We could do this by loading the address of the callee into a register;
+  // that is an extra instruction over the direct call and burns a register
+  // as well, so is not likely to be a win.)
   if (isa<ExternalSymbolSDNode>(Callee))
       return false;
 
   if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) {
-    if (Subtarget->isThumb1Only())
+    const GlobalValue *GV = G->getGlobal();
+    if (GV->isDeclaration() || GV->isWeakForLinker())
       return false;
-
-    // On Thumb, for the moment, we can only do this to functions defined in this
-    // compilation, or to indirect calls.  A Thumb B to an ARM function is not
-    // easily fixed up in the linker, unlike BL.
-    if (Subtarget->isThumb()) {
-      const GlobalValue *GV = G->getGlobal();
-      if (GV->isDeclaration() || GV->isWeakForLinker())
-        return false;
-    }
   }
 
-
   // If the calling conventions do not match, then we'd better make sure the
   // results are returned in the same way as what the caller expects.
   if (!CCMatch) {