[llvm] r236564 - [Statepoint] Clean up Statepoint.h: accessor names.

Sanjoy Das sanjoy at playingwithpointers.com
Tue May 5 19:36:26 PDT 2015


Author: sanjoy
Date: Tue May  5 21:36:26 2015
New Revision: 236564

URL: http://llvm.org/viewvc/llvm-project?rev=236564&view=rev
Log:
[Statepoint] Clean up Statepoint.h: accessor names.

Use getFoo() as accessors consistently and some other naming changes.

Modified:
    llvm/trunk/include/llvm/IR/Statepoint.h
    llvm/trunk/lib/Analysis/ValueTracking.cpp
    llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
    llvm/trunk/lib/IR/AsmWriter.cpp
    llvm/trunk/lib/IR/Verifier.cpp
    llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
    llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp

Modified: llvm/trunk/include/llvm/IR/Statepoint.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Statepoint.h?rev=236564&r1=236563&r2=236564&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Statepoint.h (original)
+++ llvm/trunk/include/llvm/IR/Statepoint.h Tue May  5 21:36:26 2015
@@ -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<FunctionType>(
-        cast<PointerType>(actualCallee()->getType())->getElementType());
+        cast<PointerType>(getActualCallee()->getType())->getElementType());
     return FTy->getReturnType();
   }
+
   /// Number of arguments to be passed to the actual callee.
