Fix warning when assertions disabled.
[oota-llvm.git] / lib / VMCore / Instructions.cpp
index cea496d1ca78e28e9b9f1aa84c3045cb55623c23..3421292930d490f4995e436b2357ce21a35cf386 100644 (file)
@@ -12,7 +12,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/BasicBlock.h"
 #include "llvm/Constants.h"
 #include "llvm/DerivedTypes.h"
 #include "llvm/Function.h"
@@ -92,6 +91,13 @@ void CallSite::setDoesNotThrow(bool doesNotThrow) {
     cast<InvokeInst>(I)->setDoesNotThrow(doesNotThrow);
 }
 
+bool CallSite::hasArgument(const Value *Arg) const {
+  for (arg_iterator AI = this->arg_begin(), E = this->arg_end(); AI != E; ++AI)
+    if (AI->get() == Arg)
+      return true;
+  return false;
+}
+
 //===----------------------------------------------------------------------===//
 //                            TerminatorInst Class
 //===----------------------------------------------------------------------===//
@@ -118,13 +124,14 @@ PHINode::PHINode(const PHINode &PN)
     ReservedSpace(PN.getNumOperands()) {
   Use *OL = OperandList;
   for (unsigned i = 0, e = PN.getNumOperands(); i != e; i+=2) {
-    OL[i].init(PN.getOperand(i), this);
-    OL[i+1].init(PN.getOperand(i+1), this);
+    OL[i] = PN.getOperand(i);
+    OL[i+1] = PN.getOperand(i+1);
   }
 }
 
 PHINode::~PHINode() {
-  dropHungoffUses(OperandList);
+  if (OperandList)
+    dropHungoffUses(OperandList);
 }
 
 // removeIncomingValue - Remove an incoming value.  This is useful if a
