Push LLVMContexts through the IntegerType APIs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78948 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp
index 9d4e98c..4e15732 100644
--- a/tools/bugpoint/CrashDebugger.cpp
+++ b/tools/bugpoint/CrashDebugger.cpp
@@ -297,12 +297,13 @@
         
         if (isa<StructType>(BBTerm->getType()))
            BBTerm->replaceAllUsesWith(UndefValue::get(BBTerm->getType()));
-        else if (BB->getTerminator()->getType() != Type::VoidTy)
+        else if (BB->getTerminator()->getType() != 
+                    Type::getVoidTy(BB->getContext()))
           BBTerm->replaceAllUsesWith(Constant::getNullValue(BBTerm->getType()));
 
         // Replace the old terminator instruction.
         BB->getInstList().pop_back();
-        new UnreachableInst(BB);
+        new UnreachableInst(BB->getContext(), BB);
       }
 
   // The CFG Simplifier pass may delete one of the basic blocks we are
@@ -332,7 +333,7 @@
     for (unsigned i = 0, e = BlockInfo.size(); i != e; ++i) {
       ValueSymbolTable &ST = BlockInfo[i].first->getValueSymbolTable();
       Value* V = ST.lookup(BlockInfo[i].second);
-      if (V && V->getType() == Type::LabelTy)
+      if (V && V->getType() == Type::getLabelTy(V->getContext()))
         BBs.push_back(cast<BasicBlock>(V));
     }
     return true;
@@ -390,7 +391,7 @@
       for (BasicBlock::iterator I = FI->begin(), E = FI->end(); I != E;) {
         Instruction *Inst = I++;
         if (!Instructions.count(Inst) && !isa<TerminatorInst>(Inst)) {
-          if (Inst->getType() != Type::VoidTy)
+          if (Inst->getType() != Type::getVoidTy(Inst->getContext()))
             Inst->replaceAllUsesWith(UndefValue::get(Inst->getType()));
           Inst->eraseFromParent();
         }
diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp
index 684dde3..9fdcc1b 100644
--- a/tools/bugpoint/ExtractFunction.cpp
+++ b/tools/bugpoint/ExtractFunction.cpp
@@ -73,7 +73,7 @@
   // If this instruction produces a value, replace any users with null values
   if (isa<StructType>(TheInst->getType()))
     TheInst->replaceAllUsesWith(UndefValue::get(TheInst->getType()));
-  else if (TheInst->getType() != Type::VoidTy)
+  else if (TheInst->getType() != Type::getVoidTy(I->getContext()))
     TheInst->replaceAllUsesWith(Constant::getNullValue(TheInst->getType()));
 
   // Remove the instruction from the program.
@@ -184,7 +184,8 @@
   std::vector<Constant*> ArrayElts;
   for (unsigned i = 0, e = TorList.size(); i != e; ++i) {
     std::vector<Constant*> Elts;
-    Elts.push_back(ConstantInt::get(Type::Int32Ty, TorList[i].second));
+    Elts.push_back(ConstantInt::get(
+          Type::getInt32Ty(TorList[i].first->getContext()), TorList[i].second));
     Elts.push_back(TorList[i].first);
     ArrayElts.push_back(ConstantStruct::get(
                                         TorList[i].first->getContext(), Elts));
diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp
index 00f26fe..64dfe88 100644
--- a/tools/bugpoint/Miscompilation.cpp
+++ b/tools/bugpoint/Miscompilation.cpp
@@ -682,12 +682,12 @@
       }
 
       // Call the old main function and return its result
-      BasicBlock *BB = BasicBlock::Create("entry", newMain);
+      BasicBlock *BB = BasicBlock::Create(Safe->getContext(), "entry", newMain);
       CallInst *call = CallInst::Create(oldMainProto, args.begin(), args.end(),
                                         "", BB);
 
       // If the type of old function wasn't void, return value of call
-      ReturnInst::Create(call, BB);
+      ReturnInst::Create(Safe->getContext(), call, BB);
     }
 
   // The second nasty issue we must deal with in the JIT is that the Safe
