summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Analysis/IPA/Andersens.cpp3
-rw-r--r--lib/Analysis/InstCount.cpp3
-rw-r--r--lib/CodeGen/AsmPrinter/AsmPrinter.cpp49
-rw-r--r--lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp17
-rw-r--r--lib/CodeGen/GCMetadata.cpp5
-rw-r--r--lib/CodeGen/GCStrategy.cpp3
-rw-r--r--lib/CodeGen/IfConversion.cpp14
-rw-r--r--lib/CodeGen/IntrinsicLowering.cpp13
-rw-r--r--lib/CodeGen/LiveIntervalAnalysis.cpp12
-rw-r--r--lib/CodeGen/MachOWriter.cpp12
-rw-r--r--lib/CodeGen/MachineVerifier.cpp8
-rw-r--r--lib/CodeGen/PreAllocSplitting.cpp4
-rw-r--r--lib/CodeGen/RegAllocLinearScan.cpp7
-rw-r--r--lib/CodeGen/RegAllocLocal.cpp22
-rw-r--r--lib/CodeGen/RegisterScavenging.cpp4
-rw-r--r--lib/CodeGen/SelectionDAG/CallingConvLower.cpp50
-rw-r--r--lib/CodeGen/SelectionDAG/DAGCombiner.cpp4
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeDAG.cpp8
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp14
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp13
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeTypes.cpp5
-rw-r--r--lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp16
-rw-r--r--lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp4
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp41
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp14
-rw-r--r--lib/ExecutionEngine/ExecutionEngine.cpp40
-rw-r--r--lib/ExecutionEngine/Interpreter/Execution.cpp60
-rw-r--r--lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp24
-rw-r--r--lib/ExecutionEngine/JIT/Intercept.cpp6
-rw-r--r--lib/ExecutionEngine/JIT/JIT.cpp20
-rw-r--r--lib/ExecutionEngine/JIT/JITEmitter.cpp24
-rw-r--r--lib/ExecutionEngine/JIT/JITMemoryManager.cpp13
-rw-r--r--lib/Support/CommandLine.cpp4
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp6
-rw-r--r--lib/Transforms/Scalar/SCCP.cpp5
-rw-r--r--lib/Transforms/Scalar/ScalarReplAggregates.cpp4
-rw-r--r--lib/Transforms/Utils/BasicBlockUtils.cpp4
-rw-r--r--lib/Transforms/Utils/CodeExtractor.cpp4
-rw-r--r--lib/VMCore/Constants.cpp4
39 files changed, 296 insertions, 267 deletions
diff --git a/lib/Analysis/IPA/Andersens.cpp b/lib/Analysis/IPA/Andersens.cpp
index 3fb6526547..f453a6f8ef 100644
--- a/lib/Analysis/IPA/Andersens.cpp
+++ b/lib/Analysis/IPA/Andersens.cpp
@@ -60,6 +60,7 @@
#include "llvm/Module.h"
#include "llvm/Pass.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/InstIterator.h"
#include "llvm/Support/InstVisitor.h"
#include "llvm/Analysis/AliasAnalysis.h"
@@ -1153,7 +1154,7 @@ void Andersens::visitInstruction(Instruction &I) {
default:
// Is this something we aren't handling yet?
cerr << "Unknown instruction: " << I;
- abort();
+ llvm_unreachable();
}
}
diff --git a/lib/Analysis/InstCount.cpp b/lib/Analysis/InstCount.cpp
index 2b34ad3b07..2dbf0d4f9e 100644
--- a/lib/Analysis/InstCount.cpp
+++ b/lib/Analysis/InstCount.cpp
@@ -16,6 +16,7 @@
#include "llvm/Pass.h"
#include "llvm/Function.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/InstVisitor.h"
#include "llvm/Support/Streams.h"
#include "llvm/ADT/Statistic.h"
@@ -47,7 +48,7 @@ namespace {
void visitInstruction(Instruction &I) {
cerr << "Instruction Count does not know about " << I;
- abort();
+ llvm_unreachable();
}
public:
static char ID; // Pass identification, replacement for typeid
diff --git a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 6d125810d9..daa4a702dc 100644
--- a/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -23,6 +23,7 @@
#include "llvm/CodeGen/DwarfWriter.h"
#include "llvm/Analysis/DebugInfo.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Mangler.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetAsmInfo.h"
@@ -1300,7 +1301,7 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV, unsigned AddrSpace) {
void AsmPrinter::EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) {
// Target doesn't support this yet!
- abort();
+ LLVM_UNREACHABLE("Target does not support EmitMachineConstantPoolValue");
}
/// PrintSpecial - Print information related to the specified machine instr
@@ -1328,9 +1329,11 @@ void AsmPrinter::PrintSpecial(const MachineInstr *MI, const char *Code) const {
}
O << Counter;
} else {
- cerr << "Unknown special formatter '" << Code
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "Unknown special formatter '" << Code
<< "' for machine instr: " << *MI;
- exit(1);
+ llvm_report_error(Msg.str());
}
}
@@ -1413,9 +1416,8 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
case '(': // $( -> same as GCC's { character.
++LastEmitted; // Consume '(' character.
if (CurVariant != -1) {
- cerr << "Nested variants found in inline asm string: '"
- << AsmStr << "'\n";
- exit(1);
+ llvm_report_error("Nested variants found in inline asm string: '"
+ + std::string(AsmStr) + "'");
}
CurVariant = 0; // We're in the first variant now.
break;
@@ -1450,9 +1452,8 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
const char *StrStart = LastEmitted;
const char *StrEnd = strchr(StrStart, '}');
if (StrEnd == 0) {
- cerr << "Unterminated ${:foo} operand in inline asm string: '"
- << AsmStr << "'\n";
- exit(1);
+ llvm_report_error("Unterminated ${:foo} operand in inline asm string: '"
+ + std::string(AsmStr) + "'");
}
std::string Val(StrStart, StrEnd);
@@ -1466,9 +1467,8 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
errno = 0;
long Val = strtol(IDStart, &IDEnd, 10); // We only accept numbers for IDs.
if (!isdigit(*IDStart) || (Val == 0 && errno == EINVAL)) {
- cerr << "Bad $ operand number in inline asm string: '"
- << AsmStr << "'\n";
- exit(1);
+ llvm_report_error("Bad $ operand number in inline asm string: '"
+ + std::string(AsmStr) + "'");
}
LastEmitted = IDEnd;
@@ -1480,9 +1480,8 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
if (*LastEmitted == ':') {
++LastEmitted; // Consume ':' character.
if (*LastEmitted == 0) {
- cerr << "Bad ${:} expression in inline asm string: '"
- << AsmStr << "'\n";
- exit(1);
+ llvm_report_error("Bad ${:} expression in inline asm string: '"
+ + std::string(AsmStr) + "'");
}
Modifier[0] = *LastEmitted;
@@ -1490,17 +1489,15 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
}
if (*LastEmitted != '}') {
- cerr << "Bad ${} expression in inline asm string: '"
- << AsmStr << "'\n";
- exit(1);
+ llvm_report_error("Bad ${} expression in inline asm string: '"
+ + std::string(AsmStr) + "'");
}
++LastEmitted; // Consume '}' character.
}
if ((unsigned)Val >= NumOperands-1) {
- cerr << "Invalid $ operand number in inline asm string: '"
- << AsmStr << "'\n";
- exit(1);
+ llvm_report_error("Invalid $ operand number in inline asm string: '"
+ + std::string(AsmStr) + "'");
}
// Okay, we finally have a value number. Ask the target to print this
@@ -1538,10 +1535,12 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const {
}
}
if (Error) {
- cerr << "Invalid operand found in inline asm: '"
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "Invalid operand found in inline asm: '"
<< AsmStr << "'\n";
- MI->dump();
- exit(1);
+ MI->print(Msg);
+ llvm_report_error(Msg.str());
}
}
break;
@@ -1747,5 +1746,5 @@ GCMetadataPrinter *AsmPrinter::GetOrCreateGCPrinter(GCStrategy *S) {
}
cerr << "no GCMetadataPrinter registered for GC: " << Name << "\n";
- abort();
+ llvm_unreachable();
}
diff --git a/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp b/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
index 8ba903a65d..0d3a2780ba 100644
--- a/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
+++ b/lib/CodeGen/AsmPrinter/OcamlGCPrinter.cpp
@@ -16,6 +16,7 @@
#include "llvm/CodeGen/GCMetadataPrinter.h"
#include "llvm/Module.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/Target/TargetData.h"
@@ -115,11 +116,13 @@ void OcamlGCMetadataPrinter::finishAssembly(raw_ostream &OS, AsmPrinter &AP,
uint64_t FrameSize = FI.getFrameSize();
if (FrameSize >= 1<<16) {
- cerr << "Function '" << FI.getFunction().getNameStart()
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "Function '" << FI.getFunction().getNameStart()
<< "' is too large for the ocaml GC! "
<< "Frame size " << FrameSize << " >= 65536.\n";
- cerr << "(" << uintptr_t(&FI) << ")\n";
- abort(); // Very rude!
+ Msg << "(" << uintptr_t(&FI) << ")";
+ llvm_report_error(Msg.str()); // Very rude!
}
OS << "\t" << TAI.getCommentString() << " live roots for "
@@ -128,10 +131,12 @@ void OcamlGCMetadataPrinter::finishAssembly(raw_ostream &OS, AsmPrinter &AP,
for (GCFunctionInfo::iterator J = FI.begin(), JE = FI.end(); J != JE; ++J) {
size_t LiveCount = FI.live_size(J);
if (LiveCount >= 1<<16) {
- cerr << "Function '" << FI.getFunction().getNameStart()
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "Function '" << FI.getFunction().getNameStart()
<< "' is too large for the ocaml GC! "
- << "Live root count " << LiveCount << " >= 65536.\n";
- abort(); // Very rude!
+ << "Live root count " << LiveCount << " >= 65536.";
+ llvm_report_error(Msg.str()); // Very rude!
}
OS << AddressDirective
diff --git a/lib/CodeGen/GCMetadata.cpp b/lib/CodeGen/GCMetadata.cpp
index cf2ebb39ad..14177dacdc 100644
--- a/lib/CodeGen/GCMetadata.cpp
+++ b/lib/CodeGen/GCMetadata.cpp
@@ -18,6 +18,7 @@
#include "llvm/CodeGen/Passes.h"
#include "llvm/Function.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/ErrorHandling.h"
using namespace llvm;
@@ -92,9 +93,9 @@ GCStrategy *GCModuleInfo::getOrCreateStrategy(const Module *M,
return S;
}
}
-
+
cerr << "unsupported GC: " << Name << "\n";
- abort();
+ llvm_unreachable();
}
GCFunctionInfo &GCModuleInfo::getFunctionInfo(const Function &F) {
diff --git a/lib/CodeGen/GCStrategy.cpp b/lib/CodeGen/GCStrategy.cpp
index ad7421abc2..560cf7df81 100644
--- a/lib/CodeGen/GCStrategy.cpp
+++ b/lib/CodeGen/GCStrategy.cpp
@@ -28,6 +28,7 @@
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/ErrorHandling.h"
using namespace llvm;
@@ -108,7 +109,7 @@ bool GCStrategy::initializeCustomLowering(Module &M) { return false; }
bool GCStrategy::performCustomLowering(Function &F) {
cerr << "gc " << getName() << " must override performCustomLowering.\n";
- abort();
+ llvm_unreachable();
return 0;
}
diff --git a/lib/CodeGen/IfConversion.cpp b/lib/CodeGen/IfConversion.cpp
index d5e7ea59a7..739c06b11a 100644
--- a/lib/CodeGen/IfConversion.cpp
+++ b/lib/CodeGen/IfConversion.cpp
@@ -21,6 +21,8 @@
#include "llvm/Target/TargetMachine.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/STLExtras.h"
@@ -1130,8 +1132,10 @@ void IfConverter::PredicateBlock(BBInfo &BBI,
if (TII->isPredicated(I))
continue;
if (!TII->PredicateInstruction(I, Cond)) {
- cerr << "Unable to predicate " << *I << "!\n";
- abort();
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "Unable to predicate " << *I << "!";
+ llvm_report_error(Msg.str());
}
}
@@ -1164,8 +1168,10 @@ void IfConverter::CopyAndPredicateBlock(BBInfo &ToBBI, BBInfo &FromBBI,
if (!isPredicated)
if (!TII->PredicateInstruction(MI, Cond)) {
- cerr << "Unable to predicate " << *MI << "!\n";
- abort();
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "Unable to predicate " << *MI << "!";
+ llvm_report_error(Msg.str());
}
}
diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp
index 64a5c9e699..9eacdfe4d5 100644
--- a/lib/CodeGen/IntrinsicLowering.cpp
+++ b/lib/CodeGen/IntrinsicLowering.cpp
@@ -17,6 +17,7 @@
#include "llvm/Type.h"
#include "llvm/CodeGen/IntrinsicLowering.h"
#include "llvm/Support/IRBuilder.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Target/TargetData.h"
#include "llvm/ADT/SmallVector.h"
using namespace llvm;
@@ -626,7 +627,7 @@ static void ReplaceFPIntrinsicWithCall(CallInst *CI, const char *Fname,
const char *Dname,
const char *LDname) {
switch (CI->getOperand(1)->getType()->getTypeID()) {
- default: assert(0 && "Invalid type in intrinsic"); abort();
+ default: LLVM_UNREACHABLE( "Invalid type in intrinsic");
case Type::FloatTyID:
ReplaceCallWith(Fname, CI, CI->op_begin() + 1, CI->op_end(),
Type::FloatTy);
@@ -652,13 +653,11 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) {
switch (Callee->getIntrinsicID()) {
case Intrinsic::not_intrinsic:
- cerr << "Cannot lower a call to a non-intrinsic function '"
- << Callee->getName() << "'!\n";
- abort();
+ llvm_report_error("Cannot lower a call to a non-intrinsic function '"+
+ Callee->getName() + "'!");
default:
- cerr << "Error: Code generator does not support intrinsic function '"
- << Callee->getName() << "'!\n";
- abort();
+ llvm_report_error("Code generator does not support intrinsic function '"+
+ Callee->getName()+"'!");
// The setjmp/longjmp intrinsics should only exist in the code if it was
// never optimized (ie, right out of the CFE), or if it has been hacked on
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp
index b13f494273..6abe465cb1 100644
--- a/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/lib/CodeGen/LiveIntervalAnalysis.cpp
@@ -34,6 +34,8 @@
#include "llvm/Target/TargetOptions.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/Statistic.h"
@@ -2450,13 +2452,15 @@ bool LiveIntervals::spillPhysRegAroundRegDefsUses(const LiveInterval &li,
pli.removeRange(StartIdx, EndIdx);
Cut = true;
} else {
- cerr << "Ran out of registers during register allocation!\n";
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "Ran out of registers during register allocation!";
if (MI->getOpcode() == TargetInstrInfo::INLINEASM) {
- cerr << "Please check your inline asm statement for invalid "
+ Msg << "\nPlease check your inline asm statement for invalid "
<< "constraints:\n";
- MI->print(cerr.stream(), tm_);
+ MI->print(Msg, tm_);
}
- exit(1);
+ llvm_report_error(Msg.str());
}
for (const unsigned* AS = tri_->getSubRegisters(SpillReg); *AS; ++AS) {
if (!hasInterval(*AS))
diff --git a/lib/CodeGen/MachOWriter.cpp b/lib/CodeGen/MachOWriter.cpp
index 3ad03a4eee..12f5cecbef 100644
--- a/lib/CodeGen/MachOWriter.cpp
+++ b/lib/CodeGen/MachOWriter.cpp
@@ -35,6 +35,7 @@
#include "llvm/Target/TargetMachOWriterInfo.h"
#include "llvm/Support/Mangler.h"
#include "llvm/Support/OutputBuffer.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
namespace llvm {
@@ -634,8 +635,7 @@ void MachOWriter::InitMem(const Constant *C, uintptr_t Offset,
case Instruction::Add:
default:
cerr << "ConstantExpr not handled as global var init: " << *CE << "\n";
- abort();
- break;
+ llvm_unreachable();
}
} else if (PC->getType()->isSingleValueType()) {
unsigned char *ptr = (unsigned char *)PA;
@@ -710,11 +710,13 @@ void MachOWriter::InitMem(const Constant *C, uintptr_t Offset,
ScatteredOffset));
ScatteredOffset = 0;
} else
- assert(0 && "Unknown constant pointer type!");
+ LLVM_UNREACHABLE("Unknown constant pointer type!");
break;
default:
- cerr << "ERROR: Constant unimp for type: " << *PC->getType() << "\n";
- abort();
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "ERROR: Constant unimp for type: " << *PC->getType();
+ llvm_report_error(Msg.str());
}
} else if (isa<ConstantAggregateZero>(PC)) {
memset((void*)PA, 0, (size_t)TD->getTypeAllocSize(PC->getType()));
diff --git a/lib/CodeGen/MachineVerifier.cpp b/lib/CodeGen/MachineVerifier.cpp
index be1396c7a8..e9b90fa040 100644
--- a/lib/CodeGen/MachineVerifier.cpp
+++ b/lib/CodeGen/MachineVerifier.cpp
@@ -36,6 +36,8 @@
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
#include <fstream>
using namespace llvm;
@@ -219,8 +221,10 @@ MachineVerifier::runOnMachineFunction(MachineFunction &MF)
OutFile.close();
if (foundErrors) {
- cerr << "\nStopping with " << foundErrors << " machine code errors.\n";
- exit(1);
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "\nStopping with " << foundErrors << " machine code errors.";
+ llvm_report_error(Msg.str());
}
return false; // no changes
diff --git a/lib/CodeGen/PreAllocSplitting.cpp b/lib/CodeGen/PreAllocSplitting.cpp
index 076f4896cf..52a403bd36 100644
--- a/lib/CodeGen/PreAllocSplitting.cpp
+++ b/lib/CodeGen/PreAllocSplitting.cpp
@@ -31,6 +31,7 @@
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/SmallPtrSet.h"
@@ -1036,8 +1037,7 @@ bool PreAllocSplitting::SplitRegLiveInterval(LiveInterval *LI) {
if (ValNo->isUnused()) {
// Defined by a dead def? How can this be?
- assert(0 && "Val# is defined by a dead def?");
- abort();
+ LLVM_UNREACHABLE("Val# is defined by a dead def?");
}
MachineInstr *DefMI = ValNo->isDefAccurate()
diff --git a/lib/CodeGen/RegAllocLinearScan.cpp b/lib/CodeGen/RegAllocLinearScan.cpp
index 904b4cb2a4..fb837511c5 100644
--- a/lib/CodeGen/RegAllocLinearScan.cpp
+++ b/lib/CodeGen/RegAllocLinearScan.cpp
@@ -34,7 +34,9 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/ErrorHandling.h"
#include <algorithm>
#include <set>
#include <queue>
@@ -235,7 +237,7 @@ namespace {
}
}
if (Error)
- abort();
+ llvm_unreachable();
#endif
regUse_.clear();
regUseBackUp_.clear();
@@ -1102,8 +1104,7 @@ void RALinScan::assignRegOrStackSlotAtInterval(LiveInterval* cur)
DowngradedRegs.clear();
assignRegOrStackSlotAtInterval(cur);
} else {
- cerr << "Ran out of registers during register allocation!\n";
- exit(1);
+ llvm_report_error("Ran out of registers during register allocation!");
}
return;
}
diff --git a/lib/CodeGen/RegAllocLocal.cpp b/lib/CodeGen/RegAllocLocal.cpp
index e1cc20cf4f..1b09f77613 100644
--- a/lib/CodeGen/RegAllocLocal.cpp
+++ b/lib/CodeGen/RegAllocLocal.cpp
@@ -25,6 +25,8 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/IndexedMap.h"
#include "llvm/ADT/SmallSet.h"
@@ -517,24 +519,28 @@ MachineInstr *RALocal::reloadVirtReg(MachineBasicBlock &MBB, MachineInstr *MI,
getVirtRegLastUse(VirtReg) = std::make_pair(MI, OpNum);
if (!ReloadedRegs.insert(PhysReg)) {
- cerr << "Ran out of registers during register allocation!\n";
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "Ran out of registers during register allocation!";
if (MI->getOpcode() == TargetInstrInfo::INLINEASM) {
- cerr << "Please check your inline asm statement for invalid "
+ Msg << "\nPlease check your inline asm statement for invalid "
<< "constraints:\n";
- MI->print(cerr.stream(), TM);
+ MI->print(Msg, TM);
}
- exit(1);
+ llvm_report_error(Msg.str());
}
for (const unsigned *SubRegs = TRI->getSubRegisters(PhysReg);
*SubRegs; ++SubRegs) {
if (!ReloadedRegs.insert(*SubRegs)) {
- cerr << "Ran out of registers during register allocation!\n";
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "Ran out of registers during register allocation!";
if (MI->getOpcode() == TargetInstrInfo::INLINEASM) {
- cerr << "Please check your inline asm statement for invalid "
+ Msg << "\nPlease check your inline asm statement for invalid "
<< "constraints:\n";
- MI->print(cerr.stream(), TM);
+ MI->print(Msg, TM);
}
- exit(1);
+ llvm_report_error(Msg.str());
}
}
diff --git a/lib/CodeGen/RegisterScavenging.cpp b/lib/CodeGen/RegisterScavenging.cpp
index d7fe7a2d54..ab9a0e340d 100644
--- a/lib/CodeGen/RegisterScavenging.cpp
+++ b/lib/CodeGen/RegisterScavenging.cpp
@@ -20,6 +20,7 @@
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetMachine.h"
@@ -459,8 +460,7 @@ unsigned RegScavenger::scavengeRegister(const TargetRegisterClass *RC,
}
if (ScavengedReg != 0) {
- assert(0 && "Scavenger slot is live, unable to scavenge another register!");
- abort();
+ LLVM_UNREACHABLE("Scavenger slot is live, unable to scavenge another register!");
}
// Spill the scavenged register before I.
diff --git a/lib/CodeGen/SelectionDAG/CallingConvLower.cpp b/lib/CodeGen/SelectionDAG/CallingConvLower.cpp
index 8b8f0e5f84..9289711e6e 100644
--- a/lib/CodeGen/SelectionDAG/CallingConvLower.cpp
+++ b/lib/CodeGen/SelectionDAG/CallingConvLower.cpp
@@ -13,6 +13,8 @@
//===----------------------------------------------------------------------===//
#include "llvm/CodeGen/CallingConvLower.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
@@ -65,9 +67,11 @@ void CCState::AnalyzeFormalArguments(SDNode *TheArgs, CCAssignFn Fn) {
ISD::ArgFlagsTy ArgFlags =
cast<ARG_FLAGSSDNode>(TheArgs->getOperand(3+i))->getArgFlags();
if (Fn(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, *this)) {
- cerr << "Formal argument #" << i << " has unhandled type "
- << ArgVT.getMVTString() << "\n";
- abort();
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "Formal argument #" << i << " has unhandled type "
+ << ArgVT.getMVTString();
+ llvm_report_error(Msg.str());
}
}
}
@@ -81,9 +85,11 @@ void CCState::AnalyzeReturn(SDNode *TheRet, CCAssignFn Fn) {
ISD::ArgFlagsTy ArgFlags =
cast<ARG_FLAGSSDNode>(TheRet->getOperand(i*2+2))->getArgFlags();
if (Fn(i, VT, VT, CCValAssign::Full, ArgFlags, *this)){
- cerr << "Return operand #" << i << " has unhandled type "
- << VT.getMVTString() << "\n";
- abort();
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "Return operand #" << i << " has unhandled type "
+ << VT.getMVTString();
+ llvm_report_error(Msg.str());
}
}
}
@@ -97,9 +103,11 @@ void CCState::AnalyzeCallOperands(CallSDNode *TheCall, CCAssignFn Fn) {
MVT ArgVT = TheCall->getArg(i).getValueType();
ISD::ArgFlagsTy ArgFlags = TheCall->getArgFlags(i);
if (Fn(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, *this)) {
- cerr << "Call operand #" << i << " has unhandled type "
- << ArgVT.getMVTString() << "\n";
- abort();
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "Call operand #" << i << " has unhandled type "
+ << ArgVT.getMVTString();
+ llvm_report_error(Msg.str());
}
}
}
@@ -114,9 +122,11 @@ void CCState::AnalyzeCallOperands(SmallVectorImpl<MVT> &ArgVTs,
MVT ArgVT = ArgVTs[i];
ISD::ArgFlagsTy ArgFlags = Flags[i];
if (Fn(i, ArgVT, ArgVT, CCValAssign::Full, ArgFlags, *this)) {
- cerr << "Call operand #" << i << " has unhandled type "
- << ArgVT.getMVTString() << "\n";
- abort();
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "Call operand #" << i << " has unhandled type "
+ << ArgVT.getMVTString();
+ llvm_report_error(Msg.str());
}
}
}
@@ -130,9 +140,11 @@ void CCState::AnalyzeCallResult(CallSDNode *TheCall, CCAssignFn Fn) {
if (TheCall->isInreg())
Flags.setInReg();
if (Fn(i, VT, VT, CCValAssign::Full, Flags, *this)) {
- cerr << "Call result #" << i << " has unhandled type "
- << VT.getMVTString() << "\n";
- abort();
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "Call result #" << i << " has unhandled type "
+ << VT.getMVTString();
+ llvm_report_error(Msg.str());
}
}
}
@@ -141,8 +153,10 @@ void CCState::AnalyzeCallResult(CallSDNode *TheCall, CCAssignFn Fn) {
/// produce a single value.
void CCState::AnalyzeCallResult(MVT VT, CCAssignFn Fn) {
if (Fn(0, VT, VT, CCValAssign::Full, ISD::ArgFlagsTy(), *this)) {
- cerr << "Call result has unhandled type "
- << VT.getMVTString() << "\n";
- abort();
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "Call result has unhandled type "
+ << VT.getMVTString();
+ llvm_report_error(Msg.str());
}
}
diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 868a5b5727..eb9dccb289 100644
--- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -33,6 +33,7 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include <algorithm>
#include <set>
@@ -2258,8 +2259,7 @@ SDValue DAGCombiner::visitXOR(SDNode *N) {
if (!LegalOperations || TLI.isCondCodeLegal(NotCC, LHS.getValueType())) {
switch (N0.getOpcode()) {
default:
- assert(0 && "Unhandled SetCC Equivalent!");
- abort();
+ LLVM_UNREACHABLE("Unhandled SetCC Equivalent!");
case ISD::SETCC:
return DAG.getSetCC(N->getDebugLoc(), VT, LHS, RHS, NotCC);
case ISD::SELECT_CC:
diff --git a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 19456417b7..a4fff892da 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -32,6 +32,7 @@
#include "llvm/GlobalVariable.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
@@ -948,8 +949,7 @@ SDValue SelectionDAGLegalize::LegalizeOp(SDValue Op) {
#ifndef NDEBUG
cerr << "NODE: "; Node->dump(&DAG); cerr << "\n";
#endif
- assert(0 && "Do not know how to legalize this operator!");
- abort();
+ LLVM_UNREACHABLE("Do not know how to legalize this operator!");
case ISD::CALL:
// The only option for this is to custom lower it.
Tmp3 = TLI.LowerOperation(Result.getValue(0), DAG);
@@ -1699,7 +1699,7 @@ void SelectionDAGLegalize::LegalizeSetCCCondCode(MVT VT,
ISD::CondCode CC1 = ISD::SETCC_INVALID, CC2 = ISD::SETCC_INVALID;
unsigned Opc = 0;
switch (CCCode) {
- default: assert(0 && "Don't know how to expand this condition!"); abort();
+ default: LLVM_UNREACHABLE("Don't know how to expand this condition!");
case ISD::SETOEQ: CC1 = ISD::SETEQ; CC2 = ISD::SETO; Opc = ISD::AND; break;
case ISD::SETOGT: CC1 = ISD::SETGT; CC2 = ISD::SETO; Opc = ISD::AND; break;
case ISD::SETOGE: CC1 = ISD::SETGE; CC2 = ISD::SETO; Opc = ISD::AND; break;
@@ -2147,7 +2147,7 @@ SDValue SelectionDAGLegalize::ExpandBSWAP(SDValue Op, DebugLoc dl) {
MVT SHVT = TLI.getShiftAmountTy();
SDValue Tmp1, Tmp2, Tmp3, Tmp4, Tmp5, Tmp6, Tmp7, Tmp8;
switch (VT.getSimpleVT()) {
- default: assert(0 && "Unhandled Expand type in BSWAP!"); abort();
+ default: LLVM_UNREACHABLE("Unhandled Expand type in BSWAP!");
case MVT::i16:
Tmp2 = DAG.getNode(ISD::SHL, dl, VT, Op, DAG.getConstant(8, SHVT));
Tmp1 = DAG.getNode(ISD::SRL, dl, VT, Op, DAG.getConstant(8, SHVT));
diff --git a/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
index 1ad0ddd69e..9428525cf8 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
@@ -20,6 +20,8 @@
//===----------------------------------------------------------------------===//
#include "LegalizeTypes.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/raw_ostream.h"
using namespace llvm;
/// GetFPLibCall - Return the right libcall for the given floating point type.
@@ -51,8 +53,7 @@ void DAGTypeLegalizer::SoftenFloatResult(SDNode *N, unsigned ResNo) {
cerr << "SoftenFloatResult #" << ResNo << ": ";
N->dump(&DAG); cerr << "\n";
#endif
- assert(0 && "Do not know how to soften the result of this operator!");
- abort();
+ LLVM_UNREACHABLE("Do not know how to soften the result of this operator!");
case ISD::BIT_CONVERT: R = SoftenFloatRes_BIT_CONVERT(N); break;
case ISD::BUILD_PAIR: R = SoftenFloatRes_BUILD_PAIR(N); break;
@@ -540,8 +541,7 @@ bool DAGTypeLegalizer::SoftenFloatOperand(SDNode *N, unsigned OpNo) {
cerr << "SoftenFloatOperand Op #" << OpNo << ": ";
N->dump(&DAG); cerr << "\n";
#endif
- assert(0 && "Do not know how to soften this operator's operand!");
- abort();
+ LLVM_UNREACHABLE("Do not know how to soften this operator's operand!");
case ISD::BIT_CONVERT: Res = SoftenFloatOp_BIT_CONVERT(N); break;
case ISD::BR_CC: Res = SoftenFloatOp_BR_CC(N); break;
@@ -781,8 +781,7 @@ void DAGTypeLegalizer::ExpandFloatResult(SDNode *N, unsigned ResNo) {
cerr << "ExpandFloatResult #" << ResNo << ": ";
N->dump(&DAG); cerr << "\n";
#endif
- assert(0 && "Do not know how to expand the result of this operator!");
- abort();
+ LLVM_UNREACHABLE("Do not know how to expand the result of this operator!");
case ISD::MERGE_VALUES: SplitRes_MERGE_VALUES(N, Lo, Hi); break;
case ISD::UNDEF: SplitRes_UNDEF(N, Lo, Hi); break;
@@ -1181,8 +1180,7 @@ bool DAGTypeLegalizer::ExpandFloatOperand(SDNode *N, unsigned OpNo) {
cerr << "ExpandFloatOperand Op #" << OpNo << ": ";
N->dump(&DAG); cerr << "\n";
#endif
- assert(0 && "Do not know how to expand this operator's operand!");
- abort();
+ LLVM_UNREACHABLE("Do not know how to expand this operator's operand!");
case ISD::BIT_CONVERT: Res = ExpandOp_BIT_CONVERT(N); break;
case ISD::BUILD_VECTOR: Res = ExpandOp_BUILD_VECTOR(N); break;
diff --git a/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
index 92446544a5..730619c7f4 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
@@ -20,6 +20,7 @@
#include "LegalizeTypes.h"
#include "llvm/CodeGen/PseudoSourceValue.h"
+#include "llvm/Support/ErrorHandling.h"
using namespace llvm;
//===----------------------------------------------------------------------===//
@@ -44,8 +45,7 @@ void DAGTypeLegalizer::PromoteIntegerResult(SDNode *N, unsigned ResNo) {
cerr << "PromoteIntegerResult #" << ResNo << ": ";
N->dump(&DAG); cerr << "\n";
#endif
- assert(0 && "Do not know how to promote this operator!");
- abort();
+ LLVM_UNREACHABLE("Do not know how to promote this operator!");
case ISD::AssertSext: Res = PromoteIntRes_AssertSext(N); break;
case ISD::AssertZext: Res = PromoteIntRes_AssertZext(N); break;
case ISD::BIT_CONVERT: Res = PromoteIntRes_BIT_CONVERT(N); break;
@@ -610,8 +610,7 @@ bool DAGTypeLegalizer::PromoteIntegerOperand(SDNode *N, unsigned OpNo) {
cerr << "PromoteIntegerOperand Op #" << OpNo << ": ";
N->dump(&DAG); cerr << "\n";
#endif
- assert(0 && "Do not know how to promote this operator's operand!");
- abort();
+ LLVM_UNREACHABLE("Do not know how to promote this operator's operand!");
case ISD::ANY_EXTEND: Res = PromoteIntOp_ANY_EXTEND(N); break;
case ISD::BIT_CONVERT: Res = PromoteIntOp_BIT_CONVERT(N); break;
@@ -924,8 +923,7 @@ void DAGTypeLegalizer::ExpandIntegerResult(SDNode *N, unsigned ResNo) {
cerr << "ExpandIntegerResult #" << ResNo << ": ";
N->dump(&DAG); cerr << "\n";
#endif
- assert(0 && "Do not know how to expand the result of this operator!");
- abort();
+ LLVM_UNREACHABLE("Do not know how to expand the result of this operator!");
case ISD::MERGE_VALUES: SplitRes_MERGE_VALUES(N, Lo, Hi); break;
case ISD::SELECT: SplitRes_SELECT(N, Lo, Hi); break;
@@ -1970,8 +1968,7 @@ bool DAGTypeLegalizer::ExpandIntegerOperand(SDNode *N, unsigned OpNo) {
cerr << "ExpandIntegerOperand Op #" << OpNo << ": ";
N->dump(&DAG); cerr << "\n";
#endif
- assert(0 && "Do not know how to expand this operator's operand!");
- abort();
+ LLVM_UNREACHABLE("Do not know how to expand this operator's operand!");
case ISD::BIT_CONVERT: Res = ExpandOp_BIT_CONVERT(N); break;
case ISD::BR_CC: Res = ExpandIntOp_BR_CC(N); break;
diff --git a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
index 183b1fa51f..f8d198a34b 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp
@@ -17,6 +17,7 @@
#include "llvm/CallingConv.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Target/TargetData.h"
using namespace llvm;
@@ -149,7 +150,7 @@ void DAGTypeLegalizer::PerformExpensiveChecks() {
if (Mapped & 128)
cerr << " WidenedVectors";
cerr << "\n";
- abort();
+ llvm_unreachable();
}
}
}
@@ -431,7 +432,7 @@ NodeDone:
if (Failed) {
I->dump(&DAG); cerr << "\n";
- abort();
+ llvm_unreachable();
}
}
#endif
diff --git a/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp b/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
index 8bec4c7b15..d4e886d254 100644
--- a/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
+++ b/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
@@ -23,6 +23,7 @@
#include "LegalizeTypes.h"
#include "llvm/CodeGen/PseudoSourceValue.h"
#include "llvm/Target/TargetData.h"
+#include "llvm/Support/ErrorHandling.h"
using namespace llvm;
//===----------------------------------------------------------------------===//
@@ -40,8 +41,7 @@ void DAGTypeLegalizer::ScalarizeVectorResult(SDNode *N, unsigned ResNo) {
cerr << "ScalarizeVectorResult #" << ResNo << ": ";
N->dump(&DAG); cerr << "\n";
#endif
- assert(0 && "Do not know how to scalarize the result of this operator!");
- abort();
+ LLVM_UNREACHABLE("Do not know how to scalarize the result of this operator!");
case ISD::BIT_CONVERT: R = ScalarizeVecRes_BIT_CONVERT(N); break;
case ISD::BUILD_VECTOR: R = N->getOperand(0); break;
@@ -378,8 +378,7 @@ void DAGTypeLegalizer::SplitVectorResult(SDNode *N, unsigned ResNo) {
cerr << "SplitVectorResult #" << ResNo << ": ";
N->dump(&DAG); cerr << "\n";
#endif
- assert(0 && "Do not know how to split the result of this operator!");
- abort();
+ LLVM_UNREACHABLE("Do not know how to split the result of this operator!");
case ISD::MERGE_VALUES: SplitRes_MERGE_VALUES(N, Lo, Hi); break;
case ISD::SELECT: SplitRes_SELECT(N, Lo, Hi); break;
@@ -929,8 +928,7 @@ bool DAGTypeLegalizer::SplitVectorOperand(SDNode *N, unsigned OpNo) {
cerr << "SplitVectorOperand Op #" << OpNo << ": ";
N->dump(&DAG); cerr << "\n";
#endif
- assert(0 && "Do not know how to split this operator's operand!");
- abort();
+ LLVM_UNREACHABLE("Do not know how to split this operator's operand!");
case ISD::BIT_CONVERT: Res = SplitVecOp_BIT_CONVERT(N); break;
case ISD::EXTRACT_SUBVECTOR: Res = SplitVecOp_EXTRACT_SUBVECTOR(N); break;
@@ -1119,8 +1117,7 @@ void DAGTypeLegalizer::WidenVectorResult(SDNode *N, unsigned ResNo) {
cerr << "WidenVectorResult #" << ResNo << ": ";
N->dump(&DAG); cerr << "\n";
#endif
- assert(0 && "Do not know how to widen the result of this operator!");
- abort();
+ LLVM_UNREACHABLE("Do not know how to widen the result of this operator!");
case ISD::BIT_CONVERT: Res = WidenVecRes_BIT_CONVERT(N); break;
case ISD::BUILD_VECTOR: Res = WidenVecRes_BUILD_VECTOR(N); break;
@@ -1776,8 +1773,7 @@ bool DAGTypeLegalizer::WidenVectorOperand(SDNode *N, unsigned ResNo) {
cerr << "WidenVectorOperand op #" << ResNo << ": ";
N->dump(&DAG); cerr << "\n";
#endif
- assert(0 && "Do not know how to widen this operator's operand!");
- abort();
+ LLVM_UNREACHABLE("Do not know how to widen this operator's operand!");
case ISD::BIT_CONVERT: Res = WidenVecOp_BIT_CONVERT(N); break;
case ISD::CONCAT_VECTORS: Res = WidenVecOp_CONCAT_VECTORS(N); break;
diff --git a/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp b/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp
index af73b28fae..4f6e59cd0d 100644
--- a/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp
+++ b/lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp
@@ -24,6 +24,7 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ErrorHandling.h"
using namespace llvm;
STATISTIC(NumUnfolds, "Number of nodes unfolded");
@@ -568,8 +569,7 @@ void ScheduleDAGFast::ListScheduleBottomUp() {
}
if (!CurSU) {
- assert(false && "Unable to resolve live physical register dependencies!");
- abort();
+ LLVM_UNREACHABLE("Unable to resolve live physical register dependencies!");
}
}
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
index 391cf17fa1..1e31b8f551 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
@@ -49,6 +49,7 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
@@ -817,8 +818,7 @@ void SelectionDAGLowering::visit(unsigned Opcode, User &I) {
// Note: this doesn't use InstVisitor, because it has to work with
// ConstantExpr's in addition to instructions.
switch (Opcode) {
- default: assert(0 && "Unknown instruction type encountered!");
- abort();
+ default: LLVM_UNREACHABLE("Unknown instruction type encountered!");
// Build the switch statement using the Instruction.def file.
#define HANDLE_INST(NUM, OPCODE, CLASS) \
case Instruction::OPCODE:return visit##OPCODE((CLASS&)I);
@@ -4160,13 +4160,11 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
}
case Intrinsic::part_select: {
// Currently not implemented: just abort
- assert(0 && "part_select intrinsic not implemented");
- abort();
+ llvm_report_error("part_select intrinsic not implemented");
}
case Intrinsic::part_set: {
// Currently not implemented: just abort
- assert(0 && "part_set intrinsic not implemented");
- abort();
+ llvm_report_error("part_set intrinsic not implemented");
}
case Intrinsic::bswap:
setValue(&I, DAG.getNode(ISD::BSWAP, dl,
@@ -5084,9 +5082,9 @@ void SelectionDAGLowering::visitInlineAsm(CallSite CS) {
Input.ConstraintVT.isInteger()) ||
(OpInfo.ConstraintVT.getSizeInBits() !=
Input.ConstraintVT.getSizeInBits())) {
- cerr << "llvm: error: Unsupported asm: input constraint with a "
- << "matching output constraint of incompatible type!\n";
- exit(1);
+ llvm_report_error("llvm: error: Unsupported asm: input constraint"
+ " with a matching output constraint of incompatible"
+ " type!");
}
Input.ConstraintVT = OpInfo.ConstraintVT;
}
@@ -5189,9 +5187,8 @@ void SelectionDAGLowering::visitInlineAsm(CallSite CS) {
// Copy the output from the appropriate register. Find a register that
// we can use.
if (OpInfo.AssignedRegs.Regs.empty()) {
- cerr << "llvm: error: Couldn't allocate output reg for constraint '"
- << OpInfo.ConstraintCode << "'!\n";
- exit(1);
+ llvm_report_error("llvm: error: Couldn't allocate output reg for"
+ " constraint '" + OpInfo.ConstraintCode + "'!");
}
// If this is an indirect operand, store through the pointer after the
@@ -5244,10 +5241,9 @@ void SelectionDAGLowering::visitInlineAsm(CallSite CS) {
|| (OpFlag & 7) == 6 /* EARLYCLOBBER REGDEF */) {
// Add (OpFlag&0xffff)>>3 registers to MatchedRegs.
if (OpInfo.isIndirect) {
- cerr << "llvm: error: "
- "Don't know how to handle tied indirect "
- "register inputs yet!\n";
- exit(1);
+ llvm_report_error("llvm: error: "
+ "Don't know how to handle tied indirect "
+ "register inputs yet!");
}
RegsForValue MatchedRegs;
MatchedRegs.TLI = &TLI;
@@ -5289,9 +5285,8 @@ void SelectionDAGLowering::visitInlineAsm(CallSite CS) {
TLI.LowerAsmOperandForConstraint(InOperandVal, OpInfo.ConstraintCode[0],
hasMemory, Ops, DAG);
if (Ops.empty()) {
- cerr << "llvm: error: Invalid operand for inline asm constraint '"
- << OpInfo.ConstraintCode << "'!\n";
- exit(1);
+ llvm_report_error("llvm: error: Invalid operand for inline asm"
+ " constraint '" + OpInfo.ConstraintCode + "'!");
}
// Add information to the INLINEASM node to know about this input.
@@ -5321,9 +5316,8 @@ void SelectionDAGLowering::visitInlineAsm(CallSite CS) {
// Copy the input into the appropriate registers.
if (OpInfo.AssignedRegs.Regs.empty()) {
- cerr << "llvm: error: Couldn't allocate input reg for constraint '"
- << OpInfo.ConstraintCode << "'!\n";
- exit(1);
+ llvm_report_error("llvm: error: Couldn't allocate input reg for"
+ " constraint '"+ OpInfo.ConstraintCode +"'!");
}
OpInfo.AssignedRegs.getCopyToRegs(InOperandVal, DAG, getCurDebugLoc(),
@@ -5776,8 +5770,7 @@ void TargetLowering::LowerOperationWrapper(SDNode *N,
}
SDValue TargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) {
- assert(0 && "LowerOperation not implemented for this target!");
- abort();
+ LLVM_UNREACHABLE("LowerOperation not implemented for this target!");
return SDValue();
}
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 485545c63a..cadf854f21 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -47,6 +47,7 @@
#include "llvm/Target/TargetOptions.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/Timer.h"
#include <algorithm>
@@ -151,10 +152,9 @@ namespace llvm {
// basic blocks, and the scheduler passes ownership of it to this method.
MachineBasicBlock *TargetLowering::EmitInstrWithCustomInserter(MachineInstr *MI,
MachineBasicBlock *MBB) const {
- cerr << "If a target marks an instruction with "
- << "'usesCustomDAGSchedInserter', it must implement "
- << "TargetLowering::EmitInstrWithCustomInserter!\n";
- abort();
+ llvm_report_error("If a target marks an instruction with "
+ "'usesCustomDAGSchedInserter', it must implement "
+ "TargetLowering::EmitInstrWithCustomInserter!");
return 0;
}
@@ -875,7 +875,7 @@ void SelectionDAGISel::SelectAllBasicBlocks(Function &Fn,
if (EnableFastISelAbort)
// The "fast" selector couldn't handle something and bailed.
// For the purpose of debugging, just abort.
- assert(0 && "FastISel didn't select the entire block");
+ LLVM_UNREACHABLE("FastISel didn't select the entire block");
}
break;
}
@@ -1215,8 +1215,8 @@ SelectInlineAsmMemoryOperands(std::vector<SDValue> &Ops) {
// Otherwise, this is a memory operand. Ask the target to select it.
std::vector<SDValue> SelOps;
if (SelectInlineAsmMemoryOperand(InOps[i+1], 'm', SelOps)) {
- cerr << "Could not match memory address. Inline asm failure!\n";
- exit(1);
+ llvm_report_error("Could not match memory address. Inline asm"
+ " failure!");
}
// Add this to the output node.
diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp
index 5ff7eb17cb..7c7456562b 100644
--- a/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -24,6 +24,7 @@
#include "llvm/Support/Debug.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MutexGuard.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/System/DynamicLibrary.h"
#include "llvm/System/Host.h"
#include "llvm/Target/TargetData.h"
@@ -332,32 +333,27 @@ int ExecutionEngine::runFunctionAsMain(Function *Fn,
switch (NumArgs) {
case 3:
if (FTy->getParamType(2) != PPInt8Ty) {
- cerr << "Invalid type for third argument of main() supplied\n";
- abort();
+ llvm_report_error("Invalid type for third argument of main() supplied");
}
// FALLS THROUGH
case 2:
if (FTy->getParamType(1) != PPInt8Ty) {
- cerr << "Invalid type for second argument of main() supplied\n";
- abort();
+ llvm_report_error("Invalid type for second argument of main() supplied");
}
// FALLS THROUGH
case 1:
if (FTy->getParamType(0) != Type::Int32Ty) {
- cerr << "Invalid type for first argument of main() supplied\n";
- abort();
+ llvm_report_error("Invalid type for first argument of main() supplied");
}
// FALLS THROUGH
case 0:
if (!isa<IntegerType>(FTy->getReturnType()) &&
FTy->getReturnType() != Type::VoidTy) {
- cerr << "Invalid return type of main() supplied\n";
- abort();
+ llvm_report_error("Invalid return type of main() supplied");
}
break;
default:
- cerr << "Invalid number of arguments of main() supplied\n";
- abort();
+ llvm_report_error("Invalid number of arguments of main() supplied");
}
if (NumArgs) {
@@ -591,7 +587,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
GenericValue RHS = getConstantValue(CE->getOperand(1));
GenericValue GV;
switch (CE->getOperand(0)->getType()->getTypeID()) {
- default: assert(0 && "Bad add type!"); abort();
+ default: LLVM_UNREACHABLE("Bad add type!");
case Type::IntegerTyID:
switch (CE->getOpcode()) {
default: assert(0 && "Invalid integer opcode");
@@ -609,7 +605,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
break;
case Type::FloatTyID:
switch (CE->getOpcode()) {
- default: assert(0 && "Invalid float opcode"); abort();
+ default: LLVM_UNREACHABLE("Invalid float opcode");
case Instruction::FAdd:
GV.FloatVal = LHS.FloatVal + RHS.FloatVal; break;
case Instruction::FSub:
@@ -624,7 +620,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
break;
case Type::DoubleTyID:
switch (CE->getOpcode()) {
- default: assert(0 && "Invalid double opcode"); abort();
+ default: LLVM_UNREACHABLE("Invalid double opcode");
case Instruction::FAdd:
GV.DoubleVal = LHS.DoubleVal + RHS.DoubleVal; break;
case Instruction::FSub:
@@ -672,8 +668,10 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
default:
break;
}
- cerr << "ConstantExpr not handled: " << *CE << "\n";
- abort();
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "ConstantExpr not handled: " << *CE;
+ llvm_report_error(Msg.str());
}
GenericValue Result;
@@ -703,8 +701,10 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
assert(0 && "Unknown constant pointer type!");
break;
default:
- cerr << "ERROR: Constant unimplemented for type: " << *C->getType() << "\n";
- abort();
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "ERROR: Constant unimplemented for type: " << *C->getType();
+ llvm_report_error(Msg.str());
}
return Result;
}
@@ -838,8 +838,10 @@ void ExecutionEngine::LoadValueFromMemory(GenericValue &Result,
break;
}
default:
- cerr << "Cannot load value of type " << *Ty << "!\n";
- abort();
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "Cannot load value of type " << *Ty << "!";
+ llvm_report_error(Msg.str());
}
}
diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp
index 5ac333fc6d..872bfeb737 100644
--- a/lib/ExecutionEngine/Interpreter/Execution.cpp
+++ b/lib/ExecutionEngine/Interpreter/Execution.cpp
@@ -22,6 +22,7 @@
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MathExtras.h"
#include <algorithm>
#include <cmath>
@@ -57,7 +58,7 @@ static void executeFAddInst(GenericValue &Dest, GenericValue Src1,
IMPLEMENT_BINARY_OPERATOR(+, Double);
default:
cerr << "Unhandled type for FAdd instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
}
@@ -68,7 +69,7 @@ static void executeFSubInst(GenericValue &Dest, GenericValue Src1,
IMPLEMENT_BINARY_OPERATOR(-, Double);
default:
cerr << "Unhandled type for FSub instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
}
@@ -79,7 +80,7 @@ static void executeFMulInst(GenericValue &Dest, GenericValue Src1,
IMPLEMENT_BINARY_OPERATOR(*, Double);
default:
cerr << "Unhandled type for FMul instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
}
@@ -90,7 +91,7 @@ static void executeFDivInst(GenericValue &Dest, GenericValue Src1,
IMPLEMENT_BINARY_OPERATOR(/, Double);
default:
cerr << "Unhandled type for FDiv instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
}
@@ -105,7 +106,7 @@ static void executeFRemInst(GenericValue &Dest, GenericValue Src1,
break;
default:
cerr << "Unhandled type for Rem instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
}
@@ -132,7 +133,7 @@ static GenericValue executeICMP_EQ(GenericValue Src1, GenericValue Src2,
IMPLEMENT_POINTER_ICMP(==);
default:
cerr << "Unhandled type for ICMP_EQ predicate: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
@@ -145,7 +146,7 @@ static GenericValue executeICMP_NE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_POINTER_ICMP(!=);
default:
cerr << "Unhandled type for ICMP_NE predicate: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
@@ -158,7 +159,7 @@ static GenericValue executeICMP_ULT(GenericValue Src1, GenericValue Src2,
IMPLEMENT_POINTER_ICMP(<);
default:
cerr << "Unhandled type for ICMP_ULT predicate: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
@@ -171,7 +172,7 @@ static GenericValue executeICMP_SLT(GenericValue Src1, GenericValue Src2,
IMPLEMENT_POINTER_ICMP(<);
default:
cerr << "Unhandled type for ICMP_SLT predicate: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
@@ -184,7 +185,7 @@ static GenericValue executeICMP_UGT(GenericValue Src1, GenericValue Src2,
IMPLEMENT_POINTER_ICMP(>);
default:
cerr << "Unhandled type for ICMP_UGT predicate: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
@@ -197,7 +198,7 @@ static GenericValue executeICMP_SGT(GenericValue Src1, GenericValue Src2,
IMPLEMENT_POINTER_ICMP(>);
default:
cerr << "Unhandled type for ICMP_SGT predicate: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
@@ -210,7 +211,7 @@ static GenericValue executeICMP_ULE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_POINTER_ICMP(<=);
default:
cerr << "Unhandled type for ICMP_ULE predicate: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
@@ -223,7 +224,7 @@ static GenericValue executeICMP_SLE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_POINTER_ICMP(<=);
default:
cerr << "Unhandled type for ICMP_SLE predicate: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
@@ -236,7 +237,7 @@ static GenericValue executeICMP_UGE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_POINTER_ICMP(>=);
default:
cerr << "Unhandled type for ICMP_UGE predicate: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
@@ -249,7 +250,7 @@ static GenericValue executeICMP_SGE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_POINTER_ICMP(>=);
default:
cerr << "Unhandled type for ICMP_SGE predicate: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
@@ -274,7 +275,7 @@ void Interpreter::visitICmpInst(ICmpInst &I) {
case ICmpInst::ICMP_SGE: R = executeICMP_SGE(Src1, Src2, Ty); break;
default:
cerr << "Don't know how to handle this ICmp predicate!\n-->" << I;
- abort();
+ llvm_unreachable();
}
SetValue(&I, R, SF);
@@ -293,7 +294,7 @@ static GenericValue executeFCMP_OEQ(GenericValue Src1, GenericValue Src2,
IMPLEMENT_FCMP(==, Double);
default:
cerr << "Unhandled type for FCmp EQ instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
@@ -307,7 +308,7 @@ static GenericValue executeFCMP_ONE(GenericValue Src1, GenericValue Src2,
default:
cerr << "Unhandled type for FCmp NE instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
@@ -320,7 +321,7 @@ static GenericValue executeFCMP_OLE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_FCMP(<=, Double);
default:
cerr << "Unhandled type for FCmp LE instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
@@ -333,7 +334,7 @@ static GenericValue executeFCMP_OGE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_FCMP(>=, Double);
default:
cerr << "Unhandled type for FCmp GE instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
@@ -346,7 +347,7 @@ static GenericValue executeFCMP_OLT(GenericValue Src1, GenericValue Src2,
IMPLEMENT_FCMP(<, Double);
default:
cerr << "Unhandled type for FCmp LT instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
@@ -359,7 +360,7 @@ static GenericValue executeFCMP_OGT(GenericValue Src1, GenericValue Src2,
IMPLEMENT_FCMP(>, Double);
default:
cerr << "Unhandled type for FCmp GT instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
return Dest;
}
@@ -468,7 +469,7 @@ void Interpreter::visitFCmpInst(FCmpInst &I) {
case FCmpInst::FCMP_OGE: R = executeFCMP_OGE(Src1, Src2, Ty); break;
default:
cerr << "Don't know how to handle this FCmp predicate!\n-->" << I;
- abort();
+ llvm_unreachable();
}
SetValue(&I, R, SF);
@@ -514,7 +515,7 @@ static GenericValue executeCmpInst(unsigned predicate, GenericValue Src1,
}
default:
cerr << "Unhandled Cmp predicate\n";
- abort();
+ llvm_unreachable();
}
}
@@ -543,7 +544,7 @@ void Interpreter::visitBinaryOperator(BinaryOperator &I) {
case Instruction::Xor: R.IntVal = Src1.IntVal ^ Src2.IntVal; break;
default:
cerr << "Don't know how to handle this binary operator!\n-->" << I;
- abort();
+ llvm_unreachable();
}
SetValue(&I, R, SF);
@@ -630,7 +631,7 @@ void Interpreter::visitUnwindInst(UnwindInst &I) {
do {
ECStack.pop_back ();
if (ECStack.empty ())
- abort ();
+ llvm_report_error("Empty stack during unwind!");
Inst = ECStack.back ().Caller.getInstruction ();
} while (!(Inst && isa<InvokeInst> (Inst)));
@@ -643,8 +644,7 @@ void Interpreter::visitUnwindInst(UnwindInst &I) {
}
void Interpreter::visitUnreachableInst(UnreachableInst &I) {
- cerr << "ERROR: Program executed an 'unreachable' instruction!\n";
- abort();
+ llvm_report_error("ERROR: Program executed an 'unreachable' instruction!");
}
void Interpreter::visitBranchInst(BranchInst &I) {
@@ -1176,7 +1176,7 @@ void Interpreter::visitVAArgInst(VAArgInst &I) {
IMPLEMENT_VAARG(Double);
default:
cerr << "Unhandled dest type for vaarg instruction: " << *Ty << "\n";
- abort();
+ llvm_unreachable();
}
// Set the Value of this Instruction.
@@ -1263,7 +1263,7 @@ GenericValue Interpreter::getConstantExprValue (ConstantExpr *CE,
break;
default:
cerr << "Unhandled ConstantExpr: " << *CE << "\n";
- abort();
+ llvm_unreachable();
return GenericValue();
}
return Dest;
diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
index 21a6f761db..12d54ae122 100644
--- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
+++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
@@ -23,6 +23,7 @@
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
#include "llvm/Config/config.h" // Detect libffi
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Streams.h"
#include "llvm/System/DynamicLibrary.h"
#include "llvm/Target/TargetData.h"
@@ -126,8 +127,7 @@ static ffi_type *ffiTypeFor(const Type *Ty) {
default: break;
}
// TODO: Support other types such as StructTyID, ArrayTyID, OpaqueTyID, etc.
- cerr << "Type could not be mapped for use with libffi.\n";
- abort();
+ llvm_report_error("Type could not be mapped for use with libffi.");
return NULL;
}
@@ -175,8 +175,7 @@ static void *ffiValueFor(const Type *Ty, const GenericValue &AV,
default: break;
}
// TODO: Support other types such as StructTyID, ArrayTyID, OpaqueTyID, etc.
- cerr << "Type value could not be mapped for use with libffi.\n";
- abort();
+ llvm_report_error("Type value could not be mapped for use with libffi.");
return NULL;
}
@@ -190,9 +189,8 @@ static bool ffiInvoke(RawFunc Fn, Function *F,
// TODO: We don't have type information about the remaining arguments, because
// this information is never passed into ExecutionEngine::runFunction().
if (ArgVals.size() > NumArgs && F->isVarArg()) {
- cerr << "Calling external var arg function '" << F->getName()
- << "' is not supported by the Interpreter.\n";
- abort();
+ llvm_report_error("Calling external var arg function '" + F->getName()
+ + "' is not supported by the Interpreter.");
}
unsigned ArgBytes = 0;
@@ -280,10 +278,12 @@ GenericValue Interpreter::callExternalFunction(Function *F,
return Result;
#endif // USE_LIBFFI
- cerr << "Tried to execute an unknown external function: "
- << F->getType()->getDescription() << " " << F->getName() << "\n";
- if (F->getName() != "__main")
- abort();
+ if (F->getName() == "__main")
+ cerr << "Tried to execute an unknown external function: "
+ << F->getType()->getDescription() << " __main\n";
+ else
+ llvm_report_error("Tried to execute an unknown external function: " +
+ F->getType()->getDescription() + " " +F->getName());
return GenericValue();
}
@@ -313,6 +313,8 @@ GenericValue lle_X_exit(const FunctionType *FT,
// void abort(void)
GenericValue lle_X_abort(const FunctionType *FT,
const std::vector<GenericValue> &Args) {
+ //FIXME: should we report or raise here?
+ //llvm_report_error("Interpreted program raised SIGABRT");
raise (SIGABRT);
return GenericValue();
}
diff --git a/lib/ExecutionEngine/JIT/Intercept.cpp b/lib/ExecutionEngine/JIT/Intercept.cpp
index 3dcc4626a1..feb13c6ce1 100644
--- a/lib/ExecutionEngine/JIT/Intercept.cpp
+++ b/lib/ExecutionEngine/JIT/Intercept.cpp
@@ -16,6 +16,7 @@
//===----------------------------------------------------------------------===//
#include "JIT.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Streams.h"
#include "llvm/System/DynamicLibrary.h"
#include "llvm/Config/config.h"
@@ -140,9 +141,8 @@ void *JIT::getPointerToNamedFunction(const std::string &Name,
return RP;
if (AbortOnFailure) {
- cerr << "ERROR: Program used external function '" << Name
- << "' which could not be resolved!\n";
- abort();
+ llvm_report_error("ERROR: Program used external function '"+Name+
+ "' which could not be resolved!");
}
return 0;
}
diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp
index 55ce16c354..f8f3f20fe2 100644
--- a/lib/ExecutionEngine/JIT/JIT.cpp
+++ b/lib/ExecutionEngine/JIT/JIT.cpp
@@ -227,8 +227,7 @@ JIT::JIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji,
// Turn the machine code intermediate representation into bytes in memory that
// may be executed.
if (TM.addPassesToEmitMachineCode(PM, *JCE, OptLevel)) {
- cerr << "Target does not support machine code emission!\n";
- abort();
+ llvm_report_error("Target does not support machine code emission!");
}
// Register routine for informing unwinding runtime about new EH frames
@@ -276,8 +275,7 @@ void JIT::addModuleProvider(ModuleProvider *MP) {
// Turn the machine code intermediate representation into bytes in memory
// that may be executed.
if (TM.addPassesToEmitMachineCode(PM, *JCE, CodeGenOpt::Default)) {
- cerr << "Target does not support machine code emission!\n";
- abort();
+ llvm_report_error("Target does not support machine code emission!");
}
// Initialize passes.
@@ -309,8 +307,7 @@ Module *JIT::removeModuleProvider(ModuleProvider *MP, std::string *E) {
// Turn the machine code intermediate representation into bytes in memory
// that may be executed.
if (TM.addPassesToEmitMachineCode(PM, *JCE, CodeGenOpt::Default)) {
- cerr << "Target does not support machine code emission!\n";
- abort();
+ llvm_report_error("Target does not support machine code emission!");
}
// Initialize passes.
@@ -341,8 +338,7 @@ void JIT::deleteModuleProvider(ModuleProvider *MP, std::string *E) {
// Turn the machine code intermediate representation into bytes in memory
// that may be executed.
if (TM.addPassesToEmitMachineCode(PM, *JCE, CodeGenOpt::Default)) {
- cerr << "Target does not support machine code emission!\n";
- abort();
+ llvm_report_error("Target does not support machine code emission!");
}
// Initialize passes.
@@ -632,9 +628,8 @@ void *JIT::getPointerToFunction(Function *F) {
std::string ErrorMsg;
if (MP->materializeFunction(F, &ErrorMsg)) {
- cerr << "Error reading function '" << F->getName()
- << "' from bitcode file: " << ErrorMsg << "\n";
- abort();
+ llvm_report_error("Error reading function '" + F->getName()+
+ "' from bitcode file: " + ErrorMsg);
}
// Now retry to get the address.
@@ -724,8 +719,7 @@ char* JIT::getMemoryForGV(const GlobalVariable* GV) {
// situation. It's returned in the same block of memory as code which may
// not be writable.
if (isGVCompilationDisabled() && !GV->isConstant()) {
- cerr << "Compilation of non-internal GlobalValue is disabled!\n";
- abort();
+ llvm_report_error("Compilation of non-internal GlobalValue is disabled!");
}
// Some applications require globals and code to live together, so they may
diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp
index cfc3680e8a..63ac6f1c72 100644
--- a/lib/ExecutionEngine/JIT/JITEmitter.cpp
+++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp
@@ -33,8 +33,10 @@
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MutexGuard.h"
#include "llvm/Support/ValueHandle.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Disassembler.h"
#include "llvm/System/Memory.h"
#include "llvm/Target/TargetInstrInfo.h"
@@ -373,9 +375,8 @@ void *JITResolver::JITCompilerFn(void *Stub) {
// If lazy compilation is disabled, emit a useful error message and abort.
if (TheJIT->isLazyCompilationDisabled()) {
- cerr << "LLVM JIT requested to do lazy compilation of function '"
- << F->getName() << "' when lazy compiles are disabled!\n";
- abort();
+ llvm_report_error("LLVM JIT requested to do lazy compilation of function '"
+ + F->getName() + "' when lazy compiles are disabled!");
}
// We might like to remove the stub from the StubToFunction map.
@@ -777,8 +778,10 @@ unsigned JITEmitter::addSizeOfGlobalsInConstantVal(const Constant *C,
break;
}
default: {
- cerr << "ConstantExpr not handled: " << *CE << "\n";
- abort();
+ std::string msg;
+ raw_string_ostream Msg(msg);
+ Msg << "ConstantExpr not handled: " << *CE;
+ llvm_report_error(Msg.str());
}
}
}
@@ -920,8 +923,7 @@ void JITEmitter::startFunction(MachineFunction &F) {
bool JITEmitter::finishFunction(MachineFunction &F) {
if (CurBufferPtr == BufferEnd) {
// FIXME: Allocate more space, then try again.
- cerr << "JIT: Ran out of space for generated machine code!\n";
- abort();
+ llvm_report_error("JIT: Ran out of space for generated machine code!");
}
emitJumpTableInfo(F.getJumpTableInfo());
@@ -1017,8 +1019,7 @@ bool JITEmitter::finishFunction(MachineFunction &F) {
if (CurBufferPtr == BufferEnd) {
// FIXME: Allocate more space, then try again.
- cerr << "JIT: Ran out of space for generated machine code!\n";
- abort();
+ llvm_report_error("JIT: Ran out of space for generated machine code!");
}
BufferBegin = CurBufferPtr = 0;
@@ -1199,9 +1200,8 @@ void JITEmitter::emitConstantPool(MachineConstantPool *MCP) {
ConstPoolAddresses.push_back(CAddr);
if (CPE.isMachineConstantPoolEntry()) {
// FIXME: add support to lower machine constant pool values into bytes!
- cerr << "Initialize memory with machine specific constant pool entry"
- << " has not been implemented!\n";
- abort();
+ llvm_report_error("Initialize memory with machine specific constant pool"
+ "entry has not been implemented!");
}
TheJIT->InitializeMemory(CPE.Val.ConstVal, (void*)CAddr);
DOUT << "JIT: CP" << i << " at [0x"
diff --git a/lib/ExecutionEngine/JIT/JITMemoryManager.cpp b/lib/ExecutionEngine/JIT/JITMemoryManager.cpp
index 9820493828..253c001ba3 100644
--- a/lib/ExecutionEngine/JIT/JITMemoryManager.cpp
+++ b/lib/ExecutionEngine/JIT/JITMemoryManager.cpp
@@ -14,6 +14,7 @@
#include "llvm/GlobalValue.h"
#include "llvm/ExecutionEngine/JITMemoryManager.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/System/Memory.h"
#include <map>
#include <vector>
@@ -356,8 +357,7 @@ namespace {
// Check for overflow.
if (CurGlobalPtr > GlobalEnd) {
// FIXME: Allocate more memory.
- fprintf(stderr, "JIT ran out of memory for globals!\n");
- abort();
+ llvm_report_error("JIT ran out of memory for globals!");
}
return Result;
@@ -555,8 +555,7 @@ uint8_t *DefaultJITMemoryManager::allocateStub(const GlobalValue* F,
~(intptr_t)(Alignment-1));
if (CurStubPtr < StubBase) {
// FIXME: allocate a new block
- fprintf(stderr, "JIT ran out of memory for function stubs!\n");
- abort();
+ llvm_report_error("JIT ran out of memory for function stubs!");
}
return CurStubPtr;
}
@@ -567,10 +566,8 @@ sys::MemoryBlock DefaultJITMemoryManager::getNewMemoryBlock(unsigned size) {
std::string ErrMsg;
sys::MemoryBlock B = sys::Memory::AllocateRWX(size, BOld, &ErrMsg);
if (B.base() == 0) {
- fprintf(stderr,
- "Allocation failed when allocating new memory in the JIT\n%s\n",
- ErrMsg.c_str());
- abort();
+ llvm_report_error("Allocation failed when allocating new memory in the"
+ " JIT\n" + ErrMsg);
}
Blocks.push_back(B);
return B;
diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp
index 4922560200..0fe949c877 100644
--- a/lib/Support/CommandLine.cpp
+++ b/lib/Support/CommandLine.cpp
@@ -19,6 +19,7 @@
#include "llvm/Config/config.h"
#include "llvm/ADT/OwningPtr.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Streams.h"
@@ -204,8 +205,7 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName,
cerr << ProgramName
<< ": Bad ValueMask flag! CommandLine usage error:"
<< Handler->getValueExpectedFlag() << "\n";
- abort();
- break;
+ llvm_unreachable();
}
// If this isn't a multi-arg option, just run the handler.
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 79de4432d8..89881f739f 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -48,6 +48,7 @@
#include "llvm/Support/CallSite.h"
#include "llvm/Support/ConstantRange.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/InstVisitor.h"
#include "llvm/Support/MathExtras.h"
@@ -1927,8 +1928,7 @@ static Value *FoldOperationIntoSelectOperand(Instruction &I, Value *SO,
New = CmpInst::Create(*Context, CI->getOpcode(), CI->getPredicate(),
Op0, Op1, SO->getName()+".cmp");
else {
- assert(0 && "Unknown binary instruction type!");
- abort();
+ LLVM_UNREACHABLE("Unknown binary instruction type!");
}
return IC->InsertNewInstBefore(New, I);
}
@@ -9114,7 +9114,7 @@ static unsigned GetSelectFoldableOperands(Instruction *I) {
static Constant *GetSelectFoldableConstant(Instruction *I,
LLVMContext *Context) {
switch (I->getOpcode()) {
- default: assert(0 && "This cannot happen!"); abort();
+ default: LLVM_UNREACHABLE("This cannot happen!");
case Instruction::Add:
case Instruction::Sub:
case Instruction::Or:
diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp
index 4a156907bf..2de64c15ab 100644
--- a/lib/Transforms/Scalar/SCCP.cpp
+++ b/lib/Transforms/Scalar/SCCP.cpp
@@ -35,6 +35,7 @@
#include "llvm/Support/CallSite.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/InstVisitor.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
@@ -513,8 +514,10 @@ bool SCCPSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To) {
}
return false;
} else {
+#ifndef NDEBUG
cerr << "Unknown terminator instruction: " << *TI;
- abort();
+#endif
+ llvm_unreachable();
}
}
diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
index 61fc9eed01..da2c375be9 100644
--- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp
+++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp
@@ -34,6 +34,7 @@
#include "llvm/Transforms/Utils/PromoteMemToReg.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/GetElementPtrTypeIterator.h"
#include "llvm/Support/IRBuilder.h"
#include "llvm/Support/MathExtras.h"
@@ -1510,8 +1511,7 @@ void SROA::ConvertUsesToScalar(Value *Ptr, AllocaInst *NewAI, uint64_t Offset) {
continue;
}
- assert(0 && "Unsupported operation!");
- abort();
+ LLVM_UNREACHABLE("Unsupported operation!");
}
}
diff --git a/lib/Transforms/Utils/BasicBlockUtils.cpp b/lib/Transforms/Utils/BasicBlockUtils.cpp
index f52546ccc4..c9af474342 100644
--- a/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ b/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -24,6 +24,7 @@
#include "llvm/Analysis/Dominators.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Transforms/Utils/Local.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ValueHandle.h"
#include <algorithm>
using namespace llvm;
@@ -263,8 +264,7 @@ void llvm::RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum) {
case Instruction::Switch: // Should remove entry
default:
case Instruction::Ret: // Cannot happen, has no successors!
- assert(0 && "Unhandled terminator instruction type in RemoveSuccessor!");
- abort();
+ LLVM_UNREACHABLE("Unhandled terminator instruction type in RemoveSuccessor!");
}
if (NewTI) // If it's a different instruction, replace.
diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp
index 09b9faf220..be02560de0 100644
--- a/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/lib/Transforms/Utils/CodeExtractor.cpp
@@ -28,6 +28,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/ADT/StringExtras.h"
#include <algorithm>
#include <set>
@@ -710,7 +711,8 @@ ExtractCodeRegion(const std::vector<BasicBlock*> &code) {
// cerr << "OLD FUNCTION: " << *oldFunction;
// verifyFunction(*oldFunction);
- DEBUG(if (verifyFunction(*newFunction)) abort());
+ DEBUG(if (verifyFunction(*newFunction))
+ llvm_report_error("verifyFunction failed!"));
return newFunction;
}
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 5ee386d67b..78ef3a8a7e 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -23,6 +23,7 @@
#include "llvm/ADT/StringMap.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/System/Mutex.h"
@@ -1120,8 +1121,7 @@ namespace llvm {
template<class ConstantClass, class TypeClass>
struct VISIBILITY_HIDDEN ConvertConstantType {
static void convert(ConstantClass *OldC, const TypeClass *NewTy) {
- assert(0 && "This type cannot be converted!\n");
- abort();
+ LLVM_UNREACHABLE("This type cannot be converted!\n");
}
};