summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index e7ab36a9386..40a3bdd4e51 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -2247,9 +2247,12 @@ SDValue SelectionDAGLegalize::ExpandLibCall(RTLIB::Libcall LC, SDNode *Node,
SDValue InChain = DAG.getEntryNode();
// isTailCall may be true since the callee does not reference caller stack
- // frame. Check if it's in the right position.
+ // frame. Check if it's in the right position and that the return types match.
SDValue TCChain = InChain;
- bool isTailCall = TLI.isInTailCallPosition(DAG, Node, TCChain);
+ const Function *F = DAG.getMachineFunction().getFunction();
+ bool isTailCall =
+ TLI.isInTailCallPosition(DAG, Node, TCChain) &&
+ (RetTy == F->getReturnType() || F->getReturnType()->isVoidTy());
if (isTailCall)
InChain = TCChain;
OpenPOWER on IntegriCloud