diff options
| author | Arnold Schwaighofer <arnold.schwaighofer@gmail.com> | 2009-03-28 08:33:27 +0000 |
|---|---|---|
| committer | Arnold Schwaighofer <arnold.schwaighofer@gmail.com> | 2009-03-28 08:33:27 +0000 |
| commit | 83d5420d028f36fc053ab48441b1dbabd1d54abe (patch) | |
| tree | a03a0971095474d6ce25942793f5f0d563b93a47 /llvm/lib/CodeGen | |
| parent | 8372efd39ae411b16ae6051ba89bb9e62fd57a09 (diff) | |
| download | bcm5719-llvm-83d5420d028f36fc053ab48441b1dbabd1d54abe.tar.gz bcm5719-llvm-83d5420d028f36fc053ab48441b1dbabd1d54abe.zip | |
Enable tail call optimization for functions that return a struct (bug 3664) and for functions that return types that need extending (e.g i1).
llvm-svn: 67934
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp index a08dcb2e49d..1efc4a677f7 100644 --- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -2571,3 +2571,27 @@ SDValue TargetLowering::BuildUDIV(SDNode *N, SelectionDAG &DAG, DAG.getConstant(magics.s-1, getShiftAmountTy())); } } + +bool TargetLowering::CheckTailCallReturnConstraints(CallSDNode *TheCall, SDValue Ret) { + unsigned NumOps = Ret.getNumOperands(); + // Struct return. + if(NumOps >= 5&& + Ret.getOperand(1).getOpcode()==ISD::MERGE_VALUES && + Ret.getOperand(1).getOperand(0) == SDValue(TheCall, 0)) + return true; + if ((NumOps == 1 && + (Ret.getOperand(0) == SDValue(TheCall,1) || + Ret.getOperand(0) == SDValue(TheCall,0))) || + (NumOps == 3 && + Ret.getOperand(1).getOpcode() == ISD::ANY_EXTEND && + Ret.getOperand(1).getNumOperands()>0 && + Ret.getOperand(1).getOperand(0).getOpcode() == ISD::TRUNCATE && + Ret.getOperand(1).getOperand(0).getNumOperands()>0 && + Ret.getOperand(1).getOperand(0).getOperand(0) == SDValue(TheCall, 0)) || + (NumOps > 1 && + Ret.getOperand(0) == SDValue(TheCall, + TheCall->getNumValues()-1) && + Ret.getOperand(1) == SDValue(TheCall,0))) + return true; + return false; +} |

