[llvm] 58beb76 - [Statepoint] Convert a few more isStatepoint calls to idiomatic isa/cast

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu May 28 11:35:45 PDT 2020


Author: Philip Reames
Date: 2020-05-28T11:35:36-07:00
New Revision: 58beb76b7bd2f7caa1df461b9db6629521c3b60b

URL: https://github.com/llvm/llvm-project/commit/58beb76b7bd2f7caa1df461b9db6629521c3b60b
DIFF: https://github.com/llvm/llvm-project/commit/58beb76b7bd2f7caa1df461b9db6629521c3b60b.diff

LOG: [Statepoint] Convert a few more isStatepoint calls to idiomatic isa/cast

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.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/Statepoint.h b/llvm/include/llvm/IR/Statepoint.h
index ce3d5a655df8..5ca6939ce773 100644
--- a/llvm/include/llvm/IR/Statepoint.h
+++ b/llvm/include/llvm/IR/Statepoint.h
@@ -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 @@ class GCProjectionInst : public IntrinsicInst {
   }
 
   /// 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 @@ class GCProjectionInst : public IntrinsicInst {
     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());
   }
 };
 

diff  --git a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
index 664f56523d9b..d826fe7b0936 100644
--- a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
@@ -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 
diff erent 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
     // 
diff erent, 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());

diff  --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 388fc72417ad..e0d28b35efdd 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -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);


        


More information about the llvm-commits mailing list