diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 3a25714f07c..201e899bd6a 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -4213,12 +4213,6 @@ isInTailCallPosition(CallSite CS, Attributes CalleeRetAttr, // causing miscompilation that has not been fully understood. if (!Ret) return false; - // Unless we are explicitly forcing tailcall optimization do not tailcall if - // the called function is bitcast'ed. The analysis may not be entirely - // accurate. - if (!PerformTailCallOpt && isa(CS.getCalledValue())) - return false; - // If I will have a chain, make sure no other instruction that will have a // chain interposes between I and the return. if (I->mayHaveSideEffects() || I->mayReadFromMemory() || @@ -4246,6 +4240,10 @@ isInTailCallPosition(CallSite CS, Attributes CalleeRetAttr, if ((CalleeRetAttr ^ CallerRetAttr) & ~Attribute::NoAlias) return false; + // It's not safe to eliminate thee sign / zero extension of the return value. + if ((CallerRetAttr & Attribute::ZExt) || (CallerRetAttr & Attribute::SExt)) + return false; + // Otherwise, make sure the unmodified return value of I is the return value. for (const Instruction *U = dyn_cast(Ret->getOperand(0)); ; U = dyn_cast(U->getOperand(0))) {