@@ -184,7 +191,7 @@ void PHINode::resizeOperands(unsigned NumOps) {
   Use *OldOps = OperandList;
   Use *NewOps = allocHungoffUses(NumOps);
   for (unsigned i = 0; i != e; ++i) {
-      NewOps[i].init(OldOps[i], this);
+      NewOps[i] = OldOps[i];
   }
   OperandList = NewOps;
   if (OldOps) Use::zap(OldOps, OldOps + e, true);
@@ -249,7 +256,7 @@ CallInst::~CallInst() {
 void CallInst::init(Value *Func, Value* const *Params, unsigned NumParams) {
   assert(NumOperands == NumParams+1 && "NumOperands not set up?");
   Use *OL = OperandList;
-  OL[0].init(Func, this);
+  OL[0] = Func;
 
   const FunctionType *FTy =
     cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
@@ -262,16 +269,16 @@ void CallInst::init(Value *Func, Value* const *Params, unsigned NumParams) {
     assert((i >= FTy->getNumParams() || 
             FTy->getParamType(i) == Params[i]->getType()) &&
            "Calling a function with a bad signature!");
-    OL[i+1].init(Params[i], this);
+    OL[i+1] = Params[i];
   }
 }
 
 void CallInst::init(Value *Func, Value *Actual1, Value *Actual2) {
   assert(NumOperands == 3 && "NumOperands not set up?");
   Use *OL = OperandList;
-  OL[0].init(Func, this);
-  OL[1].init(Actual1, this);
-  OL[2].init(Actual2, this);
+  OL[0] = Func;
+  OL[1] = Actual1;
+  OL[2] = Actual2;
 
   const FunctionType *FTy =
     cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
@@ -291,8 +298,8 @@ void CallInst::init(Value *Func, Value *Actual1, Value *Actual2) {
 void CallInst::init(Value *Func, Value *Actual) {
   assert(NumOperands == 2 && "NumOperands not set up?");
   Use *OL = OperandList;
-  OL[0].init(Func, this);
-  OL[1].init(Actual, this);
+  OL[0] = Func;
+  OL[1] = Actual;
 
   const FunctionType *FTy =
     cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
@@ -309,7 +316,7 @@ void CallInst::init(Value *Func, Value *Actual) {
 void CallInst::init(Value *Func) {
   assert(NumOperands == 1 && "NumOperands not set up?");
   Use *OL = OperandList;
-  OL[0].init(Func, this);
+  OL[0] = Func;
 
   const FunctionType *FTy =
     cast<FunctionType>(cast<PointerType>(Func->getType())->getElementType());
@@ -370,7 +377,13 @@ CallInst::CallInst(const CallInst &CI)
   Use *OL = OperandList;
   Use *InOL = CI.OperandList;
   for (unsigned i = 0, e = CI.getNumOperands(); i != e; ++i)
-    OL[i].init(InOL[i], this);
+    OL[i] = InOL[i];
+}
+
+void CallInst::addParamAttr(unsigned i, ParameterAttributes attr) {
+  PAListPtr PAL = getParamAttrs();
+  PAL = PAL.addAttr(i, attr);
+  setParamAttrs(PAL);
 }
 
 bool CallInst::paramHasAttr(unsigned i, ParameterAttributes attr) const {
@@ -399,9 +412,9 @@ void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
                       Value* const *Args, unsigned NumArgs) {
   assert(NumOperands == 3+NumArgs && "NumOperands not set up?");
   Use *OL = OperandList;
-  OL[0].init(Fn, this);
-  OL[1].init(IfNormal, this);
-  OL[2].init(IfException, this);
+  OL[0] = Fn;
+  OL[1] = IfNormal;
+  OL[2] = IfException;
   const FunctionType *FTy =
     cast<FunctionType>(cast<PointerType>(Fn->getType())->getElementType());
   FTy = FTy;  // silence warning.
@@ -415,19 +428,20 @@ void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
             FTy->getParamType(i) == Args[i]->getType()) &&
            "Invoking a function with a bad signature!");
     
-    OL[i+3].init(Args[i], this);
+    OL[i+3] = Args[i];
   }
 }
 
 InvokeInst::InvokeInst(const InvokeInst &II)
   : TerminatorInst(II.getType(), Instruction::Invoke,
-                   OperandTraits<InvokeInst>::op_end(this) - II.getNumOperands(),
+                   OperandTraits<InvokeInst>::op_end(this)
+                   - II.getNumOperands(),
                    II.getNumOperands()) {
   setParamAttrs(II.getParamAttrs());
   SubclassData = II.SubclassData;
   Use *OL = OperandList, *InOL = II.OperandList;
   for (unsigned i = 0, e = II.getNumOperands(); i != e; ++i)
-    OL[i].init(InOL[i], this);
+    OL[i] = InOL[i];
 }
 
 BasicBlock *InvokeInst::getSuccessorV(unsigned idx) const {
@@ -448,6 +462,12 @@ bool InvokeInst::paramHasAttr(unsigned i, ParameterAttributes attr) const {
   return false;
 }
 
+void InvokeInst::addParamAttr(unsigned i, ParameterAttributes attr) {
+  PAListPtr PAL = getParamAttrs();
+  PAL = PAL.addAttr(i, attr);
+  setParamAttrs(PAL);
+}
+
 void InvokeInst::setDoesNotThrow(bool doesNotThrow) {
   PAListPtr PAL = getParamAttrs();
   if (doesNotThrow)
@@ -464,15 +484,16 @@ void InvokeInst::setDoesNotThrow(bool doesNotThrow) {
 
 ReturnInst::ReturnInst(const ReturnInst &RI)
   : TerminatorInst(Type::VoidTy, Instruction::Ret,
-                   OperandTraits<ReturnInst>::op_end(this) - RI.getNumOperands(),
+                   OperandTraits<ReturnInst>::op_end(this)
+                   - RI.getNumOperands(),
                    RI.getNumOperands()) {
   unsigned N = RI.getNumOperands();
   if (N == 1)
-    Op<0>().init(RI.Op<0>(), this);
+    Op<0>() = RI.Op<0>();
   else if (N) {
     Use *OL = OperandList;
     for (unsigned i = 0; i < N; ++i)
-      OL[i].init(RI.getOperand(i), this);
+      OL[i] = RI.getOperand(i);
   }
 }
 
@@ -521,7 +542,7 @@ void ReturnInst::init(Value * const* retVals, unsigned N) {
     Value *V = *retVals;
     if (V->getType() == Type::VoidTy)
       return;
-    Op<0>().init(V, this);
+    Op<0>() = V;
     return;
   }
 
@@ -530,7 +551,7 @@ void ReturnInst::init(Value * const* retVals, unsigned N) {
     Value *V = *retVals++;
     assert(!isa<BasicBlock>(V) &&
            "Cannot return basic block.  Probably using the incorrect ctor");
-    OL[i].init(V, this);
+    OL[i] = V;
   }
 }
 
@@ -619,16 +640,16 @@ BranchInst::BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore)
                    OperandTraits<BranchInst>::op_end(this) - 1,
                    1, InsertBefore) {
   assert(IfTrue != 0 && "Branch destination may not be null!");
-  Op<0>().init(reinterpret_cast<Value*>(IfTrue), this);
+  Op<0>() = IfTrue;
 }
 BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
                        Instruction *InsertBefore)
   : TerminatorInst(Type::VoidTy, Instruction::Br,
                    OperandTraits<BranchInst>::op_end(this) - 3,
                    3, InsertBefore) {
-  Op<0>().init(reinterpret_cast<Value*>(IfTrue), this);
-  Op<1>().init(reinterpret_cast<Value*>(IfFalse), this);
-  Op<2>().init(Cond, this);
+  Op<0>() = IfTrue;
+  Op<1>() = IfFalse;
+  Op<2>() = Cond;
 #ifndef NDEBUG
   AssertOK();
 #endif
@@ -639,7 +660,7 @@ BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd)
                    OperandTraits<BranchInst>::op_end(this) - 1,
                    1, InsertAtEnd) {
   assert(IfTrue != 0 && "Branch destination may not be null!");
-  Op<0>().init(reinterpret_cast<Value*>(IfTrue), this);
+  Op<0>() = IfTrue;
 }
 
 BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
@@ -647,9 +668,9 @@ BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
   : TerminatorInst(Type::VoidTy, Instruction::Br,
                    OperandTraits<BranchInst>::op_end(this) - 3,
                    3, InsertAtEnd) {
-  Op<0>().init(reinterpret_cast<Value*>(IfTrue), this);
-  Op<1>().init(reinterpret_cast<Value*>(IfFalse), this);
-  Op<2>().init(Cond, this);
+  Op<0>() = IfTrue;
+  Op<1>() = IfFalse;
+  Op<2>() = Cond;
 #ifndef NDEBUG
   AssertOK();
 #endif
@@ -660,11 +681,11 @@ BranchInst::BranchInst(const BranchInst &BI) :
   TerminatorInst(Type::VoidTy, Instruction::Br,
                  OperandTraits<BranchInst>::op_end(this) - BI.getNumOperands(),
                  BI.getNumOperands()) {
-  OperandList[0].init(BI.getOperand(0), this);
+  OperandList[0] = BI.getOperand(0);
   if (BI.getNumOperands() != 1) {
     assert(BI.getNumOperands() == 3 && "BR can have 1 or 3 operands!");
-    OperandList[1].init(BI.getOperand(1), this);
-    OperandList[2].init(BI.getOperand(2), this);
+    OperandList[1] = BI.getOperand(1);
+    OperandList[2] = BI.getOperand(2);
   }
 }
 
@@ -895,8 +916,8 @@ StoreInst::StoreInst(Value *val, Value *addr, Instruction *InsertBefore)
                 OperandTraits<StoreInst>::op_begin(this),
                 OperandTraits<StoreInst>::operands(this),
                 InsertBefore) {
-  Op<0>().init(val, this);
-  Op<1>().init(addr, this);
+  Op<0>() = val;
+  Op<1>() = addr;
   setVolatile(false);
   setAlignment(0);
   AssertOK();
@@ -907,8 +928,8 @@ StoreInst::StoreInst(Value *val, Value *addr, BasicBlock *InsertAtEnd)
                 OperandTraits<StoreInst>::op_begin(this),
                 OperandTraits<StoreInst>::operands(this),
                 InsertAtEnd) {
-  Op<0>().init(val, this);
-  Op<1>().init(addr, this);
+  Op<0>() = val;
+  Op<1>() = addr;
   setVolatile(false);
   setAlignment(0);
   AssertOK();
@@ -920,8 +941,8 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
                 OperandTraits<StoreInst>::op_begin(this),
                 OperandTraits<StoreInst>::operands(this),
                 InsertBefore) {
-  Op<0>().init(val, this);
-  Op<1>().init(addr, this);
+  Op<0>() = val;
+  Op<1>() = addr;
   setVolatile(isVolatile);
   setAlignment(0);
   AssertOK();
@@ -933,8 +954,8 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
                 OperandTraits<StoreInst>::op_begin(this),
                 OperandTraits<StoreInst>::operands(this),
                 InsertBefore) {
-  Op<0>().init(val, this);
-  Op<1>().init(addr, this);
+  Op<0>() = val;
+  Op<1>() = addr;
   setVolatile(isVolatile);
   setAlignment(Align);
   AssertOK();
@@ -946,8 +967,8 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
                 OperandTraits<StoreInst>::op_begin(this),
                 OperandTraits<StoreInst>::operands(this),
                 InsertAtEnd) {
-  Op<0>().init(val, this);
-  Op<1>().init(addr, this);
+  Op<0>() = val;
+  Op<1>() = addr;
   setVolatile(isVolatile);
   setAlignment(Align);
   AssertOK();
@@ -959,8 +980,8 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
                 OperandTraits<StoreInst>::op_begin(this),
                 OperandTraits<StoreInst>::operands(this),
                 InsertAtEnd) {
-  Op<0>().init(val, this);
-  Op<1>().init(addr, this);
+  Op<0>() = val;
+  Op<1>() = addr;
   setVolatile(isVolatile);
   setAlignment(0);
   AssertOK();
@@ -979,30 +1000,36 @@ static unsigned retrieveAddrSpace(const Value *Val) {
   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].init(Ptr, this);
+  OL[0] = Ptr;
 
   for (unsigned i = 0; i != NumIdx; ++i)
-    OL[i+1].init(Idx[i], this);
+    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].init(Ptr, this);
-  OL[1].init(Idx, this);
+  OL[0] = Ptr;
+  OL[1] = Idx;
+
+  setName(Name);
 }
 
 GetElementPtrInst::GetElementPtrInst(const GetElementPtrInst &GEPI)
