[Statepoint] Convert a few more isStatepoint calls to idiomatic isa/cast
authorPhilip Reames <listmail@philipreames.com>
Thu, 28 May 2020 18:28:58 +0000 (11:28 -0700)
committerPhilip Reames <listmail@philipreames.com>
Thu, 28 May 2020 18:35:36 +0000 (11:35 -0700)
I'd apparently only grepped in the lib directories and missed a few used in the Statepoint header itself.  Beyond simple mechanical cleanup, changed the type of one routine to reflect the fact it also returns a statepoint.

llvm/include/llvm/IR/Statepoint.h
llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
llvm/lib/IR/Verifier.cpp

index ce3d5a6..5ca6939 100644 (file)
@@ -147,11 +147,11 @@ class StatepointBase {
 
 protected:
   explicit StatepointBase(InstructionTy *I) {
-    StatepointCall = isStatepoint(I) ? cast<CallTy>(I) : nullptr;
+    StatepointCall = dyn_cast<GCStatepointInst>(I);
   }
 
   explicit StatepointBase(CallTy *Call) {
-    StatepointCall = isStatepoint(Call) ? Call : nullptr;
+    StatepointCall = dyn_cast<GCStatepointInst>(Call);
   }
 
 public:
@@ -369,15 +369,13 @@ public:
   }
 
   /// The statepoint with which this gc.relocate is associated.
-  const CallBase *getStatepoint() const {
+  const GCStatepointInst *getStatepoint() const {
     const Value *Token = getArgOperand(0);
 
     // This takes care both of relocates for call statepoints and relocates
     // on normal path of invoke statepoint.
-    if (!isa<LandingPadInst>(Token)) {
-      assert(isStatepoint(Token));
-      return cast<CallBase>(Token);
-    }
+    if (!isa<LandingPadInst>(Token))
+      return cast<GCStatepointInst>(Token);
 
     // This relocate is on exceptional path of an invoke statepoint
     const BasicBlock *InvokeBB =
@@ -386,9 +384,8 @@ public:
     assert(InvokeBB && "safepoints should have unique landingpads");
     assert(InvokeBB->getTerminator() &&
            "safepoint block should be well formed");
-    assert(isStatepoint(InvokeBB->getTerminator()));
 
-    return cast<CallBase>(InvokeBB->getTerminator());
+    return cast<GCStatepointInst>(InvokeBB->getTerminator());
   }
 };
 
index 664f565..d826fe7 100644 (file)
@@ -970,7 +970,7 @@ void SelectionDAGBuilder::LowerCallSiteWithDeoptBundle(
 void SelectionDAGBuilder::visitGCResult(const GCResultInst &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.
-  const Instruction *I = CI.getStatepoint();
+  const GCStatepointInst *I = CI.getStatepoint();
 
   if (I->getParent() != CI.getParent()) {
     // Statepoint is in different basic block so we should have stored call
@@ -979,7 +979,7 @@ void SelectionDAGBuilder::visitGCResult(const GCResultInst &CI) {
     // register because statepoint and actual call return types can be
     // different, and getValue() will use CopyFromReg of the wrong type,
     // which is always i32 in our case.
-    Type *RetTy = cast<GCStatepointInst>(I)->getActualReturnType();
+    Type *RetTy = I->getActualReturnType();
     SDValue CopyFromReg = getCopyFromRegs(I, RetTy);
 
     assert(CopyFromReg.getNode());
index 388fc72..e0d28b3 100644 (file)
@@ -4733,7 +4733,7 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
 
     // Verify rest of the relocate arguments.
     const CallBase &StatepointCall =
-        *cast<CallBase>(cast<GCRelocateInst>(Call).getStatepoint());
+      *cast<GCRelocateInst>(Call).getStatepoint();
 
     // Both the base and derived must be piped through the safepoint.
     Value *Base = Call.getArgOperand(1);