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/Target/MSIL/MSILWriter.cpp b/lib/Target/MSIL/MSILWriter.cpp
index ee73c38..8429c27 100644
--- a/lib/Target/MSIL/MSILWriter.cpp
+++ b/lib/Target/MSIL/MSILWriter.cpp
@@ -19,6 +19,7 @@
#include "llvm/TypeSymbolTable.h"
#include "llvm/Analysis/ConstantsScanner.h"
#include "llvm/Support/CallSite.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/InstVisitor.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Transforms/Scalar.h"
@@ -273,7 +274,7 @@
return "modopt([mscorlib]System.Runtime.CompilerServices.CallConvStdcall) ";
default:
cerr << "CallingConvID = " << CallingConvID << '\n';
- assert(0 && "Unsupported calling convention");
+ LLVM_UNREACHABLE("Unsupported calling convention");
}
return ""; // Not reached
}
@@ -319,7 +320,7 @@
return "float64 ";
default:
cerr << "Type = " << *Ty << '\n';
- assert(0 && "Invalid primitive type");
+ LLVM_UNREACHABLE("Invalid primitive type");
}
return ""; // Not reached
}
@@ -347,7 +348,7 @@
return "valuetype '"+getArrayTypeName(Ty->getTypeID(),Ty)+"' ";
default:
cerr << "Type = " << *Ty << '\n';
- assert(0 && "Invalid type in getTypeName()");
+ LLVM_UNREACHABLE("Invalid type in getTypeName()");
}
return ""; // Not reached
}
@@ -391,7 +392,7 @@
return "i"+utostr(TD->getTypeAllocSize(Ty));
default:
cerr << "TypeID = " << Ty->getTypeID() << '\n';
- assert(0 && "Invalid type in TypeToPostfix()");
+ LLVM_UNREACHABLE("Invalid type in TypeToPostfix()");
}
return ""; // Not reached
}
@@ -406,7 +407,7 @@
printSimpleInstruction("conv.u8");
break;
default:
- assert(0 && "Module use not supporting pointer size");
+ LLVM_UNREACHABLE("Module use not supporting pointer size");
}
}
@@ -418,14 +419,14 @@
// FIXME: Need overflow test?
if (!isUInt32(N)) {
cerr << "Value = " << utostr(N) << '\n';
- assert(0 && "32-bit pointer overflowed");
+ LLVM_UNREACHABLE("32-bit pointer overflowed");
}
break;
case Module::Pointer64:
printSimpleInstruction("ldc.i8",utostr(N).c_str());
break;
default:
- assert(0 && "Module use not supporting pointer size");
+ LLVM_UNREACHABLE("Module use not supporting pointer size");
}
}
@@ -461,7 +462,7 @@
printPtrLoad(0);
} else {
cerr << "Constant = " << *C << '\n';
- assert(0 && "Invalid constant value");
+ LLVM_UNREACHABLE("Invalid constant value");
}
Out << '\n';
}
@@ -510,7 +511,7 @@
break;
default:
cerr << "Value = " << *V << '\n';
- assert(0 && "Invalid value location");
+ LLVM_UNREACHABLE("Invalid value location");
}
}
@@ -525,7 +526,7 @@
break;
default:
cerr << "Value = " << *V << '\n';
- assert(0 && "Invalid value location");
+ LLVM_UNREACHABLE("Invalid value location");
}
}
@@ -680,7 +681,7 @@
break;
default:
cerr << "Opcode = " << Op << '\n';
- assert(0 && "Invalid conversion instruction");
+ LLVM_UNREACHABLE("Invalid conversion instruction");
}
}
@@ -771,7 +772,7 @@
Name = getConvModopt(Invoke->getCallingConv());
else {
cerr << "Instruction = " << Inst->getName() << '\n';
- assert(0 && "Need \"Invoke\" or \"Call\" instruction only");
+ LLVM_UNREACHABLE("Need \"Invoke\" or \"Call\" instruction only");
}
if (const Function* F = dyn_cast<Function>(FnVal)) {
// Direct call.
@@ -819,7 +820,7 @@
break;
default:
cerr << "Intrinsic ID = " << Inst->getIntrinsicID() << '\n';
- assert(0 && "Invalid intrinsic function");
+ LLVM_UNREACHABLE("Invalid intrinsic function");
}
}
@@ -882,7 +883,7 @@
break;
default:
cerr << "Predicate = " << Predicate << '\n';
- assert(0 && "Invalid icmp predicate");
+ LLVM_UNREACHABLE("Invalid icmp predicate");
}
}
@@ -976,7 +977,7 @@
printSimpleInstruction("or");
break;
default:
- assert(0 && "Illegal FCmp predicate");
+ LLVM_UNREACHABLE("Illegal FCmp predicate");
}
}
@@ -1169,10 +1170,10 @@
printAllocaInstruction(cast<AllocaInst>(Inst));
break;
case Instruction::Malloc:
- assert(0 && "LowerAllocationsPass used");
+ LLVM_UNREACHABLE("LowerAllocationsPass used");
break;
case Instruction::Free:
- assert(0 && "LowerAllocationsPass used");
+ LLVM_UNREACHABLE("LowerAllocationsPass used");
break;
case Instruction::Unreachable:
printSimpleInstruction("ldstr", "\"Unreachable instruction\"");
@@ -1185,7 +1186,7 @@
break;
default:
cerr << "Instruction = " << Inst->getName() << '\n';
- assert(0 && "Unsupported instruction");
+ LLVM_UNREACHABLE("Unsupported instruction");
}
}
@@ -1373,7 +1374,7 @@
break;
default:
cerr << "Expression = " << *CE << "\n";
- assert(0 && "Invalid constant expression");
+ LLVM_UNREACHABLE("Invalid constant expression");
}
}
@@ -1407,7 +1408,7 @@
printSimpleInstruction(postfix.c_str());
} else {
cerr << "Constant = " << *I->constant << '\n';
- assert(0 && "Invalid static initializer");
+ LLVM_UNREACHABLE("Invalid static initializer");
}
}
}
@@ -1471,7 +1472,7 @@
return N;
default:
cerr << "Bits = " << N << '\n';
- assert(0 && "Unsupported integer width");
+ LLVM_UNREACHABLE("Unsupported integer width");
}
return 0; // Not reached
}
@@ -1528,12 +1529,12 @@
// Null pointer initialization
if (TySize==4) Out << "int32 (0)";
else if (TySize==8) Out << "int64 (0)";
- else assert(0 && "Invalid pointer size");
+ else LLVM_UNREACHABLE("Invalid pointer size");
}
break;
default:
cerr << "TypeID = " << Ty->getTypeID() << '\n';
- assert(0 && "Invalid type in printStaticConstant()");
+ LLVM_UNREACHABLE("Invalid type in printStaticConstant()");
}
// Increase offset.
Offset += TySize;
@@ -1556,7 +1557,7 @@
break;
default:
cerr << "Type = " << *C << "\n";
- assert(0 && "Invalid constant type");
+ LLVM_UNREACHABLE("Invalid constant type");
}
// Print initializer
std::string label = Name;