Have isInTailCallPosition take the DAG so that we can use the

version of TargetLowering/Machine from there on the way to avoiding
TargetMachine in TargetLowering.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210579 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Christopher 2014-06-10 20:39:38 +00:00
parent 4d9df32652
commit ad3aa5eb5a
3 changed files with 7 additions and 6 deletions

View File

@ -86,7 +86,7 @@ ISD::CondCode getICmpCondCode(ICmpInst::Predicate Pred);
/// between it and the return.
///
/// This function only tests target-independent requirements.
bool isInTailCallPosition(ImmutableCallSite CS, const TargetLowering &TLI);
bool isInTailCallPosition(ImmutableCallSite CS, const SelectionDAG &DAG);
/// 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

View File

@ -14,6 +14,7 @@
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/CodeGen/Analysis.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/SelectionDAG.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
@ -474,8 +475,7 @@ static bool nextRealType(SmallVectorImpl<CompositeType *> &SubTypes,
/// between it and the return.
///
/// This function only tests target-independent requirements.
bool llvm::isInTailCallPosition(ImmutableCallSite CS,
const TargetLowering &TLI) {
bool llvm::isInTailCallPosition(ImmutableCallSite CS, const SelectionDAG &DAG) {
const Instruction *I = CS.getInstruction();
const BasicBlock *ExitBB = I->getParent();
const TerminatorInst *Term = ExitBB->getTerminator();
@ -490,7 +490,7 @@ bool llvm::isInTailCallPosition(ImmutableCallSite CS,
// longjmp on x86), it can end up causing miscompilation that has not
// been fully understood.
if (!Ret &&
(!TLI.getTargetMachine().Options.GuaranteedTailCallOpt ||
(!DAG.getTarget().Options.GuaranteedTailCallOpt ||
!isa<UnreachableInst>(Term)))
return false;
@ -509,7 +509,8 @@ bool llvm::isInTailCallPosition(ImmutableCallSite CS,
return false;
}
return returnTypeIsEligibleForTailCall(ExitBB->getParent(), I, Ret, TLI);
return returnTypeIsEligibleForTailCall(ExitBB->getParent(), I, Ret,
*DAG.getTarget().getTargetLowering());
}
bool llvm::returnTypeIsEligibleForTailCall(const Function *F,

View File

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