From 58beb76b7bd2f7caa1df461b9db6629521c3b60b Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Thu, 28 May 2020 11:28:58 -0700 Subject: [PATCH] [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. --- llvm/include/llvm/IR/Statepoint.h | 15 ++++++--------- llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp | 4 ++-- llvm/lib/IR/Verifier.cpp | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/llvm/include/llvm/IR/Statepoint.h b/llvm/include/llvm/IR/Statepoint.h index ce3d5a6..5ca6939 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(I) : nullptr; + StatepointCall = dyn_cast(I); } explicit StatepointBase(CallTy *Call) { - StatepointCall = isStatepoint(Call) ? Call : nullptr; + StatepointCall = dyn_cast(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(Token)) { - assert(isStatepoint(Token)); - return cast(Token); - } + if (!isa(Token)) + return cast(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(InvokeBB->getTerminator()); + return cast(InvokeBB->getTerminator()); } }; diff --git a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp index 664f565..d826fe7 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 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(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 388fc72..e0d28b3 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(cast(Call).getStatepoint()); + *cast(Call).getStatepoint(); // Both the base and derived must be piped through the safepoint. Value *Base = Call.getArgOperand(1); -- 2.7.4