Fix warning when assertions disabled.
[oota-llvm.git] / lib / VMCore / Instructions.cpp
index 4a297b3345b2f39e155199564979d45257a341d0..3421292930d490f4995e436b2357ce21a35cf386 100644 (file)
@@ -130,7 +130,8 @@ PHINode::PHINode(const PHINode &PN)
 }
 
 PHINode::~PHINode() {
-  dropHungoffUses(OperandList);
+  if (OperandList)
+    dropHungoffUses(OperandList);
 }
 
 // removeIncomingValue - Remove an incoming value.  This is useful if a
@@ -1384,6 +1385,8 @@ InsertValueInst::InsertValueInst(const InsertValueInst &IVI)
   : Instruction(IVI.getType(), InsertValue,
                 OperandTraits<InsertValueInst>::op_begin(this), 2),
     Indices(IVI.Indices) {
+  Op<0>() = IVI.getOperand(0);
+  Op<1>() = IVI.getOperand(1);
 }
 
 InsertValueInst::InsertValueInst(Value *Agg,
@@ -1412,18 +1415,16 @@ InsertValueInst::InsertValueInst(Value *Agg,
 //                             ExtractValueInst Class
 //===----------------------------------------------------------------------===//
 
-void ExtractValueInst::init(Value *Agg, const unsigned *Idx, unsigned NumIdx,
+void ExtractValueInst::init(const unsigned *Idx, unsigned NumIdx,
                            const std::string &Name) {
   assert(NumOperands == 1 && "NumOperands not initialized?");
-  Op<0>() = Agg;
 
   Indices.insert(Indices.end(), Idx, Idx + NumIdx);
   setName(Name);
 }
 
-void ExtractValueInst::init(Value *Agg, unsigned Idx, const std::string &Name) {
+void ExtractValueInst::init(unsigned Idx, const std::string &Name) {
   assert(NumOperands == 1 && "NumOperands not initialized?");
-  Op<0>() = Agg;
 
   Indices.push_back(Idx);
   setName(Name);
@@ -1461,13 +1462,18 @@ const Type* ExtractValueInst::getIndexedType(const Type *Agg,
   return CurIdx == NumIdx ? Agg : 0;
 }
 
+const Type* ExtractValueInst::getIndexedType(const Type *Agg,
+                                             unsigned Idx) {
+  return getIndexedType(Agg, &Idx, 1);
+}
+
 ExtractValueInst::ExtractValueInst(Value *Agg,
                                    unsigned Idx,
                                    const std::string &Name,
                                    BasicBlock *InsertAtEnd)
   : UnaryInstruction(checkType(getIndexedType(Agg->getType(), &Idx, 1)),
                     ExtractValue, Agg, InsertAtEnd) {
-  init(Agg, Idx, Name);
+  init(Idx, Name);
 }
 
 ExtractValueInst::ExtractValueInst(Value *Agg,
@@ -1476,7 +1482,7 @@ ExtractValueInst::ExtractValueInst(Value *Agg,
                                    Instruction *InsertBefore)
   : UnaryInstruction(checkType(getIndexedType(Agg->getType(), &Idx, 1)),
                     ExtractValue, Agg, InsertBefore) {
-  init(Agg, Idx, Name);
+  init(Idx, Name);
 }
 
 //===----------------------------------------------------------------------===//