Make sure targets are initialized before we do anything, even command line
authorDaniel Dunbar <daniel@zuster.org>
Thu, 16 Jul 2009 02:04:54 +0000 (02:04 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Thu, 16 Jul 2009 02:04:54 +0000 (02:04 +0000)
processing.

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

tools/llc/llc.cpp
tools/lli/lli.cpp

index 34587173ab97841cfca4d18fbffe7bc6762bb523..304638c52f7079664f7ca255b5c0902311be06e4 100644 (file)
@@ -210,10 +210,12 @@ int main(int argc, char **argv) {
   PrettyStackTraceProgram X(argc, argv);
   LLVMContext &Context = getGlobalContext();
   llvm_shutdown_obj Y;  // Call llvm_shutdown() on exit.
-  cl::ParseCommandLineOptions(argc, argv, "llvm system compiler\n");
 
+  // Initialize targets first.
   InitializeAllTargets();
   InitializeAllAsmPrinters();
+
+  cl::ParseCommandLineOptions(argc, argv, "llvm system compiler\n");
   
   // Load the module to be compiled...
   std::string ErrorMessage;
index 788aca01d6a09bd3c50b782c1cec3de4c91481cb..8afdbcad95b259cca86d6ba9d7af2a8e23433ac0 100644 (file)
@@ -96,6 +96,11 @@ int main(int argc, char **argv, char * const *envp) {
   
   LLVMContext &Context = getGlobalContext();
   atexit(do_shutdown);  // Call llvm_shutdown() on exit.
+
+  // If we have a native target, initialize it to ensure it is linked in and
+  // usable by the JIT.
+  InitializeNativeTarget();
+
   cl::ParseCommandLineOptions(argc, argv,
                               "llvm interpreter & dynamic compiler\n");
 
@@ -142,10 +147,6 @@ int main(int argc, char **argv, char * const *envp) {
   case '3': OLvl = CodeGenOpt::Aggressive; break;
   }
   
-  // If we have a native target, initialize it to ensure it is linked in and
-  // usable by the JIT.
-  InitializeNativeTarget();
-
   EE = ExecutionEngine::create(MP, ForceInterpreter, &ErrorMsg, OLvl);
   if (!EE) {
     if (!ErrorMsg.empty())