From: Sanjoy Das Date: Thu, 24 Mar 2016 22:51:49 +0000 (+0000) Subject: Reduce code duplication by extracting out a helper function; NFC X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fd3eaa8c5c044910463dad0a17bdfd080fc1383b;p=platform%2Fupstream%2Fllvm.git Reduce code duplication by extracting out a helper function; NFC llvm-svn: 264355 --- diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h index 4b222a9..f9c9909 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h @@ -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); diff --git a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp index 39fea62..edec366 100644 --- a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp @@ -821,13 +821,15 @@ SelectionDAGBuilder::LowerStatepoint(ImmutableStatepoint ISP, } } -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::LowerCallSiteWithDeoptBundle( SI.StatepointFlags = static_cast(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::LowerCallSiteWithDeoptBundle( } } +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::visitGCRelocate(const GCRelocateInst &Relocate) { 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(DeoptBundle.Inputs.begin(), DeoptBundle.Inputs.end()); - SI.StatepointFlags = static_cast(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); }