[llvm] r239493 - Stop returning a Use* from allocHungOffUses.

Pete Cooper peter_cooper at apple.com
Wed Jun 10 15:38:46 PDT 2015


Author: pete
Date: Wed Jun 10 17:38:46 2015
New Revision: 239493

URL: http://llvm.org/viewvc/llvm-project?rev=239493&view=rev
Log:
Stop returning a Use* from allocHungOffUses.

This always just set the User::OperandList which is now set
in that method instead of being returned.

Reviewed by Duncan Exon Smith.

Modified:
    llvm/trunk/include/llvm/IR/Instructions.h
    llvm/trunk/include/llvm/IR/User.h
    llvm/trunk/lib/IR/Instructions.cpp
    llvm/trunk/lib/IR/User.cpp

Modified: llvm/trunk/include/llvm/IR/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Instructions.h?rev=239493&r1=239492&r2=239493&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Instructions.h (original)
+++ llvm/trunk/include/llvm/IR/Instructions.h Wed Jun 10 17:38:46 2015
@@ -2234,7 +2234,7 @@ class PHINode : public Instruction {
     : Instruction(Ty, Instruction::PHI, nullptr, 0, InsertBefore),
       ReservedSpace(NumReservedValues) {
     setName(NameStr);
-    OperandList = allocHungoffUses(ReservedSpace);
+    allocHungoffUses(ReservedSpace);
   }
 
   PHINode(Type *Ty, unsigned NumReservedValues, const Twine &NameStr,
@@ -2242,14 +2242,14 @@ class PHINode : public Instruction {
     : Instruction(Ty, Instruction::PHI, nullptr, 0, InsertAtEnd),
       ReservedSpace(NumReservedValues) {
     setName(NameStr);
-    OperandList = allocHungoffUses(ReservedSpace);
+    allocHungoffUses(ReservedSpace);
   }
 protected:
   // allocHungoffUses - this is more complicated than the generic
   // User::allocHungoffUses, because we have to allocate Uses for the incoming
   // values and pointers to the incoming blocks, all in one allocation.
-  Use *allocHungoffUses(unsigned N) {
-    return User::allocHungoffUses(N, /* IsPhi */ true);
+  void allocHungoffUses(unsigned N) {
+    User::allocHungoffUses(N, /* IsPhi */ true);
   }
 
   PHINode *clone_impl() const override;

Modified: llvm/trunk/include/llvm/IR/User.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/User.h?rev=239493&r1=239492&r2=239493&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/User.h (original)
+++ llvm/trunk/include/llvm/IR/User.h Wed Jun 10 17:38:46 2015
@@ -57,7 +57,7 @@ protected:
   /// (with bottom bit set) to the User.
   /// \param IsPhi identifies callers which are phi nodes and which need
   /// N BasicBlock* allocated along with N
-  Use *allocHungoffUses(unsigned N, bool IsPhi = false);
+  void allocHungoffUses(unsigned N, bool IsPhi = false);
 
   /// \brief Grow the number of hung off uses.  Note that allocHungoffUses
   /// should be called if there are no uses.

Modified: llvm/trunk/lib/IR/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Instructions.cpp?rev=239493&r1=239492&r2=239493&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Instructions.cpp (original)
+++ llvm/trunk/lib/IR/Instructions.cpp Wed Jun 10 17:38:46 2015
@@ -85,9 +85,9 @@ const char *SelectInst::areInvalidOperan
 //===----------------------------------------------------------------------===//
 
 PHINode::PHINode(const PHINode &PN)
-  : Instruction(PN.getType(), Instruction::PHI,
-                allocHungoffUses(PN.getNumOperands()), PN.getNumOperands()),
-    ReservedSpace(PN.getNumOperands()) {
+    : Instruction(PN.getType(), Instruction::PHI, nullptr, PN.getNumOperands()),
+      ReservedSpace(PN.getNumOperands()) {
+  allocHungoffUses(PN.getNumOperands());
   std::copy(PN.op_begin(), PN.op_end(), op_begin());
   std::copy(PN.block_begin(), PN.block_end(), block_begin());
   SubclassOptionalData = PN.SubclassOptionalData;
@@ -168,9 +168,10 @@ LandingPadInst::LandingPadInst(Type *Ret
 }
 
 LandingPadInst::LandingPadInst(const LandingPadInst &LP)
-  : Instruction(LP.getType(), Instruction::LandingPad,
-                allocHungoffUses(LP.getNumOperands()), LP.getNumOperands()),
-    ReservedSpace(LP.getNumOperands()) {
+    : Instruction(LP.getType(), Instruction::LandingPad, nullptr,
+                  LP.getNumOperands()),
+      ReservedSpace(LP.getNumOperands()) {
+  allocHungoffUses(LP.getNumOperands());
   Use *OL = OperandList, *InOL = LP.OperandList;
   for (unsigned I = 0, E = ReservedSpace; I != E; ++I)
     OL[I] = InOL[I];
@@ -198,7 +199,7 @@ void LandingPadInst::init(Value *PersFn,
                           const Twine &NameStr) {
   ReservedSpace = NumReservedValues;
   NumOperands = 1;
-  OperandList = allocHungoffUses(ReservedSpace);
+  allocHungoffUses(ReservedSpace);
   Op<0>() = PersFn;
   setName(NameStr);
   setCleanup(false);
@@ -3262,7 +3263,7 @@ void SwitchInst::init(Value *Value, Basi
   assert(Value && Default && NumReserved);
   ReservedSpace = NumReserved;
   NumOperands = 2;
-  OperandList = allocHungoffUses(ReservedSpace);
+  allocHungoffUses(ReservedSpace);
 
   Op<0>() = Value;
   Op<1>() = Default;
@@ -3371,8 +3372,8 @@ void IndirectBrInst::init(Value *Address
          "Address of indirectbr must be a pointer");
   ReservedSpace = 1+NumDests;
   NumOperands = 1;
-  OperandList = allocHungoffUses(ReservedSpace);
-  
+  allocHungoffUses(ReservedSpace);
+
   Op<0>() = Address;
 }
 
@@ -3403,9 +3404,9 @@ IndirectBrInst::IndirectBrInst(Value *Ad
 }
 
 IndirectBrInst::IndirectBrInst(const IndirectBrInst &IBI)
-  : TerminatorInst(Type::getVoidTy(IBI.getContext()), Instruction::IndirectBr,
-                   allocHungoffUses(IBI.getNumOperands()),
-                   IBI.getNumOperands()) {
+    : TerminatorInst(Type::getVoidTy(IBI.getContext()), Instruction::IndirectBr,
+                     nullptr, IBI.getNumOperands()) {
+  allocHungoffUses(IBI.getNumOperands());
   Use *OL = OperandList, *InOL = IBI.OperandList;
   for (unsigned i = 0, E = IBI.getNumOperands(); i != E; ++i)
     OL[i] = InOL[i];

Modified: llvm/trunk/lib/IR/User.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/User.cpp?rev=239493&r1=239492&r2=239493&view=diff
==============================================================================
--- llvm/trunk/lib/IR/User.cpp (original)
+++ llvm/trunk/lib/IR/User.cpp Wed Jun 10 17:38:46 2015
@@ -40,7 +40,7 @@ void User::replaceUsesOfWith(Value *From
 //                         User allocHungoffUses Implementation
 //===----------------------------------------------------------------------===//
 
-Use *User::allocHungoffUses(unsigned N, bool IsPhi) {
+void User::allocHungoffUses(unsigned N, bool IsPhi) {
   // Allocate the array of Uses, followed by a pointer (with bottom bit set) to
   // the User.
   size_t size = N * sizeof(Use) + sizeof(Use::UserRef);
@@ -49,11 +49,9 @@ Use *User::allocHungoffUses(unsigned N,
   Use *Begin = static_cast<Use*>(::operator new(size));
   Use *End = Begin + N;
   (void) new(End) Use::UserRef(const_cast<User*>(this), 1);
-  Use *Uses = Use::initTags(Begin, End);
-  OperandList = Uses;
+  OperandList = Use::initTags(Begin, End);
   // Tag this operand list as being a hung off.
   HasHungOffUses = true;
-  return Uses;
 }
 
 void User::growHungoffUses(unsigned NewNumUses, bool IsPhi) {





More information about the llvm-commits mailing list