errorstr can be null, don't unconditionally set it. Only report that
authorChris Lattner <sabre@nondot.org>
Wed, 23 Sep 2009 02:03:49 +0000 (02:03 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 23 Sep 2009 02:03:49 +0000 (02:03 +0000)
"the jit has not been linked in" if the interpreter failed.

This fixes a unit test failure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82601 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/ExecutionEngine.cpp

index fa6209d2dff346817f613b009f2b60f16f79c9b1..335d4deff84f4777a8b1e6c2954622ba2ccbfdc6 100644 (file)
@@ -429,7 +429,8 @@ ExecutionEngine *EngineBuilder::create() {
     if (WhichEngine & EngineKind::JIT)
       WhichEngine = EngineKind::JIT;
     else {
-      *ErrorStr = "Cannot create an interpreter with a memory manager.";
+      if (ErrorStr)
+        *ErrorStr = "Cannot create an interpreter with a memory manager.";
       return 0;
     }
   }
@@ -442,9 +443,6 @@ ExecutionEngine *EngineBuilder::create() {
         ExecutionEngine::JITCtor(MP, ErrorStr, JMM, OptLevel,
                                  AllocateGVsWithCode);
       if (EE) return EE;
-    } else {
-      *ErrorStr = "JIT has not been linked in.";
-      return 0;
     }
   }
 
@@ -453,10 +451,15 @@ ExecutionEngine *EngineBuilder::create() {
   if (WhichEngine & EngineKind::Interpreter) {
     if (ExecutionEngine::InterpCtor)
       return ExecutionEngine::InterpCtor(MP, ErrorStr);
-    *ErrorStr = "Interpreter has not been linked in.";
+    if (ErrorStr)
+      *ErrorStr = "Interpreter has not been linked in.";
     return 0;
   }
-  
+
+  if ((WhichEngine & EngineKind::JIT) && ExecutionEngine::JITCtor == 0) {
+    if (ErrorStr)
+      *ErrorStr = "JIT has not been linked in.";
+  }    
   return 0;
 }