Move types back to the 2.5 API.

llvm-svn: 77516
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
index cb5787b..5cf3a9b 100644
--- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -588,7 +588,7 @@
   }
 
   // Construct the new function type using the new arguments.
-  FunctionType *NFTy = Context.getFunctionType(RetTy, Params, FTy->isVarArg());
+  FunctionType *NFTy = FunctionType::get(RetTy, Params, FTy->isVarArg());
 
   // Create the new function body and insert it into the module...
   Function *NF = Function::Create(NFTy, F->getLinkage(), F->getName());
diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
index 6321048..0b7e9d987 100644
--- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -197,10 +197,9 @@
   // Start by computing a new prototype for the function, which is the same as
   // the old function, but doesn't have isVarArg set.
   const FunctionType *FTy = Fn.getFunctionType();
-  LLVMContext &Context = FTy->getContext();
   
   std::vector<const Type*> Params(FTy->param_begin(), FTy->param_end());
-  FunctionType *NFTy = Context.getFunctionType(FTy->getReturnType(),
+  FunctionType *NFTy = FunctionType::get(FTy->getReturnType(),
                                                 Params, false);
   unsigned NumArgs = Params.size();
 
@@ -641,7 +640,7 @@
       // something and {} into void.
       // Make the new struct packed if we used to return a packed struct
       // already.
-      NRetTy = Context.getStructType(RetTypes, STy->isPacked());
+      NRetTy = StructType::get(RetTypes, STy->isPacked());
     else if (RetTypes.size() == 1)
       // One return type? Just a simple value then, but only if we didn't use to
       // return a struct with that simple value before.
@@ -709,7 +708,7 @@
   }
 
   // Create the new function type based on the recomputed parameters.