@@ -699,8 +699,9 @@
   // Prototype: void *getPointerToNamedFunction(const char* Name)
   Constant *resolverFunc =
     Safe->getOrInsertFunction("getPointerToNamedFunction",
-                        PointerType::getUnqual(Type::Int8Ty),
-                        PointerType::getUnqual(Type::Int8Ty), (Type *)0);
+                    PointerType::getUnqual(Type::getInt8Ty(Safe->getContext())),
+                    PointerType::getUnqual(Type::getInt8Ty(Safe->getContext())),
+                       (Type *)0);
 
   // Use the function we just added to get addresses of functions we need.
   for (Module::iterator F = Safe->begin(), E = Safe->end(); F != E; ++F) {
@@ -711,7 +712,7 @@
       // Don't forward functions which are external in the test module too.
       if (TestFn && !TestFn->isDeclaration()) {
         // 1. Add a string constant with its name to the global file
-        Constant *InitArray = ConstantArray::get(F->getName());
+        Constant *InitArray = ConstantArray::get(F->getContext(), F->getName());
         GlobalVariable *funcName =
           new GlobalVariable(*Safe, InitArray->getType(), true /*isConstant*/,
                              GlobalValue::InternalLinkage, InitArray,
@@ -721,7 +722,8 @@
         // sbyte* so it matches the signature of the resolver function.
 
         // GetElementPtr *funcName, ulong 0, ulong 0
-        std::vector<Constant*> GEPargs(2, Constant::getNullValue(Type::Int32Ty));
+        std::vector<Constant*> GEPargs(2,
+                     Constant::getNullValue(Type::getInt32Ty(F->getContext())));
         Value *GEP =
                 ConstantExpr::getGetElementPtr(funcName, &GEPargs[0], 2);
         std::vector<Value*> ResolverArgs;
@@ -743,9 +745,12 @@
                                                    GlobalValue::InternalLinkage,
                                                    F->getName() + "_wrapper",
                                                    F->getParent());
-          BasicBlock *EntryBB  = BasicBlock::Create("entry", FuncWrapper);
-          BasicBlock *DoCallBB = BasicBlock::Create("usecache", FuncWrapper);
-          BasicBlock *LookupBB = BasicBlock::Create("lookupfp", FuncWrapper);
+          BasicBlock *EntryBB  = BasicBlock::Create(F->getContext(),
+                                                    "entry", FuncWrapper);
+          BasicBlock *DoCallBB = BasicBlock::Create(F->getContext(),
+                                                    "usecache", FuncWrapper);
+          BasicBlock *LookupBB = BasicBlock::Create(F->getContext(),
+                                                    "lookupfp", FuncWrapper);
 
           // Check to see if we already looked up the value.
           Value *CachedVal = new LoadInst(Cache, "fpcache", EntryBB);
@@ -782,13 +787,13 @@
             Args.push_back(i);
 
           // Pass on the arguments to the real function, return its result
-          if (F->getReturnType() == Type::VoidTy) {
+          if (F->getReturnType() == Type::getVoidTy(F->getContext())) {
             CallInst::Create(FuncPtr, Args.begin(), Args.end(), "", DoCallBB);
-            ReturnInst::Create(DoCallBB);
+            ReturnInst::Create(F->getContext(), DoCallBB);
           } else {
             CallInst *Call = CallInst::Create(FuncPtr, Args.begin(), Args.end(),
                                               "retval", DoCallBB);
-            ReturnInst::Create(Call, DoCallBB);
+            ReturnInst::Create(F->getContext(),Call, DoCallBB);
           }
 
           // Use the wrapper function instead of the old function
diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp
index 36054fd..9c8cc6c 100644
--- a/tools/lli/lli.cpp
+++ b/tools/lli/lli.cpp
@@ -195,8 +195,9 @@
 
   // If the program doesn't explicitly call exit, we will need the Exit 
   // function later on to make an explicit call, so get the function now. 
-  Constant *Exit = Mod->getOrInsertFunction("exit", Type::VoidTy,
-                                                        Type::Int32Ty, NULL);
+  Constant *Exit = Mod->getOrInsertFunction("exit", Type::getVoidTy(Context),
+                                                    Type::getInt32Ty(Context),
+                                                    NULL);
   
   // Reset errno to zero on entry to main.
   errno = 0;