aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-09-23 01:46:04 +0000
committerChris Lattner <sabre@nondot.org>2009-09-23 01:46:04 +0000
commit41fa2bd112bfd462ba67c54667a92ff3b29a5c23 (patch)
tree339278fd5712045697989311141a20629b97aae5 /llvm/lib/ExecutionEngine/ExecutionEngine.cpp
parentc0353bfff5a2d37b91af9b40bb6a898e18d03bb8 (diff)
downloadllvm-41fa2bd112bfd462ba67c54667a92ff3b29a5c23.zip
llvm-41fa2bd112bfd462ba67c54667a92ff3b29a5c23.tar.gz
llvm-41fa2bd112bfd462ba67c54667a92ff3b29a5c23.tar.bz2
Make EngineBuilder return more error codes, by KS Sreeram.
llvm-svn: 82600
Diffstat (limited to 'llvm/lib/ExecutionEngine/ExecutionEngine.cpp')
-rw-r--r--llvm/lib/ExecutionEngine/ExecutionEngine.cpp35
1 files changed, 22 insertions, 13 deletions
diff --git a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
index 5be3aa8..fa6209d 100644
--- a/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/llvm/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -269,7 +269,8 @@ static void *CreateArgv(LLVMContext &C, ExecutionEngine *EE,
/// runStaticConstructorsDestructors - This method is used to execute all of
/// the static constructors or destructors for a module, depending on the
/// value of isDtors.
-void ExecutionEngine::runStaticConstructorsDestructors(Module *module, bool isDtors) {
+void ExecutionEngine::runStaticConstructorsDestructors(Module *module,
+ bool isDtors) {
const char *Name = isDtors ? "llvm.global_dtors" : "llvm.global_ctors";
// Execute global ctors/dtors for each module in the program.
@@ -425,30 +426,38 @@ ExecutionEngine *EngineBuilder::create() {
// create, we assume they only want the JIT, and we fail if they only want
// the interpreter.
if (JMM) {
- if (WhichEngine & EngineKind::JIT) {
+ if (WhichEngine & EngineKind::JIT)
WhichEngine = EngineKind::JIT;
- } else {
+ else {
*ErrorStr = "Cannot create an interpreter with a memory manager.";
+ return 0;
}
}
- ExecutionEngine *EE = 0;
-
// Unless the interpreter was explicitly selected or the JIT is not linked,
// try making a JIT.
- if (WhichEngine & EngineKind::JIT && ExecutionEngine::JITCtor) {
- EE = ExecutionEngine::JITCtor(MP, ErrorStr, JMM, OptLevel,
- AllocateGVsWithCode);
+ if (WhichEngine & EngineKind::JIT) {
+ if (ExecutionEngine::JITCtor) {
+ ExecutionEngine *EE =
+ ExecutionEngine::JITCtor(MP, ErrorStr, JMM, OptLevel,
+ AllocateGVsWithCode);
+ if (EE) return EE;
+ } else {
+ *ErrorStr = "JIT has not been linked in.";
+ return 0;
+ }
}
// If we can't make a JIT and we didn't request one specifically, try making
// an interpreter instead.
- if (WhichEngine & EngineKind::Interpreter && EE == 0 &&
- ExecutionEngine::InterpCtor) {
- EE = ExecutionEngine::InterpCtor(MP, ErrorStr);
+ if (WhichEngine & EngineKind::Interpreter) {
+ if (ExecutionEngine::InterpCtor)
+ return ExecutionEngine::InterpCtor(MP, ErrorStr);
+ *ErrorStr = "Interpreter has not been linked in.";
+ return 0;
}
-
- return EE;
+
+ return 0;
}
/// getPointerToGlobal - This returns the address of the specified global