-  FunctionType *NFTy = Context.getFunctionType(NRetTy, Params,
+  FunctionType *NFTy = FunctionType::get(NRetTy, Params,
                                                 FTy->isVarArg());
 
   // No change?
diff --git a/llvm/lib/Transforms/IPO/ExtractGV.cpp b/llvm/lib/Transforms/IPO/ExtractGV.cpp
index 9c28fdb..dfbad61 100644
--- a/llvm/lib/Transforms/IPO/ExtractGV.cpp
+++ b/llvm/lib/Transforms/IPO/ExtractGV.cpp
@@ -103,13 +103,13 @@
       // by putting them in the used array
       {
         std::vector<Constant *> AUGs;
-        const Type *SBP= Context.getPointerTypeUnqual(Type::Int8Ty);
+        const Type *SBP= PointerType::getUnqual(Type::Int8Ty);
         for (std::vector<GlobalValue*>::iterator GI = Named.begin(), 
                GE = Named.end(); GI != GE; ++GI) {
           (*GI)->setLinkage(GlobalValue::ExternalLinkage);
           AUGs.push_back(ConstantExpr::getBitCast(*GI, SBP));
         }
-        ArrayType *AT = Context.getArrayType(SBP, AUGs.size());
+        ArrayType *AT = ArrayType::get(SBP, AUGs.size());
         Constant *Init = ConstantArray::get(AT, AUGs);
         GlobalValue *gv = new GlobalVariable(M, AT, false, 
                                              GlobalValue::AppendingLinkage, 
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index 5be3239..61e4316 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -826,7 +826,7 @@
   if (NElements->getZExtValue() != 1) {
     // If we have an array allocation, transform it to a single element
     // allocation to make the code below simpler.
-    Type *NewTy = Context.getArrayType(MI->getAllocatedType(),
+    Type *NewTy = ArrayType::get(MI->getAllocatedType(),
                                  NElements->getZExtValue());
     MallocInst *NewMI =
       new MallocInst(NewTy, Context.getNullValue(Type::Int32Ty),
@@ -1161,7 +1161,7 @@
       cast<StructType>(cast<PointerType>(PN->getType())->getElementType());
     
     Result =
-     PHINode::Create(Context.getPointerTypeUnqual(ST->getElementType(FieldNo)),
+     PHINode::Create(PointerType::getUnqual(ST->getElementType(FieldNo)),
                             PN->getName()+".f"+utostr(FieldNo), PN);
     PHIsToRewrite.push_back(std::make_pair(PN, FieldNo));
   } else {
@@ -1282,7 +1282,7 @@
   
   for (unsigned FieldNo = 0, e = STy->getNumElements(); FieldNo != e;++FieldNo){
     const Type *FieldTy = STy->getElementType(FieldNo);
-    const Type *PFieldTy = Context.getPointerTypeUnqual(FieldTy);
+    const Type *PFieldTy = PointerType::getUnqual(FieldTy);
     
     GlobalVariable *NGV =
       new GlobalVariable(*GV->getParent(),
@@ -1957,8 +1957,8 @@
     if (Ctors[i]) {
       CSVals[1] = Ctors[i];
     } else {
-      const Type *FTy = Context.getFunctionType(Type::VoidTy, false);
-      const PointerType *PFTy = Context.getPointerTypeUnqual(FTy);
+      const Type *FTy = FunctionType::get(Type::VoidTy, false);
+      const PointerType *PFTy = PointerType::getUnqual(FTy);
       CSVals[1] = Context.getNullValue(PFTy);
       CSVals[0] = ConstantInt::get(Type::Int32Ty, 2147483647);
     }
diff --git a/llvm/lib/Transforms/IPO/LowerSetJmp.cpp b/llvm/lib/Transforms/IPO/LowerSetJmp.cpp
index 980123a..d2837a3 100644
--- a/llvm/lib/Transforms/IPO/LowerSetJmp.cpp
+++ b/llvm/lib/Transforms/IPO/LowerSetJmp.cpp
@@ -201,9 +201,8 @@
 // This function is always successful, unless it isn't.
 bool LowerSetJmp::doInitialization(Module& M)
 {
-  LLVMContext &Context = M.getContext();
-  const Type *SBPTy = Context.getPointerTypeUnqual(Type::Int8Ty);
-  const Type *SBPPTy = Context.getPointerTypeUnqual(SBPTy);
+  const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty);
+  const Type *SBPPTy = PointerType::getUnqual(SBPTy);
 
   // N.B. See llvm/runtime/GCCLibraries/libexception/SJLJ-Exception.h for
   // a description of the following library functions.
@@ -259,7 +258,7 @@
 // throwing the exception for us.
 void LowerSetJmp::TransformLongJmpCall(CallInst* Inst)
 {
-  const Type* SBPTy = Inst->getContext().getPointerTypeUnqual(Type::Int8Ty);
+  const Type* SBPTy = PointerType::getUnqual(Type::Int8Ty);
 
   // Create the call to "__llvm_sjljeh_throw_longjmp". This takes the
   // same parameters as "longjmp", except that the buffer is cast to a
@@ -312,7 +311,7 @@
   assert(Inst && "Couldn't find even ONE instruction in entry block!");
 
   // Fill in the alloca and call to initialize the SJ map.
-  const Type *SBPTy = Func->getContext().getPointerTypeUnqual(Type::Int8Ty);
+  const Type *SBPTy = PointerType::getUnqual(Type::Int8Ty);
   AllocaInst* Map = new AllocaInst(SBPTy, 0, "SJMap", Inst);
   CallInst::Create(InitSJMap, Map, "", Inst);
   return SJMap[Func] = Map;
@@ -378,7 +377,7 @@
   Function* Func = ABlock->getParent();
 
   // Add this setjmp to the setjmp map.
-  const Type* SBPTy = Inst->getContext().getPointerTypeUnqual(Type::Int8Ty);
+  const Type* SBPTy = PointerType::getUnqual(Type::Int8Ty);
   CastInst* BufPtr = 
     new BitCastInst(Inst->getOperand(1), SBPTy, "SBJmpBuf", Inst);
   std::vector<Value*> Args = 
diff --git a/llvm/lib/Transforms/IPO/RaiseAllocations.cpp b/llvm/lib/Transforms/IPO/RaiseAllocations.cpp
index 3c9178e..943d3cf 100644
--- a/llvm/lib/Transforms/IPO/RaiseAllocations.cpp
+++ b/llvm/lib/Transforms/IPO/RaiseAllocations.cpp
@@ -70,8 +70,6 @@
 // function into the appropriate instruction.
 //
 void RaiseAllocations::doInitialization(Module &M) {
-  LLVMContext &Context = M.getContext();
-  
   // Get Malloc and free prototypes if they exist!
   MallocFunc = M.getFunction("malloc");
   if (MallocFunc) {
@@ -79,7 +77,7 @@
 
     // Get the expected prototype for malloc
     const FunctionType *Malloc1Type = 
-      Context.getFunctionType(Context.getPointerTypeUnqual(Type::Int8Ty),
+      FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
                       std::vector<const Type*>(1, Type::Int64Ty), false);
 
     // Chck to see if we got the expected malloc
@@ -87,14 +85,14 @@
       // Check to see if the prototype is wrong, giving us i8*(i32) * malloc
       // This handles the common declaration of: 'void *malloc(unsigned);'
       const FunctionType *Malloc2Type = 
-        Context.getFunctionType(Context.getPointerTypeUnqual(Type::Int8Ty),
+        FunctionType::get(PointerType::getUnqual(Type::Int8Ty),
                           std::vector<const Type*>(1, Type::Int32Ty), false);
       if (TyWeHave != Malloc2Type) {
         // Check to see if the prototype is missing, giving us 
         // i8*(...) * malloc
         // This handles the common declaration of: 'void *malloc();'
         const FunctionType *Malloc3Type = 
-          Context.getFunctionType(Context.getPointerTypeUnqual(Type::Int8Ty), 
+          FunctionType::get(PointerType::getUnqual(Type::Int8Ty), 
                                     true);
         if (TyWeHave != Malloc3Type)
           // Give up
@@ -108,21 +106,21 @@
     const FunctionType* TyWeHave = FreeFunc->getFunctionType();
     
     // Get the expected prototype for void free(i8*)
-    const FunctionType *Free1Type = Context.getFunctionType(Type::VoidTy,
-      std::vector<const Type*>(1, Context.getPointerTypeUnqual(Type::Int8Ty)), 
+    const FunctionType *Free1Type = FunctionType::get(Type::VoidTy,
+      std::vector<const Type*>(1, PointerType::getUnqual(Type::Int8Ty)), 
                                false);
 
     if (TyWeHave != Free1Type) {
       // Check to see if the prototype was forgotten, giving us 
       // void (...) * free
       // This handles the common forward declaration of: 'void free();'
-      const FunctionType* Free2Type = Context.getFunctionType(Type::VoidTy, 
+      const FunctionType* Free2Type = FunctionType::get(Type::VoidTy, 
                                                                true);
 
       if (TyWeHave != Free2Type) {
         // One last try, check to see if we can find free as 
         // int (...)* free.  This handles the case where NOTHING was declared.
-        const FunctionType* Free3Type = Context.getFunctionType(Type::Int32Ty,
+        const FunctionType* Free3Type = FunctionType::get(Type::Int32Ty,
                                                                  true);
         
         if (TyWeHave != Free3Type) {
@@ -224,7 +222,7 @@
           Value *Source = *CS.arg_begin();
           if (!isa<PointerType>(Source->getType()))
             Source = new IntToPtrInst(Source,           
-                                   Context.getPointerTypeUnqual(Type::Int8Ty), 
+                                   PointerType::getUnqual(Type::Int8Ty), 
                                       "FreePtrCast", I);
           new FreeInst(Source, I);
 
diff --git a/llvm/lib/Transforms/IPO/StructRetPromotion.cpp b/llvm/lib/Transforms/IPO/StructRetPromotion.cpp
index 8d6671d..a241359 100644
--- a/llvm/lib/Transforms/IPO/StructRetPromotion.cpp
+++ b/llvm/lib/Transforms/IPO/StructRetPromotion.cpp
@@ -232,8 +232,7 @@
     AttributesVec.push_back(AttributeWithIndex::get(~0, attrs));
 
 
-  FunctionType *NFTy =
-    F->getContext().getFunctionType(STy, Params, FTy->isVarArg());
+  FunctionType *NFTy = FunctionType::get(STy, Params, FTy->isVarArg());
   Function *NF = Function::Create(NFTy, F->getLinkage());
   NF->takeName(F);
   NF->copyAttributesFrom(F);