Begin the painful process of tearing apart the rat'ss nest that is Constants.cpp and ConstantFold.cpp.
This involves temporarily hard wiring some parts to use the global context.  This isn't ideal, but it's
the only way I could figure out to make this process vaguely incremental.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75445 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp
index 9697b34..3084857 100644
--- a/tools/bugpoint/CrashDebugger.cpp
+++ b/tools/bugpoint/CrashDebugger.cpp
@@ -299,7 +299,8 @@
         if (isa<StructType>(BBTerm->getType()))
            BBTerm->replaceAllUsesWith(UndefValue::get(BBTerm->getType()));
         else if (BB->getTerminator()->getType() != Type::VoidTy)
-          BBTerm->replaceAllUsesWith(Constant::getNullValue(BBTerm->getType()));
+          BBTerm->replaceAllUsesWith(
+                               BD.getContext().getNullValue(BBTerm->getType()));
 
         // Replace the old terminator instruction.
         BB->getInstList().pop_back();
diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp
index 6cd2d19..4498f98 100644
--- a/tools/bugpoint/ExtractFunction.cpp
+++ b/tools/bugpoint/ExtractFunction.cpp
@@ -74,7 +74,7 @@
   if (isa<StructType>(TheInst->getType()))
     TheInst->replaceAllUsesWith(UndefValue::get(TheInst->getType()));
   else if (TheInst->getType() != Type::VoidTy)
-    TheInst->replaceAllUsesWith(Constant::getNullValue(TheInst->getType()));
+    TheInst->replaceAllUsesWith(Context.getNullValue(TheInst->getType()));
 
   // Remove the instruction from the program.
   TheInst->getParent()->getInstList().erase(TheInst);
diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp
index 785abb9..5fffcc1 100644
--- a/tools/bugpoint/Miscompilation.cpp
+++ b/tools/bugpoint/Miscompilation.cpp
@@ -711,7 +711,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,
+                                   BD.getContext().getNullValue(Type::Int32Ty));
         Value *GEP = ConstantExpr::getGetElementPtr(funcName, &GEPargs[0], 2);
         std::vector<Value*> ResolverArgs;
         ResolverArgs.push_back(GEP);
diff --git a/tools/bugpoint/TestPasses.cpp b/tools/bugpoint/TestPasses.cpp
index 900bf63..2c5b3b2 100644
--- a/tools/bugpoint/TestPasses.cpp
+++ b/tools/bugpoint/TestPasses.cpp
@@ -60,7 +60,7 @@
       for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I)
         if (CallInst *CI = dyn_cast<CallInst>(I)) {
           if (!CI->use_empty())
-            CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
+            CI->replaceAllUsesWith(Context->getNullValue(CI->getType()));
           CI->getParent()->getInstList().erase(CI);
           break;
         }
diff --git a/tools/lto/LTOModule.cpp b/tools/lto/LTOModule.cpp
index c4980d6..591547f 100644
--- a/tools/lto/LTOModule.cpp
+++ b/tools/lto/LTOModule.cpp
@@ -189,7 +189,7 @@
         if (GlobalVariable* gvn = dyn_cast<GlobalVariable>(op)) {
             Constant* cn = gvn->getInitializer(); 
             if (ConstantArray* ca = dyn_cast<ConstantArray>(cn)) {
-                if ( ca->isCString() ) {
+                if ( ca->isCString(getGlobalContext()) ) {
                     name = ".objc_class_name_" + ca->getAsString();
                     return true;
                 }