1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

[Statepoint] Reduce scope of usage of ImmutableStatepoint

Can't quite fully remove it yet as some more items need sunk the GCStatepointInst class from the wrapper, but we can at least reduce scope.
This commit is contained in:
Philip Reames 2020-05-27 18:56:50 -07:00
parent 6ee8cacb58
commit 3ef66ae8ae
3 changed files with 20 additions and 20 deletions

View File

@ -2796,7 +2796,7 @@ void SelectionDAGBuilder::visitInvoke(const InvokeInst &I) {
visitPatchpoint(I, EHPadBB);
break;
case Intrinsic::experimental_gc_statepoint:
LowerStatepoint(ImmutableStatepoint(&I), EHPadBB);
LowerStatepoint(cast<GCStatepointInst>(I), EHPadBB);
break;
case Intrinsic::wasm_rethrow_in_catch: {
// This is usually done in visitTargetIntrinsic, but this intrinsic is
@ -6637,7 +6637,7 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
visitPatchpoint(I);
return;
case Intrinsic::experimental_gc_statepoint:
LowerStatepoint(ImmutableStatepoint(&I));
LowerStatepoint(cast<GCStatepointInst>(I));
return;
case Intrinsic::experimental_gc_result:
visitGCResult(cast<GCResultInst>(I));

View File

@ -625,7 +625,7 @@ public:
// This function is responsible for the whole statepoint lowering process.
// It uniformly handles invoke and call statepoints.
void LowerStatepoint(ImmutableStatepoint ISP,
void LowerStatepoint(const GCStatepointInst &I,
const BasicBlock *EHPadBB = nullptr);
void LowerCallSiteWithDeoptBundle(const CallBase *Call, SDValue Callee,

View File

@ -804,9 +804,10 @@ SDValue SelectionDAGBuilder::LowerAsSTATEPOINT(
}
void
SelectionDAGBuilder::LowerStatepoint(ImmutableStatepoint ISP,
SelectionDAGBuilder::LowerStatepoint(const GCStatepointInst &I,
const BasicBlock *EHPadBB /*= nullptr*/) {
assert(ISP.getCall()->getCallingConv() != CallingConv::AnyReg &&
ImmutableStatepoint ISP(&I);
assert(I.getCallingConv() != CallingConv::AnyReg &&
"anyregcc is not supported on statepoints!");
#ifndef NDEBUG
@ -823,7 +824,7 @@ SelectionDAGBuilder::LowerStatepoint(ImmutableStatepoint ISP,
SDValue ActualCallee;
SDValue Callee = getValue(ISP.getCalledValue());
if (ISP.getNumPatchBytes() > 0) {
if (I.getNumPatchBytes() > 0) {
// If we've been asked to emit a nop sequence instead of a call instruction
// for this statepoint then don't lower the call target, but use a constant
// `undef` instead. Not lowering the call target lets statepoint clients
@ -835,9 +836,8 @@ SelectionDAGBuilder::LowerStatepoint(ImmutableStatepoint ISP,
}
StatepointLoweringInfo SI(DAG);
populateCallLoweringInfo(SI.CLI, ISP.getCall(),
ImmutableStatepoint::CallArgsBeginPos,
ISP.getNumCallArgs(), ActualCallee,
populateCallLoweringInfo(SI.CLI, &I, GCStatepointInst::CallArgsBeginPos,
I.getNumCallArgs(), ActualCallee,
ISP.getActualReturnType(), false /* IsPatchPoint */);
// There may be duplication in the gc.relocate list; such as two copies of
@ -865,10 +865,10 @@ SelectionDAGBuilder::LowerStatepoint(ImmutableStatepoint ISP,
}
SI.GCArgs = ArrayRef<const Use>(ISP.gc_args_begin(), ISP.gc_args_end());
SI.StatepointInstr = ISP.getInstruction();
SI.ID = ISP.getID();
SI.StatepointInstr = &I;
SI.ID = I.getID();
if (auto Opt = ISP.getCall()->getOperandBundle(LLVMContext::OB_deopt)) {
if (auto Opt = I.getOperandBundle(LLVMContext::OB_deopt)) {
assert(ISP.deopt_begin() == ISP.deopt_end() &&
"can't list both deopt operands and deopt bundle");
auto &Inputs = Opt->Inputs;
@ -876,7 +876,7 @@ SelectionDAGBuilder::LowerStatepoint(ImmutableStatepoint ISP,
} else {
SI.DeoptState = ArrayRef<const Use>(ISP.deopt_begin(), ISP.deopt_end());
}
if (auto Opt = ISP.getCall()->getOperandBundle(LLVMContext::OB_gc_transition)) {
if (auto Opt = I.getOperandBundle(LLVMContext::OB_gc_transition)) {
assert(ISP.gc_transition_args_begin() == ISP.gc_transition_args_end() &&
"can't list both gc_transition operands and bundle");
auto &Inputs = Opt->Inputs;
@ -886,8 +886,8 @@ SelectionDAGBuilder::LowerStatepoint(ImmutableStatepoint ISP,
ISP.gc_transition_args_end());
}
SI.StatepointFlags = ISP.getFlags();
SI.NumPatchBytes = ISP.getNumPatchBytes();
SI.StatepointFlags = I.getFlags();
SI.NumPatchBytes = I.getNumPatchBytes();
SI.EHPadBB = EHPadBB;
SDValue ReturnValue = LowerAsSTATEPOINT(SI);
@ -896,7 +896,7 @@ SelectionDAGBuilder::LowerStatepoint(ImmutableStatepoint ISP,
const GCResultInst *GCResult = ISP.getGCResult();
Type *RetTy = ISP.getActualReturnType();
if (!RetTy->isVoidTy() && GCResult) {
if (GCResult->getParent() != ISP.getCall()->getParent()) {
if (GCResult->getParent() != I.getParent()) {
// Result value will be used in a different basic block so we need to
// export it now. Default exporting mechanism will not work here because
// statepoint call has a different type than the actual call. It means
@ -908,22 +908,22 @@ SelectionDAGBuilder::LowerStatepoint(ImmutableStatepoint ISP,
unsigned Reg = FuncInfo.CreateRegs(RetTy);
RegsForValue RFV(*DAG.getContext(), DAG.getTargetLoweringInfo(),
DAG.getDataLayout(), Reg, RetTy,
ISP.getCall()->getCallingConv());
I.getCallingConv());
SDValue Chain = DAG.getEntryNode();
RFV.getCopyToRegs(ReturnValue, DAG, getCurSDLoc(), Chain, nullptr);
PendingExports.push_back(Chain);
FuncInfo.ValueMap[ISP.getInstruction()] = Reg;
FuncInfo.ValueMap[&I] = Reg;
} else {
// Result value will be used in a same basic block. Don't export it or
// perform any explicit register copies.
// We'll replace the actuall call node shortly. gc_result will grab
// this value.
setValue(ISP.getInstruction(), ReturnValue);
setValue(&I, ReturnValue);
}
} else {
// The token value is never used from here on, just generate a poison value
setValue(ISP.getInstruction(), DAG.getIntPtrConstant(-1, getCurSDLoc()));
setValue(&I, DAG.getIntPtrConstant(-1, getCurSDLoc()));
}
}