aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/SelectionDAG
diff options
context:
space:
mode:
authorArnold Schwaighofer <arnold.schwaighofer@gmail.com>2009-03-28 08:33:27 +0000
committerArnold Schwaighofer <arnold.schwaighofer@gmail.com>2009-03-28 08:33:27 +0000
commite75fd69f15dc1b35d20b12d0e765ea6f2b9ffe0b (patch)
tree5d16e8dd25eccdf855e428d8f2f885c10e2b368e /lib/CodeGen/SelectionDAG
parent1717f3af087e44d2c4b7fe2b35abc29a33d6d315 (diff)
downloadexternal_llvm-e75fd69f15dc1b35d20b12d0e765ea6f2b9ffe0b.zip
external_llvm-e75fd69f15dc1b35d20b12d0e765ea6f2b9ffe0b.tar.gz
external_llvm-e75fd69f15dc1b35d20b12d0e765ea6f2b9ffe0b.tar.bz2
Enable tail call optimization for functions that return a struct (bug 3664) and for functions that return types that need extending (e.g i1).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67934 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG')
-rw-r--r--lib/CodeGen/SelectionDAG/TargetLowering.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index a08dcb2..1efc4a6 100644
--- a/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/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;
+}