diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h index 99ed63ba6d3..7812cdb5913 100644 --- a/include/llvm/Instructions.h +++ b/include/llvm/Instructions.h @@ -336,7 +336,7 @@ class GetElementPtrInst : public Instruction { for (unsigned i = 0, E = NumOperands; i != E; ++i) OL[i].init(GEPIOL[i], this); } - void init(Value *Ptr, const std::vector &Idx); + void init(Value *Ptr, Value* const *Idx, unsigned NumIdx); void init(Value *Ptr, Value *Idx0, Value *Idx1); void init(Value *Ptr, Value *Idx); public: diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index ccd25de022f..d830dfd685f 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -684,12 +684,12 @@ static inline const Type *checkType(const Type *Ty) { return Ty; } -void GetElementPtrInst::init(Value *Ptr, const std::vector &Idx) { - NumOperands = 1+Idx.size(); +void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx) { + NumOperands = 1+NumIdx; Use *OL = OperandList = new Use[NumOperands]; OL[0].init(Ptr, this); - for (unsigned i = 0, e = Idx.size(); i != e; ++i) + for (unsigned i = 0; i != NumIdx; ++i) OL[i+1].init(Idx[i], this); } @@ -713,7 +713,7 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, const std::vector &Idx, : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), Idx, true))), GetElementPtr, 0, 0, Name, InBe) { - init(Ptr, Idx); + init(Ptr, &Idx[0], Idx.size()); } GetElementPtrInst::GetElementPtrInst(Value *Ptr, const std::vector &Idx, @@ -721,7 +721,25 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, const std::vector &Idx, : Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), Idx, true))), GetElementPtr, 0, 0, Name, IAE) { - init(Ptr, Idx); + init(Ptr, &Idx[0], Idx.size()); +} + +GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value* const *Idx, + unsigned NumIdx, + const std::string &Name, Instruction *InBe) +: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), + Idx, true))), + GetElementPtr, 0, 0, Name, InBe) { + init(Ptr, Idx, NumIdx); +} + +GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value* const *Idx, + unsigned NumIdx, + const std::string &Name, BasicBlock *IAE) +: Instruction(PointerType::get(checkType(getIndexedType(Ptr->getType(), + Idx, true))), + GetElementPtr, 0, 0, Name, IAE) { + init(Ptr, Idx, NumIdx); } GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,