[llvm] r264355 - Reduce code duplication by extracting out a helper function; NFC

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 24 15:51:50 PDT 2016


Author: sanjoy
Date: Thu Mar 24 17:51:49 2016
New Revision: 264355

URL: http://llvm.org/viewvc/llvm-project?rev=264355&view=rev
Log:
Reduce code duplication by extracting out a helper function; NFC

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
    llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h?rev=264355&r1=264354&r2=264355&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h Thu Mar 24 17:51:49 2016
@@ -783,6 +783,10 @@ public:
 
   void LowerDeoptimizeCall(const CallInst *CI);
 
+  void LowerCallSiteWithDeoptBundleImpl(ImmutableCallSite CS, SDValue Callee,
+                                        const BasicBlock *EHPadBB,
+                                        bool VarArgDisallowed);
+
 private:
   // Terminator instructions.
   void visitRet(const ReturnInst &I);

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp?rev=264355&r1=264354&r2=264355&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp Thu Mar 24 17:51:49 2016
@@ -821,13 +821,15 @@ SelectionDAGBuilder::LowerStatepoint(Imm
   }
 }
 
-void SelectionDAGBuilder::LowerCallSiteWithDeoptBundle(
-    ImmutableCallSite CS, SDValue Callee, const BasicBlock *EHPadBB) {
+void SelectionDAGBuilder::LowerCallSiteWithDeoptBundleImpl(
+    ImmutableCallSite CS, SDValue Callee, const BasicBlock *EHPadBB,
+    bool VarArgDisallowed) {
   StatepointLoweringInfo SI(DAG);
   unsigned ArgBeginIndex = CS.arg_begin() - CS.getInstruction()->op_begin();
   populateCallLoweringInfo(SI.CLI, CS, ArgBeginIndex, CS.getNumArgOperands(),
                            Callee, CS.getType(), false);
-  SI.CLI.IsVarArg = CS.getFunctionType()->isVarArg();
+  if (!VarArgDisallowed)
+    SI.CLI.IsVarArg = CS.getFunctionType()->isVarArg();
 
   auto DeoptBundle = *CS.getOperandBundle(LLVMContext::OB_deopt);
 
@@ -842,6 +844,8 @@ void SelectionDAGBuilder::LowerCallSiteW
   SI.StatepointFlags = static_cast<uint64_t>(StatepointFlags::None);
   SI.EHPadBB = EHPadBB;
 
+  // NB! The GC arguments are deliberately left empty.
+
   if (SDValue ReturnVal = LowerAsSTATEPOINT(SI)) {
     const Instruction *Inst = CS.getInstruction();
     ReturnVal = lowerRangeToAssertZExt(DAG, *Inst, ReturnVal);
@@ -849,6 +853,12 @@ void SelectionDAGBuilder::LowerCallSiteW
   }
 }
 
+void SelectionDAGBuilder::LowerCallSiteWithDeoptBundle(
+    ImmutableCallSite CS, SDValue Callee, const BasicBlock *EHPadBB) {
+  LowerCallSiteWithDeoptBundleImpl(CS, Callee, EHPadBB,
+                                   /* VarArgDisallowed = */ false);
+}
+
 void SelectionDAGBuilder::visitGCResult(const CallInst &CI) {
   // The result value of the gc_result is simply the result of the actual
   // call.  We've already emitted this, so just grab the value.
@@ -927,34 +937,11 @@ void SelectionDAGBuilder::visitGCRelocat
 
 void SelectionDAGBuilder::LowerDeoptimizeCall(const CallInst *CI) {
   const auto &TLI = DAG.getTargetLoweringInfo();
-
   SDValue Callee = DAG.getExternalSymbol(TLI.getLibcallName(RTLIB::DEOPTIMIZE),
                                          TLI.getPointerTy(DAG.getDataLayout()));
-  StatepointLoweringInfo SI(DAG);
-  unsigned ArgBeginIndex = CI->arg_begin() - CI->op_begin();
-  populateCallLoweringInfo(SI.CLI, CI, ArgBeginIndex, CI->getNumArgOperands(),
-                           Callee, CI->getType(), false);
-
-  // We don't lower calls to __llvm_deoptimize as varargs, but as a
-  // regular call.
-  assert(!SI.CLI.IsVarArg && "Expected from populateCallLoweringInfo!");
-
-  auto DeoptBundle = *CI->getOperandBundle(LLVMContext::OB_deopt);
-
-  unsigned DefaultID = StatepointDirectives::DeoptBundleStatepointID;
-
-  auto SD = parseStatepointDirectivesFromAttrs(CI->getAttributes());
-  SI.ID = SD.StatepointID.getValueOr(DefaultID);
-  SI.NumPatchBytes = SD.NumPatchBytes.getValueOr(0);
 
-  SI.DeoptState =
-      ArrayRef<const Use>(DeoptBundle.Inputs.begin(), DeoptBundle.Inputs.end());
-  SI.StatepointFlags = static_cast<uint64_t>(StatepointFlags::None);
-
-  // NB! The GC arguments are specifically left empty.
-
-  if (SDValue ReturnVal = LowerAsSTATEPOINT(SI)) {
-    ReturnVal = lowerRangeToAssertZExt(DAG, *CI, ReturnVal);
-    setValue(CI, ReturnVal);
-  }
+  // We don't lower calls to __llvm_deoptimize as varargs, but as a regular
+  // call.
+  LowerCallSiteWithDeoptBundleImpl(CI, Callee, /* EHPadBB = */ nullptr,
+                                   /* VarArgDisallowed = */ true);
 }




More information about the llvm-commits mailing list