diff options
author | Torok Edwin <edwintorok@gmail.com> | 2009-07-11 13:10:19 +0000 |
---|---|---|
committer | Torok Edwin <edwintorok@gmail.com> | 2009-07-11 13:10:19 +0000 |
commit | 7d696d80409aad20bb5da0fc4eccab941dd371d4 (patch) | |
tree | 948cd8ec42ea724903f0789140bdbfd4f11241dc /lib/ExecutionEngine/JIT | |
parent | 238f5100c60ba69afc388a78a296606bb2e72dce (diff) | |
download | external_llvm-7d696d80409aad20bb5da0fc4eccab941dd371d4.zip external_llvm-7d696d80409aad20bb5da0fc4eccab941dd371d4.tar.gz external_llvm-7d696d80409aad20bb5da0fc4eccab941dd371d4.tar.bz2 |
Convert more assert(0)+abort() -> LLVM_UNREACHABLE,
and abort()/exit() -> llvm_report_error().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75363 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/JIT')
-rw-r--r-- | lib/ExecutionEngine/JIT/Intercept.cpp | 6 | ||||
-rw-r--r-- | lib/ExecutionEngine/JIT/JIT.cpp | 20 | ||||
-rw-r--r-- | lib/ExecutionEngine/JIT/JITEmitter.cpp | 24 | ||||
-rw-r--r-- | lib/ExecutionEngine/JIT/JITMemoryManager.cpp | 13 |
4 files changed, 27 insertions, 36 deletions
diff --git a/lib/ExecutionEngine/JIT/Intercept.cpp b/lib/ExecutionEngine/JIT/Intercept.cpp index 3dcc462..feb13c6 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 55ce16c..f8f3f20 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 cfc3680..63ac6f1 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 9820493..253c001 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; |