-  : Instruction(reinterpret_cast<const Type*>(GEPI.getType()), GetElementPtr,
-                OperandTraits<GetElementPtrInst>::op_end(this) - GEPI.getNumOperands(),
+  : Instruction(GEPI.getType(), GetElementPtr,
+                OperandTraits<GetElementPtrInst>::op_end(this)
+                - GEPI.getNumOperands(),
                 GEPI.getNumOperands()) {
   Use *OL = OperandList;
   Use *GEPIOL = GEPI.OperandList;
   for (unsigned i = 0, E = NumOperands; i != E; ++i)
-    OL[i].init(GEPIOL[i], this);
+    OL[i] = GEPIOL[i];
 }
 
 GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
@@ -1012,8 +1039,7 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
                 GetElementPtr,
                 OperandTraits<GetElementPtrInst>::op_end(this) - 2,
                 2, InBe) {
-  init(Ptr, Idx);
-  setName(Name);
+  init(Ptr, Idx, Name);
 }
 
 GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
@@ -1023,8 +1049,7 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
                 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
@@ -1035,41 +1060,31 @@ GetElementPtrInst::GetElementPtrInst(Value *Ptr, Value *Idx,
 //
 const Type* GetElementPtrInst::getIndexedType(const Type *Ptr,
                                               Value* const *Idxs,
-                                              unsigned NumIdx,
-                                              bool AllowCompositeLeaf) {
-  if (!isa<PointerType>(Ptr)) return 0;   // Type isn't a pointer type!
+                                              unsigned NumIdx) {
+  const PointerType *PTy = dyn_cast<PointerType>(Ptr);
+  if (!PTy) return 0;   // Type isn't a pointer type!
+  const Type *Agg = PTy->getElementType();
 
   // Handle the special case of the empty set index set...
-  if (NumIdx == 0) {
-    if (AllowCompositeLeaf ||
-        cast<PointerType>(Ptr)->getElementType()->isFirstClassType())
-      return cast<PointerType>(Ptr)->getElementType();
-    else
-      return 0;
-  }
-
-  unsigned CurIdx = 0;
-  while (const CompositeType *CT = dyn_cast<CompositeType>(Ptr)) {
-    if (NumIdx == CurIdx) {
-      if (AllowCompositeLeaf || CT->isFirstClassType()) return Ptr;
-      return 0;   // Can't load a whole structure or array!?!?
-    }
-
-    Value *Index = Idxs[CurIdx++];
-    if (isa<PointerType>(CT) && CurIdx != 1)
-      return 0;  // Can only index into pointer types at the first index!
+  if (NumIdx == 0)
+    return Agg;
+
+  unsigned CurIdx = 1;
+  for (; CurIdx != NumIdx; ++CurIdx) {
+    const CompositeType *CT = dyn_cast<CompositeType>(Agg);
+    if (!CT || isa<PointerType>(CT)) return 0;
+    Value *Index = Idxs[CurIdx];
     if (!CT->indexValid(Index)) return 0;
-    Ptr = CT->getTypeAtIndex(Index);
+    Agg = CT->getTypeAtIndex(Index);
 
     // If the new type forwards to another type, then it is in the middle
     // of being refined to another type (and hence, may have dropped all
     // references to what it was using before).  So, use the new forwarded
     // type.
-    if (const Type * Ty = Ptr->getForwardedType()) {
-      Ptr = Ty;
-    }
+    if (const Type *Ty = Agg->getForwardedType())
+      Agg = Ty;
   }
-  return CurIdx == NumIdx ? Ptr : 0;
+  return CurIdx == NumIdx ? Agg : 0;
 }
 
 const Type* GetElementPtrInst::getIndexedType(const Type *Ptr, Value *Idx) {
@@ -1122,8 +1137,8 @@ ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
                 2, InsertBef) {
   assert(isValidOperands(Val, Index) &&
          "Invalid extractelement instruction operands!");
-  Op<0>().init(Val, this);
-  Op<1>().init(Index, this);
+  Op<0>() = Val;
+  Op<1>() = Index;
   setName(Name);
 }
 
@@ -1137,8 +1152,8 @@ ExtractElementInst::ExtractElementInst(Value *Val, unsigned IndexV,
   Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV);
   assert(isValidOperands(Val, Index) &&
          "Invalid extractelement instruction operands!");
-  Op<0>().init(Val, this);
-  Op<1>().init(Index, this);
+  Op<0>() = Val;
+  Op<1>() = Index;
   setName(Name);
 }
 
@@ -1153,8 +1168,8 @@ ExtractElementInst::ExtractElementInst(Value *Val, Value *Index,
   assert(isValidOperands(Val, Index) &&
          "Invalid extractelement instruction operands!");
 
-  Op<0>().init(Val, this);
-  Op<1>().init(Index, this);
+  Op<0>() = Val;
+  Op<1>() = Index;
   setName(Name);
 }
 
@@ -1169,8 +1184,8 @@ ExtractElementInst::ExtractElementInst(Value *Val, unsigned IndexV,
   assert(isValidOperands(Val, Index) &&
          "Invalid extractelement instruction operands!");
   
-  Op<0>().init(Val, this);
-  Op<1>().init(Index, this);
+  Op<0>() = Val;
+  Op<1>() = Index;
   setName(Name);
 }
 
@@ -1189,9 +1204,9 @@ bool ExtractElementInst::isValidOperands(const Value *Val, const Value *Index) {
 InsertElementInst::InsertElementInst(const InsertElementInst &IE)
     : Instruction(IE.getType(), InsertElement,
                   OperandTraits<InsertElementInst>::op_begin(this), 3) {
-  Op<0>().init(IE.Op<0>(), this);
-  Op<1>().init(IE.Op<1>(), this);
-  Op<2>().init(IE.Op<2>(), this);
+  Op<0>() = IE.Op<0>();
+  Op<1>() = IE.Op<1>();
+  Op<2>() = IE.Op<2>();
 }
 InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
                                      const std::string &Name,
@@ -1201,9 +1216,9 @@ InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
                 3, InsertBef) {
   assert(isValidOperands(Vec, Elt, Index) &&
          "Invalid insertelement instruction operands!");
-  Op<0>().init(Vec, this);
-  Op<1>().init(Elt, this);
-  Op<2>().init(Index, this);
+  Op<0>() = Vec;
+  Op<1>() = Elt;
+  Op<2>() = Index;
   setName(Name);
 }
 
@@ -1216,9 +1231,9 @@ InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV,
   Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV);
   assert(isValidOperands(Vec, Elt, Index) &&
          "Invalid insertelement instruction operands!");
