assert(0) -> LLVM_UNREACHABLE.
Make llvm_unreachable take an optional string, thus moving the cerr<< out of
line.
LLVM_UNREACHABLE is now a simple wrapper that makes the message go away for
NDEBUG builds.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75379 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index 366005b..57a8d28 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -28,6 +28,7 @@
 #include "llvm/Support/CallSite.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/GetElementPtrTypeIterator.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/ADT/DenseMap.h"
@@ -882,7 +883,7 @@
           Value *LV = new LoadInst(InitBool, InitBool->getName()+".val", CI);
           InitBoolUsed = true;
           switch (CI->getPredicate()) {
-          default: assert(0 && "Unknown ICmp Predicate!");
+          default: LLVM_UNREACHABLE("Unknown ICmp Predicate!");
           case ICmpInst::ICMP_ULT:
           case ICmpInst::ICMP_SLT:
             LV = Context->getConstantIntFalse();   // X < null -> always false
@@ -1163,7 +1164,7 @@
                             PN->getName()+".f"+utostr(FieldNo), PN);
     PHIsToRewrite.push_back(std::make_pair(PN, FieldNo));
   } else {
-    assert(0 && "Unknown usable value");
+    LLVM_UNREACHABLE("Unknown usable value");
     Result = 0;
   }
   
@@ -2056,7 +2057,7 @@
       for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i)
         Elts.push_back(Context->getUndef(STy->getElementType(i)));
     } else {
-      assert(0 && "This code is out of sync with "
+      LLVM_UNREACHABLE("This code is out of sync with "
              " ConstantFoldLoadThroughGEPConstantExpr");
     }
     
@@ -2084,7 +2085,7 @@
       Constant *Elt = Context->getUndef(ATy->getElementType());
       Elts.assign(ATy->getNumElements(), Elt);
     } else {
-      assert(0 && "This code is out of sync with "
+      LLVM_UNREACHABLE("This code is out of sync with "
              " ConstantFoldLoadThroughGEPConstantExpr");
     }
     
diff --git a/lib/Transforms/IPO/MergeFunctions.cpp b/lib/Transforms/IPO/MergeFunctions.cpp
index 9d87403..31e36d8 100644
--- a/lib/Transforms/IPO/MergeFunctions.cpp
+++ b/lib/Transforms/IPO/MergeFunctions.cpp
@@ -53,6 +53,7 @@
 #include "llvm/Support/CallSite.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
 #include <map>
 #include <vector>
 using namespace llvm;
@@ -128,7 +129,7 @@
     return false;
 
   default:
-    assert(0 && "Unknown type!");
+    LLVM_UNREACHABLE("Unknown type!");
     return false;
 
   case Type::PointerTyID: {
@@ -469,7 +470,7 @@
     return ExternalStrong;
   }
 
-  assert(0 && "Unknown LinkageType.");
+  LLVM_UNREACHABLE("Unknown LinkageType.");
   return ExternalWeak;
 }
 
@@ -575,7 +576,7 @@
     case Internal:
       switch (catG) {
         case ExternalStrong:
-          assert(0);
+          llvm_unreachable();
           // fall-through
         case ExternalWeak:
 	  if (F->hasAddressTaken())