forked from OSchip/llvm-project
Reduce code duplication by extracting out a helper function; NFC
llvm-svn: 264355
This commit is contained in:
parent
731c67fed2
commit
fd3eaa8c5c
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue