[FastISel] Make isInTailCallPosition independent of SelectionDAG.

Break out the arguemnts required from SelectionDAG, so that this function can
also be used by FastISel.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212844 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Juergen Ributzka
2014-07-11 20:50:47 +00:00
parent 2f58a513f1
commit 56b7de65b0
3 changed files with 9 additions and 8 deletions

View File

@@ -24,10 +24,11 @@
namespace llvm { namespace llvm {
class GlobalVariable; class GlobalVariable;
class TargetLoweringBase; class TargetLoweringBase;
class TargetLowering;
class TargetMachine;
class SDNode; class SDNode;
class SDValue; class SDValue;
class SelectionDAG; class SelectionDAG;
class TargetLowering;
struct EVT; struct EVT;
/// ComputeLinearIndex - Given an LLVM IR aggregate type and a sequence /// ComputeLinearIndex - Given an LLVM IR aggregate type and a sequence
@@ -86,7 +87,8 @@ ISD::CondCode getICmpCondCode(ICmpInst::Predicate Pred);
/// between it and the return. /// between it and the return.
/// ///
/// This function only tests target-independent requirements. /// This function only tests target-independent requirements.
bool isInTailCallPosition(ImmutableCallSite CS, const SelectionDAG &DAG); bool isInTailCallPosition(ImmutableCallSite CS, const TargetMachine &TM,
const TargetLoweringBase &TLI);
/// Test if given that the input instruction is in the tail call position if the /// Test if given that the input instruction is in the tail call position if the
/// return type or any attributes of the function will inhibit tail call /// return type or any attributes of the function will inhibit tail call

View File

@@ -475,7 +475,8 @@ static bool nextRealType(SmallVectorImpl<CompositeType *> &SubTypes,
/// between it and the return. /// between it and the return.
/// ///
/// This function only tests target-independent requirements. /// This function only tests target-independent requirements.
bool llvm::isInTailCallPosition(ImmutableCallSite CS, const SelectionDAG &DAG) { bool llvm::isInTailCallPosition(ImmutableCallSite CS, const TargetMachine &TM,
const TargetLoweringBase &TLI) {
const Instruction *I = CS.getInstruction(); const Instruction *I = CS.getInstruction();
const BasicBlock *ExitBB = I->getParent(); const BasicBlock *ExitBB = I->getParent();
const TerminatorInst *Term = ExitBB->getTerminator(); const TerminatorInst *Term = ExitBB->getTerminator();
@@ -490,8 +491,7 @@ bool llvm::isInTailCallPosition(ImmutableCallSite CS, const SelectionDAG &DAG) {
// longjmp on x86), it can end up causing miscompilation that has not // longjmp on x86), it can end up causing miscompilation that has not
// been fully understood. // been fully understood.
if (!Ret && if (!Ret &&
(!DAG.getTarget().Options.GuaranteedTailCallOpt || (!TM.Options.GuaranteedTailCallOpt || !isa<UnreachableInst>(Term)))
!isa<UnreachableInst>(Term)))
return false; return false;
// If I will have a chain, make sure no other instruction that will have a // If I will have a chain, make sure no other instruction that will have a
@@ -509,8 +509,7 @@ bool llvm::isInTailCallPosition(ImmutableCallSite CS, const SelectionDAG &DAG) {
return false; return false;
} }
return returnTypeIsEligibleForTailCall(ExitBB->getParent(), I, Ret, return returnTypeIsEligibleForTailCall(ExitBB->getParent(), I, Ret, TLI);
*DAG.getTarget().getTargetLowering());
} }
bool llvm::returnTypeIsEligibleForTailCall(const Function *F, bool llvm::returnTypeIsEligibleForTailCall(const Function *F,

View File

@@ -5490,7 +5490,7 @@ void SelectionDAGBuilder::LowerCallTo(ImmutableCallSite CS, SDValue Callee,
// Check if target-independent constraints permit a tail call here. // Check if target-independent constraints permit a tail call here.
// Target-dependent constraints are checked within TLI->LowerCallTo. // Target-dependent constraints are checked within TLI->LowerCallTo.
if (isTailCall && !isInTailCallPosition(CS, DAG)) if (isTailCall && !isInTailCallPosition(CS, DAG.getTarget(), *TLI))
isTailCall = false; isTailCall = false;
TargetLowering::CallLoweringInfo CLI(DAG); TargetLowering::CallLoweringInfo CLI(DAG);