[llvm] 98a87c6 - [Statepoint] Reduce scope of usage of ImmutableStatepoint

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Wed May 27 18:57:51 PDT 2020


Author: Philip Reames
Date: 2020-05-27T18:57:42-07:00
New Revision: 98a87c65a35335473cf7c233cdb312892fc771a3

URL: https://github.com/llvm/llvm-project/commit/98a87c65a35335473cf7c233cdb312892fc771a3
DIFF: https://github.com/llvm/llvm-project/commit/98a87c65a35335473cf7c233cdb312892fc771a3.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
    llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 559d166e372d..d40f7f92c4cb 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<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));

diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
index 0924939cc310..f0b7fb0d5229 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 9a35bd41d116..acb68405470c 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<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 
diff erent basic block so we need to
       // export it now.  Default exporting mechanism will not work here because
       // statepoint call has a 
diff erent 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()));
   }
 }
 


        


More information about the llvm-commits mailing list