diff options
| author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-03-24 22:51:49 +0000 |
|---|---|---|
| committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-03-24 22:51:49 +0000 |
| commit | fd3eaa8c5c044910463dad0a17bdfd080fc1383b (patch) | |
| tree | 526dc5e5d22a75d0224ff19e16f31f364c4cb5b2 /llvm/lib/CodeGen | |
| parent | 731c67fed25e8b10bb010572d4cf356bbb0e11d2 (diff) | |
| download | bcm5719-llvm-fd3eaa8c5c044910463dad0a17bdfd080fc1383b.tar.gz bcm5719-llvm-fd3eaa8c5c044910463dad0a17bdfd080fc1383b.zip | |
Reduce code duplication by extracting out a helper function; NFC
llvm-svn: 264355
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h | 4 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp | 47 |
2 files changed, 21 insertions, 30 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h index 4b222a9c435..f9c9909ad3e 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 39fea622f93..edec366aeaa 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<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::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<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); } |

