[llvm-commits] [llvm] r56235 - in /llvm/trunk/lib/CodeGen/SelectionDAG: SelectionDAGBuild.cpp SelectionDAGISel.cpp

Dan Gohman gohman at apple.com
Mon Sep 15 18:42:28 PDT 2008


Author: djg
Date: Mon Sep 15 20:42:28 2008
New Revision: 56235

URL: http://llvm.org/viewvc/llvm-project?rev=56235&view=rev
Log:
Don't take the time to CheckDAGForTailCallsAndFixThem when tail calls
are not enabled. Instead just omit the tail call flag when calls are
created.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp?rev=56235&r1=56234&r2=56235&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp Mon Sep 15 20:42:28 2008
@@ -4201,7 +4201,8 @@
     TLI.LowerCallTo(getRoot(), CS.getType(),
                     CS.paramHasAttr(0, ParamAttr::SExt),
                     CS.paramHasAttr(0, ParamAttr::ZExt),
-                    FTy->isVarArg(), CS.getCallingConv(), IsTailCall,
+                    FTy->isVarArg(), CS.getCallingConv(),
+                    IsTailCall && PerformTailCallOpt,
                     Callee, Args, DAG);
   if (CS.getType() != Type::VoidTy)
     setValue(CS.getInstruction(), Result.first);
@@ -5138,7 +5139,8 @@
 
   std::pair<SDValue,SDValue> Result =
     TLI.LowerCallTo(getRoot(), I.getType(), false, false, false, CallingConv::C,
-                    true, DAG.getExternalSymbol("malloc", IntPtr), Args, DAG);
+                    PerformTailCallOpt, DAG.getExternalSymbol("malloc", IntPtr),
+                    Args, DAG);
   setValue(&I, Result.first);  // Pointers always fit in registers
   DAG.setRoot(Result.second);
 }
@@ -5152,7 +5154,7 @@
   MVT IntPtr = TLI.getPointerTy();
   std::pair<SDValue,SDValue> Result =
     TLI.LowerCallTo(getRoot(), Type::VoidTy, false, false, false,
-                    CallingConv::C, true,
+                    CallingConv::C, PerformTailCallOpt,
                     DAG.getExternalSymbol("free", IntPtr), Args, DAG);
   DAG.setRoot(Result.second);
 }
@@ -5323,6 +5325,9 @@
                             unsigned CallingConv, bool isTailCall,
                             SDValue Callee,
                             ArgListTy &Args, SelectionDAG &DAG) {
+  assert((!isTailCall || PerformTailCallOpt) &&
+         "isTailCall set when tail-call optimizations are disabled!");
+
   SmallVector<SDValue, 32> Ops;
   Ops.push_back(Chain);   // Op#0 - Chain
   Ops.push_back(Callee);

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=56235&r1=56234&r2=56235&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Mon Sep 15 20:42:28 2008
@@ -526,7 +526,8 @@
   // with correct tailcall attribute so that the target can rely on the tailcall
   // attribute indicating whether the call is really eligible for tail call
   // optimization.
-  CheckDAGForTailCallsAndFixThem(*CurDAG, TLI);
+  if (PerformTailCallOpt)
+    CheckDAGForTailCallsAndFixThem(*CurDAG, TLI);
 
   // Final step, emit the lowered DAG as machine code.
   CodeGenAndEmitDAG();





More information about the llvm-commits mailing list