diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp index 559d166e372df..d40f7f92c4cb0 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp @@ -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(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(I)); return; case Intrinsic::experimental_gc_result: visitGCResult(cast(I)); diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h index 0924939cc3106..f0b7fb0d52299 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h @@ -625,7 +625,7 @@ class SelectionDAGBuilder { // 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, diff --git a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp index 9a35bd41d1167..acb68405470ca 100644 --- a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp @@ -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(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(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())); } }