From: Dale Johannesen Date: Wed, 23 Jun 2010 18:52:34 +0000 (+0000) Subject: Do not do tail calls to external symbols. If the X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=e39fdbe1187b74f8c415adb9f807fa56f1e055aa;p=oota-llvm.git Do not do tail calls to external symbols. If the 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 --- diff --git a/lib/Target/ARM/ARMISelLowering.cpp b/lib/Target/ARM/ARMISelLowering.cpp index 97a5f9da120..ceb6806f6d5 100644 --- a/lib/Target/ARM/ARMISelLowering.cpp +++ b/lib/Target/ARM/ARMISelLowering.cpp @@ -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(Callee)) return false; if (GlobalAddressSDNode *G = dyn_cast(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) {