[FastISel] Make isInTailCallPosition independent of SelectionDAG.
authorJuergen Ributzka <juergen@apple.com>
Fri, 11 Jul 2014 20:50:47 +0000 (20:50 +0000)
committerJuergen Ributzka <juergen@apple.com>
Fri, 11 Jul 2014 20:50:47 +0000 (20:50 +0000)
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

include/llvm/CodeGen/Analysis.h
lib/CodeGen/Analysis.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

index c5060fb5441cdc889a786847934fd0ba1c383816..9c078d497f42a4ca706ffee943cff156645e8021 100644 (file)
 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
@@ -86,7 +87,8 @@ ISD::CondCode getICmpCondCode(ICmpInst::Predicate Pred);
 /// 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
index 1bdf312e46c25500f839aaecb1e4c8d2d96a04bc..3740d03b62dec69ce36707e7950c622b128f42e7 100644 (file)
@@ -475,7 +475,8 @@ static bool nextRealType(SmallVectorImpl<CompositeType *> &SubTypes,
 /// 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();
@@ -490,8 +491,7 @@ bool llvm::isInTailCallPosition(ImmutableCallSite CS, const SelectionDAG &DAG) {
   // 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
@@ -509,8 +509,7 @@ bool llvm::isInTailCallPosition(ImmutableCallSite CS, const SelectionDAG &DAG) {
         return false;
     }
 
-  return returnTypeIsEligibleForTailCall(ExitBB->getParent(), I, Ret,
-                                         *DAG.getTarget().getTargetLowering());
+  return returnTypeIsEligibleForTailCall(ExitBB->getParent(), I, Ret, TLI);
 }
 
 bool llvm::returnTypeIsEligibleForTailCall(const Function *F,
index 28d8e98434987447a3dbddf0ce98d439da7eaea0..f20c61a21c69ee7b64baf3cbb91d6b124418e903 100644 (file)
@@ -5490,7 +5490,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, DAG))
+  if (isTailCall && !isInTailCallPosition(CS, DAG.getTarget(), *TLI))
     isTailCall = false;
 
   TargetLowering::CallLoweringInfo CLI(DAG);