Move more code back to 2.5 APIs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77635 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 0b7e9d9..fbdca72 100644
--- a/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -758,7 +758,7 @@
       }
 
     if (ExtraArgHack)
-      Args.push_back(Context.getUndef(Type::Int32Ty));
+      Args.push_back(UndefValue::get(Type::Int32Ty));
 
     // Push any varargs arguments on the list. Don't forget their attributes.
     for (CallSite::arg_iterator E = CS.arg_end(); I != E; ++I, ++i) {
@@ -814,7 +814,7 @@
         // extract/insertvalue chaining and let instcombine clean that up.
         //
         // Start out building up our return value from undef
-        Value *RetVal = Context.getUndef(RetTy);
+        Value *RetVal = UndefValue::get(RetTy);
         for (unsigned i = 0; i != RetCount; ++i)
           if (NewRetIdxs[i] != -1) {
             Value *V;
@@ -881,7 +881,7 @@
           // clean that up.
           Value *OldRet = RI->getOperand(0);
           // Start out building up our return value from undef
-          RetVal = Context.getUndef(NRetTy);
+          RetVal = UndefValue::get(NRetTy);
           for (unsigned i = 0; i != RetCount; ++i)
             if (NewRetIdxs[i] != -1) {
               ExtractValueInst *EV = ExtractValueInst::Create(OldRet, i,
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index e0e5b60..d2a5313 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -269,10 +269,10 @@
   } else if (isa<UndefValue>(Agg)) {
     if (const StructType *STy = dyn_cast<StructType>(Agg->getType())) {
       if (IdxV < STy->getNumElements())
-        return Context.getUndef(STy->getElementType(IdxV));
+        return UndefValue::get(STy->getElementType(IdxV));
     } else if (const SequentialType *STy =
                dyn_cast<SequentialType>(Agg->getType())) {
-      return Context.getUndef(STy->getElementType());
+      return UndefValue::get(STy->getElementType());
     }
   }
   return 0;
@@ -844,7 +844,7 @@
   // FIXME: This new global should have the alignment returned by malloc.  Code
   // could depend on malloc returning large alignment (on the mac, 16 bytes) but
   // this would only guarantee some lower alignment.
-  Constant *Init = Context.getUndef(MI->getAllocatedType());
+  Constant *Init = UndefValue::get(MI->getAllocatedType());
   GlobalVariable *NewGV = new GlobalVariable(*GV->getParent(), 
                                              MI->getAllocatedType(), false,
                                              GlobalValue::InternalLinkage, Init,
@@ -2056,7 +2056,7 @@
         Elts.push_back(Context.getNullValue(STy->getElementType(i)));
     } else if (isa<UndefValue>(Init)) {
       for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i)
-        Elts.push_back(Context.getUndef(STy->getElementType(i)));
+        Elts.push_back(UndefValue::get(STy->getElementType(i)));
     } else {
       llvm_unreachable("This code is out of sync with "
              " ConstantFoldLoadThroughGEPConstantExpr");
@@ -2083,7 +2083,7 @@
       Constant *Elt = Context.getNullValue(ATy->getElementType());
       Elts.assign(ATy->getNumElements(), Elt);
     } else if (isa<UndefValue>(Init)) {
-      Constant *Elt = Context.getUndef(ATy->getElementType());
+      Constant *Elt = UndefValue::get(ATy->getElementType());
       Elts.assign(ATy->getNumElements(), Elt);
     } else {
       llvm_unreachable("This code is out of sync with "
@@ -2227,7 +2227,7 @@
       const Type *Ty = AI->getType()->getElementType();
       AllocaTmps.push_back(new GlobalVariable(Context, Ty, false,
                                               GlobalValue::InternalLinkage,
-                                              Context.getUndef(Ty),
+                                              UndefValue::get(Ty),
                                               AI->getName()));
       InstResult = AllocaTmps.back();     
     } else if (CallInst *CI = dyn_cast<CallInst>(CurInst)) {
diff --git a/lib/Transforms/IPO/IPConstantPropagation.cpp b/lib/Transforms/IPO/IPConstantPropagation.cpp
index adb5242..4edecc2 100644
--- a/lib/Transforms/IPO/IPConstantPropagation.cpp
+++ b/lib/Transforms/IPO/IPConstantPropagation.cpp
@@ -134,7 +134,7 @@
       continue;
   
     Value *V = ArgumentConstants[i].first;
-    if (V == 0) V = F.getContext().getUndef(AI->getType());
+    if (V == 0) V = UndefValue::get(AI->getType());
     AI->replaceAllUsesWith(V);
     ++NumArgumentsProped;
     MadeChange = true;
@@ -167,9 +167,9 @@
   const StructType *STy = dyn_cast<StructType>(F.getReturnType());
   if (STy)
     for (unsigned i = 0, e = STy->getNumElements(); i < e; ++i) 
-      RetVals.push_back(Context.getUndef(STy->getElementType(i)));
+      RetVals.push_back(UndefValue::get(STy->getElementType(i)));
   else
-    RetVals.push_back(Context.getUndef(F.getReturnType()));
+    RetVals.push_back(UndefValue::get(F.getReturnType()));
 
   unsigned NumNonConstant = 0;
   for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp
index d2837a3..3a65ac7 100644
--- a/lib/Transforms/IPO/LowerSetJmp.cpp
+++ b/lib/Transforms/IPO/LowerSetJmp.cpp
@@ -289,8 +289,7 @@
     Removed = &BB->back();
     // If the removed instructions have any users, replace them now.
     if (!Removed->use_empty())
-      Removed->replaceAllUsesWith(
-        Inst->getContext().getUndef(Removed->getType()));
+      Removed->replaceAllUsesWith(UndefValue::get(Removed->getType()));
     Removed->eraseFromParent();
   } while (Removed != Inst);
 
diff --git a/lib/Transforms/IPO/PruneEH.cpp b/lib/Transforms/IPO/PruneEH.cpp
index a98a793..d2a6530 100644
--- a/lib/Transforms/IPO/PruneEH.cpp
+++ b/lib/Transforms/IPO/PruneEH.cpp
@@ -243,7 +243,7 @@
     } else if (InvokeInst *II = dyn_cast<InvokeInst>(I))
       CGN->removeCallEdgeFor(II);
     if (!I->use_empty())
-      I->replaceAllUsesWith(BB->getContext().getUndef(I->getType()));
+      I->replaceAllUsesWith(UndefValue::get(I->getType()));
   }
 
   // Get the list of successors of this block.
diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp
index 943d3cf..0ef0991 100644
--- a/lib/Transforms/IPO/RaiseAllocations.cpp
+++ b/lib/Transforms/IPO/RaiseAllocations.cpp
@@ -142,8 +142,6 @@
   // Find the malloc/free prototypes...
   doInitialization(M);
   
-  LLVMContext &Context = M.getContext();
-
   bool Changed = false;
 
   // First, process all of the malloc calls...
@@ -233,7 +231,7 @@
 
           // Delete the old call site
           if (I->getType() != Type::VoidTy)
-            I->replaceAllUsesWith(Context.getUndef(I->getType()));
+            I->replaceAllUsesWith(UndefValue::get(I->getType()));
           I->eraseFromParent();
           Changed = true;
           ++NumRaised;
diff --git a/lib/Transforms/IPO/StripSymbols.cpp b/lib/Transforms/IPO/StripSymbols.cpp
index f2b561d..1bbda3c 100644
--- a/lib/Transforms/IPO/StripSymbols.cpp
+++ b/lib/Transforms/IPO/StripSymbols.cpp
@@ -232,7 +232,7 @@
     if (!GV) continue;
     if (!GV->use_empty() && llvmUsedValues.count(I) == 0) {
       if (GV->getName().startswith("llvm.dbg")) {
-        GV->replaceAllUsesWith(M.getContext().getUndef(GV->getType()));
+        GV->replaceAllUsesWith(UndefValue::get(GV->getType()));
       }
     }
   }