-  int numCallArgs() {
+  int getNumCallArgs() {
     return cast<ConstantInt>(StatepointCS.getArgument(1))->getZExtValue();
   }
+
   /// Number of additional arguments excluding those intended
   /// for garbage collection.
-  int numTotalVMSArgs() {
-    return cast<ConstantInt>(StatepointCS.getArgument(3 + numCallArgs()))->getZExtValue();
+  int getNumTotalVMSArgs() {
+    const Value *NumVMSArgs = StatepointCS.getArgument(3 + getNumCallArgs());
+    return cast<ConstantInt>(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<ExtractValueInst>(token)) {
-      return cast<Instruction>(token);
+    if (!isa<ExtractValueInst>(Token)) {
+      return cast<Instruction>(Token);
     }
 
     // This relocate is on exceptional path of an invoke statepoint
-    const BasicBlock *invokeBB =
-      cast<Instruction>(token)->getParent()->getUniquePredecessor();
+    const BasicBlock *InvokeBB =
+        cast<Instruction>(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<ConstantInt>(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<ConstantInt>(RelocateCS.getArgument(2))->getZExtValue();
   }
-  Value *basePtr() {
-    ImmutableCallSite CS(statepoint());
-    return *(CS.arg_begin() + basePtrIndex());
-  }
-  Value *derivedPtr() {
-    ImmutableCallSite CS(statepoint());
-    return *(CS.arg_begin() + derivedPtrIndex());
+
+  Value *getBasePtr() {
+    ImmutableCallSite CS(getStatepoint());
+    return *(CS.arg_begin() + getBasePtrIndex());
+  }
+
+  Value *getDerivedPtr() {
+    ImmutableCallSite CS(getStatepoint());
+    return *(CS.arg_begin() + getDerivedPtrIndex());
   }
 };
 
@@ -265,22 +272,19 @@ std::vector<GCRelocateOperands>
   StatepointBase<InstructionTy, ValueTy, CallSiteTy>::
     getRelocates(ImmutableStatepoint &IS) {
 
-  std::vector<GCRelocateOperands> res;
+  std::vector<GCRelocateOperands> 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<GCRelocateOperands>
   // Search for extract value from landingpad instruction to which
   // gc relocates will be attached
   for (const User *LandingPadUser : LandingPad->users()) {
-    if (!isa<ExtractValueInst>(LandingPadUser)) {
+    if (!isa<ExtractValueInst>(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

Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=236564&r1=236563&r2=236564&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Tue May  5 21:36:26 2015
@@ -2957,7 +2957,8 @@ static bool isDereferenceablePointer(con
   if (const IntrinsicInst *I = dyn_cast<IntrinsicInst>(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<AddrSpaceCastInst>(V))

Modified: llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp?rev=236564&r1=236563&r2=236564&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp (original)
+++ llvm/trunk/lib/CodeGen/CodeGenPrepare.cpp Tue May  5 21:36:26 2015
@@ -531,8 +531,8 @@ static void computeBaseDerivedRelocateMa
   for (auto &U : AllRelocateCalls) {
     GCRelocateOperands ThisRelocate(U);
     IntrinsicInst *I = cast<IntrinsicInst>(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
     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<GetElementPtrInst>(ThisRelocate.derivedPtr());
+    Value *Base = ThisRelocate.getBasePtr();
+    auto Derived = dyn_cast<GetElementPtrInst>(ThisRelocate.getDerivedPtr());
     if (!Derived || Derived->getPointerOperand() != Base)
       continue;
 

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp?rev=236564&r1=236563&r2=236564&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/StatepointLowering.cpp Tue May  5 21:36:26 2015
@@ -229,7 +229,7 @@ lowerCallFromStatepoint(ImmutableStatepo
 
   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<ConstantSDNode>(ActualCallee.getNode()))
@@ -245,12 +245,12 @@ lowerCallFromStatepoint(ImmutableStatepo
   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(ImmutableStatepo
       // 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 getIncomingStatepointGCValue
   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(Smal
   // 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(
     // different, and getValue() will use CopyFromReg of the wrong type,
     // which is always i32 in our case.
     PointerType *CalleeType =
-        cast<PointerType>(ImmutableStatepoint(I).actualCallee()->getType());
+        cast<PointerType>(ImmutableStatepoint(I).getActualCallee()->getType());
     Type *RetTy =
         cast<FunctionType>(CalleeType->getElementType())->getReturnType();
     SDValue CopyFromReg = getCopyFromRegs(I, RetTy);
@@ -694,7 +694,7 @@ void SelectionDAGBuilder::visitGCRelocat
 #endif
 
   GCRelocateOperands relocateOpers(&CI);
-  SDValue SD = getValue(relocateOpers.derivedPtr());
+  SDValue SD = getValue(relocateOpers.getDerivedPtr());
 
   if (isa<ConstantSDNode>(SD) || isa<FrameIndexSDNode>(SD)) {
     // We didn't need to spill these special cases (constants and allocas).

Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=236564&r1=236563&r2=236564&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Tue May  5 21:36:26 2015
@@ -2654,9 +2654,9 @@ void AssemblyWriter::printGCRelocateComm
   GCRelocateOperands GCOps(cast<Instruction>(&V));
 
   Out << " ; (";
-  writeOperand(GCOps.basePtr(), false);
+  writeOperand(GCOps.getBasePtr(), false);
   Out << ", ";
-  writeOperand(GCOps.derivedPtr(), false);
+  writeOperand(GCOps.getDerivedPtr(), false);
   Out << ")";
 }
 

Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=236564&r1=236563&r2=236564&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Tue May  5 21:36:26 2015
@@ -3315,7 +3315,7 @@ void Verifier::visitIntrinsicFunctionCal
     // 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::visitIntrinsicFunctionCal
 
     // 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;
   }

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=236564&r1=236563&r2=236564&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Tue May  5 21:36:26 2015
@@ -1196,7 +1196,7 @@ Instruction *InstCombiner::visitCallInst
     // 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.

Modified: llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp?rev=236564&r1=236563&r2=236564&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp Tue May  5 21:36:26 2015
@@ -1336,7 +1336,8 @@ insertRelocationStores(iterator_range<Va
     }
 
     GCRelocateOperands relocateOperands(relocatedValue);
-    Value *originalValue = const_cast<Value *>(relocateOperands.derivedPtr());
+    Value *originalValue =
+        const_cast<Value *>(relocateOperands.getDerivedPtr());
     assert(allocaMap.count(originalValue));
     Value *alloca = allocaMap[originalValue];
 





More information about the llvm-commits mailing list