diff --git a/include/llvm/IR/Statepoint.h b/include/llvm/IR/Statepoint.h index 257eba31cb4..e3e0701312f 100644 --- a/include/llvm/IR/Statepoint.h +++ b/include/llvm/IR/Statepoint.h @@ -69,24 +69,26 @@ class StatepointBase { } /// Return the value actually being called or invoked. - ValueTy *actualCallee() { - return StatepointCS.getArgument(0); - } + ValueTy *getActualCallee() { return StatepointCS.getArgument(0); } + /// Return the type of the value returned by the call underlying the /// statepoint. - Type *actualReturnType() { + Type *getActualReturnType() { auto *FTy = cast( - cast(actualCallee()->getType())->getElementType()); + cast(getActualCallee()->getType())->getElementType()); return FTy->getReturnType(); } + /// Number of arguments to be passed to the actual callee. - int numCallArgs() { + int getNumCallArgs() { return cast(StatepointCS.getArgument(1))->getZExtValue(); } + /// Number of additional arguments excluding those intended /// for garbage collection. - int numTotalVMSArgs() { - return cast(StatepointCS.getArgument(3 + numCallArgs()))->getZExtValue(); + int getNumTotalVMSArgs() { + const Value *NumVMSArgs = StatepointCS.getArgument(3 + getNumCallArgs()); + return cast(NumVMSArgs)->getZExtValue(); } int callArgsBeginOffset() { return 3; } @@ -98,7 +100,7 @@ class StatepointBase { return StatepointCS.arg_begin() + Offset; } typename CallSiteTy::arg_iterator call_args_end() { - int Offset = callArgsBeginOffset() + numCallArgs(); + int Offset = callArgsBeginOffset() + getNumCallArgs(); assert(Offset <= (int)StatepointCS.arg_size()); return StatepointCS.arg_begin() + Offset; } @@ -112,7 +114,7 @@ class StatepointBase { return call_args_end(); } typename CallSiteTy::arg_iterator vm_state_end() { - int Offset = 3 + numCallArgs() + 1 + numTotalVMSArgs(); + int Offset = 3 + getNumCallArgs() + 1 + getNumTotalVMSArgs(); assert(Offset <= (int)StatepointCS.arg_size()); return StatepointCS.arg_begin() + Offset; } @@ -151,7 +153,7 @@ class StatepointBase { /// include incorrect length prefixes for variable length sections or /// illegal values for parameters. void verify() { - assert(numCallArgs() >= 0 && + assert(getNumCallArgs() >= 0 && "number of arguments to actually callee can't be negative"); // The internal asserts in the iterator accessors do the rest. @@ -220,43 +222,48 @@ class GCRelocateOperands { } /// The statepoint with which this gc.relocate is associated. - const Instruction *statepoint() { - const Value *token = RelocateCS.getArgument(0); + const Instruction *getStatepoint() { + const Value *Token = RelocateCS.getArgument(0); // This takes care both of relocates for call statepoints and relocates // on normal path of invoke statepoint. - if (!isa(token)) { - return cast(token); + if (!isa(Token)) { + return cast(Token); } // This relocate is on exceptional path of an invoke statepoint - const BasicBlock *invokeBB = - cast(token)->getParent()->getUniquePredecessor(); + const BasicBlock *InvokeBB = + cast(Token)->getParent()->getUniquePredecessor(); - assert(invokeBB && "safepoints should have unique landingpads"); - assert(invokeBB->getTerminator() && "safepoint block should be well formed"); - assert(isStatepoint(invokeBB->getTerminator())); + assert(InvokeBB && "safepoints should have unique landingpads"); + assert(InvokeBB->getTerminator() && + "safepoint block should be well formed"); + assert(isStatepoint(InvokeBB->getTerminator())); - return invokeBB->getTerminator(); + return InvokeBB->getTerminator(); } + /// The index into the associate statepoint's argument list /// which contains the base pointer of the pointer whose /// relocation this gc.relocate describes. - unsigned basePtrIndex() { + unsigned getBasePtrIndex() { return cast(RelocateCS.getArgument(1))->getZExtValue(); } + /// The index into the associate statepoint's argument list which /// contains the pointer whose relocation this gc.relocate describes. - unsigned derivedPtrIndex() { + unsigned getDerivedPtrIndex() { return cast(RelocateCS.getArgument(2))->getZExtValue(); } - Value *basePtr() { - ImmutableCallSite CS(statepoint()); - return *(CS.arg_begin() + basePtrIndex()); + + Value *getBasePtr() { + ImmutableCallSite CS(getStatepoint()); + return *(CS.arg_begin() + getBasePtrIndex()); } - Value *derivedPtr() { - ImmutableCallSite CS(statepoint()); - return *(CS.arg_begin() + derivedPtrIndex()); + + Value *getDerivedPtr() { + ImmutableCallSite CS(getStatepoint()); + return *(CS.arg_begin() + getDerivedPtrIndex()); } }; @@ -265,22 +272,19 @@ std::vector StatepointBase:: getRelocates(ImmutableStatepoint &IS) { - std::vector res; + std::vector Result; ImmutableCallSite StatepointCS = IS.getCallSite(); // Search for relocated pointers. Note that working backwards from the // gc_relocates ensures that we only get pairs which are actually relocated // and used after the statepoint. - for (const User *U : StatepointCS.getInstruction()->users()) { - if (isGCRelocate(U)) { - res.push_back(GCRelocateOperands(U)); - } - } + for (const User *U : StatepointCS.getInstruction()->users()) + if (isGCRelocate(U)) + Result.push_back(GCRelocateOperands(U)); - if (!StatepointCS.isInvoke()) { - return res; - } + if (!StatepointCS.isInvoke()) + return Result; // We need to scan thorough exceptional relocations if it is invoke statepoint LandingPadInst *LandingPad = @@ -289,19 +293,17 @@ std::vector // Search for extract value from landingpad instruction to which // gc relocates will be attached for (const User *LandingPadUser : LandingPad->users()) { - if (!isa(LandingPadUser)) { + if (!isa(LandingPadUser)) continue; - } // gc relocates should be attached to this extract value - for (const User *U : LandingPadUser->users()) { - if (isGCRelocate(U)) { - res.push_back(GCRelocateOperands(U)); - } - } + for (const User *U : LandingPadUser->users()) + if (isGCRelocate(U)) + Result.push_back(GCRelocateOperands(U)); } - return res; + return Result; } } + #endif diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index 52a8c69688f..8eb2e68bc48 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -2957,7 +2957,8 @@ static bool isDereferenceablePointer(const Value *V, const DataLayout &DL, if (const IntrinsicInst *I = dyn_cast(V)) if (I->getIntrinsicID() == Intrinsic::experimental_gc_relocate) { GCRelocateOperands RelocateInst(I); - return isDereferenceablePointer(RelocateInst.derivedPtr(), DL, Visited); + return isDereferenceablePointer(RelocateInst.getDerivedPtr(), DL, + Visited); } if (const AddrSpaceCastInst *ASC = dyn_cast(V)) diff --git a/lib/CodeGen/CodeGenPrepare.cpp b/lib/CodeGen/CodeGenPrepare.cpp index 35376e162d3..49836254356 100644 --- a/lib/CodeGen/CodeGenPrepare.cpp +++ b/lib/CodeGen/CodeGenPrepare.cpp @@ -531,8 +531,8 @@ static void computeBaseDerivedRelocateMap( for (auto &U : AllRelocateCalls) { GCRelocateOperands ThisRelocate(U); IntrinsicInst *I = cast(U); - auto K = std::make_pair(ThisRelocate.basePtrIndex(), - ThisRelocate.derivedPtrIndex()); + auto K = std::make_pair(ThisRelocate.getBasePtrIndex(), + ThisRelocate.getDerivedPtrIndex()); RelocateIdxMap.insert(std::make_pair(K, I)); } for (auto &Item : RelocateIdxMap) { @@ -581,15 +581,15 @@ simplifyRelocatesOffABase(IntrinsicInst *RelocatedBase, GCRelocateOperands MasterRelocate(RelocatedBase); GCRelocateOperands ThisRelocate(ToReplace); - assert(ThisRelocate.basePtrIndex() == MasterRelocate.basePtrIndex() && + assert(ThisRelocate.getBasePtrIndex() == MasterRelocate.getBasePtrIndex() && "Not relocating a derived object of the original base object"); - if (ThisRelocate.basePtrIndex() == ThisRelocate.derivedPtrIndex()) { + if (ThisRelocate.getBasePtrIndex() == ThisRelocate.getDerivedPtrIndex()) { // A duplicate relocate call. TODO: coalesce duplicates. continue; } - Value *Base = ThisRelocate.basePtr(); - auto Derived = dyn_cast(ThisRelocate.derivedPtr()); + Value *Base = ThisRelocate.getBasePtr(); + auto Derived = dyn_cast(ThisRelocate.getDerivedPtr()); if (!Derived || Derived->getPointerOperand() != Base) continue; diff --git a/lib/CodeGen/SelectionDAG/StatepointLowering.cpp b/lib/CodeGen/SelectionDAG/StatepointLowering.cpp index 9193f316a61..521e27334ff 100644 --- a/lib/CodeGen/SelectionDAG/StatepointLowering.cpp +++ b/lib/CodeGen/SelectionDAG/StatepointLowering.cpp @@ -229,7 +229,7 @@ lowerCallFromStatepoint(ImmutableStatepoint ISP, MachineBasicBlock *LandingPad, ImmutableCallSite CS(ISP.getCallSite()); - SDValue ActualCallee = Builder.getValue(ISP.actualCallee()); + SDValue ActualCallee = Builder.getValue(ISP.getActualCallee()); // Handle immediate and symbolic callees. if (auto *ConstCallee = dyn_cast(ActualCallee.getNode())) @@ -245,12 +245,12 @@ lowerCallFromStatepoint(ImmutableStatepoint ISP, MachineBasicBlock *LandingPad, assert(CS.getCallingConv() != CallingConv::AnyReg && "anyregcc is not supported on statepoints!"); - Type *DefTy = ISP.actualReturnType(); + Type *DefTy = ISP.getActualReturnType(); bool HasDef = !DefTy->isVoidTy(); SDValue ReturnValue, CallEndVal; std::tie(ReturnValue, CallEndVal) = Builder.lowerCallOperands( - ISP.getCallSite(), ISP.callArgsBeginOffset(), ISP.numCallArgs(), + ISP.getCallSite(), ISP.callArgsBeginOffset(), ISP.getNumCallArgs(), ActualCallee, DefTy, LandingPad, false /* IsPatchPoint */); SDNode *CallEnd = CallEndVal.getNode(); @@ -286,10 +286,10 @@ lowerCallFromStatepoint(ImmutableStatepoint ISP, MachineBasicBlock *LandingPad, // register with correct type and save value into it manually. // TODO: To eliminate this problem we can remove gc.result intrinsics // completelly and make statepoint call to return a tuple. - unsigned Reg = Builder.FuncInfo.CreateRegs(ISP.actualReturnType()); + unsigned Reg = Builder.FuncInfo.CreateRegs(ISP.getActualReturnType()); RegsForValue RFV(*Builder.DAG.getContext(), Builder.DAG.getTargetLoweringInfo(), Reg, - ISP.actualReturnType()); + ISP.getActualReturnType()); SDValue Chain = Builder.DAG.getEntryNode(); RFV.getCopyToRegs(ReturnValue, Builder.DAG, Builder.getCurSDLoc(), Chain, @@ -325,8 +325,8 @@ static void getIncomingStatepointGCValues( for (GCRelocateOperands relocateOpers : StatepointSite.getRelocates(StatepointSite)) { Relocs.push_back(relocateOpers.getUnderlyingCallSite().getInstruction()); - Bases.push_back(relocateOpers.basePtr()); - Ptrs.push_back(relocateOpers.derivedPtr()); + Bases.push_back(relocateOpers.getBasePtr()); + Ptrs.push_back(relocateOpers.getDerivedPtr()); } // Remove any redundant llvm::Values which map to the same SDValue as another @@ -482,7 +482,7 @@ static void lowerStatepointMetaArgs(SmallVectorImpl &Ops, // First, prefix the list with the number of unique values to be // lowered. Note that this is the number of *Values* not the // number of SDValues required to lower them. - const int NumVMSArgs = StatepointSite.numTotalVMSArgs(); + const int NumVMSArgs = StatepointSite.getNumTotalVMSArgs(); Ops.push_back( Builder.DAG.getTargetConstant(StackMaps::ConstantOp, Builder.getCurSDLoc(), MVT::i64)); @@ -675,7 +675,7 @@ void SelectionDAGBuilder::visitGCResult(const CallInst &CI) { // different, and getValue() will use CopyFromReg of the wrong type, // which is always i32 in our case. PointerType *CalleeType = - cast(ImmutableStatepoint(I).actualCallee()->getType()); + cast(ImmutableStatepoint(I).getActualCallee()->getType()); Type *RetTy = cast(CalleeType->getElementType())->getReturnType(); SDValue CopyFromReg = getCopyFromRegs(I, RetTy); @@ -694,7 +694,7 @@ void SelectionDAGBuilder::visitGCRelocate(const CallInst &CI) { #endif GCRelocateOperands relocateOpers(&CI); - SDValue SD = getValue(relocateOpers.derivedPtr()); + SDValue SD = getValue(relocateOpers.getDerivedPtr()); if (isa(SD) || isa(SD)) { // We didn't need to spill these special cases (constants and allocas). diff --git a/lib/IR/AsmWriter.cpp b/lib/IR/AsmWriter.cpp index 6b575212301..304221af400 100644 --- a/lib/IR/AsmWriter.cpp +++ b/lib/IR/AsmWriter.cpp @@ -2654,9 +2654,9 @@ void AssemblyWriter::printGCRelocateComment(const Value &V) { GCRelocateOperands GCOps(cast(&V)); Out << " ; ("; - writeOperand(GCOps.basePtr(), false); + writeOperand(GCOps.getBasePtr(), false); Out << ", "; - writeOperand(GCOps.derivedPtr(), false); + writeOperand(GCOps.getDerivedPtr(), false); Out << ")"; } diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index 1e1c4942576..16f343aee56 100644 --- a/lib/IR/Verifier.cpp +++ b/lib/IR/Verifier.cpp @@ -3315,7 +3315,7 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) { // Verify rest of the relocate arguments GCRelocateOperands ops(&CI); - ImmutableCallSite StatepointCS(ops.statepoint()); + ImmutableCallSite StatepointCS(ops.getStatepoint()); // Both the base and derived must be piped through the safepoint Value* Base = CI.getArgOperand(1); @@ -3362,7 +3362,7 @@ void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) { // Assert that the result type matches the type of the relocated pointer GCRelocateOperands Operands(&CI); - Assert(Operands.derivedPtr()->getType() == CI.getType(), + Assert(Operands.getDerivedPtr()->getType() == CI.getType(), "gc.relocate: relocating a pointer shouldn't change its type", &CI); break; } diff --git a/lib/Transforms/InstCombine/InstCombineCalls.cpp b/lib/Transforms/InstCombine/InstCombineCalls.cpp index 2f83cc8961b..1a5ef00cdb6 100644 --- a/lib/Transforms/InstCombine/InstCombineCalls.cpp +++ b/lib/Transforms/InstCombine/InstCombineCalls.cpp @@ -1196,7 +1196,7 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) { // facts about the relocate value, while being careful to // preserve relocation semantics. GCRelocateOperands Operands(II); - Value *DerivedPtr = Operands.derivedPtr(); + Value *DerivedPtr = Operands.getDerivedPtr(); // Remove the relocation if unused, note that this check is required // to prevent the cases below from looping forever. diff --git a/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp index 3da3559ca1f..9cb0748c515 100644 --- a/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ b/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -1336,7 +1336,8 @@ insertRelocationStores(iterator_range gcRelocs, } GCRelocateOperands relocateOperands(relocatedValue); - Value *originalValue = const_cast(relocateOperands.derivedPtr()); + Value *originalValue = + const_cast(relocateOperands.getDerivedPtr()); assert(allocaMap.count(originalValue)); Value *alloca = allocaMap[originalValue];