[llvm-commits] [llvm] r51945 - in /llvm/trunk: include/llvm/Instructions.h lib/VMCore/Instructions.cpp

Matthijs Kooijman matthijs at stdin.nl
Wed Jun 4 09:14:12 PDT 2008


Author: matthijs
Date: Wed Jun  4 11:14:12 2008
New Revision: 51945

URL: http://llvm.org/viewvc/llvm-project?rev=51945&view=rev
Log:
Add a Name parameter to two of the init methods of GetElementPointer to make the name setting more consistent.

Modified:
    llvm/trunk/include/llvm/Instructions.h
    llvm/trunk/lib/VMCore/Instructions.cpp

Modified: llvm/trunk/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=51945&r1=51944&r2=51945&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Instructions.h (original)
+++ llvm/trunk/include/llvm/Instructions.h Wed Jun  4 11:14:12 2008
@@ -379,8 +379,8 @@
 ///
 class GetElementPtrInst : public Instruction {
   GetElementPtrInst(const GetElementPtrInst &GEPI);
-  void init(Value *Ptr, Value* const *Idx, unsigned NumIdx);
-  void init(Value *Ptr, Value *Idx);
+  void init(Value *Ptr, Value* const *Idx, unsigned NumIdx, const std::string &Name);
+  void init(Value *Ptr, Value *Idx, const std::string &Name);
 
   template<typename InputIterator>
   void init(Value *Ptr, InputIterator IdxBegin, InputIterator IdxEnd,
@@ -392,14 +392,12 @@
     
     if (NumIdx > 0) {
       // This requires that the iterator points to contiguous memory.
-      init(Ptr, &*IdxBegin, NumIdx); // FIXME: for the general case
+      init(Ptr, &*IdxBegin, NumIdx, Name); // FIXME: for the general case
                                      // we have to build an array here
     }
     else {
-      init(Ptr, 0, NumIdx);
+      init(Ptr, 0, NumIdx, Name);
     }
-
-    setName(Name);
   }
 
   /// getIndexedType - Returns the type of the element that would be loaded with

Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=51945&r1=51944&r2=51945&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Wed Jun  4 11:14:12 2008
@@ -992,20 +992,24 @@
   return cast<PointerType>(Val->getType())->getAddressSpace();
 }
 
-void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx) {
+void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx, const std::string &Name) {
   assert(NumOperands == 1+NumIdx && "NumOperands not initialized?");
   Use *OL = OperandList;
   OL[0] = Ptr;
 
   for (unsigned i = 0; i != NumIdx; ++i)
     OL[i+1] = Idx[i];
+
+  setName(Name);
 }
 
-void GetElementPtrInst::init(Value *Ptr, Value *Idx) {
+void GetElementPtrInst::init(Value *Ptr, Value *Idx, const std::string &Name) {
   assert(NumOperands == 2 && "NumOperands not initialized?");
   Use *OL = OperandList;
   OL[0] = Ptr;
   OL[1] = Idx;
+
+  setName(Name);
 }
 
 GetElementPtrInst::GetElementPtrInst(const GetElementPtrInst &GEPI)
@@ -1026,8 +1030,7 @@
                 GetElementPtr,
                 OperandTraits<GetElementPtrInst>::op_end(this) - 2,
                 2, InBe) {
-  init(Ptr, Idx);
-  setName(Name);
+  init(Ptr, Idx, Name);
 }
 
 GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
@@ -1037,8 +1040,7 @@
                 GetElementPtr,
                 OperandTraits<GetElementPtrInst>::op_end(this) - 2,
                 2, IAE) {
-  init(Ptr, Idx);
-  setName(Name);
+  init(Ptr, Idx, Name);
 }
 
 // getIndexedType - Returns the type of the element that would be loaded with





More information about the llvm-commits mailing list