namespace llvm {
class GlobalVariable;
class TargetLoweringBase;
+class TargetLowering;
+class TargetMachine;
class SDNode;
class SDValue;
class SelectionDAG;
-class TargetLowering;
struct EVT;
/// ComputeLinearIndex - Given an LLVM IR aggregate type and a sequence
/// between it and the return.
///
/// 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
/// return type or any attributes of the function will inhibit tail call
/// between it and the return.
///
/// 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 BasicBlock *ExitBB = I->getParent();
const TerminatorInst *Term = ExitBB->getTerminator();
// longjmp on x86), it can end up causing miscompilation that has not
// been fully understood.
if (!Ret &&
- (!DAG.getTarget().Options.GuaranteedTailCallOpt ||
- !isa<UnreachableInst>(Term)))
+ (!TM.Options.GuaranteedTailCallOpt || !isa<UnreachableInst>(Term)))
return false;
// If I will have a chain, make sure no other instruction that will have a
return false;
}
- return returnTypeIsEligibleForTailCall(ExitBB->getParent(), I, Ret,
- *DAG.getTarget().getTargetLowering());
+ return returnTypeIsEligibleForTailCall(ExitBB->getParent(), I, Ret, TLI);
}
bool llvm::returnTypeIsEligibleForTailCall(const Function *F,
// Check if target-independent constraints permit a tail call here.
// Target-dependent constraints are checked within TLI->LowerCallTo.
- if (isTailCall && !isInTailCallPosition(CS, DAG))
+ if (isTailCall && !isInTailCallPosition(CS, DAG.getTarget(), *TLI))
isTailCall = false;
TargetLowering::CallLoweringInfo CLI(DAG);