summaryrefslogtreecommitdiff
path: root/lib/VMCore
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2012-02-05 22:14:15 +0000
committerCraig Topper <craig.topper@gmail.com>2012-02-05 22:14:15 +0000
commit50bee42b54cd9aec5f49566307df2b0cf23afcf6 (patch)
treecaa20b5d1a706f63057cf77fd42f4c6126050746 /lib/VMCore
parent2cb395eae71dacda49ca3fe758618fc3e0701659 (diff)
downloadllvm-50bee42b54cd9aec5f49566307df2b0cf23afcf6.tar.gz
llvm-50bee42b54cd9aec5f49566307df2b0cf23afcf6.tar.bz2
llvm-50bee42b54cd9aec5f49566307df2b0cf23afcf6.tar.xz
Convert assert(0) to llvm_unreachable
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149849 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Constants.cpp7
-rw-r--r--lib/VMCore/Core.cpp6
-rw-r--r--lib/VMCore/Instructions.cpp34
-rw-r--r--lib/VMCore/PassManager.cpp3
-rw-r--r--lib/VMCore/ValueTypes.cpp3
5 files changed, 20 insertions, 33 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index bffe859109..a2f3b3f0b3 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -117,8 +117,7 @@ Constant *Constant::getNullValue(Type *Ty) {
return ConstantAggregateZero::get(Ty);
default:
// Function, Label, or Opaque type?
- assert(0 && "Cannot create a null constant of that type!");
- return 0;
+ llvm_unreachable("Cannot create a null constant of that type!");
}
}
@@ -2285,7 +2284,7 @@ uint64_t ConstantDataSequential::getElementAsInteger(unsigned Elt) const {
// The data is stored in host byte order, make sure to cast back to the right
// type to load with the right endianness.
switch (getElementType()->getIntegerBitWidth()) {
- default: assert(0 && "Invalid bitwidth for CDS");
+ default: llvm_unreachable("Invalid bitwidth for CDS");
case 8: return *(uint8_t*)EltPtr;
case 16: return *(uint16_t*)EltPtr;
case 32: return *(uint32_t*)EltPtr;
@@ -2300,7 +2299,7 @@ APFloat ConstantDataSequential::getElementAsAPFloat(unsigned Elt) const {
switch (getElementType()->getTypeID()) {
default:
- assert(0 && "Accessor can only be used when element is float/double!");
+ llvm_unreachable("Accessor can only be used when element is float/double!");
case Type::FloatTyID: return APFloat(*(float*)EltPtr);
case Type::DoubleTyID: return APFloat(*(double*)EltPtr);
}
diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp
index c376546521..e86d805e32 100644
--- a/lib/VMCore/Core.cpp
+++ b/lib/VMCore/Core.cpp
@@ -133,8 +133,7 @@ LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M) {
LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty) {
switch (unwrap(Ty)->getTypeID()) {
- default:
- assert(false && "Unhandled TypeID.");
+ default: llvm_unreachable("Unhandled TypeID.");
case Type::VoidTyID:
return LLVMVoidTypeKind;
case Type::HalfTyID:
@@ -680,8 +679,7 @@ LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size) {
static LLVMOpcode map_to_llvmopcode(int opcode)
{
switch (opcode) {
- default:
- assert(0 && "Unhandled Opcode.");
+ default: llvm_unreachable("Unhandled Opcode.");
#define HANDLE_INST(num, opc, clas) case num: return LLVM##opc;
#include "llvm/Instruction.def"
#undef HANDLE_INST
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp
index c0e6844271..74cbfc4133 100644
--- a/lib/VMCore/Instructions.cpp
+++ b/lib/VMCore/Instructions.cpp
@@ -1410,8 +1410,7 @@ unsigned GetElementPtrInst::getAddressSpace(Value *Ptr) {
if (PointerType *PTy = dyn_cast<PointerType>(Ty))
return PTy->getAddressSpace();
- assert(false && "Invalid GEP pointer type");
- return 0;
+ llvm_unreachable("Invalid GEP pointer type");
}
/// hasAllZeroIndices - Return true if all of the indices of this GEP are
@@ -2079,8 +2078,7 @@ bool CastInst::isNoopCast(Instruction::CastOps Opcode,
Type *DestTy,
Type *IntPtrTy) {
switch (Opcode) {
- default:
- assert(0 && "Invalid CastOp");
+ default: llvm_unreachable("Invalid CastOp");
case Instruction::Trunc:
case Instruction::ZExt:
case Instruction::SExt:
@@ -2273,11 +2271,9 @@ unsigned CastInst::isEliminableCastPair(
case 99:
// cast combination can't happen (error in input). This is for all cases
// where the MidTy is not the same for the two cast instructions.
- assert(0 && "Invalid Cast Combination");
- return 0;
+ llvm_unreachable("Invalid Cast Combination");
default:
- assert(0 && "Error in CastResults table!!!");
- return 0;
+ llvm_unreachable("Error in CastResults table!!!");
}
}
@@ -2298,9 +2294,7 @@ CastInst *CastInst::Create(Instruction::CastOps op, Value *S, Type *Ty,
case PtrToInt: return new PtrToIntInst (S, Ty, Name, InsertBefore);
case IntToPtr: return new IntToPtrInst (S, Ty, Name, InsertBefore);
case BitCast: return new BitCastInst (S, Ty, Name, InsertBefore);
- default:
- assert(0 && "Invalid opcode provided");
- return 0;
+ default: llvm_unreachable("Invalid opcode provided");
}
}
@@ -2321,9 +2315,7 @@ CastInst *CastInst::Create(Instruction::CastOps op, Value *S, Type *Ty,
case PtrToInt: return new PtrToIntInst (S, Ty, Name, InsertAtEnd);
case IntToPtr: return new IntToPtrInst (S, Ty, Name, InsertAtEnd);
case BitCast: return new BitCastInst (S, Ty, Name, InsertAtEnd);
- default:
- assert(0 && "Invalid opcode provided");
- return 0;
+ default: llvm_unreachable("Invalid opcode provided");
}
}
@@ -2606,17 +2598,17 @@ CastInst::getCastOpcode(
} else if (SrcTy->isIntegerTy()) {
return IntToPtr; // int -> ptr
} else {
- assert(0 && "Casting pointer to other than pointer or int");
+ llvm_unreachable("Casting pointer to other than pointer or int");
}
} else if (DestTy->isX86_MMXTy()) {
if (SrcTy->isVectorTy()) {
assert(DestBits == SrcBits && "Casting vector of wrong width to X86_MMX");
return BitCast; // 64-bit vector to MMX
} else {
- assert(0 && "Illegal cast to X86_MMX");
+ llvm_unreachable("Illegal cast to X86_MMX");
}
} else {
- assert(0 && "Casting to type that is not first-class");
+ llvm_unreachable("Casting to type that is not first-class");
}
// If we fall through to here we probably hit an assertion cast above
@@ -2938,7 +2930,7 @@ bool CmpInst::isEquality() const {
CmpInst::Predicate CmpInst::getInversePredicate(Predicate pred) {
switch (pred) {
- default: assert(0 && "Unknown cmp predicate!");
+ default: llvm_unreachable("Unknown cmp predicate!");
case ICMP_EQ: return ICMP_NE;
case ICMP_NE: return ICMP_EQ;
case ICMP_UGT: return ICMP_ULE;
@@ -2971,7 +2963,7 @@ CmpInst::Predicate CmpInst::getInversePredicate(Predicate pred) {
ICmpInst::Predicate ICmpInst::getSignedPredicate(Predicate pred) {
switch (pred) {
- default: assert(0 && "Unknown icmp predicate!");
+ default: llvm_unreachable("Unknown icmp predicate!");
case ICMP_EQ: case ICMP_NE:
case ICMP_SGT: case ICMP_SLT: case ICMP_SGE: case ICMP_SLE:
return pred;
@@ -2984,7 +2976,7 @@ ICmpInst::Predicate ICmpInst::getSignedPredicate(Predicate pred) {
ICmpInst::Predicate ICmpInst::getUnsignedPredicate(Predicate pred) {
switch (pred) {
- default: assert(0 && "Unknown icmp predicate!");
+ default: llvm_unreachable("Unknown icmp predicate!");
case ICMP_EQ: case ICMP_NE:
case ICMP_UGT: case ICMP_ULT: case ICMP_UGE: case ICMP_ULE:
return pred;
@@ -3060,7 +3052,7 @@ ICmpInst::makeConstantRange(Predicate pred, const APInt &C) {
CmpInst::Predicate CmpInst::getSwappedPredicate(Predicate pred) {
switch (pred) {
- default: assert(0 && "Unknown cmp predicate!");
+ default: llvm_unreachable("Unknown cmp predicate!");
case ICMP_EQ: case ICMP_NE:
return pred;
case ICMP_SGT: return ICMP_SLT;
diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp
index dd27345d91..773862d203 100644
--- a/lib/VMCore/PassManager.cpp
+++ b/lib/VMCore/PassManager.cpp
@@ -1228,8 +1228,7 @@ void PMDataManager::addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass) {
}
Pass *PMDataManager::getOnTheFlyPass(Pass *P, AnalysisID PI, Function &F) {
- assert(0 && "Unable to find on the fly pass");
- return NULL;
+ llvm_unreachable("Unable to find on the fly pass");
}
// Destructor
diff --git a/lib/VMCore/ValueTypes.cpp b/lib/VMCore/ValueTypes.cpp
index 33a6ecca76..9a8e1859e2 100644
--- a/lib/VMCore/ValueTypes.cpp
+++ b/lib/VMCore/ValueTypes.cpp
@@ -87,8 +87,7 @@ unsigned EVT::getExtendedSizeInBits() const {
return ITy->getBitWidth();
if (VectorType *VTy = dyn_cast<VectorType>(LLVMTy))
return VTy->getBitWidth();
- assert(false && "Unrecognized extended type!");
- return 0; // Suppress warnings.
+ llvm_unreachable("Unrecognized extended type!");
}
/// getEVTString - This function returns value type as a string, e.g. "i32".