llvm.org GIT mirror llvm / 56b7de6
[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 Juergen Ributzka 5 years ago
3 changed file(s) with 9 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
2323 namespace llvm {
2424 class GlobalVariable;
2525 class TargetLoweringBase;
26 class TargetLowering;
27 class TargetMachine;
2628 class SDNode;
2729 class SDValue;
2830 class SelectionDAG;
29 class TargetLowering;
3031 struct EVT;
3132
3233 /// ComputeLinearIndex - Given an LLVM IR aggregate type and a sequence
8586 /// between it and the return.
8687 ///
8788 /// This function only tests target-independent requirements.
88 bool isInTailCallPosition(ImmutableCallSite CS, const SelectionDAG &DAG);
89 bool isInTailCallPosition(ImmutableCallSite CS, const TargetMachine &TM,
90 const TargetLoweringBase &TLI);
8991
9092 /// Test if given that the input instruction is in the tail call position if the
9193 /// return type or any attributes of the function will inhibit tail call
474474 /// between it and the return.
475475 ///
476476 /// This function only tests target-independent requirements.
477 bool llvm::isInTailCallPosition(ImmutableCallSite CS, const SelectionDAG &DAG) {
477 bool llvm::isInTailCallPosition(ImmutableCallSite CS, const TargetMachine &TM,
478 const TargetLoweringBase &TLI) {
478479 const Instruction *I = CS.getInstruction();
479480 const BasicBlock *ExitBB = I->getParent();
480481 const TerminatorInst *Term = ExitBB->getTerminator();
489490 // longjmp on x86), it can end up causing miscompilation that has not
490491 // been fully understood.
491492 if (!Ret &&
492 (!DAG.getTarget().Options.GuaranteedTailCallOpt ||
493 !isa(Term)))
493 (!TM.Options.GuaranteedTailCallOpt || !isa(Term)))
494494 return false;
495495
496496 // If I will have a chain, make sure no other instruction that will have a
508508 return false;
509509 }
510510
511 return returnTypeIsEligibleForTailCall(ExitBB->getParent(), I, Ret,
512 *DAG.getTarget().getTargetLowering());
511 return returnTypeIsEligibleForTailCall(ExitBB->getParent(), I, Ret, TLI);
513512 }
514513
515514 bool llvm::returnTypeIsEligibleForTailCall(const Function *F,
54895489
54905490 // Check if target-independent constraints permit a tail call here.
54915491 // Target-dependent constraints are checked within TLI->LowerCallTo.
5492 if (isTailCall && !isInTailCallPosition(CS, DAG))
5492 if (isTailCall && !isInTailCallPosition(CS, DAG.getTarget(), *TLI))
54935493 isTailCall = false;
54945494
54955495 TargetLowering::CallLoweringInfo CLI(DAG);