-  Op<0>().init(Vec, this);
-  Op<1>().init(Elt, this);
-  Op<2>().init(Index, this);
+  Op<0>() = Vec;
+  Op<1>() = Elt;
+  Op<2>() = Index;
   setName(Name);
 }
 
@@ -1232,9 +1247,9 @@ InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
   assert(isValidOperands(Vec, Elt, Index) &&
          "Invalid insertelement instruction operands!");
 
-  Op<0>().init(Vec, this);
-  Op<1>().init(Elt, this);
-  Op<2>().init(Index, this);
+  Op<0>() = Vec;
+  Op<1>() = Elt;
+  Op<2>() = Index;
   setName(Name);
 }
 
@@ -1248,9 +1263,9 @@ InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV,
   assert(isValidOperands(Vec, Elt, Index) &&
          "Invalid insertelement instruction operands!");
   
-  Op<0>().init(Vec, this);
-  Op<1>().init(Elt, this);
-  Op<2>().init(Index, this);
+  Op<0>() = Vec;
+  Op<1>() = Elt;
+  Op<2>() = Index;
   setName(Name);
 }
 
@@ -1276,9 +1291,9 @@ ShuffleVectorInst::ShuffleVectorInst(const ShuffleVectorInst &SV)
   : Instruction(SV.getType(), ShuffleVector,
                 OperandTraits<ShuffleVectorInst>::op_begin(this),
                 OperandTraits<ShuffleVectorInst>::operands(this)) {
-  Op<0>().init(SV.Op<0>(), this);
-  Op<1>().init(SV.Op<1>(), this);
-  Op<2>().init(SV.Op<2>(), this);
+  Op<0>() = SV.Op<0>();
+  Op<1>() = SV.Op<1>();
+  Op<2>() = SV.Op<2>();
 }
 
 ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
@@ -1290,9 +1305,9 @@ ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
                 InsertBefore) {
   assert(isValidOperands(V1, V2, Mask) &&
          "Invalid shuffle vector instruction operands!");
-  Op<0>().init(V1, this);
-  Op<1>().init(V2, this);
-  Op<2>().init(Mask, this);
+  Op<0>() = V1;
+  Op<1>() = V2;
+  Op<2>() = Mask;
   setName(Name);
 }
 
@@ -1306,9 +1321,9 @@ ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
   assert(isValidOperands(V1, V2, Mask) &&
          "Invalid shuffle vector instruction operands!");
 
-  Op<0>().init(V1, this);
-  Op<1>().init(V2, this);
-  Op<2>().init(Mask, this);
+  Op<0>() = V1;
+  Op<1>() = V2;
+  Op<2>() = Mask;
   setName(Name);
 }
 
@@ -1342,6 +1357,133 @@ int ShuffleVectorInst::getMaskValue(unsigned i) const {
   return cast<ConstantInt>(MaskCV->getOperand(i))->getZExtValue();
 }
 
+//===----------------------------------------------------------------------===//
+//                             InsertValueInst Class
+//===----------------------------------------------------------------------===//
+
+void InsertValueInst::init(Value *Agg, Value *Val, const unsigned *Idx, 
+                           unsigned NumIdx, const std::string &Name) {
+  assert(NumOperands == 2 && "NumOperands not initialized?");
+  Op<0>() = Agg;
+  Op<1>() = Val;
+
+  Indices.insert(Indices.end(), Idx, Idx + NumIdx);
+  setName(Name);
+}
+
+void InsertValueInst::init(Value *Agg, Value *Val, unsigned Idx, 
+                           const std::string &Name) {
+  assert(NumOperands == 2 && "NumOperands not initialized?");
+  Op<0>() = Agg;
+  Op<1>() = Val;
+
+  Indices.push_back(Idx);
+  setName(Name);
+}
+
+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,
+                                 Value *Val,
+                                 unsigned Idx, 
+                                 const std::string &Name,
+                                 Instruction *InsertBefore)
+  : Instruction(Agg->getType(), InsertValue,
+                OperandTraits<InsertValueInst>::op_begin(this),
+                2, InsertBefore) {
+  init(Agg, Val, Idx, Name);
+}
+
+InsertValueInst::InsertValueInst(Value *Agg,
+                                 Value *Val,
+                                 unsigned Idx, 
+                                 const std::string &Name,
+                                 BasicBlock *InsertAtEnd)
+  : Instruction(Agg->getType(), InsertValue,
+                OperandTraits<InsertValueInst>::op_begin(this),
+                2, InsertAtEnd) {
+  init(Agg, Val, Idx, Name);
+}
+
+//===----------------------------------------------------------------------===//
+//                             ExtractValueInst Class
+//===----------------------------------------------------------------------===//
+
+void ExtractValueInst::init(const unsigned *Idx, unsigned NumIdx,
+                           const std::string &Name) {
+  assert(NumOperands == 1 && "NumOperands not initialized?");
+
+  Indices.insert(Indices.end(), Idx, Idx + NumIdx);
+  setName(Name);
+}
+
+void ExtractValueInst::init(unsigned Idx, const std::string &Name) {
+  assert(NumOperands == 1 && "NumOperands not initialized?");
+
+  Indices.push_back(Idx);
+  setName(Name);
+}
+
+ExtractValueInst::ExtractValueInst(const ExtractValueInst &EVI)
+  : UnaryInstruction(EVI.getType(), ExtractValue, EVI.getOperand(0)),
+    Indices(EVI.Indices) {
+}
+
+// getIndexedType - Returns the type of the element that would be extracted
+// with an extractvalue instruction with the specified parameters.
+//
+// A null type is returned if the indices are invalid for the specified
+// pointer type.
+//
+const Type* ExtractValueInst::getIndexedType(const Type *Agg,
+                                             const unsigned *Idxs,
+                                             unsigned NumIdx) {
+  unsigned CurIdx = 0;
+  for (; CurIdx != NumIdx; ++CurIdx) {
+    const CompositeType *CT = dyn_cast<CompositeType>(Agg);
+    if (!CT || isa<PointerType>(CT) || isa<VectorType>(CT)) return 0;
+    unsigned Index = Idxs[CurIdx];
+    if (!CT->indexValid(Index)) return 0;
+    Agg = CT->getTypeAtIndex(Index);
+
+    // If the new type forwards to another type, then it is in the middle
+    // of being refined to another type (and hence, may have dropped all
+    // references to what it was using before).  So, use the new forwarded
+    // type.
+    if (const Type *Ty = Agg->getForwardedType())
+      Agg = Ty;
+  }
+  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(Idx, Name);
+}
+
+ExtractValueInst::ExtractValueInst(Value *Agg,
+                                   unsigned Idx,
+                                   const std::string &Name,
+                                   Instruction *InsertBefore)
+  : UnaryInstruction(checkType(getIndexedType(Agg->getType(), &Idx, 1)),
+                    ExtractValue, Agg, InsertBefore) {
+  init(Idx, Name);
+}
 
 //===----------------------------------------------------------------------===//
 //                             BinaryOperator Class
