Load the symbols first so that the interpreter constructor can find them when
authorNick Lewycky <nicholas@mxc.ca>
Sat, 8 Mar 2008 02:49:45 +0000 (02:49 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Sat, 8 Mar 2008 02:49:45 +0000 (02:49 +0000)
it tries to initialize them.

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

lib/ExecutionEngine/ExecutionEngine.cpp

index 8796a2d2e6c94382e0f3653794a93a2fc9ab6532..95df900a4bd2a0bd6e3e17c3007917152d0c4ff0 100644 (file)
@@ -317,6 +317,11 @@ ExecutionEngine *ExecutionEngine::create(ModuleProvider *MP,
                                          std::string *ErrorStr) {
   ExecutionEngine *EE = 0;
 
+  // Make sure we can resolve symbols in the program as well. The zero arg
+  // to the function tells DynamicLibrary to load the program, not a library.
+  if (sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr))
+    return 0;
+
   // Unless the interpreter was explicitly selected, try making a JIT.
   if (!ForceInterpreter && JITCtor)
     EE = JITCtor(MP, ErrorStr);
@@ -325,15 +330,6 @@ ExecutionEngine *ExecutionEngine::create(ModuleProvider *MP,
   if (EE == 0 && InterpCtor)
     EE = InterpCtor(MP, ErrorStr);
 
-  if (EE) {
-    // Make sure we can resolve symbols in the program as well. The zero arg
-    // to the function tells DynamicLibrary to load the program, not a library.
-    if (sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr)) {
-      delete EE;
-      return 0;
-    }
-  }
-
   return EE;
 }