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
This commit is contained in:
Torok Edwin
2009-07-11 20:10:48 +00:00
parent d51ffcf303
commit c25e7581b9
153 changed files with 695 additions and 610 deletions

View File

@ -421,7 +421,7 @@ void *ExecutionEngine::getPointerToGlobal(const GlobalValue *GV) {
const_cast<GlobalVariable *>(dyn_cast<GlobalVariable>(GV)))
EmitGlobalVariable(GVar);
else
assert(0 && "Global hasn't had an address allocated yet!");
LLVM_UNREACHABLE("Global hasn't had an address allocated yet!");
return state.getGlobalAddressMap(locked)[GV];
}
@ -548,7 +548,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
GenericValue GV = getConstantValue(Op0);
const Type* DestTy = CE->getType();
switch (Op0->getType()->getTypeID()) {
default: assert(0 && "Invalid bitcast operand");
default: LLVM_UNREACHABLE("Invalid bitcast operand");
case Type::IntegerTyID:
assert(DestTy->isFloatingPoint() && "invalid bitcast");
if (DestTy == Type::FloatTy)
@ -590,7 +590,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
default: LLVM_UNREACHABLE("Bad add type!");
case Type::IntegerTyID:
switch (CE->getOpcode()) {
default: assert(0 && "Invalid integer opcode");
default: LLVM_UNREACHABLE("Invalid integer opcode");
case Instruction::Add: GV.IntVal = LHS.IntVal + RHS.IntVal; break;
case Instruction::Sub: GV.IntVal = LHS.IntVal - RHS.IntVal; break;
case Instruction::Mul: GV.IntVal = LHS.IntVal * RHS.IntVal; break;
@ -638,7 +638,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
case Type::FP128TyID: {
APFloat apfLHS = APFloat(LHS.IntVal);
switch (CE->getOpcode()) {
default: assert(0 && "Invalid long double opcode");llvm_unreachable();
default: LLVM_UNREACHABLE("Invalid long double opcode");llvm_unreachable();
case Instruction::FAdd:
apfLHS.add(APFloat(RHS.IntVal), APFloat::rmNearestTiesToEven);
GV.IntVal = apfLHS.bitcastToAPInt();
@ -698,7 +698,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
else if (const GlobalVariable* GV = dyn_cast<GlobalVariable>(C))
Result = PTOGV(getOrEmitGlobalVariable(const_cast<GlobalVariable*>(GV)));
else
assert(0 && "Unknown constant pointer type!");
LLVM_UNREACHABLE("Unknown constant pointer type!");
break;
default:
std::string msg;
@ -881,7 +881,7 @@ void ExecutionEngine::InitializeMemory(const Constant *Init, void *Addr) {
}
cerr << "Bad Type: " << *Init->getType() << "\n";
assert(0 && "Unknown constant type to initialize memory with!");
LLVM_UNREACHABLE("Unknown constant type to initialize memory with!");
}
/// EmitGlobals - Emit all of the global variables to memory, storing their

View File

@ -15,6 +15,7 @@
#include "llvm-c/ExecutionEngine.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/ExecutionEngine/ExecutionEngine.h"
#include "llvm/Support/ErrorHandling.h"
#include <cstring>
using namespace llvm;
@ -45,8 +46,7 @@ LLVMGenericValueRef LLVMCreateGenericValueOfFloat(LLVMTypeRef TyRef, double N) {
GenVal->DoubleVal = N;
break;
default:
assert(0 && "LLVMGenericValueToFloat supports only float and double.");
break;
LLVM_UNREACHABLE("LLVMGenericValueToFloat supports only float and double.");
}
return wrap(GenVal);
}
@ -75,7 +75,7 @@ double LLVMGenericValueToFloat(LLVMTypeRef TyRef, LLVMGenericValueRef GenVal) {
case Type::DoubleTyID:
return unwrap(GenVal)->DoubleVal;
default:
assert(0 && "LLVMGenericValueToFloat supports only float and double.");
LLVM_UNREACHABLE("LLVMGenericValueToFloat supports only float and double.");
break;
}
return 0; // Not reached

View File

@ -1079,7 +1079,7 @@ GenericValue Interpreter::executeBitCastInst(Value *SrcVal, const Type *DstTy,
} else if (SrcTy->isInteger()) {
Dest.IntVal = Src.IntVal;
} else
assert(0 && "Invalid BitCast");
LLVM_UNREACHABLE("Invalid BitCast");
} else if (DstTy == Type::FloatTy) {
if (SrcTy->isInteger())
Dest.FloatVal = Src.IntVal.bitsToFloat();
@ -1091,7 +1091,7 @@ GenericValue Interpreter::executeBitCastInst(Value *SrcVal, const Type *DstTy,
else
Dest.DoubleVal = Src.DoubleVal;
} else
assert(0 && "Invalid Bitcast");
LLVM_UNREACHABLE("Invalid Bitcast");
return Dest;
}
@ -1345,7 +1345,7 @@ void Interpreter::run() {
DOUT << " --> ";
const GenericValue &Val = SF.Values[&I];
switch (I.getType()->getTypeID()) {
default: assert(0 && "Invalid GenericValue Type");
default: LLVM_UNREACHABLE("Invalid GenericValue Type");
case Type::VoidTyID: DOUT << "void"; break;
case Type::FloatTyID: DOUT << "float " << Val.FloatVal; break;
case Type::DoubleTyID: DOUT << "double " << Val.DoubleVal; break;

View File

@ -21,6 +21,7 @@
#include "llvm/Support/CallSite.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Support/DataTypes.h"
#include "llvm/Support/ErrorHandling.h"
namespace llvm {
@ -145,7 +146,9 @@ public:
void visitLoadInst(LoadInst &I);
void visitStoreInst(StoreInst &I);
void visitGetElementPtrInst(GetElementPtrInst &I);
void visitPHINode(PHINode &PN) { assert(0 && "PHI nodes already handled!"); }
void visitPHINode(PHINode &PN) {
LLVM_UNREACHABLE("PHI nodes already handled!");
}
void visitTruncInst(TruncInst &I);
void visitZExtInst(ZExtInst &I);
void visitSExtInst(SExtInst &I);
@ -174,7 +177,7 @@ public:
void visitVAArgInst(VAArgInst &I);
void visitInstruction(Instruction &I) {
cerr << I;
assert(0 && "Instruction not interpretable yet!");
LLVM_UNREACHABLE("Instruction not interpretable yet!");
}
GenericValue callExternalFunction(Function *F,

View File

@ -410,7 +410,7 @@ GenericValue JIT::runFunction(Function *F,
if (ArgValues.empty()) {
GenericValue rv;
switch (RetTy->getTypeID()) {
default: assert(0 && "Unknown return type for function call!");
default: LLVM_UNREACHABLE("Unknown return type for function call!");
case Type::IntegerTyID: {
unsigned BitWidth = cast<IntegerType>(RetTy)->getBitWidth();
if (BitWidth == 1)
@ -424,7 +424,7 @@ GenericValue JIT::runFunction(Function *F,
else if (BitWidth <= 64)
rv.IntVal = APInt(BitWidth, ((int64_t(*)())(intptr_t)FPtr)());
else
assert(0 && "Integer types > 64 bits not supported");
LLVM_UNREACHABLE("Integer types > 64 bits not supported");
return rv;
}
case Type::VoidTyID:
@ -439,7 +439,7 @@ GenericValue JIT::runFunction(Function *F,
case Type::X86_FP80TyID:
case Type::FP128TyID:
case Type::PPC_FP128TyID:
assert(0 && "long double not supported yet");
LLVM_UNREACHABLE("long double not supported yet");
return rv;
case Type::PointerTyID:
return PTOGV(((void*(*)())(intptr_t)FPtr)());
@ -467,7 +467,7 @@ GenericValue JIT::runFunction(Function *F,
const Type *ArgTy = FTy->getParamType(i);
const GenericValue &AV = ArgValues[i];
switch (ArgTy->getTypeID()) {
default: assert(0 && "Unknown argument type for function call!");
default: LLVM_UNREACHABLE("Unknown argument type for function call!");
case Type::IntegerTyID:
C = ConstantInt::get(AV.IntVal);
break;

View File

@ -21,6 +21,7 @@
#include "llvm/CodeGen/MachineLocation.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/ExecutionEngine/JITMemoryManager.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetInstrInfo.h"
@ -110,7 +111,7 @@ JITDwarfEmitter::EmitFrameMoves(intptr_t BaseLabelPtr,
JCE->emitULEB128Bytes(Offset);
} else {
assert(0 && "Machine move no supported yet.");
LLVM_UNREACHABLE("Machine move no supported yet.");
}
} else if (Src.isReg() &&
Src.getReg() == MachineLocation::VirtualFP) {
@ -118,7 +119,7 @@ JITDwarfEmitter::EmitFrameMoves(intptr_t BaseLabelPtr,
JCE->emitByte(dwarf::DW_CFA_def_cfa_register);
JCE->emitULEB128Bytes(RI->getDwarfRegNum(Dst.getReg(), true));
} else {
assert(0 && "Machine move no supported yet.");
LLVM_UNREACHABLE("Machine move no supported yet.");
}
} else {
unsigned Reg = RI->getDwarfRegNum(Src.getReg(), true);
@ -761,7 +762,7 @@ JITDwarfEmitter::GetFrameMovesSizeInBytes(intptr_t BaseLabelPtr,
FinalSize += TargetAsmInfo::getULEB128Size(Offset);
} else {
assert(0 && "Machine move no supported yet.");
LLVM_UNREACHABLE("Machine move no supported yet.");
}
} else if (Src.isReg() &&
Src.getReg() == MachineLocation::VirtualFP) {
@ -770,7 +771,7 @@ JITDwarfEmitter::GetFrameMovesSizeInBytes(intptr_t BaseLabelPtr,
unsigned RegNum = RI->getDwarfRegNum(Dst.getReg(), true);
FinalSize += TargetAsmInfo::getULEB128Size(RegNum);
} else {
assert(0 && "Machine move no supported yet.");
LLVM_UNREACHABLE("Machine move no supported yet.");
}
} else {
unsigned Reg = RI->getDwarfRegNum(Src.getReg(), true);