@@ -1354,8 +1496,8 @@ BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
                 OperandTraits<BinaryOperator>::op_begin(this),
                 OperandTraits<BinaryOperator>::operands(this),
                 InsertBefore) {
-  Op<0>().init(S1, this);
-  Op<1>().init(S2, this);
+  Op<0>() = S1;
+  Op<1>() = S2;
   init(iType);
   setName(Name);
 }
@@ -1367,8 +1509,8 @@ BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
                 OperandTraits<BinaryOperator>::op_begin(this),
                 OperandTraits<BinaryOperator>::operands(this),
                 InsertAtEnd) {
-  Op<0>().init(S1, this);
-  Op<1>().init(S2, this);
+  Op<0>() = S1;
+  Op<1>() = S2;
   init(iType);
   setName(Name);
 }
@@ -1442,7 +1584,7 @@ void BinaryOperator::init(BinaryOps iType) {
 #endif
 }
 
-BinaryOperator *BinaryOperator::create(BinaryOps Op, Value *S1, Value *S2,
+BinaryOperator *BinaryOperator::Create(BinaryOps Op, Value *S1, Value *S2,
                                        const std::string &Name,
                                        Instruction *InsertBefore) {
   assert(S1->getType() == S2->getType() &&
@@ -1450,15 +1592,15 @@ BinaryOperator *BinaryOperator::create(BinaryOps Op, Value *S1, Value *S2,
   return new BinaryOperator(Op, S1, S2, S1->getType(), Name, InsertBefore);
 }
 
-BinaryOperator *BinaryOperator::create(BinaryOps Op, Value *S1, Value *S2,
+BinaryOperator *BinaryOperator::Create(BinaryOps Op, Value *S1, Value *S2,
                                        const std::string &Name,
                                        BasicBlock *InsertAtEnd) {
-  BinaryOperator *Res = create(Op, S1, S2, Name);
+  BinaryOperator *Res = Create(Op, S1, S2, Name);
   InsertAtEnd->getInstList().push_back(Res);
   return Res;
 }
 
-BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name,
+BinaryOperator *BinaryOperator::CreateNeg(Value *Op, const std::string &Name,
                                           Instruction *InsertBefore) {
   Value *zero = ConstantExpr::getZeroValueForNegationExpr(Op->getType());
   return new BinaryOperator(Instruction::Sub,
@@ -1466,7 +1608,7 @@ BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name,
                             Op->getType(), Name, InsertBefore);
 }
 
-BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name,
+BinaryOperator *BinaryOperator::CreateNeg(Value *Op, const std::string &Name,
                                           BasicBlock *InsertAtEnd) {
   Value *zero = ConstantExpr::getZeroValueForNegationExpr(Op->getType());
   return new BinaryOperator(Instruction::Sub,
@@ -1474,7 +1616,7 @@ BinaryOperator *BinaryOperator::createNeg(Value *Op, const std::string &Name,
                             Op->getType(), Name, InsertAtEnd);
 }
 
-BinaryOperator *BinaryOperator::createNot(Value *Op, const std::string &Name,
+BinaryOperator *BinaryOperator::CreateNot(Value *Op, const std::string &Name,
                                           Instruction *InsertBefore) {
   Constant *C;
   if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) {
@@ -1488,7 +1630,7 @@ BinaryOperator *BinaryOperator::createNot(Value *Op, const std::string &Name,
                             Op->getType(), Name, InsertBefore);
 }
 
-BinaryOperator *BinaryOperator::createNot(Value *Op, const std::string &Name,
+BinaryOperator *BinaryOperator::CreateNot(Value *Op, const std::string &Name,
                                           BasicBlock *InsertAtEnd) {
   Constant *AllOnes;
   if (const VectorType *PTy = dyn_cast<VectorType>(Op->getType())) {
@@ -1563,7 +1705,7 @@ const Value *BinaryOperator::getNotArgument(const Value *BinOp) {
 bool BinaryOperator::swapOperands() {
   if (!isCommutative())
     return true; // Can't commute operands
-  std::swap(Op<0>(), Op<1>());
+  Op<0>().swap(Op<1>());
   return false;
 }
 
@@ -1793,7 +1935,7 @@ unsigned CastInst::isEliminableCastPair(
   return 0;
 }
 
-CastInst *CastInst::create(Instruction::CastOps op, Value *S, const Type *Ty, 
+CastInst *CastInst::Create(Instruction::CastOps op, Value *S, const Type *Ty, 
   const std::string &Name, Instruction *InsertBefore) {
   // Construct and return the appropriate CastInst subclass
   switch (op) {
@@ -1815,7 +1957,7 @@ CastInst *CastInst::create(Instruction::CastOps op, Value *S, const Type *Ty,
   return 0;
 }
 
-CastInst *CastInst::create(Instruction::CastOps op, Value *S, const Type *Ty,
+CastInst *CastInst::Create(Instruction::CastOps op, Value *S, const Type *Ty,
   const std::string &Name, BasicBlock *InsertAtEnd) {
   // Construct and return the appropriate CastInst subclass
   switch (op) {
@@ -1837,55 +1979,55 @@ CastInst *CastInst::create(Instruction::CastOps op, Value *S, const Type *Ty,
   return 0;
 }
 
-CastInst *CastInst::createZExtOrBitCast(Value *S, const Type *Ty, 
+CastInst *CastInst::CreateZExtOrBitCast(Value *S, const Type *Ty, 
                                         const std::string &Name,
                                         Instruction *InsertBefore) {
   if (S->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits())
-    return create(Instruction::BitCast, S, Ty, Name, InsertBefore);
-  return create(Instruction::ZExt, S, Ty, Name, InsertBefore);
+    return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
+  return Create(Instruction::ZExt, S, Ty, Name, InsertBefore);
 }
 
-CastInst *CastInst::createZExtOrBitCast(Value *S, const Type *Ty, 
+CastInst *CastInst::CreateZExtOrBitCast(Value *S, const Type *Ty, 
                                         const std::string &Name,
                                         BasicBlock *InsertAtEnd) {
   if (S->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits())
-    return create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
-  return create(Instruction::ZExt, S, Ty, Name, InsertAtEnd);
+    return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
+  return Create(Instruction::ZExt, S, Ty, Name, InsertAtEnd);
 }
 
-CastInst *CastInst::createSExtOrBitCast(Value *S, const Type *Ty, 
+CastInst *CastInst::CreateSExtOrBitCast(Value *S, const Type *Ty, 
                                         const std::string &Name,
                                         Instruction *InsertBefore) {
   if (S->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits())
-    return create(Instruction::BitCast, S, Ty, Name, InsertBefore);
-  return create(Instruction::SExt, S, Ty, Name, InsertBefore);
+    return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
+  return Create(Instruction::SExt, S, Ty, Name, InsertBefore);
 }
 
-CastInst *CastInst::createSExtOrBitCast(Value *S, const Type *Ty, 
+CastInst *CastInst::CreateSExtOrBitCast(Value *S, const Type *Ty, 
                                         const std::string &Name,
                                         BasicBlock *InsertAtEnd) {
   if (S->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits())
-    return create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
-  return create(Instruction::SExt, S, Ty, Name, InsertAtEnd);
+    return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
+  return Create(Instruction::SExt, S, Ty, Name, InsertAtEnd);
 }
 
-CastInst *CastInst::createTruncOrBitCast(Value *S, const Type *Ty,
+CastInst *CastInst::CreateTruncOrBitCast(Value *S, const Type *Ty,
                                          const std::string &Name,
                                          Instruction *InsertBefore) {
   if (S->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits())
-    return create(Instruction::BitCast, S, Ty, Name, InsertBefore);
-  return create(Instruction::Trunc, S, Ty, Name, InsertBefore);
+    return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
+  return Create(Instruction::Trunc, S, Ty, Name, InsertBefore);
 }
 
-CastInst *CastInst::createTruncOrBitCast(Value *S, const Type *Ty,
+CastInst *CastInst::CreateTruncOrBitCast(Value *S, const Type *Ty,
                                          const std::string &Name, 
                                          BasicBlock *InsertAtEnd) {
   if (S->getType()->getPrimitiveSizeInBits() == Ty->getPrimitiveSizeInBits())
-    return create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
-  return create(Instruction::Trunc, S, Ty, Name, InsertAtEnd);
+    return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
+  return Create(Instruction::Trunc, S, Ty, Name, InsertAtEnd);
 }
 
-CastInst *CastInst::createPointerCast(Value *S, const Type *Ty,
+CastInst *CastInst::CreatePointerCast(Value *S, const Type *Ty,
                                       const std::string &Name,
                                       BasicBlock *InsertAtEnd) {
   assert(isa<PointerType>(S->getType()) && "Invalid cast");
@@ -1893,12 +2035,12 @@ CastInst *CastInst::createPointerCast(Value *S, const Type *Ty,
          "Invalid cast");
 
   if (Ty->isInteger())
-    return create(Instruction::PtrToInt, S, Ty, Name, InsertAtEnd);
-  return create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
+    return Create(Instruction::PtrToInt, S, Ty, Name, InsertAtEnd);
+  return Create(Instruction::BitCast, S, Ty, Name, InsertAtEnd);
 }
 
 /// @brief Create a BitCast or a PtrToInt cast instruction
-CastInst *CastInst::createPointerCast(Value *S, const Type *Ty, 
+CastInst *CastInst::CreatePointerCast(Value *S, const Type *Ty, 
                                       const std::string &Name, 
                                       Instruction *InsertBefore) {
   assert(isa<PointerType>(S->getType()) && "Invalid cast");
@@ -1906,11 +2048,11 @@ CastInst *CastInst::createPointerCast(Value *S, const Type *Ty,
          "Invalid cast");
 
   if (Ty->isInteger())
-    return create(Instruction::PtrToInt, S, Ty, Name, InsertBefore);
-  return create(Instruction::BitCast, S, Ty, Name, InsertBefore);
+    return Create(Instruction::PtrToInt, S, Ty, Name, InsertBefore);
+  return Create(Instruction::BitCast, S, Ty, Name, InsertBefore);
 }
 
-CastInst *CastInst::createIntegerCast(Value *C, const Type *Ty, 
+CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty, 
                                       bool isSigned, const std::string &Name,
                                       Instruction *InsertBefore) {
   assert(C->getType()->isInteger() && Ty->isInteger() && "Invalid cast");
@@ -1920,10 +2062,10 @@ CastInst *CastInst::createIntegerCast(Value *C, const Type *Ty,
     (SrcBits == DstBits ? Instruction::BitCast :
      (SrcBits > DstBits ? Instruction::Trunc :
       (isSigned ? Instruction::SExt : Instruction::ZExt)));
-  return create(opcode, C, Ty, Name, InsertBefore);
+  return Create(opcode, C, Ty, Name, InsertBefore);
 }
 
-CastInst *CastInst::createIntegerCast(Value *C, const Type *Ty, 
+CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty, 
                                       bool isSigned, const std::string &Name,
                                       BasicBlock *InsertAtEnd) {
   assert(C->getType()->isInteger() && Ty->isInteger() && "Invalid cast");
@@ -1933,10 +2075,10 @@ CastInst *CastInst::createIntegerCast(Value *C, const Type *Ty,
     (SrcBits == DstBits ? Instruction::BitCast :
      (SrcBits > DstBits ? Instruction::Trunc :
       (isSigned ? Instruction::SExt : Instruction::ZExt)));
-  return create(opcode, C, Ty, Name, InsertAtEnd);
+  return Create(opcode, C, Ty, Name, InsertAtEnd);
 }
 
-CastInst *CastInst::createFPCast(Value *C, const Type *Ty, 
+CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty, 
                                  const std::string &Name, 
                                  Instruction *InsertBefore) {
   assert(C->getType()->isFloatingPoint() && Ty->isFloatingPoint() && 
@@ -1946,10 +2088,10 @@ CastInst *CastInst::createFPCast(Value *C, const Type *Ty,
   Instruction::CastOps opcode =
     (SrcBits == DstBits ? Instruction::BitCast :
      (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt));
-  return create(opcode, C, Ty, Name, InsertBefore);
+  return Create(opcode, C, Ty, Name, InsertBefore);
 }
 
-CastInst *CastInst::createFPCast(Value *C, const Type *Ty, 
+CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty, 
                                  const std::string &Name, 
                                  BasicBlock *InsertAtEnd) {
   assert(C->getType()->isFloatingPoint() && Ty->isFloatingPoint() && 
@@ -1959,7 +2101,7 @@ CastInst *CastInst::createFPCast(Value *C, const Type *Ty,
   Instruction::CastOps opcode =
     (SrcBits == DstBits ? Instruction::BitCast :
      (SrcBits > DstBits ? Instruction::FPTrunc : Instruction::FPExt));
-  return create(opcode, C, Ty, Name, InsertAtEnd);
+  return Create(opcode, C, Ty, Name, InsertAtEnd);
 }
 
 // Check whether it is valid to call getCastOpcode for these types.
@@ -1976,45 +2118,45 @@ bool CastInst::isCastable(const Type *SrcTy, const Type *DestTy) {
   unsigned DestBits = DestTy->getPrimitiveSizeInBits(); // 0 for ptr/vector
 
   // Run through the possibilities ...
-  if (DestTy->isInteger()) {                      // Casting to integral
-    if (SrcTy->isInteger()) {                     // Casting from integral
+  if (DestTy->isInteger()) {                   // Casting to integral
+    if (SrcTy->isInteger()) {                  // Casting from integral
         return true;
-    } else if (SrcTy->isFloatingPoint()) {        // Casting from floating pt
+    } else if (SrcTy->isFloatingPoint()) {     // Casting from floating pt
       return true;
     } else if (const VectorType *PTy = dyn_cast<VectorType>(SrcTy)) {
-                                                  // Casting from vector
+                                               // Casting from vector
       return DestBits == PTy->getBitWidth();
-    } else {                                      // Casting from something else
+    } else {                                   // Casting from something else
       return isa<PointerType>(SrcTy);
     }
-  } else if (DestTy->isFloatingPoint()) {         // Casting to floating pt
-    if (SrcTy->isInteger()) {                     // Casting from integral
+  } else if (DestTy->isFloatingPoint()) {      // Casting to floating pt
+    if (SrcTy->isInteger()) {                  // Casting from integral
       return true;
-    } else if (SrcTy->isFloatingPoint()) {        // Casting from floating pt
+    } else if (SrcTy->isFloatingPoint()) {     // Casting from floating pt
       return true;
     } else if (const VectorType *PTy = dyn_cast<VectorType>(SrcTy)) {
-                                                  // Casting from vector
+                                               // Casting from vector
       return DestBits == PTy->getBitWidth();
-    } else {                                      // Casting from something else
+    } else {                                   // Casting from something else
       return false;
     }
   } else if (const VectorType *DestPTy = dyn_cast<VectorType>(DestTy)) {
-                                                   // Casting to vector
+                                                // Casting to vector
     if (const VectorType *SrcPTy = dyn_cast<VectorType>(SrcTy)) {
-                                                   // Casting from vector
+                                                // Casting from vector
       return DestPTy->getBitWidth() == SrcPTy->getBitWidth();
-    } else {                                       // Casting from something else
+    } else {                                    // Casting from something else
       return DestPTy->getBitWidth() == SrcBits;
     }
-  } else if (isa<PointerType>(DestTy)) {           // Casting to pointer
-    if (isa<PointerType>(SrcTy)) {                 // Casting from pointer
+  } else if (isa<PointerType>(DestTy)) {        // Casting to pointer
+    if (isa<PointerType>(SrcTy)) {              // Casting from pointer
       return true;
-    } else if (SrcTy->isInteger()) {               // Casting from integral
+    } else if (SrcTy->isInteger()) {            // Casting from integral
       return true;
-    } else {                                       // Casting from something else
+    } else {                                    // Casting from something else
       return false;
     }
-  } else {                                         // Casting to something else
+  } else {                                      // Casting to something else
     return false;
   }
 }
@@ -2339,8 +2481,8 @@ CmpInst::CmpInst(const Type *ty, OtherOps op, unsigned short predicate,
                 OperandTraits<CmpInst>::op_begin(this),
                 OperandTraits<CmpInst>::operands(this),
                 InsertBefore) {
-    Op<0>().init(LHS, this);
-    Op<1>().init(RHS, this);
+    Op<0>() = LHS;
+    Op<1>() = RHS;
   SubclassData = predicate;
   setName(Name);
 }
@@ -2352,14 +2494,14 @@ CmpInst::CmpInst(const Type *ty, OtherOps op, unsigned short predicate,
                 OperandTraits<CmpInst>::op_begin(this),
                 OperandTraits<CmpInst>::operands(this),
                 InsertAtEnd) {
-  Op<0>().init(LHS, this);
-  Op<1>().init(RHS, this);
+  Op<0>() = LHS;
+  Op<1>() = RHS;
   SubclassData = predicate;
   setName(Name);
 }
 
 CmpInst *
-CmpInst::create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, 
+CmpInst::Create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, 
                 const std::string &Name, Instruction *InsertBefore) {
   if (Op == Instruction::ICmp) {
     return new ICmpInst(CmpInst::Predicate(predicate), S1, S2, Name, 
@@ -2378,7 +2520,7 @@ CmpInst::create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2,
 }
 
 CmpInst *
-CmpInst::create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, 
+CmpInst::Create(OtherOps Op, unsigned short predicate, Value *S1, Value *S2, 
                 const std::string &Name, BasicBlock *InsertAtEnd) {
   if (Op == Instruction::ICmp) {
     return new ICmpInst(CmpInst::Predicate(predicate), S1, S2, Name, 
@@ -2416,10 +2558,9 @@ bool CmpInst::isEquality() {
 }
 
 
-ICmpInst::Predicate ICmpInst::getInversePredicate(Predicate pred) {
+CmpInst::Predicate CmpInst::getInversePredicate(Predicate pred) {
   switch (pred) {
-    default:
-      assert(!"Unknown icmp predicate!");
+    default: assert(!"Unknown cmp predicate!");
     case ICMP_EQ: return ICMP_NE;
     case ICMP_NE: return ICMP_EQ;
     case ICMP_UGT: return ICMP_ULE;
@@ -2430,22 +2571,23 @@ ICmpInst::Predicate ICmpInst::getInversePredicate(Predicate pred) {
     case ICMP_SLT: return ICMP_SGE;
     case ICMP_SGE: return ICMP_SLT;
     case ICMP_SLE: return ICMP_SGT;
-  }
-}
 
-ICmpInst::Predicate ICmpInst::getSwappedPredicate(Predicate pred) {
-  switch (pred) {
-    default: assert(! "Unknown icmp predicate!");
-    case ICMP_EQ: case ICMP_NE:
-      return pred;
-    case ICMP_SGT: return ICMP_SLT;
-    case ICMP_SLT: return ICMP_SGT;
-    case ICMP_SGE: return ICMP_SLE;
-    case ICMP_SLE: return ICMP_SGE;
-    case ICMP_UGT: return ICMP_ULT;
-    case ICMP_ULT: return ICMP_UGT;
-    case ICMP_UGE: return ICMP_ULE;
-    case ICMP_ULE: return ICMP_UGE;
+    case FCMP_OEQ: return FCMP_UNE;
+    case FCMP_ONE: return FCMP_UEQ;
+    case FCMP_OGT: return FCMP_ULE;
+    case FCMP_OLT: return FCMP_UGE;
+    case FCMP_OGE: return FCMP_ULT;
+    case FCMP_OLE: return FCMP_UGT;
+    case FCMP_UEQ: return FCMP_ONE;
+    case FCMP_UNE: return FCMP_OEQ;
+    case FCMP_UGT: return FCMP_OLE;
+    case FCMP_ULT: return FCMP_OGE;
+    case FCMP_UGE: return FCMP_OLT;
+    case FCMP_ULE: return FCMP_OGT;
+    case FCMP_ORD: return FCMP_UNO;
+    case FCMP_UNO: return FCMP_ORD;
+    case FCMP_TRUE: return FCMP_FALSE;
+    case FCMP_FALSE: return FCMP_TRUE;
   }
 }
 
@@ -2521,32 +2663,20 @@ ICmpInst::makeConstantRange(Predicate pred, const APInt &C) {
   return ConstantRange(Lower, Upper);
 }
 
-FCmpInst::Predicate FCmpInst::getInversePredicate(Predicate pred) {
+CmpInst::Predicate CmpInst::getSwappedPredicate(Predicate pred) {
   switch (pred) {
-    default:
-      assert(!"Unknown icmp predicate!");
-    case FCMP_OEQ: return FCMP_UNE;
-    case FCMP_ONE: return FCMP_UEQ;
-    case FCMP_OGT: return FCMP_ULE;
-    case FCMP_OLT: return FCMP_UGE;
-    case FCMP_OGE: return FCMP_ULT;
-    case FCMP_OLE: return FCMP_UGT;
-    case FCMP_UEQ: return FCMP_ONE;
-    case FCMP_UNE: return FCMP_OEQ;
-    case FCMP_UGT: return FCMP_OLE;
-    case FCMP_ULT: return FCMP_OGE;
-    case FCMP_UGE: return FCMP_OLT;
-    case FCMP_ULE: return FCMP_OGT;
-    case FCMP_ORD: return FCMP_UNO;
-    case FCMP_UNO: return FCMP_ORD;
-    case FCMP_TRUE: return FCMP_FALSE;
-    case FCMP_FALSE: return FCMP_TRUE;
-  }
-}
-
-FCmpInst::Predicate FCmpInst::getSwappedPredicate(Predicate pred) {
-  switch (pred) {
-    default: assert(!"Unknown fcmp predicate!");
+    default: assert(!"Unknown cmp predicate!");
+    case ICMP_EQ: case ICMP_NE:
+      return pred;
+    case ICMP_SGT: return ICMP_SLT;
+    case ICMP_SLT: return ICMP_SGT;
+    case ICMP_SGE: return ICMP_SLE;
+    case ICMP_SLE: return ICMP_SGE;
+    case ICMP_UGT: return ICMP_ULT;
+    case ICMP_ULT: return ICMP_UGT;
+    case ICMP_UGE: return ICMP_ULE;
+    case ICMP_ULE: return ICMP_UGE;
+  
     case FCMP_FALSE: case FCMP_TRUE:
     case FCMP_OEQ: case FCMP_ONE:
     case FCMP_UEQ: case FCMP_UNE:
@@ -2607,8 +2737,8 @@ void SwitchInst::init(Value *Value, BasicBlock *Default, unsigned NumCases) {
   NumOperands = 2;
   OperandList = allocHungoffUses(ReservedSpace);
 
-  OperandList[0].init(Value, this);
-  OperandList[1].init(Default, this);
+  OperandList[0] = Value;
+  OperandList[1] = Default;
 }
 
 /// SwitchInst ctor - Create a new switch instruction, specifying a value to
@@ -2636,8 +2766,8 @@ SwitchInst::SwitchInst(const SwitchInst &SI)
                    allocHungoffUses(SI.getNumOperands()), SI.getNumOperands()) {
   Use *OL = OperandList, *InOL = SI.OperandList;
   for (unsigned i = 0, E = SI.getNumOperands(); i != E; i+=2) {
-    OL[i].init(InOL[i], this);
-    OL[i+1].init(InOL[i+1], this);
+    OL[i] = InOL[i];
+    OL[i+1] = InOL[i+1];
   }
 }
 
@@ -2655,8 +2785,8 @@ void SwitchInst::addCase(ConstantInt *OnVal, BasicBlock *Dest) {
   // Initialize some new operands.
   assert(OpNo+1 < ReservedSpace && "Growing didn't work!");
   NumOperands = OpNo+2;
-  OperandList[OpNo].init(OnVal, this);
-  OperandList[OpNo+1].init(Dest, this);
+  OperandList[OpNo] = OnVal;
+  OperandList[OpNo+1] = Dest;
 }
 
 /// removeCase - This method removes the specified successor from the switch
@@ -2710,7 +2840,7 @@ void SwitchInst::resizeOperands(unsigned NumOps) {
   Use *NewOps = allocHungoffUses(NumOps);
   Use *OldOps = OperandList;
   for (unsigned i = 0; i != e; ++i) {
-      NewOps[i].init(OldOps[i], this);
+      NewOps[i] = OldOps[i];
   }
   OperandList = NewOps;
   if (OldOps) Use::zap(OldOps, OldOps + e, true);
@@ -2772,7 +2902,7 @@ GetElementPtrInst *GetElementPtrInst::clone() const {
 }
 
 BinaryOperator *BinaryOperator::clone() const {
-  return create(getOpcode(), Op<0>(), Op<1>());
+  return Create(getOpcode(), Op<0>(), Op<1>());
 }
 
 FCmpInst* FCmpInst::clone() const {
@@ -2789,6 +2919,14 @@ VICmpInst* VICmpInst::clone() const {
   return new VICmpInst(getPredicate(), Op<0>(), Op<1>());
 }
 
+ExtractValueInst *ExtractValueInst::clone() const {
+  return new ExtractValueInst(*this);
+}
+InsertValueInst *InsertValueInst::clone() const {
+  return new InsertValueInst(*this);
+}
+
+
 MallocInst *MallocInst::clone()   const { return new MallocInst(*this); }
 AllocaInst *AllocaInst::clone()   const { return new AllocaInst(*this); }
 FreeInst   *FreeInst::clone()     const { return new FreeInst(getOperand(0)); }
@@ -2806,8 +2944,12 @@ CastInst   *FPToSIInst::clone()   const { return new FPToSIInst(*this); }
 CastInst   *PtrToIntInst::clone() const { return new PtrToIntInst(*this); }
 CastInst   *IntToPtrInst::clone() const { return new IntToPtrInst(*this); }
 CastInst   *BitCastInst::clone()  const { return new BitCastInst(*this); }
-CallInst   *CallInst::clone()     const { return new(getNumOperands()) CallInst(*this); }
-SelectInst *SelectInst::clone()   const { return new(getNumOperands()) SelectInst(*this); }
+CallInst   *CallInst::clone()     const {
+  return new(getNumOperands()) CallInst(*this);
+}
+SelectInst *SelectInst::clone()   const {
+  return new(getNumOperands()) SelectInst(*this);
+}
 VAArgInst  *VAArgInst::clone()    const { return new VAArgInst(*this); }
 
 ExtractElementInst *ExtractElementInst::clone() const {
@@ -2820,10 +2962,16 @@ ShuffleVectorInst *ShuffleVectorInst::clone() const {
   return new ShuffleVectorInst(*this);
 }
 PHINode    *PHINode::clone()    const { return new PHINode(*this); }
-ReturnInst *ReturnInst::clone() const { return new(getNumOperands()) ReturnInst(*this); }
-BranchInst *BranchInst::clone() const { return new(getNumOperands()) BranchInst(*this); }
+ReturnInst *ReturnInst::clone() const {
+  return new(getNumOperands()) ReturnInst(*this);
+}
+BranchInst *BranchInst::clone() const {
+  return new(getNumOperands()) BranchInst(*this);
+}
 SwitchInst *SwitchInst::clone() const { return new SwitchInst(*this); }
-InvokeInst *InvokeInst::clone() const { return new(getNumOperands()) InvokeInst(*this); }
+InvokeInst *InvokeInst::clone() const {
+  return new(getNumOperands()) InvokeInst(*this);
+}
 UnwindInst *UnwindInst::clone() const { return new UnwindInst(); }
 UnreachableInst *UnreachableInst::clone() const { return new UnreachableInst();}
 GetResultInst *GetResultInst::clone() const { return new GetResultInst(*this); }